当前位置: 首页>>代码示例>>PHP>>正文


PHP domDocument::createElement方法代码示例

本文整理汇总了PHP中domDocument::createElement方法的典型用法代码示例。如果您正苦于以下问题:PHP domDocument::createElement方法的具体用法?PHP domDocument::createElement怎么用?PHP domDocument::createElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在domDocument的用法示例。


在下文中一共展示了domDocument::createElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addModel

function addModel($node)
{
    $document = new domDocument("1.0", "utf-8");
    $document->load("test3.xml");
    if ($node == "telefon") {
        $nameEl = "Телефон";
    }
    if ($node == "noutbuk") {
        $nameEl = "Ноутбук";
    }
    if ($node == "printer") {
        $nameEl = "Принтер";
    }
    if ($_POST["marka"] != "" && $_POST["year"] != "") {
        $element = $document->getElementsByTagName($node)->item(0);
        $model = $document->createElement("model");
        $element->appendChild($model);
        $name = $document->createElement("name", $_POST["marka"]);
        $model->appendChild($name);
        $year = $document->createElement("year", $_POST["year"]);
        $model->appendChild($year);
        $document->save("test3.xml");
        echo "<p style='padding:10px; background:#C3FFD2;'>" . $nameEl . " Удачно добавлен!</p>";
    } else {
        echo "<p style='padding:10px; background:#FFF0F0;'>Не удалось добавить " . $nameEl . ", так как не все поля были заполнены!</p>";
    }
}
开发者ID:echmaster,项目名称:data,代码行数:27,代码来源:dz.php

示例2: addUser

		public function addUser(){
			$document = new domDocument();
			$document->load("users/users.xml");
			$root = $document->getElementsByTagName("users")->item(0);
			$user = $root->appendChild(new domElement("user"));
			$user->appendChild($document->createElement("login", "$this->login"));
			$user->appendChild($document->createElement("password","$this->pass"));
			$document->save("users/users.xml");
		}
开发者ID:echmaster,项目名称:data,代码行数:9,代码来源:User.php

示例3: addElement

 /**
  * Adds an child element to the parent
  * @param string The name element
  * @param domNode 
  * @return domNode
  */
 private function addElement($name, $parent = false, $ns = false)
 {
     if ($ns) {
         $el = $this->doc->createElementNS($ns, $name);
     } else {
         $el = $this->doc->createElement($name);
     }
     if ($parent) {
         $parent->appendChild($el);
     }
     return $el;
 }
开发者ID:medali1990,项目名称:medsite,代码行数:18,代码来源:WSDLStruct.class.php

示例4: actionGetUserNotify

 public function actionGetUserNotify($email)
 {
     header("Content-Type: text/xml");
     $performer = 9;
     $notify = Notify::model()->findAll(array('condition' => 'performer_id=:performer_id', 'limit' => '3', 'params' => array(':performer_id' => $performer)));
     $dom = new domDocument("1.0", "cp1251");
     // Создаём XML-документ версии 1.0 с кодировкой utf-8
     $root = $dom->createElement("notifys");
     // Создаём корневой элемент
     $dom->appendChild($root);
     foreach ($notify as $n) {
         $notify = $dom->createElement("notify");
         $header = $dom->createElement("header", $n->header);
         $description = $dom->createElement("description", strip_tags($n->description));
         $link = $dom->createElement("link", Notify::getCreateXmlUrl($n->route, $n->route_params));
         $notify->appendChild($header);
         $notify->appendChild($description);
         $notify->appendChild($link);
         $root->appendChild($notify);
     }
     $import = simplexml_import_dom($dom);
     echo $import->asXML();
 }
开发者ID:bookin,项目名称:yii-notification-center,代码行数:23,代码来源:NotifyController.php

