Example #1
0
 /**
  * Generate macro output
  *
  * @return     string
  */
 public function render()
 {
     $et = $this->args;
     if (!$et) {
         return '';
     }
     $pages = explode(',', $et);
     $html = '<div class="rellink relarticle mainarticle">Main articles: ';
     foreach ($pages as $page) {
         $page = trim($page);
         // Is it numeric?
         $scope = '';
         if (is_numeric($page)) {
             // Yes
             $page = intval($page);
         } else {
             $page = trim($page, DS);
             if (strstr($page, '/') && !strstr($page, ' ')) {
                 $bits = explode('/', $page);
                 $page = array_pop($bits);
                 $scope = implode('/', $bits);
             }
         }
         if ($this->domain != '' && $scope == '') {
             $scope = $this->scope;
         }
         // No, get resource by alias
         $g = new \Components\Wiki\Tables\Page($this->_db);
         if (strstr($page, ' ')) {
             $g->loadByTitle($page, $scope);
         } else {
             $g->load($page, $scope);
         }
         if (!$g->id) {
             $g->pagename = $page;
         }
         // Build and return the link
         if ($g->group_cn != '' && $g->scope != '') {
             $link = 'index.php?option=com_groups&scope=' . $g->scope . '&pagename=' . $g->pagename;
         } else {
             $link = 'index.php?option=com_wiki&scope=' . $g->scope . '&pagename=' . $g->pagename;
         }
         if (!$g->id) {
             $l[] = '<a href="' . Route::url($link) . '">' . stripslashes($g->getTitle()) . '</a>';
         } else {
             $l[] = '<a class="int-link" href="' . Route::url($link) . '">' . stripslashes($g->getTitle()) . '</a>';
         }
     }
     if (count($l) > 1) {
         $last = array_pop($l);
         $html .= implode(', ', $l);
         $html .= ' and ' . $last;
     } else {
         $html .= $l[0];
     }
     return $html . '</div>';
 }