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


PHP JRegistryFormat类代码示例

本文整理汇总了PHP中JRegistryFormat的典型用法代码示例。如果您正苦于以下问题:PHP JRegistryFormat类的具体用法?PHP JRegistryFormat怎么用?PHP JRegistryFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testObjectToString

	/**
	 * Test the JRegistryFormatJSON::objectToString method.
	 *
	 * @return void
	 */
	public function testObjectToString()
	{
		$class = JRegistryFormat::getInstance('JSON');
		$options = null;
		$object = new stdClass;
		$object->foo = 'bar';
		$object->quoted = '"stringwithquotes"';
		$object->booleantrue = true;
		$object->booleanfalse = false;
		$object->numericint = 42;
		$object->numericfloat = 3.1415;

		// The PHP registry format does not support nested objects
		$object->section = new stdClass;
		$object->section->key = 'value';
		$object->array = array('nestedarray' => array('test1' => 'value1'));

		$string = '{"foo":"bar","quoted":"\"stringwithquotes\"",' .
			'"booleantrue":true,"booleanfalse":false,' .
			'"numericint":42,"numericfloat":3.1415,' .
			'"section":{"key":"value"},' .
			'"array":{"nestedarray":{"test1":"value1"}}' .
			'}';

		// Test basic object to string.
		$this->assertThat(
			$class->objectToString($object, $options),
			$this->equalTo($string)
		);
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:35,代码来源:JRegistryFormatJsonTest.php

示例2: testGetInstance

	/**
	 * Test the JRegistryFormat::getInstance method.
	 */
	public function testGetInstance()
	{
		// Test INI format.
		$object = JRegistryFormat::getInstance('INI');
		$this->assertThat(
			$object instanceof JRegistryFormatIni,
			$this->isTrue()
		);

		// Test JSON format.
		$object = JRegistryFormat::getInstance('JSON');
		$this->assertThat(
			$object instanceof JRegistryFormatJson,
			$this->isTrue()
		);

		// Test PHP format.
		$object = JRegistryFormat::getInstance('PHP');
		$this->assertThat(
			$object instanceof JRegistryFormatPHP,
			$this->isTrue()
		);

		// Test XML format.
		$object = JRegistryFormat::getInstance('XML');
		$this->assertThat(
			$object instanceof JRegistryFormatXml,
			$this->isTrue()
		);
	}
开发者ID:realityking,项目名称:JAJAX,代码行数:33,代码来源:JRegistryFormatTest.php

示例3: testStringToObject

	/**
	 * Test the JRegistryFormatPHP::stringToObject method.
	 *
	 * @return void
	 */
	public function testStringToObject()
	{
		$class = JRegistryFormat::getInstance('PHP');

		// This method is not implemented in the class. The test is to achieve 100% code coverage
		$this->assertTrue($class->stringToObject(''));
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:12,代码来源:JRegistryFormatPhpTest.php

示例4: testStringToObject

 /**
  * Test the JRegistryFormatINI::stringToObject method.
  *
  * @return void
  */
 public function testStringToObject()
 {
     $class = JRegistryFormat::getInstance('INI');
     $string2 = "[section]\nfoo=bar";
     $object1 = new stdClass();
     $object1->foo = 'bar';
     $object2 = new stdClass();
     $object2->section = $object1;
     // Test INI format string without sections.
     $object = $class->stringToObject($string2, array('processSections' => false));
     $this->assertThat($object, $this->equalTo($object1));
     // Test INI format string with sections.
     $object = $class->stringToObject($string2, array('processSections' => true));
     $this->assertThat($object, $this->equalTo($object2));
     // Test empty string
     $this->assertThat($class->stringToObject(null), $this->equalTo(new stdClass()));
     $string3 = "[section]\nfoo=bar\n;Testcomment\nkey=value\n\n/brokenkey=)brokenvalue";
     $object2->section->key = 'value';
     $this->assertThat($class->stringToObject($string3, array('processSections' => true)), $this->equalTo($object2));
     $string4 = "boolfalse=false\nbooltrue=true\nkeywithoutvalue\nnumericfloat=3.1415\nnumericint=42\nkey=\"value\"";
     $object3 = new stdClass();
     $object3->boolfalse = false;
     $object3->booltrue = true;
     $object3->numericfloat = 3.1415;
     $object3->numericint = 42;
     $object3->key = 'value';
     $this->assertThat($class->stringToObject($string4), $this->equalTo($object3));
     // Trigger the cache - Doing this only to achieve 100% code coverage. ;-)
     $this->assertThat($class->stringToObject($string4), $this->equalTo($object3));
 }
开发者ID:akirsoft,项目名称:joomla-cms,代码行数:35,代码来源:JRegistryFormatIniTest.php

示例5: stdclass

 /**
  * Logic for the event edit screen
  *
  * @access public
  * @return array
  * @since 0.9
  */
 function &getData()
 {
     if (empty($this->_data)) {
         $res = new stdclass();
         // original file
         $source = $this->getSource();
         $helper =& JRegistryFormat::getInstance('INI');
         $object = $helper->stringToObject(file_get_contents($source));
         $res->from = get_object_vars($object);
         // target file
         $path = $this->getTarget();
         MissingtAdminHelper::checkHistory($path);
         if (file_exists($path)) {
             $object = $helper->stringToObject(file_get_contents($path));
             $strings = get_object_vars($object);
             $present = array();
             foreach ($res->from as $k => $v) {
                 if (isset($strings[$k]) && !empty($strings[$k])) {
                     $present[$k] = $strings[$k];
                 }
             }
             $res->to = $present;
         } else {
             $res->to = array();
         }
         $this->_data = $res;
     }
     return $this->_data;
 }
开发者ID:julienV,项目名称:the-missing-T,代码行数:36,代码来源:file.php

示例6: testStringToObject

	/**
	 * Test the JRegistryFormatXML::stringToObject method.
	 *
	 * @return void
	 */
	public function testStringToObject()
	{
		$class = JRegistryFormat::getInstance('XML');
		$object = new stdClass;
		$object->foo = 'bar';
		$object->booleantrue = true;
		$object->booleanfalse = false;
		$object->numericint = 42;
		$object->numericfloat = 3.1415;
		$object->section = new stdClass;
		$object->section->key = 'value';
		$object->array = array('test1' => 'value1');

		$string = "<?xml version=\"1.0\"?>\n<registry>" .
			"<node name=\"foo\" type=\"string\">bar</node>" .
			"<node name=\"booleantrue\" type=\"boolean\">1</node>" .
			"<node name=\"booleanfalse\" type=\"boolean\"></node>" .
			"<node name=\"numericint\" type=\"integer\">42</node>" .
			"<node name=\"numericfloat\" type=\"double\">3.1415</node>" .
			"<node name=\"section\" type=\"object\">" .
			"<node name=\"key\" type=\"string\">value</node>" .
			"</node>" .
			"<node name=\"array\" type=\"array\">" .
			"<node name=\"test1\" type=\"string\">value1</node>" .
			"</node>" .
			"</registry>\n";

		// Test basic object to string.
		$this->assertThat(
			$class->stringToObject($string),
			$this->equalTo($object)
		);
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:38,代码来源:JRegistryFormatXmlTest.php

示例7: stringToObject

 function stringToObject($data)
 {
     $data = JString::trim($data);
     if (JString::substr($data, 0, 1) != '{' && JString::substr($data, -1, 1) != '}') {
         $object = JRegistryFormat::getInstance('INI')->stringToObject($data);
     } else {
         $object = json_decode($data);
     }
     return $object;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:10,代码来源:json.php

示例8: __construct

 /**
  * Constructor.
  *
  * @param mixed $dispatcher A dispatcher
  * @param array $config     An optional KConfig object with configuration options.
  *
  * @return void
  */
 public function __construct($dispatcher = null, $config = array())
 {
     if (isset($config['params'])) {
         $config = (array) JRegistryFormat::getInstance('ini')->stringToObject($config['params']);
     }
     $config = new KConfig($config);
     parent::__construct($config);
     $this->_params = $config;
     KService::set('plg:storage.default', $this);
 }
开发者ID:walteraries,项目名称:anahita,代码行数:18,代码来源:abstract.php

示例9: __construct

 /**
  * Class Constructor
  * 
  * @param array|object $data The data to be converted to JRegistry format
  * 
  * @since 1.0.0
  */
 public function __construct($data = array())
 {
     if ($data instanceof JRegistry) {
         $data = $data->toArray();
     } else {
         if (is_string($data) && substr($data, 0, 1) != '{' && substr($data, -1, 1) != '}') {
             $data = JRegistryFormat::getInstance('INI')->stringToObject($data);
         }
     }
     parent::__construct($data);
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:18,代码来源:parameter.php

示例10: stringToObject

 /**
  * Parse a JSON formatted string and convert it into an object.
  *
  * If the string is not in JSON format, this method will attempt to parse it as INI format.
  *
  * @param   string  $data     JSON formatted string to convert.
  * @param   array   $options  Options used by the formatter.
  *
  * @return  object   Data object.
  *
  * @since   11.1
  */
 public function stringToObject($data, array $options = array('processSections' => false))
 {
     $data = trim($data);
     if (substr($data, 0, 1) != '{' && substr($data, -1, 1) != '}') {
         $ini = JRegistryFormat::getInstance('INI');
         $obj = $ini->stringToObject($data, $options);
     } else {
         $obj = json_decode($data);
     }
     return $obj;
 }
开发者ID:ZerGabriel,项目名称:joomla-platform,代码行数:23,代码来源:json.php

示例11: _convertToIni

 function _convertToIni($array)
 {
     $handlerIni =& JRegistryFormat::getInstance('INI');
     $object = new StdClass();
     foreach ($array as $k => $v) {
         if (strpos($k, 'KEY_') === 0) {
             $key = substr($k, 4);
             $object->{$key} = $v;
         }
     }
     $string = $handlerIni->objectToString($object, null);
     return $string;
 }
开发者ID:julienV,项目名称:the-missing-T,代码行数:13,代码来源:helper.php

示例12: _sanitize

 /**
  * Sanitize a value
  *
  * @param   scalar  Value to be sanitized
  * @return  string
  */
 protected function _sanitize($value)
 {
     $result = null;
     $handler = JRegistryFormat::getInstance('INI');
     if ($value instanceof KConfig) {
         $value = $value->toArray();
     }
     if (is_string($value)) {
         $result = $handler->stringToObject($value);
     }
     if (is_null($result)) {
         $result = $handler->objectToString((object) $value, null);
     }
     return $result;
 }
开发者ID:JSWebdesign,项目名称:intranet-platform,代码行数:21,代码来源:ini.php

示例13: stringToObject

 /**
  * Parse a JSON formatted string and convert it into an object.
  *
  * If the string is not in JSON format, this method will attempt to parse it as INI format.
  *
  * @param   string  $data     JSON formatted string to convert.
  * @param   array   $options  Options used by the formatter.
  *
  * @return  object   Data object.
  *
  * @since   11.1
  */
 public function stringToObject($data, $options = array('processSections' => false))
 {
     // Fix legacy API.
     if (is_bool($options)) {
         $options = array('processSections' => $options);
         // Deprecation warning.
         JLog::add('JRegistryFormatJSON::stringToObject() second argument should not be a boolean.', JLog::WARNING, 'deprecated');
     }
     $data = trim($data);
     if (substr($data, 0, 1) != '{' && substr($data, -1, 1) != '}') {
         $ini = JRegistryFormat::getInstance('INI');
         $obj = $ini->stringToObject($data, $options);
     } else {
         $obj = json_decode($data);
     }
     return $obj;
 }
开发者ID:joomline,项目名称:Joomla2.5.999,代码行数:29,代码来源:json.php

示例14: testGetInstance

	/**
	 * Test the JRegistryFormat::getInstance method.
	 *
	 * @return void
	 */
	public function testGetInstance()
	{
		// Test INI format.
		$object = JRegistryFormat::getInstance('INI');
		$this->assertThat(
			$object instanceof JRegistryFormatIni,
			$this->isTrue()
		);

		// Test JSON format.
		$object = JRegistryFormat::getInstance('JSON');
		$this->assertThat(
			$object instanceof JRegistryFormatJson,
			$this->isTrue()
		);

		// Test PHP format.
		$object = JRegistryFormat::getInstance('PHP');
		$this->assertThat(
			$object instanceof JRegistryFormatPHP,
			$this->isTrue()
		);

		// Test XML format.
		$object = JRegistryFormat::getInstance('XML');
		$this->assertThat(
			$object instanceof JRegistryFormatXml,
			$this->isTrue()
		);

		// Test non-existing format.
		try
		{
			$object = JRegistryFormat::getInstance('SQL');
		}
		catch (Exception $e)
		{
			return;
		}
		$this->fail('JRegistryFormat should throw an exception in case of non-existing formats');
	}
开发者ID:robschley,项目名称:joomla-platform,代码行数:46,代码来源:JRegistryFormatTest.php

示例15: fwdtofriend

 public static function fwdtofriend($action, $task)
 {
     jimport('joomla.html.parameter');
     $mainframe = JFactory::getApplication();
     JPluginHelper::importPlugin('jnews');
     $plugin = JPluginHelper::getPlugin('jnews', 'forwardtofriend');
     $registry = new JRegistry();
     if (!method_exists($registry, 'loadString')) {
         $data = trim($plugin->params);
         $options = array('processSections' => false);
         if (substr($data, 0, 1) != '{' && substr($data, -1, 1) != '}') {
             $ini = JRegistryFormat::getInstance('INI');
             $obj = $ini->stringToObject($data, $options);
         } else {
             $obj = json_decode($data);
         }
         $registry->loadObject($obj);
     } else {
         $registry->loadString($plugin->params);
     }
     $params = $registry;
     if ($task == 'sendtofriend') {
         $new = false;
         $mailingID = JRequest::getInt('mailingid');
         $html = JRequest::getInt('html');
         $html1 = $html ? 'true' : 'false';
         $mailing = new stdClass();
         $mailing = jNews_Mailing::getOneMailing('', $mailingID, '', $new, $html1);
         //&$new
         $mailing->fromname = JRequest::getVar('fromName');
         $mailing->fromemail = JRequest::getVar('fromEmail');
         $mailing->frombounce = JRequest::getVar('fromEmail');
         $mailing->id = $mailingID;
         $mailing->issue_nb = 0;
         $mailing->images = '';
         $mailing->attachments = '';
         $receiversNames = JRequest::getVar('toName', array(), '', 'array');
         $receiversEmails = JRequest::getVar('toEmail', array(), '', 'array');
         $message = new stdClass();
         $message->dflt = JRequest::getVar('message');
         $message->inEmail = JRequest::getVar('inEmailMessage');
         //need to get it from the URL/request
         $list = new stdClass();
         $list->id = JRequest::getInt('listid');
         $list->html = $html;
         $botResult = $mainframe->triggerEvent('jnewsbot_sendtofriend', array($mailing, $message, $receiversNames, $receiversEmails, $list));
         if (empty($plugin)) {
             echo '<center><span style="font-size: 1.3em;">The <strong>jNews: Forward to friend</strong> plugin is either not installed or published. Click <a target="_blank" href="administrator/index.php?option=com_plugins&client=site&filter_type=jnews">here</a> to check if it\'s installed or published.</span></center>';
         }
     } else {
         $botResult = $mainframe->triggerEvent('jnewsbot_fwdtofriend', array($params));
         if (empty($plugin)) {
             echo '<center><span style="font-size: 1.3em;">The <strong>jNews: Forward to friend</strong> plugin is either not installed or published. Click <a target="_blank" href="administrator/index.php?option=com_plugins&client=site&filter_type=jnews">here</a> to check if it\'s installed or published.</span></center>';
         }
     }
 }
开发者ID:naka211,项目名称:kkvn,代码行数:56,代码来源:frontend.php


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