本文整理汇总了PHP中SPLoader::translatePath方法的典型用法代码示例。如果您正苦于以下问题:PHP SPLoader::translatePath方法的具体用法?PHP SPLoader::translatePath怎么用?PHP SPLoader::translatePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPLoader
的用法示例。
在下文中一共展示了SPLoader::translatePath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tplOverride
protected function tplOverride($term)
{
if (!class_exists('Sobi') || !Sobi::Section()) {
return false;
}
static $xdef = null;
static $custom = false;
static $lang = null;
/* try this once */
if (!$custom) {
if (Sobi::Cfg('section.template')) {
$custom = true;
$template = SPLoader::translatePath('usr.templates.' . Sobi::Cfg('section.template') . '.translation', 'front', true, 'xml');
/* if the template provide it */
if ($template) {
$xml = DOMDocument::load($template);
$xdef = new DOMXPath($xml);
}
$lang = Sobi::Lang(false);
}
}
if ($xdef instanceof DOMXPath) {
$term = strip_tags(preg_replace('/[^a-z0-9\\-\\_\\+\\.\\, ]/i', null, $term));
/* case we had more params */
/* yeah - neo the xpath master -- lovin' it ;) */
$transNode = $xdef->query("/translation/term[@value=\"{$term}\"]/value[@lang='{$lang}']");
if (isset($transNode->length) && $transNode->length) {
return $transNode->item(0)->nodeValue;
} else {
$transNode = $xdef->query("/translation/term[@value=\"{$term}\"]/value[@default='true']");
if (isset($transNode->length) && $transNode->length) {
return $transNode->item(0)->nodeValue;
}
}
}
return false;
}
示例2: displayForm
/**
*
*/
public function displayForm()
{
Sobi::Trigger('Display', $this->name(), array(&$this));
$action = $this->key('action');
echo '<div class="SobiPro" id="SobiPro">' . "\n";
if ($this->get('_compatibility')) {
echo SPFactory::AdmToolbar()->render();
echo $this->legacyMessages();
}
echo $action ? "\n<form action=\"{$action}\" method=\"post\" name=\"adminForm\" id=\"SPAdminForm\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" >\n" : null;
foreach ($this->_templates as $tpl) {
$template = SPLoader::path($tpl, 'adm.template');
if (!$template) {
$tpl = SPLoader::translatePath($tpl, 'adm.template', false);
Sobi::Error($this->name(), SPLang::e('CANNOT_LOAD_TEMPLATE_AT', $tpl), SPC::ERROR, 500, __LINE__, __FILE__);
} else {
include $template;
}
}
if (count($this->_hidden)) {
$this->_hidden[SPFactory::mainframe()->token()] = 1;
$prefix = null;
if (!$this->get('_compatibility')) {
$prefix = 'SP_';
}
foreach ($this->_hidden as $name => $value) {
echo "\n<input type=\"hidden\" name=\"{$name}\" id=\"{$prefix}{$name}\" value=\"{$value}\"/>";
}
}
echo $action ? "\n</form>\n" : null;
echo '</div>';
Sobi::Trigger('AfterDisplay', $this->name());
}
示例3: initPlugin
private function initPlugin($plugin)
{
if (SPLoader::translatePath('opt.plugins.' . $plugin . '.init')) {
$pc = SPLoader::loadClass($plugin . '.init', false, 'plugin');
$this->_plugins[$plugin] = new $pc($plugin);
} else {
Sobi::Error('Class Load', sprintf('Cannot load Application file at %s. File does not exist or is not readable.', $plugin), SPC::WARNING, 0);
}
}
示例4: md5
/**
* Creates temporary (variable) JavaScript file
*
* @param string $script
* @param string $id
* @param string $params
* @param bool $adm
* @return SPHeader
*/
public function &addJsVarFile($script, $id, $params, $adm = false)
{
$this->store(get_defined_vars(), __FUNCTION__);
$checksum = md5(json_encode(get_defined_vars()));
if (!isset($this->_checksums[__FUNCTION__][$checksum])) {
$this->_checksums[__FUNCTION__][$checksum] = true;
$varFile = SPLoader::translatePath("var.js.{$script}_{$id}", 'front', true, 'js');
if (!$varFile) {
$file = SPLoader::JsFile($script, $adm, true, false);
if ($file) {
SPLoader::loadClass('base.fs.file');
$file = new SPFile($file);
$fc =& $file->read();
foreach ($params as $k => $v) {
$fc = str_replace("__{$k}__", $v, $fc);
}
$fc = str_replace('__CREATED__', date(SPFactory::config()->key('date.log_format', 'D M j G:i:s T Y')), $fc);
$varFile = SPLoader::translatePath("var.js.{$script}_{$id}", 'front', false, 'js');
$file->saveAs($varFile);
} else {
Sobi::Error(__FUNCTION__, SPLang::e('CANNOT_LOAD_FILE_AT', $file), SPC::NOTICE, 0, __LINE__, __FILE__);
}
}
if (Sobi::Cfg('cache.include_js_files', false) && !($adm || defined('SOBIPRO_ADM'))) {
$this->_cache['js'][++$this->count] = $varFile;
} else {
$varFile = str_replace(SOBI_ROOT, SPFactory::config()->get('live_site'), $varFile);
$varFile = str_replace('\\', '/', $varFile);
$varFile = preg_replace('|(\\w)(//)(\\w)|', '$1/$3', $varFile);
$varFile = "\n<script type=\"text/javascript\" src=\"{$varFile}\"></script>";
if (!in_array($varFile, $this->jsFiles)) {
$this->jsFiles[++$this->count] = $varFile;
}
}
}
return $this;
}
示例5: getClass
private function getClass()
{
if (!$this->_class) {
$this->type =& $this->fieldType;
if (SPLoader::translatePath('opt.fields.' . $this->fieldType)) {
SPLoader::loadClass('opt.fields.fieldtype');
$this->_class = SPLoader::loadClass('opt.fields.' . $this->fieldType);
}
if (!$this->_class) {
$this->_off = true;
Sobi::Error('Field', sprintf('Field type %s does not exist!', $this->fieldType), SPC::WARNING);
}
}
return $this->_class;
}
示例6: loadType
public function loadType($type = null)
{
if ($type) {
$this->type = $type;
} else {
$this->type =& $this->fieldType;
}
if ($this->type && SPLoader::translatePath('opt.fields.adm.' . $this->type)) {
SPLoader::loadClass('opt.fields.fieldtype');
$fType = SPLoader::loadClass('opt.fields.adm.' . $this->type);
$this->_type = new $fType($this);
} elseif ($this->type && SPLoader::translatePath('opt.fields.' . $this->type)) {
SPLoader::loadClass('opt.fields.fieldtype');
$fType = SPLoader::loadClass('opt.fields.' . $this->type);
$this->_type = new $fType($this);
} else {
parent::loadType();
}
}
示例7: display
/**
*
*/
public function display()
{
$tpl = SPLoader::path($this->_template . '_override', 'adm.template');
if (!$tpl) {
$tpl = SPLoader::path($this->_template, 'adm.template');
}
if (!$tpl) {
$tpl = SPLoader::translatePath($this->_template, 'adm.template', false);
Sobi::Error($this->name(), SPLang::e('TEMPLATE_DOES_NOT_EXISTS', $tpl), SPC::ERROR, 500, __LINE__, __FILE__);
exit;
}
Sobi::Trigger('Display', $this->name(), array(&$this));
$action = $this->key('action');
echo "\n<!-- SobiPro output -->\n";
echo '<div class="SobiPro" id="SobiPro">' . "\n";
if ($this->_legacy) {
echo SPFactory::AdmToolbar()->render();
echo $this->legacyMessages();
echo '<div class="row-fluid">' . "\n";
}
echo $action ? "\n<form action=\"{$action}\" method=\"post\" name=\"adminForm\" id=\"SPAdminForm\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" >\n" : null;
$prefix = null;
if (!$this->_legacy) {
$prefix = 'SP_';
}
include $tpl;
if (count($this->_hidden)) {
$this->_hidden[SPFactory::mainframe()->token()] = 1;
$this->_hidden['spsid'] = microtime(true) + Sobi::My('id') * mt_rand(5, 15) / mt_rand(5, 15);
foreach ($this->_hidden as $name => $value) {
echo "\n<input type=\"hidden\" name=\"{$name}\" id=\"{$prefix}{$name}\" value=\"{$value}\"/>";
}
}
echo $action ? "\n</form>\n" : null;
if ($this->_legacy) {
echo '</div>' . "\n";
}
echo '</div>' . "\n";
echo "\n<!-- SobiPro output end -->\n";
Sobi::Trigger('AfterDisplay', $this->name());
}
示例8: appsMenu
public function appsMenu()
{
$links = array();
$db =& SPFactory::db();
$all = $db->select('pid', 'spdb_plugin_task', array('onAction' => 'adm_menu'))->loadResultArray();
if (count($all)) {
if (Sobi::Section()) {
$list = $db->select('pid', 'spdb_plugin_section', array('section' => Sobi::Section(), 'pid' => $all, 'enabled' => 1))->loadResultArray();
} else {
$list = $db->select('pid', 'spdb_plugins', array('pid' => $all, 'enabled' => 1))->loadResultArray();
}
if (count($list)) {
foreach ($list as $app) {
if (SPLoader::translatePath('opt.plugins.' . $app . '.init')) {
$pc = SPLoader::loadClass($app . '.init', false, 'plugin');
if (method_exists($pc, 'admMenu')) {
call_user_func_array(array($pc, 'admMenu'), array(&$links));
}
} else {
Sobi::Error('Class Load', sprintf('Cannot load application file at %s. File does not exist or is not readable.', $app), SPC::WARNING, 0);
}
}
}
}
return array_flip($links);
}
示例9: add
/**
* Just when adding new field - first step
*/
private function add()
{
if ($this->_fieldType) {
$groups = $this->getFieldGroup($this->_fieldType);
$field = SPFactory::Model('field', true);
$field->loadType($this->_fieldType);
} else {
$groups = $this->getFieldTypes();
/* create dummy field with initial values */
$field = array('name' => '', 'nid' => '', 'notice' => '', 'description' => '', 'adminField' => 0, 'enabled' => 1, 'fee' => 0, 'isFree' => 1, 'withLabel' => 1, 'version' => 1, 'editable' => 1, 'required' => 0, 'priority' => 5, 'showIn' => 'details', 'editLimit' => '', 'version' => 1, 'inSearch' => 0, 'cssClass' => '', 'fieldType' => $this->_fieldType);
}
/* get view class */
$view = SPFactory::View('field', true);
$task = 'add';
$view->addHidden(SPRequest::sid(), 'sid');
$view->addHidden(0, 'fid');
$view->assign($groups, 'types');
$view->assign($field, 'field');
$view->assign($task, 'task');
if ($this->_fieldType) {
$field->onFieldEdit($view);
}
$registry = SPFactory::registry();
$registry->loadDBSection('fields_filter');
$helpTask = 'field.' . $field->get('fieldType');
$registry->set('help_task', $helpTask);
$filters = $registry->get('fields_filter');
$f = array(0 => Sobi::Txt('FM.NO_FILTER'));
if (count($filters)) {
foreach ($filters as $filter => $data) {
$f[$filter] = Sobi::Txt($data['value']);
}
}
$view->assign($f, 'filters');
if ($this->loadTemplate($field, $view)) {
$view->display();
} elseif (SPLoader::translatePath('field.edit.' . $this->_fieldType, 'adm')) {
$view->assign($helpTask, '_compatibility');
if (SPLoader::translatePath('field.edit.' . $this->_fieldType, 'adm', true, 'ini')) {
$view->loadConfig('field.edit.' . $this->_fieldType);
}
$view->setTemplate('field.edit');
if (SPLoader::translatePath('field.edit.' . $this->_fieldType, 'adm')) {
$view->setTemplate('field.edit.' . $this->_fieldType);
}
SPFactory::header()->addCSSCode('#toolbar-box { display: block }');
$view->display();
} else {
Sobi::Error($this->name(), SPLang::e('NO_FIELD_DEF'), SPC::WARNING, 500, __LINE__, __FILE__);
}
}
示例10: updateXMLDefinition
/**
* This method is adding new tasks to the XML files used for Joomla! menu definition
* @param $tasks - list of tasks to add
* @param $controlString - a single string to check for if it has not been already added
* @param $languageFile - language file where the translation for tasks can be found
* @param array $additionalStrings - optional list of additional strings to add to the sys ini files
* @param bool $force - force even if it has been already done - forcing only language files redefinition
* @return void
*/
public function updateXMLDefinition($tasks, $controlString, $languageFile, $additionalStrings = array(), $force = false)
{
$file = SPLoader::translatePath('metadata', 'front', true, 'xml');
$run = false;
$strings = array();
foreach ($tasks as $label) {
$strings[] = $label;
$strings[] = $label . '_EXPL';
}
if (count($additionalStrings)) {
foreach ($additionalStrings as $additionalString) {
$strings[] = $additionalString;
}
}
/** check if it hasn't been already added */
if (!strstr(SPFs::read($file), $controlString)) {
$run = true;
$doc = new DOMDocument();
$doc->load($file);
$options = $doc->getElementsByTagName('options')->item(0);
foreach ($tasks as $task => $label) {
$node = $doc->createElement('option');
$attribute = $doc->createAttribute('value');
$attribute->value = $task;
$node->appendChild($attribute);
$attribute = $doc->createAttribute('name');
$attribute->value = 'SP.' . $label;
$node->appendChild($attribute);
$attribute = $doc->createAttribute('msg');
$attribute->value = 'SP.' . $label . '_EXPL';
$node->appendChild($attribute);
$options->appendChild($node);
}
$doc->save($file);
}
if ($run || $force) {
$dirPath = SPLoader::dirPath('administrator.language', 'root');
/** @var SPDirectory $dir */
$dir = SPFactory::Instance('base.fs.directory', $dirPath);
$files = $dir->searchFile('com_sobipro.sys.ini', false, 2);
$default = array();
$defaultLangDir = SPLoader::dirPath("language.en-GB", 'root', true);
$defaultLang = parse_ini_file($defaultLangDir . 'en-GB.' . $languageFile . '.ini');
foreach ($strings as $string) {
$default['SP.' . $string] = $defaultLang['SP.' . $string];
}
/** @var SPFile $file */
$file = null;
foreach ($files as $file) {
$fileName = $file->getFileName();
list($language) = explode('.', $fileName);
$nativeLangDir = SPLoader::dirPath("language.{$language}", 'root', true);
$nativeStrings = array();
if ($nativeLangDir) {
$nativeLangFile = $nativeLangDir . $language . '.' . $languageFile . '.ini';
if (file_exists($nativeLangFile)) {
$nativeLang = @parse_ini_file($nativeLangFile);
foreach ($strings as $string) {
if (isset($nativeLang['SP.' . $string])) {
$nativeStrings['SP.' . $string] = $nativeLang['SP.' . $string];
}
}
}
}
$add = null;
foreach ($strings as $string) {
if (isset($nativeStrings['SP.' . $string])) {
$add .= "\nSP.{$string}=\"{$nativeStrings['SP.' . $string]}\"";
} else {
$add .= "\nSP.{$string}=\"{$default['SP.' . $string]}\"";
}
}
$add .= "\n";
$content = SPFs::read($file->getPathname());
$add = $content . $add;
SPFs::write($file->getPathname(), $add);
}
}
}
示例11: tplCfg
/**
*/
protected function tplCfg($path, $task = null)
{
$file = explode('.', $path);
$files = array();
if (strstr($file[0], 'cms:')) {
$file[0] = str_replace('cms:', null, $file[0]);
$file = SPFactory::mainframe()->path(implode('.', $file));
$path = SPLoader::dirPath($file, 'root', true);
$this->_tCfg = SPLoader::loadIniFile("{$path}.config", true, false, false, true);
$files[] = SPLoader::iniStorage();
} else {
$this->_tCfg = SPLoader::loadIniFile("usr.templates.{$path}.config");
$files[] = SPLoader::iniStorage();
$path = SPLoader::dirPath('usr.templates.' . $path, 'front', true);
}
if (!$task) {
$task = $this->_task == 'add' || $this->_task == 'submit' ? 'edit' : $this->template;
}
if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'ini')) {
$taskCfg = SPLoader::loadIniFile("{$path}.{$this->templateType}.{$task}", true, false, false, true);
$files[] = SPLoader::iniStorage();
foreach ($taskCfg as $section => $keys) {
if (isset($this->_tCfg[$section])) {
$this->_tCfg[$section] = array_merge($this->_tCfg[$section], $keys);
} else {
$this->_tCfg[$section] = $keys;
}
}
}
if (count($files)) {
foreach ($files as $i => $file) {
$files[$i] = array('file' => str_replace(SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'), null, $file), 'checksum' => md5_file($file));
}
SPFactory::registry()->set('template_config', $files);
}
if (SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')) {
$config = json_decode(SPFs::read(SPLoader::translatePath("{$path}.config", 'absolute', true, 'json')), true);
$settings = array();
foreach ($config as $section => $setting) {
$settings[str_replace('-', '.', $section)] = $setting;
}
if (SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')) {
$subConfig = json_decode(SPFs::read(SPLoader::translatePath("{$path}.{$this->templateType}.{$task}", 'absolute', true, 'json')), true);
if (count($subConfig)) {
foreach ($subConfig as $section => $subSettings) {
foreach ($subSettings as $k => $v) {
$settings[str_replace('-', '.', $section)][$k] = $v;
}
}
}
}
if (isset($settings['general'])) {
foreach ($settings['general'] as $k => $v) {
$this->_tCfg['general'][$k] = $v;
}
}
$task = SPRequest::task() == 'entry.add' ? 'entry.edit' : SPRequest::task();
if (isset($settings[$task])) {
foreach ($settings[$task] as $k => $v) {
$this->_tCfg['general'][$k] = $v;
}
}
}
Sobi::Trigger($this->name(), __FUNCTION__, array(&$this->_tCfg));
SPFactory::registry()->set('current_template', $path);
}
示例12: iconFont
protected function iconFont()
{
$font = SPRequest::cmd('font');
if (strstr($font, 'font-')) {
SPFactory::mainframe()->cleanBuffer()->customHeader();
exit(SPFs::read(SPLoader::translatePath('etc.fonts.' . $font, 'front', true, 'json')));
}
}
示例13: templateSettings
/**
* @return void
*/
protected function templateSettings()
{
if (!(isset($this->_attr['config']) && count($this->_attr['config'])) && SPLoader::translatePath("{$this->_templatePath}.config", 'absolute', true, 'json')) {
$config = json_decode(SPFs::read(SPLoader::translatePath("{$this->_templatePath}.config", 'absolute', true, 'json')), true);
$task = SPRequest::task() == 'entry.add' ? 'entry.edit' : SPRequest::task();
$settings = array();
foreach ($config as $section => $setting) {
$settings[str_replace('-', '.', $section)] = $setting;
}
if (SPLoader::translatePath("{$this->_templatePath}.{$task}", 'absolute', true, 'json')) {
$subConfig = json_decode(SPFs::read(SPLoader::translatePath("{$this->_templatePath}.{$task}", 'absolute', true, 'json')), true);
if (count($subConfig)) {
foreach ($subConfig as $section => $subSettings) {
foreach ($subSettings as $k => $v) {
$settings[str_replace('-', '.', $section)][$k] = $v;
}
}
}
}
if (isset($settings['general'])) {
foreach ($settings['general'] as $k => $v) {
$this->_attr['config'][$k] = array('_complex' => 1, '_attributes' => array('value' => $v));
}
}
if (isset($settings[$task])) {
foreach ($settings[$task] as $k => $v) {
$this->_attr['config'][$k] = array('_complex' => 1, '_attributes' => array('value' => $v));
}
}
}
}