本文整理汇总了PHP中Engine::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Engine::getInstance方法的具体用法?PHP Engine::getInstance怎么用?PHP Engine::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initEngine
public function initEngine()
{
if (!$this->oEngine) {
$this->oEngine = Engine::getInstance();
$this->oEngine->Init();
}
}
示例2: _smarty_include
function _smarty_include($params)
{
if (isset($params['smarty_include_tpl_file'])) {
$params['smarty_include_tpl_file'] = Engine::getInstance()->Plugin_GetDelegate('template', $params['smarty_include_tpl_file']);
}
parent::_smarty_include($params);
}
示例3: smarty_function_widget_template
/**
* Plugin for Smarty
*
* @param array $aParams
* @param Smarty_Internal_Template $oSmartyTemplate
*
* @return string|null
*/
function smarty_function_widget_template($aParams, $oSmartyTemplate)
{
if (!isset($aParams['name'])) {
trigger_error('Parameter "name" does not define in {widget ...} function', E_USER_WARNING);
return null;
}
$sWidgetName = $aParams['name'];
$aWidgetParams = isset($aParams['params']) ? $aParams['params'] : array();
$oEngine = Engine::getInstance();
// Проверяем делигирование
$sTemplate = E::ModulePlugin()->GetDelegate('template', $sWidgetName);
if ($sTemplate) {
if ($aWidgetParams) {
foreach ($aWidgetParams as $sKey => $sVal) {
$oSmartyTemplate->assign($sKey, $sVal);
}
if (!isset($aWidgetParams['params'])) {
/* LS-compatible */
$oSmartyTemplate->assign('params', $aWidgetParams);
}
$oSmartyTemplate->assign('aWidgetParams', $aWidgetParams);
}
$sResult = $oSmartyTemplate->fetch($sTemplate);
} else {
$sResult = null;
}
return $sResult;
}
示例4: smarty_function_show_blocks
/**
* Показывает блоки определенно группы
*
* @param unknown_type $params
* @param unknown_type $smarty
* @return unknown
*/
function smarty_function_show_blocks($aParams, &$oSmarty)
{
if (!array_key_exists('group', $aParams)) {
trigger_error("show_blocks: missing 'group' parameter", E_USER_WARNING);
return;
}
$sGroup = $aParams['group'];
$aBlocks = Engine::getInstance()->Viewer_GetBlocks(true);
$sResult = '';
if (isset($aBlocks[$sGroup]) and is_array($aBlocks[$sGroup])) {
$oSmarty->loadPlugin('smarty_insert_block');
foreach ($aBlocks[$sGroup] as $aBlock) {
if ($aBlock['type'] == 'block') {
$sResult .= smarty_insert_block(array('block' => $aBlock['name'], 'params' => isset($aBlock['params']) ? $aBlock['params'] : array()), $oSmarty);
} elseif ($aBlock['type'] == 'template') {
$sResult .= $oSmarty->getSubTemplate($aBlock['name'], $oSmarty->cache_id, $oSmarty->compile_id, null, null, array('params' => isset($aBlock['params']) ? $aBlock['params'] : array()), Smarty::SCOPE_LOCAL);
}
}
}
if (!empty($aParams['assign'])) {
$oSmarty->assign($aParams['assign'], $sResult);
} else {
return $sResult;
}
}
示例5: ClearComments
public function ClearComments()
{
$sql = "SELECT co.comment_id FROM " . Config::Get('db.table.comment_online') . " AS co\n LEFT JOIN " . Config::Get('db.table.topic') . " AS t ON co.target_type='topic' AND co.target_id=t.topic_id\n WHERE t.topic_id IS NULL";
if ($aCommentId = $this->oDb->selectCol($sql)) {
Engine::getInstance()->Comment_DeleteCommentOnlineByArrayId($aCommentId, 'topic');
}
return true;
}
示例6: DeclareClass
protected function DeclareClass($sClassName)
{
$aClassElements = $this->ClassNameExplode($sClassName);
$sParentClass = '';
$sFileClass = '';
if (isset($aClassElements['Module'])) {
$sClassDelegate = Engine::getInstance()->Plugin_GetDelegate('module', $sClassName);
if ($sClassDelegate != $sClassName) {
$sParentClass = $sClassDelegate;
}
}
if (!$sParentClass) {
$sClassNameItem = $sClassName;
if (isset($aClassElements['Plugin'])) {
// класс внутри плагина
$sParentClass = 'Plugin' . ucfirst(strtolower($aClassElements['Plugin'])) . '_';
$n = strpos($sClassName, '_');
if ($n) {
$sClassNameItem = substr($sClassName, $n + 1);
}
// если такой плагин не активирван, то уходим
if (!in_array(strtolower($aClassElements['Plugin']), Engine::getInstance()->Plugin_GetActivePlugins())) {
return;
}
}
if (preg_match('/^Ls([\\w]+)/', $sClassNameItem, $aMatches)) {
$sParentClass .= 'Module' . $aMatches[1];
} elseif (preg_match('/^(\\w+)Entity_([\\w]+)/', $sClassNameItem, $aMatches)) {
$sParentClass .= 'Module' . $aMatches[1] . '_Entity' . $aMatches[2];
} elseif (preg_match('/^Mapper_([\\w]+)/', $sClassNameItem, $aMatches)) {
$sParentClass .= 'Module' . $aMatches[1] . '_Mapper' . $aMatches[1];
} elseif (isset($aClassElements['Inherits'])) {
if (isset($aClassElements['Module'])) {
$sParentClass .= 'Inherit_Module' . $aClassElements['Module'];
}
} elseif (isset($aClassElements['Action'])) {
$sParentClass .= 'Action' . $aClassElements['Action'];
} elseif (isset($aClassElements['Block'])) {
$sParentClass .= 'Block' . $aClassElements['Block'];
} elseif (isset($aClassElements['Hook'])) {
$sParentClass .= 'Hook' . $aClassElements['Hook'];
} elseif (isset($aClassElements['Module'])) {
$sParentClass .= $aClassElements['Module'];
} elseif (isset($aClassElements['Mapper'])) {
$sParentClass .= '_Mapper' . $aClassElements['Mapper'];
}
}
if (!$sFileClass) {
$sFileClass = $this->ClassToPath($sClassName);
}
if ($sFileClass && file_exists($sFileClass)) {
include_once $sFileClass;
}
if (!class_exists($sClassName, false) && $sParentClass && $sParentClass != $sClassName) {
$sEvalCode = 'class ' . $sClassName . ' extends ' . $sParentClass . ' {}';
eval($sEvalCode);
}
}
示例7: smarty_function_get_blocks
/**
* Загружает в переменную список блоков
*
* @param unknown_type $params
* @param unknown_type $smarty
* @return unknown
*/
function smarty_function_get_blocks($params, &$smarty)
{
if (!array_key_exists('assign', $params)) {
trigger_error("get_blocks: missing 'assign' parameter", E_USER_WARNING);
return;
}
$smarty->assign($params['assign'], Engine::getInstance()->Viewer_GetBlocks());
return '';
}
示例8: smarty_insert_block
/**
* Плагин для смарти
* Подключает обработчик блоков шаблона
*
* @param array $aParams
* @param Smarty $oSmarty
* @return string
*/
function smarty_insert_block($aParams, &$oSmarty)
{
if (!isset($aParams['block'])) {
trigger_error('Not found param "block"', E_USER_WARNING);
return;
}
/**
* Устанавливаем шаблон
*/
$sBlock = ucfirst(basename($aParams['block']));
/**
* Проверяем наличие шаблона. Определяем значения параметров работы в зависимости от того,
* принадлежит ли блок одному из плагинов, или является пользовательским классом движка
*/
if (isset($aParams['params']) and isset($aParams['params']['plugin'])) {
$sBlockTemplate = Plugin::GetTemplatePath($aParams['params']['plugin']) . '/blocks/block.' . $aParams['block'] . '.tpl';
$sBlock = 'Plugin' . ucfirst($aParams['params']['plugin']) . '_Block' . $sBlock;
} else {
$sBlockTemplate = 'blocks/block.' . $aParams['block'] . '.tpl';
$sBlock = 'Block' . $sBlock;
}
$sBlock = Engine::getInstance()->Plugin_GetDelegate('block', $sBlock);
/**
* параметры
*/
$aParamsBlock = array();
if (isset($aParams['params'])) {
$aParamsBlock = $aParams['params'];
}
/**
* Подключаем необходимый обработчик
*/
$oBlock = new $sBlock($aParamsBlock);
$oBlock->SetTemplate($sBlockTemplate);
/**
* Запускаем обработчик
*/
$mResult = $oBlock->Exec();
if (is_string($mResult)) {
/**
* Если метод возвращает строку - выводим ее вместо рендеринга шаблона
*/
return $mResult;
} else {
/**
* Получаем шаблон, возможно его переопределили в обработчике блока
*/
$sBlockTemplate = Engine::getInstance()->Plugin_GetDelegate('template', $oBlock->GetTemplate());
if (!Engine::getInstance()->Viewer_TemplateExists($sBlockTemplate)) {
return "<b>Not found template for block: <i>{$sBlockTemplate} ({$sBlock})</i></b>";
}
}
/**
* Возвращаем результат в виде обработанного шаблона блока
*/
return Engine::getInstance()->Viewer_Fetch($sBlockTemplate);
}
示例9: smarty_function_asset
/**
* Плагин для смарти
* Подключает css/js на странице с учетом дублирования (но только в рамках плагина asset)
*
* @param array $aParams
* @param Smarty $oSmarty
* @return string
*/
function smarty_function_asset($aParams, &$oSmarty)
{
if (empty($aParams['file'])) {
trigger_error("Asset: missing 'file' parametr", E_USER_WARNING);
return;
}
if (empty($aParams['type'])) {
trigger_error("Asset: missing 'type' parametr", E_USER_WARNING);
return;
}
$sTypeAsset = $aParams['type'];
$oEngine = Engine::getInstance();
/**
* Проверяем тип
*/
if (!$oEngine->Asset_CheckAssetType($sTypeAsset)) {
trigger_error("Asset: wrong 'type' parametr", E_USER_WARNING);
return;
}
/**
* Получаем список текущих подключенных файлов
*/
$sKeyIncluded = 'smarty_asset_included';
$aIncluded = $oEngine->Cache_GetLife($sKeyIncluded);
/**
* Проверяем на компонент
*/
if (preg_match('#^Component@(.+)#i', $aParams['file'], $aMatch)) {
$aPath = explode('.', $aMatch[1], 2);
$aParams['name'] = 'component.' . $aPath[0] . '.' . $aPath[1];
if ($aParams['file'] = Engine::getInstance()->Component_GetAssetPath($aPath[0], $sTypeAsset, $aPath[1])) {
$aParams['file'] = Engine::getInstance()->Fs_GetPathWebFromServer($aParams['file']);
} else {
return;
}
}
/**
* Подготавливаем параметры
*/
$aParams = $oEngine->Asset_PrepareParams($aParams);
$sFileKey = $aParams['name'] ? $aParams['name'] : $aParams['file'];
/**
* Проверяем на дубли
*/
if (isset($aIncluded[$sTypeAsset][$sFileKey])) {
return;
}
$aIncluded[$sTypeAsset][$sFileKey] = $aParams;
$oEngine->Cache_SetLife($aIncluded, $sKeyIncluded);
/**
* Формируем HTML
*/
$oAsset = $oEngine->Asset_CreateObjectType($sTypeAsset);
$sHtml = $oAsset->getHeadHtml($aParams['file'], $aParams);
return $sHtml;
}
示例10: Exec
/**
* Запускает весь процесс :)
*
*/
public function Exec()
{
$this->ParseUrl();
$this->DefineActionClass();
// Для возможности ДО инициализации модулей определить какой action/event запрошен
$this->oEngine = Engine::getInstance();
$this->oEngine->Init();
$this->ExecAction();
$this->Shutdown(false);
}
示例11: doAction
public function doAction()
{
if (empty($this->segment)) {
$this->result['errors'][] = array("code" => -1, "message" => "missing source segment");
}
if (empty($this->translation)) {
$this->result['errors'][] = array("code" => -2, "message" => "missing target translation");
}
if (empty($this->source_lang)) {
$this->result['errors'][] = array("code" => -3, "message" => "missing source lang");
}
if (empty($this->target_lang)) {
$this->result['errors'][] = array("code" => -4, "message" => "missing target lang");
}
if (empty($this->time_to_edit)) {
$this->result['errors'][] = array("code" => -5, "message" => "missing time to edit");
}
if (empty($this->id_segment)) {
$this->result['errors'][] = array("code" => -6, "message" => "missing segment id");
}
//get Job Infos, we need only a row of jobs ( split )
$job_data = getJobData((int) $this->id_job, $this->password);
$pCheck = new AjaxPasswordCheck();
//check for Password correctness
if (empty($job_data) || !$pCheck->grantJobAccessByJobData($job_data, $this->password)) {
$this->result['errors'][] = array("code" => -10, "message" => "wrong password");
$msg = "\n\n Error \n\n " . var_export(array_merge($this->result, $_POST), true);
Log::doLog($msg);
Utils::sendErrMailReport($msg);
return;
}
//mt engine to contribute to
if ($job_data['id_mt_engine'] <= 1) {
return false;
}
$this->mt = Engine::getInstance($job_data['id_mt_engine']);
//array of storicised suggestions for current segment
$this->suggestion_json_array = json_decode(getArrayOfSuggestionsJSON($this->id_segment), true);
//extra parameters
$extra = json_encode(array('id_segment' => $this->id_segment, 'suggestion_json_array' => $this->suggestion_json_array, 'chosen_suggestion_index' => $this->chosen_suggestion_index, 'time_to_edit' => $this->time_to_edit));
//send stuff
$config = $this->mt->getConfigStruct();
$config['segment'] = CatUtils::view2rawxliff($this->segment);
$config['translation'] = CatUtils::view2rawxliff($this->translation);
$config['source'] = $this->source_lang;
$config['target'] = $this->target_lang;
$config['email'] = INIT::$MYMEMORY_API_KEY;
$config['segid'] = $this->id_segment;
$config['extra'] = $extra;
$config['id_user'] = array("TESTKEY");
$outcome = $this->mt->set($config);
if ($outcome->error->code < 0) {
$this->result['errors'] = $outcome->error->get_as_array();
}
}
示例12: Statistics
public function Statistics()
{
$oEngine = Engine::getInstance();
$iTimeInit = $oEngine->GetTimeInit();
$iTimeFull = round(microtime(true) - $iTimeInit, 3);
$this->Viewer_Assign('iTimeFullPerformance', $iTimeFull);
$aStats = $oEngine->getStats();
$aStats['cache']['time'] = round($aStats['cache']['time'], 5);
$this->Viewer_Assign('aStatsPerformance', $aStats);
$this->Viewer_Assign('bIsShowStatsPerformance', Router::GetIsShowStats());
return $this->Viewer_Fetch('statistics_performance.tpl');
}
示例13: getPaging
public function getPaging()
{
$iCountItems = $this->getCountPost();
$oForum = $this->getForum();
$iPerPage = $oForum && $oForum->getOptionsValue('posts_per_page') ? $oForum->getOptionsValue('posts_per_page') : Config::Get('plugin.forum.post_per_page');
if (Config::Get('plugin.forum.topic_line_mod')) {
$iCountItems--;
$iPerPage--;
}
$oEngine = Engine::getInstance();
$aPaging = $oEngine->Viewer_MakePaging($iCountItems, 1, $iPerPage, Config::Get('pagination.pages.count'), $this->getUrlFull());
return $aPaging;
}
示例14: doAction
public function doAction()
{
$this->job_info = getJobData($this->id_job, $this->password);
/**
* For future reminder
*
* MyMemory (id=1) should not be the only Glossary provider
*
*/
$this->_TMS = Engine::getInstance(1);
$this->checkLogin();
try {
$config = $this->_TMS->getConfigStruct();
$config['segment'] = $this->segment;
$config['translation'] = $this->translation;
$config['tnote'] = $this->comment;
$config['source'] = $this->job_info['source'];
$config['target'] = $this->job_info['target'];
$config['email'] = INIT::$MYMEMORY_API_KEY;
$config['id_user'] = $this->job_info['id_translator'];
$config['isGlossary'] = true;
$config['get_mt'] = null;
$config['num_result'] = 100;
//do not want limit the results from glossary: set as a big number
switch ($this->exec) {
case 'get':
$this->_get($config);
break;
case 'set':
/**
* For future reminder
*
* MyMemory should not be the only Glossary provider
*
*/
if ($this->job_info['id_tms'] == 0) {
throw new Exception("Glossary is not available when the TM feature is disabled", -11);
}
$this->_set($config);
break;
case 'update':
$this->_update($config);
break;
case 'delete':
$this->_delete($config);
break;
}
} catch (Exception $e) {
$this->result['errors'][] = array("code" => $e->getCode(), "message" => $e->getMessage());
}
}
示例15: smarty_function_hook
/**
* Плагин для смарти
* Запускает хуки из шаблона на выполнение
*
* @param array $aParams
* @param Smarty $oSmarty
* @return string
*/
function smarty_function_hook($aParams, &$oSmarty)
{
if (empty($aParams['run'])) {
trigger_error("Hook: missing 'run' parametr", E_USER_WARNING);
return;
}
$sHookName = 'template_' . strtolower($aParams['run']);
unset($aParams['run']);
$aResultHook = Engine::getInstance()->Hook_Run($sHookName, $aParams);
if (array_key_exists('template_result', $aResultHook)) {
return join('', $aResultHook['template_result']);
}
return '';
}