Example #1
0
 public static function getByPublicationId($publicationId)
 {
     $CI =& get_instance();
     $CI->load->model('image_model');
     $results = $CI->image_model->getByPublicationId($publicationId);
     $return = array();
     if (!empty($results)) {
         foreach ($results as $result) {
             $return[] = CI_Image::getInstance($result);
         }
     }
     return $return;
 }
Example #2
0
 public function setImage($image)
 {
     $this->image = CI_Image::getById($image);
 }
 protected static function getInstance($row)
 {
     if (!$row instanceof stdClass) {
         show_error("El row debe ser una instancia de stdClass.");
     }
     $publication = new stdClass();
     $publication->id = isset($row->publication_id) ? $row->publication_id : 0;
     $publication->title = isset($row->title) ? $row->title : '';
     $publication->description = isset($row->description) ? $row->description : '';
     $publication->category = isset($row->category_id) ? CI_Category::getById($row->category_id) : '';
     $publication->subcategory = isset($row->subcategory_id) ? CI_Subcategory::getById($row->category_id, $row->subcategory_id) : '';
     $publication->object = isset($row->object_id) ? CI_Object::getById($row->object_id) : '';
     $publication->quantity = isset($row->quantity) ? $row->quantity : '';
     $publication->views = isset($row->views) ? $row->views : '';
     $publication->processState = isset($row->process_state_id) ? CI_ProcessState::getById($row->process_state_id) : '';
     $publication->creationDate = isset($row->creation_date) ? $row->creation_date : '';
     $publication->expirationDate = isset($row->expiration_date) ? $row->expiration_date : '';
     $publication->image = isset($row->publication_id) ? CI_Image::getByPublicationId($row->publication_id) : '';
     if (isset($row->isFavorite)) {
         $publication->isFavorite = isset($row->isFavorite) ? $row->isFavorite : '';
     }
     if (isset($row->isOwner)) {
         $publication->isOwner = isset($row->isOwner) ? $row->isOwner : '';
     }
     if (isset($row->user_id)) {
         $publication->userId = isset($row->user_id) ? $row->user_id : '';
     }
     return $publication;
 }