Пример #1
0
 function &get_archive_list($args)
 {
     $blog_id = $args['blog_id'];
     $at = $args['archive_type'];
     $group_sql = $this->archive_list_sql($args);
     $results = $this->get_results($group_sql, ARRAY_N);
     if (is_array($results)) {
         if ($at == 'Daily') {
             $hi = sprintf("%04d%02d%02d", $results[0][1], $results[0][2], $results[0][3]);
             $low = sprintf("%04d%02d%02d", $results[count($results) - 1][1], $results[count($results) - 1][2], $results[count($results) - 1][3]);
         } elseif ($at == 'Weekly') {
             require_once "MTUtil.php";
             $week_yr = substr($results[0][1], 0, 4);
             $week_num = substr($results[0][1], 4);
             list($y, $m, $d) = week2ymd($week_yr, $week_num);
             $hi = sprintf("%04d%02d%02d", $y, $m, $d);
             $week_yr = substr($results[count($results) - 1][1], 0, 4);
             $week_num = substr($results[count($results) - 1][1], 4);
             list($y, $m, $d) = week2ymd($week_yr, $week_num);
             $low = sprintf("%04d%02d%02d", $y, $m, $d);
         } elseif ($at == 'Monthly') {
             $hi = sprintf("%04d%02d32", $results[0][1], $results[0][2]);
             $low = sprintf("%04d%02d00", $results[count($results) - 1][1], $results[count($results) - 1][2]);
         } elseif ($at == 'Yearly') {
             $hi = sprintf("%04d0000", $results[0][1]);
             $low = sprintf("%04d0000", $results[count($results) - 1][1]);
         } elseif ($at == 'Individual') {
             $hi = $results[0][1];
             $low = $results[count($results) - 1][1];
         }
         $range = "'{$low}' and '{$hi}'";
         $link_cache_sql = "\n                select fileinfo_startdate, fileinfo_url, blog_site_url, blog_file_extension, blog_archive_url\n                  from mt_fileinfo, mt_templatemap, mt_blog\n                 where fileinfo_startdate between {$range}\n                   and fileinfo_archive_type = '{$at}'\n                   and blog_id = {$blog_id}\n                   and fileinfo_blog_id = blog_id\n                   and templatemap_id = fileinfo_templatemap_id\n                   and templatemap_is_preferred = 1\n            ";
         $cache_results = $this->get_results($link_cache_sql, ARRAY_N);
         if (is_array($cache_results)) {
             foreach ($cache_results as $row) {
                 $date = $this->db2ts($row[0]);
                 if ($at == 'Page') {
                     $blog_url = $row[2];
                 } else {
                     $blog_url = $row[4];
                     $blog_url or $blog_url = $row[2];
                 }
                 $blog_url = preg_replace('!(https?://(?:[^/]+))/.*!', '$1', $blog_url);
                 $url = $blog_url . $row[1];
                 $url = _strip_index($url, array('blog_file_extension' => $row[3]));
                 $this->_archive_link_cache[$date . ';' . $at] = $url;
             }
         }
     }
     return $results;
 }
Пример #2
0
 function get_archive_list_data($args)
 {
     global $mt;
     $blog_id = $args['blog_id'];
     $order = $args['sort_order'] == 'ascend' ? 'asc' : 'desc';
     $cat_order = $args['sort_order'] == 'ascend' ? 'asc' : $args['sort_order'] == 'descend' ? 'desc' : '';
     $ctx = $mt->context();
     $index = $ctx->stash('index_archive');
     $inside = $ctx->stash('inside_archive_list');
     if (!isset($inside)) {
         $inside = false;
     }
     if ($inside) {
         $ts = $ctx->stash('current_timestamp');
         $tsend = $ctx->stash('current_timestamp_end');
         if ($ts && $tsend) {
             $ts = $mt->db->ts2db($ts);
             $tsend = $mt->db->ts2db($tsend);
             $date_filter = "and entry_authored_on between '{$ts}' and '{$tsend}'";
         }
     }
     #if (!$index) {
     $cat = $ctx->stash('archive_category');
     $cat or $cat = $ctx->stash('category');
     if (isset($cat)) {
         $cat_filter = " and placement_category_id=" . $cat['category_id'];
     }
     #}
     $sql = "\n            select count(*),\n                   entry_week_number,\n                   placement_category_id\n              from mt_entry join mt_placement on entry_id = placement_entry_id\n                   join mt_category on placement_category_id = category_id\n             where entry_blog_id = {$blog_id}\n               and entry_status = 2\n               and entry_class = 'entry'\n               {$cat_filter}\n               {$date_filter}\n             group by\n                   entry_week_number,\n                   placement_category_id\n             order by\n                   entry_week_number {$order}\n                   <LIMIT>";
     $group_sql = $mt->db->apply_limit_sql($sql, $args['lastn'], $args['offset']);
     $results = $mt->db->get_results($group_sql, ARRAY_N);
     if (is_array($results)) {
         $week_yr = substr($results[0][1], 0, 4);
         $week_num = substr($results[0][1], 4);
         list($y, $m, $d) = week2ymd($week_yr, $week_num);
         $hi = sprintf("%04d%02d%02d000000", $y, $m, $d);
         $week_yr = substr($results[count($result) - 1][1], 0, 4);
         $week_num = substr($results[count($result) - 1][1], 4);
         list($y, $m, $d) = week2ymd($week_yr, $week_num);
         $low = sprintf("%04d%02d%02d000000", $y, $m, $d);
     }
     return array($results, $hi, $low);
 }
Пример #3
0
 protected function get_update_link_args($results)
 {
     $args = array();
     if (!empty($results)) {
         $count = count($results);
         require_once "MTUtil.php";
         $week_yr = substr($results[0]['entry_week_number'], 0, 4);
         $week_num = substr($results[0]['entry_week_number'], 4);
         list($y, $m, $d) = week2ymd($week_yr, $week_num);
         $args['hi'] = sprintf("%04d%02d%02d", $y, $m, $d);
         $week_yr = substr($results[$count - 1]['entry_week_number'], 0, 4);
         $week_num = substr($results[$count - 1]['entry_week_number'], 4);
         list($y, $m, $d) = week2ymd($week_yr, $week_num);
         $args['low'] = sprintf("%04d%02d%02d", $y, $m, $d);
     }
     return $args;
 }