예제 #1
0
 /**
  * @param WpTesting_Model_Passing $item
  * @param string $column_name
  * @return string
  */
 protected function render_static_column(WpTesting_Model_Passing $item, $column_name)
 {
     switch ($column_name) {
         case 'row_number':
             return $this->get_row_number();
         case 'test_title':
             $test = $item->createTest();
             return $this->render_link($this->wp->getPostPermalink($test->getId()), $test->getTitle());
         case 'results':
             $links = array();
             /* @var $result WpTesting_Model_Result */
             foreach ($item->buildResults() as $result) {
                 $links[] = $result->getTitle();
             }
             return implode(', ', $links);
         case 'scales':
             $links = array();
             foreach ($item->buildScalesWithRangeOnce() as $scale) {
                 $link = $scale->getTitle();
                 $outOf = ' (' . sprintf(__('%1$d out of %2$d', 'wp-testing'), $scale->getValue(), $scale->getMaximum()) . ')';
                 $links[] = $link . str_replace(' ', ' ', $outOf);
             }
             return implode(', ', $links);
         case 'view':
             return $this->render_link($item->getUrl());
     }
     return parent::render_static_column($item, $column_name);
 }
예제 #2
0
 /**
  * @param WpTesting_Model_Passing $item
  * @param string $column_name
  * @return string
  */
 protected function render_static_column(WpTesting_Model_Passing $item, $column_name)
 {
     switch ($column_name) {
         case 'id':
             return $item->getId();
         case 'passing_device_uuid':
             return $item->getDeviceUuid();
         case 'passing_ip':
             return $item->getIp();
         case 'passing_user_agent':
             return $item->getUserAgent();
         case 'test_title':
             $test = $item->createTest();
             return $this->render_link($this->wp->getEditPostLink($test->getId()), $test->getTitle());
         case 'results':
             $links = array();
             /* @var $result WpTesting_Model_Result */
             foreach ($item->buildResults() as $result) {
                 $links[] = $this->render_link($this->wp->getEditTermLink($result->getId(), 'wpt_result', 'wpt_test'), $result->getTitle());
             }
             return implode(', ', $links);
         case 'scales':
             $links = array();
             foreach ($item->buildScalesWithRangeOnce() as $scale) {
                 $link = $this->render_link($this->wp->getEditTermLink($scale->getId(), 'wpt_scale', 'wpt_test'), $scale->getTitle());
                 $outOf = ' (' . sprintf(__('%1$d out of %2$d', 'wp-testing'), $scale->getValue(), $scale->getMaximum()) . ')';
                 $links[] = $link . str_replace(' ', ' ', $outOf);
             }
             return implode(', ', $links);
         case 'user':
             $user = $this->wp->getUserdata($item->getRespondentId());
             if (!$user) {
                 return '';
             }
             $avatar = $this->wp->getAvatar($user->ID, 32);
             $editLink = $this->wp->getEditUserLink($user->ID);
             return "{$avatar} <strong><a href=\"{$editLink}\">{$user->user_login}</a></strong>";
         case 'actions':
             $actions = array();
             $url = '?post_type=wpt_test&page=wpt_test_respondents_results&passing_id=' . $item->getId() . '&action=';
             if ($this->is_trash) {
                 $head = $this->render_link($url . 'untrash', $this->wp->translate('Untrash'), 'row-title', array('title' => $this->wp->translate('Restore this item from the Trash')));
                 $actions[] = $this->render_tag('span', array('class' => 'delete'), $this->render_link($url . 'delete', $this->wp->translate('Delete Permanently'), 'submitdelete', array('title' => $this->wp->translate('Delete this item permanently'))));
             } else {
                 $head = $this->render_link($item->getUrl(), $this->wp->translate('View'), 'row-title', array('title' => sprintf(html_entity_decode($this->wp->translate('View &#8220;%s&#8221;')), $item->getSlug($this->wp->getSalt()))));
                 $actions[] = $this->render_tag('span', array('class' => 'trash'), $this->render_link($url . 'trash', $this->wp->translate('Trash'), 'submitdelete', array('title' => $this->wp->translate('Move this item to the Trash'))));
             }
             return $this->render_tag('strong', array(), $head) . $this->render_tag('div', array('class' => 'row-actions'), implode(' | ', $actions));
     }
     return parent::render_static_column($item, $column_name);
 }