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


PHP Hook::call方法代码示例

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


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

示例1: _designerFixCallback


//.........这里部分代码省略.........
     // do the replacement
     switch ($tag) {
         case "[current]":
             $return = Reg::get("Path.current");
             break;
         case "[site]":
             $return = Reg::get("Path.site");
             break;
         case "[skin]":
             $return = Reg::get("Path.skin");
             break;
         case "[root]":
             $return = Reg::get("Path.root");
             break;
         case "[branch.site]":
             $return = Reg::get("Path.branch");
             break;
         case "[branch.skin]":
             $return = Reg::get("Path.branchSkin");
             break;
         case "[branch.root]":
             $return = Reg::get("Path.branchRoot");
             break;
         default:
             // see if it is a php variable. Quick way to echo variables from $this
             if (strpos($tag, '$') === 1) {
                 $custom = true;
                 $var = str_replace(array('[', ']', '$', 'this->'), '', $tag);
                 // if it is in an object then we need to go down the objects pulling out the variables
                 // not pretty
                 if (strpos($var, '->') !== false) {
                     $parts = explode('->', $var);
                     $failed = false;
                     $var = $this->{array_shift($parts)};
                     foreach ($parts as $part) {
                         if (!isset($var->{$part})) {
                             // variable isn't set so it failed
                             $failed = true;
                             break;
                         }
                         $var = $var->{$part};
                     }
                     if ($failed === false) {
                         $return = $var;
                     }
                 } else {
                     // it is a variable that isn't an object
                     if (isset($this->{$var})) {
                         $return = $this->{$var};
                     }
                 }
                 // the variable didn't exist so send nothing back to the page
                 // don't want variable names to sneak in
                 if ($return == $tag) {
                     $return = '';
                 }
             } else {
                 if (Reg::has(str_replace(array('[', ']'), '', $tag))) {
                     $custom = true;
                     // get the variable from the registry
                     $return = Reg::get(str_replace(array('[', ']'), '', $tag));
                 } else {
                     // look for the tag within the working URI
                     $working_uri = Reg::get("URI.working");
                     if (Reg::hasVal("Branch.name")) {
                         $working_uri = array_merge(array("branch" => Reg::get("Branch.name")), $working_uri);
                     }
                     foreach ($working_uri as $key => $item) {
                         $tmp_key = "[" . $key . "]";
                         if ($tag == $tmp_key && Reg::has('Path.' . $key)) {
                             $return = Reg::get('Path.' . $key);
                             break 1;
                         }
                     }
                 }
             }
             break;
     }
     // if it is a link then we need to do some more processing
     if ($link === true && $custom === false) {
         // remove any ../ from the url so that they are clean
         $link_arr = explode("/", $match[2]);
         $up_link_count = count(array_keys(array_slice($link_arr, 1), ".."));
         $return = explode('/', $return);
         $return = implode("/", $up_link_count ? array_slice($return, 0, -1 * $up_link_count) : $return) . implode("/", array_pad(array_slice($link_arr, $up_link_count + 1), -(count(array_slice($link_arr, $up_link_count + 1)) + 1), ""));
         // if mod_rewrite isn't being used then need to make sure the URL is valid by turning any extra ? into &
         if (Reg::get("URI.useModRewrite") != true && !empty($return)) {
             if (substr_count($return, "?", 0) > 1) {
                 $return = strrev(preg_replace("/\\?/i", "&", strrev($return), substr_count($return, "?", 0) - 1));
             }
         }
     } else {
         if (!empty($match[2])) {
             $return .= $match[2];
         }
     }
     // call hook
     Hook::call('Controller.designerFixCallback', array(&$match, &$return));
     return $return;
 }
开发者ID:kidaa30,项目名称:Evergreen-1,代码行数:101,代码来源:controller.class.php

