Esempio n. 1
0
 /**
  * Searches and loads multiple .php snippet file.
  *
  * @param string $filenames Array of snippet names with optionally extra parameters included
  * @param \MUtil_Ra::pairs $parameter_value_pairs name/value pairs ot add to the source for this snippet
  * @return array Of filename => \MUtil_Snippets_SnippetInterface snippets
  */
 public function getSnippets($filenames, $parameter_value_pairs = null)
 {
     if (func_num_args() > 1) {
         $extraSourceParameters = \MUtil_Ra::pairs(func_get_args(), 1);
     } else {
         $extraSourceParameters = array();
     }
     if (is_array($filenames)) {
         list($filenames, $params) = \MUtil_Ra::keySplit($filenames);
         if ($params) {
             $extraSourceParameters = $params + $extraSourceParameters;
         }
     } else {
         $filenames = array($filenames);
     }
     $results = array();
     if ($filenames) {
         $loader = $this->getSnippetLoader();
         foreach ($filenames as $filename) {
             $results[$filename] = $loader->getSnippet($filename, $extraSourceParameters);
         }
     }
     return $results;
 }
Esempio n. 2
0
 public function testKeySplitEmpty()
 {
     $args = array();
     list($nums, $strings) = MUtil_Ra::keySplit($args);
     $this->assertEquals($nums, array());
     $this->assertEquals($strings, array());
 }
Esempio n. 3
0
 /**
  *
  * @param string $name Snippet name
  * @param \MUtil_Ra::pairs $parameter_value_pairs Optional extra snippets
  * @return \MUtil_Snippets_SnippetInterface
  */
 public static function snippet($name, $parameter_value_pairs = null)
 {
     if (func_num_args() > 1) {
         $extraSourceParameters = \MUtil_Ra::pairs(func_get_args(), 1);
     } else {
         $extraSourceParameters = array();
     }
     if (is_array($name)) {
         list($names, $params) = \MUtil_Ra::keySplit($name);
         if ($params) {
             $extraSourceParameters = $params + $extraSourceParameters;
         }
         if (isset($names[0])) {
             $name = $names[0];
         } else {
             throw new \MUtil_Html_HtmlException('Missing snippet name in call to create snippet.');
         }
     }
     $loader = self::getSnippetLoader();
     $snippet = $loader->getSnippet($name, $extraSourceParameters);
     if ($snippet->hasHtmlOutput()) {
         return $snippet;
     }
 }
 /**
  * Exports all the tokens of a single track, grouped by round
  *
  * @param \Gems_Tracker_RespondentTrack $track
  */
 protected function _exportTrackTokens(\Gems_Tracker_RespondentTrack $track)
 {
     $groupSurveys = $this->_group;
     $token = $track->getFirstToken();
     $engine = $track->getTrackEngine();
     $surveys = array();
     $table = $this->html->table(array('class' => 'browser table'));
     $table->th($this->_('Survey'))->th($this->_('Round'))->th($this->_('Token'))->th($this->_('Status'));
     $this->html->br();
     while ($token) {
         //Should this token be in the list?
         if (!$this->_isTokenInFilter($token)) {
             $token = $token->getNextToken();
             continue;
         }
         $table->tr()->td($token->getSurveyName())->td($engine->getTrackType() == 'T' ? $token->getRoundDescription() : $this->_('Single Survey'))->td(strtoupper($token->getTokenId()))->td($token->getStatus());
         //Should we display the answers?
         if (!$this->_displayToken($token)) {
             $token = $token->getNextToken();
             continue;
         }
         $showToken = false;
         if ($engine->getTrackType() == 'S' || !$groupSurveys) {
             // For single survey tracks or when $groupSurvey === false we show all tokens
             $showToken = true;
         } else {
             // For multi survey tracks and $groupSurveys === true, we show only the first token
             // as the snippet takes care of showing the other tokens
             if (!isset($surveys[$token->getSurveyId()])) {
                 $showToken = true;
                 $surveys[$token->getSurveyId()] = 1;
             }
         }
         if ($showToken) {
             $params = array('token' => $token, 'tokenId' => $token->getTokenId(), 'showHeaders' => false, 'showButtons' => false, 'showSelected' => false, 'showTakeButton' => false, 'grouped' => $groupSurveys);
             $snippets = $token->getAnswerSnippetNames();
             if (!is_array($snippets)) {
                 $snippets = array($snippets);
             }
             list($snippets, $snippetParams) = \MUtil_Ra::keySplit($snippets);
             $params = $params + $snippetParams;
             $this->html->snippet('Export_SurveyHeaderSnippet', 'token', $token);
             foreach ($snippets as $snippet) {
                 $this->html->snippet($snippet, $params);
             }
             $this->html->br();
         }
         $token = $token->getNextToken();
     }
 }