• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP JRegistryFormat类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: processLanguageINI

 protected static function processLanguageINI($files, $sections = array(), $filter = '')
 {
     $data = array();
     foreach ((array) $files as $file) {
         $ini = false;
         $content = file_get_contents($file);
         if ($content) {
             if (function_exists('parse_ini_string')) {
                 $ini = @parse_ini_string($content, true);
             } else {
                 $registry = JRegistryFormat::getInstance('INI');
                 $obj = $registry->stringToObject($content, true);
                 $ini = self::object_to_array($obj);
             }
         }
         if ($ini && is_array($ini)) {
             // only include these keys
             if (!empty($sections)) {
                 $ini = array_intersect_key($ini, array_flip($sections));
             }
             // filter keys by regular expression
             if ($filter) {
                 foreach (array_keys($ini) as $key) {
                     if (preg_match('#' . $filter . '#', $key)) {
                         unset($ini[$key]);
                     }
                 }
             }
             $data = array_merge($data, $ini);
         }
     }
     $output = '';
     if (!empty($data)) {
         $x = 0;
         foreach ($data as $key => $strings) {
             if (is_array($strings)) {
                 $output .= '"' . strtolower($key) . '":{';
                 $i = 0;
                 foreach ($strings as $k => $v) {
                     if (is_numeric($v)) {
                         $v = (double) $v;
                     } else {
                         $v = '"' . $v . '"';
                     }
                     // key to lowercase
                     $k = strtolower($k);
                     // get position of the section name in the key if any
                     $pos = strpos($k, $key . '_');
                     // remove the section name
                     if ($pos === 0) {
                         $k = substr($k, strlen($key) + 1);
                     }
                     // hex colours to uppercase and remove marker
                     if (strpos($k, 'hex_') !== false) {
                         $k = strtoupper(str_replace('hex_', '', $k));
                     }
                     // create key/value pair as JSON string
                     $output .= '"' . $k . '":' . $v . ',';
                     $i++;
                 }
                 // remove last comma
                 $output = rtrim(trim($output), ',');
                 $output .= "},";
                 $x++;
             }
         }
         // remove last comma
         $output = rtrim(trim($output), ',');
     }
     return $output;
 }
开发者ID:01J,项目名称:topm,代码行数:71,代码来源:language.php


示例17: toString

 /**
  * Get a namespace in a given string format
  *
  * @param	string	Format to return the string in
  * @param	mixed	Parameters used by the formatter, see formatters for more info
  * @return	string	Namespace in string format
  * @since	1.5
  */
 public function toString($format = 'JSON', $options = array())
 {
     // Return a namespace in a given format
     $handler = JRegistryFormat::getInstance($format);
     return $handler->objectToString($this->data, $options);
 }
开发者ID:Joomla-on-NoSQL,项目名称:LaMojo,代码行数:14,代码来源:registry.php


示例18: toString

 /**
  * Get a namespace in a given string format
  *
  * @access	public
  * @param	string	$format		Format to return the string in
  * @param	string	$namespace	Namespace to return [optional: null returns the default namespace]
  * @param	mixed	$params		Parameters used by the formatter, see formatters for more info
  * @return	string	Namespace in string format
  * @since	1.5
  */
 function toString($format = 'INI', $namespace = null, $params = null)
 {
     // Return a namespace in a given format
     $handler =& JRegistryFormat::getInstance($format);
     // If namespace is not set, get the default namespace
     if ($namespace == null) {
         $namespace = $this->_defaultNameSpace;
     }
     // Get the namespace
     $ns =& $this->_registry[$namespace]['data'];
     return $handler->objectToString($ns, $params);
 }
开发者ID:Fellah,项目名称:govnobaki,代码行数:22,代码来源:registry.php


