Ejemplo n.º 1
0
 /**
  * Create the school choice form
  */
 public function setupNewPage()
 {
     $entityManager = $this->_controller->getEntityManager();
     $types = $entityManager->getRepository('Jazzee\\Entity\\ElementType')->findAll();
     $elementTypes = array();
     foreach ($types as $type) {
         $elementTypes[$type->getClass()] = $type;
     }
     $standardPageType = $entityManager->getRepository('\\Jazzee\\Entity\\PageType')->findOneBy(array('class' => '\\Jazzee\\Page\\Standard'));
     $newSchool = new \Jazzee\Entity\Page();
     $newSchool->setType($standardPageType);
     $newSchool->setFixedId(self::PAGE_FID_NEWSCHOOL);
     $newSchool->setTitle('New School');
     $this->_applicationPage->getPage()->addChild($newSchool);
     $entityManager->persist($newSchool);
     $elements = array(array('fid' => self::ELEMENT_FID_NAME, 'title' => 'School Name', 'max' => 255, 'required' => true), array('fid' => self::ELEMENT_FID_CITY, 'title' => 'City', 'max' => 64, 'required' => true), array('fid' => self::ELEMENT_FID_STATE, 'title' => 'State or Province', 'max' => 64, 'required' => false), array('fid' => self::ELEMENT_FID_COUNTRY, 'title' => 'Country', 'max' => 64, 'required' => true), array('fid' => self::ELEMENT_FID_POSTALCODE, 'title' => 'Postal Code', 'max' => 10, 'required' => false));
     $count = 1;
     foreach ($elements as $arr) {
         $element = new \Jazzee\Entity\Element();
         $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
         $element->setTitle($arr['title']);
         if ($arr['required']) {
             $element->required();
         } else {
             $element->optional();
         }
         $element->setWeight($count++);
         $element->setMax($arr['max']);
         $element->setFixedId($arr['fid']);
         $newSchool->addElement($element);
         $entityManager->persist($element);
     }
     $defaultVars = array('schoolListType' => 'full', 'partialSchoolList' => '');
     foreach ($defaultVars as $name => $value) {
         $var = $this->_applicationPage->getPage()->setVar($name, $value);
         $entityManager->persist($var);
     }
 }
Ejemplo n.º 2
0
 /**
  * Copy a Page
  * @param \Doctrine\ORM\EntityManager $em
  * @param \Jazzee\Entity\Page $page
  * @return \Jazzee\Entity\Page
  */
 public function copyPage(\Doctrine\ORM\EntityManager $em, \Jazzee\Entity\Page $page)
 {
     $newPage = new \Jazzee\Entity\Page();
     $newPage->setTitle($page->getTitle());
     $newPage->setMax($page->getMax());
     $newPage->setInstructions($page->getInstructions());
     $newPage->setLeadingText($page->getLeadingText());
     $newPage->setTrailingText($page->getTrailingText());
     $newPage->setFixedId($page->getFixedId());
     $newPage->setType($em->getRepository('\\Jazzee\\Entity\\PageType')->findOneByClass($page->getType()->getClass()));
     if ($page->isGlobal()) {
         $newPage->makeGlobal();
     } else {
         $newPage->notGlobal();
     }
     if ($page->isRequired()) {
         $newPage->required();
     } else {
         $newPage->optional();
     }
     foreach ($page->getChildren() as $child) {
         $newPage->addChild($this->copyPage($em, $child));
     }
     foreach ($page->getVariables() as $variable) {
         $newPage->setVar($variable->getName(), $variable->getValue());
     }
     foreach ($newPage->getVariables() as $variable) {
         $em->persist($variable);
     }
     foreach ($page->getElements() as $element) {
         $newElement = new \Jazzee\Entity\Element();
         $newElement->setType($em->getRepository('\\Jazzee\\Entity\\ElementType')->findOneByClass($element->getType()->getClass()));
         $newElement->setWeight($element->getWeight());
         $newElement->setFixedId($element->getFixedId());
         $newElement->setTitle($element->getTitle());
         $newElement->setMax($element->getMax());
         $newElement->setMin($element->getMin());
         $newElement->setInstructions($element->getInstructions());
         $newElement->setDefaultValue($element->getDefaultValue());
         $newElement->setFormat($element->getFormat());
         if ($element->isRequired()) {
             $newElement->required();
         } else {
             $newElement->optional();
         }
         foreach ($element->getListItems() as $item) {
             $newItem = new \Jazzee\Entity\ElementListItem();
             $newItem->setValue($item->getValue());
             $newItem->setWeight($item->getWeight());
             $newElement->addItem($newItem);
             $em->persist($newItem);
         }
         $em->persist($newElement);
         $newPage->addElement($newElement);
     }
     $em->persist($newPage);
     return $newPage;
 }
