예제 #1
0
 public static function getInstance($row)
 {
     if (!$row instanceof stdClass) {
         show_error("El row debe ser una instancia de stdClass.");
     }
     $subcategory = new CI_Subcategory();
     $subcategory->id = isset($row->subcategory_id) ? $row->subcategory_id : 0;
     $subcategory->category = isset($row->category_id) ? CI_Category::getById($row->category_id) : '';
     $subcategory->description = isset($row->description) ? $row->description : '';
     $subcategory->commonState = isset($row->common_state_id) ? CI_CommonState::getById($row->common_state_id) : '';
     return $subcategory;
 }
예제 #2
0
 public static function getById($id)
 {
     $CI =& get_instance();
     $CI->load->model('category_model');
     $results = $CI->category_model->getById($id);
     $return = array();
     if (!empty($results)) {
         foreach ($results as $result) {
             $return = CI_Category::getInstance($result);
         }
     }
     return $return;
 }
예제 #3
0
 public function index_get()
 {
     $status = 404;
     $return["result"] = "NOOK";
     $categories = CI_Category::getCategories();
     if ($categories) {
         $status = 200;
         $return["result"] = "OK";
         $return["data"] = "";
         foreach ($categories as $key => $category) {
             $myCategory = CI_Category::getData($category);
             $return["data"][$key] = $myCategory;
         }
     }
     $this->response($return, $status);
 }
예제 #4
0
 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;
 }