/** * Generate macro output * * @return string */ public function render() { $et = $this->args; $live_site = rtrim(Request::base(), '/'); // What pages are we getting? if ($et) { $et = strip_tags($et); // Get pages with a prefix $sql = "SELECT * FROM `#__wiki_attachments` WHERE LOWER(filename) LIKE '" . strtolower($et) . "%' AND pageid='" . $this->pageid . "' ORDER BY created ASC"; } else { // Get all pages $sql = "SELECT * FROM `#__wiki_attachments` WHERE pageid='" . $this->pageid . "' ORDER BY created ASC"; } // Perform query $this->_db->setQuery($sql); $rows = $this->_db->loadObjectList(); // Did we get a result from the database? if ($rows) { $config = Component::params('com_wiki'); if ($this->filepath != '') { $config->set('filepath', $this->filepath); } $page = new \Components\Wiki\Models\Page($this->pageid); if ($page->get('namespace') == 'help') { $page->set('scope', $page->get('scope') ? rtrim($this->scope, '/') . '/' . ltrim($page->get('scope'), '/') : $this->scope); $page->set('group_cn', $this->domain); } // Build and return the link $html = '<ul>'; foreach ($rows as $row) { $page->set('pagename', $page->get('pagename') . '/' . 'File:' . $row->filename); $link = $page->link(); //$live_site . substr(PATH_APP, strlen(PATH_ROOT)) . DS . trim($config->get('filepath', '/site/wiki'), DS) . DS . $this->pageid . DS . $row->filename; $fpath = PATH_APP . DS . trim($config->get('filepath', '/site/wiki'), DS) . DS . $this->pageid . DS . $row->filename; $html .= '<li><a href="' . Route::url($link) . '">' . $row->filename . '</a> (' . (file_exists($fpath) ? \Hubzero\Utility\Number::formatBytes(filesize($fpath)) : '-- file not found --') . ') '; $huser = User::getInstance($row->created_by); if ($huser->get('id')) { $html .= '- added by <a href="' . Route::url('index.php?option=com_members&id=' . $huser->get('id')) . '">' . stripslashes($huser->get('name')) . '</a> '; } if ($row->created && $row->created != '0000-00-00 00:00:00') { $html .= Date::of($row->created)->relative() . '. '; } $html .= $row->description ? '<span>"' . stripslashes($row->description) . '"</span>' : ''; $html .= '</li>' . "\n"; } $html .= '</ul>'; return $html; } else { // Return error message //return '(TitleIndex('.$et.') failed)'; return '(No ' . $et . ' files to display)'; } }
/** * Generate macro output * * @return string */ public function render() { $et = $this->args; $sort = ''; if ($et) { $et = strip_tags($et); if (strstr($et, ',')) { $attribs = explode(',', $et); $et = trim($attribs[0]); $sort = strtolower(trim($attribs[1])); } if (strtolower($et) == 'sort=modified' || strtolower($et) == 'sort=created' || strtolower($et) == 'sort=title') { $sort = $et; $et = ''; } } // What pages are we getting? switch ($sort) { case 'sort=modified': $sql = "SELECT p.`id`, p.`pagename`, p.`scope`, p.`group_cn`, (CASE WHEN (p.`title` IS NOT NULL AND p.`title` !='') THEN p.`title` ELSE p.`pagename` END) AS `title`, MAX(v.`created`) AS `modified`, MAX(v.`version`) FROM `#__wiki_page` AS p, `#__wiki_version` AS v WHERE v.pageid=p.id AND v.approved=1 AND p.state < 2 AND "; break; case 'sort=created': case 'sort=title': default: $sql = "SELECT p.`id`, p.`pagename`, p.`scope`, p.`group_cn`, (CASE WHEN (p.`title` IS NOT NULL AND p.`title` !='') THEN p.`title` ELSE p.`pagename` END) AS `title`, v.`created`, MAX(v.`version`) FROM `#__wiki_page` AS p, `#__wiki_version` AS v WHERE v.pageid=p.id AND v.approved=1 AND p.state < 2 AND "; break; } if ($et) { // Get pages with a prefix if ($this->domain && substr(strtolower($et), 0, 4) != 'help') { $sql .= "LOWER(p.pagename) LIKE '" . strtolower($et) . "%' AND p.`group_cn`=" . $this->_db->quote($this->domain); } else { $sql .= "LOWER(p.pagename) LIKE '" . strtolower($et) . "%' AND (p.`group_cn`='' OR p.`group_cn` IS NULL)"; } } else { // Get all pages if ($this->domain) { $sql .= "p.`group_cn`=" . $this->_db->quote($this->domain); } else { $sql .= "(p.`group_cn`='' OR p.`group_cn` IS NULL)"; } } switch ($sort) { case 'sort=created': $sql .= " GROUP BY v.pageid ORDER BY `created` ASC"; break; case 'sort=modified': $sql .= " GROUP BY v.pageid ORDER BY `modified` DESC"; break; case 'sort=title': default: $sql .= " GROUP BY v.pageid ORDER BY `title` ASC, `pagename` ASC"; break; } // Perform query $this->_db->setQuery($sql); $rows = $this->_db->loadObjectList(); // Did we get a result from the database? if ($rows) { // Build and return the link $html = '<ul>'; foreach ($rows as $row) { if ($row->pagename == $this->pagename) { continue; } $row = new \Components\Wiki\Models\Page($row); if ($row->get('namespace') == 'help') { $row->set('scope', $row->get('scope') ? rtrim($this->scope, '/') . '/' . ltrim($row->get('scope'), '/') : $this->scope); $row->set('group_cn', $this->domain); } $html .= '<li><a href="' . Route::url($row->link()) . '">'; $html .= stripslashes($row->get('title', $row->get('pagename'))); $html .= '</a></li>' . "\n"; } $html .= '</ul>'; return $html; } else { // Return error message return '(No ' . $et . ' pages to display)'; } }
} $this->js('wiki.js', 'com_wiki')->js('jquery.fileuploader.js', 'system'); $tags = $this->page->tags('string'); if ($this->page->exists()) { $lid = $this->page->get('id'); } else { $lid = Request::getInt('lid', time() . rand(0, 10000), 'post'); } $db = App::get('db'); $tbl = new \Components\Wiki\Tables\Page($db); $db->setQuery($tbl->buildQuery(array('search' => 'Help:WikiMacros', 'sort' => 'title', 'sort_Dir' => 'asc', 'limit' => 1, 'start' => 0))); $macros = new \Components\Wiki\Models\Page($db->loadObject()); $macros->set('group_cn', null); $db->setQuery($tbl->buildQuery(array('search' => 'Help:WikiFormatting', 'sort' => 'title', 'sort_Dir' => 'asc', 'limit' => 1, 'start' => 0))); $formatting = new \Components\Wiki\Models\Page($db->loadObject()); $formatting->set('group_cn', null); ?> <header id="<?php echo $this->sub ? 'sub-content-header' : 'content-header'; ?> "> <h2><?php echo $this->escape($this->title); ?> </h2> <?php //if ($this->page->exists()) //{ $this->view('authors')->setBasePath($this->base_path)->set('page', $this->page)->display(); //} ?>