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


PHP Translator::parse方法代码示例

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


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

示例1: update

 /**
  * this is the main feature of the view, in the MVC paradigm the controller sends updates to the view, this is 
  * the method which captures the updates.  
  * 
  * The uri is essentially the part of the system which we are updating so different output will be negotiated 
  * depending on the value of the uri.  
  * 
  * The data are the things which have changed due to the controller. 
  * 
  * The message is optional, it is for notes, debug information or with json sending messages back alongside the data
  *
  * @param string $uri 
  * @param array $data 
  * @return void
  * @author Craig Ulliott
  */
 public static function update($uri, $data = NULL)
 {
     // extract the base from the url, we use this to determine the type of output
     $uri_r = explode('/', trim($uri, '/'), 2);
     $base = array_val($uri_r, 0);
     $path = array_val($uri_r, 1);
     // for an error we try and determine the best format to send back the message
     if ($base == 'error') {
         // if the original request came from AJAX
         if (array_val($_SERVER, 'HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest') {
             // rewrite and use the json handler for this error
             $base = 'json';
             $path = 'fail';
             $data = array_val($data, 'message', 'Unknown Error');
         } else {
             // pass back the appropriate http code for this error
             $code = array_val($data, 'code');
             switch ($code) {
                 case '404':
                     header("HTTP/1.0 404 Not Found");
                     break;
                 case '500':
                     header("HTTP/1.0 500 Internal Server Error");
                     break;
                 default:
                     die('unknown error code "' . $code . '"');
             }
             // use the page handler to display this error
             $base = 'page';
             $path = 'error/' . $code;
         }
     }
     // for an error, we try to determine if we are
     // we handle the update differently depending on the base of the uri
     switch ($base) {
         // these are the different layout files, we are loading a whole page template and passing the result into these layouts
         case 'page':
             // we are preparing a full html page
             $tpl_vars = array();
             // the part of the page being updated from teh controller (aka the page contents)
             $tpl_vars['page_content'] = Template::loadTemplate($path, $data);
             // script and css clien side includes
             $tpl_vars['css_url'] = ENV == 'dev' ? '/css/generate' : STATIC_BASE_URL . 'css/style.css';
             $tpl_vars['js_url'] = ENV == 'dev' ? '/js/generate' : STATIC_BASE_URL . 'js/script.js';
             // todo::
             $tpl_vars['css_url'] = '/css/generate';
             $tpl_vars['js_url'] = '/js/generate';
             // the facebook API key
             $tpl_vars['fb_api_key'] = getConfiguration('facebook', 'api_key');
             // user values
             $tpl_vars['current_uid'] = CURRENT_UID;
             $tpl_vars['current_session_key'] = CURRENT_SESSION_KEY;
             // the parts of the path
             $path_r = explode('/', $path);
             // the active section is the first part of the path
             $active_section = reset($path_r);
             // used to set an active class on the main tab
             $tpl_vars['active'] = $active_section;
             // we build body classes to target css more accurately, one whole class for each parent section
             $body_classes = array();
             while ($path_r) {
                 $body_classes[] = implode('-', $path_r);
                 array_pop($path_r);
             }
             // the current login state
             if (CURRENT_UID) {
                 $body_classes[] = 'logged-in';
             }
             // the current browser (TODO:)
             if (true == false) {
                 $body_classes[] = 'ie-7';
             }
             // the body classes, used to determine the browser and login state
             $tpl_vars['body_class'] = implode(' ', $body_classes);
             // render the full page in either the base or admin layout file
             $output = Template::loadLayout($base, $tpl_vars);
             // complete the translations
             Translator::translate('en');
             $output = Translator::parse($output);
             // useful headers for debugging
             self::outputDebugHeaders();
             // output to the browser
             die($output);
             // partial means we are rendering a template (usualy html) but not passing it back into the page template
//.........这里部分代码省略.........
开发者ID:Tapac,项目名称:hotscot,代码行数:101,代码来源:view.php


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