예제 #1
0
파일: index.php 프로젝트: piiskop/pstk
 public static function start()
 {
     $target = isset($_GET['target']) ? $_GET['target'] : 'showForm';
     switch ($target) {
         case 'register':
             require_once dirname(__FILE__) . '/ParticipationView.php';
             if (isset($_GET['idExhibition']) && $_GET['idExhibition'] > 0) {
                 require_once dirname(__FILE__) . '/Dog.php';
                 $dog = new Dog();
                 $dog->setBreed('retriiver')->setGender('m')->setBirthDate('2000-12-21');
                 require_once dirname(__FILE__) . '/Exhibition.php';
                 $exhibition = new Exhibition();
                 $exhibition->setId($_GET['idExhibition']);
                 $exhibition->setCompleteExhibition();
                 $exhibition->insertDog($dog);
                 echo ParticipationView::buildMessage(array('dog' => $dog, 'exhibition' => $exhibition));
             } else {
                 echo ParticipationView::buildErrorMessage();
             }
             break;
         case 'showForm':
         default:
             require_once dirname(__FILE__) . '/Exhibition.php';
             $exhibitions = Exhibition::getListOfTypeExhibitions();
             require_once dirname(__FILE__) . '/ParticipationView.php';
             echo ParticipationView::buildRegistrationForm(array('exhibitions' => $exhibitions));
             break;
     }
 }
예제 #2
0
파일: Exhibition.php 프로젝트: piiskop/pstk
 public function setCompleteExhibition()
 {
     Exhibition::getListOfTypeExhibitions();
     $id = $this->getId();
     $this->timestamp = Exhibition::$exhibitions[$id]->timestamp;
     $this->location = Exhibition::$exhibitions[$id]->location;
 }
예제 #3
0
 /**
  * Populates the Venue object from the request
  * @return bean Venue
  */
 protected function getBeanFromRequest()
 {
     global $logger;
     $prgm = new Program($_REQUEST);
     $genre = new Genre();
     $genre->setOid($_REQUEST['primaryGenre']);
     $prgm->setPrimaryGenre($genre);
     if (isset($_REQUEST['defaultVenue'])) {
         $venue = new Venue();
         $venue->setOid($_REQUEST['defaultVenue']);
         $prgm->setDefaultVenue($venue);
         $prgm->setVenues(array($venue));
     }
     // categories
     $cats = array();
     if (isset($_REQUEST['audience'])) {
         foreach ($_REQUEST['audience'] as $oid) {
             $category = new Audience();
             $category->setOid($oid);
             $cats['audience'][] = $category;
         }
     }
     if (isset($_REQUEST['genre'])) {
         foreach ($_REQUEST['genre'] as $oid) {
             $category = new Genre();
             $category->setOid($oid);
             $cats['genre'][] = $category;
         }
     }
     if (isset($_REQUEST['series'])) {
         foreach ($_REQUEST['series'] as $oid) {
             $category = new Series();
             $category->setOid($oid);
             $cats['series'][] = $category;
         }
     }
     if (isset($cats['audience'])) {
         $logger->debug("Number of audience categories in the form: " . count($cats['audience']));
     }
     if (isset($cats['genre'])) {
         $logger->debug("Number of genre categories in the form: " . count($cats['genre']));
     }
     if (isset($cats['series'])) {
         $logger->debug("Number of series categories in the form: " . count($cats['series']));
     }
     if (isset($cats['audience']) || isset($cats['genre']) || isset($cats['series'])) {
         $prgm->setCategories($cats);
     }
     // related events
     $events = array();
     if (isset($_REQUEST['exhibition'])) {
         foreach ($_REQUEST['exhibition'] as $oid) {
             $exhibition = new Exhibition();
             $exhibition->setOid($oid);
             $events[] = $exhibition;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related exhibitions in the form: " . count($events));
         $prgm->setExhibitions($events);
     }
     $events = array();
     if (isset($_REQUEST['course'])) {
         foreach ($_REQUEST['course'] as $oid) {
             $course = new Course();
             $course->setOid($oid);
             $events[] = $course;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related courses in the form: " . count($events));
         $prgm->setCourses($events);
     }
     $activities = array();
     if (isset($_REQUEST['activityChanged']) && $_REQUEST['activityChanged']) {
         // parse delimited attributes as pipe-delimited '|' string
         $startTimes = explode('|', $_REQUEST['activityStartTime']);
         $endTimes = explode('|', $_REQUEST['activityEndTime']);
         $venues = explode('|', $_REQUEST['activityVenueList']);
         $status = explode('|', $_REQUEST['activityStatusList']);
         $tickets = explode('|', $_REQUEST['activityTicketList']);
         for ($index = 0; $index < count($venues); $index++) {
             $schedule = new Schedule();
             $stint = strtotime($startTimes[$index]);
             $etint = strtotime($endTimes[$index]);
             $schedule->setStartTime($stint);
             $schedule->setEndTime($etint);
             $venue = new Venue();
             $venue->setOid($venues[$index]);
             $activity = new Performance();
             $activity->setSchedule($schedule);
             $activity->setVenue($venue);
             $activity->setActivityStatus($status[$index]);
             $activity->setTicketCode($tickets[$index]);
             $activities[] = $activity;
         }
     }
     if (isset($activities)) {
         $logger->debug("Number of related performances in the form: " . count($activities));
         $prgm->setChildren($activities);
     }
     return $prgm;
 }
예제 #4
0
파일: index.php 프로젝트: piiskop/pstk
// Controller::start();
require_once dirname(__FILE__) . '/Exhibition.php';
//lõin muutuja (mis on objekt) exhibition1, millel on omadused ja funktsioonid, mis on määratud klassis Exhibition
$exhibition1 = new Exhibition();
$exhibition1->setId(1);
$exhibition1->setLocation('Pärnu');
$exhibition1->setTimestamp('2015-12-30 09:00:00');
$exhibition2 = new Exhibition();
$exhibition2->setId(2);
$exhibition2->setLocation('Tallinn');
$exhibition2->setTimestamp('2015-12-20 10:00:00');
Exhibition::insertExhibition($exhibition1);
Exhibition::insertExhibition($exhibition2);
$exhibition1->setLocation('Tartu');
echo '<pre>';
var_dump(Exhibition::getExhibitions());
echo '</pre>';
require_once dirname(__FILE__) . '/Dog.php';
$dog1 = new Dog();
$dog1->setId(1);
$dog1->setBreed('retriiver');
$dog1->setBirthDate('2014-12-30 09:00:00');
$dog2 = new Dog();
$dog2->setId(2);
$dog2->setBreed('labrador');
$dog2->setBirthdate('2013-12-20 10:00:00');
//käivitatakse dog1 küljes olev funktsioon insert
$dog1->insert();
$dog2->insert();
echo '<pre>';
var_dump($_GET);
예제 #5
0
 /**
  * Populates the Person object from the request
  * @return bean Person
  */
 private function getBeanFromRequest()
 {
     global $logger;
     $logger->debug(get_class($this) . "::getBeanFromRequest()");
     $person = new Artist($_REQUEST);
     // related events
     $events = array();
     if (isset($_REQUEST['exhibition'])) {
         foreach ($_REQUEST['exhibition'] as $oid) {
             $event = new Exhibition();
             $event->setOid($oid);
             $events[] = $event;
         }
     }
     if ($events) {
         $logger->debug("Number of related exhibitions in the form: " . count($events));
         $person->setExhibitions($events);
     }
     // gallery
     if (isset($_REQUEST['gallery'])) {
         $person->setGallery($_REQUEST['gallery']);
     }
     return $person;
 }
예제 #6
0
 /**
  * Converts the given exhibition PDO to a bean object.
  * This includes the conversion from nested lists
  * of PDO objects to usable lists of oids/names to be used
  * by the page renderer.
  *
  * @access private
  * @param pdo $pdo Program
  * @return bean Program
  */
 private function exhibitionPdoToBean($pdo)
 {
     global $logger;
     $logger->debug(get_class($this) . "::exhibitionPdoToBean({$pdo})");
     $bean = new Exhibition($pdo->epGetVars());
     // pubState to a string
     $ps = '';
     if ($pdo->getPubState() != null) {
         $ps = $pdo->getPubState()->getValue();
     }
     $bean->setPubState($ps);
     // eventStatus to a string
     $es = '';
     if ($pdo->getEventStatus() != null) {
         $es = $pdo->getEventStatus()->getValue();
     }
     $bean->setEventStatus($es);
     // schedule
     $schedule = $pdo->getSchedule();
     if ($schedule) {
         $bean->setSchedule(new Schedule($schedule->epGetVars()));
     } else {
         $bean->setSchedule(new Schedule());
     }
     // venues from array of pdos to array of venue bean
     $vens = array();
     if ($pdo->getVenues() != null) {
         foreach ($pdo->getVenues() as $ven) {
             $vens[] = new Venue($ven->epGetVars());
         }
     }
     $bean->setVenues($vens);
     // categories from array of pdos to keyed array of oids
     $cats = array();
     if ($pdo->getCategories() != null) {
         foreach ($pdo->getCategories() as $cat) {
             $scope = $cat->getScope();
             $cats[$scope][] = new $scope($cat->epGetVars());
         }
     }
     $bean->setCategories($cats);
     // related programs from array of pdos to keyed array of oids
     $programs = $pdo->getPrograms();
     if ($programs != null) {
         $related = array();
         foreach ($programs as $event) {
             $rp = new Program($event->epGetVars());
             $ps = $event->getPubState()->getValue();
             $rp->setPubState($ps);
             // primary genre
             if ($event->getPrimaryGenre()) {
                 $pg = $event->getPrimaryGenre();
                 $prpg = new Category(array("oid" => $pg->getOid(), "name" => $pg->getName()));
                 $rp->setPrimaryGenre($prpg);
             }
             $acts = array();
             foreach ($event->getChildren() as $perf) {
                 $sch = new Performance($perf->epGetVars());
                 $sch->setSchedule(new Schedule($perf->schedule->epGetVars()));
                 $acts[] = $sch;
             }
             usort($acts, array(&$this, "orderPerformances"));
             $rp->setChildren($acts);
             // Using "Nextevent" so we can use orderProgramsByNextevent; really is firstEvent
             $rp->setNextevent($acts[0]->schedule->getStartTime());
             $related[] = $rp;
         }
         usort($related, array(&$this, "orderProgramsByNextevent"));
         $bean->setPrograms($related);
     }
     // related courses from array of pdos to keyed array of oids
     $courses = $pdo->getCourses();
     if ($courses != null) {
         $related = array();
         foreach ($courses as $event) {
             $related[] = new Course($event->epGetVars());
         }
         $bean->setCourses($related);
     }
     // related artists
     $artists = $pdo->getArtists();
     if ($artists != null) {
         $related = array();
         foreach ($artists as $person) {
             $related[] = new Artist($person->epGetVars());
         }
         $bean->setArtists($related);
     }
     return $bean;
 }
예제 #7
0
 /**
  * Instantiates an Exhibition bean object and copies all
  * valid incoming form elements to the bean object
  * @return The valid Exhibition bean
  */
 protected function getBeanFromRequest()
 {
     global $logger;
     $logger->debug(get_class($this) . "::getBeanFromRequest()");
     $service = $this->getEventService();
     // TODO: Add validator here
     $exhibit = new Exhibition($_REQUEST);
     $logger->debug("exhibition object: {$exhibit}");
     if (isset($_REQUEST['displayOrder']) && intval($_REQUEST['displayOrder']) > 0) {
         $exhibit->setDisplayOrder($_REQUEST['displayOrder']);
     }
     // Format the times
     $logger->debug("Start Time: " . $_REQUEST['startMonth'] . "," . $_REQUEST['startDay'] . "," . $_REQUEST['startYear']);
     $startTime = mktime(0, 0, 0, $_REQUEST['startMonth'], $_REQUEST['startDay'], $_REQUEST['startYear']);
     $logger->debug("Start Time (mktime)" . $startTime);
     // find out if this is a recurring event
     $endTime = mktime(0, 0, 0, $_REQUEST['endMonth'], $_REQUEST['endDay'], $_REQUEST['endYear']);
     if ($_REQUEST['close_type'] == 'ongoing') {
         $endTime = 0;
     }
     // load the schedule
     $schedule = new Schedule();
     if (isset($_REQUEST['scheduleOid'])) {
         $schedule->setOid(intval($_REQUEST['scheduleOid']));
     }
     $schedule->setStartTime($startTime);
     $schedule->setEndTime($endTime);
     $exhibit->setSchedule($schedule);
     // venues
     if (isset($_REQUEST['venue'])) {
         $venues = array();
         foreach ($_REQUEST['venue'] as $oid) {
             $venue = new Venue();
             $venue->setOid($oid);
             $venues[] = $venue;
         }
         $logger->debug("Number of venues in the form: " . count($venues));
         $exhibit->setVenues($venues);
     }
     // categories
     $cats = array();
     if (isset($_REQUEST['audience'])) {
         foreach ($_REQUEST['audience'] as $oid) {
             $category = new Audience();
             $category->setOid($oid);
             $cats['audience'][] = $category;
         }
     }
     if (isset($_REQUEST['genre'])) {
         foreach ($_REQUEST['genre'] as $oid) {
             $category = new Genre();
             $category->setOid($oid);
             $cats['genre'][] = $category;
         }
     }
     if (isset($cats['audience'])) {
         $logger->debug("Number of audience categories in the form: " . count($cats['audience']));
     }
     if (isset($cats['genre'])) {
         $logger->debug("Number of genre categories in the form: " . count($cats['genre']));
     }
     if (isset($cats['audience']) || isset($cats['genre'])) {
         $exhibit->setCategories($cats);
     }
     // related events
     $events = array();
     if (isset($_REQUEST['program'])) {
         foreach ($_REQUEST['program'] as $oid) {
             $program = new Program();
             $program->setOid($oid);
             $events[] = $program;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related programs in the form: " . count($events));
         $exhibit->setPrograms($events);
     }
     $events = array();
     if (isset($_REQUEST['course'])) {
         foreach ($_REQUEST['course'] as $oid) {
             $course = new Course();
             $course->setOid($oid);
             $events[] = $course;
         }
     }
     if (isset($events)) {
         $logger->debug("Number of related courses in the form: " . count($events));
         $exhibit->setCourses($events);
     }
     // gallery
     if (isset($_REQUEST['gallery'])) {
         $exhibit->setGallery($_REQUEST['gallery']);
     }
     // artists
     if (isset($_REQUEST['person'])) {
         $persons = array();
         foreach ($_REQUEST['person'] as $oid) {
             $person = new Artist();
             $person->setOid($oid);
             $persons[] = $person;
         }
         $logger->debug("Number of persons in the form: " . count($persons));
         $exhibit->setArtists($persons);
     }
     // artifacts
     if (isset($_REQUEST['artifact'])) {
         $artifacts = array();
         foreach ($_REQUEST['artifact'] as $id) {
             $artifacts[] = $id;
         }
         $artlist = implode(",", $artifacts);
         $logger->debug("Number of persons in the form: " . count($artifacts));
         $exhibit->setArtifacts($artlist);
     }
     return $exhibit;
 }