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


PHP Hooks::notify方法代码示例

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


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

示例1: getOutput

 /**
  * This is the actual Tag Replacement method
  * First it assigns the default tags that need to be used and then prepars the Tags that
  * will be used in the PHP 'Jail' class. All of the Tags for PHP use are convertd to lowercase
  *
  * After all PHP is run it gets the output from the class and goes about replacing the normal
  * {TAGS} in the view file. All language tags are also found and assigned, they appear at the start
  * of the assigned tags array
  *
  * @param bool $parseConfigTags		If this is set to true, values such as {%TCM_SITE_TITLE%} will get replaced
  * @return string
  */
 public function getOutput($parseConfigTags = false)
 {
     $this->noparse = array();
     # Restore noparse array
     // Get and assign the default tags
     $defaultTags = $this->getDefaultTags();
     $this->assignHtml(array('plain' => $defaultTags['plain']));
     unset($defaultTags['plain']);
     $this->assign($defaultTags);
     if ($this->loadedContent === null) {
         if ($this->parsePhp === true) {
             // Prepare the tags for the PHP class
             $phpTags = array();
             foreach ($this->assignedTags as $tag => $val) {
                 $tag = str_replace('-', '_', $tag);
                 if ($this->caseSensitive === false) {
                     $tag = zula_strtolower($tag);
                 }
                 $phpTags[$tag] = $val;
             }
             $tmpView = new View_OB($phpTags, $this->viewPath, $this->module);
             $tmpViewContent = $tmpView->getOutput();
             # Return content of the parsed PHP view file
         } else {
             $tmpViewContent = file_get_contents($this->viewPath);
         }
     } else {
         $tmpViewContent = $this->loadedContent;
     }
     // Gather all language tags and merge them into the final tag array
     $languageTags = $this->languageTags($tmpViewContent);
     $this->assignedTags = array_merge($languageTags, $this->assignedTags);
     // Remove all <noparse> text
     $tmpViewContent = preg_replace_callback('#<noparse>(.*?)</noparse>#s', array($this, 'extractNoparse'), $tmpViewContent);
     preg_match_all('@{(?!(?:%|\\s|}))(.*?)(?<!%)}@', $tmpViewContent, $templateTags);
     if (!empty($templateTags[0])) {
         foreach ($templateTags[0] as $key => $tag) {
             if (zula_substr($tag, 0, 4) == '{L_[') {
                 // Replace the langauge tags without splitting the tag into .. tokens?
                 try {
                     $tmpViewContent = $this->replaceTag($templateTags[1][$key], $tmpViewContent, true);
                 } catch (View_TagNotAssigned $e) {
                     $this->_log->message($e->getMessage(), Log::L_NOTICE);
                 } catch (View_InvalidTagValue $e) {
                     trigger_error('View::getOutput() view tag has invalid assigned value:' . $e->getMessage(), E_USER_WARNING);
                 }
             } else {
                 $tagTokens = explode('.', $templateTags[1][$key]);
                 if (count($tagTokens) <= 1) {
                     $tmpTag = $templateTags[1][$key];
                 } else {
                     // Tag is in the format of {FOO.BAR.CAR}
                     $tmpTag = $tagTokens;
                 }
                 try {
                     $tmpViewContent = $this->replaceTag($tmpTag, $tmpViewContent);
                 } catch (View_TagNotAssigned $e) {
                     $this->_log->message($e->getMessage(), Log::L_NOTICE);
                 } catch (View_InvalidTagValue $e) {
                     trigger_error('View::getOutput() view tag has invalid assigned value:' . $e->getMessage(), E_USER_WARNING);
                 }
             }
         }
     }
     foreach ($defaultTags as $tag => $val) {
         $tmpViewContent = str_replace('{' . $tag . '}', $val, $tmpViewContent);
         if ($parseConfigTags === true) {
             $tmpViewContent = str_replace('{%' . $tag . '%}', $val, $tmpViewContent);
         }
     }
     // Restore noparse text
     $text = preg_replace_callback('#<noparse></noparse>#', array($this, 'insertNoparse'), $tmpViewContent);
     # hook event: cntrlr_error_output
     while ($tmpText = Hooks::notify('view_output', $text, $this->viewPath, $this->module)) {
         if (is_string($tmpText)) {
             $text = $tmpText;
         }
     }
     return $text;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:92,代码来源:View.php

示例2: parse

 /**
  * Parses text using correct parser, if $break is set
  * to a value which equates to true, the text will be
  * split at the '<!--break-->' point, instead of
  * parsing the entire document
  *
  * @param bool $break
  * @param bool $disablePhp
  * @return string
  */
 public function parse($break = false, $disablePhp = false)
 {
     if ($disablePhp == false && $this->_config->get('editor/parse_php')) {
         // Eww =\ 10 kittens just died because of this.
         ob_start();
         echo eval('?>' . $this->parser->text);
         $this->parser->text = ob_get_clean();
     }
     $parsed = $this->parser->parse($break);
     while ($tmpText = Hooks::notify('editor_parse', $parsed)) {
         if (is_string($tmpText)) {
             $parsed = $tmpText;
         }
     }
     // Fix for bug #275, replace #foobar with {URL}#foobar (needed due to <base>)
     $parsed = preg_replace('/\\shref="#([^"]*?)"/i', ' href="' . $this->_router->getRequestPath() . '#$1"', $parsed);
     if ($this->_router->getType() == 'standard') {
         // Fix for Bug #167, rewrite URLs to include 'index.php?url='
         $parsed = preg_replace_callback('#\\shref="(?!(/|[A-Z][A-Z0-9+.\\-]+://))(.*?)"#i', array($this, 'cbFixSefUrl'), $parsed);
     }
     if ($break && $this->contentUrl != null) {
         $parsed .= sprintf('<p class="readmore"><a href="%s">%s</a></p>', $this->contentUrl, t('Read more', I18n::_DTD));
     }
     return $parsed;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:35,代码来源:Editor.php

示例3: loadAmc

    /**
     * Loads the additional module content, such as table forms
     *
     * @return int
     */
    protected function loadAmc()
    {
        $amcTable = '<table>
							<thead>
								<tr>
									<th colspan="2">' . t('Additional content', I18n::_DTD) . '</th>
								</tr>
							</thead>
							<tbody>';
        $htmlLib = new Html('amcForm[%s]');
        $rowFormat = '<tr class="%1$s">
							<td>
								<dl>
									<dt>%2$s</dt>
									<dd>%3$s</dd>
								</dl>
							</td>
							<td class="confcol">%4$s</td>
						  </tr>';
        $i = 0;
        while ($amcElements = Hooks::notify('amc_form_table', Module::getLoading(), $this->formType, $this->contentUrl)) {
            if (isset($amcElements['onSuccess'])) {
                $this->successCallbacks[] = $amcElements['onSuccess'];
            }
            foreach ((array) $amcElements['inputs'] as $input) {
                if (!isset($input['required'])) {
                    $input['required'] = true;
                }
                $inputKey = 'amcForm/' . $input['args'][0];
                if ($this->_input->has('post', $inputKey)) {
                    // Attempt to get the value form the previous form if it failed
                    $input['args'][1] = $this->_input->post($inputKey);
                }
                $amcTable .= sprintf($rowFormat, zula_odd_even($i++), $input['name'], $input['desc'], call_user_func_array(array($htmlLib, $input['type']), $input['args']));
                $this->addElement($inputKey, '', $input['name'], $input['validators'], $input['required']);
            }
        }
        if ($i === 0) {
            $this->assign(array('AMC' => array('TABLE' => '')));
            return 0;
        } else {
            $amcTable .= '</tbody></table>';
            $this->assignHtml(array('AMC' => array('TABLE' => $amcTable)));
            return $i;
        }
    }
开发者ID:jinshana,项目名称:tangocms,代码行数:51,代码来源:Form.php

示例4: dispatch

 /**
  * Takes data from a Router_Url instance and attempts to load the correct cntrlr
  * based upon that.
  *
  * @param Router_Url $request
  * @param array $config
  * @return string|bool
  */
 public function dispatch(Router_Url $request, array $config = array())
 {
     $this->dispatchData = $request->asArray();
     $this->dispatchData['config'] = $config;
     unset($config);
     while ($preDispatch = Hooks::notify('cntrlr_pre_dispatch', $this->dispatchData)) {
         if (is_string($preDispatch)) {
             return $preDispatch;
         } else {
             if (is_array($preDispatch)) {
                 $this->dispatchData = $preDispatch;
             }
         }
     }
     try {
         $module = new Module($this->dispatchData['module']);
         $loadedCntrlr = $module->loadController($this->dispatchData['controller'], $this->dispatchData['section'], $this->dispatchData['config'], 'SC');
         $this->requestedCntrlr = $loadedCntrlr['cntrlr'];
         return $loadedCntrlr['output'];
     } catch (Module_NoPermission $e) {
         $this->statusCode = 403;
     } catch (Module_ControllerNoExist $e) {
         $this->statusCode = 404;
     } catch (Module_NoExist $e) {
         $this->statusCode = 404;
     }
     if ($this->setStatusHeader) {
         switch ($this->statusCode) {
             case 200:
                 header('HTTP/1.1 200 OK');
                 break;
             case 403:
                 header('HTTP/1.1 403 Forbidden');
                 break;
             case 404:
                 header('HTTP/1.1 404 Not Found');
         }
     }
     if ($this->displayErrors) {
         // Display own custom error message in place of the modules output
         $view = new View('errors/' . $this->statusCode . '.html');
         $view->assign($this->dispatchData);
         $output = $view->getOutput();
         # hook event: cntrrl_error_output
         while ($tmpOutput = Hooks::notify('cntrlr_error_output', $this->statusCode, $output)) {
             if (is_string($tmpOutput)) {
                 $output = $tmpOutput;
             }
         }
         return $output;
     } else {
         return false;
     }
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:62,代码来源:Dispatcher.php

示例5: getParsedUrl

 /**
  * Returns a Router_Url instance of the current parsed URL
  * which includes the request path and query arguments.
  *
  * @return object
  */
 public function getParsedUrl()
 {
     if (!$this->requestUrl instanceof Router_Url) {
         // Parse the current raw request path and store it. Call the router_pre_parse hook first, though
         $this->requestPath = $this->rawRequestPath;
         while (($tmpUrl = Hooks::notify('router_pre_parse', trim($this->requestPath, '/'))) !== null) {
             $this->requestPath = $tmpUrl;
         }
         $queryArgs = $this->_input->getAll('get');
         unset($queryArgs['url']);
         $this->requestUrl = new Router_Url($this->requestPath . '?' . http_build_query($queryArgs));
     }
     return $this->requestUrl;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:20,代码来源:Router.php


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