本文整理汇总了PHP中SPFactory::registry方法的典型用法代码示例。如果您正苦于以下问题:PHP SPFactory::registry方法的具体用法?PHP SPFactory::registry怎么用?PHP SPFactory::registry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPFactory
的用法示例。
在下文中一共展示了SPFactory::registry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($task = null, $sid = 0)
{
SPFactory::header()->addCSSFile('menu', true)->addJsFile('menu', true);
$this->_task = $task ? $task : SPRequest::task();
$this->_sid = $sid;
SPFactory::registry()->set('adm_menu', $this);
}
示例2: screen
private function screen()
{
$data = SPFactory::registry()->loadDBSection('paypal_' . Sobi::Section())->get('paypal_' . Sobi::Section());
if (!count($data)) {
$data = SPFactory::registry()->loadDBSection('paypal')->get('paypal');
}
$ppexpl = SPLang::getValue('ppexpl', 'application', Sobi::Section());
$ppsubj = SPLang::getValue('ppsubject', 'application', Sobi::Section());
if (!strlen($ppsubj)) {
$ppsubj = SPLang::getValue('ppsubject', 'application');
}
$this->getView('paypal')->assign($tile, 'title')->assign($data['ppurl']['value'], 'ppurl')->assign($data['ppemail']['value'], 'ppemail')->assign($data['pprurl']['value'], 'pprurl')->assign($data['ppcc']['value'], 'ppcc')->assign($ppexpl, 'ppexpl')->assign($ppsubj, 'ppsubject')->determineTemplate('extensions', 'paypal')->display();
}
示例3: PaymentMethodView
/**
* This function have to add own string into the given array
* Basically: $methods[ $this->id ] = "Some String To Output";
* Optionally the value can be also SobiPro Arr2XML array.
* Check the documentation for more information
* @param array $methods
* @param SPEntry $entry
* @param array $payment
* @param bool $message
* @return void
*/
public function PaymentMethodView(&$methods, $entry, &$payment, $message = false)
{
$data = SPFactory::registry()->loadDBSection('paypal_' . Sobi::Section())->get('paypal_' . Sobi::Section());
if (!count($data)) {
$data = SPFactory::registry()->loadDBSection('paypal')->get('paypal');
}
$cfg = SPLoader::loadIniFile('etc.paypal');
$rp = $cfg['general']['replace'];
$to = $cfg['general']['replace'] == ',' ? '.' : ',';
$amount = str_replace($rp, $to, $payment['summary']['sum_brutto']);
$values = array('entry' => $entry, 'amount' => preg_replace('/[^0-9\\.,]/', null, $amount), 'ppurl' => SPLang::replacePlaceHolders($data['ppurl']['value'], $entry), 'ppemail' => SPLang::replacePlaceHolders($data['ppemail']['value'], $entry), 'pprurl' => SPLang::replacePlaceHolders($data['pprurl']['value'], $entry), 'ppcc' => SPLang::replacePlaceHolders($data['ppcc']['value'], $entry));
$expl = SPLang::replacePlaceHolders(SPLang::getValue('ppexpl', 'plugin', Sobi::Section()), $values);
$subject = SPLang::replacePlaceHolders(SPLang::getValue('ppsubject', 'plugin', Sobi::Section()), $values);
$values['expl'] = $expl;
$values['subject'] = $subject;
$values['ip'] = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
$methods[$this->id] = array('content' => $message ? $this->raw($cfg, $values) : $this->content($cfg, $values), 'title' => Sobi::Txt('APP.PPP.PAY_TITLE'));
}
示例4: cachedView
public function cachedView($xml, $template, $cacheId, $config = array())
{
$this->_xml = $xml;
Sobi::Trigger('Start', ucfirst(__FUNCTION__), array(&$this->_xml));
$templatePackage = SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates');
$templateOverride = SPRequest::cmd('sptpl');
if ($templateOverride) {
if (strstr($templateOverride, '.')) {
$templateOverride = str_replace('.', '/', $templateOverride);
}
$template = $templateOverride . '.xsl';
}
if (file_exists(Sobi::FixPath($templatePackage . '/' . $template))) {
$template = Sobi::FixPath($templatePackage . '/' . $template);
} else {
$type = SPFactory::db()->select('oType', 'spdb_object', array('id' => SPRequest::sid()))->loadResult();
$template = $templatePackage . '/' . $type . '/' . $template;
}
SPFactory::registry()->set('current_template', $templatePackage);
$this->_templatePath = $templatePackage;
$this->_template = str_replace('.xsl', null, $template);
$ini = array();
if (count($config)) {
foreach ($config as $file) {
$file = parse_ini_file($file, true);
foreach ($file as $section => $keys) {
if (isset($ini[$section])) {
$ini[$section] = array_merge($ini[$section], $keys);
} else {
$ini[$section] = $keys;
}
}
}
}
$this->setConfig($ini, SPRequest::task('get'));
$this->parseXml();
$this->validateData($cacheId);
Sobi::Trigger('After', ucfirst(__FUNCTION__), array(&$this->_xml));
}
示例5: array
/**
* @param int $sid
* @return SPCache
*/
public static function &cache($sid = 0)
{
if (!Sobi::Section()) {
$path = array();
$id = $sid;
while ($id > 0) {
try {
$id = SPFactory::db()->select('pid', 'spdb_relations', array('id' => $id))->loadResult();
if ($id) {
$path[] = (int) $id;
}
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
if (count($path)) {
$path = array_reverse($path);
}
SPFactory::registry()->set('current_section', $path[0]);
}
SPLoader::loadClass('base.cache');
return SPCache::getInstance($sid);
}
示例6: getSection
/**
* get the right section
* @return void
*/
private function getSection()
{
$pid = SPRequest::int('pid');
$pid = $pid ? $pid : $this->_sid;
if ($pid) {
$this->_model = SPFactory::object($pid);
/** @noinspection PhpParamsInspection
* @var $this ->_model stdClass
*/
if ($this->_model->oType == 'section') {
$this->_section = $this->_model->id;
} else {
$db = SPFactory::db();
$path = array();
$id = $pid;
while ($id > 0) {
try {
$db->select('pid', 'spdb_relations', array('id' => $id));
$id = $db->loadResult();
if ($id) {
$path[] = (int) $id;
}
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
$path = array_reverse($path);
$this->_section = $path[0];
}
} else {
$this->_section = '0';
}
SPFactory::registry()->set('current_section', $this->_section);
}
示例7: getView
/**
* @param string
* @return SPConfigAdmView
*/
protected function getView($task)
{
SPLoader::loadClass('html.input');
$sid = Sobi::Reg('current_section');
/* create menu */
$class = SPLoader::loadClass('views.adm.menu');
$menu = new $class($task, $sid);
/* load the menu definition */
if ($sid) {
$cfg = SPLoader::loadIniFile('etc.adm.section_menu');
} else {
$cfg = SPLoader::loadIniFile('etc.adm.config_menu');
}
Sobi::Trigger('Create', 'AdmMenu', array(&$cfg));
if (count($cfg)) {
foreach ($cfg as $section => $keys) {
$menu->addSection($section, $keys);
}
}
Sobi::Trigger('AfterCreate', 'AdmMenu', array(&$menu));
if ($sid) {
if (Sobi::Cfg('section.template') == SPC::DEFAULT_TEMPLATE && strstr(SPRequest::task(), 'config')) {
SPFactory::message()->warning(Sobi::Txt('TP.DEFAULT_WARN', 'https://www.sigsiu.net/help_screen/template.info'), false)->setSystemMessage();
}
/* create new SigsiuTree */
$tree = SPLoader::loadClass('mlo.tree');
$tree = new $tree(Sobi::GetUserState('categories.order', 'corder', 'position.asc'));
/* set link */
$tree->setHref(Sobi::Url(array('sid' => '{sid}')));
$tree->setId('menuTree');
/* set the task to expand the tree */
$tree->setTask('category.expand');
$tree->init($sid);
/* add the tree into the menu */
$menu->addCustom('AMN.ENT_CAT', $tree->getTree());
$seClass = SPLoader::loadModel('section');
$cSec = new $seClass();
$cSec->init($sid);
} else {
$cSec = array('name' => Sobi::Txt('GB.CFG.GLOBAL_CONFIGURATION'));
$menu->addCustom('GB.CFG.GLOBAL_TEMPLATES', $this->listTemplates());
}
$view = SPFactory::View('config', true);
$view->assign($task, 'task');
$view->assign($cSec, 'section');
$view->assign($menu, 'menu');
$view->addHidden(SPFactory::registry()->get('current_section'), 'sid');
return $view;
}
示例8: 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);
}
示例9: init
/**
* initialising
*
* @param string $name
* @param string $method
* @throws SPException
*/
private static function init($name, $method)
{
if (!is_string($method)) {
throw new SPException('Wrong method given: ' . get_class($method));
}
self::$method = strtoupper($method);
$name = self::$method == 'COOKIE' ? 'SPro_' . $name : $name;
self::$name = $name;
switch (self::$method) {
case 'GET':
// it's seems that Joomla! is storing the decoded variables from menu
// into $_REQUEST instead of $_GET
self::$request =& $_REQUEST;
// self::$request =& $_GET;
break;
case 'POST':
self::$request =& $_POST;
break;
case 'FILES':
self::$request =& $_FILES;
break;
case 'COOKIE':
self::$request =& $_COOKIE;
break;
case 'ENV':
self::$request =& $_ENV;
break;
case 'SERVER':
self::$request =& $_SERVER;
break;
case 'REQUESTCACHE':
self::$request =& SPFactory::registry()->__get('requestcache');
break;
default:
self::$request =& $_REQUEST;
self::$method = 'REQUEST';
break;
}
}
示例10: saveData
/**
* Gets the data for a field and save it in the database
* @param SPEntry $entry
* @param string $request
* @param bool $clone
* @throws SPException
* @return bool
*/
public function saveData(&$entry, $request = 'POST', $clone = false)
{
if (!$this->enabled) {
return false;
}
$del = SPRequest::bool($this->nid . '_delete', false, $request);
if ($clone) {
$orgSid = SPRequest::sid();
$this->loadData($orgSid);
$files = $this->getExistingFiles();
$cloneFiles = array();
if (isset($files['original']) && file_exists(SOBI_ROOT . '/' . $files['original'])) {
return $this->cloneFiles($entry, $request, $files, $cloneFiles);
}
}
$fileSize = SPRequest::file($this->nid, 'size');
$cropped = null;
static $store = null;
$cache = false;
if ($store == null) {
$store = SPFactory::registry()->get('requestcache_stored');
}
if (is_array($store) && isset($store[$this->nid])) {
if (!strstr($store[$this->nid], 'file://') && !strstr($store[$this->nid], 'directory://')) {
$data = $store[$this->nid];
$cache = true;
$orgName = SPRequest::file($this->nid, 'name', $request);
} else {
SPRequest::set($this->nid, $store[$this->nid]);
$orgName = SPRequest::file($this->nid, 'name');
$data = SPRequest::file($this->nid, 'tmp_name');
}
} else {
$data = SPRequest::file($this->nid, 'tmp_name');
$orgName = SPRequest::file($this->nid, 'name');
}
$sPath = $this->parseName($entry, $orgName, $this->savePath);
$path = SPLoader::dirPath($sPath, 'root', false);
/** Wed, Oct 15, 2014 13:51:03
* Implemented a cropper with Ajax checker.
* This is the actual method to get those files
* Other methods left for BC
* */
if (!$data) {
$directory = SPRequest::string($this->nid, $store[$this->nid], false, $request);
if (strlen($directory)) {
list($data, $dirName, $files, $coordinates) = $this->getAjaxFiles($directory);
if (count($files)) {
foreach ($files as $file) {
if ($file == '.') {
continue;
}
if ($file == '..') {
continue;
}
if (strpos($file, 'icon_') !== false) {
continue;
}
if (strpos($file, 'resized_') !== false) {
continue;
}
if (strpos($file, 'cropped_') !== false) {
$cropped = $dirName . $file;
SPFs::upload($cropped, $path . basename($cropped));
continue;
}
if (strpos($file, '.var') !== false) {
continue;
}
$fileSize = filesize($dirName . $file);
$orgName = $file;
}
}
if (strlen($coordinates)) {
$coordinates = json_decode(SPLang::clean($coordinates), true);
/** @var SPImage $croppedImage */
$croppedImage = SPFactory::Instance('base.fs.image', $dirName . $orgName);
$croppedImage->crop($coordinates['width'], $coordinates['height'], $coordinates['x'], $coordinates['y']);
$cropped = 'cropped_' . $orgName;
$croppedImage->saveAs($path . $cropped);
}
$data = strlen($cropped) ? $cropped : $dirName . $file;
}
}
$files = array();
/* if we have an image */
if ($data && $orgName) {
if ($fileSize > $this->maxSize) {
throw new SPException(SPLang::e('FIELD_IMG_TOO_LARGE', $this->name, $fileSize, $this->maxSize));
}
if ($cropped) {
SPFs::upload($dirName . $orgName, $path . $orgName);
//.........这里部分代码省略.........
示例11: Init
/**
* @deprecated since 1.1 replaced by {@link #Initialise()}
* @param int $sid - section id
* @param null $root - root of Joomla!
* @param null $lang - language
* @return null
*/
public static function Init($root = null, $lang = null, $sid = 0)
{
static $loaded = false;
if (!$loaded) {
if (!defined('SOBI_CMS')) {
define('SOBI_CMS', version_compare(JVERSION, '3.0.0', 'ge') ? 'joomla3' : (version_compare(JVERSION, '1.6.0', 'ge') ? 'joomla16' : 'joomla15'));
}
defined('SOBIPRO') || define('SOBIPRO', true);
defined('SOBI_TASK') || define('SOBI_TASK', 'task');
defined('SOBI_DEFLANG') || define('SOBI_DEFLANG', $lang);
defined('SOBI_ACL') || define('SOBI_ACL', 'front');
defined('SOBI_ROOT') || define('SOBI_ROOT', $root);
defined('SOBI_MEDIA') || define('SOBI_MEDIA', implode('/', array($root, 'media', 'sobipro')));
defined('SOBI_PATH') || define('SOBI_PATH', SOBI_ROOT . '/components/com_sobipro');
defined('SOBI_LIVE_PATH') || define('SOBI_LIVE_PATH', 'components/com_sobipro');
require_once SOBI_PATH . '/lib/base/fs/loader.php';
SPLoader::loadController('sobipro');
SPLoader::loadController('interface');
SPLoader::loadClass('base.exception');
SPLoader::loadClass('base.const');
SPLoader::loadClass('base.object');
SPLoader::loadClass('base.filter');
SPLoader::loadClass('base.request');
SPLoader::loadClass('cms.base.lang');
SPLoader::loadClass('models.dbobject');
SPLoader::loadClass('base.factory');
SPLoader::loadClass('base.config');
SPLoader::loadClass('cms.base.fs');
// in case it is a CLI call
if (isset($_SERVER['REQUEST_URI'])) {
SPFactory::config()->set('live_site', JURI::root());
}
$loaded = true;
}
if ($sid) {
$section = null;
if ($sid) {
$path = array();
$id = $sid;
$path[] = (int) $id;
while ($id > 0) {
try {
$id = SPFactory::db()->select('pid', 'spdb_relations', array('id' => $id))->loadResult();
if ($id) {
$path[] = (int) $id;
}
} catch (SPException $x) {
Sobi::Error('ExtCoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
$path = array_reverse($path);
$section = SPFactory::object($path[0]);
}
/* set current section in the registry */
SPFactory::registry()->set('current_section', $section->id);
$_config =& SPFactory::config();
/* load basic configuration settings */
$_config->addIniFile('etc.config', true);
$_config->addTable('spdb_config', $sid);
/* initialise interface config setting */
SPFactory::mainframe()->getBasicCfg();
/* initialise config */
$_config->init();
}
}
示例12: getReports
/**
* @param null $spsid
* @return array
*/
public function getReports($spsid)
{
$reports = array();
if ($this->reports[$spsid]) {
// $messages = SPConfig::serialize( $this->reports );
$reports = $this->reports[$spsid];
unset($this->reports[$spsid]);
/** Thu, Jul 31, 2014 11:12:02
* Why the hell we are setting these messages into the db again?
*/
$store = array('params' => array(), 'key' => 'queue', 'value' => date(DATE_RFC822), 'description' => null, 'options' => null);
SPFactory::registry()->saveDBSection(array('reports' => $store), 'reports');
}
return $reports;
}
示例13: tplPath
protected function tplPath()
{
if (!$this->_templatePath) {
$tpl = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
$file = explode('.', $tpl);
if (strstr($file[0], 'cms:')) {
$file[0] = str_replace('cms:', null, $file[0]);
$file = SPFactory::mainframe()->path(implode('.', $file));
$this->_templatePath = SPLoader::dirPath($file, 'root', false, null);
} else {
$this->_templatePath = SPLoader::dirPath('usr.templates.' . $tpl, 'front', false, null);
}
}
SPFactory::registry()->set('current_template_path', $this->_templatePath);
return $this->_templatePath;
}
示例14: createValidationScript
/**
* @param SPField[] $fields
* @return void
*/
protected function createValidationScript($fields)
{
/* get input filters */
$registry =& SPFactory::registry();
$registry->loadDBSection('fields_filter');
$filters = $registry->get('fields_filter');
$validate = array();
foreach ($fields as $field) {
$filter = $field->get('filter');
if ($filter && isset($filters[$filter])) {
$f = new stdClass();
$f->name = $field->get('nid');
$f->filter = base64_decode($filters[$filter]['params']);
$f->msg = Sobi::Txt('[JS]' . $filters[$filter]['description']);
$validate[] = $f;
}
}
if (count($validate)) {
Sobi::Trigger($this->name(), __FUNCTION__, array(&$validate));
$validate = json_encode($validate);
$header =& SPFactory::header();
$header->addJsVarFile('efilter', md5($validate), array('OBJ' => addslashes($validate)));
}
}
示例15: replacePlaceHolders
/**
* Parse text and replaces placeholders
* @param string $text
* @param SPDBObject $obj
* @param bool $html
* @param bool $dropEmpty
* @return string
*/
public static function replacePlaceHolders($text, $obj = null, $html = false, $dropEmpty = false)
{
preg_match_all('/{([a-zA-Z0-9\\-_\\:\\.\\%\\s]+)}/', $text, $placeHolders);
if (count($placeHolders[1])) {
foreach ($placeHolders[1] as $placeHolder) {
$replacement = null;
switch ($placeHolder) {
case 'section':
case 'section.id':
case 'section.name':
$replacement = Sobi::Section($placeHolder == 'section' || $placeHolder == 'section.name');
break;
/*
* eat own dog food is so true. Isn't it?!
*/
/*
* eat own dog food is so true. Isn't it?!
*/
case 'token':
$replacement = SPFactory::mainframe()->token();
break;
default:
if (strstr($placeHolder, 'date%')) {
$date = explode('%', $placeHolder);
$replacement = date($date[1]);
break;
}
if (strstr($placeHolder, 'cfg:')) {
$replacement = Sobi::Cfg(str_replace('cfg:', null, $placeHolder));
break;
} else {
if (strstr($placeHolder, 'messages')) {
$obj = SPFactory::registry()->get('messages');
}
$replacement = self::parseVal($placeHolder, $obj, $html);
}
}
if ($replacement && (is_string($replacement) || is_numeric($replacement))) {
$text = str_replace('{' . $placeHolder . '}', (string) $replacement, $text);
} elseif ($dropEmpty) {
$text = str_replace('{' . $placeHolder . '}', null, $text);
}
}
}
return $text;
}