Пример #1
0
 /**
  * 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 = Letag_InstallUtils::replaceDirname($info[$block->get('func_num')]['template'], $module->get('dirname'), $module->getInfo('trust_dirname'));
     $tplHandler =& Letag_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 = Letag_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_LETAG_INSTALL_MSG_BLOCK_TPL_INSTALLED, $filename['public']));
         return true;
     }
     $log->addError(XCube_Utils::formatString(_MI_LETAG_INSTALL_ERROR_BLOCK_TPL_INSTALLED, $filename['public']));
     return false;
 }