AAAAviews/.htaccess000066600000000177151371544250007517 0ustar00 Order allow,deny Deny from all views/index.html000066600000000037151371544250007711 0ustar00 views/categories/view.html.php000066600000005361151371544250012474 0ustar00get('State'); $items = $this->get('Items'); $parent = $this->get('Parent'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } if($items === false) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } if($parent == false) { return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } $params = &$state->params; $items = array($parent->id => $items); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->maxLevelcat = $params->get('maxLevelcat', -1); $this->assignRef('params', $params); $this->assignRef('parent', $parent); $this->assignRef('items', $items); $this->_prepareDocument(); parent::display($tpl); } /** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('COM_WEBLINKS_DEFAULT_PAGE_TITLE')); } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } $this->document->setTitle($title); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } } views/categories/index.html000066600000000037151371544250012036 0ustar00 views/categories/tmpl/default.php000066600000002437151371544250013160 0ustar00
params->get('show_page_heading')) : ?>

escape($this->params->get('page_heading')); ?>

params->get('show_base_description')) : ?> params->get('categories_description')) : ?>
params->get('categories_description'), '', 'com_weblinks.categories'); ?>
parent->description) : ?>
parent->description, '', 'com_weblinks.categories'); ?>
loadTemplate('items'); ?>
views/categories/tmpl/default.xml000066600000015607151371544250013174 0ustar00
views/categories/tmpl/index.html000066600000000037151371544250013012 0ustar00 views/categories/tmpl/.htaccess000066600000000177151371544250012620 0ustar00 Order allow,deny Deny from all views/categories/tmpl/default_items.php000066600000003273151371544250014360 0ustar00items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) : ?> views/categories/.htaccess000066600000000177151371544250011644 0ustar00 Order allow,deny Deny from all views/category/view.html.php000066600000015045151371544250012164 0ustar00getParams(); // Get some data from the models $state = $this->get('State'); $items = $this->get('Items'); $category = $this->get('Category'); $children = $this->get('Children'); $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } if ($category == false) { return JError::raiseWarning(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } if ($parent == false) { return JError::raiseWarning(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND')); } // Check whether category access level allows access. // TODO: SHould already be computed in $category->params->get('access-view') $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); if (!in_array($category->access, $groups)) { return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); } // Prepare the data. // Compute the weblink slug & link url. for ($i = 0, $n = count($items); $i < $n; $i++) { $item = &$items[$i]; $item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id; if ($item->params->get('count_clicks', $params->get('count_clicks')) == 1) { $item->link = JRoute::_('index.php?option=com_weblinks&task=weblink.go&id='. $item->id); } else { $item->link = $item->url; } $temp = new JRegistry(); $temp->loadString($item->params); $item->params = clone($params); $item->params->merge($temp); } // Setup the category parameters. $cparams = $category->getParams(); $category->params = clone($params); $category->params->merge($cparams); $children = array($category->id => $children); $maxLevel = $params->get('maxLevel', -1); $this->assignRef('maxLevel', $maxLevel); $this->assignRef('state', $state); $this->assignRef('items', $items); $this->assignRef('category', $category); $this->assignRef('children', $children); $this->assignRef('params', $params); $this->assignRef('parent', $parent); $this->assignRef('pagination', $pagination); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); // Check for layout override only if this is not the active menu item // If it is the active menu item, then the view and category id will match $active = $app->getMenu()->getActive(); if ((!$active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $this->category->id) === false))) { if ($layout = $category->params->get('category_layout')) { $this->setLayout($layout); } } elseif (isset($active->query['layout'])) { // We need to set the layout in case this is an alternative menu item (with an alternative layout) $this->setLayout($active->query['layout']); } $this->_prepareDocument(); parent::display($tpl); } /** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('COM_WEBLINKS_DEFAULT_PAGE_TITLE')); } $id = (int) @$menu->query['id']; if ($menu && ($menu->query['option'] != 'com_weblinks' || $id != $this->category->id)) { $this->params->set('page_subheading', $this->category->title); $path = array(array('title' => $this->category->title, 'link' => '')); $category = $this->category->getParent(); while (($menu->query['option'] != 'com_weblinks' || $id != $category->id) && $category->id > 1) { $path[] = array('title' => $category->title, 'link' => WeblinksHelperRoute::getCategoryRoute($category->id)); $category = $category->getParent(); } $path = array_reverse($path); foreach($path as $item) { $pathway->addItem($item['title'], $item['link']); } } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $app->getCfg('sitename'); } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } $this->document->setTitle($title); if ($this->category->metadesc) { $this->document->setDescription($this->category->metadesc); } elseif (!$this->category->metadesc && $this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->category->metakey) { $this->document->setMetadata('keywords', $this->category->metakey); } elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } if ($app->getCfg('MetaAuthor') == '1') { $this->document->setMetaData('author', $this->category->getMetadata()->get('author')); } $mdata = $this->category->getMetadata()->toArray(); foreach ($mdata as $k => $v) { if ($v) { $this->document->setMetadata($k, $v); } } // Add alternative feed link if ($this->params->get('show_feed_link', 1) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs); } } } views/category/view.feed.php000066600000004303151371544250012116 0ustar00link = JRoute::_(WeblinksHelperRoute::getCategoryRoute(JRequest::getVar('id', null, '', 'int'))); JRequest::setVar('limit', $app->getCfg('feed_limit')); $params = $app->getParams(); $siteEmail = $app->getCfg('mailfrom'); $fromName = $app->getCfg('fromname'); $feedEmail = $app->getCfg('feed_email', 'author'); $document->editor = $fromName; if ($feedEmail != "none") { $document->editorEmail = $siteEmail; } // Get some data from the model $items = $this->get('Items'); $category = $this->get('Category'); foreach ($items as $item) { // strip html from feed item title $title = $this->escape($item->title); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // url link to article $link = JRoute::_(WeblinksHelperRoute::getWeblinkRoute($item->id, $item->catid)); // strip html from feed item description text $description = $item->description; $author = $item->created_by_alias ? $item->created_by_alias : $item->author; $date = ($item->date ? date('r', strtotime($item->date)) : ''); // load individual item creator class $feeditem = new JFeedItem(); $feeditem->title = $title; $feeditem->link = $link; $feeditem->description = $description; $feeditem->date = $date; $feeditem->category = $category->title; $feeditem->author = $author; // We don't have the author email so we have to use site in both cases. if ($feedEmail == 'site') { $feeditem->authorEmail = $siteEmail; } elseif($feedEmail === 'author') { $feeditem->authorEmail = $item->author_email; } // loads item info into rss array $document->addItem($feeditem); } } } ?> views/category/tmpl/default.xml000066600000012442151371544250012656 0ustar00
views/category/tmpl/default.php000066600000003122151371544250012640 0ustar00 views/category/tmpl/default_children.php000066600000003353151371544250014516 0ustar00children[$this->category->id]) > 0 && $this->maxLevel != 0) : ?> views/category/tmpl/.htaccess000066600000000177151371544250012310 0ustar00 Order allow,deny Deny from all views/category/tmpl/default_items.php000066600000013172151371544250014047 0ustar00item->params; JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); JHtml::_('behavior.tooltip'); JHtml::_('behavior.framework'); // Get the user object. $user = JFactory::getUser(); // Check if user is allowed to add/edit based on weblinks permissinos. $canEdit = $user->authorise('core.edit', 'com_weblinks'); $canCreate = $user->authorise('core.create', 'com_weblinks'); $canEditState = $user->authorise('core.edit.state', 'com_weblinks'); $n = count($this->items); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?> items)) : ?>

params->get('show_pagination_limit')) : ?>
  pagination->getLimitBox(); ?>
params->get('show_headings')==1) : ?> params->get('show_link_hits')) : ?> items as $i => $item) : ?> items[$i]->state == 0) : ?> params->get('show_link_hits')) : ?>

params->get('icons') == 0) : ?> params->get('icons') == 1) : ?> params->get('link_icons')) : ?> params->get('link_icons', 'weblink.png'), JText::_('COM_WEBLINKS_LINK'), NULL, true); ?> params->get('link_icons').'" alt="'.JText::_('COM_WEBLINKS_LINK').'" />'; ?> pageclass_sfx; $link = $item->link; $width = $item->params->get('width'); $height = $item->params->get('height'); if ($width == null || $height == null) { $width = 600; $height = 500; } switch ($item->params->get('target', $this->params->get('target'))) { case 1: // open in a new window echo ''. $this->escape($item->title) .''; break; case 2: // open in a popup window $attribs = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='.$this->escape($width).',height='.$this->escape($height).''; echo "". $this->escape($item->title).''; break; case 3: // open in a modal window JHtml::_('behavior.modal', 'a.modal'); ?> escape($item->title). ' ' ; break; default: // open in parent window echo ''. $this->escape($item->title) . ' '; break; } ?>

params->get('show_link_description')) and ($item->description !='')): ?> description; ?>
hits; ?>
params); ?> params->get('show_pagination')) : ?>
views/category/metadata.xml000066600000000221151371544250012026 0ustar00 views/category/.htaccess000066600000000177151371544250011334 0ustar00 Order allow,deny Deny from all views/category/index.html000066600000000037151371544250011526 0ustar00 views/weblink/view.html.php000066600000001750151371544250012000 0ustar00getParams(); // Get some data from the models $state = $this->get('State'); $item = $this->get('Item'); $category = $this->get('Category'); if ($this->getLayout() == 'edit') { $this->_displayEdit($tpl); return; } if ($item->url) { // redirects to url if matching id found $app->redirect($item->url); } else { //TODO create proper error handling $app->redirect(JRoute::_('index.php'), JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND'), 'notice'); } } } views/weblink/index.html000066600000000037151371544250011344 0ustar00 views/weblink/tmpl/index.html000066600000000037151371544250012320 0ustar00 views/weblink/tmpl/.htaccess000066600000000177151371544250012126 0ustar00 Order allow,deny Deny from all views/weblink/.htaccess000066600000000177151371544250011152 0ustar00 Order allow,deny Deny from all views/form/tmpl/.htaccess000066600000000177151371544250011436 0ustar00 Order allow,deny Deny from all views/form/tmpl/index.html000066600000000037151371544250011630 0ustar00 views/form/tmpl/edit.xml000066600000000470151371544250011303 0ustar00 views/form/tmpl/edit.php000066600000005376151371544250011304 0ustar00state->get('params'); ?>
params->get('show_page_heading')) : ?>

escape($this->params->get('page_heading')); ?>

form->getLabel('title'); ?> form->getInput('title'); ?>
form->getLabel('alias'); ?> form->getInput('alias'); ?>
form->getLabel('catid'); ?> form->getInput('catid'); ?>
form->getLabel('url'); ?> form->getInput('url'); ?>
user->authorise('core.edit.state', 'com_weblinks.weblink')): ?>
form->getLabel('state'); ?> form->getInput('state'); ?>
form->getLabel('language'); ?> form->getInput('language'); ?>
form->getLabel('description'); ?> form->getInput('description'); ?>
views/form/.htaccess000066600000000177151371544250010462 0ustar00 Order allow,deny Deny from all views/form/index.html000066600000000037151371544250010654 0ustar00 views/form/metadata.xml000066600000000217151371544250011161 0ustar00 views/form/view.html.php000066600000006017151371544250011311 0ustar00state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->return_page = $this->get('ReturnPage'); if (empty($this->item->id)) { $authorised = ($user->authorise('core.create', 'com_weblinks') || (count($user->getAuthorisedCategories('com_weblinks', 'core.create')))); } else { $authorised = $user->authorise('core.edit', 'com_weblinks.weblink.'.$this->item->id); } if ($authorised !== true) { JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); return false; } if (!empty($this->item)) { $this->form->bind($this->item); } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // Create a shortcut to the parameters. $params = &$this->state->params; //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->params = $params; $this->user = $user; $this->_prepareDocument(); parent::display($tpl); } /** * Prepares the document */ protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if (empty($this->item->id)) { $head = JText::_('COM_WEBLINKS_FORM_SUBMIT_WEBLINK'); } else { $head = JText::_('COM_WEBLINKS_FORM_EDIT_WEBLINK'); } if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', $head); } $title = $this->params->def('page_title', $head); if ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title); } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename')); } $this->document->setTitle($title); if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } } router.php000066600000011563151371544250006616 0ustar00getMenu(); $params = JComponentHelper::getParams('com_weblinks'); $advanced = $params->get('sef_advanced_link', 0); // we need a menu item. Either the one specified in the query, or the current active one if none specified if (empty($query['Itemid'])) { $menuItem = $menu->getActive(); } else { $menuItem = $menu->getItem($query['Itemid']); } $mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view']; $mCatid = (empty($menuItem->query['catid'])) ? null : $menuItem->query['catid']; $mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id']; if (isset($query['view'])) { $view = $query['view']; if (empty($query['Itemid'])) { $segments[] = $query['view']; } // We need to keep the view for forms since they never have their own menu item if ($view != 'form') { unset($query['view']); } } // are we dealing with an weblink that is attached to a menu item? if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == intval($query['id']))) { unset($query['view']); unset($query['catid']); unset($query['id']); return $segments; } if (isset($view) and ($view == 'category' or $view == 'weblink' )) { if ($mId != intval($query['id']) || $mView != $view) { if ($view == 'weblink' && isset($query['catid'])) { $catid = $query['catid']; } elseif (isset($query['id'])) { $catid = $query['id']; } $menuCatid = $mId; $categories = JCategories::getInstance('Weblinks'); $category = $categories->get($catid); if ($category) { //TODO Throw error that the category either not exists or is unpublished $path = $category->getPath(); $path = array_reverse($path); $array = array(); foreach($path as $id) { if ((int) $id == (int)$menuCatid) { break; } if ($advanced) { list($tmp, $id) = explode(':', $id, 2); } $array[] = $id; } $segments = array_merge($segments, array_reverse($array)); } if ($view == 'weblink') { if ($advanced) { list($tmp, $id) = explode(':', $query['id'], 2); } else { $id = $query['id']; } $segments[] = $id; } } unset($query['id']); unset($query['catid']); } if (isset($query['layout'])) { if (!empty($query['Itemid']) && isset($menuItem->query['layout'])) { if ($query['layout'] == $menuItem->query['layout']) { unset($query['layout']); } } else { if ($query['layout'] == 'default') { unset($query['layout']); } } }; return $segments; } /** * Parse the segments of a URL. * * @param array The segments of the URL to parse. * * @return array The URL attributes to be used by the application. */ function WeblinksParseRoute($segments) { $vars = array(); //Get the active menu item. $app = JFactory::getApplication(); $menu = $app->getMenu(); $item = $menu->getActive(); $params = JComponentHelper::getParams('com_weblinks'); $advanced = $params->get('sef_advanced_link', 0); // Count route segments $count = count($segments); // Standard routing for weblinks. if (!isset($item)) { $vars['view'] = $segments[0]; $vars['id'] = $segments[$count - 1]; return $vars; } // From the categories view, we can only jump to a category. $id = (isset($item->query['id']) && $item->query['id'] > 1) ? $item->query['id'] : 'root'; $category = JCategories::getInstance('Weblinks')->get($id); $categories = $category->getChildren(); $found = 0; foreach($segments as $segment) { foreach($categories as $category) { if (($category->slug == $segment) || ($advanced && $category->alias == str_replace(':', '-', $segment))) { $vars['id'] = $category->id; $vars['view'] = 'category'; $categories = $category->getChildren(); $found = 1; break; } } if ($found == 0) { if ($advanced) { $db = JFactory::getDBO(); $query = 'SELECT id FROM #__weblinks WHERE catid = '.$vars['id'].' AND alias = '.$db->Quote(str_replace(':', '-', $segment)); $db->setQuery($query); $id = $db->loadResult(); } else { $id = $segment; } $vars['id'] = $id; $vars['view'] = 'weblink'; break; } $found = 0; } return $vars; } weblinks.php000066600000000671151371544250007112 0ustar00execute(JRequest::getCmd('task')); $controller->redirect(); models/weblink.php000066600000004346151371544250010215 0ustar00getParams(); // Load the object state. $id = JRequest::getInt('id'); $this->setState('weblink.id', $id); // Load the parameters. $this->setState('params', $params); } /** * Method to get an ojbect. * * @param integer The id of the object to get. * * @return mixed Object on success, false on failure. */ public function &getItem($id = null) { if ($this->_item === null) { $this->_item = false; if (empty($id)) { $id = $this->getState('weblink.id'); } // Get a level row instance. $table = JTable::getInstance('Weblink', 'WeblinksTable'); // Attempt to load the row. if ($table->load($id)) { // Check published state. if ($published = $this->getState('filter.published')) { if ($table->state != $published) { return $this->_item; } } // Convert the JTable to a clean JObject. $properties = $table->getProperties(1); $this->_item = JArrayHelper::toObject($properties, 'JObject'); } elseif ($error = $table->getError()) { $this->setError($error); } } return $this->_item; } /** * Method to increment the hit counter for the weblink * * @param int Optional ID of the weblink. * @return boolean True on success * @since 1.5 */ public function hit($id = null) { if (empty($id)) { $id = $this->getState('weblink.id'); } $weblink = $this->getTable('Weblink', 'WeblinksTable'); return $weblink->hit($id); } } models/categories.php000066600000005673151371544250010713 0ustar00setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = JRequest::getInt('id'); $this->setState('filter.parentId', $parentId); $params = $app->getParams(); $this->setState('params', $params); $this->setState('filter.published', 1); $this->setState('filter.access', true); } /** * Method to get a store id based on model configuration state. * * This is necessary because the model is used by the component and * different modules that might need different sets of data or different * ordering requirements. * * @param string $id A prefix for the store id. * * @return string A store id. */ protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.extension'); $id .= ':'.$this->getState('filter.published'); $id .= ':'.$this->getState('filter.access'); $id .= ':'.$this->getState('filter.parentId'); return parent::getStoreId($id); } /** * redefine the function an add some properties to make the styling more easy * * @return mixed An array of data items on success, false on failure. */ public function getItems() { if(!count($this->_items)) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $params = new JRegistry(); if($active) { $params->loadString($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_num_links', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Weblinks', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if(is_object($this->_parent)) { $this->_items = $this->_parent->getChildren(); } else { $this->_items = false; } } return $this->_items; } public function getParent() { if(!is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } } models/.htaccess000066600000000177151371544250007645 0ustar00 Order allow,deny Deny from all models/category.php000066600000017405151371544250010377 0ustar00_params)) { $params = new JRegistry; $params->loadString($items[$i]->params); $items[$i]->params = $params; } } return $items; } /** * Method to build an SQL query to load the list data. * * @return string An SQL query * @since 1.6 */ protected function getListQuery() { $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select required fields from the categories. $query->select($this->getState('list.select', 'a.*')); $query->from($db->quoteName('#__weblinks').' AS a'); $query->where('a.access IN ('.$groups.')'); // Filter by category. if ($categoryId = $this->getState('category.id')) { $query->where('a.catid = '.(int) $categoryId); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); $query->where('c.access IN ('.$groups.')'); //Filter by published category $cpublished = $this->getState('filter.c.published'); if (is_numeric($cpublished)) { $query->where('c.published = '.(int) $cpublished); } } // Join over the users for the author and modified_by names. $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author"); $query->select("ua.email AS author_email"); $query->join('LEFT', '#__users AS ua ON ua.id = a.created_by'); $query->join('LEFT', '#__users AS uam ON uam.id = a.modified_by'); // Filter by state $state = $this->getState('filter.state'); if (is_numeric($state)) { $query->where('a.state = '.(int) $state); } // do not show trashed links on the front-end $query->where('a.state != -2'); // Filter by start and end dates. $nullDate = $db->Quote($db->getNullDate()); $date = JFactory::getDate(); $nowDate = $db->Quote($date->toSql()); if ($this->getState('filter.publish_date')){ $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')'); $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by language if ($this->getState('filter.language')) { $query->where('a.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'); } // Add the list ordering clause. $query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC'))); return $query; } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { // Initialise variables. $app = JFactory::getApplication(); $params = JComponentHelper::getParams('com_weblinks'); // List state information $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint'); $this->setState('list.limit', $limit); $limitstart = JRequest::getUInt('limitstart', 0); $this->setState('list.start', $limitstart); $orderCol = JRequest::getCmd('filter_order', 'ordering'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = JRequest::getCmd('filter_order_Dir', 'ASC'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $id = JRequest::getVar('id', 0, '', 'int'); $this->setState('category.id', $id); $user = JFactory::getUser(); if ((!$user->authorise('core.edit.state', 'com_weblinks')) && (!$user->authorise('core.edit', 'com_weblinks'))){ // limit to published for people who can't edit or edit.state. $this->setState('filter.state', 1); // Filter by start and end dates. $this->setState('filter.publish_date', true); } $this->setState('filter.language', $app->getLanguageFilter()); // Load the parameters. $this->setState('params', $params); } /** * Method to get category data for the current category * * @param int An optional ID * * @return object * @since 1.5 */ public function getCategory() { if(!is_object($this->_item)) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $params = new JRegistry(); if($active) { $params->loadString($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_num_links_cat', 1) || $params->get('show_empty_categories', 0); $categories = JCategories::getInstance('Weblinks', $options); $this->_item = $categories->get($this->getState('category.id', 'root')); if(is_object($this->_item)) { $this->_children = $this->_item->getChildren(); $this->_parent = false; if($this->_item->getParent()) { $this->_parent = $this->_item->getParent(); } $this->_rightsibling = $this->_item->getSibling(); $this->_leftsibling = $this->_item->getSibling(false); } else { $this->_children = false; $this->_parent = false; } } return $this->_item; } /** * Get the parent categorie. * * @param int An optional category id. If not supplied, the model state 'category.id' will be used. * * @return mixed An array of categories or false if an error occurs. */ public function getParent() { if(!is_object($this->_item)) { $this->getCategory(); } return $this->_parent; } /** * Get the sibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. */ function &getLeftSibling() { if(!is_object($this->_item)) { $this->getCategory(); } return $this->_leftsibling; } function &getRightSibling() { if(!is_object($this->_item)) { $this->getCategory(); } return $this->_rightsibling; } /** * Get the child categories. * * @param int An optional category id. If not supplied, the model state 'category.id' will be used. * * @return mixed An array of categories or false if an error occurs. */ function &getChildren() { if(!is_object($this->_item)) { $this->getCategory(); } return $this->_children; } } models/index.html000066600000000037151371544250010037 0ustar00 models/forms/index.html000066600000000037151371544250011165 0ustar00 models/forms/weblink.xml000066600000002753151371544250011354 0ustar00
models/forms/.htaccess000066600000000177151371544250010773 0ustar00 Order allow,deny Deny from all models/form.php000066600000003035151371544250007517 0ustar00getState('return_page')); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ protected function populateState() { $app = JFactory::getApplication(); // Load state from the request. $pk = JRequest::getInt('w_id'); $this->setState('weblink.id', $pk); // Add compatibility variable for default naming conventions. $this->setState('form.id', $pk); $categoryId = JRequest::getInt('catid'); $this->setState('weblink.catid', $categoryId); $return = JRequest::getVar('return', null, 'default', 'base64'); if (!JUri::isInternal(base64_decode($return))) { $return = null; } $this->setState('return_page', base64_decode($return)); // Load the parameters. $params = $app->getParams(); $this->setState('params', $params); $this->setState('layout', JRequest::getCmd('layout')); } } index.html000066600000000037151371544250006554 0ustar00 controllers/weblink.php000066600000016360151371544250011277 0ustar00setRedirect($this->getReturnPage()); } } /** * Method override to check if you can add a new record. * * @param array $data An array of input data. * @return boolean * @since 1.6 */ protected function allowAdd($data = array()) { // Initialise variables. $user = JFactory::getUser(); $categoryId = JArrayHelper::getValue($data, 'catid', JRequest::getInt('id'), 'int'); $allow = null; if ($categoryId) { // If the category has been passed in the URL check it. $allow = $user->authorise('core.create', $this->option.'.category.'.$categoryId); } if ($allow === null) { // In the absense of better information, revert to the component permissions. return parent::allowAdd($data); } else { return $allow; } } /** * Method to check if you can add a new record. * * @param array $data An array of input data. * @param string $key The name of the key for the primary key. * * @return boolean * @since 1.6 */ protected function allowEdit($data = array(), $key = 'id') { // Initialise variables. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; $categoryId = 0; if ($recordId) { $categoryId = (int) $this->getModel()->getItem($recordId)->catid; } if ($categoryId) { // The category has been set. Check the category permissions. return JFactory::getUser()->authorise('core.edit', $this->option.'.category.'.$categoryId); } else { // Since there is no asset tracking, revert to the component permissions. return parent::allowEdit($data, $key); } } /** * Method to cancel an edit. * * @param string $key The name of the primary key of the URL variable. * * @return Boolean True if access level checks pass, false otherwise. * @since 1.6 */ public function cancel($key = 'w_id') { parent::cancel($key); // Redirect to the return page. $this->setRedirect($this->getReturnPage()); } /** * Method to edit an existing record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return Boolean True if access level check and checkout passes, false otherwise. * @since 1.6 */ public function edit($key = null, $urlVar = 'w_id') { $result = parent::edit($key, $urlVar); return $result; } /** * Method to get a model object, loading it if required. * * @param string $name The model name. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for model. Optional. * * @return object The model. * @since 1.5 */ public function getModel($name = 'form', $prefix = '', $config = array('ignore_request' => true)) { $model = parent::getModel($name, $prefix, $config); return $model; } /** * Gets the URL arguments to append to an item redirect. * * @param int $recordId The primary key id for the item. * @param string $urlVar The name of the URL variable for the id. * * @return string The arguments to append to the redirect URL. * @since 1.6 */ protected function getRedirectToItemAppend($recordId = null, $urlVar = null) { $append = parent::getRedirectToItemAppend($recordId, $urlVar); $itemId = JRequest::getInt('Itemid'); $return = $this->getReturnPage(); if ($itemId) { $append .= '&Itemid='.$itemId; } if ($return) { $append .= '&return='.base64_encode($return); } return $append; } /** * Get the return URL. * * If a "return" variable has been passed in the request * * @return string The return URL. * @since 1.6 */ protected function getReturnPage() { $return = JRequest::getVar('return', null, 'default', 'base64'); if (empty($return) || !JUri::isInternal(base64_decode($return))) { return JURI::base(); } else { return base64_decode($return); } } /** * Function that allows child controller access to model data after the data has been saved. * * @param JModel $model The data model object. * @param array $validData The validated data. * * @return void * @since 1.6 */ protected function postSaveHook(JModel &$model, $validData = array()) { $task = $this->getTask(); if ($task == 'save') { $this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=category&id='.$validData['catid'], false)); } } /** * Method to save a record. * * @param string $key The name of the primary key of the URL variable. * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). * * @return Boolean True if successful, false otherwise. * @since 1.6 */ public function save($key = null, $urlVar = 'w_id') { $result = parent::save($key, $urlVar); // If ok, redirect to the return page. if ($result) { $this->setRedirect($this->getReturnPage()); } return $result; } /** * Go to a weblink * * @return void * @since 1.6 */ public function go() { // Get the ID from the request $id = JRequest::getInt('id'); // Get the model, requiring published items $modelLink = $this->getModel('Weblink', '', array('ignore_request' => true)); $modelLink->setState('filter.published', 1); // Get the item $link = $modelLink->getItem($id); // Make sure the item was found. if (empty($link)) { return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND')); } // Check whether item access level allows access. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); if (!in_array($link->access, $groups)) { return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); } // Check whether category access level allows access. $modelCat = $this->getModel('Category', 'WeblinksModel', array('ignore_request' => true)); $modelCat->setState('filter.published', 1); // Get the category $category = $modelCat->getCategory($link->catid); // Make sure the category was found. if (empty($category)) { return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_NOT_FOUND')); } // Check whether item access level allows access. if (!in_array($category->access, $groups)) { return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR')); } // Redirect to the URL // TODO: Probably should check for a valid http link if ($link->url) { $modelLink->hit($id); JFactory::getApplication()->redirect($link->url); } else { return JError::raiseWarning(404, JText::_('COM_WEBLINKS_ERROR_WEBLINK_URL_INVALID')); } } } controllers/index.html000066600000000037151371544250011122 0ustar00 controllers/.htaccess000066600000000177151371544250010730 0ustar00 Order allow,deny Deny from all metadata.xml000066600000000075151371544250007063 0ustar00 helpers/.htaccess000066600000000177151371544250010024 0ustar00 Order allow,deny Deny from all helpers/route.php000066600000006551151371544250010077 0ustar00 array((int) $id) ); //Create the link $link = 'index.php?option=com_weblinks&view=weblink&id='. $id; if ($catid > 1) { $categories = JCategories::getInstance('Weblinks'); $category = $categories->get($catid); if($category) { $needles['category'] = array_reverse($category->getPath()); $needles['categories'] = $needles['category']; $link .= '&catid='.$catid; } } if ($item = self::_findItem($needles)) { $link .= '&Itemid='.$item; } return $link; } /** * @param int $id The id of the weblink. * @param string $return The return page variable. */ public static function getFormRoute($id, $return = null) { // Create the link. if ($id) { $link = 'index.php?option=com_weblinks&task=weblink.edit&w_id='. $id; } else { $link = 'index.php?option=com_weblinks&task=weblink.add&w_id=0'; } if ($return) { $link .= '&return='.$return; } return $link; } public static function getCategoryRoute($catid) { if ($catid instanceof JCategoryNode) { $id = $catid->id; $category = $catid; } else { $id = (int) $catid; $category = JCategories::getInstance('Weblinks')->get($id); } if ($id < 1 || !($category instanceof JCategoryNode)) { $link = ''; } else { $needles = array(); //Create the link $link = 'index.php?option=com_weblinks&view=category&id='.$id; $catids = array_reverse($category->getPath()); $needles['category'] = $catids; $needles['categories'] = $catids; if ($item = self::_findItem($needles)) { $link .= '&Itemid='.$item; } } return $link; } protected static function _findItem($needles = null) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); // Prepare the reverse lookup array. if (self::$lookup === null) { self::$lookup = array(); $component = JComponentHelper::getComponent('com_weblinks'); $items = $menus->getItems('component_id', $component->id); if ($items) { foreach ($items as $item) { if (isset($item->query) && isset($item->query['view'])) { $view = $item->query['view']; if (!isset(self::$lookup[$view])) { self::$lookup[$view] = array(); } if (isset($item->query['id'])) { self::$lookup[$view][$item->query['id']] = $item->id; } } } } } if ($needles) { foreach ($needles as $view => $ids) { if (isset(self::$lookup[$view])) { foreach($ids as $id) { if (isset(self::$lookup[$view][(int)$id])) { return self::$lookup[$view][(int)$id]; } } } } } $active = $menus->getActive(); if ($active) { return $active->id; } return null; } } helpers/category.php000066600000001332151371544250010546 0ustar00'.$button.''; return $output; } static function edit($weblink, $params, $attribs = array()) { $user = JFactory::getUser(); $uri = JFactory::getURI(); if ($params && $params->get('popup')) { return; } if ($weblink->state < 0) { return; } JHtml::_('behavior.tooltip'); $url = WeblinksHelperRoute::getFormRoute($weblink->id, base64_encode($uri)); $icon = $weblink->state ? 'edit.png' : 'edit_unpublished.png'; $text = JHtml::_('image', 'system/'.$icon, JText::_('JGLOBAL_EDIT'), NULL, true); if ($weblink->state == 0) { $overlib = JText::_('JUNPUBLISHED'); } else { $overlib = JText::_('JPUBLISHED'); } $date = JHtml::_('date', $weblink->created); $author = $weblink->created_by_alias ? $weblink->created_by_alias : $weblink->author; $overlib .= '<br />'; $overlib .= $date; $overlib .= '<br />'; $overlib .= htmlspecialchars($author, ENT_COMPAT, 'UTF-8'); $button = JHtml::_('link', JRoute::_($url), $text); $output = ''.$button.''; return $output; } } helpers/index.html000066600000000037151371544250010216 0ustar00 controller.php000066600000003541151371544250007456 0ustar00get('id') ||($_SERVER['REQUEST_METHOD'] == 'POST' && $vName = 'categories')) { $cachable = false; } $safeurlparams = array( 'id' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'lang' => 'CMD' ); // Check for edit form. if ($vName == 'form' && !$this->checkEditId('com_weblinks.edit.weblink', $id)) { // Somehow the person just went to the form - we don't allow that. return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); } return parent::display($cachable, $safeurlparams); } } .htaccess000066600000000177151371544250006362 0ustar00 Order allow,deny Deny from all weblink/.htaccess000066600000000177151371745130010015 0ustar00 Order allow,deny Deny from all weblink/edit_metadata.php000066600000002650151371745130011513 0ustar00form->getFieldsets('metadata'); foreach ($fieldSets as $name => $fieldSet) : echo JHtml::_('sliders.panel', JText::_($fieldSet->label), $name.'-options'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
label); ?>
weblink/index.html000066600000000037151371745130010207 0ustar00 weblink/edit.php000066600000010302151371745130007644 0ustar00 weblink/edit_params.php000066600000001740151371745130011215 0ustar00form->getFieldsets('params'); foreach ($fieldSets as $name => $fieldSet) : echo JHtml::_('sliders.panel', JText::_($fieldSet->label), $name.'-params'); if (isset($fieldSet->description) && trim($fieldSet->description)) : echo '

