/** * Generate macro output * * @return string */ public function render() { // Perform query $this->_db->setQuery("SELECT * FROM `#__wiki_page` WHERE state < 2 ORDER BY rand() LIMIT 1"); $a = $this->_db->loadObject(); // Did we get a result from the database? if ($a) { $row = new \Components\Wiki\Models\Page($a); // Build and return the link return '<a href="' . Route::url($row->link()) . '">' . $row->get('title', $row->get('pagename')) . '</a>'; } }
/** * 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; 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 $page = intval($page); } else { $page = trim($page, DS); if (strstr($page, '/')) { $bits = explode('/', $page); $page = array_pop($bits); $scope = implode('/', $bits); } } if ($this->domain != '' && $scope == '') { $scope = $this->scope; } // No, get resource by alias $row = new \Components\Wiki\Models\Page($page, $scope); if (!$row->exists()) { return '(Page(' . $et . ') failed)'; } if ($nolink) { return stripslashes($row->get('title', $row->get('pagename'))); } else { // Build and return the link return '<a href="' . Route::url($row->link()) . '">' . stripslashes($row->get('title', $row->get('pagename'))) . '</a>'; } }
echo Lang::txt('COM_WIKI_COL_LENGTH'); ?> </th> </tr> </thead> <tbody> <?php if ($rows) { foreach ($rows as $row) { $name = Lang::txt('COM_WIKI_UNKNOWN'); $xprofile = \Hubzero\User\Profile::getInstance($row->created_by); if (is_object($xprofile)) { $name = $this->escape(stripslashes($xprofile->get('name'))); $name = $xprofile->get('public') ? '<a href="' . Route::url($xprofile->getLink()) . '">' . $name . '</a>' : $name; } $row = new \Components\Wiki\Models\Page($row); ?> <tr> <td> <time datetime="<?php echo $row->get('created'); ?> "><?php echo $row->get('created'); ?> </time> </td> <td> <a href="<?php echo Route::url($row->link()); ?>
/** * Generate macro output * * @return string */ public function render() { $limit = 1; $cls = ''; $limitstart = 0; if ($this->args) { $args = explode(',', $this->args); if (isset($args[0])) { $args[0] = intval($args[0]); if ($args[0]) { $limit = $args[0]; } } if (isset($args[1])) { $cls = $args[1]; } if (isset($args[2])) { $args[2] = intval($args[2]); if ($args[2]) { $limitstart = $args[2]; } } } $query = "SELECT wv.pageid, wp.title, wp.pagename, wp.scope, wp.group_cn, wp.access, wv.version, wv.created_by, wv.created, wv.pagehtml\n\t\t\t\t\tFROM `#__wiki_version` AS wv\n\t\t\t\t\tINNER JOIN `#__wiki_page` AS wp\n\t\t\t\t\t\tON wp.id = wv.pageid\n\t\t\t\t\tWHERE wv.approved = 1\n\t\t\t\t\t\tAND wp.group_cn = '{$this->domain}'\n\t\t\t\t\t\tAND wp.scope = '{$this->scope}'\n\t\t\t\t\t\tAND wp.access != 1\n\t\t\t\t\t\tAND wp.state < 2\n\t\t\t\t\t\tAND wv.id = (SELECT MAX(wv2.id) FROM `#__wiki_version` AS wv2 WHERE wv2.pageid = wv.pageid)\n\t\t\t\t\tORDER BY created DESC\n\t\t\t\t\tLIMIT {$limitstart}, {$limit}"; // Perform query $this->_db->setQuery($query); $rows = $this->_db->loadObjectList(); $html = ''; // Did we get a result from the database? if ($rows) { foreach ($rows as $row) { $row = new \Components\Wiki\Models\Page($row); $html .= '<div'; if ($cls) { $html .= ' class="' . $cls . '"'; } $html .= '>' . "\n"; $html .= "\t" . '<h3><a href="' . Route::url($row->link()) . '">' . stripslashes($row->get('title', $row->get('pagename'))) . '</a></h3>' . "\n"; $html .= "\t" . '<p class="modified-date">'; if ($row->get('version') > 1) { $html .= Lang::txt('PLG_WIKI_PARSERDEFAULT_MODIFIED_ON', Date::of($row->get('created'))->toLocal(Lang::txt('DATE_FORMAT_HZ1'))); } else { $html .= Lang::txt('PLG_WIKI_PARSERDEFAULT_CREATED_ON', Date::of($row->get('created'))->toLocal(Lang::txt('DATE_FORMAT_HZ1'))); } $html .= '</p>' . "\n"; $html .= $this->_shortenText($row->get('pagehtml')); $html .= "\t" . '<p><a href="' . Route::url($row->link()) . '">' . Lang::txt('PLG_WIKI_PARSERDEFAULT_READ_MORE') . '</a></p>' . "\n"; $html .= '</div>' . "\n"; } } else { $html .= '<p class="warning">' . Lang::txt('PLG_WIKI_PARSERDEFAULT_NO_RESULTS') . '</p>' . "\n"; } return $html; }
?> </h3> <ul> <?php } else { if ($k == 0) { ?> <h3><?php echo Lang::txt('COM_WIKI_INDEX_CONTINUED', $index); ?> </h3> <ul> <?php } } $row = new \Components\Wiki\Models\Page($row); ?> <li> <a href="<?php echo Route::url($row->link()); ?> "> <?php echo $this->escape(stripslashes($row->get('title'))); ?> </a> </li> <?php $k++; } ?>
/** * List children of a page * * @param integer $currentDepth How far down the tree we are * @param integer $targetDepth How far down the tree to go * @param integer $pageid * @return string HMTL */ private function listChildren($currentDepth, $targetDepth, $pageid) { $html = ''; if ($currentDepth > $targetDepth) { return $html; } $rows = \Components\Wiki\Models\Page::all()->whereEquals('parent', $pageid)->whereEquals('state', 1)->rows(); if ($rows->count()) { $html = '<ul>'; foreach ($rows as $row) { $row = new \Components\Wiki\Models\Page($row); $html .= '<li><a href="' . Route::url($row->link()) . '">'; $html .= stripslashes($row->get('title', $row->get('pagename'))); $html .= '</a>'; $html .= $this->listChildren($currentDepth + 1, $targetDepth, $row->get('id')); $html .= '</li>' . "\n"; } $html .= '</ul>'; } elseif ($currentDepth == 1) { // Return error message return '<p>(No sub-pages to display)</p>'; } return $html; }
/** * 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->css(); } $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(); //}
/** * List children of a page * * @param integer $currentDepth How far down the tree we are * @param integer $targetDepth How far down the tree to go * @param string $scope Page scope * @return string HMTL */ private function listChildren($currentDepth, $targetDepth, $scope = '') { $html = ''; if ($currentDepth > $targetDepth) { return $html; } $rows = $this->getchildren($scope); if ($rows) { $html = '<ul>'; foreach ($rows as $row) { $row = new \Components\Wiki\Models\Page($row); $html .= '<li><a href="' . Route::url($row->link()) . '">'; $html .= stripslashes($row->get('title', $row->get('pagename'))); $html .= '</a>'; $html .= $this->listChildren($currentDepth + 1, $targetDepth, $row->get('scope') . '/' . $row->get('pagename')); $html .= '</li>' . "\n"; } $html .= '</ul>'; } elseif ($currentDepth == 1) { // Return error message return '<p>(No sub-pages to display)</p>'; } return $html; }
/** * Build a tree of parents * * @param array $rows An array of objects * @return string */ private function _buildTree($rows) { $html = ''; if ($rows && count($rows) > 0) { // Get the last element in the array $row = array_pop($rows); $row = new \Components\Wiki\Models\Page($row); // Build the HTML $html .= '<ul>'; $html .= '<li><a href="' . Route::url($row->link()) . '">'; $html .= stripslashes($row->get('title', $row->get('pagename'))); $html .= '</a>'; $html .= $this->_buildTree($rows); $html .= '</li>' . "\n"; $html .= '</ul>'; } return $html; }