diff --git a/Controller/TopicsController.php b/Controller/TopicsController.php index 49c2f4a..c4aa711 100644 --- a/Controller/TopicsController.php +++ b/Controller/TopicsController.php @@ -77,11 +77,19 @@ public function beforeFilter() { * * 速度改善の修正に伴って発生したため抑制 * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function index() { $topicFrameSetting = $this->viewVars['topicFrameSetting']; $displayType = $this->viewVars['topicFrameSetting']['display_type']; + $unitType = isset($this->params['named']['unit_type']) + ? (string)$this->params['named']['unit_type'] + : null; + if (TopicFrameSetting::UNIT_TYPE_NUMBERS === $unitType) { + $topicFrameSetting['unit_type'] = $unitType; + } + $conditions = array(); $days = isset($this->params['named']['days']) @@ -171,6 +179,17 @@ private function __getTopics($topicFrameSetting, $conditions) { ? $this->params['named']['status'] : 0; + $sort = isset($this->params['named']['order_by']) + ? (string)$this->params['named']['order_by'] + : null; + if ($sort === 'modified') { + $options['order'] = [ + $this->Topic->alias . '.modified' => 'desc', + $this->Topic->alias . '.publish_start' => 'desc', + $this->Topic->alias . '.id' => 'desc' + ]; + } + $this->Paginator->settings = array( 'Topic' => $this->Topic->getQueryOptions($status, $options), ); diff --git a/Model/Topic.php b/Model/Topic.php index 7bf3272..913c180 100644 --- a/Model/Topic.php +++ b/Model/Topic.php @@ -498,11 +498,13 @@ public function getQueryOptions($status, $options = array()) { $options['conditions'][] = $statusConditions; } + if (! isset($options['order'])) { + $options['order'] = [ + $this->alias . '.publish_start' => 'desc', $this->alias . '.id' => 'desc' + ]; + } $result = Hash::merge(array( 'recursive' => 0, - 'order' => array( - $this->alias . '.publish_start' => 'desc', $this->alias . '.id' => 'desc' - ), ), $options); return $result; diff --git a/Model/TopicUserStatus.php b/Model/TopicUserStatus.php index d546e41..588996a 100644 --- a/Model/TopicUserStatus.php +++ b/Model/TopicUserStatus.php @@ -29,6 +29,14 @@ class TopicUserStatus extends TopicsAppModel { */ public $validate = array(); +/** + * invalidateCDN cache + * DB 保存/削除時に CDN のキャッシュを invalidate するか + * + * @var bool + */ + public $invalidateCDN = false; + //The Associations below have been created with all possible keys, those that are not needed can be removed /**