/**
  * Fetches content object states by conditions.
  *
  * The content object states are fetched in the right language, depending on the list of prioritized languages
  * of the site access.
  *
  * @param $conditions
  * @param $limit
  * @param $offset
  * @return array
  */
 private static function fetchByConditions($conditions, $limit, $offset)
 {
     $db = eZDB::instance();
     $defaultConditions = array('ezcobj_state.group_id=ezcobj_state_group.id', 'ezcobj_state_language.contentobject_state_id=ezcobj_state.id', eZContentLanguage::languagesSQLFilter('ezcobj_state'), eZContentLanguage::sqlFilter('ezcobj_state_language', 'ezcobj_state'));
     $conditions = array_merge($conditions, $defaultConditions);
     $conditionsSQL = implode(' AND ', $conditions);
     $sql = "SELECT ezcobj_state.*, ezcobj_state_language.* " . "FROM ezcobj_state, ezcobj_state_group, ezcobj_state_language " . "WHERE {$conditionsSQL} " . "ORDER BY ezcobj_state.priority";
     $rows = $db->arrayQuery($sql, array('limit' => $limit, 'offset' => $offset));
     $states = array();
     foreach ($rows as $row) {
         $state = new eZContentObjectState($row);
         $stateLanguage = new eZContentObjectStateLanguage($row);
         $state->setLanguageObject($stateLanguage);
         $states[] = $state;
     }
     return $states;
 }