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'); ?>
com_weblinks.php000066600000014712151374116510007746 0ustar00link); parse_str(html_entity_decode($link_query['query']), $link_vars); $view = JArrayHelper::getValue($link_vars, 'view', ''); if ($view == 'weblink') { $id = intval(JArrayHelper::getValue($link_vars, 'id', 0)); if ($id) { $node->uid = 'com_weblinksi' . $id; $node->expandible = false; } } elseif ($view == 'categories') { $node->uid = 'com_weblinkscategories'; $node->expandible = true; } elseif ($view == 'category') { $catid = intval(JArrayHelper::getValue($link_vars, 'id', 0)); $node->uid = 'com_weblinksc' . $catid; $node->expandible = true; } } static function getTree($xmap, $parent, &$params) { self::initialize($params); $app = JFactory::getApplication(); $weblinks_params = $app->getParams('com_weblinks'); $link_query = parse_url($parent->link); parse_str(html_entity_decode($link_query['query']), $link_vars); $view = JArrayHelper::getValue($link_vars, 'view', 0); $app = JFactory::getApplication(); $menu = $app->getMenu(); $menuparams = $menu->getParams($parent->id); if ($view == 'category') { $catid = intval(JArrayHelper::getValue($link_vars, 'id', 0)); } elseif ($view == 'categories') { $catid = 0; } else { // Only expand category menu items return; } $include_links = JArrayHelper::getValue($params, 'include_links', 1, ''); $include_links = ( $include_links == 1 || ( $include_links == 2 && $xmap->view == 'xml') || ( $include_links == 3 && $xmap->view == 'html') || $xmap->view == 'navigator'); $params['include_links'] = $include_links; $priority = JArrayHelper::getValue($params, 'cat_priority', $parent->priority, ''); $changefreq = JArrayHelper::getValue($params, 'cat_changefreq', $parent->changefreq, ''); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['cat_priority'] = $priority; $params['cat_changefreq'] = $changefreq; $priority = JArrayHelper::getValue($params, 'link_priority', $parent->priority, ''); $changefreq = JArrayHelper::getValue($params, 'link_changefreq', $parent->changefreq, ''); if ($priority == '-1') $priority = $parent->priority; if ($changefreq == '-1') $changefreq = $parent->changefreq; $params['link_priority'] = $priority; $params['link_changefreq'] = $changefreq; $options = array(); $options['countItems'] = false; $options['catid'] = rand(); $categories = JCategories::getInstance('Weblinks', $options); $category = $categories->get($catid? $catid : 'root', true); $params['count_clicks'] = $weblinks_params->get('count_clicks'); xmap_com_weblinks::getCategoryTree($xmap, $parent, $params, $category); } static function getCategoryTree($xmap, $parent, &$params, $category) { $db = JFactory::getDBO(); $children = $category->getChildren(); $xmap->changeLevel(1); foreach ($children as $cat) { $node = new stdclass; $node->id = $parent->id; $node->uid = $parent->uid . 'c' . $cat->id; $node->name = $cat->title; $node->link = WeblinksHelperRoute::getCategoryRoute($cat); $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->expandible = true; if ($xmap->printNode($node) !== FALSE) { xmap_com_weblinks::getCategoryTree($xmap, $parent, $params, $cat); } } $xmap->changeLevel(-1); if ($params['include_links']) { //view=category&catid=... $linksModel = new WeblinksModelCategory(); $linksModel->getState(); // To force the populate state $linksModel->setState('list.limit', JArrayHelper::getValue($params, 'max_links', NULL)); $linksModel->setState('list.start', 0); $linksModel->setState('list.ordering', 'ordering'); $linksModel->setState('list.direction', 'ASC'); $linksModel->setState('category.id', $category->id); $links = $linksModel->getItems(); $xmap->changeLevel(1); foreach ($links as $link) { $item_params = new JRegistry; $item_params->loadString($link->params); $node = new stdclass; $node->id = $parent->id; $node->uid = $parent->uid . 'i' . $link->id; $node->name = $link->title; // Find the Itemid $Itemid = intval(preg_replace('/.*Itemid=([0-9]+).*/','$1',WeblinksHelperRoute::getWeblinkRoute($link->id, $category->id))); if ($item_params->get('count_clicks', $params['count_clicks']) == 1) { $node->link = 'index.php?option=com_weblinks&task=weblink.go&id='. $link->id.'&Itemid='.($Itemid ? $Itemid : $parent->id); } else { $node->link = $link->url; } $node->priority = $params['link_priority']; $node->changefreq = $params['link_changefreq']; $node->expandible = false; $xmap->printNode($node); } $xmap->changeLevel(-1); } } static public function initialize(&$params) { if (self::$_initialized) { return; } self::$_initialized = true; require_once JPATH_SITE.'/components/com_weblinks/models/category.php'; require_once JPATH_SITE.'/components/com_weblinks/helpers/route.php'; } }com_weblinks.xml000066600000012055151374116510007755 0ustar00 Xmap - WebLinks Plugin Guillermo Vargas Apr 2004 GNU GPL http://www.gnu.org/copyleft/gpl.html GNU/GPL guille@vargas.co.cr joomla.vargas.co.cr 2.0.1 XMAP_WL_PLUGIN_DESCRIPTION com_weblinks.php index.html en-GB.plg_xmap_com_weblinks.ini es-ES.plg_xmap_com_weblinks.ini fa-IR.plg_xmap_com_weblinks.ini cs-CZ.plg_xmap_com_weblinks.ini nl-NL.plg_xmap_com_weblinks.ini ru-RU.plg_xmap_com_weblinks.ini
access.xml000066600000002546151374527150006554 0ustar00
tables/.htaccess000066600000000177151374527150007637 0ustar00 Order allow,deny Deny from all tables/index.html000066600000000037151374527150010031 0ustar00 tables/weblink.php000066600000015053151374527150010204 0ustar00loadArray($array['params']); $array['params'] = (string)$registry; } if (isset($array['metadata']) && is_array($array['metadata'])) { $registry = new JRegistry(); $registry->loadArray($array['metadata']); $array['metadata'] = (string)$registry; } return parent::bind($array, $ignore); } /** * Overload the store method for the Weblinks table. * * @param boolean Toggle whether null values should be updated. * @return boolean True on success, false on failure. * @since 1.6 */ public function store($updateNulls = false) { $date = JFactory::getDate(); $user = JFactory::getUser(); if ($this->id) { // Existing item $this->modified = $date->toSql(); $this->modified_by = $user->get('id'); } else { // New weblink. A weblink created and created_by field can be set by the user, // so we don't touch either of these if they are set. if (!intval($this->created)) { $this->created = $date->toSql(); } if (empty($this->created_by)) { $this->created_by = $user->get('id'); } } // Verify that the alias is unique $table = JTable::getInstance('Weblink', 'WeblinksTable'); if ($table->load(array('alias'=>$this->alias, 'catid'=>$this->catid)) && ($table->id != $this->id || $this->id==0)) { $this->setError(JText::_('COM_WEBLINKS_ERROR_UNIQUE_ALIAS')); return false; } // Attempt to store the user data. return parent::store($updateNulls); } /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. */ public function check() { if (JFilterInput::checkAttribute(array ('href', $this->url))) { $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL')); return false; } // check for valid name if (trim($this->title) == '') { $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE')); return false; } // check for existing name $query = 'SELECT id FROM #__weblinks WHERE title = '.$this->_db->Quote($this->title).' AND catid = '.(int) $this->catid; $this->_db->setQuery($query); $xid = intval($this->_db->loadResult()); if ($xid && $xid != intval($this->id)) { $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_NAME')); return false; } if (empty($this->alias)) { $this->alias = $this->title; } $this->alias = JApplication::stringURLSafe($this->alias); if (trim(str_replace('-', '', $this->alias)) == '') { $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s"); } // Check the publish down date is not earlier than publish up. if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) { $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH')); return false; } // clean up keywords -- eliminate extra spaces between phrases // and cr (\r) and lf (\n) characters from string if (!empty($this->metakey)) { // only process if not empty $bad_characters = array("\n", "\r", "\"", "<", ">"); // array of characters to remove $after_clean = JString::str_ireplace($bad_characters, "", $this->metakey); // remove bad characters $keys = explode(',', $after_clean); // create array using commas as delimiter $clean_keys = array(); foreach($keys as $key) { if (trim($key)) { // ignore blank keywords $clean_keys[] = trim($key); } } $this->metakey = implode(", ", $clean_keys); // put array back together delimited by ", " } return true; } /** * Method to set the publishing state for a row or list of rows in the database * table. The method respects checked out rows by other users and will attempt * to checkin rows that it can after adjustments are made. * * @param mixed An optional array of primary key values to update. If not * set the instance property value is used. * @param integer The publishing state. eg. [0 = unpublished, 1 = published] * @param integer The user id of the user performing the operation. * @return boolean True on success. * @since 1.0.4 */ public function publish($pks = null, $state = 1, $userId = 0) { // Initialise variables. $k = $this->_tbl_key; // Sanitize input. JArrayHelper::toInteger($pks); $userId = (int) $userId; $state = (int) $state; // If there are no primary keys set check to see if the instance key is set. if (empty($pks)) { if ($this->$k) { $pks = array($this->$k); } // Nothing to set publishing state on, return false. else { $this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED')); return false; } } // Build the WHERE clause for the primary keys. $where = $k.'='.implode(' OR '.$k.'=', $pks); // Determine if there is checkin support for the table. if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time')) { $checkin = ''; } else { $checkin = ' AND (checked_out = 0 OR checked_out = '.(int) $userId.')'; } // Update the publishing state for rows with the given primary keys. $this->_db->setQuery( 'UPDATE '.$this->_db->quoteName($this->_tbl) . ' SET '.$this->_db->quoteName('state').' = '.(int) $state . ' WHERE ('.$where.')' . $checkin ); $this->_db->query(); // Check for a database error. if ($this->_db->getErrorNum()) { $this->setError($this->_db->getErrorMsg()); return false; } // If checkin is supported and all rows were adjusted, check them in. if ($checkin && (count($pks) == $this->_db->getAffectedRows())) { // Checkin the rows. foreach($pks as $pk) { $this->checkin($pk); } } // If the JTable instance value is in the list of primary keys that were set, set the instance. if (in_array($this->$k, $pks)) { $this->state = $state; } $this->setError(''); return true; } } config.xml000066600000016550151374527150006560 0ustar00
weblinks.xml000066600000004521151374527150007124 0ustar00 com_weblinks Joomla! Project April 2006 (C) 2005 - 2014 Open Source Matters. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt admin@joomla.org www.joomla.org 2.5.0 COM_WEBLINKS_XML_DESCRIPTION sql/install.mysql.utf8.sql sql/uninstall.mysql.utf8.sql index.html weblinks.php controller.php router.php metadata.xml views models controllers helpers language/en-GB.com_weblinks.ini com_weblinks com_weblinks_links com_weblinks_categories access.xml config.xml controller.php index.html weblinks.php controllers helpers models sql tables views language/en-GB.com_weblinks.ini language/en-GB.com_weblinks.sys.ini models/fields/.htaccess000066600000000177151374527150011116 0ustar00 Order allow,deny Deny from all models/fields/index.html000066600000000037151374527150011310 0ustar00 models/fields/ordering.php000066600000004016151374527150011636 0ustar00element['class'] ? ' class="'.(string) $this->element['class'].'"' : ''; $attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : ''; $attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : ''; // Get some field values from the form. $weblinkId = (int) $this->form->getValue('id'); $categoryId = (int) $this->form->getValue('catid'); // Build the query for the ordering list. $query = 'SELECT ordering AS value, title AS text' . ' FROM #__weblinks' . ' WHERE catid = ' . (int) $categoryId . ' ORDER BY ordering'; // Create a read-only list (no name) with a hidden input to store the value. if ((string) $this->element['readonly'] == 'true') { $html[] = JHtml::_('list.ordering', '', $query, trim($attr), $this->value, $weblinkId ? 0 : 1); $html[] = ''; } // Create a regular list. else { $html[] = JHtml::_('list.ordering', $this->name, $query, trim($attr), $this->value, $weblinkId ? 0 : 1); } return implode($html); } } models/weblinks.php000066600000014006151374527150010375 0ustar00getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); $accessId = $this->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); $this->setState('filter.access', $accessId); $published = $this->getUserStateFromRequest($this->context.'.filter.state', 'filter_published', '', 'string'); $this->setState('filter.state', $published); $categoryId = $this->getUserStateFromRequest($this->context.'.filter.category_id', 'filter_category_id', ''); $this->setState('filter.category_id', $categoryId); $language = $this->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', ''); $this->setState('filter.language', $language); // Load the parameters. $params = JComponentHelper::getParams('com_weblinks'); $this->setState('params', $params); // List state information. parent::populateState('a.title', 'asc'); } /** * 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. * @since 1.6 */ protected function getStoreId($id = '') { // Compile the store id. $id.= ':' . $this->getState('filter.search'); $id.= ':' . $this->getState('filter.access'); $id.= ':' . $this->getState('filter.state'); $id.= ':' . $this->getState('filter.category_id'); $id.= ':' . $this->getState('filter.language'); return parent::getStoreId($id); } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); $user = JFactory::getUser(); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid,' . 'a.hits,' . 'a.state, a.access, a.ordering,'. 'a.language, a.publish_up, a.publish_down' ) ); $query->from($db->quoteName('#__weblinks').' AS a'); // Join over the language $query->select('l.title AS language_title'); $query->join('LEFT', $db->quoteName('#__languages').' AS l ON l.lang_code = a.language'); // Join over the users for the checked out user. $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); // Join over the asset groups. $query->select('ag.title AS access_level'); $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); // Join over the categories. $query->select('c.title AS category_title'); $query->join('LEFT', '#__categories AS c ON c.id = a.catid'); // Filter by access level. if ($access = $this->getState('filter.access')) { $query->where('a.access = '.(int) $access); } // Implement View Level Access if (!$user->authorise('core.admin')) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN ('.$groups.')'); } // Filter by published state $published = $this->getState('filter.state'); if (is_numeric($published)) { $query->where('a.state = '.(int) $published); } elseif ($published === '') { $query->where('(a.state IN (0, 1))'); } // Filter by category. $categoryId = $this->getState('filter.category_id'); if (is_numeric($categoryId)) { $query->where('a.catid = '.(int) $categoryId); } // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { if (stripos($search, 'id:') === 0) { $query->where('a.id = '.(int) substr($search, 3)); } else { $search = $db->Quote('%'.$db->escape($search, true).'%'); $query->where('(a.title LIKE '.$search.' OR a.alias LIKE '.$search.')'); } } // Filter on the language. if ($language = $this->getState('filter.language')) { $query->where('a.language = ' . $db->quote($language)); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); if ($orderCol == 'a.ordering' || $orderCol == 'category_title') { $orderCol = 'c.title '.$orderDirn.', a.ordering'; } $query->order($db->escape($orderCol.' '.$orderDirn)); //echo nl2br(str_replace('#__','jos_',$query)); return $query; } } views/weblinks/view.html.php000066600000004345151374527150012171 0ustar00state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); } /** * Add the page title and toolbar. * * @since 1.6 */ protected function addToolbar() { require_once JPATH_COMPONENT.'/helpers/weblinks.php'; $state = $this->get('State'); $canDo = WeblinksHelper::getActions($state->get('filter.category_id')); $user = JFactory::getUser(); JToolBarHelper::title(JText::_('COM_WEBLINKS_MANAGER_WEBLINKS'), 'weblinks.png'); if (count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0) { JToolBarHelper::addNew('weblink.add'); } if ($canDo->get('core.edit')) { JToolBarHelper::editList('weblink.edit'); } if ($canDo->get('core.edit.state')) { JToolBarHelper::divider(); JToolBarHelper::publish('weblinks.publish', 'JTOOLBAR_PUBLISH', true); JToolBarHelper::unpublish('weblinks.unpublish', 'JTOOLBAR_UNPUBLISH', true); JToolBarHelper::divider(); JToolBarHelper::archiveList('weblinks.archive'); JToolBarHelper::checkin('weblinks.checkin'); } if ($state->get('filter.state') == -2 && $canDo->get('core.delete')) { JToolBarHelper::deleteList('', 'weblinks.delete', 'JTOOLBAR_EMPTY_TRASH'); JToolBarHelper::divider(); } elseif ($canDo->get('core.edit.state')) { JToolBarHelper::trash('weblinks.trash'); JToolBarHelper::divider(); } if ($canDo->get('core.admin')) { JToolBarHelper::preferences('com_weblinks'); JToolBarHelper::divider(); } JToolBarHelper::help('JHELP_COMPONENTS_WEBLINKS_LINKS'); } } views/weblinks/tmpl/.htaccess000066600000000177151374527150012314 0ustar00 Order allow,deny Deny from all views/weblinks/tmpl/index.html000066600000000037151374527150012506 0ustar00 views/weblinks/tmpl/default_batch.php000066600000002027151374527150014010 0ustar00state->get('filter.published'); ?>

= 0) : ?>
views/weblinks/tmpl/default.php000066600000020433151374527150012650 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'); ?>
pagination->getListFooter(); ?>
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" /> ordering; ?> escape($item->access_level); ?> hits; ?> language=='*'):?> language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?> id; ?>
authorize('core.create', 'com_weblinks') && $user->authorize('core.edit', 'com_weblinks') && $user->authorize('core.edit.state', 'com_weblinks')) : ?> loadTemplate('batch'); ?>
views/weblinks/index.html000066600000000037151374527150011532 0ustar00 views/weblinks/.htaccess000066600000000177151374527150011340 0ustar00 Order allow,deny Deny from all views/weblink/tmpl/edit_params.php000066600000001566151374527150013337 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; ?>
views/weblink/tmpl/edit.php000066600000010041151374527150011760 0ustar00 views/weblink/tmpl/edit_metadata.php000066600000002477151374527150013636 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; ?>
helpers/weblinks.php000066600000003153151374527150010555 0ustar00set($action->name, $user->authorise($action->name, $assetName)); } return $result; } } controllers/weblinks.php000066600000001306151374527150011457 0ustar00 true)) { $model = parent::getModel($name, $prefix, $config); return $model; } } sql/uninstall.mysql.utf8.sql000066600000000043151374527150012141 0ustar00DROP TABLE IF EXISTS `#__weblinks`;sql/install.mysql.utf8.sql000066600000003612151374527150011603 0ustar00CREATE TABLE IF NOT EXISTS `#__weblinks` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `catid` int(11) NOT NULL DEFAULT '0', `sid` int(11) NOT NULL DEFAULT '0', `title` varchar(250) NOT NULL DEFAULT '', `alias` varchar(255) NOT NULL DEFAULT '', `url` varchar(250) NOT NULL DEFAULT '', `description` text NOT NULL, `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `hits` int(11) NOT NULL DEFAULT '0', `state` tinyint(1) NOT NULL DEFAULT '0', `checked_out` int(11) NOT NULL DEFAULT '0', `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `ordering` int(11) NOT NULL DEFAULT '0', `archived` tinyint(1) NOT NULL DEFAULT '0', `approved` tinyint(1) NOT NULL DEFAULT '1', `access` int(11) NOT NULL DEFAULT '1', `params` text NOT NULL, `language` char(7) NOT NULL DEFAULT '', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created_by` int(10) unsigned NOT NULL DEFAULT '0', `created_by_alias` varchar(255) NOT NULL DEFAULT '', `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `modified_by` int(10) unsigned NOT NULL DEFAULT '0', `metakey` text NOT NULL, `metadesc` text NOT NULL, `metadata` text NOT NULL, `featured` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT 'Set if link is featured.', `xreference` varchar(50) NOT NULL COMMENT 'A reference to enable linkages to external data sets.', `publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`), KEY `idx_access` (`access`), KEY `idx_checkout` (`checked_out`), KEY `idx_state` (`state`), KEY `idx_catid` (`catid`), KEY `idx_createdby` (`created_by`), KEY `idx_featured_catid` (`featured`,`catid`), KEY `idx_language` (`language`), KEY `idx_xreference` (`xreference`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; sql/index.html000066600000000037151374527150007356 0ustar00 sql/.htaccess000066600000000177151374527150007164 0ustar00 Order allow,deny Deny from all