本文整理汇总了PHP中Sobi::Reg方法的典型用法代码示例。如果您正苦于以下问题:PHP Sobi::Reg方法的具体用法?PHP Sobi::Reg怎么用?PHP Sobi::Reg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sobi
的用法示例。
在下文中一共展示了Sobi::Reg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: menu
protected function menu(&$data)
{
if (Sobi::Cfg('general.top_menu', true)) {
$data['menu'] = array('front' => array('_complex' => 1, '_data' => Sobi::Reg('current_section_name'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('sid' => Sobi::Section())))));
if (Sobi::Can('section.search')) {
$data['menu']['search'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.SEARCH'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'search', 'sid' => Sobi::Section()))));
}
if (Sobi::Can('entry', 'add', 'own', Sobi::Section())) {
$data['menu']['add'] = array('_complex' => 1, '_data' => Sobi::Txt('MN.ADD_ENTRY'), '_attributes' => array('lang' => Sobi::Lang(false), 'url' => Sobi::Url(array('task' => 'entry.add', 'sid' => SPRequest::sid()))));
}
}
}
示例2: __callStatic
public static function __callStatic($name, $args)
{
if (defined('SOBIPRO_ADM')) {
return call_user_func_array(array('self', '_' . $name), $args);
} else {
static $className = false;
if (!$className) {
$package = Sobi::Reg('current_template');
if (SPFs::exists(Sobi::FixPath($package . '/input.php'))) {
$path = Sobi::FixPath($package . '/input.php');
ob_start();
$content = file_get_contents($path);
$class = array();
preg_match('/\\s*(class)\\s+(\\w+)/', $content, $class);
if (isset($class[2])) {
$className = $class[2];
} else {
Sobi::Error('Custom Input Class', SPLang::e('Cannot determine class name in file %s.', str_replace(SOBI_ROOT, null, $path)), SPC::WARNING, 0);
return false;
}
require_once $path;
} else {
$className = true;
}
}
if (is_string($className) && method_exists($className, $name)) {
return call_user_func_array(array($className, $name), $args);
} else {
return call_user_func_array(array('self', '_' . $name), $args);
}
}
}
示例3: loadData
/**
* @param int $sid
* @return void
*/
public function loadData($sid)
{
if ($this->_off) {
return null;
}
$this->sid = $sid;
$fdata = Sobi::Reg('fields_data_' . $sid, array());
$this->suffix = SPLang::clean($this->suffix);
if ($sid && count($fdata) && isset($fdata[$this->id])) {
$this->_fData = $fdata[$this->id];
$this->lang = $this->_fData->lang;
$this->_rawData = $this->_fData->baseData;
$this->_data = $this->_fData->baseData;
// if the field has own method we have to re-init
$this->checkMethod('loadData');
if ($this->_type && method_exists($this->_type, 'loadData')) {
$this->_type->loadData($sid, $this->_fData, $this->_rawData, $this->_data);
}
if ($this->editLimit > 0 && is_numeric($this->_fData->editLimit)) {
$this->editLimit = $this->_fData->editLimit;
} elseif ($this->editLimit < 0) {
$this->editLimit = 2;
} else {
$this->editLimit = 2;
}
// if the limit has been reached - this field cannot be required
if (!Sobi::Can('entry.manage.*') && $this->editLimit < 1 && in_array(SPRequest::task(), array('entry.save', 'entry.edit', 'entry.submit'))) {
$this->required = false;
$this->enabled = false;
$this->_off = true;
}
} else {
$fdata = Sobi::Reg('editcache');
if (is_array($fdata) && isset($fdata[$this->nid])) {
$this->_data = $fdata[$this->nid];
$this->_rawData = $fdata[$this->nid];
} else {
$this->checkMethod('loadData');
if ($this->_type && method_exists($this->_type, 'loadData')) {
$this->_type->loadData($sid, $this->_fData, $this->_rawData, $this->_data);
} else {
$this->_rawData = SPFactory::db()->select('baseData', 'spdb_field_data', array('sid' => $this->sid, 'fid' => $this->fid, 'lang' => Sobi::Lang(false)))->loadResult();
}
}
}
if (!$this->isFree && SPRequest::task() == 'entry.edit') {
/* in case we are editing - check if this field wasn't paid already */
SPLoader::loadClass('services.payment');
if (SPPayment::check($sid, $this->id)) {
$this->fee = 0;
$this->isFree = true;
}
}
}
示例4: initIcons
protected function initIcons()
{
if (!count($this->_icons)) {
if (Sobi::Reg('current_template') && SPFs::exists(Sobi::Reg('current_template') . '/js/icons.json')) {
$this->_icons = json_decode(Sobi::Reg('current_template') . '/js/icons.json', true);
} else {
$this->_icons = json_decode(SPFs::read(SOBI_PATH . '/etc/icons.json'), true);
}
}
}
示例5: getLink
private function getLink($button)
{
$link = '#';
if (isset($button['type'])) {
switch ($button['type']) {
case 'help':
$link = 'https://www.sigsiu.net/help_screen/' . Sobi::Reg('help_task', SPRequest::task());
break;
case 'url':
if (isset($button['sid']) && $button['sid'] == 'true') {
$link = Sobi::Url(array('task' => $button['task'], 'sid' => SPRequest::sid('request', SPRequest::int('pid'), true)));
} else {
$link = Sobi::Url($button['task'] ? $button['task'] : $button['url']);
}
break;
}
}
return $link;
}
示例6: save
/**
* (non-PHPdoc)
* @see Site/lib/models/SPDBObject#save()
*/
public function save($request = 'post')
{
$this->loadFields(Sobi::Section(), true);
// Thu, Feb 19, 2015 12:12:47 - it should be actually "beforeSave"
Sobi::Trigger($this->name(), 'Before' . ucfirst(__FUNCTION__), array($this->id));
/* save the base object data */
/* @var SPdb $db */
$db = SPFactory::db();
$db->transaction();
if (!$this->nid || SPRequest::task() == 'entry.clone') {
$this->nid = SPRequest::string($this->nameField, null, false, $request);
$this->nid = $this->createAlias();
$this->name = $this->nid;
}
if (Sobi::Cfg('entry.publish_limit', 0) && !defined('SOBI_ADM_PATH')) {
SPRequest::set('entry_createdTime', 0, $request);
SPRequest::set('entry_validSince', 0, $request);
SPRequest::set('entry_validUntil', 0, $request);
$this->validUntil = gmdate('Y-m-d H:i:s', time() + Sobi::Cfg('entry.publish_limit', 0) * 24 * 3600);
}
$preState = Sobi::Reg('object_previous_state');
parent::save($request);
$nameField = $this->nameField();
/* get the fields for this section */
foreach ($this->fields as $field) {
/* @var $field SPField */
try {
if ($field->enabled('form', $preState['new'])) {
$field->saveData($this, $request);
} else {
$field->finaliseSave($this, $request);
}
if ($field->get('id') == $nameField) {
/* get the entry name */
$this->name = $field->getRaw();
/* save the nid (name id) of the field where the entry name is saved */
$this->nameField = $field->get('nid');
}
} catch (SPException $x) {
if (SPRequest::task() != 'entry.clone') {
$db->rollback();
throw new SPException(SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()));
} else {
Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELS_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
}
$values = array();
/* get categories */
$cats = Sobi::Reg('request_categories');
if (!count($cats)) {
$cats = SPRequest::arr('entry_parent', SPFactory::registry()->get('request_categories', array()), $request);
}
/* by default it should be comma separated string */
if (!count($cats)) {
$cats = SPRequest::string('entry_parent', null, $request);
if (strlen($cats) && strpos($cats, ',')) {
$cats = explode(',', $cats);
foreach ($cats as $i => $cat) {
$c = (int) trim($cat);
if ($c) {
$cats[$i] = $c;
} else {
unset($cats[$i]);
}
}
} elseif (strlen($cats)) {
$cats = array((int) $cats);
}
}
if (is_array($cats) && count($cats)) {
foreach ($cats as $i => $v) {
if (!$v) {
unset($cats[$i]);
}
}
}
if (is_array($cats) && count($cats)) {
/* get the ordering in these categories */
try {
$db->select('pid, MAX(position)', 'spdb_relations', array('pid' => $cats, 'oType' => 'entry'), null, 0, 0, false, 'pid');
$cPos = $db->loadAssocList('pid');
$currPos = $db->select(array('pid', 'position'), 'spdb_relations', array('id' => $this->id, 'oType' => 'entry'))->loadAssocList('pid');
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
/* set the right position */
foreach ($cats as $i => $cat) {
$copy = 0;
if (!$this->approved) {
$copy = isset($this->categories[$cats[$i]]) ? 0 : 1;
} else {
$db->delete('spdb_relations', array('id' => $this->id, 'oType' => 'entry'));
}
if (isset($currPos[$cat])) {
$pos = $currPos[$cat]['position'];
//.........这里部分代码省略.........
示例7: init
/**
* init tree
* @param int $sid - sobi id / section id
* @param int $current - actually displayed category
* @return string $tree
*/
public function init($sid, $current = 0)
{
$head =& SPFactory::header();
if (defined('SOBIPRO_ADM')) {
$head->addCssFile('tree', true);
} else {
if (Sobi::Reg('current_template_path', null) && SPFs::exists(Sobi::Reg('current_template_path') . 'css/tree.css')) {
$head->addCssFile('absolute.' . Sobi::Reg('current_template_path') . 'css/tree.css');
} else {
$head->addCssFile('tree');
}
}
$tree = null;
$matrix = null;
$this->_sid = $sid;
if ($current) {
$this->startScript($current);
}
$section = $this->getSection($sid);
$sectionLink = $this->parseLink($section);
$sectionName = $section->get('name');
$childs = $this->getChilds($sid);
// if( count( $cats ) ) {
// foreach ( $cats as $i => $cat ) {
// $childs[ $cat->get( 'name' ).$i ] = $cat;
// }
// }
// ksort( $childs );
$countNodes = count($childs, 0);
$lastNode = 0;
$tree .= "\n\t<{$this->_tag} class=\"sigsiuTree {$this->_id}SigsiuTree\">";
$tree .= "\n\t\t<{$this->_tag} class=\"sigsiuTreeNode\" id=\"{$this->_id}stNode0\">";
if (!in_array($sid, $this->_disabled)) {
$tree .= "<a href=\"{$sectionLink}\" id=\"{$this->_id}_imgFolderUrl0\"><img id=\"{$this->_id}0\" src=\"{$this->_images['root']}\" alt=\"{$sectionName}\"/></a>";
} else {
$tree .= "<img id=\"{$this->_id}0\" src=\"{$this->_images['root']}\" alt=\"{$sectionName}\"/>";
}
if (!in_array($sid, $this->_disabled)) {
$tree .= "<a href=\"{$sectionLink}\" rel=\"{$sid}\" data-sid=\"{$sid}\" class=\"treeNode\" id=\"{$this->_id}_CatUrl0\">{$sectionName}</a>";
} else {
$tree .= $sectionName;
}
$tree .= "</{$this->_tag}>";
$tree .= "\n\t\t<{$this->_tag} id=\"{$this->_id}\" class=\"clip\" style=\"display: block;\">";
if (count($childs)) {
foreach ($childs as $cat) {
$countNodes--;
// clean string produces htmlents and these are invalid in XML
$catName = $cat->get('name');
$hasChilds = count($cat->getChilds('category'));
$cid = $cat->get('id');
$url = $this->parseLink($cat);
$disabled = in_array($cid, $this->_disabled) ? true : false;
$tree .= "\n\t\t\t<{$this->_tag} class=\"sigsiuTreeNode\" id=\"{$this->_id}stNode{$cid}\">";
if ($hasChilds) {
if ($countNodes == 0 && !$disabled) {
$lastNode = $cid;
$tree .= "\n\t\t\t\t\t<a href=\"javascript:{$this->_id}_stmExpand( {$cid}, 0, {$this->_pid} );\" id=\"{$this->_id}_imgUrlExpand{$cid}\">\n\t\t\t\t\t\t<img src=\"{$this->_images['plusBottom']}\" id=\"{$this->_id}_imgExpand{$cid}\" style=\"border-style:none;\" alt=\"expand\"/>\n\t\t\t\t\t</a>";
$matrix .= "\n{$this->_id}_stmImgMatrix[ {$cid} ] = new Array( 'plusBottom' );";
} elseif (!$disabled) {
$tree .= "\n\t\t\t\t\t<a href=\"javascript:{$this->_id}_stmExpand( {$cid}, 0, {$this->_pid} );\" id=\"{$this->_id}_imgUrlExpand{$cid}\">\n\t\t\t\t\t\t<img src=\"{$this->_images['plus']}\" id=\"{$this->_id}_imgExpand{$cid}\" style=\"border-style:none;\" alt=\"expand\"/>\n\t\t\t\t\t</a>";
$matrix .= "\n{$this->_id}_stmImgMatrix[ {$cid} ] = new Array( 'plus' );";
} else {
$tree .= "\n\t\t\t\t\t<img src=\"{$this->_images['join']}\" id=\"{$this->_id}_imgExpand{$cid}\" style=\"border-style:none;\" alt=\"expand\"/>";
$matrix .= "\n{$this->_id}_stmImgMatrix[ {$cid} ] = new Array( 'plus' );";
}
} else {
if ($countNodes == 0 && !$disabled) {
$lastNode = $cid;
$tree .= "\n\t\t\t\t\t<img src=\"{$this->_images['joinBottom']}\" style=\"border-style:none;\" id=\"{$this->_id}_imgJoin{$cid}\" alt=\"\"/>";
$matrix .= "\n{$this->_id}_stmImgMatrix[ {$cid} ] = new Array( 'join' );";
} elseif (!$disabled) {
$tree .= "\n\t\t\t\t\t<img src=\"{$this->_images['join']}\" style=\"border-style:none;\" id=\"{$this->_id}_imgJoin{$cid}\" alt=\"\"/>";
$matrix .= "\n{$this->_id}_stmImgMatrix[ {$cid} ] = new Array( 'joinBottom' );";
} else {
$tree .= "\n\t\t\t\t\t<img src=\"{$this->_images['joinBottom']}\" id=\"{$this->_id}_imgExpand{$cid}\" style=\"border-style:none;\" alt=\"expand\"/>";
$matrix .= "\n{$this->_id}_stmImgMatrix[ {$cid} ] = new Array( 'plus' );";
}
}
if (!$disabled) {
$tree .= "\n\t\t\t\t\t<a href=\"{$url}\" id=\"{$this->_id}_imgFolderUrl{$cid}\">\n\t\t\t\t\t\t<img src=\"{$this->_images['folder']}\" style=\"border-style:none;\" id=\"{$this->_id}_imgFolder{$cid}\" alt=\"\"/>\n\t\t\t\t\t</a>\n\t\t\t\t\t<a href=\"{$url}\" rel=\"{$cid}\" data-sid=\"{$cid}\" class=\"treeNode\" id=\"{$this->_id}_CatUrl{$cid}\">\n\t\t\t\t\t\t{$catName}\n\t\t\t\t\t</a>";
} else {
$tree .= "\n\t\t\t\t\t<img src=\"{$this->_images['disabled']}\" style=\"border-style:none;\" id=\"{$this->_id}_imgFolder{$cid}\" alt=\"\"/>\n\t\t\t\t\t{$catName}\n\t\t\t\t\t</a>";
}
$tree .= "\n\t\t\t</{$this->_tag}>";
if ($hasChilds && !$disabled) {
$tree .= "\n\t\t\t<{$this->_tag} id=\"{$this->_id}_childsContainer{$cid}\" class=\"clip\" style=\"display: block; display:none;\"></{$this->_tag}>";
}
}
}
$tree .= "\n\t\t</{$this->_tag}>";
$tree .= "\n\t</{$this->_tag}>\n\n";
$this->createScript($lastNode, $childs, $matrix, $head);
$this->tree = $tree;
//.........这里部分代码省略.........
示例8: trigger
/**
* @param string $action
* @param string $subject
* @param mixed $params
* @return bool
*/
public function trigger($action, $subject = null, $params = array())
{
static $actions = array();
static $count = 0;
$action = ucfirst($action) . ucfirst($subject);
$action = str_replace('SP', null, $action);
$task = Sobi::Reg('task', SPRequest::task());
$task = strlen($task) ? $task : '*';
if (strstr($task, '.')) {
$t = explode('.', $task);
$task = $t[0] . '.' . $t[1];
}
/**
* Joomla! -> Unable to load renderer class
*/
if ($action == 'ParseContent' && SPRequest::cmd('format') == 'raw') {
return;
}
$actions[$count++] = $action;
// this always
SPFactory::mainframe()->trigger($action, $params);
// SPConfig::debOut( $action, false, false, true );
/**
* An Application should not trigger other applications
* Apps are running non parallel
* Exception, if an app will an action to be
* triggered this action has to begin with App
*/
/*
* it's important to write comments in own code ..
* It may be also helpful to read own comments sometimes
* How the hell "has to begin with App" == substr( $action, 0, 3 ) != 'App' ) ???
* ========================================================================================
* Note for intelligent people: it caused for example that the payment method wasn't delivered to the notification App
*/
if ($count < 2 || substr($action, 0, 3) == 'App') {
/* load all plugins having method for this action */
if (!isset($this->_actions[$task])) {
$this->load($task);
}
/* if there were any plugin for this action, check if these are loaded */
if (count($this->_actions[$task])) {
foreach ($this->_actions[$task] as $plugin) {
/* in case this plugin wasn't initialised */
if (!isset($this->_plugins[$plugin])) {
$this->initPlugin($plugin);
}
/* call the method */
if (isset($this->_plugins[$plugin]) && $this->_plugins[$plugin]->provide($action)) {
call_user_func_array(array($this->_plugins[$plugin], $action), $params);
}
}
}
}
// SPConfig::debOut( $action, true, false, true );
unset($actions[$count]);
$count--;
return true;
}
示例9: saveData
/**
* Gets the data for a field and save it in the database
* @param SPEntry $entry
* @param string $request
* @throws SPException
* @return bool
*/
public function saveData(&$entry, $request = 'POST')
{
if (!$this->enabled) {
return false;
}
if ($this->method == 'fixed') {
$fixed = $this->fixedCid;
$fixed = explode(',', $fixed);
$data = array();
if (count($fixed)) {
foreach ($fixed as $cid) {
$data[] = trim($cid);
}
}
if (!count($data)) {
throw new SPException(SPLang::e('FIELD_CC_FIXED_CID_NOT_SELECTED', $this->name));
}
} else {
$data = $this->verify($entry, $request);
}
$time = SPRequest::now();
$IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
$uid = Sobi::My('id');
/* if we are here, we can save these data */
/* @var SPdb $db */
$db = SPFactory::db();
/* collect the needed params */
$params = array();
$params['publishUp'] = $entry->get('publishUp');
$params['publishDown'] = $entry->get('publishDown');
$params['fid'] = $this->fid;
$params['sid'] = $entry->get('id');
$params['section'] = Sobi::Reg('current_section');
$params['lang'] = Sobi::Lang();
$params['enabled'] = $entry->get('state');
$params['params'] = null;
$params['options'] = null;
$params['baseData'] = SPConfig::serialize($data);
$params['approved'] = $entry->get('approved');
$params['confirmed'] = $entry->get('confirmed');
/* if it is the first version, it is new entry */
if ($entry->get('version') == 1) {
$params['createdTime'] = $time;
$params['createdBy'] = $uid;
$params['createdIP'] = $IP;
}
$params['updatedTime'] = $time;
$params['updatedBy'] = $uid;
$params['updatedIP'] = $IP;
$params['copy'] = !$entry->get('approved');
if (Sobi::My('id') == $entry->get('owner')) {
--$this->editLimit;
}
$params['editLimit'] = $this->editLimit;
/* save it */
try {
/* Notices:
* If it was new entry - insert
* If it was an edit and the field wasn't filled before - insert
* If it was an edit and the field was filled before - update
* " ... " and changes are not autopublish it should be insert of the copy .... but
* " ... " if a copy already exist it is update again
* */
$db->insertUpdate('spdb_field_data', $params);
} catch (SPException $x) {
Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
/* if it wasn't edited in the default language, we have to try to insert it also for def lang */
if (Sobi::Lang() != Sobi::DefLang()) {
$params['lang'] = Sobi::DefLang();
try {
$db->insert('spdb_field_data', $params, true, true);
} catch (SPException $x) {
Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
/** Last important thing - join selected categories */
$cats = SPFactory::registry()->get('request_categories', array());
$cats = array_unique(array_merge($cats, $data));
SPFactory::registry()->set('request_categories', $cats);
if ($this->method == 'select' && $this->isPrimary) {
$db->update('spdb_object', array('parent' => $data[0]), array('id' => $params['sid']));
}
}
示例10: listFields
/**
* List all fields in this section
*/
private function listFields()
{
/* @var SPdb $db */
$ord = $this->parseOrdering('forder', 'position.asc');
SPLoader::loadClass('html.input');
Sobi::ReturnPoint();
/* create menu */
$sid = Sobi::Reg('current_section');
$menu = SPFactory::Instance('views.adm.menu', 'field.list', $sid);
$cfg = SPLoader::loadIniFile('etc.adm.section_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));
/* 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());
try {
$results = SPFactory::db()->select('*', 'spdb_field', array('section' => $sid), $ord)->loadObjectList();
} catch (SPException $x) {
// SPConfig::debOut(SPFactory::db()->getQuery());
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
$fields = array();
if (count($results)) {
foreach ($results as $result) {
$field = SPFactory::Model('field', true);
$field->extend($result);
$fields[] = $field;
}
}
$fieldTypes = $this->getFieldTypes();
$subMenu = array();
foreach ($fieldTypes as $type => $group) {
asort($group);
$subMenu[] = array('label' => $type, 'element' => 'nav-header');
foreach ($group as $t => $l) {
$subMenu[] = array('type' => null, 'task' => 'field.add.' . $t, 'label' => $l, 'icon' => 'tasks', 'element' => 'button');
}
}
SPFactory::View('field', true)->addHidden($sid, 'sid')->assign($fields, 'fields')->assign($subMenu, 'fieldTypes')->assign(Sobi::Section(true), 'section')->assign($menu, 'menu')->assign(Sobi::GetUserState('fields.order', 'forder', 'position.asc'), 'ordering')->assign($this->_task, 'task')->determineTemplate('field', 'list')->display();
}
示例11: storeView
/**
*/
public function storeView($head)
{
if (!Sobi::Cfg('cache.xml_enabled') || $this->_cachedView || Sobi::My('id') && Sobi::Cfg('cache.xml_no_reg')) {
return false;
}
if ($this->view['xml']) {
$xml = $this->view['xml'];
$template = Sobi::Reg('cache_view_template');
if (!$template) {
$template = $this->view['template'];
$template = str_replace(SPLoader::translateDirPath(Sobi::Cfg('section.template'), 'templates'), null, $template);
}
$root = $xml->documentElement;
$root->removeChild($root->getElementsByTagName('visitor')->item(0));
if ($root->getElementsByTagName('messages')->length) {
$root->removeChild($root->getElementsByTagName('messages')->item(0));
}
/** @var $header DOMDocument */
$header = SPFactory::Instance('types.array')->toXML($head, 'header', true);
$root->appendChild($xml->importNode($header->documentElement, true));
if ($this->view['data'] && count($this->view['data'])) {
$data = SPFactory::Instance('types.array')->toXML($this->view['data'], 'cache-data', true);
$root->appendChild($xml->importNode($data->documentElement, true));
}
$request = $this->viewRequest();
$request['template'] = $template;
$configFiles = SPFactory::registry()->get('template_config');
$request['configFile'] = str_replace('"', "'", json_encode($configFiles));
$request['cid'] = 'NULL';
$request['created'] = 'FUNCTION:NOW()';
$fileName = md5(serialize($request));
$request['fileName'] = $fileName;
$filePath = SPLoader::path('var.xml.' . $fileName, 'front', false, 'xml');
$content = $xml->saveXML();
$content = str_replace(' ', ' ', $content);
$content = preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', null, $content);
$matches = array();
preg_match_all('/<(category|entry|subcategory)[^>]*id="(\\d{1,})"/', $content, $matches);
try {
$cid = SPFactory::db()->insert('spdb_view_cache', $request, false, true)->insertid();
$relations = array(SPRequest::sid() => array('cid' => $cid, 'sid' => SPRequest::sid()));
if (isset($matches[2])) {
$ids = array_unique($matches[2]);
foreach ($ids as $sid) {
$relations[$sid] = array('cid' => $cid, 'sid' => $sid);
}
}
SPFactory::db()->insertArray('spdb_view_cache_relation', $relations);
SPFs::write($filePath, $content);
} catch (SPException $x) {
Sobi::Error('XML-Cache', $x->getMessage());
}
}
}
示例12: chooser
/**
* Show category chooser
*
*/
protected function chooser($menu = false)
{
$out = SPRequest::cmd('out', null);
$exp = SPRequest::int('expand', 0);
$multi = SPRequest::int('multiple', 0);
$tpl = SPRequest::word('treetpl', null);
/* load the SigsiuTree class */
$tree = SPLoader::loadClass('mlo.tree');
$ordering = defined('SOBI_ADM_PATH') ? Sobi::GetUserState('categories.order', 'corder', 'position.asc') : Sobi::Cfg('list.categories_ordering');
/* create new instance */
$tree = new $tree($ordering);
/* set link */
if ($menu) {
$tree->setId('menuTree');
if (defined('SOBIPRO_ADM')) {
$link = Sobi::Url(array('sid' => '{sid}'), false, false, true);
} else {
$link = Sobi::Url(array('sid' => '{sid}'));
}
} else {
$link = "javascript:SP_selectCat( '{sid}' )";
}
$tree->setHref($link);
/* set the task to expand the tree */
$tree->setTask('category.chooser');
/* disable the category which is currently edited - category cannot be within it self */
if (!$multi) {
if (SPRequest::sid() != Sobi::Section()) {
$tree->disable(SPRequest::sid());
}
$tree->setPid(SPRequest::sid());
} else {
$tree->disable(Sobi::Reg('current_section'));
}
/* case we extending existing tree */
if ($out == 'xml' && $exp) {
$pid = SPRequest::int('pid', 0);
$pid = $pid ? $pid : SPRequest::sid();
$tree->setPid($pid);
$tree->disable($pid);
$tree->extend($exp);
} else {
/* init the tree for the current section */
$tree->init(Sobi::Reg('current_section'));
/* load model */
if (!$this->_model) {
$this->setModel(SPLoader::loadModel('category'));
}
/* create new view */
$class = SPLoader::loadView('category');
$view = new $class();
/* assign the task and the tree */
$view->assign($this->_task, 'task');
$view->assign($tree, 'tree');
$view->assign($this->_model, 'category');
/* select template to show */
if ($tpl) {
$view->setTemplate('category.' . $tpl);
} elseif ($multi) {
$view->setTemplate('category.mchooser');
} else {
$view->setTemplate('category.chooser');
}
Sobi::Trigger('Category', 'ChooserView', array(&$view));
$view->chooser();
}
}
示例13: routeObj
/**
* @return bool
*/
private function routeObj()
{
try {
$ctrl = SPFactory::Controller($this->_model->oType);
if ($ctrl instanceof SPController) {
$this->setController($ctrl);
if ($this->_model->id == SPRequest::sid()) {
// just to use the pre-fetched entry
if ($this->_model->oType == 'entry') {
$e = SPFactory::Entry($this->_model->id);
// object has been stored anyway in the SPFactory::object method
// and also already initialized
// therefore it will be now rewritten and because the init flag is set to true
// the name is getting lost
// $e->extend( $this->_model );
$this->_ctrl->setModel($e);
} else {
$this->_ctrl->setModel(SPLoader::loadModel($this->_model->oType));
$this->_ctrl->extend($this->_model);
}
} else {
$this->_ctrl->extend(SPFactory::object(SPRequest::sid()));
}
$this->_ctrl->setTask($this->_task);
}
} catch (SPException $x) {
if (defined('SOBI_TESTS')) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot set controller. %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
} else {
SPFactory::mainframe()->setRedirect(Sobi::Reg('live_site'), SPLang::e('PAGE_NOT_FOUND'), SPC::ERROR_MSG, true);
}
}
return true;
}
示例14: editForm
/**
*/
private function editForm()
{
$sid = SPRequest::int('pid');
$sid = $sid ? $sid : SPRequest::sid();
$view = SPFactory::View('entry', true);
$this->checkTranslation();
/* if adding new */
if (!$this->_model) {
$this->setModel(SPLoader::loadModel('entry'));
}
$this->_model->formatDatesToEdit();
$id = $this->_model->get('id');
if (!$id) {
$this->_model->set('state', 1);
$this->_model->set('approved', 1);
} else {
$view->assign($view->languages(), 'languages-list');
}
$this->_model->loadFields(Sobi::Reg('current_section'), true);
$this->_model->formatDatesToEdit();
if ($this->_model->isCheckedOut()) {
SPFactory::message()->error(Sobi::Txt('EN.IS_CHECKED_OUT', $this->_model->get('name')), false);
} else {
/* check out the model */
$this->_model->checkOut();
}
/* get fields for this section */
/* @var SPEntry $this ->_model */
$fields = $this->_model->get('fields');
if (!count($fields)) {
throw new SPException(SPLang::e('CANNOT_GET_FIELDS_IN_SECTION', Sobi::Reg('current_section')));
}
$revisionChange = false;
$rev = SPRequest::cmd('revision');
$revisionsDelta = array();
if ($rev) {
$revision = SPFactory::message()->getRevision(SPRequest::cmd('revision'));
if (isset($revision['changes']) && count($revision['changes'])) {
SPFactory::message()->warning(Sobi::Txt('HISTORY_REVISION_WARNING', $revision['changedAt']), false);
foreach ($fields as $i => $field) {
if ($field->get('enabled') && $field->enabled('form')) {
if (isset($revision['changes']['fields'][$field->get('nid')])) {
$revisionData = $revision['changes']['fields'][$field->get('nid')];
} else {
$revisionData = null;
}
$currentData = $field->getRaw();
if (is_array($revisionData) && !is_array($currentData)) {
try {
$currentData = SPConfig::unserialize($currentData);
} catch (SPException $x) {
}
}
if ($revisionData || $currentData) {
if (md5(serialize($currentData)) != md5(serialize($revisionData))) {
$field->revisionChanged()->setRawData($revisionData);
}
}
$fields[$i] = $field;
}
}
unset($revision['changes']['fields']);
foreach ($revision['changes'] as $attr => $value) {
if ($value != $this->_model->get($attr)) {
$revisionsDelta[$attr] = $value;
$this->_model->setRevData($attr, $value);
}
}
$revisionChange = true;
} else {
SPFactory::message()->error(Sobi::Txt('HISTORY_REVISION_NOT_FOUND'), false)->setSystemMessage();
}
}
$f = array();
foreach ($fields as $field) {
if ($field->get('enabled') && $field->enabled('form')) {
$f[] = $field;
}
}
/* create the validation script to check if required fields are filled in and the filters, if any, match */
$this->createValidationScript($fields);
$view->assign($this->_model, 'entry');
/* get the categories */
$cats = $this->_model->getCategories(true);
if (count($cats)) {
$tCats = array();
foreach ($cats as $cid) {
/* ROTFL ... damn I like arrays ;-) */
$tCats2 = SPFactory::config()->getParentPath($cid, true);
if (is_array($tCats2) && count($tCats2)) {
$tCats[] = implode(Sobi::Cfg('string.path_separator'), $tCats2);
}
}
if (count($tCats)) {
$view->assign(implode("\n", $tCats), 'parent_path');
}
$view->assign(implode(", ", $cats), 'parents');
} elseif ($this->_model->get('valid')) {
//.........这里部分代码省略.........
示例15: submit
private function submit()
{
$xml = $this->payment();
$visitor = $this->get('visitor');
$id = $this->get('entry')->get('id');
SPLoader::loadClass('mlo.input');
if ($id) {
$saveUrl = Sobi::Url(array('task' => 'entry.save', 'pid' => Sobi::Reg('current_section'), 'sid' => $id), false, false);
$backUrl = Sobi::Url(array('task' => 'entry.edit', 'pid' => Sobi::Reg('current_section'), 'sid' => $id));
} else {
$saveUrl = Sobi::Url(array('task' => 'entry.save', 'pid' => Sobi::Reg('current_section')), false, false);
$backUrl = Sobi::Url(array('task' => 'entry.add', 'pid' => Sobi::Reg('current_section')));
}
$xml['buttons']['save_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::button('save', Sobi::Txt('EN.PAYMENT_SAVE_ENTRY_BT'), array('href' => $saveUrl)))));
$xml['buttons']['back_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::button('back', Sobi::Txt('EN.PAYMENT_BACK_BT'), array('href' => $backUrl)))));
$xml['buttons']['cancel_button'] = array('_complex' => 1, '_data' => array('data' => array('_complex' => 1, '_xml' => 1, '_data' => SPHtml_Input::submit('save', Sobi::Txt('EN.CANCEL_BT')), '_data' => SPHtml_Input::button('cancel', Sobi::Txt('EN.CANCEL_BT'), array('href' => Sobi::Url(array('task' => 'entry.cancel', 'pid' => Sobi::Reg('current_section'))))))));
$xml['save_url'] = $saveUrl;
$xml['visitor'] = $this->visitorArray($visitor);
$this->_attr = $xml;
Sobi::Trigger('PaymentView', ucfirst(__FUNCTION__), array(&$this->_attr));
}