/** * linktitleHandler */ public static function linktitleHandler($url) { if (module_const('is_cache', false)) { $store_key = array('__hatenaformat_linktitlehandler', $url); if (Store::has($store_key)) { return Store::get($store_key); } } if (Tag::setof($title, Http::read($url), 'title')) { $url = $title->value(); if (module_const('is_cache', false)) { Store::set($store_key, $url, self::CACHE_EXPIRE); } } return $url; }
/** * ファイルから生成する * @param string $filename * @return string */ public function read($filename, $template_name = null) { $this->filename($filename); $this->selected_template = $template_name; $cfilename = $this->filename . $this->selected_template; if (!self::$CACHE || File::isExpiry($cfilename, self::$CACHE_TIME)) { if (strpos($filename, "://") === false) { $src = $this->parse(File::read($this->filename)); } else { if (empty($this->url)) { $this->url = $this->filename; } $src = $this->parse(Http::read($this->filename)); } if (self::$CACHE) { File::cwrite($cfilename, $src); } } else { $src = File::cread($cfilename); } $src = $this->exec($src); $this->call_modules("after_read_template", $src); return $this->replace_ptag($src); }
private static function read_xml($type) { $path = "repository_" . $type . ".xml"; return self::is_remote() ? Http::read(self::path($path)) : File::read(self::path($path)); }
/** * ファイルから生成する * @param string $filename テンプレートファイルパス * @param string $template_name 対象となるテンプレート名 * @return string */ public function read($filename = null, $template_name = null) { if (!empty($filename)) { $this->filename($filename); } $this->selected_template = $template_name; $cfilename = $this->filename() . $this->selected_template; if (!self::$is_cache || !Store::has($cfilename, true)) { if (strpos($filename, '://') === false) { $src = $this->parse(File::read($this->filename())); } else { if (empty($this->media_url)) { $this->media_url($this->filename()); } $src = $this->parse(Http::read($this->filename())); } if (self::$is_cache) { Store::set($cfilename, $src); } } else { $src = Store::get($cfilename); } $src = $this->html_reform($this->exec($src)); $this->call_module('after_read_template', $src, $this); return $this->replace_ptag($src); }