mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-17 07:10:48 +03:00
Возможность создавать хуки внутри шаблонов
This commit is contained in:
parent
932d0ef733
commit
be2fe70c70
|
@ -80,6 +80,7 @@ class LsHook extends Module {
|
|||
public function Run($sName,&$aVars=array()) {
|
||||
$result=array();
|
||||
$sName=strtolower($sName);
|
||||
$bTemplateHook=strpos($sName,'template_')===0 ? true : false;
|
||||
if (isset($this->aHooks[$sName])) {
|
||||
$aHookNum=array();
|
||||
$aHookNumDelegate=array();
|
||||
|
@ -100,7 +101,14 @@ class LsHook extends Module {
|
|||
*/
|
||||
foreach ($aHookNum as $iKey => $iPr) {
|
||||
$aHook=$this->aHooks[$sName][$iKey];
|
||||
$this->RunType($aHook,$aVars);
|
||||
if ($bTemplateHook) {
|
||||
/**
|
||||
* Если это шаблонных хук то сохраняем результат
|
||||
*/
|
||||
$result['template_result'][]=$this->RunType($aHook,$aVars);
|
||||
} else {
|
||||
$this->RunType($aHook,$aVars);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Теперь запускаем делигирующие
|
||||
|
|
39
engine/modules/viewer/plugs/function.hook.php
Normal file
39
engine/modules/viewer/plugs/function.hook.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/*-------------------------------------------------------
|
||||
*
|
||||
* LiveStreet Engine Social Networking
|
||||
* Copyright © 2008 Mzhelskiy Maxim
|
||||
*
|
||||
*--------------------------------------------------------
|
||||
*
|
||||
* Official site: www.livestreet.ru
|
||||
* Contact e-mail: rus.engine@gmail.com
|
||||
*
|
||||
* GNU General Public License, version 2:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
---------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Плагин для смарти
|
||||
* Запускает хуки из шаблона на выполнение
|
||||
*
|
||||
* @param array $aParams
|
||||
* @param Smarty $oSmarty
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_hook($aParams,&$oSmarty) {
|
||||
if(empty($aParams['run'])) {
|
||||
$oSmarty->trigger_error("Hook: missing 'run' parametr");
|
||||
return;
|
||||
}
|
||||
|
||||
$sHookName='template_'.strtolower($aParams['run']);
|
||||
$aResultHook=Engine::getInstance()->Hook_Run($sHookName);
|
||||
if (array_key_exists('template_result',$aResultHook)) {
|
||||
return join('',$aResultHook['template_result']);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
?>
|
|
@ -1,4 +1,4 @@
|
|||
</div>
|
||||
|
||||
{hook run='body_end'}
|
||||
</body>
|
||||
</html>
|
|
@ -17,6 +17,6 @@
|
|||
<!-- /Footer -->
|
||||
|
||||
</div>
|
||||
|
||||
{hook run='body_end'}
|
||||
</body>
|
||||
</html>
|
|
@ -15,7 +15,7 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
{hook run='body_begin'}
|
||||
<div id="container">
|
||||
<h1 class="lite-header"><a href="{cfg name='path.root.web'}">Live<span>Street</span></a></h1>
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ var msgNoticeBox=new Roar({
|
|||
|
||||
<body onload="prettyPrint()">
|
||||
|
||||
|
||||
{hook run='body_begin'}
|
||||
|
||||
<div id="debug" style="border: 2px #dd0000 solid; display: none;"></div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue