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


PHP JFactory::getXml方法代码示例

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


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

示例1: getManifest

 /**
  * Retrieves the settings from the entry view
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getManifest($file, $hasInherit = true)
 {
     $parser = JFactory::getXml($file);
     $fieldsets = array();
     foreach ($parser->fields as $field) {
         foreach ($field->fieldset as $row) {
             $fieldset = new stdClass();
             $attributes = $row->attributes();
             $fieldset->name = (string) $attributes['name'];
             $fieldset->info = (string) $attributes['info'];
             $fieldset->label = (string) $attributes['label'];
             $fieldset->fields = array();
             // Skip anything without a label.
             if (!$fieldset->label) {
                 continue;
             }
             // Go through each of the fields
             foreach ($row->field as $fieldItem) {
                 $field = new stdClass();
                 $field->attributes = new stdClass();
                 $field->options = array();
                 foreach ($fieldItem->attributes() as $key => $value) {
                     $field->attributes->{$key} = (string) $value;
                 }
                 // If user wants to skip this option altogether.
                 if (isset($field->attributes->globals) && !$field->attributes->globals) {
                     continue;
                 }
                 foreach ($fieldItem->option as $optionItem) {
                     $option = new stdClass();
                     $option->label = (string) $optionItem;
                     foreach ($optionItem->attributes() as $optionKey => $optionValue) {
                         $option->{$optionKey} = (string) $optionValue;
                         $field->options[] = $option;
                     }
                 }
                 // If the xml file contains such attributes, we assume that the user wants to render a boolean field
                 // This is only applicable if the field has maximum of 2 option
                 if ($field->attributes->type == 'radio' && $field->attributes->class == 'btn-group') {
                     $field->attributes->type = 'boolean';
                 }
                 $fieldset->fields[] = $field;
             }
             $fieldsets[] = $fieldset;
         }
     }
     return $fieldsets;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:56,代码来源:form.php

示例2: getManifest

 /**
  * Retrieves the settings from the entry view
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function getManifest($file)
 {
     $parser = JFactory::getXml($file);
     $fieldsets = array();
     foreach ($parser->fields as $field) {
         foreach ($field->fieldset as $row) {
             $fieldset = new stdClass();
             $attributes = $row->attributes();
             $fieldset->name = (string) $attributes['name'];
             $fieldset->info = (string) $attributes['info'];
             $fieldset->label = (string) $attributes['label'];
             $fieldset->fields = array();
             // Skip anything without a label.
             if (!$fieldset->label) {
                 continue;
             }
             foreach ($row->field as $fieldItem) {
                 $field = new stdClass();
                 $field->attributes = new stdClass();
                 $field->options = array();
                 foreach ($fieldItem->attributes() as $key => $value) {
                     $field->attributes->{$key} = (string) $value;
                 }
                 foreach ($fieldItem->option as $optionItem) {
                     $option = new stdClass();
                     $option->label = (string) $optionItem;
                     foreach ($optionItem->attributes() as $optionKey => $optionValue) {
                         $option->{$optionKey} = (string) $optionValue;
                         $field->options[] = $option;
                     }
                 }
                 $fieldset->fields[] = $field;
             }
             $fieldsets[] = $fieldset;
         }
     }
     return $fieldsets;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:46,代码来源:form.php

示例3: getModulesList

 private function getModulesList($path, $tmp)
 {
     $info = $this->getInfo();
     $zip = $path . '/modules.zip';
     $state = JArchive::extract($zip, $tmp);
     // @TODO: Return errors
     if (!$state) {
         return false;
     }
     // Get a list of modules
     $items = JFolder::folders($tmp, '.', false, true);
     $modules = array();
     foreach ($items as $item) {
         $element = basename($item);
         $manifest = $item . '/' . $element . '.xml';
         // Read the xml file
         $parser = JFactory::getXml($manifest);
         $module = new stdClass();
         $module->title = (string) $parser->name;
         $module->version = (string) $parser->version;
         $module->description = (string) $parser->description;
         $module->description = trim($module->description);
         $module->element = $element;
         $modules[] = $module;
     }
     return $modules;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:27,代码来源:addons.list.php

示例4: testGetXml

 /**
  * Tests the JFactory::getXML method.
  *
  * @return  void
  *
  * @since   12.2
  */
 public function testGetXml()
 {
     $xml = JFactory::getXml('<foo />', false);
     $this->assertInstanceOf('SimpleXMLElement', $xml, 'Line: ' . __LINE__);
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:12,代码来源:JFactoryTest.php

示例5: testLoad_BadInput

 /**
  * Test the JForm::load method for cases of unexpected or bad input.
  *
  * This method can load an XML data object, or parse an XML string.
  */
 public function testLoad_BadInput()
 {
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(123), $this->isFalse(), 'Line:' . __LINE__ . ' A non-string should return false.');
     $this->assertThat($form->load('junk'), $this->isFalse(), 'Line:' . __LINE__ . ' An invalid string should return false.');
     $this->assertThat($form->getXml(), $this->isNull(), 'Line:' . __LINE__ . ' The internal XML should be false as returned from simplexml_load_string.');
     $this->assertThat($form->load('<notform><test /></notform>'), $this->isTrue(), 'Line:' . __LINE__ . ' Invalid root node name from string should still load.');
     $this->assertThat($form->getXml()->getName(), $this->equalTo('form'), 'Line:' . __LINE__ . ' The internal XML should still be named "form".');
     // Test for irregular object input.
     $form = new JFormInspector('form1');
     $this->assertThat($form->load(JFactory::getXml('<notform><test /></notform>', false)), $this->isTrue(), 'Line:' . __LINE__ . ' Invalid root node name from XML object should still load.');
     $this->assertThat($form->getXml()->getName(), $this->equalTo('form'), 'Line:' . __LINE__ . ' The internal XML should still be named "form".');
 }