示例2: loadURL

 /**
  * Loads the url for the error. If the url points to a page inside the framework the function attempts to load it and handles any errors
  * or issues associated such as loading in a default error. If the url points to a page outside the framework then header location is set
  * and execution is stopped.
  * 
  * @access public
  * @static
  * @final
  * @param string|array $url The url that should be loaded can be the url or an array in the URI.map format
  */
 public function loadURL($url)
 {
     // call hook
     Hook::call('Exception.loadURL.before', array(&$url));
     if (!empty($url)) {
         if (!is_array($url) && preg_match("/^(http:|https:|ftp:|ftps:)/im", $url)) {
             // call hook
             Hook::call('Exception.loadURL.redirect', array(&$url));
             header('Location: ' . $url);
             header('Connection: close');
             exit;
         }
         if (is_array($url)) {
             $url = '/' . implode('/', array_merge(Reg::get("URI.map"), $url));
         }
         $url = str_replace(Reg::get('Path.root'), "", $url);
         $_SERVER['REQUEST_URI'] = $url;
         Reg::set("URI.working", $url);
         Reg::del("Branch.name");
         Config::processURI();
         $load['name'] = Config::uriToClass(Reg::get("URI.working.controller"));
         if (Reg::hasVal("Branch.name")) {
             $load['branch'] = Config::uriToClass(Reg::get("Branch.name"));
         }
         $load['type'] = 'Controller';
         $load = implode('_', $load);
         $controller = new $load();
         if (!is_object($controller)) {
             if (!file_exists(Reg::get("System.defaultError404"))) {
                 include Reg::get("System.defaultError404");
             } else {
                 echo Reg::get("System.defaultError404");
             }
         } else {
             try {
                 // call hook
                 Hook::call('Exception.loadURL.controller', array(&$controller));
                 $controller->_showView();
             } catch (EvergreenException $e) {
                 var_dump($e);
                 exit;
                 if (Reg::get("System.mode") == "development") {
                     if (isset(self::$params['code'])) {
                         $code = self::$params['code'];
                     }
                     // call hook
                     Hook::call('Exception.loadURL.default', array(&$url, &$code));
                     switch ($code) {
                         case 'GEN':
                             if (file_exists(Reg::get("System.defaultErrorGEN"))) {
                                 include Reg::get("System.defaultErrorGEN");
                             } else {
                                 echo Reg::get("System.defaultErrorGEN");
                             }
                             break;
                         case 'DB':
                             if (file_exists(Reg::get("System.defaultErrorDB"))) {
                                 include Reg::get("System.defaultErrorDB");
                             } else {
                                 echo Reg::get("System.defaultErrorDB");
                             }
                             break;
                         default:
                             if (file_exists(Reg::get("System.defaultErrorGEN"))) {
                                 include Reg::get("System.defaultErrorGEN");
                             } else {
                                 echo Reg::get("System.defaultErrorGEN");
                             }
                             break;
                     }
                 }
             }
         }
     } else {
         if (file_exists(Reg::get("System.defaultErrorGEN"))) {
             include Reg::get("System.defaultErrorGEN");
         } else {
             echo Reg::get("System.defaultErrorGEN");
         }
     }
 }
开发者ID:kidaa30,项目名称:Evergreen-1,代码行数:91,代码来源:evergreen.exception.class.php

示例3: triggered

 /**
  * Returns if an error has been triggered or not.
  * 
  * @access public
  * @static
  * @final
  * @return boolean true if an error has been triggered and boolean false if not
  */
 public static final function triggered()
 {
     $triggered = self::$triggered;
     // call hook
     Hook::call('Error.triggered', array(&$triggered));
     return $triggered;
 }
开发者ID:kidaa30,项目名称:Evergreen-1,代码行数:15,代码来源:error.class.php

示例4: showPageLoadInfo

 /**
  * Returns the page load info.
  * 
  * @access public
  * @param integer $starttime The float microtime that the script started
  */
 public function showPageLoadInfo($starttime)
 {
     // call hook
     Hook::call('showPageLoadInfo.before', array(&$starttime));
     $totaltime = microtime(true) - $starttime;
     echo sprintf('Time : %.3fs seconds', $totaltime);
     if (class_exists('DB', false)) {
         echo ' | Queries Executed : ' . DB::getQueryCount();
     }
     if (function_exists('memory_get_usage')) {
         // php has to be compiled with --enable-memory-limit for this to exist
         // prior to version 5.2.1
         echo ' | Memory Used : ' . $this->convertBytes(memory_get_usage(true));
     }
     if (function_exists('memory_get_peak_usage')) {
         // php 5.2+
         echo ' | Peak Memory Used: ' . $this->convertBytes(memory_get_peak_usage(true));
     }
     // call hook
     Hook::call('showPageLoadInfo.after');
 }
开发者ID:kidaa30,项目名称:Evergreen-1,代码行数:27,代码来源:evergreen.class.php

示例5: del

 /**
  * Deletes a variable by the key and returns true if deleted otherwise returns false.
  * 
  * @access public
  * @static
  * @param string $key The registration variable that is being accessed
  * @return boolean true if the variable was deleted and boolean false if it wasn't or doesn't exist
  */
 public static function del($key)
 {
     // call hook
     if (method_exists('Hook', 'call')) {
         Hook::call('Reg.del.' . $key, array(&$key));
     }
     $path = explode('.', $key);
     $variablesHolder =& self::$variables;
     // loop through the exploded variable key to get to the correct level in the variable array
     foreach ($path as $i => $path_key) {
         if ($i == count($path) - 1) {
             if (isset($variablesHolder[$path_key])) {
                 // unset the variable key
                 unset($variablesHolder[$path_key]);
                 return true;
             } else {
                 return false;
             }
         } else {
             // set the current level of the array to the holder and continue to loop
             $variablesHolder =& $variablesHolder[$path_key];
         }
     }
     return false;
 }
开发者ID:kidaa30,项目名称:Evergreen-1,代码行数:33,代码来源:config.class.php


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