/** * Builds order statement with a key and its value * The key can be a known string or it can be a field id, this method will create statements in consequence * * @access public * @param string $key name of statement to set * @param string $direction , the direction to give (asc or desc, default is asc) * @return void or false if an error occured */ function addOrderCondition($type, $direction = 'asc', $operator = false) { if (!$type || !in_array($direction, array('asc', 'desc'))) { return; } $value = array('direction' => $direction, 'operator' => $operator); switch ($type) { case "objectID": $this->_orderConditions['objectID'] = $value; break; if ($this->_object->isPrimaryResource()) { $this->_orderConditions['publication date after'] = $value; } break; case "publication date after": // Date start // Date start case "publication date before": case "publication date start": case "publication date end": if ($this->_object->isPrimaryResource()) { $this->_orderConditions[$type] = $value; } break; case "random": // Random ordering $this->_orderConditions['random'] = $value; break; case "relevance": // Only if ASE module exists if (class_exists('CMS_module_ase') && CMS_module_ase::isActive()) { $this->_orderConditions['relevance'] = $value; } else { $this->raiseError('Sorting by relevance is not active if module ASE does not exists ... '); return false; } break; default: if (sensitiveIO::IsPositiveInteger($type)) { $this->_orderConditions[$type] = $value; break; } $this->raiseError('Unknown type : ' . $type); return false; break; } }