/**
  * init item by ID
  */
 public function initByID($id)
 {
     UniteFunctionsUG::validateNumeric($id, "item id");
     $record = $this->db->fetchSingle(GlobalsUG::$table_items, "id={$id}");
     $this->initByDBRecord($record);
 }
 /**
  * update items category from data
  * the gallery is not inited
  */
 public function updateItemsCategoryFromData($data)
 {
     $galleryID = UniteFunctionsUG::getVal($data, "galleryID");
     if (empty($galleryID)) {
         return false;
     }
     $this->initByID($galleryID);
     $catID = UniteFunctionsUG::getVal($data, "catID");
     UniteFunctionsUG::validateNumeric($catID, "category id");
     $this->updateParam("category", $catID);
 }
 private function handleImageEffects(&$imgHandle)
 {
     if (empty($this->effect)) {
         return false;
     }
     switch ($this->effect) {
         case self::EFFECT_BW:
             if (defined("IMG_FILTER_GRAYSCALE")) {
                 imagefilter($imgHandle, IMG_FILTER_GRAYSCALE);
             }
             break;
         case self::EFFECT_BRIGHTNESS:
             if (defined("IMG_FILTER_BRIGHTNESS")) {
                 if (!is_numeric($this->effect_arg1)) {
                     $this->effect_arg1 = 50;
                 }
                 //set default value
                 UniteFunctionsUG::validateNumeric($this->effect_arg1, "'ea1' argument");
                 imagefilter($imgHandle, IMG_FILTER_BRIGHTNESS, $this->effect_arg1);
             }
             break;
         case self::EFFECT_DARK:
             if (defined("IMG_FILTER_BRIGHTNESS")) {
                 if (!is_numeric($this->effect_arg1)) {
                     $this->effect_arg1 = -50;
                 }
                 //set default value
                 UniteFunctionsUG::validateNumeric($this->effect_arg1, "'ea1' argument");
                 imagefilter($imgHandle, IMG_FILTER_BRIGHTNESS, $this->effect_arg1);
             }
             break;
         case self::EFFECT_CONTRAST:
             if (defined("IMG_FILTER_CONTRAST")) {
                 if (!is_numeric($this->effect_arg1)) {
                     $this->effect_arg1 = -5;
                 }
                 //set default value
                 imagefilter($imgHandle, IMG_FILTER_CONTRAST, $this->effect_arg1);
             }
             break;
         case self::EFFECT_EDGE:
             if (defined("IMG_FILTER_EDGEDETECT")) {
                 imagefilter($imgHandle, IMG_FILTER_EDGEDETECT);
             }
             break;
         case self::EFFECT_EMBOSS:
             if (defined("IMG_FILTER_EMBOSS")) {
                 imagefilter($imgHandle, IMG_FILTER_EMBOSS);
             }
             break;
         case self::EFFECT_BLUR:
             $this->effect_Blur($imgHandle, 5);
             /*
             if(defined("IMG_FILTER_GAUSSIAN_BLUR"))
             	imagefilter($imgHandle,IMG_FILTER_GAUSSIAN_BLUR);
             */
             break;
         case self::EFFECT_MEAN:
             if (defined("IMG_FILTER_MEAN_REMOVAL")) {
                 imagefilter($imgHandle, IMG_FILTER_MEAN_REMOVAL);
             }
             break;
         case self::EFFECT_SMOOTH:
             if (defined("IMG_FILTER_SMOOTH")) {
                 if (!is_numeric($this->effect_arg1)) {
                     $this->effect_arg1 = 15;
                 }
                 //set default value
                 imagefilter($imgHandle, IMG_FILTER_SMOOTH, $this->effect_arg1);
             }
             break;
         case self::EFFECT_BLUR3:
             $this->effect_Blur($imgHandle, 5);
             break;
         default:
             $this->throwError("Effect not supported: <b>" . $this->effect . "</b>");
             break;
     }
 }
 /**
  * get gallery by id
  */
 private function getGalleryByID($galleryID)
 {
     UniteFunctionsUG::validateNotEmpty($galleryID, "gallery id");
     UniteFunctionsUG::validateNumeric($galleryID);
     $gallery = new UniteGalleryGallery();
     $gallery->initByID($galleryID);
     return $gallery;
 }
 /**
  * 
  * get category items html
  */
 public function getCatItemsHtmlFromData($data)
 {
     $catID = UniteFunctionsUG::getVal($data, "catID");
     UniteFunctionsUG::validateNumeric($catID, "category id");
     $itemsHtml = $this->getCatItemsHtml($catID);
     $response = array("itemsHtml" => $itemsHtml);
     return $response;
 }
 /**
  * 
  * get category
  */
 public function getCat($catID)
 {
     UniteFunctionsUG::validateNumeric($catID, "category id");
     $catID = (int) $catID;
     $arrCat = $this->db->fetchSingle(GlobalsUG::$table_categories, "id={$catID}");
     if (empty($arrCat)) {
         UniteFunctionsUG::throwError("Category with id: {$catID} not found");
     }
     return $arrCat;
 }