/**
  * @return array|mixed
  */
 public function get()
 {
     $ilGlobalCache = ilGlobalCache::getInstance();
     if ($ilGlobalCache->isActive()) {
         $rec = $ilGlobalCache->get($this->cache_key);
         if (!$rec) {
             $rec = $this->getFromDb();
             $ilGlobalCache->set($this->cache_key, $rec, 600);
         }
     } else {
         $rec = $this->getFromDb();
     }
     return $rec;
 }
 /**
  * @param $language_key
  */
 protected function __construct($language_key)
 {
     $this->setLanguageKey($language_key);
     /**
      * @var $ilUser         ilObjUser
      * @var $ilLog          ilLog
      */
     $this->global_cache = ilGlobalCache::getInstance(ilGlobalCache::COMP_CLNG);
     $this->readFromCache();
     if (!$this->getLoaded()) {
         $this->readFromDB();
         $this->writeToCache();
         $this->setLoaded(true);
     }
 }
 protected function initListeners()
 {
     require_once './Services/GlobalCache/classes/class.ilGlobalCache.php';
     $ilGlobalCache = ilGlobalCache::getInstance(ilGlobalCache::COMP_EVENTS);
     $cached_listeners = $ilGlobalCache->get('listeners');
     if (is_array($cached_listeners)) {
         $this->listener = $cached_listeners;
         return;
     }
     global $ilDB;
     $this->listener = array();
     $sql = "SELECT * FROM il_event_handling" . " WHERE type = " . $ilDB->quote("listen", "text");
     $res = $ilDB->query($sql);
     while ($row = $ilDB->fetchAssoc($res)) {
         $this->listener[$row["id"]][] = $row["component"];
     }
     $ilGlobalCache->set('listeners', $this->listener);
 }
 /**
  * read structure
  */
 function readStructure($a_force = false, $a_dir = "", $a_comp_prefix = "", $a_plugin_path = "")
 {
     global $ilDB;
     if (!$a_force && $this->ini->readVariable("db", "structure_reload") != "1") {
         return;
     }
     require_once './Services/UICore/classes/class.ilCachedCtrl.php';
     ilCachedCtrl::flush();
     require_once './Services/GlobalCache/classes/class.ilGlobalCache.php';
     ilGlobalCache::flushAll();
     // prefix for component
     $this->comp_prefix = $a_comp_prefix;
     // plugin path
     $this->plugin_path = $a_plugin_path;
     // only run one time per db_update request
     if (!$this->executed) {
         if ($a_dir == "") {
             $this->start_dir = ILIAS_ABSOLUTE_PATH;
             $this->read(ILIAS_ABSOLUTE_PATH);
         } else {
             $this->start_dir = $a_dir;
             $this->read($a_dir);
         }
         $this->store();
         $this->determineClassFileIds();
         $this->executed = true;
         if (!$a_force) {
             $this->ini->setVariable("db", "structure_reload", "0");
             $this->ini->write();
         }
     }
     // read module information
     // not clear whether this is a good place for module reading info
     // or not
     include_once "./Services/UICore/classes/class.ilCtrl.php";
     $ctrl = new ilCtrl();
     //		$ctrl->storeCommonStructures();
 }
 /**
  * @return string
  */
 protected static function generateServiceId()
 {
     if (!isset(self::$unique_service_id)) {
         self::$unique_service_id = substr(md5('il_' . CLIENT_ID), 0, 6);
     }
     return self::$unique_service_id;
 }
 public static function flush()
 {
     ilGlobalCache::getInstance(ilGlobalCache::COMP_COMPONENT)->flush();
     self::$instance = NULL;
 }
