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


PHP Citruscart::dump方法代码示例

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


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

示例1: toXml

 /**
  * The main function for converting to an XML document.
  * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
  *
  * @param  array $data
  * @param  string $rootNodeName - what you want the root node to be - defaultsto data.
  * @param  SimpleXMLElement $xml - should only be used recursively
  * @param  array $namespaces - the namespaces (like $namespace[] = array('url' => 'http://....', 'name' => 'xmlns:g')
  */
 public function toXml($data, $rootNodeName = 'data', &$xml = null, $namespaces = null, $root_ns = null)
 {
     // First call: create document and root node
     if (is_null($xml)) {
         $this->doc = new DOMDocument('1.0', 'utf8');
         // Root namespace
         if ($root_ns) {
             $root = $this->doc->createElementNS($root_ns, $rootNodeName);
         }
         $xml =& $root;
         $this->doc->appendChild($root);
         // Namespaces
         foreach ($namespaces as $ns) {
             $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:' . $ns['name'], $ns['url']);
         }
     }
     // loop though the array
     foreach ($data as $key => $value) {
         // normal list of nodes
         if (is_numeric($key)) {
             $key = $rootNodeName;
         }
         // Attributes support
         if ($key == $this->attr_arr_string) {
             // Add attributes to node
             foreach ($value as $attr_name => $attr_value) {
                 $att = $this->doc->createAttribute($attr_name);
                 $xml->appendChild($att);
                 $att->appendChild($this->doc->createTextNode($attr_value));
             }
         } else {
             // Add the value if there was a value together with the att
             if ($key == $this->value_string) {
                 // Add value to node
                 $xml->appendChild($this->doc->createTextNode($value));
             } else {
                 // delete any char not allowed in XML element names
                 $key = preg_replace('/[^a-z0-9\\-\\_\\.\\:]/i', '', $key);
                 // if there is another array found recrusively call this function
                 if (is_array($value)) {
                     // create a new node unless this is an array of elements
                     if ($this->isAssoc($value)) {
                         $node = $this->doc->createElement($key);
                         $xml->appendChild($node);
                     } else {
                         $node = $xml;
                     }
                     // recrusive call - pass $key as the new rootNodeName
                     $this->toXml($value, $key, $node);
                 } else {
                     // Add a single value
                     $value = htmlentities($value);
                     $t = $this->doc->createElement($key);
                     $xml->appendChild($t);
                     $v = $this->doc->createTextNode($value);
                     $t->appendChild($v);
                 }
             }
         }
     }
     $this->doc->formatOutput = true;
     echo Citruscart::dump($this->doc->saveXML());
     return $this->doc->saveXML();
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:73,代码来源:xml.php

示例2: saveattributeoptionvalues

 /**
  * Saves the properties for all attribute option values in list
  *
  * @return unknown_type
  */
 function saveattributeoptionvalues()
 {
     JPluginHelper::importPlugin('citruscart');
     $app = JFactory::getApplication();
     $error = false;
     $this->messagetype = '';
     $this->message = '';
     $model = $this->getModel('productattributeoptionvalues');
     $row = $model->getTable();
     $id = $app->input->getInt('id', 0);
     $cids = $app->input->get('cid', array(0), 'request', 'array');
     $field = $app->input->get('field', array(0), 'request', 'array');
     $operator = $app->input->get('operator', array(0), 'request', 'array');
     $value = $app->input->get('value', array(0), 'request', 'array');
     foreach ($cids as $cid) {
         $row->load($cid);
         $row->productattributeoptionvalue_field = $field[$cid];
         $row->productattributeoptionvalue_operator = $operator[$cid];
         $row->productattributeoptionvalue_value = $value[$cid];
         echo Citruscart::dump($row);
         if (!$row->check() || !$row->store()) {
             $this->message .= $row->getError();
             $this->messagetype = 'notice';
             $error = true;
         }
     }
     $row->reorder();
     $productModel = $this->getModel('products');
     $productModel->clearCache();
     if ($error) {
         $this->message = JText::_('COM_CITRUSCART_ERROR') . " - " . $this->message;
     } else {
         $this->message = JText::_('COM_CITRUSCART_PRODUCT_OPTIONVALUES_SAVED_SUCCESSFULLY');
         $this->messagetype = "Message";
     }
     $redirect = "index.php?option=com_citruscart&view=products&task=setattributeoptionvalues&id={$id}&tmpl=component";
     $redirect = JRoute::_($redirect, false);
     $app->redirect($redirect, $this->message, $this->messagetype);
     //$this->setRedirect( $redirect, $this->message, $this->messagetype );
 }
开发者ID:joomlacorner,项目名称:citruscart,代码行数:45,代码来源:products.php


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