本文整理汇总了PHP中JParameter::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP JParameter::toArray方法的具体用法?PHP JParameter::toArray怎么用?PHP JParameter::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JParameter
的用法示例。
在下文中一共展示了JParameter::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
function load($id = null)
{
parent::load($id);
jimport('joomla.html.parameter');
$params = new JParameter($this->settings);
$this->settings = $params->toArray();
}
示例2: getList
public function getList()
{
if (!isset($this->_list))
{
$rowset = KFactory::get('com://admin/settings.database.rowset.settings');
//Insert the system configuration settings
$rowset->insert(KFactory::get('com://admin/settings.database.row.system'));
//Insert the component configuration settings
$components = KFactory::get('com://admin/extensions.model.components')->enabled(1)->parent(0)->getList();
foreach($components as $component)
{
$path = JPATH_ADMINISTRATOR.'/components/'.$component->option.'/config.xml';
$params = new JParameter( $component->params);
$config = array(
'name' => strtolower(substr($component->option, 4)),
'path' => file_exists($path) ? $path : '',
'id' => $component->id,
'data' => $params->toArray(),
);
$row = KFactory::get('com://admin/settings.database.row.component', $config);
$rowset->insert($row);
}
$this->_list = $rowset;
}
return $this->_list;
}
示例3: up
/**
* Up
**/
public function up()
{
$query = "CREATE TABLE IF NOT EXISTS `jos_announcements` (\n\t\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t`scope` varchar(100) DEFAULT NULL,\n\t\t\t\t\t\t`scope_id` int(11) DEFAULT NULL,\n\t\t\t\t\t\t`content` text,\n\t\t\t\t\t\t`priority` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`created_by` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`state` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t\t\t`sticky` tinyint(2) NOT NULL DEFAULT '0',\n\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$this->db->setQuery($query);
$this->db->query();
$params = array('plugin_access' => 'members', 'display_tab' => 1);
$this->addPluginEntry('groups', 'announcements', 1, $params);
//get citation params
if ($this->db->tableExists('#__extensions')) {
$sql = "SELECT `params` FROM `#__extensions` WHERE `type`='plugin' AND `element`='messages' AND `folder` = 'groups'";
} else {
$sql = "SELECT `params` FROM `#__plugins` WHERE `element`='messages' AND `folder`='groups'";
}
$this->db->setQuery($sql);
$p = $this->db->loadResult();
//load params object
$params = new \JParameter($p);
//set param to hide messages tab
$params->set('display_tab', 0);
//save new params
if ($this->db->tableExists('#__extensions')) {
$query = "UPDATE `#__extensions` SET `params`=" . $this->db->quote(json_encode($params->toArray())) . " WHERE `element`='messages' AND `folder`='groups'";
} else {
$query = "UPDATE `#__plugins` SET `params`='" . $params->toString() . "' WHERE `element`='messages' AND `folder`='groups'";
}
$this->db->setQuery($query);
$this->db->query();
}
示例4: _initialize
/**
* Initializes the default configuration for the object.
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param KConfig $config An optional KConfig object with configuration options.
*/
protected function _initialize(KConfig $config)
{
$params = '';
if (is_readable($file = JPATH_THEMES . '/' . $this->getIdentifier()->package . '/params.ini')) {
$params = file_get_contents($file);
}
$params = new JParameter($params);
$config->append(array('mimetype' => 'text/html', 'params' => $params->toArray(), 'template_filters' => array('shorttag', 'html', 'alias')));
parent::_initialize($config);
}
示例5: jimport
public static function &getExtensions()
{
static $list;
jimport('joomla.html.parameter');
if ($list != null) {
return $list;
}
$db = JFactory::getDBO();
$list = array();
// Get the menu items as a tree.
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__extensions AS n');
$query->where('n.folder = \'xmap\'');
$query->where('n.enabled = 1');
// Get the list of menu items.
$db->setQuery($query);
$extensions = $db->loadObjectList('element');
foreach ($extensions as $element => $extension) {
require_once JPATH_PLUGINS . DS . $extension->folder . DS . $element . DS . $element . '.php';
//$xmlPath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'extensions' . DS . $extension->folder . DS . $element . '.xml';
//$params = new JParameter($extension->params, $xmlPath);
$params = new JParameter($extension->params);
$extension->params = $params->toArray();
$list[$element] = $extension;
}
return $list;
}
示例6: preload
public static function preload()
{
// Don't preload anything if this is the API
if (MageBridge::isApiPage() == true) {
return null;
}
// Don't preload anything if the current output contains only the component-area
if (in_array(JRequest::getCmd('tmpl'), array('component', 'raw'))) {
return null;
}
// Fetch all the current modules
$modules = MageBridgeModuleHelper::load();
$register = MageBridgeModelRegister::getInstance();
// Loop through all the available Joomla! modules
if (!empty($modules)) {
foreach ($modules as $module) {
// Check the name to see if this is a MageBridge-related module
if (preg_match('/^mod_magebridge_/', $module->module)) {
// Initialize variables
$type = null;
$name = null;
jimport('joomla.html.parameter');
$params = new JParameter($module->params);
$conf = JFactory::getConfig();
$user = JFactory::getUser();
// Check whether caching returns a valid module-output
if ($params->get('cache', 0) && $conf->getValue('config.caching')) {
$cache = JFactory::getCache($module->module);
$cache->setLifeTime($params->get('cache_time', $conf->getValue('config.cachetime') * 60));
$contents = $cache->get(array('JModuleHelper', 'renderModule'), array($module, $params->toArray()), $module->id . $user->get('aid', 0));
// If the contents are not empty, there is a cached version so we skip this
if (!empty($contents)) {
continue;
}
// If the contents are empty, make sure we have a fresh start
// @todo: Why was this needed? This causes under certain circumstances numerous bridge-calls which is bad.
//if (empty($contents)) {
// $cache->clean();
//}
}
// If the layout is AJAX-ified, do not fetch the block at all
if ($params->get('layout') == 'ajax') {
continue;
}
// Try to include the helper-file
if (is_file(JPATH_SITE . '/modules/' . $module->module . '/helper.php')) {
$module_file = JPATH_SITE . '/modules/' . $module->module . '/helper.php';
} else {
if (is_file(JPATH_ADMINISTRATOR . '/modules/' . $module->module . '/helper.php')) {
$module_file = JPATH_ADMINISTRATOR . '/modules/' . $module->module . '/helper.php';
}
}
// If there is a module-file, include it
if (!empty($module_file) && is_file($module_file)) {
require_once $module_file;
// Construct and detect the module-class
$class = preg_replace('/_([a-z]{1})/', '\\1', $module->module) . 'Helper';
if (class_exists($class)) {
// Instantiate the class and check for the "register" method
$o = new $class();
if (method_exists($o, 'register')) {
// Fetch the requested tasks
$requests = $o->register($params);
if (is_array($requests) && count($requests) > 0) {
foreach ($requests as $request) {
// Add each requested task to the MageBridge register
if (!empty($request[2])) {
$register->add($request[0], $request[1], $request[2]);
} else {
if (!empty($request[1])) {
$register->add($request[0], $request[1]);
} else {
$register->add($request[0]);
}
}
}
}
}
}
}
}
}
}
}
示例7: dirname
$uri = str_replace(DS, "/", str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__)));
$uri = str_replace("/administrator", "", $uri);
$template = $obj->template;
$name = 'pages_profile';
$profiles = $obj->getProfiles();
$pageids = $obj->getPageIds($name);
$langlist = $obj->getLanguageList();
jimport('joomla.filesystem.file');
$jsonData = $profiles;
$configfile = dirname(__FILE__) . DS . 'config.xml';
if (file_exists($configfile)) {
/* For General Tab */
$generalconfig = $obj->getGeneralConfig();
$configform = JForm::getInstance('general', $configfile, array('control' => 'jform'));
$params = new JParameter($generalconfig);
$jsonData['generalconfigdata'] = $params->toArray();
$jsonData['generalconfigdata'][$name] = str_replace("\n", "\\\\n", $params->get($name, ''));
$arr_values = array();
$value = $params->get($name, '');
$assignedMenus = $obj->getAssignedMenu();
if ($value) {
$arr_values_tmp = explode("\n", $value);
foreach ($arr_values_tmp as $k => $v) {
if ($v) {
// Separate data of row
$row = explode('=', $v);
// Get pages & language
$tmp = explode(',', $row[0]);
$pages = array();
$language = 'All';
foreach ($tmp as $t) {
示例8: _updateMijosef
protected function _updateMijosef()
{
if (empty($this->_current_version)) {
return;
}
if ($this->_current_version = '1.0.0') {
$db = JFactory::getDBO();
jimport('joomla.html.parameter');
$db->setQuery('SELECT params FROM #__extensions WHERE element = "com_mijosef" AND type = "component"');
$o_c = $db->loadResult();
$o_p = new JParameter($o_c);
$reg = new JRegistry($o_p->toArray());
$config = $reg->toString();
$db->setQuery('UPDATE #__extensions SET params = ' . $db->Quote($config) . ' WHERE element = "com_mijosef" AND type = "component"');
$db->query();
$db->setQuery('SELECT id, params FROM #__mijosef_extensions');
$o_exts = $db->loadObjectList();
if (empty($o_exts)) {
return;
}
foreach ($o_exts as $o_ext) {
$ext_p = new JParameter($o_ext->params);
$reg = new JRegistry($ext_p->toArray());
$params = $reg->toString();
$db = JFactory::getDBO();
$db->setQuery('UPDATE #__mijosef_extensions SET params = ' . $db->Quote($params) . ' WHERE id=' . $o_ext->id);
$db->query();
}
$db->setQuery('SELECT id, params FROM #__mijosef_urls');
$o_urls = $db->loadObjectList();
if (empty($o_urls)) {
return;
}
foreach ($o_urls as $o_url) {
$url_p = new JParameter($o_url->params);
$reg = new JRegistry($url_p->toArray());
$params = $reg->toString();
$db = JFactory::getDBO();
$db->setQuery('UPDATE #__mijosef_urls SET params = ' . $db->Quote($params) . ' WHERE id=' . $o_url->id);
$db->query();
}
return;
}
}
示例9: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
if (!defined('japaramhelper2')) {
$uri = str_replace(DS, "/", str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__)));
$uri = str_replace("/administrator", "", $uri);
JHTML::stylesheet('japaramhelper2.css', $uri . "/assets/css/");
JHTML::script('japaramhelper2.js', $uri . "/assets/js/");
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
define('japaramhelper2', true);
}
$jsonData = array();
$folder_profiles = array();
/* Get all profiles name folder from folder profiles */
$profiles = array();
$jsonData = array();
$jsonTempData = array();
// get in template
$template = $this->get_active_template();
$path = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'mod_janewspro';
if (JFolder::exists($path)) {
$files = JFolder::files($path, '.ini');
if ($files) {
foreach ($files as $fname) {
$fname = substr($fname, 0, -4);
$f = new stdClass();
$f->id = $fname;
$f->title = $fname;
$profiles[$fname] = $f;
$params = new JParameter(JFile::read($path . DS . $fname . '.ini'));
$jsonData[$fname] = $params->toArray();
$jsonTempData[$fname] = $jsonData[$fname];
}
}
}
// get in module
$path = JPATH_SITE . DS . 'modules' . DS . 'mod_janewspro' . DS . 'profiles';
if (!JFolder::exists($path)) {
return JText::_('Profiles Folder not exist');
}
$files = JFolder::files($path, '.ini');
if ($files) {
foreach ($files as $fname) {
$fname = substr($fname, 0, -4);
$f = new stdClass();
$f->id = $fname;
$f->title = $fname;
$profiles[$fname] = $f;
$params = new JParameter(JFile::read($path . DS . $fname . '.ini'));
$jsonData[$fname] = $params->toArray();
}
}
$HTML_Profile = JHTML::_('select.genericlist', $profiles, '' . $control_name . '[' . $name . ']', 'style="width:150px;" onchange="japarams2.changeProfile(this.value)"', 'id', 'title', $value);
$xml_profile = JPATH_SITE . DS . 'modules' . DS . 'mod_janewspro' . DS . 'admin' . DS . 'config.xml';
if (file_exists($xml_profile)) {
/* For General Tab */
$paramsForm = new JParameter('', $xml_profile, 'template');
}
$_body = JResponse::getBody();
ob_start();
require_once dirname(__FILE__) . DS . 'tpl.php';
$content = ob_get_clean();
JResponse::setBody($_body);
return $HTML_Profile . $content;
}
示例10: isset
//.........这里部分代码省略.........
}
}
}
}
// Add the existing variables
if ($hrefVars != "") {
$href .= '?' . $hrefVars;
}
if ($jfLang->getLanguageCode() != null) {
$ulang = 'lang=' . $jfLang->getLanguageCode();
} else {
// it's important that we add at least the basic parameter - as of the sef is adding the actual otherwise!
$ulang = 'lang=';
}
// if there are other vars we need to add a & otherwiese ?
if ($hrefVars == '') {
$href .= '?' . $ulang;
} else {
$href .= '&' . $ulang;
}
$registry->setValue("config.multilingual_support", true);
global $mainframe;
$mainframe->setUserState('application.lang', $jfLang->code);
$registry->setValue("config.jflang", $jfLang->code);
$registry->setValue("config.lang_site", $jfLang->code);
$registry->setValue("config.language", $jfLang->code);
$registry->setValue("joomfish.language", $jfLang);
$href = JRoute::_($href, false);
header('HTTP/1.1 303 See Other');
header("Location: " . $href);
exit;
}
if (isset($jfLang) && $jfLang->code != "" && ($jfLang->active || $jfm->getCfg("frontEndPreview"))) {
$locale = $jfLang->code;
} else {
$jfLang = TableJFLanguage::createByJoomla($locale);
if (!$jfLang->active) {
?>
<div style="background-color: #c00; color: #fff">
<p style="font-size: 1.5em; font-weight: bold; padding: 10px 0px 10px 0px; text-align: center; font-family: Arial, Helvetica, sans-serif;">
Joom!Fish config error: Default language is inactive!<br /> <br />
Please check configuration, try to use first active language</p>
</div>
<?php
$activeLanguages = $jfm->getActiveLanguages();
if (count($activeLanguages) > 0) {
$jfLang = $activeLanguages[0];
$locale = $jfLang->code;
} else {
// No active language defined - using system default is only alternative!
}
}
$client_lang = $jfLang->shortcode != '' ? $jfLang->shortcode : $jfLang->iso;
}
// TODO set the cookie domain so that it works for all subdomains
if ($enableCookie) {
setcookie("lang", "", time() - 1800, "/");
setcookie("jfcookie", "", time() - 1800, "/");
setcookie("jfcookie[lang]", $client_lang, time() + 24 * 3600, '/');
}
if (defined("_JLEGACY")) {
$GLOBALS['iso_client_lang'] = $client_lang;
$GLOBALS['mosConfig_lang'] = $jfLang->code;
}
$registry->setValue("config.multilingual_support", true);
global $mainframe;
$mainframe->setUserState('application.lang', $jfLang->code);
$registry->setValue("config.jflang", $jfLang->code);
$registry->setValue("config.lang_site", $jfLang->code);
$registry->setValue("config.language", $jfLang->code);
$registry->setValue("joomfish.language", $jfLang);
// Force factory static instance to be updated if necessary
$lang =& JFactory::getLanguage();
if ($jfLang->code != $lang->getTag()) {
// Must not assign by reference in order to overwrite the existing reference to the static instance of the language
$lang = JFactory::_createLanguage();
$lang->setDefault($jfLang->code);
$lang->_metadata = array();
$lang->_metadata['tag'] = $jfLang->code;
$lang->_metadata['rtl'] = false;
}
// no need to set locale for this ISO code its done by JLanguage
// overwrite with the valued from $jfLang
$jfparams = JComponentHelper::getParams("com_joomfish");
$overwriteGlobalConfig = $jfparams->get('overwriteGlobalConfig', 0);
if ($overwriteGlobalConfig) {
// We should overwrite additional global variables based on the language parameter configuration
$params = new JParameter($jfLang->params);
$paramarray = $params->toArray();
foreach ($paramarray as $key => $val) {
if (trim($val) !== '') {
$registry->setValue("config." . $key, $val);
}
if (defined("_JLEGACY")) {
$name = 'mosConfig_' . $key;
$GLOBALS[$name] = $val;
}
}
}
}
示例11: getProfiles
function getProfiles()
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$profiles = array();
$file_profiles = array();
$arr_folder = array('core', 'local');
foreach ($arr_folder as $folder) {
$path = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . $folder . DS . 'etc' . DS . 'profiles';
if (!JFolder::exists($path)) {
JFolder::create($path);
$content = '';
JFile::write($path . DS . 'index.html', $content);
}
$files = @JFolder::files($path, '\\.ini');
if ($files) {
foreach ($files as $f) {
$file_profiles[$f] = $path . DS . $f;
}
}
}
if ($file_profiles) {
foreach ($file_profiles as $name => $p) {
$dparams = array();
if ($name == 'default.ini') {
$xmlpath = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'templateDetails.xml';
$xml =& JFactory::getXMLParser('Simple');
if ($xml->loadFile($xmlpath)) {
if ($params =& $xml->document->params) {
foreach ($params as $param) {
foreach ($param->children() as $p) {
if ($p->attributes('name') && isset($p->_attributes['default'])) {
$dparams[$p->attributes('name')] = $p->attributes('default');
}
}
}
}
}
}
$profile = new stdclass();
$path = 'etc' . DS . 'profiles' . DS . $name;
$file = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'local' . DS . $path;
$profile->local = null;
if (JFile::exists($file)) {
$params = new JParameter(JFile::read($file));
$profile->local = array_merge($dparams, $params->toArray());
}
$file = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'core' . DS . $path;
$profile->core = null;
if (JFile::exists($file)) {
$params = new JParameter(JFile::read($file));
$profile->core = array_merge($dparams, $params->toArray());
}
$profiles[strtolower(substr($name, 0, -4))] = $profile;
}
}
if (!$profiles) {
$profile = new stdclass();
$profile->core = ' ';
$profile->local = null;
$profiles['default'] = $profile;
}
return $profiles;
}
示例12: install
function install($theme)
{
$app = JFactory::getApplication();
$db = JFactory::getDBO();
$package = $this->_getPackageFromUpload();
if (!$package) {
JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_FIND_INSTALL_PACKAGE'));
$this->deleteTempFiles();
return false;
}
if ($package['dir'] && JFolder::exists($package['dir'])) {
$this->setPath('source', $package['dir']);
} else {
JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_INSTALL_PATH_NOT_EXISTS'));
$this->deleteTempFiles();
return false;
}
// We need to find the installation manifest file
if (!$this->_findManifest()) {
JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_FIND_INFO_INSTALL_PACKAGE'));
$this->deleteTempFiles();
return false;
}
// Files - copy files in manifest
foreach ($this->_manifest->children() as $child) {
if (is_a($child, 'JXMLElement') && $child->name() == 'files') {
if ($this->parseFiles($child) === false) {
JError::raiseWarning(1, JText::_('COM_PHOCAGALLERY_ERROR_FIND_INFO_INSTALL_PACKAGE'));
$this->deleteTempFiles();
return false;
}
}
}
// File - copy the xml file
$copyFile = array();
$path['src'] = $this->getPath('manifest');
// XML file will be copied too
$path['dest'] = JPATH_SITE . DS . 'media' . DS . 'com_phocagallery' . DS . 'images' . DS . basename($this->getPath('manifest'));
$copyFile[] = $path;
$this->copyFiles($copyFile, array());
$this->deleteTempFiles();
// -------------------
// Themes
// -------------------
// Params - Get new themes params
$paramsThemes = $this->getParamsThemes();
// -------------------
// Component
// -------------------
if (isset($theme['component']) && $theme['component'] == 1) {
$component = 'com_phocagallery';
$paramsC = JComponentHelper::getParams($component);
foreach ($paramsThemes as $keyT => $valueT) {
$paramsC->set($valueT['name'], $valueT['value']);
}
$data['params'] = $paramsC->toArray();
$table = JTable::getInstance('extension');
$idCom = $table->find(array('element' => $component));
$table->load($idCom);
if (!$table->bind($data)) {
JError::raiseWarning(500, 'Not a valid component');
return false;
}
// pre-save checks
if (!$table->check()) {
JError::raiseWarning(500, $table->getError('Check Problem'));
return false;
}
// save the changes
if (!$table->store()) {
JError::raiseWarning(500, $table->getError('Store Problem'));
return false;
}
}
// -------------------
// Menu Categories
// -------------------
if (isset($theme['categories']) && $theme['categories'] == 1) {
$link = 'index.php?option=com_phocagallery&view=categories';
$where = array();
$where[] = 'link = ' . $db->Quote($link);
$query = 'SELECT id, params FROM #__menu WHERE ' . implode(' AND ', $where);
$db->setQuery($query);
$itemsCat = $db->loadObjectList();
if (!empty($itemsCat)) {
foreach ($itemsCat as $keyIT => $valueIT) {
$query = 'SELECT m.params FROM #__menu AS m WHERE m.id = ' . (int) $valueIT->id;
$db->setQuery($query);
$paramsCJSON = $db->loadResult();
//$paramsCJSON = $valueIT->params;
$paramsMc = new JParameter();
$paramsMc->loadJSON($paramsCJSON);
foreach ($paramsThemes as $keyT => $valueT) {
$paramsMc->set($valueT['name'], $valueT['value']);
}
$dataMc['params'] = $paramsMc->toArray();
$table =& JTable::getInstance('menu');
if (!$table->load((int) $valueIT->id)) {
JError::raiseWarning(500, 'Not a valid table');
return false;
//.........这里部分代码省略.........
示例13: getProfiles
/**
* Get all profiles
*
* @return array An array of profiles
*/
function getProfiles()
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$path = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'etc' . DS . 'profiles';
// Check to sure that core & local folders were remove from template.
// If etc/$type exists, considered as core & local folders were removed
if (@is_dir($path)) {
if (!is_file($path . DS . 'index.html')) {
$content = '<!DOCTYPE html><title></title>';
JFile::write($path . DS . 'index.html', $content);
}
// Read custom parameters
$dparams = array();
$xmlpath = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'templateDetails.xml';
$xml =& JFactory::getXMLParser('Simple');
if ($xml->loadFile($xmlpath)) {
$params =& $xml->document->params;
if ($params) {
foreach ($params as $param) {
foreach ($param->children() as $p) {
if ($p->attributes('name') && isset($p->_attributes['default'])) {
$dparams[$p->attributes('name')] = $p->attributes('default');
}
}
}
}
}
$filelist = array();
$profiles = array();
// Get filename list from profiles folder
$file_list = JFolder::files($path, '\\.ini');
// Load profile data
foreach ($file_list as $file) {
// Get filename & filepath
$filename = strtolower(substr($file, 0, -4));
$filepath = $path . DS . $file;
if (@file_exists($filepath)) {
$profile = new stdclass();
$profile->local = null;
$params = new JParameter(JFile::read($filepath));
// Check if it is default profile or not
if ($filename == 'default') {
$profile->core = $params->toArray();
// Merge custom parameters
$profile->local = array_merge($dparams, $params->toArray());
} else {
$profile->local = $params->toArray();
}
$profiles[$filename] = $profile;
}
}
// If there isn't any profile in etc/profiles folders, create empty default profile
if (empty($profiles) || !isset($profiles['default'])) {
$profile = new stdclass();
$profile->core = ' ';
$profile->local = null;
$profiles['default'] = $profile;
}
} else {
// Maybe template still has older structure folders, so try to read core/local folder.
$profiles = array();
$file_profiles = array();
$arr_folder = array('core', 'local');
foreach ($arr_folder as $folder) {
$path = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . $folder . DS . 'etc' . DS . 'profiles';
if (!JFolder::exists($path)) {
if (JFolder::create($path)) {
$content = '';
JFile::write($path . DS . 'index.html', $content);
}
}
$files = @JFolder::files($path, '\\.ini');
if ($files) {
foreach ($files as $f) {
$file_profiles[$f] = $path . DS . $f;
}
}
}
if ($file_profiles) {
foreach ($file_profiles as $name => $p) {
$dparams = array();
if ($name == 'default.ini') {
// Read custom parameters
$xmlpath = JPATH_SITE . DS . 'templates' . DS . $this->template . DS . 'templateDetails.xml';
$xml =& JFactory::getXMLParser('Simple');
if ($xml->loadFile($xmlpath)) {
if ($params =& $xml->document->params) {
foreach ($params as $param) {
foreach ($param->children() as $p) {
if ($p->attributes('name') && isset($p->_attributes['default'])) {
$dparams[$p->attributes('name')] = $p->attributes('default');
}
}
}
//.........这里部分代码省略.........
示例14: getUsers
public function getUsers($params = array())
{
// System variables
$db = JFactory::getDBO();
// Construct the query
$query = 'SELECT * FROM #__users';
if (isset($params['search'])) {
$query .= ' WHERE username LIKE ' . $db->Quote($params['search']);
}
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $index => $row) {
$params = new JParameter($row->params);
$row->params = $params->toArray();
$rows[$index] = $row;
}
return $rows;
}
示例15: determineLanguage
//.........这里部分代码省略.........
$client_lang = $short_lang;
break;
}
}
if (!empty($client_lang)) {
if (strlen($client_lang) == 2) {
$browser_code = self::getLangLongCode($client_lang);
} else {
$browser_code = $client_lang;
}
}
}
}
// Check if language is selected
if (empty($lang)) {
if (empty($code) || !JLanguage::exists($code)) {
if ($this->AcesefConfig->joomfish_main_lang != '0') {
$code = self::getLangLongCode($this->AcesefConfig->joomfish_main_lang);
}
}
// Try to get language code from JF cookie
if (empty($code) || !JLanguage::exists($code)) {
if (isset($cookieCode)) {
$code = $cookieCode;
}
}
// Try to get language from browser if needed
if (empty($code) || !JLanguage::exists($code)) {
if (isset($browser_code)) {
$code = $browser_code;
}
}
// Get language from configuration if needed
if (empty($code) || !JLanguage::exists($code)) {
if ($this->AcesefConfig->joomfish_main_lang != '0') {
$code = self::getLangLongCode($this->AcesefConfig->joomfish_main_lang);
}
}
// Get default language if needed
if (empty($code) || !JLanguage::exists($code)) {
$code = $registry->get('config.language');
}
}
// get language long code if needed
if (empty($code)) {
if (empty($lang)) {
return;
}
$code = self::getLangLongCode($lang);
}
if (!empty($code)) {
// set the site language
$reset_lang = false;
if ($code != self::getLangLongCode()) {
$language = JFactory::getLanguage();
$language->setLanguage($code);
$language->load();
// set the backward compatible language
$back_lang = $language->getBackwardLang();
$GLOBALS['mosConfig_lang'] = $back_lang;
$registry->set("config.lang", $back_lang);
$reset_lang = true;
}
// set joomfish language if needed
if ($reset_lang) {
$jf_lang = TableJFLanguage::createByJoomla($code);
$registry->set("joomfish.language", $jf_lang);
// set some more variables
$mainframe = JFactory::getApplication();
$registry->set("config.multilingual_support", true);
$mainframe->setUserState('application.lang', $jf_lang->code);
$registry->set("config.jflang", $jf_lang->code);
$registry->set("config.lang_site", $jf_lang->code);
$registry->set("config.language", $jf_lang->code);
$registry->set("joomfish.language", $jf_lang);
// overwrite global config with values from $jf_lang if set to in JoomFish
$jf_params = JComponentHelper::getParams("com_joomfish");
$overwriteGlobalConfig = $jf_params->get('overwriteGlobalConfig', 0);
if ($overwriteGlobalConfig) {
// We should overwrite additional global variables based on the language parameter configuration
$lang_params = new JParameter($jf_lang->params);
$param_array = $lang_params->toArray();
foreach ($param_array as $key => $val) {
$registry->set("config." . $key, $val);
if (defined("_JLEGACY")) {
$name = 'mosConfig_' . $key;
$GLOBALS[$name] = $val;
}
}
}
// set the cookie with language
if ($this->AcesefConfig->joomfish_cookie) {
setcookie("lang", "", time() - 1800, "/");
setcookie("jfcookie", "", time() - 1800, "/");
setcookie("jfcookie[lang]", $code, time() + 24 * 3600, '/');
}
}
}
}
}