本文整理汇总了PHP中Sobi::Redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Sobi::Redirect方法的具体用法?PHP Sobi::Redirect怎么用?PHP Sobi::Redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sobi
的用法示例。
在下文中一共展示了Sobi::Redirect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
示例2: delete
/**
*/
public function delete()
{
$childs = $this->getChilds('all', true);
Sobi::Trigger('Section', ucfirst(__FUNCTION__), array(&$this->id));
if (count($childs)) {
Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), Sobi::Txt('SEC.DEL_WARN'), SPC::ERROR_MSG, true);
} else {
Sobi::Trigger('delete', $this->name(), array(&$this));
$db = SPFactory::db();
try {
$db->delete('spdb_relations', "id = {$this->id} OR pid = {$this->id}");
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
try {
$db->delete('spdb_config', array('section' => $this->id));
$db->delete('spdb_plugin_section', array('section' => $this->id));
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
try {
$fids = $db->select('fid', 'spdb_field', array('section' => $this->id))->loadResultArray();
if (count($fids)) {
foreach ($fids as $fid) {
try {
$db->select('*', $db->join(array(array('table' => 'spdb_field', 'as' => 'sField', 'key' => 'fieldType'), array('table' => 'spdb_field_types', 'as' => 'sType', 'key' => 'tid'))), array('fid' => $fid));
$f = $db->loadObject();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
$field =& SPFactory::Model('field', true);
$field->extend($f);
$field->delete();
}
}
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
parent::delete();
Sobi::Trigger('afterDelete', $this->name(), array(&$this));
}
}
示例3: routeTask
/**
* Route by task
* @return bool
*/
private function routeTask()
{
$r = true;
if (strstr($this->_task, '.')) {
/* task consist of the real task and the object type */
$task = explode('.', $this->_task);
$obj = trim(array_shift($task));
$task = trim(implode('.', $task));
/* load the controller class definition and get the class name */
$ctrl = SPLoader::loadController($obj, true);
/* route task for multiple objects - e.g removing or publishing elements from a list */
$sids = SPRequest::arr('sid');
$csids = SPRequest::arr('c_sid');
$esids = SPRequest::arr('e_sid');
if (count($sids) || count($csids) || count($esids)) {
$sid = array_key_exists('sid', $_REQUEST) && is_array($_REQUEST['sid']) ? 'sid' : (array_key_exists('c_sid', $_REQUEST) ? 'c_sid' : 'e_sid');
if (count(SPRequest::arr($sid))) {
/* @var SPdb $db */
$db =& SPFactory::db();
$objects = null;
try {
$db->select('*', 'spdb_object', array('id' => SPRequest::arr($sid)));
$objects = $db->loadObjectList();
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
$r = false;
}
/** @noinspection PhpUndefinedVariableInspection */
if (count($objects)) {
$this->_ctrl = array();
foreach ($objects as $object) {
$o = $this->extendObj($object, $obj, $ctrl, $task);
if ($o) {
$this->_ctrl[] = $o;
}
}
if (!count($this->_ctrl)) {
Sobi::Error('CoreCtrl', SPLang::e('IDENTIFIER_EXPECTED'), SPC::WARNING, 0, __LINE__, __FILE__);
Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), SPLang::e('IDENTIFIER_EXPECTED'), SPC::ERROR_MSG);
}
} else {
Sobi::Error('CoreCtrl', SPLang::e('IDENTIFIER_EXPECTED'), SPC::WARNING, 0, __LINE__, __FILE__);
Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), SPLang::e('IDENTIFIER_EXPECTED'), SPC::ERROR_MSG);
$r = false;
//break;
}
} else {
Sobi::Error('CoreCtrl', SPLang::e('IDENTIFIER_EXPECTED'), SPC::WARNING, 0, __LINE__, __FILE__);
Sobi::Redirect(Sobi::GetUserState('back_url', Sobi::Url()), SPLang::e('IDENTIFIER_EXPECTED'), SPC::ERROR_MSG);
$r = false;
//break;
}
} else {
/* set controller and model */
try {
$ctrl = new $ctrl();
$this->setController($ctrl);
if ($ctrl instanceof SPController) {
$model = SPLoader::loadModel($obj, false, false);
if ($model) {
$this->_ctrl->setModel($model);
}
}
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
if ($this->_sid) {
$this->_model =& SPFactory::object($this->_sid);
}
/* if the basic object we got from the #getSection method is the same one ... */
if ($this->_model instanceof stdClass && $this->_model->oType == $obj) {
/*... extend the empty model of these data we've already got */
/** @noinspection PhpParamsInspection */
$this->_ctrl->extend($this->_model);
}
/* ... and so on... */
$this->_ctrl->setTask($task);
}
} else {
/** Special controllers not inherited from object and without model */
$task = $this->_task;
$ctrl = SPLoader::loadController($task, true);
try {
$this->setController(new $ctrl());
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot set controller. %s.', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
}
return $r;
}
示例4: ajaxResponse
protected function ajaxResponse($ajax, $message, $redirect, $type, $callback = 'SPExtensionInstaller')
{
if ($ajax) {
if ($redirect) {
SPFactory::message()->setMessage($message, false, $type);
}
$response = array('type' => $type, 'text' => $message, 'redirect' => $redirect ? Sobi::Url('extensions.installed') : false, 'callback' => $type == SPC::SUCCESS_MSG ? $callback : false);
SPFactory::mainframe()->cleanBuffer()->customHeader();
echo json_encode($response);
exit;
} elseif ($redirect) {
SPFactory::message()->setMessage($message, false, $type);
Sobi::Redirect(Sobi::Url('extensions.installed'));
} else {
return array('msg' => $message, 'msgtype' => $type);
}
}
示例5: editForm
/**
*/
private function editForm()
{
if ($this->_task != 'add') {
$sid = SPRequest::sid();
$sid = $sid ? $sid : SPRequest::int('pid');
} else {
$this->authorise($this->_task, 'own');
$this->_model = null;
$sid = SPRequest::int('pid');
// $section = SPFactory::Section( Sobi::Section() );
}
if ($this->_model && $this->_model->isCheckedOut()) {
Sobi::Redirect(Sobi::Url(array('sid' => SPRequest::sid())), Sobi::Txt('EN.IS_CHECKED_OUT', $this->_model->get('name')), SPC::ERROR_MSG, true);
}
/* determine template package */
$tplPackage = Sobi::Cfg('section.template', SPC::DEFAULT_TEMPLATE);
/* load template config */
$this->template();
$this->tplCfg($tplPackage);
/* check if we have stored last edit in cache */
$this->getCache(SPRequest::string('editentry', null, false, 'cookie'), 'editcache');
$section = SPFactory::Model('section');
$section->init(Sobi::Section());
SPFactory::cache()->setJoomlaCaching(false);
if ($this->_model) {
/* handle meta data */
SPFactory::header()->objMeta($this->_model);
/* add pathway */
SPFactory::mainframe()->addObjToPathway($this->_model);
} else {
/* handle meta data */
SPFactory::header()->objMeta($section);
if ($this->_task == 'add') {
SPFactory::header()->addKeyword($section->get('efMetaKeys'))->addDescription($section->get('efMetaDesc'));
}
SPFactory::mainframe()->addToPathway(Sobi::Txt('EN.ADD_PATH_TITLE'), Sobi::Url('current'));
SPFactory::mainframe()->setTitle(Sobi::Txt('EN.ADD_TITLE', array('section' => $section->get('name'))));
/* add pathway */
SPFactory::mainframe()->addObjToPathway($section);
$this->setModel(SPLoader::loadModel('entry'));
}
$this->_model->formatDatesToEdit();
$id = $this->_model->get('id');
if (!$id) {
$this->_model->set('state', 1);
}
if ($this->_task != 'add' && !$this->authorise($this->_task, $this->_model->get('owner') == Sobi::My('id') ? 'own' : '*')) {
throw new SPException(SPLang::e('YOU_ARE_NOT_AUTH_TO_EDIT_THIS_ENTRY'));
}
$this->_model->loadFields(Sobi::Reg('current_section'));
/* get fields for this section */
$fields = $this->_model->get('fields');
if (!count($fields)) {
throw new SPException(SPLang::e('CANNOT_GET_FIELDS_IN_SECTION', Sobi::Reg('current_section')));
}
/* create the validation script to check if required fields are filled in and the filters, if any, match */
$this->createValidationScript($fields);
/* check out the model */
$this->_model->checkOut();
$class = SPLoader::loadView('entry');
$view = new $class($this->template);
$view->assign($this->_model, 'entry');
$cache = Sobi::Reg('editcache');
/* get the categories */
if (isset($cache) && isset($cache['entry_parent'])) {
$cats = explode(',', $cache['entry_parent']);
} else {
$cats = $this->_model->getCategories(true);
}
if (count($cats)) {
$tCats = array();
foreach ($cats as $cid) {
$tCats2 = SPFactory::config()->getParentPath((int) $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');
} else {
$parent = $sid == Sobi::Reg('current_section') ? 0 : $sid;
if ($parent) {
$view->assign(implode(Sobi::Cfg('string.path_separator', ' > '), SPFactory::config()->getParentPath($parent, true)), 'parent_path');
}
$view->assign($parent, 'parents');
}
$view->assign($this->_task, 'task');
$view->assign($fields, 'fields');
$view->assign($id, 'id');
$view->assign($id, 'sid');
$view->assign(SPFactory::user()->getCurrent(), 'visitor');
$view->setConfig($this->_tCfg, $this->template);
$view->setTemplate($tplPackage . '.' . $this->templateType . '.' . ($this->template == 'add' ? 'edit' : $this->template));
$view->addHidden($sid ? $sid : SPRequest::sid(), 'pid');
$view->addHidden($id, 'sid');
$view->addHidden(SPRequest::int('pid') && SPRequest::int('pid') != $id ? SPRequest::int('pid') : Sobi::Section(), 'pid');
//.........这里部分代码省略.........
示例6: search
//.........这里部分代码省略.........
case 'any':
$this->searchWords($this->_request['phrase'] == 'all');
break;
}
$this->_results = array_unique($this->_results);
}
Sobi::Trigger('AfterBasic', 'Search', array(&$this->_results, &$this->_resultsByPriority));
/* ... now the extended search. Check which data we've received */
if (count($this->_fields)) {
$results = null;
foreach ($this->_fields as $field) {
if (isset($this->_request[$field->get('nid')]) && $this->_request[$field->get('nid')] != null) {
$this->_narrowing = true;
$fr = $field->searchData($this->_request[$field->get('nid')], Sobi::Section());
$priority = $field->get('priority');
if (is_array($fr)) {
$this->_resultsByPriority[$priority] = array_merge($this->_resultsByPriority[$priority], $fr);
}
/* if we didn't got any results before this array contains the results */
if (!is_array($results)) {
$results = $fr;
} else {
if (is_array($fr)) {
$results = array_intersect($results, $fr);
}
}
}
}
/** Tue, Oct 21, 2014 10:18:37
* No result is also a result so no "count"
* */
// if ( is_array( $results ) && count( $results ) ) {
if (is_array($results)) {
/* if we had also a string to search we have to get the intersection */
if ($searchForString) {
$this->_results = array_intersect($this->_results, $results);
} else {
$this->_results = $results;
}
}
}
$this->verify();
/** @since 1.1 - a method to narrow the search results down */
if (count($this->_fields)) {
// If we have any results already - the we are limiting results down
// if we don't have results but we were already searching then skip - because there is nothing to narrow down
// if we don't have results but we weren't searching for anything else - then we are narrowing down everything
if (count($this->_results) || !$this->_narrowing) {
foreach ($this->_fields as &$field) {
$request = isset($this->_request[$field->get('nid')]) ? $this->_request[$field->get('nid')] : null;
if ($request) {
$field->searchNarrowResults($request, $this->_results, $this->_resultsByPriority);
}
}
}
}
$this->_request['search_for'] = str_replace('%', '*', $this->_request['search_for']);
if (count($this->_results) > $searchLimit) {
SPFactory::message()->error(Sobi::Txt('SH.SEARCH_TOO_MANY_RESULTS', count($this->_results), $searchLimit), false);
$this->_resultsByPriority = array();
$this->_results = array_slice($this->_results, 0, $searchLimit);
} else {
$this->sortPriority();
}
Sobi::Trigger('AfterExtended', 'Search', array(&$this->_results, &$this->_resultsByPriority));
$req = is_array($this->_request) && count($this->_request) ? SPConfig::serialize($this->_request) : null;
$res = is_array($this->_results) && count($this->_results) ? implode(', ', $this->_results) : null;
$cre = is_array($this->_categoriesResults) && count($this->_categoriesResults) ? implode(', ', $this->_categoriesResults) : null;
/* determine the search parameters */
$attr = array('entriesResults' => array('results' => $res, 'resultsByPriority' => $this->_resultsByPriority), 'catsResults' => $cre, 'uid' => Sobi::My('id'), 'browserData' => SPConfig::serialize(SPBrowser::getInstance()));
if (strlen($req)) {
$attr['requestData'] = $req;
}
/* finally save */
try {
Sobi::Trigger('OnSave', 'Search', array(&$attr, &$ssid));
$this->_db->update('spdb_search', $attr, array('ssid' => $ssid));
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('CANNOT_CREATE_SESSION_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
}
$url = array('task' => 'search.results', 'sid' => Sobi::Section());
// For Peter's Components Anywhere extension and other
$params = Sobi::Cfg('search.params_to_pass');
if (count($params)) {
foreach ($params as $param) {
$val = SPRequest::raw($param);
if ($val) {
$url[$param] = SPRequest::raw($param);
}
}
}
/* if we cannot transfer the search id in cookie */
if (!SPRequest::cmd('ssid', null, 'cookie')) {
$url['ssid'] = $ssid;
}
if (Sobi::Cfg('cache.unique_search_url')) {
$url['t'] = microtime(true);
}
Sobi::Redirect(Sobi::Url($url));
}
示例7: execute
/**
* Route task
*/
public function execute()
{
/* parent class executes the plugins */
$r = false;
$task = $this->_task;
if (strstr($this->_task, '.')) {
$task = explode('.', $this->_task);
$this->_fieldType = $task[1];
$task = $task[0];
}
switch ($task) {
case 'list':
$r = true;
$this->listFields();
break;
case 'add':
case 'edit':
$r = true;
$this->edit();
break;
case 'cancel':
$r = true;
$this->checkIn();
$this->response(Sobi::Back());
break;
case 'addNew':
$r = true;
Sobi::Redirect(Sobi::Url(array('task' => 'field.edit', 'fid' => $this->saveNew(), 'sid' => SPRequest::sid())));
break;
case 'apply':
case 'save':
$r = true;
$this->save();
break;
case 'clone':
$r = true;
$this->save(true);
break;
case 'delete':
$r = true;
SPFactory::cache()->cleanSection();
$this->response(Sobi::Url(array('task' => 'field.list', 'pid' => Sobi::Section())), $this->delete(), true);
break;
case 'reorder':
$r = true;
$this->reorder();
break;
case 'revisions':
$r = true;
$this->revisions();
break;
case 'up':
case 'down':
$r = true;
$this->singleReorder($this->_task == 'up');
break;
case 'hide':
case 'publish':
case 'setRequired':
case 'setNotRequired':
case 'setEditable':
case 'setNotEditable':
case 'setFee':
case 'setFree':
case 'toggle':
$r = true;
$this->authorise($this->_task);
SPFactory::cache()->cleanSection();
$this->response(Sobi::Back(), $this->changeState($task), true);
break;
default:
/* case plugin didn't registered this task, it was an error */
if (!Sobi::Trigger('Execute', $this->name(), array(&$this))) {
$fid = SPRequest::int('fid');
$method = $this->_task;
if ($fid) {
SPLoader::loadModel('field', true);
$fdata = $this->loadField($fid);
$field = new SPAdmField();
$field->extend($fdata);
try {
$field->{$method}();
} catch (SPException $x) {
Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
}
} elseif (!parent::execute()) {
Sobi::Error($this->name(), SPLang::e('SUCH_TASK_NOT_FOUND', SPRequest::task()), SPC::NOTICE, 404, __LINE__, __FILE__);
}
}
break;
}
return $r;
}
示例8: response
protected function response($url, $message = null, $redirect = true, $type = SPC::INFO_MSG, $data = array(), $request = 'post')
{
if (is_array($message)) {
$type = $message['type'];
$message = $message['text'];
}
if (SPRequest::cmd('method', null, $request) == 'xhr') {
if ($redirect && $message) {
SPFactory::message()->setMessage($message, false, $type);
}
$url = str_replace('&', '&', $url);
SPFactory::mainframe()->cleanBuffer()->customHeader();
echo json_encode(array('message' => array('text' => $message, 'type' => $type), 'redirect' => array('url' => $url, 'execute' => (bool) $redirect), 'data' => $data));
exit;
} else {
if ($message) {
if (strstr($url, 'com_sobipro')) {
SPFactory::message()->setMessage($message, false, $type);
$message = null;
}
}
Sobi::Redirect($url, $message, null, $redirect);
}
}
示例9: __construct
/**
* @param string $task
* @return \SobiProCtrl
*/
function __construct($task)
{
$this->_mem = memory_get_usage();
$this->_time = microtime(true);
SPLoader::loadClass('base.exception');
set_error_handler('SPExceptionHandler');
$this->_err = ini_set('display_errors', 'on');
$this->_task = $task;
/* load all needed classes */
SPLoader::loadClass('base.const');
SPLoader::loadClass('base.factory');
SPLoader::loadClass('base.object');
SPLoader::loadClass('base.filter');
SPLoader::loadClass('base.request');
SPLoader::loadClass('sobi');
SPLoader::loadClass('base.config');
SPLoader::loadClass('cms.base.lang');
/* get sid if any */
$this->_sid = SPRequest::sid();
/* determine section */
$access = $this->getSection();
/* initialise mainframe interface to CMS */
$this->_mainframe = SPFactory::mainframe();
/* initialise config */
$this->createConfig();
ini_set('display_errors', Sobi::Cfg('debug.display_errors', false));
$this->_deb = error_reporting(Sobi::Cfg('debug.level', 0));
/* trigger plugin */
Sobi::Trigger('Start');
/* initialise translator and load language files */
SPLang::setLang(Sobi::Lang(false));
try {
SPLang::registerDomain('site');
} catch (SPException $x) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot register language domain: %s.', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
}
if (!$access) {
if (Sobi::Cfg('redirects.section_enabled', false)) {
$redirect = Sobi::Cfg('redirects.section_url', null);
$msg = Sobi::Cfg('redirects.section_msg', SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task()));
$msgtype = Sobi::Cfg('redirects.section_msgtype', 'message');
Sobi::Redirect(Sobi::Url($redirect), Sobi::Txt($msg), $msgtype, true);
} else {
SPFactory::mainframe()->runAway('You have no permission to access this site', 403, null, true);
}
}
/* load css and js files */
SPFactory::header()->initBase();
$sectionName = SPLang::translateObject($this->_section, 'name', 'section');
if ($this->_section) {
SPFactory::registry()->set('current_section_name', SPLang::clean($sectionName[$this->_section]['value']));
}
$start = array($this->_mem, $this->_time);
SPFactory::registry()->set('start', $start);
/* check if it wasn't plugin custom task */
if (!Sobi::Trigger('custom', 'task', array(&$this, SPRequest::task()))) {
/* if not, start to route */
try {
$this->route();
} catch (SPException $x) {
if (defined('SOBI_TESTS')) {
Sobi::Error('CoreCtrl', SPLang::e('Cannot route: %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;
}