예제 #1
0
파일: index.php 프로젝트: formatcc/tipi
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/BookPage.php";
try {
    $view = new SimpieView('../templates/downloads/index.php', "../templates/layout/common_page.php");
    $view->render(array('current_page' => 'downloads', 'title' => '下载'));
} catch (PageNotFoundException $e) {
    // TODO Suggest the page like the page name
    $view = new SimpieView("../templates/book_page_404.php", "../templates/layout/book.php");
    $view->render(array('book_page' => $page_name, 'title' => "Page Not Found", 'is_detail_view' => true, 'chapt_list' => $chapt_list));
}
예제 #2
0
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/BookPage.php";
$page_name = isset($_GET['p']) && $_GET['p'] ? trim($_GET['p']) : 'index';
try {
    ensure_page_name_safe($page_name);
    $page = new BookPage($page_name);
    // 线下模式不显示修改时间,因为从Github读取需要的时间太长
    $page_last_update_time = IN_PROD_MODE ? $page->getLastUpdatedAt(true, "Y-m-d H:h") : false;
    // 如果获取修改时间失败,则先暂时禁用缓存,否则无法重新获取最后修改时间
    if ($page_last_update_time === false) {
        PageCache::disable();
    }
    $view = new SimpieView($page->toHtml(), "../templates/layout/book.php", SimpieView::IS_RAW_TEXT);
    $view->render(array('title' => $page->getTitle(), 'page' => $page, 'chapt_list' => BookPage::getChapterList(), 'is_detail_view' => $page_name != 'index', 'page_last_update_time' => $page_last_update_time));
} catch (PageNotFoundException $e) {
    // 尝试查找是否是因为章节调整导致地址发生变化导致的404
    // 通过永久重定向解决搜索引擎和错误地址的问题
    if ($similar_page_name = BookPage::getMostSimilarPageFromPageName($page_name)) {
        redirect_to("/book?p=" . $similar_page_name, 301);
    }
    header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
    header("Status: 404 Not Found");
    $view = 404;
    $title = "Page Not Found";
    $view = new SimpieView("../templates/book_page_{$view}.php", "../templates/layout/book.php");
    $view->render(array('book_page' => $page_name, 'exception' => $e, 'title' => $title, 'rev' => $rev, 'exception' => $e, 'is_detail_view' => true, 'chapt_list' => $chapt_list));
}
예제 #3
0
파일: index.php 프로젝트: formatcc/tipi
<?php

require_once "lib/common.inc.php";
require_once "lib/SimpieView.php";
$view = new SimpieView("templates/index.php", "templates/layout/main.php");
$view->render(array('title' => "首页", 'have_new_version' => TIPI::haveNewVersion()));
예제 #4
0
파일: index.php 프로젝트: redautumn/tipi
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";

$view = new SimpieView('../../README.markdown', "../templates/layout/common_page.php");
$view->render(array(
	'current_page' => 'about',
	'title' => '关于',
));
예제 #5
0
파일: header.php 프로젝트: hellolwq/tipi
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/BookPage.php";
$view = new SimpieView('../templates/portable/header.php');
$view->render();
예제 #6
0
파일: index.php 프로젝트: formatcc/tipi
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/News.php";
$page_name = isset($_GET['p']) && $_GET['p'] ? $_GET['p'] : null;
try {
    ensure_page_name_safe($page_name);
    if (!$page_name) {
        $view_path = TEMPLATE_PATH . '/news/list.php';
        $params = array('news_array' => News::findAll(), 'title' => '新闻');
    } else {
        $view_path = NEWS_ROOT_PATH . "/{$page_name}." . MarkdownPage::extension;
        $news_page = new News($page_name);
        $params = array('news' => $news_page, 'title' => $news_page->getTitle() . " - 新闻");
    }
    $params = array_merge($params, array('current_page' => 'news'));
    $view = new SimpieView($view_path, "../templates/layout/common_page.php");
    $view->render($params);
} catch (PageNotFoundException $e) {
    $view = new SimpieView("../templates/book_page_404.php", "../templates/layout/book.php");
    $view->render(array('book_page' => $page_name));
}
예제 #7
0
파일: print.php 프로젝트: formatcc/tipi
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/BookPage.php";
$pages = BookPage::getFlatPagesArrayForPrint();
// 不需要index页面
array_shift($pages);
// 处理页面中的header,PDF生成工具可以根据标题级别来生成目录,将所有目录的层级缩短
$view = new SimpieView('../templates/portable/print.php');
$view->render(array('pages' => $pages));
예제 #8
0
파일: index.php 프로젝트: dollavon/tipi
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
$view = new SimpieView('../../AUTHORS', "../templates/layout/common_page.php", null, SimpieView::MARKDOWN_VIEW);
$view->render(array('current_page' => 'team', 'title' => 'TIPI团队'));
예제 #9
0
파일: index.php 프로젝트: formatcc/tipi
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
$view = new SimpieView('../../HISTORY', "../templates/layout/common_page.php", null, SimpieView::MARKDOWN_VIEW);
$view->render(array('current_page' => 'events', 'title' => 'TIPI大事记'));
예제 #10
0
파일: TipiCHM.php 프로젝트: dollavon/tipi
 public function createHome()
 {
     $filename = $this->_filepath . $this->_createFilename('ch/home');
     $view = new SimpieView('../../web/templates/chm/home.php');
     $content = $view->render(array(), TRUE);
     $fp = fopen($filename, "w");
     flock($fp, LOCK_EX);
     $this->_encodeAndwrite($fp, $content);
     // 输出内容也重新编码为GBK编码
     flock($fp, LOCK_UN);
     fclose($fp);
 }