本文整理汇总了PHP中JRegistry::loadJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP JRegistry::loadJSON方法的具体用法?PHP JRegistry::loadJSON怎么用?PHP JRegistry::loadJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRegistry
的用法示例。
在下文中一共展示了JRegistry::loadJSON方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
JLoader::import('joomla.filesystem.file');
// $isPro = defined('ARS_PRO') ? (ARS_PRO == 1) : false;
// Load the component parameters, not using JComponentHelper to avoid conflicts ;)
JLoader::import('joomla.html.parameter');
JLoader::import('joomla.application.component.helper');
$db = JFactory::getDbo();
$sql = $db->getQuery(true)->select($db->quoteName('params'))->from($db->quoteName('#__extensions'))->where($db->quoteName('type') . ' = ' . $db->quote('component'))->where($db->quoteName('element') . ' = ' . $db->quote('com_j2store'));
$db->setQuery($sql);
$rawparams = $db->loadResult();
$params = new JRegistry();
if (version_compare(JVERSION, '3.0', 'ge')) {
$params->loadString($rawparams, 'JSON');
} else {
$params->loadJSON($rawparams);
}
// Dev releases use the "newest" strategy
if (substr($this->_currentVersion, 1, 2) == 'ev') {
$this->_versionStrategy = 'newest';
} else {
$this->_versionStrategy = 'vcompare';
}
// Get the minimum stability level for updates
$this->_minStability = $params->get('minstability', 'stable');
// Do we need authorized URLs?
$this->_requiresAuthorization = false;
// Should I use our private CA store?
if (@file_exists(dirname(__FILE__) . '/../assets/cacert.pem')) {
$this->_cacerts = dirname(__FILE__) . '/../assets/cacert.pem';
}
parent::__construct();
}
示例2: getItem
/**
* Method to get a category.
*
* @param integer An optional id of the object to get, otherwise the id from the model state is used.
* @return mixed Category data object on success, false on failure.
* @since 1.6
*/
public function getItem($pk = null)
{
if ($result = parent::getItem($pk)) {
// Prime required properties.
if (empty($result->id)) {
$result->parent_id = $this->getState('category.parent_id');
$result->extension = $this->getState('category.extension');
}
// Convert the metadata field to an array.
$registry = new JRegistry();
$registry->loadJSON($result->metadata);
$result->metadata = $registry->toArray();
// Convert the created and modified dates to local user time for display in the form.
jimport('joomla.utilities.date');
$tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
if (intval($result->created_time)) {
$date = new JDate($result->created_time);
$date->setTimezone($tz);
$result->created_time = $date->toMySQL(true);
} else {
$result->created_time = null;
}
if (intval($result->modified_time)) {
$date = new JDate($result->modified_time);
$date->setTimezone($tz);
$result->modified_time = $date->toMySQL(true);
} else {
$result->modified_time = null;
}
}
return $result;
}
示例3: getContact
/**
* Gets a list of contacts
* @param array
* @return mixed Object or null
*/
function getContact($pk = null)
{
$query = $this->_getContactQuery($pk);
try {
$this->_db->setQuery($query);
$result = $this->_db->loadObject();
if ($error = $this->_db->getErrorMsg()) {
throw new Exception($error);
}
if (empty($result)) {
throw new Exception(JText::_('Contact_Error_Contact_not_found'), 404);
}
// Convert parameter fields to object and merge with menu item params
$registry = new JRegistry();
$registry->loadJSON($result->params);
$result->mergedParams = clone $this->getState('params');
$result->mergedParams->merge($registry);
} catch (Exception $e) {
$this->setError($e);
return false;
}
if ($result) {
$user =& JFactory::getUser();
$groups = implode(',', $user->authorisedLevels());
//get the content by the linked user
$query = 'SELECT id, title, state, access, created' . ' FROM #__content' . ' WHERE created_by = ' . (int) $result->user_id . ' AND access IN (' . $groups . ')' . ' ORDER BY state DESC, created DESC';
$this->_db->setQuery($query, 0, 10);
$articles = $this->_db->loadObjectList();
$contact->articles = $articles;
}
return $result;
}
示例4: render
/**
* Renders a module script and returns the results as a string
*
* @param string $name The name of the module to render
* @param array $attribs Associative array of values
*
* @return string The output of the script
* @since 1.0
*/
public function render($module, $attribs = array(), $content = null)
{
// add the environment data to attributes of module
$registry = JRegistry::getInstance('document.environment');
$env = $registry->getValue('params', array());
$attribs = array_merge($env, $attribs);
if (!is_object($module)) {
$title = isset($attribs['title']) ? $attribs['title'] : null;
$module = MigurModuleHelper::getModule($module, $title);
if (!is_object($module)) {
if (is_null($content)) {
return '';
} else {
/**
* If module isn't found in the database but data has been pushed in the buffer
* we want to render it
*/
$tmp = $module;
$module = new stdClass();
$module->params = null;
$module->module = $tmp;
$module->id = 0;
$module->user = 0;
}
}
}
// get the user and configuration object
//$user = JFactory::getUser();
$conf = JFactory::getConfig();
// set the module content
if (!is_null($content)) {
$module->content = $content;
}
//get module parameters
$params = new JRegistry();
$params->loadJSON($module->params);
// use parameters from template
if (isset($attribs['params'])) {
$template_params = new JRegistry();
$template_params->loadJSON(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
$params->merge($template_params);
$module = clone $module;
$module->params = (string) $params;
}
$contents = '';
$cachemode = $params->get('cachemode', 'oldstatic');
// default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the module instead
if ($params->get('cache', 0) == 1 && $conf->get('caching') >= 1 && $cachemode != 'id' && $cachemode != 'safeuri') {
// default to itemid creating mehod and workarounds on
$cacheparams = new stdClass();
$cacheparams->cachemode = $cachemode;
$cacheparams->class = 'JModuleHelper';
$cacheparams->method = 'renderModule';
$cacheparams->methodparams = array($module, $attribs);
$contents = MigurModuleHelper::ModuleCache($module, $params, $cacheparams);
} else {
$contents = MigurModuleHelper::renderModule($module, $attribs);
}
return $contents;
}
示例5: JRegistry
/**
* Method to get an item.
*
* @param integer The id of the item to get.
*
* @return mixed Item data object on success, false on failure.
*/
public function &getItem($itemId = null)
{
// Initialise variables.
$itemId = !empty($itemId) ? $itemId : (int) $this->getState('contact.id');
$false = false;
// Get a row instance.
$table =& $this->getTable();
// Attempt to load the row.
$return = $table->load($itemId);
// Check for a table object error.
if ($return === false && $table->getError()) {
$this->setError($table->getError());
return $false;
}
// Prime required properties.
if (empty($table->id)) {
$table->parent_id = $this->getState('item.parent_id');
//$table->menutype = $this->getState('item.menutype');
//$table->type = $this->getState('item.type');
}
// Convert the params field to an array.
$registry = new JRegistry();
$registry->loadJSON($table->params);
$table->params = $registry->toArray();
// Convert the params field to an array.
$registry = new JRegistry();
//$registry->loadJSON($table->metadata);
$table->metadata = $registry->toArray();
$value = JArrayHelper::toObject($table->getProperties(1), 'JObject');
return $value;
}
示例6: getCurrentTemplate
function getCurrentTemplate()
{
$cache = JFactory::getCache('com_rokcandy', '');
if (!($templates = $cache->get('templates'))) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, home, template, params');
$query->from('#__template_styles');
$query->where('client_id = 0');
$db->setQuery($query);
$templates = $db->loadObjectList('id');
foreach ($templates as &$template) {
$registry = new JRegistry();
$registry->loadJSON($template->params);
$template->params = $registry;
// Create home element
if ($template->home == '1' && !isset($templates[0])) {
$templates[0] = clone $template;
}
}
$cache->store($templates, 'templates');
}
$template = $templates[0];
return $template->template;
}
示例7: stdClass
/**
* Method to get article data.
*
* @param integer The id of the article.
*
* @return mixed Menu item data object on success, false on failure.
*/
public function &getItem ($pk = null)
{
$pk = 0;
$this->setState('article.id', $pk);
$this->_item[$pk] = new stdClass();
$registry = new JRegistry;
$registry->loadJSON('{}');
$this->_item[$pk]->params = $registry;
$this->_item[$pk]->attribs = $registry;
$this->_item[$pk]->metadata = $registry;
$this->_item[$pk]->title = '{post-title}';
$this->_item[$pk]->introtext = '{post-body}';
$this->_item[$pk]->fulltext = null;
$this->_item[$pk]->params->set('show_page_heading', 0);
$this->_item[$pk]->params->set('show_title', 1);
$this->_item[$pk]->params->set('access-view', true);
$this->_item[$pk]->params->set('access-edit', 0);
$this->_item[$pk]->params->set('show_print_icon', 0);
$this->_item[$pk]->params->set('show_email_icon', 0);
$this->_item[$pk]->params->set('show_author', 0);
$this->_item[$pk]->params->set('show_category', 0);
$this->_item[$pk]->params->set('show_parent_category', 0);
$this->_item[$pk]->params->set('show_create_date', 0);
$this->_item[$pk]->params->set('show_modify_date', 0);
$this->_item[$pk]->params->set('show_publish_date', 0);
$this->_item[$pk]->params->set('show_hits', 0);
$this->getState('params')->set('show_page_heading', 0);
return $this->_item[$pk];
}
示例8: getUserLang
function getUserLang($formName = 'language')
{
$user =& JFactory::getUser();
$paramsC = JComponentHelper::getParams('com_phocagallery');
$userLang = $paramsC->get('user_ucp_lang', 1);
$o = array();
switch ($userLang) {
case 2:
$registry = new JRegistry();
$registry->loadJSON($user->params);
$o['lang'] = $registry->get('language', '*');
$o['langinput'] = '<input type="hidden" name="' . $formName . '" value="' . $o['lang'] . '" />';
break;
case 3:
$o['lang'] = JFactory::getLanguage()->getTag();
$o['langinput'] = '<input type="hidden" name="' . $formName . '" value="' . $o['lang'] . '" />';
break;
default:
case 1:
$o['lang'] = '*';
$o['langinput'] = '<input type="hidden" name="' . $formName . '" value="*" />';
break;
}
return $o;
}
示例9: getPluginParamValues
function getPluginParamValues($name, $type = 'system')
{
jimport('joomla.plugin.plugin');
$plugin = JPluginHelper::getPlugin($type, $name);
$registry = new JRegistry();
$registry->loadJSON($plugin->params);
return $this->getParams($registry->toObject(), JPATH_PLUGINS . DS . $type . DS . $name . DS . $name . '.xml');
}
示例10: display
/**
* Display the view
*
* @return mixed False on error, null otherwise.
*/
function display($tpl = null)
{
$comName = JRequest::getCmd('option');
$document =& JFactory::getDocument();
$app = JFactory::getApplication();
$params = $app->getParams();
//Check whether category access level allows access.
$user = JFactory::getUser();
$groups = $user->getAuthorisedViewLevels();
//Load resources
$document->addStyleSheet($this->baseurl . "/media/{$comName}/css/styles.css");
//Get some data from the models
$state = $this->get('State');
$items = $this->get('Items');
$category = $this->get('Category');
$children = $this->get('Children');
$parent = $this->get('Parent');
$pagination = $this->get('Pagination');
//Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
//Prepare the data
//Compute the contact slug
for ($i = 0, $n = count($items); $i < $n; $i++) {
$item =& $items[$i];
$item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
$temp = new JRegistry();
$temp->loadJSON($item->params);
$item->params = clone $params;
$item->params->merge($temp);
if ($item->params->get('show_email', 0) == 1) {
$item->email_to = trim($item->email_to);
if (!empty($item->email_to) && JMailHelper::isEmailAddress($item->email_to)) {
$item->email_to = JHtml::_('email.cloak', $item->email_to);
} else {
$item->email_to = '';
}
}
}
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$maxLevel = $params->get('maxLevel', -1);
$this->assignRef('maxLevel', $maxLevel);
$this->assignRef('state', $state);
$this->assignRef('items', $items);
$this->assignRef('category', $category);
$this->assignRef('children', $children);
$this->assignRef('params', $params);
$this->assignRef('parent', $parent);
$this->assignRef('pagination', $pagination);
//define some few document params
$this->_prepareDocument();
//Display the view
parent::display($tpl);
}
示例11: JVersion
function init_all($context)
{
// Current version for infornation message
$this->botmtversion = 'Multithumb 3.7.3';
// Don't initialize anymore if plugin is disabled
$this->published = JPluginHelper::isEnabled('content', 'multithumb');
if (!$this->published) {
return;
}
$this->_live_site = JURI::base(true);
$this->jversion = new JVersion();
if (version_compare($this->jversion->getShortVersion(), '1.6.0', '>=')) {
$this->loadLanguage();
}
// Initialize paramters
$plugin = JPluginHelper::getPlugin('content', 'multithumb');
if (version_compare($this->jversion->getShortVersion(), '1.6.0', '>=')) {
$plugin = JPluginHelper::getPlugin('content', 'multithumb');
$params = new JRegistry();
if (version_compare($this->jversion->getShortVersion(), '3.0.0', '>=')) {
$params->loadString($plugin->params);
} else {
$params->loadJSON($plugin->params);
}
$this->init_params($params, $context);
} else {
$this->init_params(new JParameter($plugin->params), $context);
}
if ($this->_params->get('highslide_headers') == 2) {
$this->botAddMultiThumbHeader('highslide');
}
if ($this->_params->get('lightbox_headers') == 2) {
$this->botAddMultiThumbHeader('lightbox');
}
if ($this->_params->get('slimbox_headers') == 2) {
$this->botAddMultiThumbHeader('slimbox');
}
if ($this->_params->get('prettyphoto_headers') == 2) {
$this->botAddMultiThumbHeader('prettyPhoto');
}
if ($this->_params->get('shadowbox_headers') == 2) {
$this->botAddMultiThumbHeader('shadowbox');
}
if ($this->_params->get('jquery_headers') == 2) {
$this->botAddMultiThumbHeader('jquery');
}
if ($this->_params->get('iload_headers') == 2) {
$this->botAddMultiThumbHeader('iLoad');
}
if (!$this->_params->get('disable_image_cache_link') && !is_link(JPATH_BASE . "/images/multithumb_thumbs")) {
symlink(JPATH_CACHE . "/multithumb_thumbs", JPATH_BASE . "/images/multithumb_thumbs");
}
if ($this->_params->get('disable_image_cache_link') == 2 && is_link(JPATH_BASE . "/images/multithumb_thumbs")) {
unlink(JPATH_BASE . "/images/multithumb_thumbs");
}
}
示例12: getItem
public function getItem($pk = null)
{
if ($item = parent::getItem($pk)) {
// Convert the params field to an array.
$registry = new JRegistry();
$registry->loadJSON($item->metadata);
$item->metadata = $registry->toArray();
}
return $item;
}
示例13: load
/**
* Overloaded load function
*
* @param int $pk primary key
* @param boolean $reset reset data
* @return boolean
* @see JTable:load
*/
public function load($pk = null, $reset = true)
{
if (parent::load($pk, $reset)) {
// Convert the params field to a registry.
$params = new JRegistry();
$params->loadJSON($this->params);
$this->params = $params;
return true;
} else {
return false;
}
}
示例14: onBeforeBrowse
public function onBeforeBrowse()
{
$result = parent::onBeforeBrowse();
if ($result) {
$view = $this->getThisView();
$view->setModel($this->getThisModel(), true);
// Upgrade the database schema if necessary
$this->getThisModel()->checkAndFixDatabase();
// Migrate user data if necessary
$this->getThisModel()->autoMigrate();
// Refresh the update site definitions if required. Also takes into account any change of the Download ID
// in the Options.
/** @var AdmintoolsModelUpdates $updateModel */
$updateModel = F0FModel::getTmpInstance('Updates', 'AdmintoolsModel');
$updateModel->refreshUpdateSite();
// Is a Download ID needed but missing?
$needDLID = $this->getThisModel()->needsDownloadID();
$view->needsdlid = $needDLID;
// Check the last installed version and show the post-setup page on Joomla! 3.1 or earlier
if (!version_compare(JVERSION, '3.2.0', 'ge')) {
$versionLast = null;
if (file_exists(JPATH_COMPONENT_ADMINISTRATOR . '/admintools.lastversion.php')) {
include_once JPATH_COMPONENT_ADMINISTRATOR . '/admintools.lastversion.php';
if (defined('ADMINTOOLS_LASTVERSIONCHECK')) {
$versionLast = ADMINTOOLS_LASTVERSIONCHECK;
}
}
if (is_null($versionLast)) {
// FIX 2.1.13: Load the component parameters WITHOUT using JComponentHelper
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array($db->quoteName('params')))->from($db->quoteName('#__extensions'))->where($db->quoteName('type') . ' = ' . $db->Quote('component'))->where($db->quoteName('element') . ' = ' . $db->Quote('com_admintools'));
$db->setQuery($query);
$rawparams = $db->loadResult();
$params = new JRegistry();
if (version_compare(JVERSION, '3.0', 'ge')) {
$params->loadString($rawparams, 'JSON');
} else {
$params->loadJSON($rawparams);
}
$versionLast = $params->get('lastversion', '');
}
if (version_compare(ADMINTOOLS_VERSION, $versionLast, 'ne') || empty($versionLast)) {
$this->setRedirect('index.php?option=com_admintools&view=postsetup');
return true;
}
}
}
return $result;
}
示例15: __construct
/**
* Class constructor
*
* @param array $options An array of configuration options.
*
* @return JMenu A JMenu object
* @since 11.1
*/
public function __construct($options = array())
{
// Load the menu items
$this->load();
foreach ($this->_items as $k => $item) {
if ($item->home) {
$this->_default[$item->language] = $item->id;
}
// Decode the item params
$result = new JRegistry();
$result->loadJSON($item->params);
$item->params = $result;
}
}