/** * 公開済の conditions を取得 */ public function testGetConditionAllowPublish() { $result = $this->Page->getConditionAllowPublish(); $now = date('Y-m-d H:i:s'); $expected = array('Page.status' => true, 0 => array('or' => array(array('Page.publish_begin <=' => $now), array('Page.publish_begin' => null), array('Page.publish_begin' => '0000-00-00 00:00:00'))), 1 => array('or' => array(array('Page.publish_end >=' => $now), array('Page.publish_end' => null), array('Page.publish_end' => '0000-00-00 00:00:00')))); $this->assertEquals($expected, $result, '公開済を取得するための conditions を取得できません'); }
/** * 指定した固定ページデータの次、または、前のデータを取得する * * @param array $page 固定ページデータ * @param string $type next Or prev * @param bool $overCategory カテゴリをまたがるかどうか * @return array 次、または、前の固定ページデータ */ protected function _getPageByNextOrPrev($page, $type, $overCategory = false) { switch ($type) { case 'next': $operator = '>'; $sort = 'sort'; break; case 'prev': $operator = '<'; $sort = 'sort DESC'; break; } if ($overCategory === true) { $requestAgent = Configure::read('BcRequest.agent'); if ($requestAgent) { $pageCategoryConditions = array('Page.page_category_id' => $this->_getAgentCategoryIds($requestAgent)); } else { $pageCategoryConditions = array('or' => array(array('Page.page_category_id !=' => $this->_getAllAgentCategoryIds()), array('Page.page_category_id' => null))); } } else { $pageCategoryConditions = array('Page.sort ' . $operator => $page['Page']['sort'], 'Page.page_category_id' => $page['Page']['page_category_id']); } return $this->Page->find('first', array('conditions' => array_merge(array(array('Page.sort ' . $operator => $page['Page']['sort']), $this->Page->getConditionAllowPublish(), $pageCategoryConditions)), 'fields' => array('title', 'url'), 'order' => $sort, 'recursive' => -1, 'cache' => false)); }