示例#1
0
 public function __construct($humanId = null)
 {
     //set the model name and create an empty file if not exists
     $this->modelName = serverConfig('HUMAN_MODEL');
     parent::__construct(serverConfig('DATA_FILE_LOCATION') . serverConfig('HUMAN_MODEL'));
     if (!is_null($humanId)) {
         $humanData = $this->findRowById($humanId);
         if ($humanData) {
             $this->attributes = $humanData;
         }
     }
 }
示例#2
0
文件: directory.php 项目: ondc/spider
 /**
  * 读取数组中对应的所有文件数据
  *
  * @param Array,包含文件名列表
  * @return Array,对应的二维数组,包括文件名、作者信息等
  */
 private function fetchHtmlFileContent($html_file_name_preg)
 {
     $htmlArray = $this->fetchHtmlList($html_file_name_preg);
     foreach ($htmlArray as $htmName) {
         if (file_exists($this->dirPath . $htmName)) {
             //创建一个数组保存meta信息
             $singleHTMLMeta = array();
             $fileProc = new FileProcessor();
             $fileMeta = $fileProc->readHtml($this->dirPath, $htmName);
             //文件名
             $singleHTMLMeta['fileName'] = $htmName;
             //作者
             $singleHTMLMeta['author'] = strtolower($fileMeta['author']);
             if (!in_array($singleHTMLMeta['author'], $this->authorList)) {
                 array_push($this->authorList, $singleHTMLMeta['author']);
             }
             //缩略图
             $thumb_url = "http://getimg.in/220x150s" . preg_replace('/.html?/', '', $htmName);
             $pngName = preg_replace('/html?/', 'png', $htmName);
             $pngName = $this->dirPath . $pngName;
             if (file_exists($pngName)) {
                 $thumb_url = $pngName;
             }
             $singleHTMLMeta['thumbUrl'] = $thumb_url;
             //最后修改时间
             $fileUpdateData = date("Y/m/d", filemtime($this->dirPath . $htmName));
             $singleHTMLMeta['fileUpdateData'] = $fileUpdateData;
             //简介
             $fileDescription = $fileMeta['description'];
             $singleHTMLMeta['fileDescription'] = $fileDescription;
             //标题
             $fileTitle = $fileMeta['metatitle'];
             $singleHTMLMeta['fileTitle'] = $fileTitle;
             array_push($this->htmlMetaList, $singleHTMLMeta);
         }
     }
 }