示例19: onAfterStoreUser

 function onAfterStoreUser($user, $isnew, $success, $msg)
 {
     if ($success === false) {
         return false;
     }
     if (strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13)) == 'administrator') {
         $adminPath = strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13));
     } else {
         $adminPath = JPATH_ROOT;
     }
     if (!@(include_once $adminPath . DS . 'components' . DS . 'com_jnews' . DS . 'defines.php')) {
         return;
     }
     include_once JNEWSPATH_CLASS . 'class.jnews.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.subscribers.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.listssubscribers.php';
     jimport('joomla.html.parameter');
     $plugin = JPluginHelper::getPlugin('user', 'jnewssyncuser');
     $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;
     $db = JFactory::getDBO();
     $subscriber = new stdClass();
     $confirmed = 1;
     if ($user['block']) {
         $confirmed = 0;
     }
     $subscriber->email = trim(strip_tags($user['email']));
     if (!empty($user['name'])) {
         $subscriber->name = trim(strip_tags($user['name']));
     }
     if (empty($user['block'])) {
         $subscriber->confirmed = 1;
     }
     $subscriber->user_id = $user['id'];
     $subscriber->ip = jNews_Subscribers::getIP();
     $subscriber->receive_html = 1;
     $subscriber->confirmed = $confirmed;
     $subscriber->subscribe_date = time();
     $subscriber->language_iso = 'eng';
     $subscriber->timezone = '00:00:00';
     $subscriber->blacklist = 0;
     //check if the version of jnews is pro
     if ($GLOBALS[JNEWS . 'level'] > 2) {
         $subscriber->column1 = '';
         $subscriber->column2 = '';
         $subscriber->column3 = '';
         $subscriber->column4 = '';
         $subscriber->column5 = '';
     }
     //end if check if the version is pro
     if (!$isnew and !empty($this->oldUser['email']) and $user['email'] != $this->oldUser['email']) {
         $d['email'] = $this->oldUser['email'];
         $infos = jNews_Subscribers::getSubscriberIdFromEmail($this->oldUser);
         $subscriber->id = $infos['subscriberId'];
     }
     if ($isnew) {
         //new registered user
         $status = jNews_Subscribers::saveSubscriber($subscriber, $subscriber->user_id, true);
         if (empty($subscriber->id)) {
             $subscriber->id = jNews_Subscribers::getSubscriberIdFromUserId($subscriber->user_id);
         }
         if (!$status) {
             return;
         }
         $listsToSubscribe = $params->get('lists', '');
         if (!empty($listsToSubscribe)) {
             $condition = ' WHERE `id` IN (' . $listsToSubscribe . ')';
         } else {
             $condition = ' WHERE `auto_add` > 0';
         }
         //get list ids of auto_add lists
         $query = 'SELECT `id`, `list_type`, `params` from `#__jnews_lists`' . $condition;
         $db->setQuery($query);
         $autoListId = $db->loadObjectList();
         $error = $db->getErrorMsg();
         if (!empty($error)) {
             echo $error;
             return false;
         } else {
             //use for masterlists
             $listsA = array();
             foreach ($autoListId as $autoId) {
                 if (!empty($autoId->params)) {
                     //use for masterlists
                     $listsA[] = $autoId->id;
                 } else {
                     //for non-masterlists
//.........这里部分代码省略.........
开发者ID:naka211,项目名称:kkvn,代码行数:101,代码来源:jnewssyncuser.php


示例20: onAfterRoute

 function onAfterRoute()
 {
     $redirectlink = trim(JRequest::getString('redirectlink'));
     $fromSubscribe = JRequest::getVar('fromSubscribe', '');
     // this is either we have a redirect setup or we come from the module
     if (empty($fromSubscribe) || empty($redirectlink)) {
         return '';
     }
     if (strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13)) == 'administrator') {
         $adminPath = strtolower(substr(JPATH_ROOT, strlen(JPATH_ROOT) - 13));
     } else {
         $adminPath = JPATH_ROOT;
     }
     if (!@(include_once $adminPath . DS . 'components' . DS . 'com_jnews' . DS . 'defines.php')) {
         return;
     }
     include_once JNEWSPATH_CLASS . 'class.jnews.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.subscribers.php';
     require_once JNEWS_JPATH_ROOT_NO_ADMIN . DS . 'administrator' . DS . 'components' . DS . JNEWS_OPTION . DS . 'classes' . DS . 'class.listssubscribers.php';
     jimport('joomla.html.parameter');
     $db = JFactory::getDBO();
     $plugin = JPluginHelper::getPlugin('system', 'vmjnewssubs');
     $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;
     $reqfield = $params->get('reqfield', 'user_email');
     $email = JRequest::getString('email');
     $reqvalue = $reqfield == 'user_email' ? $email : JRequest::get($reqfield);
     if (is_array($reqvalue)) {
         //if we find any no we do no
         if (empty($reqvalue)) {
             return '';
         }
         foreach ($reqvalue as $resultArVal) {
             if (empty($resultArVal)) {
                 return '';
             }
         }
     } else {
         if (empty($reqvalue) || empty($email) || in_array(strtolower($reqvalue), array('', '0', 'n', 'no', 'none', 'nein', 'non'))) {
             return;
         }
     }
     $user_id = JRequest::getInt('user_id');
     $email = trim(strip_tags($email));
     $fname = JRequest::getString('first_name', '');
     $mname = JRequest::getString('middle_name', '');
     $lname = JRequest::getString('last_name', '');
     $name = '';
     if (!empty($fname)) {
         $name .= $fname . ' ';
     }
     if (!empty($mname)) {
         $name .= $mname . ' ';
     }
     if (!empty($lname)) {
         $name .= $lname;
     }
     $name = trim($name);
     if (empty($name)) {
         $name = JRequest::getVar('username');
     }
     $subscriber = new stdClass();
     $subscriber->user_id = $user_id;
     $subscriber->name = $name;
     $subscriber->email = $email;
     $subscriber->ip = jNews_Subscribers::getIP();
     $subscriber->receive_html = 1;
     $subscriber->confirmed = $GLOBALS[JNEWS . 'require_confirmation'] == '1' ? 0 : 1;
     $subscriber->subscribe_date = time();
     $subscriber->language_iso = 'eng';
     $subscriber->timezone = '00:00:00';
     $subscriber->blacklist = 0;
     $subscriber->params = '';
     $subscriber->admin_id = 62;
     $status = jNews_Subscribers::saveSubscriber($subscriber, $user_id, true);
     if (!$status) {
         return;
     }
     $listsToSubscribe = $params->get('lists', '');
     $listsToSubscribe = str_replace(' ', '', $listsToSubscribe);
     if (!empty($listsToSubscribe)) {
         $condition = ' WHERE `id` IN (' . $listsToSubscribe . ')';
     } else {
         $condition = '';
     }
     $query = 'SELECT `id`, `list_type`,`params` from `#__jnews_lists`' . $condition;
     $db->setQuery($query);
//.........这里部分代码省略.........
开发者ID:naka211,项目名称:kkvn,代码行数:101,代码来源:vmjnewssubs.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP JRequest类代码示例发布时间:2022-05-23
下一篇:
PHP JRegistry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap