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($id) { $app = \App::getInstance(); $events = new \Archive\Port\Adaptor\Data\Archive\Events(); $conn = $app->DB_CONNECT; $params = array(); $params[":id"] = $id; $ref = new \Archive\Port\Adaptor\Data\Archive\Refs\Ref(); $ref->setRel("destination"); $ref->setHref($id); $events->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`='event'\n\t\t ORDER BY `l`.`autoid`;"; $sth = $conn->prepare($query); $sth->execute($params); while ($row = $sth->fetch()) { $event = new \Archive\Port\Adaptor\Data\Archive\Events\Event(); $event->fromXmlStr($row["rxmlview"]); $link = new \Archive\Port\Adaptor\Data\Archive\Links\Link(); $link->fromXmlStr($row["lxmlview"]); $event->setLink($link); $events->setEvent($event); } return $events; }