本文整理汇总了PHP中SPRequest::task方法的典型用法代码示例。如果您正苦于以下问题:PHP SPRequest::task方法的具体用法?PHP SPRequest::task怎么用?PHP SPRequest::task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPRequest
的用法示例。
在下文中一共展示了SPRequest::task方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
SPRequest::set('task', strtolower('list.' . $this->_task));
$task = str_replace(':', '-', SPRequest::task());
$task = explode('.', $task);
if (isset($task[2]) && $task[2] == 'switch' && isset($task[3])) {
return $this->switchIndex($task[3]);
} else {
if (SPRequest::cmd('letter')) {
$this->_letter = urldecode(SPRequest::cmd('letter'));
} else {
$this->_letter = urldecode($task[2]);
SPRequest::set('letter', strtoupper($this->_letter));
if (isset($task[3])) {
$this->determineFid($task[3]);
} else {
$this->determineFid(Sobi::Cfg('alphamenu.primary_field'));
}
}
if (!strlen($this->_letter) || !Sobi::Section()) {
Sobi::Error($this->name(), SPLang::e('SITE_NOT_FOUND_MISSING_PARAMS'), SPC::NOTICE, 404, __LINE__, __FILE__);
}
if (!preg_match('/^[\\x20-\\x7f]*$/D', $this->_letter) && function_exists('mb_strtolower')) {
$this->_letter = mb_strtoupper($this->_letter);
} else {
$this->_letter = strtoupper($this->_letter);
}
$this->view();
}
}
示例2: execute
/**
*/
public function execute()
{
switch ($this->_task) {
case 'add':
$this->setModel(SPLoader::loadModel('section'));
$this->editForm();
break;
case 'edit':
Sobi::Redirect(Sobi::Url(array('task' => 'config', 'sid' => SPRequest::sid())), null, true);
break;
case 'view':
case 'entries':
Sobi::ReturnPoint();
$this->view($this->_task == 'entries', Sobi::GetUserState('entries_filter', 'sp_entries_filter', null));
break;
case 'toggle.enabled':
case 'toggle.approval':
$this->toggleState();
break;
default:
/* case plugin didn't register 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;
}
}
示例3: execute
/**
*/
public function execute()
{
$r = false;
switch ($this->_task) {
case 'chooser':
case 'expand':
SPLoader::loadClass('html.input');
$r = true;
$this->chooser($this->_task == 'expand');
break;
case 'parents':
$r = true;
$this->parents();
break;
case 'icon':
$r = true;
$this->iconChooser();
break;
default:
/* 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__);
} else {
$r = true;
}
break;
}
return $r;
}
示例4: save
protected function save()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$id = SPRequest::cmd('filter_id');
if ($id) {
$this->validate('field.filter', 'filter');
$filters = $this->getFilters();
$name = SPRequest::string('filter_name', 'Filter Name');
$msg = str_replace(array("\n", "\t", "\r"), null, SPLang::clean(SPRequest::string('filter_message', 'The data entered in the $field field contains not allowed characters')));
$regex = SPLang::clean(SPRequest::raw('filter_regex', '/^[\\.*]+$/'));
$regex = str_replace('[:apostrophes:]', '\\"' . "\\'", $regex);
$regex = base64_encode(str_replace(array("\n", "\t", "\r"), null, $regex));
$custom = 'custom';
if (isset($filters[$id]) && !strlen($filters[$id]['options'])) {
$regex = $filters[$id]['params'];
$custom = null;
}
$filters[$id] = array('params' => $regex, 'key' => $id, 'value' => $name, 'description' => $msg, 'options' => $custom);
SPFactory::registry()->saveDBSection($filters, 'fields_filter');
$this->response(Sobi::Url('filter'), Sobi::Txt('FLR.MSG_FILTER_SAVED'), false, 'success');
} else {
$this->response(Sobi::Url('filter'), SPLang::e('FILTER_NOT_FOUND'), true, SPC::ERROR_MSG);
}
}
示例5: setTitle
/**
* @param string $title
* @return string|void
*/
public function setTitle($title)
{
if (strstr(SPRequest::task(), '.add')) {
$title = str_replace('EDIT', 'ADD', $title);
}
$title = Sobi::Txt($title, array('field' => $this->get('field.name'), 'field_type' => $this->get('field.fieldType')));
Sobi::Trigger('setTitle', $this->name(), array(&$title));
SPFactory::header()->setTitle($title);
$this->set($title, 'site_title');
}
示例6: search
protected function search()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
// $selected = SPRequest::int( 'selected', 0 );
$ssid = SPRequest::base64('ssid');
$query = SPRequest::string('q', null);
$session = SPFactory::user()->getUserState('userSelector', null, array());
$setting = $session[$ssid];
/* get the site to display */
$site = SPRequest::int('site', 1);
$eLim = Sobi::Cfg('user_selector.entries_limit', 18);
$eLimStart = ($site - 1) * $eLim;
$params = array();
if ($query) {
$q = '%' . $query . '%';
$params = SPFactory::db()->where(array('name' => $q, 'username' => $q, 'email' => $q), 'OR');
}
try {
$count = SPFactory::db()->select('COUNT(*)', '#__users', $params, $setting['ordering'])->loadResult();
$data = SPFactory::db()->select(array('id', 'name', 'username', 'email', 'registerDate', 'lastvisitDate'), '#__users', $params, $setting['ordering'], $eLim, $eLimStart)->loadAssocList();
} catch (SPException $x) {
echo $x->getMessage();
exit;
}
$response = array('sites' => ceil($count / $eLim), 'site' => $site);
if (count($data)) {
$replacements = array();
preg_match_all('/\\%[a-z]*/', $setting['format'], $replacements);
$placeholders = array();
if (isset($replacements[0]) && count($replacements[0])) {
foreach ($replacements[0] as $placeholder) {
$placeholders[] = str_replace('%', null, $placeholder);
}
}
if (count($replacements)) {
foreach ($data as $index => $user) {
$txt = $setting['format'];
foreach ($placeholders as $attribute) {
if (isset($user[$attribute])) {
$txt = str_replace('%' . $attribute, $user[$attribute], $txt);
}
}
$data[$index]['text'] = $txt;
}
}
$response['users'] = $data;
}
SPFactory::mainframe()->cleanBuffer();
echo json_encode($response);
exit;
}
示例7: execute
public function execute()
{
$this->start = microtime(true);
$sites = $this->getSites();
$responses = array();
$status = 'working';
$message = null;
$this->format = SPRequest::bool('fullFormat') ? self::FORMAT_FULL : self::FORMAT;
// $this->format = SPRequest::bool( 'fullFormat' ) ? self::FORMAT_FULL : self::FORMAT_FULL;
$task = SPRequest::task();
if (in_array($task, array('crawler.init', 'crawler.restart'))) {
if ($task == 'crawler.restart') {
SPFactory::cache()->cleanSection(Sobi::Section());
}
SPFactory::db()->truncate(self::DB_TABLE);
$multiLang = Sobi::Cfg('lang.multimode', false);
if ($multiLang) {
$langs = SPFactory::CmsHelper()->getLanguages();
if ($multiLang && $langs) {
foreach ($langs as $lang) {
$responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section() . '&lang=' . $lang);
}
}
}
$responses[] = $this->getResponse(Sobi::Cfg('live_site') . 'index.php?option=com_sobipro&sid=' . Sobi::Section());
$sites = $this->getSites();
}
if (!count($sites) && !in_array($task, array('crawler.init', 'crawler.restart'))) {
$message = Sobi::Txt('CRAWL_URL_PARSED_DONE', SPFactory::db()->select('count(*)', self::DB_TABLE)->loadResult());
SPFactory::db()->truncate(self::DB_TABLE);
$this->response(array('status' => 'done', 'data' => array(), 'message' => $message));
}
if (count($sites)) {
$i = 0;
$timeLimit = SPRequest::int('timeLimit', self::TIME_LIMIT, 'get', true);
foreach ($sites as $site) {
if (!strlen($site)) {
continue;
}
$responses[] = $this->getResponse($site);
$i++;
if (microtime(true) - $this->start > $timeLimit) {
break;
}
}
$message = Sobi::Txt('CRAWL_URL_PARSED_WORKING', $i, count($sites));
}
$this->response(array('status' => $status, 'data' => $responses, 'message' => $message));
}
示例8: save
protected function save()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$data = SPRequest::string('bankdata', null, true);
$data = array('key' => 'bankdata', 'value' => $data, 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
try {
SPLang::saveValues($data);
} catch (SPException $x) {
$message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
$this->response(Sobi::Back(), $message, false, 'error');
}
$this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
}
示例9: Error
/**
* @param string $section - error section. I.e. Entry controller
* @param string $msg - main message
* @param int $type - error type
* @param int $code - error code
* @param int $line - file line
* @param string $file - file name
* @param null $sMsg - additional message
* @return null
*/
public static function Error($section, $msg, $type = SPC::NOTICE, $code = 0, $line = null, $file = null, $sMsg = null)
{
if ($type == 0) {
$type = SPC::NOTICE;
}
/*
* Mi., Jul 4, 2012
* So now could someone explain me what was the sense of the code below and why trigger_error was commented out??!!
*
* Mi., Jul 4, 2012
* Ok, it doesn't make much sense.
* This is what actually should be removed.
* if( Sobi::Cfg( 'debug.level', 0 ) < $type ) { return true; }
* It was the problem with the ACL when error reporting was disabled.
* But why the hell I removed the damn trigger_error from it?!!!
* Being sloppy again?!!!!
* Frack me - it means that since 20.07.2011 the whole error reporting went in nirvana??
*/
if ($type == E_USER_ERROR) {
$rType = E_ERROR;
$code = $code ? $code : 500;
} elseif ($type == E_USER_WARNING) {
$rType = E_WARNING;
} else {
$rType = $type;
}
if (Sobi::Cfg('debug.level', 0) >= $rType) {
if ($file) {
$sMsg .= sprintf('In file %s at line %d', $file, $line);
}
if (SPRequest::task()) {
$sMsg .= ' [ ' . SPRequest::task() . ' ]';
}
$error = array('section' => $section, 'message' => $msg, 'code' => $code, 'file' => $file, 'line' => $line, 'content' => $sMsg);
trigger_error('json://' . json_encode($error), $type);
}
if ($code) {
SPLoader::loadClass('base.mainframe');
SPLoader::loadClass('cms.base.mainframe');
SPFactory::mainframe()->runAway($msg, $code, SPConfig::getBacktrace());
}
return null;
}
示例10: save
protected function save()
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$this->validate('extensions.paypal', array('task' => 'paypal', 'pid' => Sobi::Section()));
SPFactory::registry()->saveDBSection(array(array('key' => 'ppurl', 'value' => SPRequest::string('ppurl')), array('key' => 'ppemail', 'value' => SPRequest::string('ppemail')), array('key' => 'ppcc', 'value' => SPRequest::string('ppcc')), array('key' => 'pprurl', 'value' => SPRequest::string('pprurl'))), 'paypal_' . Sobi::Section());
$data = array('key' => 'ppexpl', 'value' => SPRequest::string('ppexpl', null, true), 'type' => 'application', 'id' => Sobi::Section(), 'section' => Sobi::Section());
try {
SPLang::saveValues($data);
$data['key'] = 'ppsubject';
$data['value'] = SPRequest::string('ppsubject', true);
SPLang::saveValues($data);
} catch (SPException $x) {
$message = SPLang::e('DB_REPORTS_ERR', $x->getMessage());
Sobi::Error('SPPaymentBt', $message, SPC::WARNING, 0, __LINE__, __FILE__);
$this->response(Sobi::Back(), $message, false, 'error');
}
$this->response(Sobi::Back(), Sobi::Txt('MSG.ALL_CHANGES_SAVED'), false, 'success');
}
示例11: 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));
}
示例12: 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;
}
}
示例13: 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__);
}
}
}
示例14: save
protected function save($new = false)
{
if (!SPFactory::mainframe()->checkToken()) {
Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
}
$content = SPRequest::raw('file_content', null, 'post');
$file = $this->file(SPRequest::cmd('fileName'), !$new);
Sobi::Trigger('Save', $this->name(), array(&$content, &$file));
if (!$file) {
throw new SPException(SPLang::e('Missing file to save %s', SPRequest::cmd('fileName')));
}
$File = SPFactory::Instance('base.fs.file', $file);
$File->content(stripslashes($content));
try {
$File->save();
$u = array('task' => 'template.edit', 'file' => SPRequest::cmd('fileName'));
if (Sobi::Section()) {
$u['sid'] = Sobi::Section();
}
$this->response(Sobi::Url($u), Sobi::Txt('TP.FILE_SAVED'), $new, 'success');
} catch (SPException $x) {
$this->response(Sobi::Back(), $x->getMessage(), false, 'error');
}
}
示例15: entry
protected function entry($entry, $manager, $noId = false)
{
$en = array();
if (is_numeric($entry)) {
$en = $this->cachedEntry($entry, $manager, $noId);
}
if (!is_array($en) || !count($en)) {
if (is_numeric($entry)) {
$entry = SPFactory::Entry($entry);
}
$en['id'] = $entry->get('id');
$en['nid'] = $entry->get('nid');
$en['name'] = array('_complex' => 1, '_data' => $entry->get('name'), '_attributes' => array('lang' => Sobi::Lang(false)));
$en['url_array'] = array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id'));
if (strstr(SPRequest::task(), 'search') || $noId || Sobi::Cfg('section.force_category_id', false) && SPRequest::sid() == Sobi::Section()) {
$en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => $entry->get('primary'), 'sid' => $entry->get('id')));
} else {
$en['url'] = Sobi::Url(array('title' => Sobi::Cfg('sef.alias', true) ? $entry->get('nid') : $entry->get('name'), 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
}
if (Sobi::Cfg('list.entry_meta', true)) {
$en['meta'] = array('description' => $entry->get('metaDesc'), 'keys' => $this->metaKeys($entry), 'author' => $entry->get('metaAuthor'), 'robots' => $entry->get('metaRobots'));
}
if ($manager || Sobi::My('id') && Sobi::My('id') == $entry->get('owner') && Sobi::Can('entry', 'edit', 'own', Sobi::Section())) {
$en['edit_url'] = Sobi::Url(array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id')));
} else {
if (isset($en['edit_url'])) {
unset($en['edit_url']);
}
}
$en['edit_url_array'] = array('task' => 'entry.edit', 'pid' => SPRequest::sid(), 'sid' => $entry->get('id'));
$en['created_time'] = $entry->get('createdTime');
$en['updated_time'] = $entry->get('updatedTime');
$en['valid_since'] = $entry->get('validSince');
$en['valid_until'] = $entry->get('validUntil');
$this->fixTimes($en);
if ($entry->get('state') == 0) {
$en['state'] = 'unpublished';
} else {
if (strtotime($entry->get('validUntil')) != 0 && strtotime($entry->get('validUntil')) < time()) {
$en['state'] = 'expired';
} elseif (strtotime($entry->get('validSince')) != 0 && strtotime($entry->get('validSince')) > time()) {
$en['state'] = 'pending';
} else {
$en['state'] = 'published';
}
}
$en['author'] = $entry->get('owner');
$en['counter'] = $entry->get('counter');
$en['approved'] = $entry->get('approved');
// $en[ 'confirmed' ] = $entry->get( 'confirmed' );
if (Sobi::Cfg('list.entry_cats', true)) {
$cats = $entry->get('categories');
$categories = array();
if (count($cats)) {
$cn = SPLang::translateObject(array_keys($cats), array('name', 'alias'));
}
foreach ($cats as $cid => $cat) {
$categories[] = array('_complex' => 1, '_data' => SPLang::clean($cn[$cid]['value']), '_attributes' => array('lang' => Sobi::Lang(false), 'id' => $cat['pid'], 'position' => $cat['position'], 'url' => Sobi::Url(array('sid' => $cat['pid'], 'title' => Sobi::Cfg('sef.alias', true) ? $cat['alias'] : $cat['name']))));
}
$en['categories'] = $categories;
}
$fields = $entry->getFields();
if (count($fields)) {
// foreach ( $fields as $field ) {
// if ( $field->enabled( 'vcard' ) && $field->get( 'id' ) != Sobi::Cfg( 'entry.name_field' ) ) {
// $struct = $field->struct();
// $options = null;
// if ( isset( $struct[ '_options' ] ) ) {
// $options = $struct[ '_options' ];
// unset( $struct[ '_options' ] );
// }
// $f[ $field->get( 'nid' ) ] = array(
// '_complex' => 1,
// '_data' => array(
// 'label' => array(
// '_complex' => 1,
// '_data' => $field->get( 'name' ),
// '_attributes' => array( 'lang' => Sobi::Lang( false ), 'show' => $field->get( 'withLabel' ) )
// ),
// 'data' => $struct,
// ),
// '_attributes' => array( 'id' => $field->get( 'id' ), 'type' => $field->get( 'type' ), 'suffix' => $field->get( 'suffix' ), 'position' => $field->get( 'position' ), 'css_class' => ( strlen( $field->get( 'cssClass' ) ) ? $field->get( 'cssClass' ) : 'spField' ) )
// );
// if ( Sobi::Cfg( 'list.field_description', false ) ) {
// $f[ $field->get( 'nid' ) ][ '_data' ][ 'description' ] = array( '_complex' => 1, '_xml' => 1, '_data' => $field->get( 'description' ) );
// }
// if ( $options ) {
// $f[ $field->get( 'nid' ) ][ '_data' ][ 'options' ] = $options;
// }
// if ( isset( $struct[ '_xml_out' ] ) && count( $struct[ '_xml_out' ] ) ) {
// foreach ( $struct[ '_xml_out' ] as $k => $v )
// $f[ $field->get( 'nid' ) ][ '_data' ][ $k ] = $v;
// }
// }
// }
$en['fields'] = $this->fieldStruct($fields, 'vcard');
}
SPFactory::cache()->addObj($entry, 'entry', $entry->get('id'))->addObj($en, 'entry_struct', $entry->get('id'));
unset($en['url_array']);
unset($en['edit_url_array']);
//.........这里部分代码省略.........