当前位置: 首页>>代码示例>>PHP>>正文


PHP Context::redirect方法代码示例

本文整理汇总了PHP中Context::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::redirect方法的具体用法?PHP Context::redirect怎么用?PHP Context::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Context的用法示例。


在下文中一共展示了Context::redirect方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rpc_post_install

 public static function rpc_post_install(Context $ctx)
 {
     $data = $ctx->post;
     if (empty($data['dbtype'])) {
         throw new RuntimeException(t('Вы не выбрали тип БД.'));
     }
     $config = $ctx->config;
     // Выносим секцию main в самое начало.
     $config['main'] = array();
     if ($config->isok()) {
         throw new ForbiddenException(t('Инсталляция невозможна: конфигурационный файл уже есть.'));
     }
     $dsn = self::getDSN($data['dbtype'], $data['db'][$data['dbtype']]);
     if (!empty($data['db']['prefix'])) {
         $dsn['prefix'] = $data['db']['prefix'];
     }
     $config->set('modules/db', $dsn);
     foreach (array('modules/mail/server', 'modules/mail/from', 'main/debug/errors') as $key) {
         if (!empty($data[$key])) {
             $config->set($key, $data[$key]);
         }
     }
     $config->set('modules/files/storage', 'files');
     $config->set('modules/files/ftp', 'ftp');
     $config->set('main/tmpdir', 'tmp');
     $config->set('main/debug/allow', array('127.0.0.1', $_SERVER['REMOTE_ADDR']));
     // Создаём маршрут для главной страницы.
     $config['routes']['localhost/'] = array('title' => 'Molinos CMS', 'theme' => 'example', 'call' => 'BaseRoute::serve');
     // Проверим соединение с БД.
     $pdo = Database::connect($config->get('modules/db'));
     // Подключились, можно сохранять конфиг.
     $config->save();
     $ctx->redirect('admin/system/reload?destination=admin/system/settings');
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:34,代码来源:class.installmodule.php

示例2: rpc_get

 public static function rpc_get(Context $ctx)
 {
     $host = null;
     if ($tmp = $ctx->get('host')) {
         $host = $tmp;
     } elseif ($tmp = $ctx->get('url')) {
         $url = new url($tmp);
         $host = $url->host;
     }
     if (null === $host) {
         throw new InvalidArgumentException(t('Имя сервера нужно указать в параметре host или url.'));
     }
     $next = 'http://www.google.com/s2/favicons?domain=' . urlencode($host);
     $ctx->redirect($next);
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:15,代码来源:class.faviconrpc.php

示例3: on_clone

 /**
  * Клонирование объекта.
  * @route GET//api/node/clone.rpc
  */
 public static function on_clone(Context $ctx)
 {
     $node = Node::load($ctx->get('id'))->knock(ACL::CREATE);
     $ctx->db->beginTransaction();
     $node->published = false;
     $node->deleted = false;
     $node->created = null;
     $node->parent_id = $ctx->get('parent');
     // Копируем связи с другими объектами.
     $node->onSave("REPLACE INTO `node__rel` (`tid`, `nid`, `key`) " . "SELECT %ID%, `nid`, `key` FROM `node__rel` WHERE `tid` = ?", array($node->id));
     $node->onSave("REPLACE INTO `node__rel` (`tid`, `nid`, `key`) " . "SELECT `tid`, %ID%, `key` FROM `node__rel` WHERE `nid` = ?", array($node->id));
     $ctx->registry->broadcast('ru.molinos.cms.node.clone', array($node));
     $node->id = null;
     $node->save();
     $node->updateXML();
     $ctx->db->commit();
     $ctx->redirect("admin/node/{$node->id}?destination=" . urlencode($ctx->get('destination')));
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:22,代码来源:class.cloneapi.php

示例4: on_post_search_form

 /**
  * Поиск (обработка).
  */
 public static function on_post_search_form(Context $ctx)
 {
     $list = 'admin/content/list';
     $term = $ctx->post('search_term');
     if (null !== ($tmp = $ctx->post('search_class'))) {
         $list = Node::create($tmp)->getListURL();
     }
     $url = new url($ctx->get('from', $list));
     if (null !== ($tmp = $ctx->post('search_uid'))) {
         $url->setarg('author', $tmp);
     }
     if (null !== ($tmp = $ctx->post('search_tag'))) {
         $term .= ' tags:' . $tmp;
     }
     $url->setarg('search', trim($term));
     $url->setarg('page', null);
     $ctx->redirect($url->string());
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:21,代码来源:class.adminadvsearch.php

示例5: load

 /**
  * Main module function, executed right after module loading by Orion.
  * Handles route parsing and function callbacks.
  */
 public function load()
 {
     if ($this->route == null) {
         if (!\Orion::config()->defined('ROUTING_AUTO') || \Orion::config()->get('ROUTING_AUTO') == false) {
             throw new Exception('No route object found in controller and automatic routing is disabled.', E_USER_ERROR, get_class($this));
         }
         $this->route = new Route();
         $function = $this->route->decodeAuto();
     } else {
         $function = $this->route->decode();
     }
     if (Tools::startWith($function->getName(), '__')) {
         throw new Exception('Trying to access a resticted function, you are not allowed to use methods starting with "__".', E_USER_ERROR, get_class($this));
     }
     if (Tools::startWith($function->getName(), self::FUNCTION_PREFIX)) {
         throw new Exception('Function name in rule must be declared without function prefix ' . self::FUNCTION_PREFIX . '.', E_USER_ERROR, get_class($this));
     }
     if (!is_callable(array($this, self::FUNCTION_PREFIX . $function->getName()))) {
         Context::redirect(404);
     }
     Tools::callClassMethod($this, self::FUNCTION_PREFIX . $function->getName(), $function->getArgs());
 }
开发者ID:nijal,项目名称:Orion,代码行数:26,代码来源:controller.php

示例6: on_post_sendto

 public static function on_post_sendto(Context $ctx)
 {
     if ($pick = $ctx->post('selected')) {
         if (false === strpos($ctx->post('sendto'), '.')) {
             list($nid, $fieldName) = array($ctx->post('sendto'), null);
         } else {
             list($nid, $fieldName) = explode('.', $ctx->post('sendto'));
         }
         $params = array($fieldName);
         $sql = "REPLACE INTO `node__rel` (`tid`, `nid`, `key`) SELECT %ID%, `id`, ? FROM `node` WHERE `deleted` = 0 AND `id` " . sql::in($pick, $params);
         $ctx->db->beginTransaction();
         $node = Node::load($nid)->knock(ACL::UPDATE);
         if (isset($node->{$fieldName})) {
             unset($node->{$fieldName});
         }
         $node->onSave("DELETE FROM `node__rel` WHERE `tid` = %ID% AND `key` = ?", array($fieldName))->onSave($sql, $params)->save();
         $ctx->db->commit();
         // destiantion сейчас указывает на список, а нам надо
         // вернуться на уровень выше.
         $url = new url($ctx->get('destination'));
         if ($next = $url->arg('destination')) {
             $ctx->redirect($next);
         }
     }
     return $ctx->getRedirect();
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:26,代码来源:class.nodeapimodule.php

示例7: on_get_edit_field_form

 /**
  * Редактирование поля (форма).
  */
 public static function on_get_edit_field_form(Context $ctx, $path, array $pathinfo, $nid, $fieldName)
 {
     $node = Node::load($nid);
     if (!array_key_exists($fieldName, $schema = $node->getFormFields())) {
         throw new PageNotFoundException();
     }
     if ($url = $schema[$fieldName]->getFieldEditURL($node)) {
         $ctx->redirect($url);
     }
     $form = $node->formGet($fieldName);
     $form->addClass('tabbed');
     $page = new AdminPage(html::em('content', array('name' => 'edit'), $form->getXML($node)));
     return $page->getResponse($ctx);
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:17,代码来源:class.adminrpc.php

示例8: add_files

 /**
  * Обработка нескольких файлов.
  */
 private static function add_files(Context $ctx, array $files)
 {
     $bad = 0;
     $good = array();
     $ctx->db->beginTransaction();
     foreach ($files as $file) {
         try {
             $good[] = Node::create('file', $ctx->db)->import($file)->save()->id;
         } catch (Exception $e) {
             $bad = 1;
         }
     }
     if (count($good)) {
         $ctx->db->commit();
     }
     $next = 'admin/files/edit' . '?destination=' . urlencode($ctx->get('destination')) . '&files=' . implode('+', $good);
     if ($bad) {
         $next .= '&bad=' . $bad;
     }
     $next .= '&sendto=' . $ctx->get('sendto');
     $ctx->redirect($next);
 }
开发者ID:umonkey,项目名称:molinos-cms,代码行数:25,代码来源:class.attachmentrpc.php

示例9: init

 /**
  * Inits Orion's URI context.
  * Basically retreiving and parsing : base directory, requested URI, module URI, URI parameters, and mode.
  * 
  * Throw an Exception if no compatible URI is found.
  */
 public static function init($path)
 {
     try {
         self::$URI = $_SERVER['REQUEST_URI'];
         if (\Orion::config()->defined('BASE_DIR')) {
             self::$BASE_DIR = \Orion::config()->get('BASE_DIR');
         } else {
             self::$BASE_DIR = '';
         }
         if (\Orion::config()->defined('MODULE_SEPARATOR')) {
             self::$MODULE_SEP = \Orion::config()->get('MODULE_SEPARATOR');
         } else {
             self::$MODULE_SEP = '/';
         }
         self::$PATH = $path;
         $uri = self::getRelativeURI();
         $modelist = \Orion::config()->get('MODE_LIST');
         if ($uri == '') {
             $mode = \Orion::config()->get('DEFAULT_MODE');
             if (!array_key_exists($mode, $modelist)) {
                 throw new Exception("Default mode isn't registered in MODE_LIST", E_USER_ERROR, get_class());
             }
             \Orion::setMode($mode);
             self::$MODULE_EXT = $modelist[$mode];
             self::$MODULE_NAME = \Orion::config()->get('DEFAULT_MODULE');
             self::$MODULE_URI = '';
         } else {
             foreach ($modelist as $mode => $ext) {
                 $matches = array();
                 // Module-only URI type (ex: module.html)
                 if (preg_match('#^(\\w+)' . Tools::escapeRegex($ext) . '$#', $uri, $matches)) {
                     \Orion::setMode($mode);
                     self::$MODULE_EXT = $ext;
                     self::$MODULE_NAME = $matches[1];
                     self::$MODULE_URI = null;
                     break;
                 } elseif (preg_match('#^(\\w+)' . self::$MODULE_SEP . '(.*)' . Tools::escapeRegex($ext) . '$#', $uri, $matches)) {
                     \Orion::setMode($mode);
                     self::$MODULE_EXT = $ext;
                     self::$MODULE_NAME = $matches[1];
                     self::$MODULE_URI = $matches[2];
                     break;
                 }
             }
         }
         // No compatible URI found, redirecting.
         if (self::$MODULE_NAME == null) {
             Context::redirect(404);
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:nijal,项目名称:Orion,代码行数:59,代码来源:context.php


注:本文中的Context::redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。