Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
0
 /**
  * Converts the given program 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 programPdoToBean($pdo)
 {
     require_once WEB_INF . '/beans/Performance.php';
     global $logger;
     $logger->debug(get_class($this) . "::programPdoToBean({$pdo})");
     $copyOption = new CopyBeanOption();
     $copyOption->setUseTargetVars(true);
     $copyOption->setScalarsOnly(true);
     $bean = new Program($pdo->epGetVars());
     // primaryGenre to bean
     $genre = $pdo->getPrimaryGenre();
     $ga = $genre != null ? $genre->epGetVars() : null;
     $pg = new Genre($ga);
     $bean->setPrimaryGenre($pg);
     // 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);
     // default venue from pdo to bean
     $dven = $pdo->getDefaultVenue();
     $dv = $dven != null ? $dven->epGetVars() : null;
     $bean->setDefaultVenue(new Venue($dv));
     // 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 exhibitions from array of pdos to keyed array of oids
     $exhibitions = $pdo->getExhibitions();
     if ($exhibitions != null) {
         $related = array();
         foreach ($exhibitions as $event) {
             $related[] = new Exhibition($event->epGetVars());
         }
         $bean->setExhibitions($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 performances from array of pdos to array of activities
     $children = $pdo->getChildren();
     if ($children != null) {
         $activities = array();
         foreach ($children as $activity) {
             $scope = $activity->getScope();
             $perf = new $scope($activity->epGetVars());
             $perf->setActivityStatus(new EventStatus($activity->getActivityStatus()->epGetVars()));
             $perf->setSchedule(new Schedule($activity->getSchedule()->epGetVars()));
             if ($activity->getVenue()) {
                 $perf->setVenue(new Venue($activity->getVenue()->epGetVars()));
             }
             $activities[] = $perf;
         }
         $bean->setChildren($activities);
     }
     return $bean;
     //		// gallery
     //		// TODO get gallery relationship
 }