'.$this->escape(JText::_($fieldSet->description)).'

'; endif; ?>
label); ?>
weblinks/index.html000066600000000037151371745130010372 0ustar00 weblinks/.htaccess000066600000000177151371745130010200 0ustar00 Order allow,deny Deny from all weblinks/default.php000066600000021367151371745130010543 0ustar00get('id'); $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); $canOrder = $user->authorise('core.edit.state', 'com_weblinks.category'); $saveOrder = $listOrder == 'a.ordering'; ?>
items as $i => $item) : $ordering = ($listOrder == 'a.ordering'); $item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_weblinks&task=edit&type=other&cid[]='. $item->catid); $canCreate = $user->authorise('core.create', 'com_weblinks.category.'.$item->catid); $canEdit = $user->authorise('core.edit', 'com_weblinks.category.'.$item->catid); $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id') || $item->checked_out==0; $canChange = $user->authorise('core.edit.state', 'com_weblinks.category.'.$item->catid) && $canCheckin; ?>
items, 'filesave.png', 'weblinks.saveorder'); ?>
id); ?> checked_out) : ?> editor, $item->checked_out_time, 'weblinks.', $canCheckin); ?> escape($item->title); ?> escape($item->title); ?>

escape($item->alias));?>

state, $i, 'weblinks.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?> escape($item->category_title); ?> pagination->orderUpIcon($i, ($item->catid == @$this->items[$i-1]->catid), 'weblinks.orderup', 'JLIB_HTML_MOVE_UP', $ordering); ?> pagination->orderDownIcon($i, $this->pagination->total, ($item->catid == @$this->items[$i+1]->catid), 'weblinks.orderdown', 'JLIB_HTML_MOVE_DOWN', $ordering); ?> pagination->orderUpIcon($i, ($item->catid == @$this->items[$i-1]->catid), 'weblinks.orderdown', 'JLIB_HTML_MOVE_UP', $ordering); ?> pagination->orderDownIcon($i, $this->pagination->total, ($item->catid == @$this->items[$i+1]->catid), 'weblinks.orderup', 'JLIB_HTML_MOVE_DOWN', $ordering); ?> class="text-area-order" title="title; ?> order" /> ordering; ?> escape($item->access_level); ?> hits; ?> language=='*'):?> language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?> id; ?>
pagination->getListFooter(); ?>
loadTemplate('batch'); ?>