本文整理汇总了PHP中JRegistry::loadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP JRegistry::loadFile方法的具体用法?PHP JRegistry::loadFile怎么用?PHP JRegistry::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRegistry
的用法示例。
在下文中一共展示了JRegistry::loadFile方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTrans
/**
* Get language items and store them in an array
*
*/
function getTrans($lang, $item)
{
$app = JFactory::getApplication();
$option = 'com_osmembership';
$registry = new JRegistry();
$languages = array();
if (strpos($item, 'admin.') !== false) {
$isAdmin = true;
$item = substr($item, 6);
} else {
$isAdmin = false;
}
if ($isAdmin) {
$path = JPATH_ROOT . '/administrator/language/en-GB/en-GB.' . $item . '.ini';
} else {
$path = JPATH_ROOT . '/language/en-GB/en-GB.' . $item . '.ini';
}
$registry->loadFile($path, 'INI');
$languages['en-GB'][$item] = $registry->toArray();
if ($isAdmin) {
$path = JPATH_ROOT . '/administrator/language/' . $lang . '/' . $lang . '.' . $item . '.ini';
} else {
$path = JPATH_ROOT . '/language/' . $lang . '/' . $lang . '.' . $item . '.ini';
}
$search = $app->getUserStateFromRequest($option . 'search', 'search', '', 'string');
$search = JString::strtolower($search);
if (JFile::exists($path)) {
$registry->loadFile($path, 'INI');
$languages[$lang][$item] = $registry->toArray();
} else {
$languages[$lang][$item] = array();
}
return $languages;
}
示例2: postflight
/**
* Method to run after installing the component
*/
function postflight($type, $parent)
{
//Restore the modified language strings by merging to language files
$registry = new JRegistry();
foreach (self::$languageFiles as $languageFile) {
$backupFile = JPATH_ROOT . '/language/en-GB/bak.' . $languageFile;
$currentFile = JPATH_ROOT . '/language/en-GB/' . $languageFile;
if (JFile::exists($currentFile) && JFile::exists($backupFile)) {
$registry->loadFile($currentFile, 'INI');
$currentItems = $registry->toArray();
$registry->loadFile($backupFile, 'INI');
$backupItems = $registry->toArray();
$items = array_merge($currentItems, $backupItems);
$content = "";
foreach ($items as $key => $value) {
$content .= "{$key}=\"{$value}\"\n";
}
JFile::write($currentFile, $content);
}
}
// Restore custom modified css file
if (JFile::exists(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css')) {
JFile::copy(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css', JPATH_ROOT . '/components/com_osmembership/assets/css/custom.css');
JFile::delete(JPATH_ROOT . '/components/com_osmembership/assets/css/bak.custom.css');
}
}
示例3: getTrans
/**
* Get language items and store them in an array
*
*/
function getTrans($lang, $item)
{
$mainframe =& JFactory::getApplication();
$option = 'com_helpdeskpro';
jimport('joomla.filesystem.file');
$registry = new JRegistry();
$languages = array();
$path = JPATH_ROOT . '/language/en-GB/en-GB.' . $item . '.ini';
$registry->loadFile($path, 'INI');
$languages['en-GB'][$item] = $registry->toArray();
$path = JPATH_ROOT . '/language/' . $lang . '/' . $lang . '.' . $item . '.ini';
$search = $mainframe->getUserStateFromRequest($option . 'language.search', 'search', '', 'string');
$search = JString::strtolower($search);
if (JFile::exists($path)) {
$registry->loadFile($path);
$languages[$lang][$item] = $registry->toArray();
} else {
$languages[$lang][$item] = array();
}
return $languages;
}
示例4: onToolGetForm
public function onToolGetForm($context, $form, $name, $id)
{
if ($name != 'toolset') {
return;
}
$tool = $this->_getTool($id);
if (!JFile::exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'saved' . DIRECTORY_SEPARATOR . $id . '.conf')) {
JFile::write(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'saved' . DIRECTORY_SEPARATOR . $id . '.conf', @$a);
}
$params = new JRegistry();
$params->loadFile(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'saved' . DIRECTORY_SEPARATOR . $id . '.conf');
$form_object = JForm::getInstance('plg_toolset.form', JPATH_PLUGINS . DIRECTORY_SEPARATOR . 'mint' . DIRECTORY_SEPARATOR . 'toolset' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'forms.xml', array('control' => 'jform'));
$form = MEFormHelper::renderFieldset($form_object, 'toolset' . $id, $params, null, FORM_STYLE_TABLE);
}
示例5: save
/**
* Save method is diff here because we're writing to a file
* (non-PHPdoc)
* @see Citruscart/admin/CitruscartController::save()
*/
function save()
{
$app = JFactory::getApplication();
$id = $app->input->get('id', 'en-GB');
$temp_values = $app->input->getArray($_POST);
$model = $this->getModel('Emails', 'CitruscartModel');
// Filter values
$prefix = $model->email_prefix;
$values = array();
foreach ($temp_values as $k => $v) {
if (stripos($k, $prefix) === 0) {
$values[$k] = $v;
}
}
$lang = $model->getItem($id);
$path = $lang->path;
$msg = JText::_('COM_CITRUSCART_SAVED');
jimport('joomla.filesystem.file');
if (JFile::exists($path)) {
$original = new JRegistry();
$original->loadFile($path);
$registry = new JRegistry();
$registry->loadArray($values);
$original->merge($registry);
$txt = $original->__toString('INI');
$success = JFile::write($path, $txt);
if (!$success) {
$msg = JText::_('COM_CITRUSCART_ERROR_SAVING_NEW_LANGUAGE_FILE');
}
}
$model->clearCache();
//$task = JRequest::getVar('task');
$task = $app->input->getString('task');
$redirect = "index.php?option=com_citruscart";
switch ($task) {
case "apply":
$redirect .= '&view=' . $this->get('suffix') . '&task=edit&id=' . $id;
break;
case "save":
default:
$redirect .= "&view=" . $this->get('suffix');
break;
}
$redirect = JRoute::_($redirect, false);
$this->setRedirect($redirect, $this->message, $this->messagetype);
}
示例6: loadJSON
protected static function loadJSON($path)
{
$data = new JRegistry();
$data->loadFile($path);
return $data;
}
示例7: testLoadFile
/**
* Test the JRegistry::loadFile method.
*
* @covers JRegistry::loadFile
*
* @return void
*/
public function testLoadFile()
{
$registry = new JRegistry();
// Result is always true, no error checking in method.
// JSON.
$result = $registry->loadFile(__DIR__ . '/stubs/jregistry.json');
// Test getting a known value.
$this->assertThat($registry->get('foo'), $this->equalTo('bar'), 'Line: ' . __LINE__ . '.');
// INI.
$result = $registry->loadFile(__DIR__ . '/stubs/jregistry.ini', 'ini');
// Test getting a known value.
$this->assertThat($registry->get('foo'), $this->equalTo('bar'), 'Line: ' . __LINE__ . '.');
// INI + section.
$result = $registry->loadFile(__DIR__ . '/stubs/jregistry.ini', 'ini', array('processSections' => true));
// Test getting a known value.
$this->assertThat($registry->get('section.foo'), $this->equalTo('bar'), 'Line: ' . __LINE__ . '.');
// XML and PHP versions do not support stringToObject.
}
示例8: checkJAT3v2CacheExclude
private function checkJAT3v2CacheExclude($extension = 'mod_pwebcontact', $type = 'module')
{
if (!file_exists(JPATH_ROOT . '/plugins/system/jat3/jat3.php')) {
return null;
}
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName('element'))->from($db->quoteName('#__extensions'))->where($db->quoteName('type') . ' = ' . $db->quote('template'))->where($db->quoteName('element') . ' LIKE ' . $db->quote('ja_%'))->where($db->quoteName('client_id') . ' = 0');
$db->setQuery($query);
$templates = $db->loadColumn();
if (!$templates or !count($templates)) {
return null;
}
$app = JFactory::getApplication();
foreach ($templates as $template) {
$params = new JRegistry();
$params->loadFile(JPATH_ROOT . '/templates/' . $template . '/params.ini', 'ini');
if ($params->get('cache', false) === 1 and !preg_match('/' . $type . '=[^=]*' . $extension . '/i', $params->get('cache_exclude'))) {
$app->enqueueMessage(JText::sprintf('MOD_PWEBCONTACT_CONFIG_MSG_JAT3V2_CACHE', $type . '=' . $extension, '<a href="index.php?option=com_templates&filter_search=' . $template . '" target="_blank">', $template, '</a>'), 'warning');
}
}
return true;
}
示例9: loadINI
/**
* loadINI
*
* @return bool
*/
protected static function loadINI()
{
if (self::$_compinfo && self::$_pluginfo) {
return true;
}
self::$_compinfo = array();
self::$_pluginfo = array();
self::$_thirdparty = array();
// Get component parameter
$version_check = EParameter::getComponentParam(CAUTOTWEETNG, 'version_check', 1);
$remoteFile = self::SERVER_INI_PATH . self::SERVER_INI_FILE;
$localFile = JPATH_AUTOTWEET_HELPERS . '/' . self::SERVER_INI_FILE;
$file = $localFile;
if ($version_check) {
try {
$ch = curl_init($remoteFile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::CXN_TIMEOUT);
curl_setopt($ch, CURLOPT_TIMEOUT, self::EXEC_TIMEOUT);
$data = curl_exec($ch);
curl_close($ch);
file_put_contents($localFile, $data);
} catch (Exception $e) {
$msg = $e->getMessage();
$logger->log(JLog::ERROR, 'AutoTweetNG - ' . $msg);
}
}
jimport('joomla.error.error');
jimport('joomla.registry.registry');
$registry = new JRegistry();
if (!$registry->loadFile($file, 'INI', array('processSections' => 'true'))) {
$logger->log(JLog::ERROR, 'AutoTweetNG - error reading INI file ' . $file);
return false;
}
// Init logging
$logger = AutotweetLogger::getInstance();
$db = JFactory::getDBO();
// Get component info and remove from array
$data = JApplicationHelper::parseXMLInstallFile(JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . self::COMP_INSTALL_FILE);
self::$_compinfo = array('id' => $registry->get('component.id'), 'name' => $registry->get('component.name'), 'server_version' => $registry->get('component.version'), 'client_version' => $data['version'], 'home' => $registry->get('component.home'), 'faq' => $registry->get('component.faq'), 'download' => $registry->get('component.download'), 'support' => $registry->get('component.support'), 'products' => $registry->get('component.products'), 'twitter' => $registry->get('component.twitter'), 'jed' => $registry->get('component.jed'), 'message' => $registry->get('component.message'), 'news' => $registry->get('component.news'));
$extensions = TextUtil::listToArray($registry->get('component.extensions'));
foreach ($extensions as $extension) {
$state = self::EXT_NOTINSTALLED;
$config = '';
$client_version = '';
$type = $registry->get($extension . '.type');
$id = $registry->get($extension . '.id');
$source = $registry->get($extension . '.source');
if ('module' == $type) {
$mod_filename = 'mod_' . $id;
// Get the module id and set url for config
$pluginsModel = F0FModel::getTmpInstance('Extensions', 'ExtlyModel');
$pluginsModel->savestate(false)->setState('element', $mod_filename);
$rows = $pluginsModel->getItemList();
if (!empty($rows)) {
$row = $rows[0];
if ($row->client_id) {
$path = JPATH_ADMINISTRATOR . '/modules/' . $mod_filename . DIRECTORY_SEPARATOR . $mod_filename . '.xml';
} else {
$path = JPATH_ROOT . '/modules/' . $mod_filename . DIRECTORY_SEPARATOR . $mod_filename . '.xml';
}
$data = JApplicationHelper::parseXMLInstallFile($path);
$client_version = $data['version'];
if (self::_isEnabled($mod_filename)) {
$state = self::EXT_ENABLED;
} else {
$state = self::EXT_DISABLED;
}
// $config = 'index.php?option=com_modules&task=module.edit&id=' . $row->extension_id;
}
} else {
// Get the plugin id and set url for config
$pluginsModel = F0FModel::getTmpInstance('Plugins', 'AutoTweetModel');
$pluginsModel->savestate(false)->set('element_id', $id);
$rows = $pluginsModel->getItemList();
if (!empty($rows)) {
$row = $rows[0];
$path = JPATH_PLUGINS . DIRECTORY_SEPARATOR . $row->folder . DIRECTORY_SEPARATOR . $row->element . DIRECTORY_SEPARATOR . $row->element . '.xml';
$data = JApplicationHelper::parseXMLInstallFile($path);
$client_version = $data['version'];
if (JPluginHelper::isEnabled($row->folder, $row->element)) {
$state = self::EXT_ENABLED;
} else {
$state = self::EXT_DISABLED;
}
$config = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $row->id;
}
}
// Append plugin state to result arrays
if (self::FM_EXT_SOURCE == $source) {
self::$_pluginfo[] = array('id' => $id, 'name' => $registry->get($extension . '.name'), 'state' => $state, 'client_version' => $client_version, 'server_version' => $registry->get($extension . '.version'), 'message' => $registry->get($extension . '.message'), 'config' => $config);
} else {
self::$_thirdparty[] = array('id' => $id, 'name' => $registry->get($extension . '.name'), 'state' => $state, 'client_version' => $client_version, 'message' => $registry->get($extension . '.message'), 'config' => $config, 'source' => $source, 'download' => $registry->get($extension . '.download'));
}
}
//.........这里部分代码省略.........
示例10: loadParams
/**
* Loading layout configuration in JSON format
* @param (string) name of the layout
*/
protected static function loadParams($layout)
{
$file = JPath::clean(JMF_TPL_PATH . '/assets/layout/' . $layout . '.json');
$params = new JRegistry();
if (JFile::exists($file)) {
$params->loadString(JFile::read($file));
}
$defaults = new JRegistry();
$default_settings_file = JPath::clean(JMF_TPL_PATH . '/templateDefaults.json');
if (JFile::exists($default_settings_file)) {
$defaults->loadFile($default_settings_file, 'JSON');
}
$params->def('#tmplWidth', $defaults->get('JMfluidGridContainerLg'));
$params->def('#tmplSpace', $defaults->get('JMbaseSpace'));
$data = $params->toString();
return $data;
}