/** * installBlockTemplate * * @param XoopsBlock &$block * @param XoopsModule &$module * @param Legacy_ModuleInstallLog &$log * * @return bool **/ public static function installBlockTemplate(&$block, &$module, &$log) { if ($block->get('template') == null) { return true; } $info =& $module->getInfo('blocks'); $filename = Xupdate_InstallUtils::replaceDirname($info[$block->get('func_num')]['template'], $module->get('dirname'), $module->getInfo('trust_dirname')); $tplHandler =& Xupdate_Utils::getXoopsHandler('tplfile'); $cri = new CriteriaCompo(); $cri->add(new Criteria('tpl_type', 'block')); $cri->add(new Criteria('tpl_tplset', 'default')); $cri->add(new Criteria('tpl_module', $module->get('dirname'))); $cri->add(new Criteria('tpl_file', $filename['public'])); $tpls =& $tplHandler->getObjects($cri); if (count($tpls) > 0) { $tplFile =& $tpls[0]; } else { $tplFile =& $tplHandler->create(); $tplFile->set('tpl_refid', $block->get('bid')); $tplFile->set('tpl_tplset', 'default'); $tplFile->set('tpl_file', $filename['public']); $tplFile->set('tpl_module', $module->get('dirname')); $tplFile->set('tpl_type', 'block'); //$tplFile->set('tpl_desc',$block->get('description')); $tplFile->set('tpl_lastimported', 0); } $tplSource = Xupdate_InstallUtils::readTemplateFile($module->get('dirname'), $module->getInfo('trust_dirname'), $filename['trust'], true); $tplFile->set('tpl_source', $tplSource); $tplFile->set('tpl_lastmodified', time()); if ($tplHandler->insert($tplFile)) { $log->addReport(XCube_Utils::formatString(_MI_XUPDATE_INSTALL_MSG_BLOCK_TPL_INSTALLED, $filename['public'])); return true; } $log->addError(XCube_Utils::formatString(_MI_XUPDATE_INSTALL_ERROR_BLOCK_TPL_INSTALLED, $filename['public'])); return false; }