コード例 #1
0
 /**
  * pageActions::executePage_index()
  *
  * @param sfWebRequest $request
  * @return
  */
 public function executePage_index(sfWebRequest $request)
 {
     // リクエストされたパスを取得する。
     $path = strtolower($request->getPathInfo());
     //  並べ替えパラメータを取得する。
     $sort_key = $request->getParameter('sk', 'title');
     $sort_order = $request->getParameter('so', 'asc');
     // パスにマッチするページ一覧を取得する。
     $pages = PageTable::getListFromPath($path, $sort_key, $sort_order);
     $this->path = $path;
     $this->pages = $pages;
 }
コード例 #2
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     // リクエストされたパスを取得する。
     $path = strtolower($request->getPathInfo());
     $year = $request->getParameter('year', '');
     $month = $request->getParameter('month', '');
     $page_type = $request->getParameter('page_type', '');
     $path = str_replace(sprintf('%s/%s/', $year, $month), '', $path);
     //  並べ替えパラメータを設定する。
     $sort_key = 'first_committed';
     $sort_order = 'desc';
     // パスと条件にマッチするページ一覧を取得する。
     $pages = PageTable::getListFromPath($path, $sort_key, $sort_order, -1, true, $year, $month);
     // パスにマッチするページ一覧(全部)を取得する。
     $pages_temp = PageTable::getListFromPath($path, $sort_key, $sort_order);
     // ページの一覧から年月インデックス配列を作成する。
     $ym_index = array();
     foreach ($pages_temp as $page) {
         $ym = $page->getDateTimeObject('first_committed')->format('Ym');
         if (isset($ym_index[$ym])) {
             ++$ym_index[$ym]['count'];
         } else {
             $ym_index[$ym]['count'] = 1;
             $ym_index[$ym]['year'] = substr($ym, 0, 4);
             $ym_index[$ym]['month'] = substr($ym, -2, 2);
         }
     }
     $this->path = $path;
     $this->pages = $pages;
     $this->ym_index = $ym_index;
     switch ($page_type) {
         case 'events':
             $title = 'イベント';
             break;
         case 'news':
             $title = 'ニュース';
             break;
         case 'blog':
         default:
             $title = 'ブログ';
             break;
     }
     $this->page_type = $page_type;
     $this->page_title = $title;
 }
コード例 #3
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->news_pages = PageTable::getListFromPath('/news', 'first_committed', 'desc', 10);
     $this->events_pages = PageTable::getListFromPath('/events', 'first_committed', 'desc', 10);
     $this->blog_pages = PageTable::getListFromPath('/blog', 'first_committed', 'desc', 10);
 }
コード例 #4
0
$page2 = $page_rec[1];
$page3 = $page_rec[2];
$t->ok($page1->getTitle() === 'testtitle2' && $page2->getTitle() === 'testtitle3' && $page3->getTitle() === 'testtitle', '取得したレコードの順序(並べ替えに不正文字を指定した場合はデフォルトのdescになる))');
$page_rec = PageTable::getListFromPath('/foo', '', '', 2);
$t->is(count($page_rec), 2, '取得件数の指定');
$page_rec = PageTable::getListFromPath('/foo/', '', '', -1, false);
$t->is(count($page_rec), 3, 'サブディレクトリ除外');
$page_rec = PageTable::getListFromPath('/foo', '', '', -1, true);
$t->is(count($page_rec), 4, 'サブディレクトリ含む');
$page_rec = PageTable::getListFromPath('/foo', '', '', -1, true, '2000');
$t->is(count($page_rec), 0, '年のみ指定(該当レコードなし)');
$page_rec = PageTable::getListFromPath('/foo', '', '', -1, true, '', '05');
$t->is(count($page_rec), 0, '月のみ指定(該当レコードなし)');
$page_rec = PageTable::getListFromPath('/foo', '', '', -1, true, '2010', '05');
$t->is(count($page_rec), 4, '年月指定');
$page_rec = PageTable::getListFromPath('/foo', '', '', -1, true, '2010', '06');
$t->is(count($page_rec), 0, '年月指定');
// renderContent()
$t->diag('renderContent()');
$markdown = <<<EOF
test
====
foo bar
EOF;
$t->is(PageTable::renderContent($markdown, 'markdown'), "<h1 id=\"" . md5('test') . "\">test</h1>\n\n<p>foo bar</p>\n", 'markdownレンダリング');
$t->is(PageTable::renderContent("<h1>test</h1>\n\n<p>foo bar</p>\n", 'html'), "<h1>test</h1>\n\n<p>foo bar</p>\n", 'HTMLレンダリング');
// getRenderer()
$t->diag('getRenderer()');
$t->ok(PageTable::getRenderer('markdown') instanceof MarkdownRenderer, 'レンダラーの取得(Markdown)');
$t->ok(PageTable::getRenderer('markdown') instanceof MarkdownRenderer, 'レンダラーの取得(Markdown) 複数回実行(キャッシュのテスト)');
$t->ok(PageTable::getRenderer('html') instanceof HtmlRenderer, 'レンダラーの取得(HTML)');