Esempio n. 1
0
 public function findById($id)
 {
     $app = \App::getInstance();
     $conn = $app->DB_CONNECT;
     $resource = NULL;
     $query = "SELECT * FROM `resources` WHERE id=? OR autoid=?;";
     $sth = $conn->prepare($query);
     $sth->execute(array($id, $id));
     while ($row = $sth->fetch()) {
         switch ($row['type']) {
             case "person":
                 $resource = new \Archive\Port\Adaptor\Data\Archive\Persons\Person();
                 $resource->fromXmlStr($row["xmlview"]);
                 break;
             case "union":
                 $resource = new \Archive\Port\Adaptor\Data\Archive\Unions\Union();
                 $resource->fromXmlStr($row["xmlview"]);
                 break;
             case "document":
                 $resource = new \Archive\Port\Adaptor\Data\Archive\Documents\Document();
                 $resource->fromXmlStr($row["xmlview"]);
                 break;
             default:
                 $resource = new \Archive\Port\Adaptor\Data\Archive\Resources\Resource();
                 $resource->fromXmlStr($row["xmlview"]);
                 break;
         }
     }
     return $resource;
 }
Esempio n. 2
0
 public function findById($id)
 {
     $app = \App::getInstance();
     $conn = $app->DB_CONNECT;
     $person = NULL;
     $params = array($id);
     $query = "SELECT * FROM `resources` WHERE `id`=?";
     $sth = $conn->prepare($query);
     $sth->execute($params);
     while ($row = $sth->fetch()) {
         $person = new \Archive\Port\Adaptor\Data\Archive\Persons\Person();
         $person->fromXmlStr($row["xmlview"]);
     }
     return $person;
 }
Esempio n. 3
0
 public function execute()
 {
     $app = \App::getInstance();
     $persons = new \Archive\Port\Adaptor\Data\Archive\Persons();
     $conn = $app->DB_CONNECT;
     $params = array();
     $start = isset($app->QUERY['start']) ? intval($app->QUERY['start']) : 0;
     $count = isset($app->QUERY['count']) ? intval($app->QUERY['count']) : (isset($app->QUERY['search']) ? 100 : 100);
     $where = "";
     if (isset($app->QUERY['fn']) && $app->QUERY['fn'] != "") {
         $where = " AND `pk`.`fullName` LIKE :fn";
         $params[":fn"] = "%" . trim($app->QUERY['fn']) . "%";
         $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref();
         $ref->setRel("fn");
         $ref->setHref(trim($app->QUERY['fn']));
         $persons->setRef($ref);
     }
     if (isset($app->QUERY['in']) && $app->QUERY['in'] != "") {
         $where .= " AND ((`l`.`dt_start` <= :start AND `l`.`dt_start` IS NOT NULL) AND (`l`.`dt_end` >= :end AND `l`.`dt_end` IS NOT NULL))";
         $params[":start"] = trim($app->QUERY['in']);
         $params[":end"] = trim($app->QUERY['in']);
         $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref();
         $ref->setRel("in");
         $ref->setHref(trim($app->QUERY['in']));
         $persons->setRef($ref);
     }
     $query = "SELECT `r`.`xmlview`, `l`.`xmlview` AS `lxmlview` FROM `resources` AS `r` \n\t\t            LEFT JOIN `persons_keys` AS `pk` ON `pk`.`personId`=`r`.`id`\n\t\t            LEFT JOIN `links` as `l` ON `r`.`id`=`l`.`source`\n\t\t            WHERE `r`.`type`='person' {$where}\n\t\t            ORDER BY `pk`.`lastName`,`pk`.`dob` LIMIT {$start},{$count};";
     $sth = $conn->prepare($query);
     $sth->execute($params);
     while ($row = $sth->fetch()) {
         $person = new \Archive\Port\Adaptor\Data\Archive\Persons\Person();
         $person->fromXmlStr($row["xmlview"]);
         $link = new \Archive\Port\Adaptor\Data\Archive\Links\Link();
         $link->fromXmlStr($row["lxmlview"]);
         $person->setLink($link);
         $persons->setPerson($person);
     }
     $persons->setPI(str_replace($app->API_VERSION . $app->PATH_INFO, "", $_SERVER["SCRIPT_URI"]) . "/stylesheets/Archive/Persons.xsl");
     return $persons;
 }
 public function execute($id)
 {
     $app = \App::getInstance();
     $persons = new \Archive\Port\Adaptor\Data\Archive\Persons();
     $conn = $app->DB_CONNECT;
     $params = array();
     $params[":id"] = $id;
     $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref();
     $ref->setRel("destination");
     $ref->setHref($id);
     $persons->setRef($ref);
     $query = "SELECT `r`.`xmlview` AS `rxmlview`,`l`.`xmlview` AS `lxmlview` FROM `links` AS `l` \n\t\t            LEFT JOIN `resources` AS `r` ON `l`.`source`=`r`.`id`\n\t\t            WHERE `l`.`destination`=:id AND `r`.`type`='person'\n\t\t            ORDER BY `l`.`autoid`;";
     $sth = $conn->prepare($query);
     $sth->execute($params);
     while ($row = $sth->fetch()) {
         $person = new \Archive\Port\Adaptor\Data\Archive\Persons\Person();
         $person->fromXmlStr($row["rxmlview"]);
         $link = new \Archive\Port\Adaptor\Data\Archive\Links\Link();
         $link->fromXmlStr($row["lxmlview"]);
         $person->setLink($link);
         $persons->setPerson($person);
     }
     return $persons;
 }