Current Path :
/
home
/
develito
/
httpdocs
/
components
/
com_abook
/
views
/
book
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/httpdocs/components/com_abook/views/book/view.html.php
<?php /** * @package Joomla * @subpackage Abook * @copyright (C) 2010-2019 Federica Ugolotti * @license GNU/GPL, see LICENSE.php * Abook is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License 3 * as published by the Free Software Foundation. * Abook is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with Abook; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ defined( '_JEXEC' ) or die( 'Restricted access' ); jimport( 'joomla.application.application' ); jimport( 'joomla.application.component.view' ); jimport( 'joomla.filesystem.file' ); class AbookViewBook extends JViewLegacy { protected $state; protected $item; protected $print; protected $params; protected $user; protected $authors; protected $captchaEnabled = false; function display($tpl = null) { // Initialise variables. $app = JFactory::getApplication(); $user = JFactory::getUser(); $dispatcher = JDispatcher::getInstance(); // Get model data. $this->state = $this->get('State'); $this->item = $this->get('Item'); $item = $this->item; $this->authors = $this->get('Authors'); $this->tags = $this->get('Tags'); $this->user = $user; // Check for errors. if (count($errors = $this->get('Errors'))){ throw new Exception(implode("\n", $errors), 500); } if($item == false) { throw new Exception(JText::_('JGLOBAL_ITEM_NOT_FOUND'), 404); } $this->filename= JFile::getName($item->file); $document = JFactory::getDocument(); $document->addStyleSheet('components/com_abook/assets/css/style.css'); JHTML::_('behavior.modal'); $document->addScriptDeclaration(" window.addEvent('domready', function() { document.preview = SqueezeBox; });"); // Get view related request variables. $this->print = $app->input->getBool('print'); //----------------------------------------------------------------------------------------------------------------------------- // Merge book params. If this is single-book view, menu params override book params // Otherwise, book params override menu item params $this->params = $this->state->get('params'); $active = $app->getMenu()->getActive(); $temp = clone $this->params; // Check to see which parameters should take priority if ($active) { $currentLink = $active->link; // If the current view is the active item and an book view for this book, then the menu item params take priority if (strpos($currentLink, 'view=book') && strpos($currentLink, '&id=' . (string) $item->id)) { // Load layout from active query (in case it is an alternative menu item) if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } // Check for alternative layout of book elseif ($layout = $item->params->get('book_layout')) { $this->setLayout($layout); } // $item->params are the book params, $temp are the menu item params // Merge so that the menu item params take priority $item->params->merge($temp); } else { // Current view is not a single book, so the book params take priority here // Merge the menu item params with the book params so that the book params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-book menu item) // Single-book menu item layout takes priority over alt layout for an book if ($layout = $item->params->get('book_layout')) { $this->setLayout($layout); } } } else { // Merge so that book params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-book menu item) // Single-book menu item layout takes priority over alt layout for an book if ($layout = $item->params->get('book_layout')) { $this->setLayout($layout); } } //----------------------------------------------------------------------------------------------------------------------------- if ($this->params->get('view_rate', 1)){ $vote = $this->get('Voting'); $this->assignRef('vote', $vote); } $lend=$this->params->get('show_lend_availability', 1); if($lend){ $this->lend = $this->get('Lend'); } // check if access is not public $groups = $this->user->getAuthorisedViewLevels(); $return =""; if ((!in_array($item->access, $groups)) || (!in_array($item->category_access, $groups))) { $uri = JFactory::getURI(); $return = (string)$uri; JFactory::getApplication()->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); return; } $offset = $this->state->get('list.offset'); //inizio plugin $item->text=$item->description; JPluginHelper::importPlugin('content'); JPluginHelper::importPlugin('abook'); $results = $dispatcher->trigger('onContentPrepare', array ('com_abook.book', &$item, &$this->params, $offset)); $item->event = new stdClass; $results = $dispatcher->trigger('onContentAfterTitle', array('com_abook.book', &$item, &$this->params, $offset)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_abook.book', &$item, &$this->params, $offset)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_abook.book', &$item, &$this->params, $offset)); $item->event->afterDisplayContent = trim(implode("\n", $results)); $item->description=$item->text; //fine plugin //incremento il numero delle visite $model = $this->getModel(); $model->hit(); // Add router helpers. $item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id; $item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid; $item->parent_slug = $item->category_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id; $item->authorreview = $item->created_by_alias==''?$item->written_by:$item->created_by_alias; JHtml::_('behavior.formvalidation'); if ($this->params->get( 'breadcrumb' ) != 0){ $categories = $this->get('Categories'); $category = $this->get('Category'); $parent = $this->get('Parent'); $this->assignRef('categories', $categories); $this->assignRef('category', $category); $this->assignRef('parent', $parent); } $this->assignRef('return', $return); if ($this->item->docsfolder != ''){ $this->docslist = JFolder::files(JPATH_ROOT.DIRECTORY_SEPARATOR.$this->item->docsfolder.DIRECTORY_SEPARATOR, '', '', '', array('.svn', 'CVS','.DS_Store','__MACOSX', 'index.html')); } //captcha $captchaSet = $this->params->get('captcha', JFactory::getApplication()->get('captcha', '0')); foreach (JPluginHelper::getPlugin('captcha') as $plugin) { if ($captchaSet === $plugin->name) { $this->captchaEnabled = true; break; } } //fine captcha $this->_prepareDocument(); parent::display($tpl); } protected function _prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $pathway = $app->getPathway(); $title = null; $menus = $app->getMenu(); $menu = $menus->getActive(); if ($menu){ $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); }else{ $this->params->def('page_heading', $this->params->def('comp_name')); } if ($this->params->get( 'breadcrumb' ) != 0){ $path= null; $path[] = array('title' => $this->item->category_title, 'link' => AbookHelperRoute::getCategoryRoute($this->item->catslug)); $category=$this->category->getParent(); //suggerito da evpadallas http://forum.voxpopulix.org/errori-(bugs)/not-working-sef_advanced_link/ if ($category->id != "root"){ while($category->id > 1){ $path[] = array('title' => $category->title, 'link' => AbookHelperRoute::getCategoryRoute($category->id.':'.$category->alias)); $category = $category->getParent(); } } if ($category != ''){ $path = array_reverse($path); foreach ($path as $item){ $pathway->addItem($item['title'], $item['link']); } } //if breadcrumb is set to be shows in joomla breadcrumb if ($this->params->get( 'breadcrumb' ) == 1) { $pathway->addItem($this->item->title); } $path[]=array('title' =>$this->item->title, 'link' => ''); $this->assignRef('path', $path); } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = $this->item->cat_title." - ".$this->item->title; }elseif ($app->getCfg('sitename_pagetitles', 0) == 1) { $title = $this->params->get('comp_name').' - '.$this->item->category_title." - ".$this->item->title; }elseif ($app->getCfg('sitename_pagetitles', 0) == 2) { $title = $this->item->category_title." - ".$this->item->title.' - '.$this->params->get('comp_name'); }else{ $title = $this->params->get('page_title', '').' - '.$this->item->category_title." - ".$this->item->title; } $this->document->setTitle($title); if ($this->item->metadesc){ $this->document->setDescription($this->item->metadesc); }else if (!$this->item->metadesc && $this->params->get('menu-meta_description')){ $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->item->metakey){ $this->document->setMetadata('keywords', $this->item->metakey); }else if (!$this->item->metakey&& $this->params->get('menu-meta_keywords')){ $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->print){ $this->document->setMetaData('robots', 'noindex, nofollow'); }else{ if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } if ($app->getCfg('MetaAuthor') == '1'){ $this->document->setMetaData('author', $this->item->authorreview); } $mdata = $this->item->metadata->toArray(); foreach ($mdata as $k => $v){ if ($v){ $this->document->setMetadata($k, $v); } } } }