示例#1
0
 public static function normalize_data($value)
 {
     if ($value instanceof AbstractDO) {
         return ActiveRecordUtils::toArray($value);
     }
     return $value;
 }
 function elenco_prodotti_servizi_vetrina()
 {
     $peer = new ProdottoServizioVetrinaPeer();
     $peer->id_vetrina__EQUAL(Params::get("id_vetrina"));
     $elenco_prodotti_servizi = $peer->find();
     return ActiveRecordUtils::toArray($elenco_prodotti_servizi);
 }
 function apply($peer, $object)
 {
     $type = $object[$this->entity_type_field_name];
     $id = $object[$this->entity_id_field_name];
     $decoration_peer = __create_instance(StringUtils::underscored_to_camel_case($type . "_peer"));
     $decoration = ActiveRecordUtils::toArray($decoration_peer->find_by_id($id));
     $object[$this->entity_type_field_name] = $decoration;
     return array($peer, $object);
 }
 function index_immagini()
 {
     $peer = new ImmagineProdottoServizioPeer();
     ActiveRecordUtils::updateFilters($peer);
     $elenco_immagini_prodotti_servizi = $peer->find();
     $data = ActiveRecordUtils::toArray($elenco_immagini_prodotti_servizi);
     if (is_html()) {
         $data[Block::MARKER_KEY] = "vetrine/prodotti_servizi/select_immagine_prodotto_servizio";
     }
     return $data;
 }
 function by_chiave()
 {
     $chiave = Params::get("chiave");
     $peer = $this->__myPeer();
     $peer->chiave__EQUAL($chiave);
     $results = $peer->find();
     if (count($results) > 0) {
         $do = $results[0];
     } else {
         $do = null;
     }
     return ActiveRecordUtils::toArray($do);
 }
 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);
 }
 function get_image()
 {
     $peer = new GalleryImagePeer();
     $gallery_image = $peer->find_by_id(Params::get("id_gallery_image"));
     return ActiveRecordUtils::toArray($gallery_image);
 }
示例#8
0
 function new_empty()
 {
     $peer = new TestiPeer();
     return ActiveRecordUtils::toArray($peer->new_do());
 }
 function index()
 {
     $peer = new DocumentiPeer();
     ActiveRecordUtils::updateFilters($peer);
     return ActiveRecordUtils::toArray($peer->find());
 }
示例#10
0
 function create_root()
 {
     $peer = new FolderPeer();
     $do = $peer->new_do();
     $peer->setupByParams($do);
     $do->id_parent_folder = null;
     $peer->save($do);
     if (is_html()) {
         return Result::ok();
     } else {
         return ActiveRecordUtils::toArray($do);
     }
 }
 function get_banner()
 {
     $peer = new BannerPeer();
     $banner = $peer->find_by_id(Params::get("id_banner"));
     return ActiveRecordUtils::toArray($banner);
 }
示例#12
0
 function create_root()
 {
     $peer = new FolderPeer();
     $do = $peer->new_do();
     $peer->setupByParams($do);
     $do->path = "";
     $do->nome = "";
     $do->ordine = 1;
     $do->level = 0;
     $peer->save($do);
     if (is_html()) {
         return Result::ok();
     } else {
         return ActiveRecordUtils::toArray($do);
     }
 }
示例#13
0
 public function testToDO()
 {
     $test_data = array();
     $ar1 = array();
     $ar1[AbstractDO::CLASS_FIELD_KEY] = "Simple3";
     $ar1["id"] = 3;
     $ar1["nome"] = "Ciao";
     $ar1["livello"] = 14;
     $test_data[] = $ar1;
     $ar2 = array();
     $ar2[AbstractDO::CLASS_FIELD_KEY] = "Simple3";
     $ar2["id"] = 4;
     $ar2["nome"] = "Hello";
     $ar2["livello"] = 12;
     $test_data[] = $ar2;
     $do_array = ActiveRecordUtils::toDO($test_data);
     $this->assertEqual(count($do_array), count($test_data), "Il numero dei dati non coincide!!");
     $do1 = $do_array[0];
     $this->assertTrue($do1 instanceof Simple3DO, "La classe del DO non corrisponde!!");
     $this->assertEqual($do1->id, 3, "L'id dell'entita' non corrisponde!!");
     $this->assertEqual($do1->nome, "Ciao", "Il nome dell'entita' non corrisponde!!");
     $this->assertEqual($do1->livello, 14, "Il livello dell'entita' non corrisponde!!");
     $do2 = $do_array[1];
     $this->assertTrue($do2 instanceof Simple3DO, "La classe del DO non corrisponde!!");
     $this->assertEqual($do2->id, 4, "L'id dell'entita' non corrisponde!!");
     $this->assertEqual($do2->nome, "Hello", "Il nome dell'entita' non corrisponde!!");
     $this->assertEqual($do2->livello, 12, "Il livello dell'entita' non corrisponde!!");
 }
 function get_collection()
 {
     $peer = new GalleryCollectionPeer();
     $collection = $peer->find_by_id(Params::get("id_gallery_collection"));
     return ActiveRecordUtils::toArray($collection);
 }
示例#15
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;
 }