コード例 #1
0
function smarty_function_mtarchivelabel($args, &$ctx)
{
    $at = $ctx->stash('current_archive_type');
    if (isset($args['type'])) {
        $at = $args['type'];
    } elseif (isset($args['archive_type'])) {
        $at = $args['archive_type'];
    }
    $ar = ArchiverFactory::get_archiver($at);
    if (isset($ar)) {
        return $ar->get_label($args);
    } else {
        $mt = MT::get_instance();
        return $mt->translate($at);
    }
}
コード例 #2
0
function smarty_function_mtarchivetitle($args, &$ctx)
{
    $at = $ctx->stash('current_archive_type');
    if (isset($args['type'])) {
        $at = $args['type'];
    } elseif (isset($args['archive_type'])) {
        $at = $args['archive_type'];
    }
    if ($at == 'Category') {
        $title = $ctx->tag('CategoryLabel', $args);
        if (!empty($title)) {
            $title = encode_html(strip_tags($title));
        } else {
            $title = '';
        }
        return $title;
    } else {
        $ar = ArchiverFactory::get_archiver($at);
        return $ar->get_title($args, $ctx);
    }
}
コード例 #3
0
function smarty_function_mtarchivelink($args, &$ctx)
{
    $blog = $ctx->stash('blog');
    $at = $args['type'];
    $at or $at = $args['archive_type'];
    $at or $at = $ctx->stash('current_archive_type');
    $ts = $ctx->stash('current_timestamp');
    if ($at == 'Monthly') {
        $ts = substr($ts, 0, 6) . '01000000';
    } elseif ($at == 'Daily') {
        $ts = substr($ts, 0, 8) . '000000';
    } elseif ($at == 'Weekly') {
        require_once "MTUtil.php";
        list($ws, $we) = start_end_week($ts);
        $ts = $ws;
    } elseif ($at == 'Yearly') {
        $ts = substr($ts, 0, 4) . '0101000000';
    } elseif ($at == 'Individual' || $at == 'Page') {
        $args['archive_type'] or $args['archive_type'] = $at;
        return $ctx->tag('EntryPermalink', $args);
    } elseif ($at == 'Category') {
        return $ctx->tag('CategoryArchiveLink', $args);
    }
    $args['blog_id'] = $blog->blog_id;
    $ar = ArchiverFactory::get_archiver($at);
    $link_sql = $ar->get_archive_link_sql($ts, $at, $args);
    $link = $ctx->mt->db()->archive_link($ts, $at, $link_sql, $args);
    if ($args['with_index'] && preg_match('/\\/(#.*)*$/', $link)) {
        $blog = $ctx->stash('blog');
        $index = $ctx->mt->config('IndexBasename');
        $ext = $blog->blog_file_extension;
        if ($ext) {
            $ext = '.' . $ext;
        }
        $index .= $ext;
        $link = preg_replace('/\\/(#.*)?$/', "/{$index}\$1", $link);
    }
    return $link;
}
コード例 #4
0
function smarty_function_mtarchivecount($args, &$ctx)
{
    $at = '';
    $archiver = null;
    if ($at = $ctx->stash('current_archive_type')) {
        require_once "archive_lib.php";
        $archiver = ArchiverFactory::get_archiver($at);
    }
    $count = 0;
    if (!isset($archiver) && $ctx->stash('inside_mt_categories') || $ctx->stash('inside_mt_categories') && !$archiver->is_date_based()) {
        return $ctx->tag('MTCategoryCount', $args);
    } elseif ($count = $ctx->stash('archive_count')) {
        # $count is set
    } elseif ($entries = $ctx->stash('entries')) {
        $count = count($entries);
    } else {
        $eargs = array();
        $eargs['blog_id'] = $ctx->stash('blog_id');
        if ($at) {
            $ts = $ctx->stash('current_timestamp');
            $tse = $ctx->stash('current_timestamp_end');
            if (isset($archiver)) {
                if ($ts && $tse) {
                    # assign date range if we have both
                    # start and end date
                    $eargs['current_timestamp'] = $ts;
                    $eargs['current_timestamp_end'] = $tse;
                }
                $archiver->setup_args($ctx, $eargs);
            }
            $eargs['lastn'] = -1;
            $entries = $ctx->mt->db()->fetch_entries($eargs);
            $count = count($entries);
        }
    }
    return $ctx->count_format($count, $args);
}
コード例 #5
0
function smarty_function_mtentrytrackbackdata($args, &$ctx)
{
    $e = $ctx->stash('entry');
    $tb = $e->trackback();
    if (empty($tb)) {
        return '';
    }
    if ($tb->trackback_is_disabled) {
        return '';
    }
    $blog = $ctx->stash('blog');
    $entry = $ctx->stash('entry');
    $blog_accepted = $blog->blog_allow_pings && $ctx->mt->config('AllowPings');
    if ($entry) {
        $accepted = $blog_accepted && $entry->entry_allow_pings;
    } else {
        $accepted = $blog_accepted;
    }
    if (!$accepted) {
        return '';
    }
    require_once "function.mtcgipath.php";
    $path = smarty_function_mtcgipath($args, $ctx);
    $path .= $ctx->mt->config('TrackbackScript') . '/' . $tb->trackback_id;
    $at = $ctx->stash('current_archive_type');
    if ($at) {
        $at = ArchiverFactory::get_archiver($at);
    }
    if ($at && !$at instanceof IndividualArchiver) {
        $url = $ctx->tag('ArchiveLink');
        $url .= '#entry-' . sprintf("%06d", $e->entry_id);
    } else {
        $url = $ctx->tag($e->entry_class . 'Permalink', array('archive_type' => 'Individual'));
    }
    $rdf = '';
    $comment_wrap = isset($args['comment_wrap']) ? $args['comment_wrap'] : 1;
    if ($comment_wrap) {
        $rdf .= "<!--\n";
    }
    require_once "MTUtil.php";
    ## SGML comments cannot contain double hyphens, so we convert
    ## any double hyphens to single hyphens.
    $title = encode_xml(strip_hyphen($e->entry_title), 1);
    $subject = encode_xml(strip_hyphen($ctx->tag('EntryCategory')), 1);
    $excerpt = encode_xml(strip_hyphen($ctx->tag('EntryExcerpt')), 1);
    $creator = encode_xml(strip_hyphen($ctx->tag('EntryAuthorDisplayName')), 1);
    $date = $ctx->_hdlr_date(array('format' => '%Y-%m-%dT%H:%M:%S'), $ctx) . $ctx->tag('BlogTimezone');
    $rdf .= <<<RDF
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
         xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description
    rdf:about="{$url}"
    trackback:ping="{$path}"
    dc:title="{$title}"
    dc:identifier="{$url}"
    dc:subject="{$subject}"
    dc:description="{$excerpt}"
    dc:creator="{$creator}"
    dc:date="{$date}" />
</rdf:RDF>

RDF;
    if ($comment_wrap) {
        $rdf .= "-->\n";
    }
    return $rdf;
}
コード例 #6
0
ファイル: block.mtentries.php プロジェクト: OCMO/movabletype
function smarty_block_mtentries($args, $content, &$ctx, &$repeat)
{
    $localvars = array(array('entry', '_entries_counter', 'entries', 'current_timestamp', 'modification_timestamp', '_entries_lastn', 'current_timestamp_end', 'DateHeader', 'DateFooter', '_entries_glue', 'blog', 'blog_id', 'conditional', 'else_content', '__out'), common_loop_vars());
    if (isset($args['sort_by']) && $args['sort_by'] == 'score' && !isset($args['namespace'])) {
        return $ctx->error($ctx->mt->translate('sort_by="score" must be used together with a namespace.'));
    }
    if (!isset($content)) {
        $ctx->localize($localvars);
        // If we have a set of entries that were set based on context,
        // but the user has specified attributes that effectively
        // break that context, clear the stashed entries so fetch_entries
        // can reselect.
        $this_tag = strtolower($ctx->this_tag());
        if ($this_tag == 'mtentries' || $this_tag == 'mtpages') {
            if ($ctx->stash('entries') && (isset($args['category']) || isset($args['categories']) || isset($args['tag']) || isset($args['tags']) || isset($args['author']))) {
                $ctx->__stash['entries'] = null;
            }
        }
        if ($ctx->__stash['entries']) {
            if (isset($args['id']) || isset($args['recently_commented_on']) || isset($args['include_subcategories']) || isset($args['days'])) {
                $ctx->__stash['entries'] = null;
            } else {
                if (isset($args['sort_by'])) {
                    $ids = array();
                    foreach ($ctx->__stash['entries'] as $e) {
                        $ids[] = $e->entry_id;
                    }
                    $ctx->__stash['entries'] = null;
                    $args['entry_ids'] = $ids;
                }
            }
        }
        $counter = 0;
        $lastn = $args['lastn'];
        $ctx->stash('_entries_lastn', $lastn);
        $ctx->stash('__out', false);
    } else {
        $lastn = $ctx->stash('_entries_lastn');
        $counter = $ctx->stash('_entries_counter');
        $out = $ctx->stash('__out');
    }
    if (!isset($args['class'])) {
        $args['class'] = 'entry';
    }
    if (isset($args['offset']) && $args['offset'] == 'auto') {
        $l = 0;
        if ($args['limit']) {
            if ($args['limit'] == 'auto') {
                if ($_REQUEST['limit']) {
                    $l = $_REQUEST['limit'];
                } else {
                    $blog_id = intval($ctx->stash('blog_id'));
                    $blog = $ctx->mt->db()->fetch_blog($blog_id);
                    $l = $blog->blog_entries_on_index;
                }
            } else {
                $l = $args['limit'];
            }
        }
        if (!$l) {
            $l = 20;
        }
        $ctx->stash('__pager_limit', $l);
        if ($_REQUEST['offset']) {
            $ctx->stash('__pager_offset', $_REQUEST['offset']);
        }
    }
    $entries = $ctx->stash('entries');
    if (!isset($entries)) {
        require_once 'archive_lib.php';
        $at = $ctx->stash('current_archive_type');
        try {
            $archiver = ArchiverFactory::get_archiver($at);
        } catch (Exception $e) {
        }
        if (isset($args['id'])) {
            $args['entry_id'] = $args['id'];
        }
        $ts = $ctx->stash('current_timestamp');
        $tse = $ctx->stash('current_timestamp_end');
        if ($ts && $tse) {
            # assign date range if we have both
            # start and end date
            $args['current_timestamp'] = $ts;
            $args['current_timestamp_end'] = $tse;
        }
        if (isset($archiver)) {
            $args['limit'] || $args['lastn'] or $args['lastn'] = -1;
            $archiver->setup_args($args);
        }
        $cat = $ctx->stash('category');
        if (isset($cat) && ($args['class'] == 'entry' && $cat->category_class == 'category' || $args['class'] == 'page' && $cat->category_class == 'folder')) {
            $args['category'] or $args['categories'] or $args['category_id'] = $cat->category_id;
            if ($ctx->stash('inside_mt_categories')) {
                $args['category_id'] = $cat->category_id;
                $args['show_empty'] = $ctx->stash('show_empty');
            } else {
                $args['category'] or $args['categories'] or $args['category_id'] = $cat->category_id;
            }
        }
        if ($tag = $ctx->stash('Tag')) {
            $args['tag'] or $args['tags'] or $args['tags'] = is_object($tag) ? $tag->tag_name : $tag;
        }
        if (isset($args['offset']) && $args['offset'] == 'auto') {
            $total_count = 0;
        }
        $entries = $ctx->mt->db()->fetch_entries($args, $total_count);
        if (isset($args['offset']) && $args['offset'] == 'auto') {
            $ctx->stash('__pager_total_count', $total_count);
        }
        $ctx->stash('entries', $entries);
    }
    $ctx->stash('conditional', empty($entries) ? 0 : 1);
    if (empty($entries)) {
        $ret = $ctx->_hdlr_if($args, $content, $ctx, $repeat, 0);
        if (!$repeat) {
            $ctx->restore($localvars);
        }
        return $ret;
    }
    $ctx->stash('_entries_glue', $args['glue']);
    if ($lastn > count($entries) || $lastn == -1) {
        $lastn = count($entries);
        $ctx->stash('_entries_lastn', $lastn);
    }
    if ($lastn ? $counter < $lastn : $counter < count($entries)) {
        $blog_id = $ctx->stash('blog_id');
        $entry = $entries[$counter];
        if (!empty($entry)) {
            if ($blog_id != $entry->entry_blog_id) {
                $blog_id = $entry->entry_blog_id;
                $ctx->stash('blog_id', $blog_id);
                $ctx->stash('blog', $entry->blog());
            }
            if ($counter > 0) {
                $last_entry_created_on = $entries[$counter - 1]->entry_authored_on;
            } else {
                $last_entry_created_on = '';
            }
            if ($counter < count($entries) - 1) {
                $next_entry_created_on = $entries[$counter + 1]->entry_authored_on;
            } else {
                $next_entry_created_on = '';
            }
            $ctx->stash('DateHeader', !(substr($entry->entry_authored_on, 0, 8) == substr($last_entry_created_on, 0, 8)));
            $ctx->stash('DateFooter', substr($entry->entry_authored_on, 0, 8) != substr($next_entry_created_on, 0, 8));
            $ctx->stash('entry', $entry);
            $ctx->stash('current_timestamp', $entry->entry_authored_on);
            $ctx->stash('current_timestamp_end', null);
            $ctx->stash('modification_timestamp', $entry->entry_modified_on);
            $ctx->stash('_entries_counter', $counter + 1);
            $_REQUEST['entry_ids_published'][$entry->entry_id] = 1;
            $glue = $ctx->stash('_entries_glue');
            if (isset($glue) && !empty($content)) {
                if ($out) {
                    $content = $glue . $content;
                } else {
                    $ctx->stash('__out', true);
                }
            }
            $count = $counter + 1;
            $ctx->__stash['vars']['__counter__'] = $count;
            $ctx->__stash['vars']['__odd__'] = $count % 2 == 1;
            $ctx->__stash['vars']['__even__'] = $count % 2 == 0;
            $ctx->__stash['vars']['__first__'] = $count == 1;
            $ctx->__stash['vars']['__last__'] = $count == count($entries);
            $repeat = true;
        }
    } else {
        $glue = $ctx->stash('_entries_glue');
        if (isset($glue) && $out && !empty($content)) {
            $content = $glue . $content;
        }
        $ctx->restore($localvars);
        $repeat = false;
    }
    return $content;
}
コード例 #7
0
function smarty_block_mtarchivelist($args, $content, &$ctx, &$repeat)
{
    $localvars = array(array('current_archive_type', 'current_timestamp', 'current_timestamp_end', 'entries', 'archive_count', '_archive_list_num', '_archive_list_results', 'entry', 'ArchiveListHeader', 'ArchiveListFooter', 'inside_archive_list', 'category', 'author'), common_loop_vars());
    if (!isset($content)) {
        $blog = $ctx->stash('blog');
        $at = $args['type'];
        $at or $at = $args['archive_type'];
        $at or $at = $ctx->stash('current_archive_type');
        if ($at) {
            # do nothing if we have an $at
        } elseif ($blog_at = $blog->blog_archive_type_preferred) {
            $at = $blog_at;
        } elseif (empty($at)) {
            $types = explode(',', $blog->blog_archive_type);
            $at = $types[0];
        }
        if (empty($at) || $at == 'None') {
            $repeat = false;
            return '';
        }
        if ($at != 'Category') {
            try {
                $ar = ArchiverFactory::get_archiver($at);
            } catch (Exception $e) {
                $repeat = false;
                return '';
            }
        }
        $ctx->localize($localvars);
        $ctx->stash('current_archive_type', $at);
        ## If we are producing a Category archive list, don't bother to
        ## handle it here--instead hand it over to <MTCategories>.
        if ($at == 'Category') {
            require_once "block.mtcategories.php";
            return smarty_block_mtcategories($args, $content, $ctx, $repeat);
        }
        $blog_id = $blog->blog_id;
        $args['sort'] = 'created_on';
        $args['direction'] = 'descend';
        $args['archive_type'] = $at;
        $args['blog_id'] = $blog_id;
        $archive_list_results = $ar->get_archive_list($args);
        $ctx->stash('_archive_list_results', $archive_list_results);
        # allow <MTEntries> to load them
        $ctx->stash('entries', null);
        $ctx->stash('inside_archive_list', true);
        $i = 0;
    } else {
        $at = $ctx->stash('current_archive_type');
        $archive_list_results = $ctx->stash('_archive_list_results');
        $i = $ctx->stash('_archive_list_num');
    }
    if ($at == 'Category') {
        $content = smarty_block_mtcategories($args, $content, $ctx, $repeat);
        if (!$repeat) {
            $ctx->restore($localvars);
        }
        return $content;
    }
    if ($i < count($archive_list_results)) {
        if (empty($ar)) {
            $ar = ArchiverFactory::get_archiver($at);
        }
        $grp = $archive_list_results[$i];
        $ar->prepare_list($grp);
        if ($at == 'Individual' || $at == 'Page') {
            $cnt = 1;
        } else {
            $cnt = array_shift($grp);
        }
        if ($at == 'Individual' || $at == 'Page') {
            $entry = $ctx->stash('entry');
            $start = $end = $entry->entry_authored_on;
        } else {
            list($start, $end) = $ar->get_range($grp);
        }
        $start = preg_replace('/[^0-9]/', '', $start);
        $end = preg_replace('/[^0-9]/', '', $end);
        $ctx->stash('current_timestamp', $start);
        $ctx->stash('current_timestamp_end', $end);
        $ctx->stash('archive_count', $cnt);
        $ctx->stash('_archive_list_num', $i + 1);
        $ctx->stash('ArchiveListHeader', $i == 0);
        $ctx->stash('ArchiveListFooter', $i + 1 == count($archive_list_results));
        $repeat = true;
        $count = $i + 1;
        $ctx->__stash['vars']['__counter__'] = $count;
        $ctx->__stash['vars']['__odd__'] = $count % 2 == 1;
        $ctx->__stash['vars']['__even__'] = $count % 2 == 0;
        $ctx->__stash['vars']['__first__'] = $count == 1;
        $ctx->__stash['vars']['__last__'] = $count == count($archive_list_results);
        $i++;
    } else {
        $ctx->restore($localvars);
        $repeat = false;
    }
    return $content;
}
コード例 #8
0
ファイル: mt.php プロジェクト: benvanstaveren/movabletype
 function view($blog_id = null)
 {
     set_error_handler(array(&$this, 'error_handler'));
     require_once "MTUtil.php";
     $blog_id or $blog_id = $this->blog_id;
     try {
         $ctx =& $this->context();
         $this->init_plugins();
         $ctx->caching = $this->caching;
         // Some defaults...
         $mtdb =& $this->db();
         $ctx->mt->db =& $mtdb;
     } catch (Exception $e) {
         if ($this->debugging) {
             $msg = "<b>Error:</b> " . $e->getMessage() . "<br>\n" . "<pre>" . $e->getTraceAsString() . "</pre>";
             return trigger_error($msg, E_USER_ERROR);
         }
         header("503 Service Unavailable");
         return false;
     }
     // User-specified request through request variable
     $path = $this->request;
     // Apache request
     if (!$path && $_SERVER['REQUEST_URI']) {
         $path = $_SERVER['REQUEST_URI'];
         // strip off any query string...
         $path = preg_replace('/\\?.*/', '', $path);
         // strip any duplicated slashes...
         $path = preg_replace('!/+!', '/', $path);
     }
     // IIS request by error document...
     if (preg_match('/IIS/', $_SERVER['SERVER_SOFTWARE'])) {
         // assume 404 handler
         if (preg_match('/^\\d+;(.*)$/', $_SERVER['QUERY_STRING'], $matches)) {
             $path = $matches[1];
             $path = preg_replace('!^http://[^/]+!', '', $path);
             if (preg_match('/\\?(.+)?/', $path, $matches)) {
                 $_SERVER['QUERY_STRING'] = $matches[1];
                 $path = preg_replace('/\\?.*$/', '', $path);
             }
         }
     }
     // now set the path so it may be queried
     $path = preg_replace('/\\\\/', '\\\\\\\\', $path);
     $this->request = $path;
     $pathinfo = pathinfo($path);
     $ctx->stash('_basename', $pathinfo['filename']);
     // When we are invoked as an ErrorDocument, the parameters are
     // in the environment variables REDIRECT_*
     if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
         // todo: populate $_GET and QUERY_STRING with REDIRECT_QUERY_STRING
         $_SERVER['QUERY_STRING'] = getenv('REDIRECT_QUERY_STRING');
     }
     if (preg_match('/\\.(\\w+)$/', $path, $matches)) {
         $req_ext = strtolower($matches[1]);
     }
     $this->blog_id = $blog_id;
     $data = $this->resolve_url($path);
     if (!$data) {
         // 404!
         $this->http_error = 404;
         header("HTTP/1.1 404 Not found");
         return $ctx->error($this->translate("Page not found - [_1]", $path), E_USER_ERROR);
     }
     $fi_path = $data->fileinfo_url;
     $fid = $data->fileinfo_id;
     $at = $data->fileinfo_archive_type;
     $ts = $data->fileinfo_startdate;
     $tpl_id = $data->fileinfo_template_id;
     $cat = $data->fileinfo_category_id;
     $auth = $data->fileinfo_author_id;
     $entry_id = $data->fileinfo_entry_id;
     $blog_id = $data->fileinfo_blog_id;
     $blog = $data->blog();
     if ($at == 'index') {
         $at = null;
         $ctx->stash('index_archive', true);
     } else {
         $ctx->stash('index_archive', false);
     }
     $tmpl = $data->template();
     $ctx->stash('template', $tmpl);
     $tts = $tmpl->template_modified_on;
     if ($tts) {
         $tts = offset_time(datetime_to_timestamp($tts), $blog);
     }
     $ctx->stash('template_timestamp', $tts);
     $ctx->stash('template_created_on', $tmpl->template_created_on);
     $page_layout = $blog->blog_page_layout;
     $columns = get_page_column($page_layout);
     $vars =& $ctx->__stash['vars'];
     $vars['page_columns'] = $columns;
     $vars['page_layout'] = $page_layout;
     if (isset($tmpl->template_identifier)) {
         $vars[$tmpl->template_identifier] = 1;
     }
     $this->configure_paths($blog->site_path());
     // start populating our stash
     $ctx->stash('blog_id', $blog_id);
     $ctx->stash('local_blog_id', $blog_id);
     $ctx->stash('blog', $blog);
     $ctx->stash('build_template_id', $tpl_id);
     // conditional get support...
     if ($this->caching) {
         $this->cache_modified_check = true;
     }
     if ($this->conditional) {
         $local_last_datetime = $blog->blog_children_modified_on;
         $gmt_last_ts = datetime_to_timestamp($local_last_datetime);
         $gmt_last_datetime = gmdate('YmdHis', $gmt_last_ts);
         $last_modified = $ctx->_hdlr_date(array('ts' => $gmt_last_datetime, 'format' => '%a, %d %b %Y %H:%M:%S GMT', 'language' => 'en'), $ctx);
         $this->doConditionalGet($last_modified);
     }
     $cache_id = $blog_id . ';' . $fi_path;
     if (!$ctx->is_cached('mt:' . $tpl_id, $cache_id)) {
         if (isset($at) && $at != 'Category') {
             require_once "archive_lib.php";
             try {
                 $archiver = ArchiverFactory::get_archiver($at);
             } catch (Exception $e) {
                 // 404
                 $this->http_errr = 404;
                 header("HTTP/1.1 404 Not Found");
                 return $ctx->error($this->translate("Page not found - [_1]", $at), E_USER_ERROR);
             }
             $archiver->template_params($ctx);
         }
         if ($cat) {
             $archive_category = $mtdb->fetch_category($cat);
             $ctx->stash('category', $archive_category);
             $ctx->stash('archive_category', $archive_category);
         }
         if ($auth) {
             $archive_author = $mtdb->fetch_author($auth);
             $ctx->stash('author', $archive_author);
             $ctx->stash('archive_author', $archive_author);
         }
         if (isset($at)) {
             if ($at != 'Category' && isset($ts)) {
                 list($ts_start, $ts_end) = $archiver->get_range($ts);
                 $ctx->stash('current_timestamp', $ts_start);
                 $ctx->stash('current_timestamp_end', $ts_end);
             }
             $ctx->stash('current_archive_type', $at);
         }
         if (isset($entry_id) && $entry_id && ($at == 'Individual' || $at == 'Page')) {
             if ($at == 'Individual') {
                 $entry = $mtdb->fetch_entry($entry_id);
             } elseif ($at == 'Page') {
                 $entry = $mtdb->fetch_page($entry_id);
             }
             $ctx->stash('entry', $entry);
             $ctx->stash('current_timestamp', $entry->entry_authored_on);
         }
         if ($at == 'Category') {
             $vars =& $ctx->__stash['vars'];
             $vars['archive_class'] = "category-archive";
             $vars['category_archive'] = 1;
             $vars['archive_template'] = 1;
             $vars['archive_listing'] = 1;
             $vars['module_category_archives'] = 1;
         }
     }
     $this->set_canonical_url($ctx, $blog, $data);
     $output = $ctx->fetch('mt:' . $tpl_id, $cache_id);
     $this->http_error = 200;
     header("HTTP/1.1 200 OK");
     // content-type header-- need to supplement with charset
     $content_type = $ctx->stash('content_type');
     if (!isset($content_type)) {
         $content_type = $this->mime_types['__default__'];
         if ($req_ext && isset($this->mime_types[$req_ext])) {
             $content_type = $this->mime_types[$req_ext];
         }
     }
     $charset = $this->config('PublishCharset');
     if (isset($charset)) {
         if (!preg_match('/charset=/', $content_type)) {
             $content_type .= '; charset=' . $charset;
         }
     }
     header("Content-Type: {$content_type}");
     // finally, issue output
     $output = preg_replace('/^\\s*/', '', $output);
     echo $output;
     // if warnings found, show it.
     if (!empty($this->warning)) {
         $this->_dump($this->warning);
     }
     #        if ($this->debugging) {
     #            $this->log("Queries: ".$mtdb->num_queries);
     #            $this->log("Queries executed:");
     #            $queries = $mtdb->savedqueries;
     #            foreach ($queries as $q) {
     #                $this->log($q);
     #            }
     #            $this->log_dump();
     #        }
     restore_error_handler();
 }
コード例 #9
0
 protected function get_category_name()
 {
     $mt = MT::get_instance();
     $ctx =& $mt->context();
     $curr_at = $ctx->stash('current_archive_type');
     $archiver = ArchiverFactory::get_archiver($curr_at);
     $cat = $ctx->stash('category');
     $cat_name = '';
     if ($ctx->stash('index_archive') || !isset($archiver) || isset($archiver) && !isset($cat) || !$ctx->stash('inside_archive_list')) {
         $cat = $ctx->stash('archive_category');
         $cat or $cat = $ctx->stash('category');
         if (isset($cat)) {
             $cat_name = $cat->category_label . ": ";
         }
     }
     return $cat_name;
 }