/**
  * 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;
 }
Example #2
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;
 }
Example #3
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;
 }
 /**
  * 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.');
     }
 }
Example #5
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);
 }