/** * url method * * Change applied to "if (is_array($url['order'])) {" block * It trips the alias if sorting by OtherModel.field * I.e. * /index/page:1/sort:Supplier.name/direction:asc * links to * I.e. /index/page:2/sort:name/direction:asc * * @TODO ticket, test case, patch, delete * @param array $options array() * @param bool $asArray false * @param mixed $model null * @return void * @access public */ public function url($options = array(), $asArray = false, $model = null) { $paging = $this->params($model); $url = array_merge(array_filter(Set::diff(array_merge($paging['defaults'], $paging['options']), $paging['defaults'])), $options); if (isset($url['order'])) { $sort = $direction = null; if (is_array($url['order'])) { // @TODO list($sort, $direction) = array($this->sortKey($model, $url), current($url['order'])); $direction = current($url['order']); $sort = current(array_keys($url['order'])); } unset($url['order']); $url = array_merge($url, compact('sort', 'direction')); } if ($asArray) { return $url; } return parent::url($url); }
/** * Merges passed URL options with current pagination state to generate a pagination URL. * * @param array $options Pagination/URL options array * @param boolean $asArray Return the url as an array, or a URI string * @param string $model Which model to paginate on * @return mixed By default, returns a full pagination URL string for use in non-standard contexts (i.e. JavaScript) * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::url */ public function url($options = array(), $asArray = false, $model = null) { $paging = $this->params($model); $url = array_merge(array_filter($paging['options']), $options); if (isset($url['order'])) { $sort = $direction = null; if (is_array($url['order'])) { list($sort, $direction) = array($this->sortKey($model, $url), current($url['order'])); } unset($url['order']); $url = array_merge($url, compact('sort', 'direction')); } $url = $this->_convertUrlKeys($url, $paging['paramType']); if ($asArray) { return $url; } return parent::url($url); }