Ejemplo n.º 1
0
 /**
  * clear config cache of a module
  *
  *
  * @param    string    $dirname    module dirname
  * @return    bool
  */
 function mod_clearConfig($dirname = "")
 {
     if (empty($dirname)) {
         return false;
     }
     return \Xoops\Cache::delete("{$dirname}_config");
 }
Ejemplo n.º 2
0
 /**
  * Blocks::buildBlock()
  *
  * @param XoopsBlock $xobject  block to render
  * @param XoopsTpl   $template template engine
  *
  * @return array|bool
  */
 public function buildBlock(XoopsBlock $xobject, XoopsTpl $template)
 {
     $xoops = \Xoops::getInstance();
     // The lame type workaround will change
     // bid is added temporarily as workaround for specific block manipulation
     $dirname = $xobject->getVar('dirname');
     $block = array('id' => $xobject->getVar('bid'), 'module' => $dirname, 'title' => $xobject->getVar('title'), 'weight' => $xobject->getVar('weight'), 'lastmod' => $xobject->getVar('last_modified'));
     $bcachetime = (int) $xobject->getVar('bcachetime');
     if (empty($bcachetime)) {
         $template->caching = 0;
     } else {
         $template->caching = 2;
         $template->cache_lifetime = $bcachetime;
     }
     $template->setCompileId($dirname);
     $tplName = ($tplName = $xobject->getVar('template')) ? "block:{$dirname}/{$tplName}" : "module:system/system_block_dummy.tpl";
     //$tplName = str_replace('.html', '.tpl', $tplName);
     $cacheid = $this->generateCacheId('blk_' . $xobject->getVar('bid'));
     $xoops->preload()->triggerEvent('core.themeblocks.buildblock.start', array($xobject, $template->isCached($tplName, $cacheid)));
     if (!$bcachetime || !$template->isCached($tplName, $cacheid)) {
         //Get theme metas
         $old = array();
         if ($this->theme && $bcachetime) {
             foreach ($this->theme->metas as $type => $value) {
                 $old[$type] = $this->theme->metas[$type];
             }
         }
         //build block
         if ($bresult = $xobject->buildBlock()) {
             $template->assign('block', $bresult);
             $block['content'] = $template->fetch($tplName, $cacheid);
         } else {
             $block = false;
         }
         //check if theme added new metas
         if ($this->theme && $bcachetime) {
             $metas = array();
             foreach ($this->theme->metas as $type => $value) {
                 $dif = \Xoops\Utils::arrayRecursiveDiff($this->theme->metas[$type], $old[$type]);
                 if (count($dif)) {
                     $metas[$type] = $dif;
                 }
             }
             if (count($metas)) {
                 \Xoops\Cache::write($cacheid, $metas);
             }
         }
     } else {
         $block['content'] = $template->fetch($tplName, $cacheid);
     }
     //add block cached metas
     if ($this->theme && $bcachetime) {
         if ($metas = \Xoops\Cache::read($cacheid)) {
             foreach ($metas as $type => $value) {
                 $this->theme->metas[$type] = array_merge($this->theme->metas[$type], $metas[$type]);
             }
         }
     }
     $template->setCompileId();
     return $block;
 }
Ejemplo n.º 3
0
 /**
  * Get a list of extensions
  *
  * @param string $name      name of captcha looking for
  * @param string $extension extentions for captcha
  *
  * @return array|mixed
  */
 public function getList($name, $extension = "")
 {
     if ($items = \Xoops\Cache::read("captcha_captcha_{$name}")) {
         return $items;
     }
     $file_path = $this->xoops_root_path . "/class/captcha/image/{$name}";
     $files = \Xoops\Core\Lists\File::getList($file_path);
     foreach ($files as $item) {
         if (empty($extension) || preg_match("/(\\.{$extension})\$/i", $item)) {
             $items[] = $item;
         }
     }
     \Xoops\Cache::write("captcha_captcha_{$name}", $items);
     return $items;
 }
Ejemplo n.º 4
0
 /**
  * @param $name
  * @param null|string $dirname
  * @param null|string $cache_path
  * @return mixed|null
  */
 function mod_loadFile($name, $dirname = null, $cache_path = null)
 {
     $xoops = Xoops::getInstance();
     $data = null;
     if (empty($name)) {
         return $data;
     }
     $dirname = $dirname ? $dirname : $xoops->moduleDirname;
     $cache_path = $cache_path ? $cache_path : $xoops->globalData->getVar('cache-path');
     $key = "{$dirname}_{$name}";
     return \Xoops\Cache::read($key);
 }