Esempio n. 1
0
 /**
  * Overloading: allow rendering specific decorators
  *
  * Call renderDecoratorName() to render a specific decorator.
  *
  * @param  string $method
  * @param  array $args
  * @return \MUtil_Html_HtmlElement or at least something that implements the \MUtil_Html_HtmlInterface interface
  * @throws \Zend_Form_Exception for invalid decorator or invalid method call
  */
 public function __call($method, $args)
 {
     if ('render' == substr($method, 0, 6)) {
         return parent::__call($method, $args);
     }
     $elem = \MUtil_Html::createArray($method, $args);
     $value = $this->getValue();
     if (!$value instanceof \MUtil_Html_ElementInterface) {
         $value = new \MUtil_Html_Sequence();
     }
     $value->append($elem);
     $this->setValue($value);
     return $elem;
 }
 /**
  * A list of all participating organizations.
  *
  * @return \MUtil_Html_HtmlElement
  */
 protected function _getOrganizationsList()
 {
     $html = new \MUtil_Html_Sequence();
     $sql = '
         SELECT *
         FROM gems__organizations
         WHERE gor_active=1 AND gor_url IS NOT NULL AND gor_task IS NOT NULL
         ORDER BY gor_name';
     // $organizations = array();
     // $organizations = array(key($organizations) => reset($organizations));
     $organizations = $this->db->fetchAll($sql);
     $orgCount = count($organizations);
     switch ($orgCount) {
         case 0:
             return $html->pInfo(sprintf($this->_('%s is still under development.'), $this->project->getName()));
         case 1:
             $organization = reset($organizations);
             $p = $html->pInfo(sprintf($this->_('%s is run by: '), $this->project->getName()));
             $p->a($organization['gor_url'], $organization['gor_name']);
             $p->append('.');
             $html->pInfo()->sprintf($this->_('Please contact the %s if you have any questions regarding %s.'), $organization['gor_name'], $this->project->getName());
             return $html;
         default:
             $p = $html->pInfo(sprintf($this->_('%s is a collaboration of these organizations:'), $this->project->getName()));
             $data = \MUtil_Lazy::repeat($organizations);
             $ul = $p->ul($data, array('class' => 'indent'));
             $li = $ul->li();
             $li->a($data->gor_url->call($this, '_'), $data->gor_name, array('rel' => 'external'));
             $li->append(' (');
             $li->append($data->gor_task->call(array($this, '_')));
             $li->append(')');
             $html->pInfo()->sprintf($this->_('You can contact any of these organizations if you have questions regarding %s.'), $this->project->getName());
             return $html;
     }
 }
 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     $this->html = $this->getHtmlSequence();
     $versions = $this->loader->getVersions();
     $this->html->h1(sprintf('Upgrade compatibility report for GemsTracker %s, build %d', $versions->getGemsVersion(), $versions->getBuild()));
     $this->addEscortReport();
     $this->addFileReports();
     return $this->html;
 }
 /**
  * Renders the entire report (including layout)
  *
  * @param array|string[] $respondentId
  * @param boolean $group Group same surveys or not
  * @param string $format html|pdf, the output format to use
  */
 public function render($respondents, $group = true, $format = 'html')
 {
     $this->_group = $group;
     $this->html->snippet($this->_reportHeader);
     $respondentCount = count($respondents);
     $respondentIdx = 0;
     foreach ($respondents as $respondentId) {
         $respondentIdx++;
         $this->_exportRespondent($respondentId);
         if ($respondentIdx < $respondentCount) {
             // Add some whitespace between patients
             $this->html->div('', array('style' => 'height: 100px'));
         }
     }
     $this->html->snippet($this->_reportFooter, 'respondents', $respondents);
     $this->menu->setVisible(false);
     if ($this->escort instanceof \Gems_Project_Layout_MultiLayoutInterface) {
         $this->escort->layoutSwitch();
     }
     $this->escort->postDispatch(\Zend_Controller_Front::getInstance()->getRequest());
     \Zend_Controller_Action_HelperBroker::getExistingHelper('layout')->disableLayout();
     \Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(true);
     $this->view->layout()->content = $this->html->render($this->view);
     $content = $this->view->layout->render();
     if ($format == 'pdf') {
         if (is_array($respondentId) && isset($respondentId['gr2o_id_organization'])) {
             $respondentId = $respondentId['gr2o_patient_nr'];
         }
         $filename = 'respondent-export-' . strtolower($respondentId) . '.pdf';
         $content = $this->_pdf->convertFromHtml($content);
         $this->_pdf->echoPdfContent($content, $filename, true);
     } else {
         echo $content;
     }
     $this->menu->setVisible(true);
 }
 /**
  * Get the action links for the specified items.
  *
  * @param boolean $remove Optional, set to true to remove the item from this list.
  * @param string $contr1 Controller name
  * @param string $action1 Action name, continues in pairs
  * @return \MUtil_Html_Sequence
  */
 public function getActionLinks($remove, $contr1, $action1 = null, $contr2 = null, $action2 = null)
 {
     $args = func_get_args();
     $count = func_num_args();
     $results = new \MUtil_Html_Sequence();
     $results->setGlue($this->getGlue());
     for ($i = 1; $i < $count; $i++) {
         if ($result = $this->getActionLink($args[$i], $args[++$i], $remove)) {
             $results->append($result);
         }
     }
     return $results;
 }