示例5: createXML

 /**
  * Get XML by Array
  *
  * @param array $ar
  * @param array $options []
  *                       root_tag   - root tag wraping body xml (example root - <root>...</root>)
  *                       format     - true/false (formatting output XML)
  *                       version    - XML version (<?xml version="1"?>)
  *                       encode     - XML encode (<?xml encode="UTF-8"?>)
  *                       nohead     - XML output without "<?xml" header
  *
  * @return string
  */
 public static function createXML(array $ar, $options = array())
 {
     $root_tag = isset($options['root_tag']) ? $options['root_tag'] : 'root';
     $format = isset($options['format']) ? $options['format'] : true;
     $version = isset($options['version']) ? $options['version'] : '1.0';
     $encode = isset($options['encode']) ? $options['encode'] : 'UTF-8';
     $nohead = isset($options['nohead']) ? $options['nohead'] : false;
     $dom = new domDocument($version, $encode);
     $root = $dom->appendChild($dom->createElement($root_tag));
     self::createXMLElement($dom, $root, $ar);
     $dom->formatOutput = $format;
     if ($nohead) {
         return $dom->saveXML($root);
     }
     return $dom->saveXML();
 }
开发者ID:sfedosimov,项目名称:SimpleXMLTool,代码行数:29,代码来源:SimpleXMLTool.php

