/** * * @param PersistentObject $targetObject * @param string $targetMethod * @param string $targetMethodParameters * @param string $bps * @param string $target window or tab * * @return string */ public static function window($targetObject, $targetMethod, $targetMethodParameters = "", $bps = null, $target = null) { $useID = "-1"; if (!$targetObject instanceof Collection) { $useID = $targetObject->getID() == "" ? "-1" : $targetObject->getID(); } if (!is_numeric($useID)) { $useID = "'{$useID}'"; } return "windowWithRme('" . str_replace("GUI", "", get_class($targetObject)) . "', {$useID}, '{$targetMethod}', " . (is_array($targetMethodParameters) ? "['" . implode("','", $targetMethodParameters) . "']" : "'{$targetMethodParameters}'") . ($bps != null ? ", '{$bps}'" : "") . ($target != null ? ", '{$target}'" : "") . "); "; }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_i005_recipiente"); $this->addAttribute("material", Datatypes::TEXT); $this->addAttribute("capacidad", Datatypes::FLOAT_NUMBER); $this->addAttribute("tieneTapa", Datatypes::BOOLEAN); $this->addConstraints("material", array(Constraint::maxLength(30), Constraint::blank(false))); $this->addConstraints("capacidad", array(Constraint::between(0.0, 10.0))); $this->addConstraints("tieneTapa", array(Constraint::nullable(true))); /* $this->constraints = array ( "material" => array ( Constraint :: maxLength(30), Constraint :: blank(false) ), "capacidad" => array ( Constraint :: between(0.0, 10.0) ), "tieneTapa" => array ( Constraint :: nullable(true) ) ); */ parent::__construct($args, $isSimpleInstance); }
function Comment($fields, $referenced = false) { parent::PersistentObject($fields, $referenced); if (!$this->date) { $this->update(array("date" => time())); } }
function deleteMe() { if ($this->A("phimFromUserID") != Session::currentUser()->getID()) { Red::errorD("Sie können nur eigene Nachrichten löschen!"); } parent::deleteMe(); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_003_entidad"); // BUG #19 $this->addAttribute("tipo", Datatypes::TEXT); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable('test_issue37_bbb'); $this->belongsTo = array('AAA'); $this->addAttribute('attrBBB', Datatypes::TEXT); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_002_nariz"); $this->belongsTo = array('Cara'); $this->addAttribute("tamanio", Datatypes::TEXT); $this->addConstraints("tamanio", array(Constraint::inList(array("chica", "mediana", "grande")))); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable('test_002_cara'); $this->addAttribute('color', Datatypes::TEXT); $this->addHasOne('nariz', 'Nariz'); $this->addConstraints('color', array(Constraint::inList(array('blanco', 'negro', 'pardo')), Constraint::nullable(true))); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_m003_dedo"); $this->belongsTo = array('Mano'); $this->addHasOne('mano', 'Mano'); $this->addAttribute("uniaLarga", Datatypes::BOOLEAN); parent::__construct($args, $isSimpleInstance); }
function deleteMe() { $AC = anyC::get("Navigation", "parentID", $this->getID()); while ($N = $AC->getNextEntry()) { $N->deleteMe(); } parent::deleteMe(); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable('test_hmb_aclass'); $this->addAttribute('attrAClass', Datatypes::TEXT); $this->addHasMany('rolb1', 'BClass', self::HASMANY_COLLECTION, 'rel1'); $this->addHasMany('rolb2', 'BClass', self::HASMANY_COLLECTION, 'rel2'); parent::__construct($args, $isSimpleInstance); }
public function saveMe($checkUserData = true, $output = false) { if ($this->A("SystemType") == "ip") { $data = "\nhostname\nclientid\npersistent\noption rapid_commit\n\noption domain_name_servers, domain_name, domain_search, host_name\noption classless_static_routes\noption ntp_servers\nrequire dhcp_server_identifier\n\nslaac private\n\nnohook lookup-hostname\n\ninterface eth0\nstatic ip_address=" . $this->A("SystemSetting1") . "/24\nstatic routers=" . $this->A("SystemSetting3") . "\nstatic domain_name_servers=" . $this->A("SystemSetting4") . "\n"; echo shell_exec("echo '{$data}' | sudo tee /etc/dhcpcd.conf 2>&1"); } parent::saveMe($checkUserData, $output); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable('test_dirty_bit_class1'); $this->addAttribute('attr11', Datatypes::TEXT); $this->addAttribute('attr12', Datatypes::DATE); $this->addAttribute('attr13', Datatypes::INT_NUMBER); $this->addHasOne('class2', 'Class2'); parent::__construct($args, $isSimpleInstance); }
/** * Instancia Model e opcionalmente inicializa atributos com $data. * @param mixed $data */ public function __construct($data = NULL) { parent::__construct(); $this->_className = get_class($this); $p = strrpos($this->_className, '\\'); $this->_namespace = substr($this->_className, 0, $p); $this->_map = $this->ORMMap(); $this->onCreate($data); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_m003_mano"); $this->addHasMany('dedos', 'Dedo'); // La unica diferencia con respecto al test i005 $this->addAttribute("tamanio", Datatypes::TEXT); $this->addConstraints("tamanio", array(Constraint::inList(array("grande", "mediana", "chica")))); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("hello_world_persona"); $this->addAttribute("nombre", Datatypes::TEXT); $this->addAttribute("edad", Datatypes::INT_NUMBER); $this->addConstraints("nombre", array(Constraint::maxLength(30), Constraint::blank(false))); $this->addConstraints("edad", array(Constraint::between(10, 100))); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable('test_dirty_bit_class3'); $this->belongsTo = array('Class2'); $this->addAttribute('attr31', Datatypes::TEXT); $this->addAttribute('attr32', Datatypes::DATE); $this->addAttribute('attr33', Datatypes::INT_NUMBER); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_m010_persona"); $this->addAttribute("nombre", Datatypes::TEXT); // Los hijos de la persona $this->addHasMany("hijos", "M010_Persona"); $this->belongsTo = array('M010_Persona'); parent::__construct($args, $isSimpleInstance); }
function loadAdapter() { parent::loadAdapter(); if (is_file($this->folder . "Installation.pfdb.php")) { $this->Adapter->setDBFolder($this->folder); } else { $this->Adapter->setDBFolder("." . $this->folder); } }
function delete($del = true) { parent::delete(); if ($del) { unlink($this->fullPath()); if ($this->thumbnail) { unlink($this->baseDir . $this->thumbnail); } } }
function saveMe($checkUserData = true, $output = false) { $AC = anyC::get("poolSteuerung", "poolSteuerungTyp", $this->A("poolSteuerungTyp")); $AC->addAssocV3("poolSteuerungID", "!=", $this->getID()); $S = $AC->n(); if ($S !== null) { Red::errorD("Jeder Steuerungstyp darf maximal einmal angelegt werden."); } return parent::saveMe($checkUserData, $output); }
function saveMe($checkUserData = true, $output = false) { $O = new Einkaufszettel($this->getID()); if ($O->A("EinkaufszettelBought") == "0" and $this->A("EinkaufszettelBought") == "1") { $this->changeA("EinkaufszettelBoughtTime", $this->hasParsers ? Util::CLDateTimeParser(time()) : time()); } if ($O->A("EinkaufszettelBought") == "1" and $this->A("EinkaufszettelBought") == "0") { $this->changeA("EinkaufszettelBoughtTime", ""); } parent::saveMe($checkUserData, $output); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_001_botella"); $this->addAttribute("material", Datatypes::TEXT); $this->addAttribute("capacidad", Datatypes::FLOAT_NUMBER); $this->addAttribute("tapaRosca", Datatypes::BOOLEAN); $this->addConstraints("material", array(Constraint::maxLength(30), Constraint::blank(false))); $this->addConstraints("capacidad", array(Constraint::between(0.0, 10.0))); $this->addConstraints("tapaRosca", array(Constraint::nullable(true))); parent::__construct($args, $isSimpleInstance); }
/** * Metodo auxiliar para cargar los objetos asociados en cascada, tanto los hasOne como los hasMany, * verificando previamente si no fueron ya cargados. * @param PersistentObject $obj el objeto al que hay que cargarle los objetos asociados. */ private function getCascadeAssocs($obj) { // Para saber si estaba limpia previamente, para poder limpiar lo que esta operacion ensucia (dirty bits) $wasClean = $obj->isClean(); // TODO: Verificar si para los objetos en hasOne, sus asociaciones son cargadas en cascada. // Para cada objeto hasOne, lo trae. // Para el objeto hago get para hasOne y getMany para los hasMany. $ho_attrs = $obj->getHasOne(); foreach ($ho_attrs as $attr => $assoc_class) { // attr = "email_id" ? $ho_instance = new $assoc_class(); $hasOneAttr = DatabaseNormalization::getSimpleAssocName($attr); // email $assoc_id = $ho_instance->aGet($attr); $assoc_obj = NULL; if (ArtifactHolder::getInstance()->existsModel($assoc_class, $assoc_id)) { $assoc_obj = ArtifactHolder::getInstance()->getModel($assoc_class, $assoc_id); } else { $assoc_obj = $this->get($assoc_class, $assoc_id); ArtifactHolder::getInstance()->addModel($assoc_obj); } //$obj->{"set".$attr}( $assoc_obj ); $obj->aSet($attr, $assoc_obj); } // Para cada objeto hasMany, lo trae // Para el objeto hago get para hasOne y getMany para los hasMany. $hm_attrs = $obj->getHasMany(); foreach ($hm_attrs as $attr => $class) { $this->getMany($obj, $attr); // Carga los elementos del atributo en la clase. } // TODO: si carga en cascada, entonces la instancia de obj y sus clases asociadas // se cargan todas en el mismo momento, por lo que no habria nada sucio, // y seria innecesario verificar si estaba sucia antes de la carga. // Solo limpia si la clase estaba limpia antes de la operacion if ($wasClean) { $obj->resetDirty(); } // Apaga las banderas que se prendieron en la carga }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable("test_a004_pagina"); $this->addAttribute("titulo", Datatypes::TEXT); $this->addAttribute("contenido", Datatypes::TEXT); // Pagina padre $this->addHasOne('owner', 'Pagina'); // Paginas hijas $this->addHasMany('subpages', 'Pagina'); $this->addConstraints("titulo", array(Constraint::maxLength(255))); $this->addConstraints("contenido", array(Constraint::maxLength(100000))); $this->addConstraints("owner", array(Constraint::nullable(true))); parent::__construct($args, $isSimpleInstance); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable(self::TABLE); // message data $this->addAttribute('text', Datatypes::TEXT); $this->addAttribute('createdOn', Datatypes::DATETIME); // associations $this->addHasOne('createdBy', 'TUser'); // the user that creates this twitter message // default values $this->setCreatedOn(date("Y-m-d H:i:s")); // Ya con formato de MySQL! // constraints $this->addConstraints('text', array(Constraint::maxLength(160), Constraint::nullable(false), Constraint::blank(false))); parent::__construct($args, $isSimpleInstance); }
/** * Nombre de la tabla que almacena informacion sobre la relacion entre 2 instancias de PO. * El nombre de la tabla de la relacion es el nombre derivado de la instancia1 concatenado * al nombre del atributo que apunta a la instancia 2, concatenado al nombre derivador de * la instancia 2. * @param PersistentObject $ins1 Instancia duenia de la asociacion. * @param String Atributo de $ins1 que apunta a $ins2. * @param PersistentObject $ins2 Instancia hija en la asociacion. */ public static function relTableName(PersistentObject $ins1, $inst1Attr, PersistentObject $ins2) { // Problema: si el atributo pertenece a C1, y $ins1 es instancia de G1, // la tabla que se genera para hasMany a UnaClase es "gs_unaclase_" // y deberia ser "cs_unaclase_", esto es un problema porque si cargo // una instancia de C1 no tiene acceso a sus hasMany "UnaClase". // TODO: esta es una solucion rapida al problema, hay que mejorarla. // Esta solucion intenta buscar cual es la clase en la que se declara el atributo hasMany // para el que se quiere generar la tabla intermedia de referencias, si no la encuentra, // es que el atributo hasMany se declaro en $ins1. // Tambien hay un problema cuando hay composite> // Si ins1->hasMany[ins1Attr] es a una superclase de ins2, genera mal el nombre de la tabla de join. // El nombre se tiene que generar a la clase para la que se declara le hasMany, // no para el nombre de tabla de ins2 (porque ins2 puede guardarse en otra tabla // que no sea la que se guarda su superclase a la cual fue declarado el hasMany // ins1->hasMany[inst1Attr]). // Solucion: ver si la clase a la que se declara el hasMany no es la clase de ins2, // y verificar si ins2 se guarda en otra tabla que la clase a la que se // declara el hasMany en ins1. Si es distinta, el nombre debe apuntar al // de la clase declarada en el hasMany. (aunque en ambos casos es a esto, // asi que no es necesario verificar). $classes = ModelUtils::getAllAncestorsOf($ins1->getClass()); //Logger::struct( $classes, "Superclases de " . $ins1->getClass() ); $instConElAtributoHasMany = $ins1; // En ppio pienso que la instancia es la que tiene el atributo masMany. foreach ($classes as $aclass) { $ins = new $aclass(NULL, true); //if ( $ins->hasManyOfThis( $ins2->getClass() ) ) // la clase no es la que tenga el atributo, debe ser en la que se declara el atributo if ($ins->attributeDeclaredOnThisClass($inst1Attr)) { //Logger::getInstance()->log("TIENE MANY DE " . $ins2->getClass()); $instConElAtributoHasMany = $ins; break; } //Logger::struct( $ins, "Instancia de $aclass" ); } $tableName1 = self::tableName($instConElAtributoHasMany); //echo "=== " . $ins1->getAttributeType( $inst1Attr ) . " ==== <br/>"; // La tabla de join considera la tabla en la que se guardan las instancias del tipo // declarado en el hasMany, NO A LOS DE SUS SUBCLASES!!! (como podia ser ins2) $tableName2 = self::tableName($ins1->getAttributeType($inst1Attr)); // $tableName2 = self::tableName( $ins2 ); // TODO: Normalizar $inst1Attr ? // echo "Nombre tabla relTableName: ". $tableName1 . "_" . $inst1Attr . "_" . $tableName2 ."<br/>"; return $tableName1 . "_" . $inst1Attr . "_" . $tableName2; // owner_child }
/** * This method stores a persistent object in the database * * @param integer $userId * @param string $name * @param array $value */ public static function set($userId, $name, $value) { $lVar = self::retrieveByUserIdAndName($name, $userId); if (!$lVar) { $lVar = new PersistentObject(); } $lVar->setName($name); $lVar->setUserId($userId); $lVar->setValue(serialize($value)); $lVar->save(); return $lVar; }
function saveMe($checkUserData = true, $output = false) { if ($this->A("ContentImage") != "") { $path = Util::getRootPath() . "specifics/" . $this->A("ContentImage"); $image = new Imagick($path); $imageSmall = Util::getRootPath() . "specifics/" . str_replace(basename($this->A("ContentImage")), "small/" . basename($this->A("ContentImage")), $this->A("ContentImage")); $imageBig = Util::getRootPath() . "specifics/" . str_replace(basename($this->A("ContentImage")), "big/" . basename($this->A("ContentImage")), $this->A("ContentImage")); $image->resizeImage(0, 550, Imagick::FILTER_LANCZOS, 1); if (!$image->writeImage($imageBig)) { Red::alertD("Das große Vorschaubild kann nicht erstellt werden!"); } $image->resizeImage(150, 0, Imagick::FILTER_LANCZOS, 1); if (!$image->writeImage($imageSmall)) { Red::alertD("Das kleine Vorschaubild kann nicht erstellt werden!"); } $image->destroy(); } parent::saveMe($checkUserData, $output); }
function __construct($args = array(), $isSimpleInstance = false) { $this->setWithTable(self::TABLE); // user data $this->addAttribute('name', Datatypes::TEXT); $this->addAttribute('email', Datatypes::TEXT); // auth $this->addAttribute('username', Datatypes::TEXT); $this->addAttribute('password', Datatypes::TEXT); // associations $this->addHasMany('following', 'TUser', PersistentObject::HASMANY_SET); // users I follow, is a set // constraints $this->addConstraints('name', array(Constraint::minLength(1), Constraint::maxLength(255), Constraint::nullable(false), Constraint::blank(false))); $this->addConstraints('username', array(Constraint::blank(false))); $this->addConstraints('password', array(Constraint::minLength(4))); $this->addConstraints('email', array(Constraint::email())); parent::__construct($args, $isSimpleInstance); }