Example #1
0
 public function update_archive_link_cache($args)
 {
     $blog_id = $args['blog_id'];
     $at = $args['archive_type'];
     $where = isset($args['where']) ? $args['where'] : '';
     if (isset($args['hi']) && isset($args['low'])) {
         $hi = $args['hi'];
         $low = $args['low'];
         $range = " and fileinfo_startdate between '{$low}' and '{$hi}'";
     }
     $sql = "\n            fileinfo_archive_type = '{$at}'\n            and fileinfo_blog_id = {$blog_id}\n            and templatemap_is_preferred = 1\n            {$range}\n            {$where}";
     $extras['join']['mt_templatemap'] = array('condition' => "templatemap_id = fileinfo_templatemap_id");
     require_once 'class.mt_fileinfo.php';
     $fileinfo = new FileInfo();
     $finfos = $fileinfo->Find($sql, false, false, $extras);
     if (!empty($finfos)) {
         $mt = MT::get_instance();
         foreach ($finfos as $finfo) {
             $date = $this->db2ts($finfo->fileinfo_startdate);
             if ($at == 'Page') {
                 $blog_url = $finfo->blog()->site_url();
             } else {
                 $blog_url = $finfo->blog()->archive_url();
                 $blog_url or $blog_url = $finfo->blog()->site_url();
             }
             $blog_url = preg_replace('!(https?://(?:[^/]+))/.*!', '$1', $blog_url);
             $url = $blog_url . $finfo->url;
             $url = _strip_index($url, array('blog_file_extension' => $finfo->blog()->blog_file_extension));
             $this->_archive_link_cache[$date . ';' . $at] = $url;
         }
     }
     return true;
 }