예제 #1
0
 public static function getModuleTemplatePath(XoopsTplfile $tplObj)
 {
     $block = $tplObj->getVar('tpl_type') === 'block' ? '/blocks' : null;
     $dirname = $tplObj->getVar('tpl_module');
     $modulePath = $dirname . '/templates' . $block;
     //Case 1:under public root_path with dirname in template name like 'cat'
     $publicPath = XOOPS_MODULE_PATH . '/' . $modulePath . '/' . $tplObj->getVar('tpl_file');
     if (file_exists($publicPath)) {
         return $publicPath;
     }
     //prepare for Case 2 and Case 3
     if (!($trustDirname = self::getTrustPath($dirname))) {
         return false;
     }
     $filename = preg_replace('/' . $dirname . '/', $trustDirname, $tplObj->getVar('tpl_file'), 1);
     //Case 2:under public root_path with trust_dirname in template name like 'lecat'
     $publicPath = XOOPS_MODULE_PATH . '/' . $modulePath . '/' . $filename;
     if (file_exists($publicPath)) {
         return $publicPath;
     }
     //Case 3:under trust_path
     $trustPath = XOOPS_TRUST_PATH . '/modules/' . $trustDirname . '/templates' . $block . '/' . $filename;
     if (file_exists($trustPath)) {
         return $trustPath;
     }
     return false;
 }
예제 #2
0
 /**
  * delete a block from the database
  *
  * @param XoopsTplfile $tplfile
  *
  * @return bool
  */
 public function deleteTpl(XoopsTplfile &$tplfile)
 {
     $tpl_id = $tplfile->getVar('tpl_id');
     if (!$this->db2->deletePrefix('tplfile', array('tpl_id' => $tpl_id))) {
         return false;
     }
     $this->db2->deletePrefix('tplsource', array('tpl_id' => $tpl_id));
     return true;
 }