public function execute() { $app = \App::getInstance(); $unions = new \Archive\Port\Adaptor\Data\Archive\Unions(); $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['type']) && $app->QUERY['type'] != "") { $where = " AND `uk`.`type` = :type"; $params[":type"] = trim($app->QUERY['type']); $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("type"); $ref->setHref(trim($app->QUERY['type'])); $unions->setRef($ref); } $query = "SELECT `r`.`xmlview` FROM `resources` AS `r` \n\t\t LEFT JOIN `unions_keys` AS `uk` ON `uk`.`unionId`=`r`.`id`\n\t\t WHERE `r`.`type`='union' {$where}\n\t\t ORDER BY `uk`.`name` LIMIT {$start},{$count};"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $union = new \Archive\Port\Adaptor\Data\Archive\Unions\Union(); $union->fromXmlStr($row["xmlview"]); $unions->setUnion($union); } //$unions->setPI(str_replace($app->API_VERSION.$app->PATH_INFO,"",$_SERVER["SCRIPT_URI"])."/stylesheets/Archive/Unions.xsl"); return $unions; }
public function execute() { $app = \App::getInstance(); $conn = $app->DB_CONNECT; $evs = new \Archive\Port\Adaptor\Data\Archive\Events(); $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['type']) && $app->QUERY['type'] != "") { $where = " AND `ek`.`type`= :type"; $id = trim($app->QUERY['id']); $params[":type"] = $type; $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("type"); $ref->setHref($id); $evs->setRef($ref); } $query = "SELECT `r`.`autoid`,`r`.`xmlview` FROM `resources` AS `r` \n\t\t LEFT JOIN `events_keys` AS `ek` ON `ek`.`eventId`=`r`.`id`\n\t\t WHERE `r`.`type`='event' {$where}\n\t\t ORDER BY `ek`.`dt` LIMIT {$start},{$count};"; $sth = $conn->prepare($query); $sth->execute(array()); while ($row = $sth->fetch()) { $ev = new \Archive\Port\Adaptor\Data\Archive\Events\Event(); $ev->fromXmlStr($row["xmlview"]); $evs->setEvent($ev); } $evs->setPI(str_replace($app->API_VERSION . $app->PATH_INFO, "", $_SERVER["SCRIPT_URI"]) . "/stylesheets/Archive/Timeline.xsl"); return $evs; }
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(); $unions = new \Archive\Port\Adaptor\Data\Archive\Unions(); $conn = $app->DB_CONNECT; $params = array(); $params[":id"] = $id; $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("destination"); $ref->setHref($id); $unions->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`='union'\n\t\t ORDER BY `l`.`autoid`;"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $union = new \Archive\Port\Adaptor\Data\Archive\Unions\Union(); $union->fromXmlStr($row["rxmlview"]); $link = new \Archive\Port\Adaptor\Data\Archive\Links\Link(); $link->fromXmlStr($row["lxmlview"]); $union->setLink($link); $unions->setUnion($union); } return $unions; }
public function execute($id) { $app = \App::getInstance(); $docs = new \Archive\Port\Adaptor\Data\Archive\Documents(); $conn = $app->DB_CONNECT; $params = array(); $params[":id"] = $id; $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("source"); $ref->setHref($id); $docs->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`.`destination`=`r`.`id`\n\t\t LEFT JOIN `documents_keys` AS `dk` ON `l`.`destination`=`dk`.`documentId`\n\t\t WHERE `l`.`source`=:id AND `r`.`type`='document'\n\t\t ORDER BY `dk`.`year`;"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $doc = new \Archive\Port\Adaptor\Data\Archive\Documents\Document(); $doc->fromXmlStr($row["rxmlview"]); $link = new \Archive\Port\Adaptor\Data\Archive\Links\Link(); $link->fromXmlStr($row["lxmlview"]); $doc->setLink($link); $docs->setDocument($doc); } return $docs; }
public function execute() { $app = \App::getInstance(); $docs = new \Archive\Port\Adaptor\Data\Archive\Documents(); $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['id']) && $app->QUERY['id'] != "") { $where = " AND `r`.`id`= :id"; $id = trim($app->QUERY['id']); $params[":id"] = $id; $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("id"); $ref->setHref($id); $docs->setRef($ref); } if (isset($app->QUERY['path']) && $app->QUERY['path'] != "") { $where = " AND `dk`.`path`= :path"; $path = trim($app->QUERY['path']); $params[":path"] = $path; $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("path"); $ref->setHref($path); $docs->setRef($ref); } if (isset($app->QUERY['snumber']) && $app->QUERY['snumber'] != "") { $start = intval(trim($app->QUERY['snumber'])); $count = 1; } $query = "SELECT `r`.`autoid`,`r`.`xmlview` FROM `resources` AS `r` \n\t\t LEFT JOIN `documents_keys` AS `dk` ON `dk`.`documentId`=`r`.`id`\n\t\t WHERE `r`.`type`='document' {$where}\n\t\t ORDER BY `dk`.`path` LIMIT {$start},{$count};"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $autoid = $row["autoid"]; $doc = new \Archive\Port\Adaptor\Data\Archive\Documents\Document(); $doc->fromXmlStr($row["xmlview"]); $docs->setDocument($doc); } if (count($docs->getDocument()) == 1) { $params = [$autoid]; $query = "SELECT COUNT(`autoid`) AS `total` FROM `resources` WHERE `type`='document' AND `autoid` < ?;"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("snumber"); $ref->setHref($row["total"]); $docs->setRef($ref); } $query = "SELECT COUNT(`autoid`) AS `total` FROM `resources` WHERE `type`='document';"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("max"); $ref->setHref($row["total"] - 1); $docs->setRef($ref); } } return $docs; }