开发者ID:Joomla-on-NoSQL,项目名称:LaMojo,代码行数:18,代码来源:JFormTest.php

示例6: getPobocky

 public static function getPobocky(&$params, $cache = true)
 {
     if (isset(self::$pobocky_cache)) {
         return self::$pobocky_cache;
     }
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $retfalse = new stdClass();
     $document = JFactory::getDocument();
     if ($cache) {
         if (!file_exists(JPATH_ROOT . DS . 'cache' . DS . 'ulozenka')) {
             if (@JFolder::create(JPATH_ROOT . DS . 'cache' . DS . 'ulozenka') === false) {
                 return $retfalse;
             }
         }
     }
     $ts_filename = JPATH_ROOT . DS . 'cache' . DS . 'ulozenka' . DS . 'timestamp.txt';
     $filename = JPATH_ROOT . DS . 'cache' . DS . 'ulozenka' . DS . 'pobocky.xml';
     $url = 'http://www.ulozenka.cz/partner/pobocky.php?key=' . $params->key . '&partners=' . $params->partners;
     $time = time();
     if (!$cache) {
         require_once dirname(__FILE__) . DS . 'api.php';
         $request = new ulozenkaApi($params);
         $data = $request->getPobocky();
     } else {
         /*
         	if (file_exists(JPATH_CACHE.DS.'ulozenka'.DS.'ulozenkaobj.php'))
         	 //include(JPATH_CACHE.DS.'ulozenka'.DS.'ulozenkaobj.php'); 
         	 $data = file_get_contents(JPATH_CACHE.DS.'ulozenka'.DS.'ulozenkaobj.php'); 
         	 if (eval('?>'.$data.'<?php')!==false)
         	 {
         	  if (!empty($retObj)) return $retObj; 
              }
         */
         if (file_exists($filename)) {
         } else {
             require_once dirname(__FILE__) . DS . 'api.php';
             $request = new ulozenkaApi($params);
             $data = $request->getPobocky();
             if (!empty($data)) {
                 JFile::write($filename, $data);
                 JFile::write($ts_filename, $time);
             }
         }
     }
     if ($cache) {
         if (!JFile::exists($filename)) {
             return $retfalse;
         }
     }
     if (!function_exists('simplexml_load_file')) {
         return $retfalse;
     }
     if ($cache) {
         $xml = JFactory::getXml($filename);
         //$xml = simplexml_load_file($filename, "SimpleXMLElement", true);
         if (empty($xml)) {
             JFile::delete($ts_filename);
             JFile::delete($filename);
             return $retfalse;
         }
     } else {
         if (empty($data)) {
             $retfalse->error = $request->error;
             return $retfalse;
         }
         //$xml = simplexml_load_string($data, "SimpleXMLElement", true);
         $xml = JFactory::getXml($data, false);
     }
     if (empty($xml)) {
         $xml = new stdClass();
     }
     $copy = new stdClass();
     $copy->pobocky = array();
     $copy->branch = $xml->branch;
     if (isset($request->error)) {
         $copy->error = (string) $request->error;
     }
     if (isset($xml->branch)) {
         foreach ($xml->branch as $p) {
             self::br2p($copy->pobocky, $p);
         }
         self::$pobocky_cache = $copy;
         if ($cache) {
             self::saveObj($copy);
         }
         return $copy;
     }
     // if (isset($xml->body)) $copy->body = (string)$xml->error;
     if (isset($xml->pobocky)) {
         if (count($xml->pobocky)) {
             foreach ($xml->pobocky as $pobocka) {
                 $newpobocka = new stdClass();
                 $ac = (array) $pobocka;
                 foreach ($ac as $key => $val) {
                     $newpobocka->{$key} = $val;
                 }
                 $copy->pobocky[] = $newpobocka;
             }
             if (isset($xml->error)) {
//.........这里部分代码省略.........
开发者ID:aldegtyarev,项目名称:stelsvelo,代码行数:101,代码来源:helper.php


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