Beispiel #7
0
 /**
  * Update all languages
  */
 public final function updateLanguages()
 {
     global $ilCtrl;
     ilGlobalCache::flushAll();
     include_once "./Services/Language/classes/class.ilObjLanguage.php";
     $langs = $this->getAvailableLangFiles($this->getLanguageDirectory());
     $prefix = $this->getPrefix();
     foreach ($langs as $lang) {
         $txt = file($this->getLanguageDirectory() . "/" . $lang["file"]);
         $lang_array = array();
         // get language data
         if (is_array($txt)) {
             foreach ($txt as $row) {
                 if ($row[0] != "#" && strpos($row, "#:#") > 0) {
                     $a = explode("#:#", trim($row));
                     $lang_array[$prefix . "_" . trim($a[0])] = trim($a[1]);
                     ilObjLanguage::replaceLangEntry($prefix, $prefix . "_" . trim($a[0]), $lang["key"], trim($a[1]));
                     //echo "<br>-$prefix-".$prefix."_".trim($a[0])."-".$lang["key"]."-";
                 }
             }
         }
         ilObjLanguage::replaceLangModule($lang["key"], $prefix, $lang_array);
     }
 }
 /**
  * Read object definition data
  */
 function readDefinitionData()
 {
     if (ilGlobalCache::getInstance(ilGlobalCache::COMP_COMPONENT)->isActive()) {
         $this->readDefinitionDataFromCache();
     } else {
         $this->readDefinitionDataFromDB();
     }
 }
 public function saveCache()
 {
     /**
      * @var $ini ilIniFile
      */
     require_once 'Services/GlobalCache/classes/class.ilGlobalCache.php';
     ilGlobalCache::flushAll();
     $ini = $this->setup->getClient()->ini;
     if (!$ini->readGroup('cache')) {
         $ini->addGroup('cache');
     }
     $activate_global_cache = 'activate_global_cache';
     $global_cache_service_type = 'global_cache_service_type';
     $ini->setVariable('cache', $activate_global_cache, $_POST[$activate_global_cache]);
     $ini->setVariable('cache', $global_cache_service_type, $_POST[$global_cache_service_type]);
     $ini->write();
     ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
     ilUtil::redirect('setup.php?cmd=cache');
 }
Beispiel #10
0
 protected function __construct()
 {
     $this->global_cache = ilGlobalCache::getInstance(ilGlobalCache::COMP_ILCTRL);
     $this->readFromDB();
 }
 /**
  * Replace lang entry
  */
 static final function replaceLangEntry($a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change = null, $a_remarks = null)
 {
     global $ilDB;
     ilGlobalCache::flushAll();
     if (isset($a_remarks)) {
         $a_remarks = substr($a_remarks, 0, 250);
     }
     if ($a_remarks == '') {
         unset($a_remarks);
     }
     if (isset($a_value)) {
         $a_value = substr($a_value, 0, 4000);
     }
     if ($a_value == '') {
         unset($a_value);
     }
     $ilDB->replace('lng_data', array('module' => array('text', $a_module), 'identifier' => array('text', $a_identifier), 'lang_key' => array('text', $a_lang_key)), array('value' => array('text', $a_value), 'local_change' => array('timestamp', $a_local_change), 'remarks' => array('text', $a_remarks)));
     return true;
     /*
     $ilDB->manipulate(sprintf("DELETE FROM lng_data WHERE module = %s AND ".
     	"identifier = %s AND lang_key = %s",
     	$ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
     	$ilDB->quote($a_lang_key, "text")));
     
     
     $ilDB->manipulate(sprintf("INSERT INTO lng_data " .
     	"(module, identifier, lang_key, value, local_change) " .
     	"VALUES (%s,%s,%s,%s,%s)",
     	$ilDB->quote($a_module, "text"), $ilDB->quote($a_identifier, "text"),
     	$ilDB->quote($a_lang_key, "text"), $ilDB->quote($a_value, "text"),
     	$ilDB->quote($a_local_change, "timestamp")));
     */
 }
 protected function updateCachedResults()
 {
     $this->global_cache->set($this->getTableName() . '_cached_results', $this->getCachedResults());
 }