Ejemplo n.º 3
0
 /**
  * Add a new page
  *
  * Do this in a deperate funciton so it can call itself
  * @param \Jazzee\Entity\Page $previousPage
  * @return \Jazzee\Entity\Page
  */
 protected function addPage(\Jazzee\Entity\Page $previousPage)
 {
     if ($previousPage->isGlobal()) {
         $page = $previousPage;
     } else {
         $page = new \Jazzee\Entity\Page();
         $page->setType($previousPage->getType());
         $page->setTitle($previousPage->getTitle());
         $page->setMin($previousPage->getMin());
         $page->setMax($previousPage->getMax());
         if ($previousPage->isRequired()) {
             $page->required();
         } else {
             $page->optional();
         }
         if ($previousPage->answerStatusDisplay()) {
             $page->showAnswerStatus();
         } else {
             $page->hideAnswerStatus();
         }
         $page->setInstructions($previousPage->getInstructions());
         $page->setLeadingText($previousPage->getLeadingText());
         $page->setTrailingText($previousPage->getTrailingText());
         $page->notGlobal();
         $this->_em->persist($page);
         foreach ($previousPage->getElements() as $previousElement) {
             $element = new \Jazzee\Entity\Element();
             $element->setType($previousElement->getType());
             $element->setFixedId($previousElement->getFixedId());
             $element->setTitle($previousElement->getTitle());
             $element->setMin($previousElement->getMin());
             $element->setMax($previousElement->getMax());
             $element->setName($previousElement->getName());
             if ($previousElement->isRequired()) {
                 $element->required();
             } else {
                 $element->optional();
             }
             $element->setInstructions($previousElement->getInstructions());
             $element->setFormat($previousElement->getFormat());
             $element->setWeight($previousElement->getWeight());
             $page->addElement($element);
             foreach ($previousElement->getListItems() as $previousItem) {
                 $listItem = new \Jazzee\Entity\ElementListItem();
                 $listItem->setValue($previousItem->getValue());
                 $listItem->setWeight($previousItem->getWeight());
                 $listItem->setName($previousItem->getName());
                 if ($previousItem->isActive()) {
                     $listItem->activate();
                 } else {
                     $listItem->deactivate();
                 }
                 $element->addItem($listItem);
                 $this->_em->persist($listItem);
             }
             $this->_em->persist($element);
         }
         foreach ($previousPage->getVariables() as $previousVar) {
             $var = $page->setVar($previousVar->getName(), $previousVar->getValue());
             $this->_em->persist($var);
         }
         foreach ($previousPage->getChildren() as $previousChild) {
             $childPage = $this->addPage($previousChild);
             $page->addChild($childPage);
         }
     }
     return $page;
 }
Ejemplo n.º 4
0
 /**
  * Create the recommenders form
  */
 public function setupNewPage()
 {
     $entityManager = $this->_controller->getEntityManager();
     $types = $entityManager->getRepository('Jazzee\\Entity\\ElementType')->findAll();
     $elementTypes = array();
     foreach ($types as $type) {
         $elementTypes[$type->getClass()] = $type;
     }
     $count = 1;
     foreach (array(self::FID_FIRST_NAME => 'First Name', self::FID_LAST_NAME => 'Last Name', self::FID_INSTITUTION => 'Institution') as $fid => $title) {
         $element = new \Jazzee\Entity\Element();
         $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
         $element->setTitle($title);
         $element->required();
         $element->setWeight($count);
         $element->setFixedId($fid);
         $this->_applicationPage->getPage()->addElement($element);
         $entityManager->persist($element);
         $count++;
     }
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\EmailAddress']);
     $element->setTitle('Email Address');
     $element->required();
     $element->setWeight(5);
     $element->setFixedId(self::FID_EMAIL);
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\Phonenumber']);
     $element->setTitle('Phone Number');
     $element->required();
     $element->setWeight(6);
     $element->setFixedId(self::FID_PHONE);
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\RadioList']);
     $element->setTitle('Do you waive your right to view this letter at a later time?');
     $element->required();
     $element->setWeight(7);
     $element->setFixedId(self::FID_WAIVE_RIGHT);
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $item = new \Jazzee\Entity\ElementListItem();
     $item->setValue('Yes');
     $item->setWeight(1);
     $element->addItem($item);
     $entityManager->persist($item);
     $item = new \Jazzee\Entity\ElementListItem();
     $item->setValue('No');
     $item->setWeight(2);
     $element->addItem($item);
     $entityManager->persist($item);
     $defaultVars = array('lorDeadline' => null, 'lorDeadlineEnforced' => false, 'recommenderEmailText' => '', 'lorWaitDays' => 14);
     foreach ($defaultVars as $name => $value) {
         $var = $this->_applicationPage->getPage()->setVar($name, $value);
         $entityManager->persist($var);
     }
 }
