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


PHP context函数代码示例

本文整理汇总了PHP中context函数的典型用法代码示例。如果您正苦于以下问题:PHP context函数的具体用法?PHP context怎么用?PHP context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: elggadmin_pagesetup

function elggadmin_pagesetup()
{
    // first login?
    global $CFG;
    if (user_flag_get('admin', $_SESSION['userid']) && !isset($CFG->elggadmin_installed)) {
        $CFG->elggadmin_installed = true;
        set_config('elggadmin_installed', true);
        header_redirect(get_url(null, 'elggadmin::config'), __gettext('Welcome to the Elgg configuration manager!'));
    }
    if (context() == 'admin') {
        if (!plugin_is_loaded('pages')) {
            elgg_messages_add(__gettext('Error: <code>elggadmin</code> plugin needs <code>pages</code> plugin to run'));
        } else {
            pages_submenu_add('elggadmin', __gettext('Site administration'), get_url(null, 'elggadmin::'), 10);
        }
    } elseif (context() == 'elggadmin') {
        if (!plugin_is_loaded('pages')) {
            elgg_messages_add(__gettext('Error: <code>elggadmin</code> plugin needs <code>pages</code> plugin to run'));
            header_redirect(get_url(null, 'admin::'));
        }
        // submenu options
        pages_submenu_add('elggadmin', __gettext('Configuration manager'), get_url(null, 'elggadmin::'));
        pages_submenu_add('elggadmin:theme', __gettext('Default theme editor'), get_url(null, 'elggadmin::theme'));
        pages_submenu_add('elggadmin:frontpage', __gettext('Frontpage template editor'), get_url(null, 'elggadmin::frontpage'));
        pages_submenu_add('elggadmin:logs', __gettext('Error log'), get_url(null, 'elggadmin::logs'));
        sidebar_add(50, 'sidebar-' . elggadmin_currentpage(), elggadmin_sidebar());
        // clear sidebar
        $clear_sidebar[] = 'sidebar-profile';
        $clear_sidebar[] = 'sidebar-' . elggadmin_currentpage();
        sidebar_remove($clear_sidebar, true);
        if (elggadmin_is_404()) {
            header('HTTP/1.0 404 Not Found');
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:35,代码来源:lib.php

示例2: dispatch

 private static function dispatch()
 {
     $route = Utils::get('appDispatch');
     if (!$route instanceof Container) {
         context()->is404();
         $route = container()->getRoute();
     }
     if (true !== container()->getIsDispatched()) {
         if (true !== $route->getCache()) {
             context()->dispatch($route);
         } else {
             $redis = context()->redis();
             $key = sha1(serialize($route->assoc())) . '::routeCache';
             $cached = $redis->get($key);
             if (!strlen($cached)) {
                 ob_start();
                 context()->dispatch($route);
                 $cached = ob_get_contents();
                 ob_end_clean();
                 $redis->set($key, $cached);
                 $ttl = Config::get('application.route.cache', 7200);
                 $redis->expire($key, $ttl);
             }
             echo $cached;
         }
     }
 }
开发者ID:noikiy,项目名称:inovi,代码行数:27,代码来源:Bootstrap.php

示例3: register

 /**
  * Register options
  */
 public function register()
 {
     if ($this->registered) {
         return $this;
     }
     $hadStack = context()->exists(Stack::class);
     if (!$hadStack) {
         context()->bind(Stack::class, new Stack());
     }
     $this->registerAutoloaders($this->autoload());
     $this->registerClassMaps($this->classMaps());
     $this->registerApps($this->apps());
     $this->registerProviders($this->providers());
     $this->registerRoutes($this->routes());
     $this->registerListeners($this->listeners());
     $this->registerMiddlewares($this->middlewares());
     $this->registerAfterwares($this->afterwares());
     $this->registerPaths($this->paths());
     $this->registerViewObjects($this->viewObjects());
     $this->registerConsoles($this->consoles());
     $this->registerAssets($this->assets());
     if (method_exists($this, 'registered')) {
         Reflect::method($this, 'registered');
     }
     $this->registered = true;
     /**
      * Some actions needs to be executed in reverse direction, for example config initialization.
      */
     if (!$hadStack) {
         $stack = context()->get(Stack::class);
         $stack->execute();
     }
     return $this;
 }
开发者ID:pckg,项目名称:framework,代码行数:37,代码来源:Provider.php

示例4: createEntity

 /**
  * @return Entity
  */
 public function createEntity()
 {
     $repository = $this->repository ? context()->get(Repository::class . '.' . $this->repository) : null;
     $entityClass = $this->framework_entity ? $this->framework_entity : Entity::class;
     $entity = new $entityClass($repository);
     $entity->setTable($this->table);
     return $entity;
 }
开发者ID:pckg,项目名称:generic,代码行数:11,代码来源:Table.php

示例5: douban_login

function douban_login()
{
    define('BASEURL', 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/');
    $options = array('oauth_as_header' => false);
    $tokenResultParams = OAuthRequester::requestRequestToken(DOUBAN_KEY, 0, array(), 'POST', $options);
    $_SESSION['oauth_token'] = $tokenResultParams['token'];
    context('redirect', DOUBAN_AUTHORIZE_URL . '?oauth_token=' . $tokenResultParams['token'] . '&oauth_callback=' . BASEURL . 'index.php?q=douban_oauth_callback');
}
开发者ID:reusee,项目名称:defphp,代码行数:8,代码来源:douban_oauth.php

示例6: executeCron

 public function executeCron($cron, $unqueue = true)
 {
     $date = $cron->getDate();
     if ($date <= time()) {
         $_REQUEST = unserialize($cron->getData());
         context()->dispatch($cron);
         return true === $unqueue ? $this->unqueueCron($cron) : $this;
     }
 }
开发者ID:schpill,项目名称:thin,代码行数:9,代码来源:Cron.php

示例7: elggadmin_page_before

function elggadmin_page_before($c = null, $args = null)
{
    require_login('admin');
    if (!defined('context')) {
        context('elggadmin');
    }
    $page = isset($args[1]) ? $args[1] : 'config';
    elggadmin_currentpage($page);
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:9,代码来源:elggadmin.inc.php

示例8: getCache

 /**
  * @return Cache
  */
 public function getCache()
 {
     $key = 'pckg.database.repository.cache.' . sha1(Cache::getCachePathByRepository($this));
     $context = context();
     if (!$context->exists($key)) {
         $context->bind($key, $cache = new Cache($this));
     }
     return $context->get($key);
 }
开发者ID:pckg,项目名称:database,代码行数:12,代码来源:PDO.php

示例9: del

 public function del($key)
 {
     if (is_string($key)) {
         $val = isAke($this->data, $key, '__null__');
         if ('__null__' != $val) {
             unset($this->data[$key]);
         }
     }
     return context('collection');
 }
开发者ID:schpill,项目名称:thin,代码行数:10,代码来源:Mapper.php

示例10: update

 public function update($id = false)
 {
     $pk = $this->model->pk();
     $id = false === $id ? isAke($_POST, $pk, false) : $id;
     if (false !== $id && true === context()->isPost()) {
         $this->model->post()->save();
         return true;
     }
     return false;
 }
开发者ID:noikiy,项目名称:inovi,代码行数:10,代码来源:Crud.php

示例11: __construct

 public function __construct($name = '')
 {
     $this->tool =& get_clips_tool();
     context('app', $this);
     context('app_name', $name);
     context('smarty', $this->tool->create('Smarty'));
     set_error_handler("Clips\\web_error_handler");
     $this->name = $name;
     $this->router = $this->tool->load_class('Router', true);
     $this->router->route();
 }
开发者ID:guitarpoet,项目名称:clips-tool,代码行数:11,代码来源:WebApp.php

示例12: executeInRepository

 protected function executeInRepository()
 {
     $repositoryName = $this->migration->getRepository();
     foreach ($this->sqls as $sql) {
         $repository = context()->get($repositoryName);
         $prepare = $repository->getConnection()->prepare($sql);
         $execute = $prepare->execute();
         if (!$execute) {
             throw new Exception('Cannot execute query! ' . "\n" . $sql . "\n" . 'Error code ' . $prepare->errorCode() . "\n" . $prepare->errorInfo()[2]);
         }
     }
 }
开发者ID:pckg,项目名称:migrator,代码行数:12,代码来源:ExecuteMigration.php

示例13: init

 public static function init()
 {
     try {
         $loader = new \Phalcon\Loader();
         $loader->registerDirs([__DIR__ . DS . 'controllers' . DS, __DIR__ . DS . 'views' . DS, __DIR__ . DS . 'models' . DS, __DIR__ . DS . 'lib' . DS])->registerNamespaces(['Phalway' => __DIR__])->register();
         context()->set('phalwayLoader', $loader);
         $di = new \Phalcon\DI\FactoryDefault();
         return new \Phalcon\Mvc\Application($di);
     } catch (\Phalcon\Exception $e) {
         dd($e);
     }
 }
开发者ID:schpill,项目名称:standalone,代码行数:12,代码来源:Mvc.php

示例14: execute

 public function execute(callable $next)
 {
     try {
         /**
          * First argument is always 'console'.
          * Second argument is app name or command.
          * If it's command, we leave things as they are.
          * Id it's app, we unset it.
          */
         $argv = $_SERVER['argv'];
         /**
          * Remove application name.
          */
         if (isset($argv[1]) && !strpos($argv[1], ':')) {
             unset($argv[1]);
         }
         /**
          * Remove platform name.
          */
         if (isset($argv[2]) && !strpos($argv[2], ':') && false === strpos($argv[2], '-')) {
             unset($argv[2]);
         }
         /**
          * Get Symfony Console Application, find available commands and run app.
          */
         $application = context()->get(SymfonyConsole::class);
         try {
             /**
              * Apply global middlewares.
              */
             if ($middlewares = $this->response->getMiddlewares()) {
                 chain($middlewares, 'execute');
             }
             $application->run(new ArgvInput(array_values($argv)));
             /**
              * Apply global afterwares/decorators.
              */
             if ($afterwares = $this->response->getAfterwares()) {
                 chain($afterwares, 'execute', [$this->response]);
             }
         } catch (Throwable $e) {
             die("EXCEPTION: " . exception($e));
         }
         /**
          * This is here just for better readability. =)
          */
         echo "\n";
     } catch (Throwable $e) {
     }
     return $next();
 }
开发者ID:pckg,项目名称:framework,代码行数:51,代码来源:RunCommand.php

示例15: build

 public function build($slug, $repository = null)
 {
     if ($repository) {
         $this->menus->setRepository(context()->get(Repository::class . ($repository ? '.' . $repository : '')));
     }
     $menu = $this->menus->withMenuItems(function (HasMany $relation) {
         $relation->joinTranslation();
         // $relation->joinPermissionTo('read');
     })->where('slug', $slug)->one();
     if (!$menu) {
         return '<!-- no menu ' . $slug . ' -->';
     }
     return view('Pckg\\Generic:menu\\' . $menu->template, ['menu' => $menu, 'menuItems' => $this->buildTree($menu->menuItems)]);
 }
开发者ID:pckg,项目名称:generic,代码行数:14,代码来源:Menu.php


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