コード例 #1
0
 /**
  * Constructor
  */
 function ilPDNewsBlockGUI()
 {
     global $ilCtrl, $lng, $ilUser, $ilBench, $ilAccess, $ilCtrl;
     $ilBench->start("News", "ilPDNewsBlockGUI_Constructor");
     $news_set = new ilSetting("news");
     parent::ilBlockGUI();
     $this->setImage(ilUtil::getImagePath("icon_news_s.png"));
     $lng->loadLanguageModule("news");
     include_once "./Services/News/classes/class.ilNewsItem.php";
     $this->setLimit(5);
     $this->setAvailableDetailLevels(3);
     $this->dynamic = false;
     // store current access check results
     //		$this->acc_results = $ilAccess->getResults();
     // read access cache
     //		$this->acc_cache_hit = $ilAccess->readCache(
     //			((int) $news_set->get("acc_cache_mins")) * 60);
     include_once "./Services/News/classes/class.ilNewsCache.php";
     $this->acache = new ilNewsCache();
     $cres = $this->acache->getEntry($ilUser->getId() . ":0");
     $this->cache_hit = false;
     if ($this->acache->getLastAccessStatus() == "hit") {
         self::$st_data = unserialize($cres);
         $this->cache_hit = true;
     }
     if ($this->getDynamic() && !$this->cache_hit) {
         $this->dynamic = true;
         $data = array();
     } else {
         if ($this->getCurrentDetailLevel() > 0) {
             // do not ask two times for the data (e.g. if user displays a
             // single item on the personal desktop and the news block is
             // displayed at the same time)
             if (empty(self::$st_data)) {
                 self::$st_data = $this->getNewsData();
                 $data = self::$st_data;
             } else {
                 $data = self::$st_data;
             }
         } else {
             $data = array();
         }
     }
     $this->setTitle($lng->txt("news_internal_news"));
     $this->setRowTemplate("tpl.block_row_news_for_context.html", "Services/News");
     $this->setData($data);
     $this->handleView();
     // reset access check results
     $ilAccess->setResults($this->acc_results);
     $ilBench->stop("News", "ilPDNewsBlockGUI_Constructor");
 }