示例#1
0
 /**
  * Renders the summary of given venues
  * @param bean $model The venues summary model
  */
 private function renderSummary($model)
 {
     global $logger;
     $logger->debug(get_class($this) . '::summary()');
     $data = $model->getVenues();
     $tmpl = $this->createPatTemplate();
     $tmpl->readTemplatesFromInput('venue_summary.pat.tpl');
     $tmpl->addVar('venue_summary', 'total', count($data));
     // Add the objects to the nested templates
     for ($i = 0; $i < count($data); $i++) {
         $venue = $data[$i];
         $logger->debug("Class of venue: " . get_class($venue));
         $tmpl->addVar('venue', 'iter', $i);
         $tmpl->addVar('venue', 'index', $i + 1);
         // Render the primary form fields
         $tmpl->addVars('venue', BeanUtil::beanToArray($venue, true));
         // scalars only
         $ab = $venue->getAddress();
         if ($ab->getStreet() == null) {
             $addr = "n/a";
         } else {
             $addr = $ab->getStreet() . "," . $ab->getCity() . "," . $ab->getState();
         }
         $tmpl->addVar('venue', 'address', $addr);
         $pubwidget = $this->getPubControls($venue->getPubState());
         $tmpl->addVars('venue', $pubwidget);
         $ecount = 0;
         $pcount = 0;
         $ccount = 0;
         $events = $venue->getEvents();
         foreach ($events as $event) {
             switch ($event->getScope()) {
                 case 'Exhibition':
                     $ecount += 1;
                     break;
                 case 'Program':
                     $pcount += 1;
                     break;
                 case 'Course':
                     $ccount += 1;
                     break;
             }
         }
         $tmpl->addVar('venue', 'exhibition', $ecount);
         $tmpl->addVar('venue', 'program', $pcount);
         $tmpl->addVar('venue', 'course', $ccount);
         $tmpl->parseTemplate('venue', "a");
     }
     $tmpl->displayParsedTemplate('venue_summary');
 }