Example #1
0
 /**
  * Generate macro output
  *
  * @return  string
  */
 public function render()
 {
     $et = $this->args;
     if (!$et) {
         return '';
     }
     $p = explode(',', $et);
     $page = array_shift($p);
     $nolink = false;
     $p = explode(' ', end($p));
     foreach ($p as $a) {
         $a = trim($a);
         if ($a == 'nolink') {
             $nolink = true;
         }
     }
     // Is it numeric?
     $scope = '';
     if (is_numeric($page)) {
         // Yes
         $row = \Components\Wiki\Models\Page::oneOrNew(intval($page));
     } else {
         $page = rtrim($page, '/');
         $row = \Components\Wiki\Models\Page::oneByPagename($page, $this->domain, $this->domain_id);
     }
     if (!$row->exists()) {
         return '(Page(' . $et . ') failed)';
     }
     if ($nolink) {
         return stripslashes($row->get('title', $row->get('pagename')));
     }
     // Build and return the link
     return '<a href="' . Route::url($row->link()) . '">' . stripslashes($row->get('title', $row->get('pagename'))) . '</a>';
 }