Пример #1
0
 /**
  * Decorate the about::confusa template with the information from the
  * VERSION file
  */
 private function assignVersionVariables()
 {
     try {
         $confusaVersion = MetaInfo::getConfusaVersion();
     } catch (ConfusaGenException $cge) {
         Framework::error_output("Could not determine the version of Confusa! " . "Please contact an administrator about that!");
     }
     $version_path = Config::get_config('install_path') . "VERSION";
     $version_file = file_get_contents($version_path);
     $this->tpl->assign('cVersion', $confusaVersion);
     $cdn_line_start = strpos($version_file, "NAME=");
     $cdn_line_end = strpos($version_file, "\n", $cdn_line_start);
     if ($cdn_line_start === false || $cdn_line_end === false) {
         Framework::error_output("Could not determine the version codename of " . "Confusa! Please contact an administrator about " . "that!");
     }
     $cdn_line_start += 5;
     $versionCodename = substr($version_file, $cdn_line_start, $cdn_line_end - $cdn_line_start);
     $this->tpl->assign('cCodename', $versionCodename);
 }
Пример #2
0
 /**
  * 获取元信息
  * 会缓存
  * @param string $class
  * @return array
  */
 public function getMetaInfo($class)
 {
     if (is_string($class)) {
         $refl = new \ReflectionClass($class);
     } else {
         $refl = $class;
     }
     $name = $refl->getName();
     if ($this->metas !== null && isset($this->metas[$name])) {
         return $this->metas[$name];
     }
     static $cache = null;
     if ($cache === null) {
         $cache = new Cache();
     }
     $succeeded = false;
     $cache_key = 'meta_' . sha1($refl->getFileName() . '/' . $name);
     $data = $cache->get($cache_key, $succeeded);
     if ($succeeded) {
         return $data;
     }
     $data = MetaInfo::get($name);
     $files = [$refl->getFileName()];
     $parent = $refl->getParentClass();
     if ($parent) {
         $files[] = $parent->getFileName();
     }
     foreach ($refl->getInterfaces() as $i) {
         $files[] = $i->getFileName();
     }
     $cache->set($cache_key, $data, 60, new FileExpiredChecker($files));
     return $data;
 }