本文整理汇总了PHP中SPRequest::set方法的典型用法代码示例。如果您正苦于以下问题:PHP SPRequest::set方法的具体用法?PHP SPRequest::set怎么用?PHP SPRequest::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPRequest
的用法示例。
在下文中一共展示了SPRequest::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
*/
public function execute()
{
$r = false;
switch ($this->_task) {
case 'edit':
case 'add':
$r = true;
$this->editForm();
break;
case 'approve':
case 'unapprove':
$r = true;
$this->approval($this->_task == 'approve');
break;
case 'up':
case 'down':
$r = true;
$this->singleReorder($this->_task == 'up');
break;
case 'clone':
$r = true;
$this->_model = null;
SPRequest::set('entry_id', 0, 'post');
SPRequest::set('entry_state', 0, 'post');
$this->save(false, true);
break;
case 'saveWithRevision':
$this->save(true);
break;
case 'reorder':
$r = true;
$this->reorder();
break;
case 'reject':
$r = true;
$this->reject();
break;
case 'revisions':
$r = true;
$this->revisions();
break;
case 'search':
$this->search();
break;
default:
/* case plugin didn't registered this task, it was an error */
if (!parent::execute()) {
Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
} else {
$r = true;
}
break;
}
return $r;
}
示例2: execute
/**
*/
public function execute()
{
$r = false;
SPRequest::set('task', $this->_type . '.' . $this->_task);
switch ($this->_task) {
case 'edit':
case 'add':
Sobi::ReturnPoint();
SPLoader::loadClass('html.input');
$this->editForm();
break;
case 'approve':
case 'unapprove':
$r = true;
$this->approve($this->_task == 'approve');
break;
case 'publish':
case 'unpublish':
case 'hide':
$r = true;
$this->state($this->_task == 'publish');
break;
case 'submit':
$this->submit();
break;
case 'details':
$this->visible();
$this->details();
Sobi::ReturnPoint();
break;
case 'payment':
$this->payment();
break;
default:
if (!parent::execute()) {
Sobi::Error('entry_ctrl', SPLang::e('TASK_NOT_FOUND'), SPC::NOTICE, 404, __LINE__, $this->name());
} else {
$r = true;
}
break;
}
return $r;
}
示例3: execute
/**
*/
public function execute()
{
if (!Sobi::Can('section.search')) {
if ($this->_task != 'suggest') {
if (Sobi::Cfg('redirects.section_search_enabled') && strlen(Sobi::Cfg('redirects.section_search_url', null))) {
$this->escape(Sobi::Cfg('redirects.section_search_url', null), SPLang::e(Sobi::Cfg('redirects.section_search_msg', 'UNAUTHORIZED_ACCESS')), Sobi::Cfg('redirects.section_search_msgtype', SPC::ERROR_MSG));
} else {
Sobi::Error($this->name(), SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
} else {
exit;
}
}
$r = false;
SPLoader::loadClass('env.cookie');
SPLoader::loadClass('env.browser');
SPRequest::set('task', $this->_type . '.' . $this->_task);
switch ($this->_task) {
case 'results':
case 'view':
$this->form();
$r = true;
break;
case 'search':
$this->search();
$r = true;
break;
case 'suggest':
$this->suggest();
$r = true;
break;
default:
if (!parent::execute()) {
Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
}
break;
}
return $r;
}
示例4: execute
public function execute()
{
SPRequest::set('task', $this->_type . '.' . $this->_task);
if (strstr($this->_task, '.')) {
$task = explode('.', $this->_task);
$class = SPLoader::loadClass('opt.listing.' . $task[0], false, null, true);
} else {
$class = SPLoader::loadClass('opt.listing.' . $this->_task, false, null, true);
}
if ($class) {
$imp = class_implements($class);
if (is_array($imp) && in_array('SPListing', $imp)) {
/** @noinspection PhpIncludeInspection $compatibility */
$listing = new $class();
if (!isset($class::$compatibility)) {
define('SOBI_LEGACY_LISTING', true);
if (strstr($this->_task, '.')) {
$t = explode('.', $this->_task);
$listing->setTask($t[0]);
} else {
$listing->setTask($this->_task);
}
} else {
$listing->setTask($this->_task);
}
return $listing->execute();
} else {
Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND Wrong class definition', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
}
} else {
/* case parent didn't registered this task, it was an error */
if (!parent::execute() && $this->name() == __CLASS__) {
Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
}
}
}
示例5: execute
/**
*/
public function execute()
{
/* parent class executes the plugins */
SPRequest::set('task', $this->_type . '.' . $this->_task);
switch ($this->_task) {
case 'front':
$this->getSections();
/** @var $view SPAdmPanelView */
$view = SPFactory::View('front');
/* load template config */
// $this->tplCfg( 'front' );
// $view->setConfig( $this->_tCfg, 'general' );
$view->determineTemplate('front', SPC::DEFAULT_TEMPLATE);
$view->assign($this->_sections, 'sections');
$view->display();
break;
default:
/* case parents or plugin didn't registered this task, it was an error */
if (!parent::execute()) {
Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
}
break;
}
}
示例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: determineFid
protected function determineFid($nid)
{
if (is_numeric($nid)) {
$field = SPFactory::db()->select(array('fid', 'fieldType', 'nid'), 'spdb_field', array('section' => Sobi::Section(), 'fid' => $nid))->loadObject();
} else {
$field = SPFactory::db()->select(array('fid', 'fieldType', 'nid'), 'spdb_field', array('section' => Sobi::Section(), 'nid' => $nid))->loadObject();
}
$this->_field = $field->fid;
$this->_nid = $field->nid;
$this->_fieldType = $field->fieldType;
SPRequest::set('alpha_field', strtolower($this->_nid));
}
示例8: defined
* @author
* Name: Sigrid Suski & Radek Suski, Sigsiu.NET GmbH
* Email: sobi[at]sigsiu.net
* Url: http://www.Sigsiu.NET
* @copyright Copyright (C) 2006 - 2015 Sigsiu.NET GmbH (http://www.sigsiu.net). All rights reserved.
* @license GNU/GPL Version 3
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation, and under the additional terms according section 7 of GPL v3.
* See http://www.gnu.org/licenses/gpl.html and http://sobipro.sigsiu.net/licenses.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* $Date: 2015-02-19 13:24:35 +0100 (Thu, 19 Feb 2015) $
* $Revision: 4387 $
* $Author: Radek Suski $
* $HeadURL: file:///opt/svn/SobiPro/Component/branches/SobiPro-1.1/Admin/field/edit.php $
*/
defined('SOBIPRO') || exit('Restricted access');
SPRequest::set('hidemainmenu', 1);
SPFactory::header()->addCSSCode('body { min-width: 1200px; }')->addJsCode("\n\t\t\tvar SPErrMsg = SobiPro.Txt( 'Please fill in all required fields!' );\n\t function submitbutton( task )\n\t {\n\t var form = document.adminForm;\n\t if ( task == 'field.cancel' || SPValidateForm() ) {\n\t if ( SP_id( 'field.nid' ).value == '' ) {\n\t SP_id( 'field.nid' ).value = SP_id( 'field.name' ).value;\n\t }\n\t var nid = SP_id( 'field.nid' ).value;\n\t nid = nid.replace( /(\\s+)/g, '_' );\n\t nid = nid.replace( /[^\\w_]/g, '' );\n\t SP_id( 'field.nid' ).value = nid.toLowerCase();\n\t if ( SP_id( 'field.nid' ).value.indexOf( 'field_' ) != 0 ) {\n\t SP_id( 'field.nid' ).value = 'field_' + SP_id( 'field.nid' ).value;\n\t }\n\t submitform( task );\n\t }\n\t }\n\t SobiPro.jQuery( document ).ready( function ()\n\t {\n\t \tJoomla.submitform = function ( task )\n\t {\n\t submitbutton( task );\n\t }\n\t } );\n ");
$row = 0;
$this->trigger('OnStart');
?>
<div>
<fieldset class="adminform">
<table class="admintable">
<tr class="row<?php
echo ++$row % 2;
?>
">
<td class="key">
<?php
$this->txt('FM.FIELD_LABEL');
示例9: view
/**
*/
protected function view($allEntries, $term = null)
{
if ($allEntries) {
SPRequest::set('task', 'section.entries');
} else {
SPRequest::set('task', 'section.view');
}
/* @var SPdb $db */
$db = SPFactory::db();
$c = array();
$e = array();
if (!Sobi::Section()) {
Sobi::Error('Section', SPLang::e('Missing section identifier'), SPC::ERROR, 500, __LINE__, __FILE__);
}
$this->_model->init(Sobi::Section());
/* get the lists ordering and limits */
$eLimit = Sobi::GetUserState('entries.limit', 'elimit', Sobi::Cfg('admin.entries-limit', 25));
$cLimit = Sobi::GetUserState('categories.limit', 'climit', Sobi::Cfg('admin.categories-limit', 15));
$eLimStart = SPRequest::int('eSite', 0);
$cLimStart = SPRequest::int('cSite', 0);
/* get child categories and entries */
/* @todo: need better method - the query can be very large with lot of entries */
if (!$allEntries) {
$e = $this->_model->getChilds();
$c = $this->_model->getChilds('category');
} elseif (!($term && $allEntries)) {
$c = $this->_model->getChilds('category', true);
$c[] = Sobi::Section();
if (count($c)) {
try {
$e1 = $db->dselect('id', 'spdb_relations', array('pid' => $c, 'oType' => 'entry'))->loadResultArray();
$e2 = $db->dselect('sid', 'spdb_field_data', array('section' => Sobi::Section(), 'fid' => Sobi::Cfg('entry.name_field')))->loadResultArray();
$e = array_merge($e1, $e2);
$e = array_unique($e);
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
} else {
try {
$e = $db->dselect('sid', 'spdb_field_data', array('section' => Sobi::Section(), 'fid' => Sobi::Cfg('entry.name_field'), 'baseData' => "%{$term}%"))->loadResultArray();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
// just in case the given site is grater than all existing sites
$cCount = count($c);
$cPages = ceil($cCount / $cLimit);
if ($cLimStart > $cPages) {
$cLimStart = $cPages;
SPRequest::set('cSite', $cPages);
}
$eCount = count($e);
$ePages = ceil($eCount / $eLimit);
if ($eLimStart > $ePages) {
$eLimStart = $ePages;
SPRequest::set('eSite', $ePages);
}
$entries = array();
$categories = array();
/* if there are entries in the root */
if (count($e)) {
try {
$Limit = $eLimit > 0 ? $eLimit : 0;
$LimStart = $eLimStart ? ($eLimStart - 1) * $eLimit : $eLimStart;
$eOrder = $this->parseOrdering('entries', 'eorder', 'position.asc', $Limit, $LimStart, $e);
$results = $db->select('id', 'spdb_object', array('id' => $e, 'oType' => 'entry'), $eOrder, $Limit, $LimStart)->loadResultArray();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
foreach ($results as $i => $entry) {
$entries[$i] = $entry;
}
}
/* if there are categories in the root */
if (count($c)) {
try {
$LimStart = $cLimStart ? ($cLimStart - 1) * $cLimit : $cLimStart;
$Limit = $cLimit > 0 ? $cLimit : 0;
$cOrder = $this->parseOrdering('categories', 'corder', 'order.asc', $Limit, $LimStart, $c);
$results = $db->select('id', 'spdb_object', array('id' => $c, 'oType' => 'category'), $cOrder, $Limit, $LimStart)->loadResultArray();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
foreach ($results as $i => $category) {
$categories[$i] = SPFactory::Category($category);
}
}
/* create menu */
$mClass = SPLoader::loadClass('views.adm.menu');
$menu = new $mClass('section.' . $this->_task, Sobi::Section());
/* load the menu definition */
$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);
}
//.........这里部分代码省略.........
示例10: 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;
}
$del = SPRequest::bool($this->nid . '_delete', false, $request);
$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);
}
/**
* @var SPImage $orgImage
*/
if ($cache) {
$orgImage = SPFactory::Instance('base.fs.image', $data);
$orgImage->move($path . $orgName);
} else {
$orgImage = SPFactory::Instance('base.fs.image');
$nameArray = explode('.', $orgName);
//.........这里部分代码省略.........
示例11: 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);
//.........这里部分代码省略.........
示例12: save
/**
* Save existing field
*/
protected function save($clone = false)
{
$sets = array();
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$fid = SPRequest::int('fid');
$field = SPFactory::Model('field', true);
if ($fid) {
$f = $this->loadField($fid);
$field->extend($f);
} else {
$field->loadType(SPRequest::cmd('field_fieldType'));
}
$nid = SPRequest::cmd('field_nid');
if (!$nid || !strstr($nid, 'field_')) {
/** give me my spaces back!!! */
$nid = strtolower(str_replace('-', '_', SPLang::nid('field_' . SPRequest::string('field_name'))));
SPRequest::set('field_nid', $nid);
}
$this->getRequest();
$this->validate($field);
if ($clone || !$fid) {
try {
$fid = $field->saveNew($this->attr);
$field->save($this->attr);
} catch (SPException $x) {
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $x->getMessage(), false, SPC::ERROR_MSG);
}
} else {
try {
$field->save($this->attr);
} catch (SPException $x) {
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $x->getMessage(), false, SPC::ERROR_MSG);
}
}
$alias = $field->get('nid');
$fieldSets = $field->get('sets');
if (is_array($fieldSets) && count($fieldSets)) {
$sets = array_merge($fieldSets, $sets);
}
$sets['fid'] = $field->get('fid');
$sets['field.nid'] = $alias;
/* in case we are changing the sort by field */
if (Sobi::Cfg('list.entries_ordering') == $alias && $field->get('nid') != $alias) {
SPFactory::config()->saveCfg('list.entries_ordering', $field->get('nid'));
}
SPFactory::cache()->cleanSection();
if ($this->_task == 'apply' || $clone) {
if ($clone) {
$msg = Sobi::Txt('FM.FIELD_CLONED');
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $msg);
} else {
$msg = Sobi::Txt('MSG.ALL_CHANGES_SAVED');
$this->response(Sobi::Url(array('task' => 'field.edit', 'fid' => $fid, 'sid' => SPRequest::sid())), $msg, false, 'success', array('sets' => $sets));
}
} else {
$this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'));
}
}
示例13: view
/**
*/
protected function view()
{
/* @var SPdb $db */
$db = SPFactory::db();
SPRequest::set('task', 'category.view');
/* get the lists ordering and limits */
$eLimit = Sobi::GetUserState('entries.limit', 'elimit', Sobi::Cfg('admin.entries-limit', 25));
$cLimit = Sobi::GetUserState('categories.limit', 'climit', Sobi::Cfg('admin.categories-limit', 15));
$eLimStart = SPRequest::int('eSite', 0);
$cLimStart = SPRequest::int('cSite', 0);
/* get child categories and entries */
$e = $this->_model->getChilds();
$c = $this->_model->getChilds('category');
// just in case the given site is grater than all existing sites
$cCount = count($c);
$cPages = ceil($cCount / $cLimit);
if ($cLimStart > $cPages) {
$cLimStart = $cPages;
SPRequest::set('cSite', $cPages);
}
$eCount = count($e);
$ePages = ceil($eCount / $eLimit);
if ($eLimStart > $ePages) {
$eLimStart = $ePages;
SPRequest::set('eSite', $ePages);
}
$entries = array();
$categories = array();
SPLoader::loadClass('models.dbobject');
/* if there are categories in the root */
if (count($c)) {
try {
$LimStart = $cLimStart ? ($cLimStart - 1) * $cLimit : $cLimStart;
$Limit = $cLimit > 0 ? $cLimit : 0;
$cOrder = $this->parseOrdering('categories', 'corder', 'position.asc', $Limit, $LimStart, $c);
$db->select('*', 'spdb_object', array('id' => $c, 'oType' => 'category'), $cOrder, $Limit, $LimStart);
$results = $db->loadResultArray();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
foreach ($results as $i => $category) {
$categories[$i] = SPFactory::Category($category);
// new $cClass();
//$categories[ $i ]->extend( $category );
}
}
/* if there are entries in the root */
if (count($e)) {
try {
$LimStart = $eLimStart ? ($eLimStart - 1) * $eLimit : $eLimStart;
$Limit = $eLimit > 0 ? $eLimit : 0;
$eOrder = $this->parseOrdering('entries', 'eorder', 'position.asc', $Limit, $LimStart, $e);
$entries = $db->select('*', 'spdb_object', array('id' => $e, 'oType' => 'entry'), $eOrder, $Limit, $LimStart)->loadResultArray();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
}
$entriesName = SPFactory::config()->nameField()->get('name');
$entriesField = SPFactory::config()->nameField()->get('nid');
/* create menu */
SPLoader::loadClass('views.adm.menu');
$menu = new SPAdmSiteMenu('section.' . $this->_task, SPRequest::sid());
/* load the menu definition */
$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);
}
}
/* 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(Sobi::Reg('current_section'), SPRequest::sid());
/* add the tree into the menu */
$menu->addCustom('AMN.ENT_CAT', $tree->getTree());
/* get view class */
$view = SPFactory::View('category', true);
$view->assign($eLimit, '$eLimit')->assign($eLimit, 'entries-limit')->assign($cLimit, 'categories-limit')->assign(SPRequest::int('eSite', 1), 'entries-site')->assign(SPRequest::int('cSite', 1), 'categories-site')->assign($cCount, 'categories-count')->assign($eCount, 'entries-count')->assign($this->_task, 'task')->assign($this->_model, 'category')->assign($categories, 'categories')->assign($entries, 'entries')->assign($this->customCols(), 'fields')->assign($entriesName, 'entries_name')->assign($entriesField, 'entries_field')->assign($menu, 'menu')->assign(Sobi::GetUserState('entries.eorder', 'eorder', 'position.asc'), 'eorder')->assign(Sobi::GetUserState('categories.corder', 'corder', 'position.asc'), 'corder')->assign($this->_model->get('name'), 'category_name')->addHidden(Sobi::Section(), 'pid')->addHidden(SPRequest::sid(), 'sid');
Sobi::Trigger('Category', 'View', array(&$view));
$view->display();
}
示例14: execute
/**
* @return bool
*/
public function execute()
{
$r = false;
SPRequest::set('task', $this->_type . '.' . $this->_task);
switch ($this->_task) {
/* if someone want edit an object - just check if it is not checked out */
case 'edit':
if ($this->_model && $this->_model->isCheckedOut()) {
Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), Sobi::Txt('MSG.OBJ_CHECKED_OUT', array('type' => Sobi::Txt($this->_type))), SPC::ERROR_MSG, true);
exit;
}
break;
case 'hide':
case 'publish':
$r = true;
$this->state($this->_task == 'publish');
break;
case 'toggle.enabled':
case 'toggle.approval':
$r = true;
$this->toggleState();
break;
case 'apply':
case 'save':
case 'saveAndNew':
$r = true;
$this->save($this->_task == 'apply');
break;
case 'cancel':
if (defined('SOBI_ADM_PATH')) {
$this->checkIn(SPRequest::sid(), false);
$this->response(Sobi::Back());
}
$this->checkIn(SPRequest::int('sid'));
$r = true;
if (SPRequest::int('sid')) {
$url = Sobi::Url(array('sid' => SPRequest::sid()));
} elseif (SPRequest::int('pid')) {
$url = Sobi::Url(array('sid' => SPRequest::int('pid')));
} else {
$url = Sobi::Url(array('sid' => Sobi::Section()));
}
$this->response($url);
break;
case 'delete':
if ($this->_model->get('owner') == Sobi::My('id') && $this->authorise('delete', 'own') || $this->authorise('delete', '*')) {
$r = true;
if ($this->_model->get('id')) {
$this->_model->delete();
if ($this->_type == 'entry' && !defined('SOBIPRO_ADM')) {
if (SPRequest::int('pid')) {
$url = Sobi::Url(array('sid' => SPRequest::int('pid')));
} else {
$url = Sobi::Url(array('sid' => Sobi::Section()));
}
} else {
$url = Sobi::Back();
}
$this->response($url, Sobi::Txt('MSG.OBJ_DELETED', array('type' => Sobi::Txt($this->_type))), false);
} else {
$this->response(Sobi::Back(), Sobi::Txt('CHANGE_NO_ID'), false, SPC::ERROR_MSG);
}
}
break;
case 'view':
$r = true;
$this->visible();
$this->view();
break;
case 'resetCounter':
if ($this->authorise('edit', '*')) {
$this->_model->countVisit(true);
exit(true);
}
break;
default:
$r = Sobi::Trigger('Execute', $this->name(), array(&$this));
break;
}
return $r;
}
示例15: parseXml
protected function parseXml()
{
$header = $this->_xml->getElementsByTagName('header')->item(0);
if ($header->hasChildNodes()) {
foreach ($header->childNodes as $node) {
if (!strstr($node->nodeName, '#')) {
$params = array();
$this->parseParams($node, $params);
$this->callHeader($node->nodeName, $params[$node->nodeName]);
}
}
}
$data = $this->_xml->getElementsByTagName('cache-data')->item(0);
if ($data && $data->hasChildNodes()) {
foreach ($data->childNodes as $node) {
if (!strstr($node->nodeName, '#')) {
$params = array();
$this->parseParams($node, $params);
if (isset($params['hidden']) && is_array($params['hidden']) && count($params['hidden'])) {
foreach ($params['hidden'] as $k => $v) {
$this->addHidden($v, $k);
}
}
if (isset($params['request']) && is_array($params['request']) && count($params['request'])) {
foreach ($params['request'] as $k => $v) {
SPRequest::set($k, $v, 'get');
}
}
if (isset($params['pathway']) && is_array($params['pathway']) && count($params['pathway'])) {
foreach ($params['pathway'] as $v) {
SPFactory::mainframe()->addToPathway($v['name'], $v['url']);
}
}
}
}
}
$visitor = $this->visitorArray(SPFactory::user()->getCurrent());
if (is_array($visitor) && isset($visitor['_data'])) {
$this->importData($this->_xml->documentElement, $visitor, 'visitor');
}
$messages = SPFactory::message()->getMessages();
$info = array();
if (count($messages)) {
foreach ($messages as $type => $content) {
$info[$type] = array_values($content);
}
}
if (is_array($info)) {
$this->importData($this->_xml->documentElement, $info, 'messages');
}
$this->_xml->formatOutput = true;
}