function aggiungi_immagine()
 {
     $id_prodotto_servizio = Params::get("id_prodotto_servizio");
     if (Params::is_set("file_field_name")) {
         $file_field_name = Params::get("file_field_name");
     } else {
         $file_field_name = "file";
     }
     if (Upload::isUploadSuccessful($file_field_name)) {
         $product_dir = new Dir(self::PRODUCT_IMAGE_DIR . "/" . $id_prodotto_servizio);
         $product_dir->touch();
         $uploaded_img = Upload::saveTo($file_field_name, $product_dir);
         if (isset(Config::instance()->PRODUCT_IMAGE_RESIZE_BY_WIDTH)) {
             image_w($uploaded_img->getPath(), Config::instance()->PRODUCT_IMAGE_RESIZE_BY_WIDTH);
         } else {
             if (isset(Config::instance()->PRODUCT_IMAGE_RESIZE_BY_HEIGHT)) {
                 image_h($uploaded_img->getPath(), Config::instance()->PRODUCT_IMAGE_RESIZE_BY_HEIGHT);
             }
         }
         //creo una riga associata all'immagine
         $immagine_prodotto_servizio_peer = new ImmagineProdottoServizioPeer();
         $do = $immagine_prodotto_servizio_peer->new_do();
         $do->id_prodotto_servizio = Params::get("id_prodotto_servizio");
         $do->nome_immagine = $uploaded_img->getFilename();
         $immagine_prodotto_servizio_peer->save($do);
         return Redirect::success();
     } else {
         Flash::error(Upload::getUploadError($file_field_name));
         return Redirect::failure();
     }
 }
Exemplo n.º 2
0
 function testParamsNotset()
 {
     $_POST["__not_set_hello"] = 5;
     Params::clear();
     Params::importFromPost();
     $this->assertTrue(Params::is_set("hello"), "Il parametro hello non e' stato caricato!!");
     $this->assertEqual(Params::get("hello"), "5", "Il parametro hello non e' stato caricato!!");
     unset($_POST["__not_set_hello"]);
 }
Exemplo n.º 3
0
 public function get_vetrina()
 {
     $peer = new VetrinaPeer();
     if (Params::is_set("id_vetrina")) {
         $do = $peer->find_by_id(Params::get("id_vetrina"));
     } else {
         $peer->nome_vetrina__EQUAL(Params::get("nome_vetrina"));
         $do_list = $peer->find();
         $do = $do_list[0];
     }
     return ActiveRecordUtils::toArray($do);
 }
Exemplo n.º 4
0
 function get()
 {
     $peer = new TestiPeer();
     if (Params::is_set("id")) {
         $do = $peer->find_by_id(Params::get("id"));
     } else {
         ActiveRecordUtils::updateFilters($peer);
         $results = $peer->find();
         if (count($results) > 0) {
             $do = $results[0];
         } else {
             $do = null;
         }
     }
     return ActiveRecordUtils::toArray($do);
 }
Exemplo n.º 5
0
 function get()
 {
     $peer = new FolderPeer();
     if (Params::is_set("id")) {
         $result = ActiveRecordUtils::toArray($peer->find_by_id(Params::get("id")));
         return self::load_attributes($result);
     } else {
         ActiveRecordUtils::updateFilters($peer);
         $results = $peer->find();
         if (count($results) == 0) {
             return null;
         } else {
             return self::load_attributes(ActiveRecordUtils::toArray($results[0]));
         }
     }
 }
 function get()
 {
     $peer = $this->__myPeer();
     if ($this->__dump_enabled()) {
         $peer->__dump_sql();
     }
     $pk_fields = $peer->__getPrimaryKeyFields();
     if (Params::is_set($pk_fields[0])) {
         $do = $peer->find_by_id(Params::get($pk_fields[0]));
     } else {
         ActiveRecordUtils::updateFilters($peer);
         $results = $peer->find();
         if (count($results) > 0) {
             $do = $results[0];
         } else {
             $do = null;
         }
     }
     return ActiveRecordUtils::toArray($do);
 }
Exemplo n.º 7
0
 public static function updatePageFilters($peer)
 {
     if (Params::is_set(self::PAGE_SIZE_KEY) && Params::get(self::PAGE_SIZE_KEY) != "" && Params::is_set(self::PAGE_NUM_KEY) && Params::get(self::PAGE_NUM_KEY) != "") {
         $page_size = Params::get(self::PAGE_SIZE_KEY);
         $page_num = Params::get(self::PAGE_NUM_KEY);
         $peer->__PAGE($page_num, $page_size);
     }
 }
Exemplo n.º 8
0
 function accept()
 {
     $accepted = Params::get("accept");
     $nome_parametro = Params::is_set("nome_parametro") ? Params::get("nome_parametro") : "[IMPOSTA IL NOME DELLA CHECKBOX OBBLIGATORIA]";
     if ($accepted !== "accept") {
         return Result::error("È necessario accettare " . $nome_parametro . ".");
     }
     return Result::ok();
 }
Exemplo n.º 9
0
 public function setupByParams($do)
 {
     $fields = $this->__getAllFields();
     $pk_fields = $this->__getPrimaryKeyFields();
     $params_list = array();
     //tolgo le chiavi primarie
     foreach (ArrayUtils::delete_keys($fields, $pk_fields) as $fkey => $attribs) {
         if (Params::is_set($fkey)) {
             $params_list[$fkey] = Params::get($fkey);
         }
     }
     foreach (Params::keys() as $k) {
         if (StringUtils::starts_with($k, self::CHECK_PREFIX)) {
             $field_to_check = substr($k, strlen(self::CHECK_PREFIX));
             if (Params::is_set($field_to_check)) {
                 $params_list[$field_to_check] = true;
             } else {
                 $params_list[$field_to_check] = false;
             }
         }
     }
     return $this->setupWithMap($do, $params_list);
 }
Exemplo n.º 10
0
 static function check_login()
 {
     return Params::is_set("code") && Params::get("code") == "frzadmin";
 }
Exemplo n.º 11
0
 function get_gallery()
 {
     if (Params::is_set("id_gallery")) {
         $id_gallery = Params::get("id_gallery");
         $peer = new GalleryPeer();
         $gallery = $peer->find_by_id($id_gallery);
     } else {
         $gallery_name = Params::get("gallery_name");
         $tokens = preg_split("/\\//", $gallery_name);
         $collection_key = $tokens[0];
         $gallery_key = $tokens[1];
         $collection = call("gallery_collection", "get_collection_by_key", array("key" => $collection_key));
         $peer = new GalleryPeer();
         $peer->id_gallery_collection__EQUAL($collection["id_gallery_collection"]);
         $peer->key__EQUAL($gallery_key);
         $gallery = $peer->find_single_result();
     }
     $collection_peer = new GalleryCollectionPeer();
     $gallery_collection = $collection_peer->find_by_id($gallery->id_gallery_collection);
     $folder_path = GalleryCollectionController::GALLERY_COLLECTION_ROOT_DIR . $gallery_collection->folder . "/" . $gallery->folder;
     $gallery_data = ActiveRecordUtils::toArray($gallery);
     $image_list = call("gallery_image", "index", array("__filter_id_gallery__EQUAL" => $gallery_data["id_gallery"]));
     foreach ($image_list as $k => &$img) {
         $img["path"] = $folder_path . "/" . $img["image_name"];
     }
     $gallery_data["image_list"] = $image_list;
     $gallery_data["gallery_name"] = $gallery_collection->key . "/" . $gallery->key;
     $gallery_data["id_collection"] = $gallery->id_gallery_collection;
     return $gallery_data;
 }