Ejemplo n.º 5
0
 protected function addPageFromXml(SimpleXMLElement $xml)
 {
     $attributes = $xml->attributes();
     if (!empty($attributes['globalPageUuid'])) {
         $page = $this->_em->getRepository('\\Jazzee\\Entity\\Page')->findOneBy(array('isGlobal' => true, 'uuid' => (string) $attributes['globalPageUuid']));
         if (!$page) {
             $this->addMessage('error', (string) $attributes['title'] . ' page in import references global page with uuid ' . (string) $attributes['globalPageUuid'] . ' but this page does not exist.  You need to import it before importing this application.');
             $this->_em->clear();
             $this->redirectPath('setup/importapplication');
         }
     } else {
         $page = new \Jazzee\Entity\Page();
         $page->setType($this->_em->getRepository('\\Jazzee\\Entity\\PageType')->findOneBy(array('class' => (string) $attributes['class'])));
         $page->setTitle(html_entity_decode((string) $attributes['title']));
         $page->setMin((string) $attributes['min']);
         $page->setMax((string) $attributes['max']);
         if ((string) $attributes['required']) {
             $page->required();
         } else {
             $page->optional();
         }
         if ((string) $attributes['answerStatusDisplay']) {
             $page->showAnswerStatus();
         } else {
             $page->hideAnswerStatus();
         }
         $eattr = $xml->xpath('instructions');
         $page->setInstructions((string) $eattr[0]);
         $eattr = $xml->xpath('leadingText');
         $page->setLeadingText((string) $eattr[0]);
         $eattr = $xml->xpath('trailingText');
         $page->setTrailingText((string) $eattr[0]);
         $page->notGlobal();
         $this->_em->persist($page);
         foreach ($xml->xpath('elements/element') as $elementElement) {
             $attributes = $elementElement->attributes();
             $element = new \Jazzee\Entity\Element();
             $element->setType($this->_em->getRepository('\\Jazzee\\Entity\\ElementType')->findOneBy(array('class' => (string) $attributes['class'])));
             if ((string) $attributes['fixedId']) {
                 $element->setFixedId((string) $attributes['fixedId']);
             }
             $element->setTitle((string) $attributes['title']);
             $element->setName((string) $attributes['name']);
             $element->setMin((string) $attributes['min']);
             $element->setMax((string) $attributes['max']);
             if ((string) $attributes['required']) {
                 $element->required();
             } else {
                 $element->optional();
             }
             $element->setInstructions(html_entity_decode((string) $attributes['instructions']));
             $element->setFormat(html_entity_decode((string) $attributes['format']));
             $element->setWeight((string) $attributes['weight']);
             $page->addElement($element);
             foreach ($elementElement->xpath('listitems/item') as $listElement) {
                 $attributes = $listElement->attributes();
                 $listItem = new \Jazzee\Entity\ElementListItem();
                 $listItem->setValue((string) $listElement);
                 $listItem->setWeight((string) $attributes['weight']);
                 $listItem->setName((string) $attributes['name']);
                 if ((string) $attributes['active']) {
                     $listItem->activate();
                 } else {
                     $listItem->deactivate();
                 }
                 $element->addItem($listItem);
                 $this->_em->persist($listItem);
             }
             $this->_em->persist($element);
         }
         foreach ($xml->xpath('variables/variable') as $element) {
             $var = $page->setVar($element['name'], (string) $element);
             $this->_em->persist($var);
         }
         foreach ($xml->xpath('children/page') as $element) {
             $childPage = $this->addPageFromXml($element);
             $page->addChild($childPage);
         }
     }
     return $page;
 }
Ejemplo n.º 6
0
 /**
  * Create the recommenders form
  */
 public function setupNewPage()
 {
     $entityManager = $this->_controller->getEntityManager();
     $types = $entityManager->getRepository('Jazzee\\Entity\\ElementType')->findAll();
     $elementTypes = array();
     foreach ($types as $type) {
         $elementTypes[$type->getClass()] = $type;
     }
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
     $element->setTitle('Address 3');
     $element->setWeight(1);
     $element->setFixedId(self::FID_ADDRESS3);
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
     $element->setTitle('Address 1');
     $element->required();
     $element->setWeight(2);
     $element->setFixedId(self::FID_ADDRESS1);
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
     $element->setTitle('Address 2');
     $element->setWeight(3);
     $element->setFixedId(self::FID_ADDRESS2);
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
     $element->setTitle('City');
     $element->setWeight(4);
     $element->setFixedId(self::FID_CITY);
     $element->required();
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
     $element->setTitle('State');
     $element->setWeight(5);
     $element->setFixedId(self::FID_STATE);
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
     $element->setTitle('Country');
     $element->setWeight(5);
     $element->setFixedId(self::FID_COUNTRY);
     $element->required();
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $element = new \Jazzee\Entity\Element();
     $element->setType($elementTypes['\\Jazzee\\Element\\TextInput']);
     $element->setTitle('Postal Code');
     $element->setWeight(6);
     $element->setFixedId(self::FID_POSTALCODE);
     $element->required();
     $this->_applicationPage->getPage()->addElement($element);
     $entityManager->persist($element);
     $defaultVars = array('wsdlAddress' => null, 'validatedCountries' => '');
     foreach ($defaultVars as $name => $value) {
         $var = $this->_applicationPage->getPage()->setVar($name, $value);
         $entityManager->persist($var);
     }
 }