Example #1
0
 /**
  * ページ機能用URLを取得する
  * 
  * @param array $page 固定ページデータ
  * @return string URL
  */
 public function getUrl($page)
 {
     if (isset($page['Page'])) {
         $page = $page['Page'];
     }
     if (!isset($page['url'])) {
         return '';
     }
     return $this->Page->convertViewUrl($page['url']);
 }
Example #2
0
 /**
  * 固定ページ機能で作成したページの一覧データを取得する
  *
  * @param string $categoryId 固定ページカテゴリID(初期値 : null)※ 指定しない場合は全ページを取得
  * @param array $options オプション(初期値 : array())
  *	- `conditions` : 検索条件(初期値 : array('Page.status' => 1))
  *	- `fields` : 取得フィールド(初期値 : array('title', 'url'))
  *	- `order` : 並び順(初期値 : array('Page.sort'))
  * @return mixed ページ一覧、または、false
  */
 public function getPageList($categoryId = null, $options = array())
 {
     if (empty($this->_Page)) {
         return false;
     }
     if (!is_array($options)) {
         $options = array();
     }
     $options = array_merge(array('conditions' => array('Page.status' => 1), 'fields' => array('title', 'url'), 'order' => 'Page.sort'), $options);
     if ($categoryId) {
         $options['conditions']['Page.page_category_id'] = $categoryId;
     }
     $this->_Page->unbindModel(array('belongsTo' => array('PageCategory')));
     $pages = $this->_Page->find('all', $options);
     if (empty($pages)) {
         return false;
     }
     foreach ($pages as $key => $page) {
         $pages[$key]['Page']['url'] = $this->_Page->convertViewUrl($page['Page']['url']);
     }
     return Hash::extract($pages, '{n}.Page');
 }
Example #3
0
 /**
  * 固定ページのURLを表示用のURLに変換する
  * 
  * 《変換例》
  * /mobile/index → /m/
  * 
  * @param string $url 変換対象のURL
  * @param array $expected 期待値
  * @param string $message テストが失敗した時に表示されるメッセージ
  * @dataProvider convertViewUrlDataProvider
  */
 public function testConvertViewUrl($url, $expected, $message = null)
 {
     $result = $this->Page->convertViewUrl($url);
     $this->assertEquals($expected, $result, $message);
 }