示例6: getTextBetweenTags

 /**
  *
  * @get text between tags
  * @param string $tag The tag name
  * @param string $html The XML or XHTML string
  * @param int $strict Whether to use strict mode
  * @param string $encoding
  * @return array
  */
 private function getTextBetweenTags($tag, $html, $strict = 0, $encoding = "UTF-8")
 {
     global $PAGE, $CFG;
     if (!isset($CFG->filter_jsxgraph_divid)) {
         set_config('filter_jsxgraph_divid', 'box');
     }
     if (!isset($CFG->filter_jsxgraph_boardvar)) {
         set_config('filter_jsxgraph_boardvar', 'board');
     }
     if (!isset($CFG->filter_jsxgraph_width)) {
         set_config('filter_jsxgraph_width', '500');
     }
     if (!isset($CFG->filter_jsxgraph_height)) {
         set_config('filter_jsxgraph_height', '400');
     }
     // a new dom object
     $dom = new domDocument();
     $dom->formatOutput = true;
     // load the html into the object
     if ($strict == 1) {
         $dom->loadXML($html);
     } else {
         libxml_use_internal_errors(true);
         $htmlutf8 = mb_convert_encoding($html, 'HTML-ENTITIES', $encoding);
         $dom->loadHTML($htmlutf8);
         libxml_use_internal_errors(false);
     }
     // discard white space
     $dom->preserveWhiteSpace = false;
     $dom->strictErrorChecking = false;
     $dom->recover = true;
     // the tag by its tag name
     $content = $dom->getElementsByTagname($tag);
     if (count($content) > 0) {
         $PAGE->requires->js(new moodle_url($CFG->wwwroot . '/filter/jsxgraph/jsxgraphcore.js'));
     }
     // Iterate backwards through the jsxgraph tags
     $i = $content->length - 1;
     while ($i > -1) {
         $item = $content->item($i);
         // Read attributes
         $w = $item->getAttribute('width');
         if ($w == "") {
             $w = $CFG->filter_jsxgraph_width;
         }
         $h = $item->getAttribute('height');
         if ($h == "") {
             $h = $CFG->filter_jsxgraph_height;
         }
         $b = $item->getAttribute('box');
         if ($b == "") {
             $b = $CFG->filter_jsxgraph_divid . $i;
         }
         $brd = $item->getAttribute('board');
         if ($brd == "") {
             $brd = $CFG->filter_jsxgraph_boardvar . $i;
         }
         /* Create new div element containing JSXGraph */
         $out = $dom->createElement('div');
         $a = $dom->createAttribute('id');
         $a->value = $b;
         $out->appendChild($a);
         $a = $dom->createAttribute('class');
         $a->value = "jxgbox";
         $out->appendChild($a);
         $a = $dom->createAttribute('style');
         $a->value = "width:" . $w . "px; height:" . $h . "px; ";
         $out->appendChild($a);
         $t = $dom->createTextNode("");
         $out->appendChild($t);
         $out = $dom->appendChild($out);
         // Replace <jsxgraph> by <div>
         $item->parentNode->replaceChild($out, $item);
         $code = "";
         $needGXT = false;
         $url = $item->getAttribute('file');
         if ($url != "") {
             $code = "var " . $brd . " = JXG.JSXGraph.loadBoardFromFile('" . $b . "', '" . $url . "', 'Geonext');";
             $needGXT = true;
         } else {
             $url = $item->getAttribute('filestring');
             if ($url != "") {
                 $code = "var " . $brd . " = JXG.JSXGraph.loadBoardFromString('" . $b . "', '" . $url . "', 'Geonext');";
                 $needGXT = true;
             } else {
                 // Plain JavaScript code
                 $code = $item->nodeValue;
             }
         }
         // Place JavaScript code at the end of the page.
         $PAGE->requires->js_init_call($code);
//.........这里部分代码省略.........
开发者ID:zelenkoff,项目名称:projectmath,代码行数:101,代码来源:filter.php

示例7: xml

 protected function xml($datafeed, $filename)
 {
     $this->load->helper('download');
     $dom = new domDocument("1.0", "utf-8");
     $root = $dom->createElement("items");
     $dom->appendChild($root);
     foreach ($datafeed as $feed) {
         if ($feed->ic_id == "") {
             continue;
         }
         $feed->ic_retail_price = trim($feed->ic_retail_price) == '' || $feed->ic_retail_price == 0 ? $feed->ic_price * 3 : $feed->ic_retail_price;
         $item = $dom->createElement("item");
         $item->setAttribute("id", $feed->ic_id);
         $params = array();
         $params['SKU'] = $dom->createElement("SKU", $feed->SKU);
         $params['Barcode'] = $dom->createElement("Barcode", $feed->upc_ean);
         $params['Manufacturer_Part_Number'] = $dom->createElement("Manufacturer_Part_Number", $feed->manuf_num);
         $params['Manufacturer_Name'] = $dom->createElement("Manufacturer_Name", $feed->m_name);
         $params['Brand_Name'] = $dom->createElement("Brand_Name", $feed->b_name);
         $params['Title'] = $dom->createElement("Title", $feed->tr_title);
         $params['Description'] = $dom->createElement("Description", htmlspecialchars(strip_tags($feed->tr_desc)));
         $params['Category_ID'] = $dom->createElement("Category_ID", $feed->c_id);
         $params['Category_Name'] = $dom->createElement("Category_Name", htmlspecialchars($this->getFullCategoryName($feed->c_id)));
         $params['Weight'] = $dom->createElement("Weight", $feed->weight + " " + $feed->weightScale);
         $params['Ship_Alone'] = $dom->createElement("Ship_Alone", $feed->ship_alone);
         $params['Height'] = $dom->createElement("Height", $feed->d_height + " " + $feed->d_scale);
         $params['Width'] = $dom->createElement("Width", $feed->d_width + " " + $feed->d_scale);
         $params['Depth'] = $dom->createElement("Depth", $feed->d_dept + " " + $feed->d_scale);
         $params['LeadTime'] = $dom->createElement("LeadTime", $feed->ic_leadtime);
         $params['Quantity_In_Stock'] = $dom->createElement("Quantity_In_Stock", $feed->ic_quan);
         $params['Selling_Price'] = $dom->createElement("Selling_Price", $feed->ic_price);
         $params['MSRP'] = $dom->createElement("MSRP", $feed->ic_retail_price);
         $params['Promo_Text'] = $dom->createElement("Promo_Text", $feed->ic_prom_text);
         $params['MAP'] = $dom->createElement("MAP", $feed->ic_map);
         $params['Shipping_Cost'] = $dom->createElement("Shipping_Cost", $feed->ic_ship_cost);
         $params['Min_Order'] = $dom->createElement("Min_Order", $feed->ic_min_order);
         $params['Case_Pack'] = $dom->createElement("Case_Pack", $feed->ic_case_pack);
         $this->load->model('inventories');
         $image_list = $this->inventories->list_image($feed->i_id);
         $images = $dom->createElement("images");
         foreach ($image_list as $image) {
             $pic_name = $dom->createElement("image", "http://shop.oceantailer.com/" . $image->ii_link);
             $images->appendChild($pic_name);
         }
         foreach ($params as $param) {
             $item->appendChild($param);
         }
         $item->appendChild($images);
         $root->appendChild($item);
     }
     $dom->save($filename);
     return;
 }
开发者ID:rnlduadia,项目名称:LAMP-eCommerce-CodeIgniter,代码行数:53,代码来源:buyers_cron.php

示例8: domDocument

         $day[$count] = $attr4[$count]['day'];
         $low[$count] = $attr4[$count]['low'];
         $high[$count] = $attr4[$count]['high'];
         $text1[$count] = $attr4[$count]['text'];
         //echo "result here".$day[$count];
         $count++;
     }
 }
 /************************************************create xml********************************************/
 try {
     /*** a new dom object ***/
     $dom = new domDocument();
     /*** make the output tidy ***/
     $dom->formatOutput = true;
     /*** create the root element ***/
     $root = $dom->appendChild($dom->createElement("weather"));
     /*** create the simple xml element ***/
     $sxe = simplexml_import_dom($dom);
     /*** add a feed element ***/
     $sxe->addChild("feed", $url_weather);
     /*** add a link element ***/
     $sxe->addChild("link", $link);
     /*** add a location element ***/
     $loc = $sxe->addChild("location");
     /*** add attributes ***/
     $loc->addAttribute("city", $city);
     $loc->addAttribute("region", $region);
     $loc->addAttribute("country", $country);
     /*** add a unit element***/
     $uni = $sxe->addChild("units");
     /*** add attributes ***/
开发者ID:harshs08,项目名称:WeatherApps,代码行数:31,代码来源:index.php

示例9: nl2br

<?php

$dom = new domDocument('1.0');
$dom->load(dirname(__FILE__) . "/thedata.xml");
$new_item = $dom->createElement('item');
$new_item->setAttribute("id", 1234);
// set attribute id for new item
foreach (array('title', 'link', 'description') as $v) {
    $node = $dom->createElement($v);
    $node->appendChild($dom->createTextNode($v));
    $new_item->appendChild($node);
}
// append entry to existing forum entries
$dom->documentElement->appendChild($new_item);
$xml = $dom->saveXML();
echo nl2br(htmlspecialchars(str_replace('><', ">\n<", $xml)));
开发者ID:SandyS1,项目名称:presentations,代码行数:16,代码来源:dom_modify.php

示例10: domDocument

<?php

error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
$dom = new domDocument("1.0", "utf-8");
// Создаём XML-документ версии 1.0 с кодировкой utf-8
$root = $dom->createElement("rss");
// Создаём корневой элемент
$root->setAttribute("version", "2.0");
$dom->appendChild($root);
$chanel = $dom->createElement("channel");
$dom->appendChild($chanel);
$root->appendChild($chanel);
$title = $dom->createElement("title", "Лента сайта WEIRD WORLD");
$dom->appendChild($title);
$chanel->appendChild($title);
$link = $dom->createElement("link", "http://weird-world.ru");
$dom->appendChild($link);
$chanel->appendChild($link);
$description = $dom->createElement("description", "Описание");
$dom->appendChild($description);
$chanel->appendChild($description);
include "../include/connection.php";
$result = mysql_query("SELECT * FROM articles WHERE visible='1'", $db);
if (mysql_num_rows($result) > 0) {
    do {
        $item = $dom->createElement("item");
        $dom->appendChild($item);
        $chanel->appendChild($item);
        $title = $dom->createElement("title", htmlspecialchars_decode($row["title"]));
        $dom->appendChild($title);
        $item->appendChild($title);
开发者ID:VitaAprel,项目名称:easytesting,代码行数:31,代码来源:feedparse.php

示例11: domDocument

<bureau>
\t<userburo>
\t</userburo>
</bureau>
XML;
$dom = new domDocument();
$dom->loadXML($xmlPrefs);
if (!$dom) {
    echo 'Erreur de traitement XML';
    exit;
}
$frstN = array("wallpaper", "pos_wallpaper", "iconsize", "iconsfield", "bgcolor", "quicklaunch", "s_idart", "winsize", "data");
$liste = $dom->getElementsByTagName('userburo');
$neud = $liste->item(0);
foreach ($frstN as $thisN) {
    ${$thisN} = $dom->createElement($thisN);
    ${$thisN}->appendChild($dom->createTextNode($_POST[$thisN]));
    $neud->appendChild(${$thisN});
}
foreach ($_POST['icons'] as $k => $val) {
    $noeud = $liste->item(0);
    $node = $dom->createElement("icon");
    foreach ($val as $k1 => $val1) {
        $icon_x = $dom->createElement($k1, $val1);
        $node->appendchild($icon_x);
    }
    $noeud->appendChild($node);
}
$s = simplexml_import_dom($dom);
// ecriture du fichier
$filexml = 'PREFS_' . $login . '.xml';
开发者ID:rhertzog,项目名称:lcs,代码行数:31,代码来源:save_prefs.php

示例12: domDocument

<?php

include '../Config/db.php';
header("content-type: text/xml");
$dom = new domDocument("1.0", "CP1251");
$root = $dom->createElement("Orders");
$dom->appendChild($root);
$query = mysql_query(@"SELECT\n                          orders.*,\n                          users.name,\n                          users.email,\n                          users.phone,\n                          users.company,\n                          warehouses.keycode AS wh_key,\n                          pricetypes.keycode AS pt_key\n                        FROM orders\n                        LEFT JOIN users ON orders.user_id = users.id\n                        LEFT JOIN warehouses ON users.wh_id = warehouses.id\n                        LEFT JOIN pricetypes ON users.pt_id = pricetypes.id\n                        WHERE orders.status = 1 AND orders.sync = 0");
while ($do = mysql_fetch_array($query)) {
    $order = $dom->createElement("Order");
    $number = $dom->createElement("Number", $do['id']);
    $wh = $dom->createElement("WH", $do['wh_key']);
    $pt = $dom->createElement("PT", $do['pt_key']);
    $clientID = $dom->createElement("ClientID", $do['user_id']);
    $clientName = $dom->createElement("ClientName", $do['name']);
    $clientCompany = $dom->createElement("Company", $do['company']);
    $email = $dom->createElement("Email", $do['email']);
    $phone = $dom->createElement("Phone", $do['phone']);
    $comment = $dom->createElement("Comment", $do['comment']);
    $products = $dom->createElement("Products");
    $pquery = mysql_query("SELECT cart.*, products.keycode, categories.expected FROM cart LEFT JOIN products ON cart.product_id = products.id LEFT JOIN categories ON products.category_id = categories.id WHERE order_id = '" . $do['id'] . "'");
    while ($pdo = mysql_fetch_array($pquery)) {
        $product = $dom->createElement("Product");
        $article = $dom->createElement("Key", $pdo['keycode']);
        $quantity = $dom->createElement("Quantity", $pdo['quantity']);
        $price = $dom->createElement("Price", $pdo['price']);
        $expected = $dom->createElement("ThisExpected", $pdo['expected']);
        $product->appendChild($article);
        $product->appendChild($quantity);
        $product->appendChild($price);
        $product->appendChild($expected);
开发者ID:anton-kol,项目名称:buelo,代码行数:31,代码来源:getorders.php

示例13: domDocument

</SET_OF_SOLUTIONS>
<SET_OF_RELATED_PATTERNS>
</SET_OF_RELATED_PATTERNS>
<PATTERN_IDENTIFICATION>
</PATTERN_IDENTIFICATION>
</Patern>';
$doc = new domDocument();
$doc->loadXML($anXMLString);
$key = key($resultQuery);
$val = current($resultQuery);
$nbrValues = count($resultQuery);
while (list($key, $val) = each($resultQuery)) {
    if (!is_array($val)) {
        switch ($key) {
            case $key == 'pattern_name':
                $newnode = $doc->createElement($key, $val);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('GENERAL')->item(0);
                $add->appendChild($newnode);
                break;
            case $key == 'pattern_abstract':
                $newnode = $doc->createElement($key, $val);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('GENERAL')->item(0);
                $add->appendChild($newnode);
                break;
            case $key == 'pattern_desc':
                $newnode = $doc->createElement($key, $val);
                $doc->appendChild($newnode);
                $add = $doc->getElementsByTagName('GENERAL')->item(0);
                $add->appendChild($newnode);
开发者ID:laiello,项目名称:dp-navigator,代码行数:31,代码来源:createXml7.php

示例14: remove

 public static function remove($subscriber, $subscriberId, $cle = '')
 {
     $db = JFactory::getDBO();
     $listUnsubA = array();
     //unsubscribe listIds
     $allAvailableListsA = JRequest::getVar('sub_list_id', '');
     $unsubListValA = JRequest::getVar('unsubscribed', '');
     $textarea_msg = JRequest::getVar('textareamess', ' ', 'post');
     foreach ($allAvailableListsA as $key => $unsublist) {
         if (!empty($unsubListValA[$key]) == 1) {
             $listidUnsubA[] = $unsublist;
         }
     }
     if (!empty($subscriberId) and !empty($cle)) {
         if (md5($subscriber->email) == $cle) {
             if (!empty($listidUnsubA)) {
                 $query = 'UPDATE `#__jnews_listssubscribers` SET ';
                 $query .= ' `unsubdate`=' . time();
                 $query .= ' ,`unsubscribe`=1';
                 $query .= ' WHERE `subscriber_id`= ' . $subscriberId;
                 $query .= ' AND `list_id` IN (' . implode(',', $listidUnsubA) . ')';
                 $db->setQuery($query);
                 $result = $db->query();
                 $query = 'SELECT * FROM `#__jnews_lists` WHERE `id` IN (' . implode(',', $listidUnsubA) . ')';
                 $db->setQuery($query);
                 $listsO = $db->loadObjectList();
             }
             //check if we have subscription to any auto-responder
             $query = 'SELECT `id` FROM `#__jnews_lists` ';
             $query .= ' WHERE `list_type`= 2 ';
             $query .= ' AND `id` IN (' . implode(',', $listidUnsubA) . ')';
             $db->setQuery($query);
             $loadResultArray = $db->loadObjectList();
             $autoRespondListA = jnews::convertObjectList2Array($loadResultArray);
             if (!empty($autoRespondListA)) {
                 $query = 'DELETE FROM `#__jnews_queue` ';
                 $query .= ' WHERE `subscriber_id`= ' . $subscriberId;
                 $query .= ' AND `mailing_id` IN ( SELECT `mailing_id` FROM `#__jnews_listmailings` WHERE `list_id` IN (' . implode(',', $autoRespondListA) . ') )';
                 $db->setQuery($query);
                 $db->query();
             }
             foreach ($listsO as $key => $list) {
                 //we send the unsubscription notification to the subscriber if it is turn to yes
                 if ($list->unsubscribesend == 1) {
                     jNews_ProcessMail::sendUnsubcribeEmail($subscriber, $subscriberId, $list);
                 }
                 //we send the unsubscription notification to the list owner if it is turn to yes
                 if ($GLOBALS[JNEWS . 'level'] > 2 && $list->unsubscribenotifyadmin == 1 && !empty($list->notifyadminmsg) && !empty($list->owner)) {
                     $my = JFactory::getUser($list->owner);
                     if ($list->notifyadminmsg != "") {
                         $dom = new domDocument();
                         $dom->preserveWhiteSpace = false;
                         $dom->formatOutput = true;
                         if ($dom->loadHTML("<html><body>" . $list->notifyadminmsg . "</body></html>")) {
                             $xpath = new DOMXpath($dom);
                             $elements = $xpath->query("/html/descendant::*[contains(text(),'LISTNAME')]/..");
                             if (!is_null($elements)) {
                                 $feedback = _JNEWS_UNSUBSCRIBE_MESSAGE_TEXTAREA_TITLE;
                                 foreach ($elements as $element) {
                                     $item = $dom->createElement("span", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $feedback);
                                     $br = $dom->createElement('br');
                                     $item->insertBefore($br);
                                     $titlespace = $dom->createElement("span", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $textarea_msg);
                                     $item->appendChild($titlespace);
                                     if ($element->nextSibling != null) {
                                         $appen = $element->nextSibling;
                                     } else {
                                         $appen = $element;
                                     }
                                     if ($element->parentNode != null) {
                                         $inss = $element->parentNode;
                                     } else {
                                         $inss = $element;
                                     }
                                     $inss->insertBefore($item, $appen);
                                 }
                                 $dom->formatOutput = true;
                                 $lisnotifyadminmsg = $dom->saveHTML();
                             }
                             $res_search = preg_match("/(?:<body[^>]*>)(.*)<\\/body>/isU", $lisnotifyadminmsg, $matches);
                             if ($res_search > 0 && isset($matches[1]) && $matches[1] !== "") {
                                 $list->notifyadminmsg = $matches[1];
                             }
                         }
                     }
                 }
                 jNews_ProcessMail::sendNotification($list->notifyadminmsg, $subscriber, $my, $list, JNEWS_SITE_NAME . ' ' . _JNEWS_UNSUBS_NOTIFYSUBJECT);
             }
             if (!empty($GLOBALS[JNEWS . 'unsubscribe_notification'])) {
                 $listOfAdminA = explode(',', $GLOBALS[JNEWS . 'unsubscribe_notification']);
                 if (!empty($listOfAdminA)) {
                     foreach ($listOfAdminA as $oneAdmin) {
                         if (empty($oneAdmin)) {
                             continue;
                         }
                         $owner = new stdClass();
                         $owner->name = $oneAdmin;
                         $owner->email = $oneAdmin;
                         jNews_ProcessMail::sendNotification(_JNEWS_UNSUBSCRIBE_ADMIN_NOTIFICATION, $newSubscriber, $owner, $list, JNEWS_SITE_NAME . ' ' . _JNEWS_UNSUBS_NOTIFYSUBJECT);
                     }
//.........这里部分代码省略.........
开发者ID:naka211,项目名称:kkvn,代码行数:101,代码来源:frontend.php

示例15: calculate

 public function calculate()
 {
     $weight = $this->getTotalWeight() > 0 ? $this->getTotalWeight() : $this->avg_weight;
     $city = $this->getAddress('city') . ', ' . $this->getAddress('region');
     if ($city == '') {
         $services = 'Не задан город';
         return $services;
     }
     if (!extension_loaded('curl')) {
         $services = 'PHP extension CURL not loaded';
         return $services;
     }
     $dom = new domDocument("1.0", "utf-8");
     $root = $dom->createElement("request");
     $dom->appendChild($root);
     $child = $dom->createElement("function", "get_delivery_price");
     $root->appendChild($child);
     $child = $dom->createElement("api_id", $this->api_id);
     $root->appendChild($child);
     $child = $dom->createElement("from_city", $this->from_city_code_id);
     $root->appendChild($child);
     $child = $dom->createElement("to_city", $city);
     $root->appendChild($child);
     $child = $dom->createElement("pickup_place", 0);
     $root->appendChild($child);
     $child = $dom->createElement("weight", $weight);
     $root->appendChild($child);
     $child = $dom->createElement("order_price", $this->getTotalPrice());
     $root->appendChild($child);
     $child = $dom->createElement("num", $this->avg_num);
     $root->appendChild($child);
     $child = $dom->createElement("tarifs_type", 1);
     $root->appendChild($child);
     $child = $dom->createElement("price_options", 1);
     $root->appendChild($child);
     $child = $dom->createElement("delivery_partner", $this->partner);
     $root->appendChild($child);
     $res = $this->sendRequest($dom->saveXML());
     try {
         $xml = new SimpleXMLElement($res);
     } catch (Exception $e) {
         return 'Ошибка получения данных';
     }
     $price = (double) $xml->price;
     if ($xml->error_code > 0) {
         return "В заданный город доставка не осуществляется";
     }
     if ($xml->srok_dostavki != '') {
         $srok_dostavki = $xml->srok_dostavki . ' дн.';
     }
     $services['sl_courier'] = array('name' => 'до дверей', 'description' => '', 'id' => 'sl_courier', 'est_delivery' => $srok_dostavki, 'rate' => $price, 'currency' => 'RUB');
     return $services;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:53,代码来源:shoplogisticscourierShipping.class.php


注:本文中的domDocument::createElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。