Esempio n. 6
0
 /**
  * Displays the content
  *
  * @param string $value
  * @return string
  */
 public function format($value)
 {
     // \MUtil_Echo::track($value, $this->options);
     if (!is_array($value)) {
         $value = $this->loadValue($value);
     }
     if (is_array($value)) {
         if ($this->options) {
             foreach ($value as &$val) {
                 if (isset($this->options[$val])) {
                     $val = $this->options[$val];
                 }
             }
         }
         if (is_string($this->displaySeperator)) {
             return implode($this->displaySeperator, $value);
         } else {
             $output = new \MUtil_Html_Sequence($value);
             $output->setGlue($this->displaySeperator);
             return $output;
         }
     }
     if (isset($this->options[$value])) {
         return $this->options[$value];
     }
     return $value;
 }
 /**
  * A ModelAbstract->setOnLoad() function that takes care of transforming a
  * dateformat read from the database to a \Zend_Date format
  *
  * If empty or \Zend_Db_Expression (after save) it will return just the value
  * currently there are no checks for a valid date format.
  *
  * @see \MUtil_Model_ModelAbstract
  *
  * @param mixed $value The value being saved
  * @param boolean $isNew True when a new item is being saved
  * @param string $name The name of the current field
  * @param array $context Optional, the other values being saved
  * @param boolean $isPost True when passing on post data
  * @return \MUtil_Date|\Zend_Db_Expr|string
  */
 public function calculateTrackUsage($value, $isNew = false, $name = null, array $context = array(), $isPost = false)
 {
     $surveyId = isset($context['gsu_id_survey']) ? $context['gsu_id_survey'] : false;
     if (!$surveyId) {
         return 0;
     }
     $select = new \Zend_Db_Select($this->db);
     $select->from('gems__tracks', array('gtr_track_name'));
     $select->joinLeft('gems__rounds', 'gro_id_track = gtr_id_track', array('useCnt' => 'COUNT(*)'))->where('gro_id_survey = ?', $surveyId)->group('gtr_track_name');
     $usage = $this->db->fetchPairs($select);
     if ($usage) {
         $seq = new \MUtil_Html_Sequence();
         $seq->setGlue(\MUtil_Html::create('br'));
         foreach ($usage as $track => $count) {
             $seq[] = sprintf($this->plural('%d time in %s track.', '%d times in %s track.', $count), $count, $track);
         }
         return $seq;
     } else {
         return $this->_('Not in any track.');
     }
 }
 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     if ($this->request->isPost()) {
         $this->export->render($this->getRespondentIds(), $this->request->getParam('group'), $this->request->getParam('format'));
     } else {
         $seq = new \MUtil_Html_Sequence();
         if ($this->formTitle) {
             $seq->h2($this->formTitle);
         }
         $form = $this->export->getForm($this->hideGroup);
         $div = $seq->div(array('id' => 'mainform'), $form);
         $table = new \MUtil_Html_TableElement(array('class' => 'formTable'));
         $table->setAsFormLayout($form);
         $form->populate($this->request->getParams());
         return $seq;
     }
 }
 /**
  * Displays textual information what checking tokens does
  *
  * @param \MUtil_Html_Sequence $html
  * @param \Zend_Translate $translate
  * @param string $itemDescription Describe which tokens will be checked
  */
 public static function addCheckInformation(\MUtil_Html_Sequence $html, \Zend_Translate $translate, $itemDescription)
 {
     $html->pInfo($translate->_('Check tokens for being answered or not, reruns survey and round event code on completed tokens and recalculates the start and end times of all tokens in tracks that have completed tokens.'));
     $html->pInfo($translate->_('Run this code when survey result fields, survey or round events or the event code has changed or after bulk changes in a survey source.'));
     $html->pInfo($itemDescription);
 }
Esempio n. 10
0
 public function uptoOffDynamic($upto = '~', $off = '/', $less = '-', $more = '+', $all = null, $glue = ' ', $args = null)
 {
     $argDefaults = array('upto' => '~', 'off' => '/', 'less' => '-', 'more' => '+', 'all' => null, 'glue' => ' ');
     $argNames = array_keys($argDefaults);
     $args = \MUtil_Ra::args(func_get_args(), $argNames, $argDefaults);
     foreach ($argNames as $name) {
         ${$name} = $args[$name];
         unset($args[$name]);
     }
     $seq = new \MUtil_Html_Sequence();
     $seq->setGlue($glue);
     if (null !== $upto) {
         $seq->if($this->pages->totalItemCount, $this->pages->firstItemNumber, 0);
         $seq[] = $upto;
     }
     if (null !== $less) {
         $cless = $this->toLazy()->getItemCountLess();
         $seq[] = $this->createCountLink($cless, $cless, (array) $less + $args);
     }
     if (null !== $upto) {
         $seq[] = $this->pages->lastItemNumber;
     }
     if (null !== $more) {
         $cmore = $this->toLazy()->getItemCountMore();
         $seq[] = $this->createCountLink($cmore, $cmore, (array) $more + $args);
     }
     if (null !== $all) {
         $seq[] = $this->createCountLink($this->toLazy()->getItemCountNotMax(), $this->toLazy()->getItemCountMax(), (array) $all + $args);
     }
     if (null !== $off) {
         if (null !== $upto) {
             $seq[] = $off;
         }
         $seq[] = $this->pages->totalItemCount;
     }
     return $seq;
 }
Esempio n. 11
0
 /**
  * Displays the content
  *
  * @param string $value
  * @return string
  */
 public function formatTable($value)
 {
     if (null === $value || is_scalar($value)) {
         return $value;
     }
     if (is_array($value)) {
         $i = 0;
         $output = new \MUtil_Html_Sequence();
         $output->setGlue($this->_separator);
         foreach ($value as $val) {
             if ($i++ > $this->_maxTable) {
                 $output->append($this->_more);
                 break;
             }
             $output->append($val);
         }
         return $output;
     }
     return \MUtil_Html_TableElement::createArray($value);
 }