/**
  * Gets the model query
  * @param joppa\content\model\ContentProperties $contentProperties
  * @param zibo\library\orm\model\Model $model
  * @param string $locale Code of the locale
  * @param string $id The id of the record to fetch
  * @return zibo\library\orm\query\ModelQuery
  */
 private function getModelQuery(ContentProperties $contentProperties, $model, $locale, $id)
 {
     $includeUnlocalizedData = $contentProperties->getIncludeUnlocalized();
     $query = $model->createQuery($contentProperties->getRecursiveDepth(), $locale, $includeUnlocalizedData);
     $modelFields = $contentProperties->getModelFields();
     if ($modelFields) {
         foreach ($modelFields as $fieldName) {
             $query->addFields('{' . $fieldName . '}');
         }
     }
     $idField = $contentProperties->getParameterId();
     $query->addCondition('{' . $idField . '} = %1%', $id);
     $condition = $contentProperties->getCondition();
     if ($condition) {
         $query->addCondition($condition);
     }
     $order = $contentProperties->getOrder();
     if ($order) {
         $query->addOrderBy($order);
     }
     return $query;
 }
 /**
  * Gets the model query
  * @param zibo\library\orm\model\Model $model
  * @param joppa\content\model\ContentProperties $contentProperties
  * @param string $locale Code of the locale
  * @param integer $page Page number
  * @return zibo\library\orm\query\ModelQuery
  */
 public function getModelQuery($model, ContentProperties $contentProperties, $locale, $page = 1)
 {
     $includeUnlocalizedData = $contentProperties->getIncludeUnlocalized();
     $query = $model->createQuery($contentProperties->getRecursiveDepth(), $locale, $includeUnlocalizedData);
     $modelFields = $contentProperties->getModelFields();
     if ($modelFields) {
         foreach ($modelFields as $fieldName) {
             $query->addFields('{' . $fieldName . '}');
         }
     }
     $condition = $contentProperties->getCondition();
     if ($condition) {
         $query->addCondition($condition);
     }
     $order = $contentProperties->getOrder();
     if ($order) {
         $query->addOrderBy($order);
     }
     if ($contentProperties->isPaginationEnabled()) {
         $paginationOffset = $contentProperties->getPaginationOffset();
         $rows = $contentProperties->getPaginationRows();
         $offset = ($page - 1) * $rows;
         if ($paginationOffset) {
             $offset += $paginationOffset;
         }
         $query->setLimit($rows, $offset);
     }
     return $query;
 }