File manager - Edit - /home/jardides/www/Jardi-design/images/administrator/models.tar
Back
contenttype.php 0000644 00000000630 15247074252 0007640 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/contenttype.php'; modules.php 0000644 00000000624 15247074252 0006737 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/modules.php'; menus.php 0000644 00000000622 15247074252 0006414 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/menus.php'; links.php 0000644 00000000622 15247074252 0006405 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/links.php'; elements.php 0000644 00000000625 15247074252 0007104 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/elements.php'; page.php 0000644 00000075064 15247074252 0006215 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ // No direct access. defined('_JEXEC') or die('Restricted access'); use Joomla\Registry\Registry; use Pagebuilderck\CKModel; use Pagebuilderck\CKFof; include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/defines.php'; include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/ckmodel.php'; include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/simple_html_dom.php'; include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/pagebuilderckfront.php'; include_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/helpers/pagebuilderck.php'; class PagebuilderckModelPage extends CKModel { protected $table = '#__pagebuilderck_pages'; var $item = null; // protected $_context = 'com_pagebuilderck.page'; public $styleTags; public $responsiveStyleTags4, $responsiveStyleTags3, $responsiveStyleTags2, $responsiveStyleTags1; function __construct() { parent::__construct(); } public function getItem($id = 0) { $user = JFactory::getUser(); // for new page if ($id === 0) { // check that the user has the rights to edit $authorised = ($user->authorise('core.create', 'com_pagebuilderck') || (count($user->getAuthorisedCategories('com_pagebuilderck', 'core.create')))); if ($authorised !== true) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); return false; } $this->item = CKFof::dbLoad($this->table, $id); } else { // item already exists if (empty($this->item)) { // $id = $this->input->get('id', $id, 'int'); $query = "SELECT * FROM " . $this->table . " AS a" . " WHERE a.state = 1" . " AND a.id = " . (int) $id; try { $this->item = CKFof::dbLoadObject($query); } catch(Exception $e) { return false; } } if (empty($this->item)) { return false; } if ($id !== 0) { // counter for hits $sql = "UPDATE #__pagebuilderck_pages SET hits = hits + 1 WHERE id= " . $this->item->id; CKFof::dbExecute($sql); } } if (! empty($this->item)) { // transform params to JRegistry object if (isset($this->item->params)) $this->item->params = new JRegistry($this->item->params); } if (isset($this->item->htmlcode) && $this->item->htmlcode) { // replace the root path for all elements $this->item->htmlcode = trim(str_replace("|URIROOT|", JUri::root(true), $this->item->htmlcode)); // load the general style if (! empty($this->item->styles)) { foreach($this->item->styles as $style) { $this->styleTags .= PagebuilderckHelper::getStyleCode($style); } } // pass through the html code to convert what is needed if ($this->input->get('layout', '', 'cmd') !== 'edit') { $this->parseHtml($this->item->htmlcode); } // active the content plugins interaction if ($this->item->params->get('contentprepare', '0')) { CKFof::importPlugin('content'); $this->item->htmlcode = JHtml::_('content.prepare', $this->item->htmlcode, '', 'com_pagebuilderck.page'); } } return $this->item; } public function parseHtml(&$htmlcode) { $customcss = ''; // replace the root path for all elements $htmlcode = trim(str_replace("|URIROOT|", JUri::root(true), $htmlcode)); // replace the tags for W3C compliance // $htmlcode = trim(str_replace('<div class="ckstyle"><style>', '<div class="ckstyle"><style scoped>', $htmlcode)); // WARNING : scoped limits to the ckstyle parent ! $htmlcode = str_replace('https://fonts.googleapis.com', 'https://fonts.googleapis.com', $htmlcode); $htmlcode = trim(str_replace('height=""', '', $htmlcode)); $htmlcode = trim(str_replace('width=""', '', $htmlcode)); // for RS Firewall fix $htmlcode = trim(str_replace('<s-tyle', '<style', $htmlcode)); $htmlcode = trim(str_replace('</s-tyle', '</style', $htmlcode)); // other fix $htmlcode = trim(str_replace('<style type="text/css" wfd-invisible="true">', '<style>', $htmlcode)); $htmlcode = trim(str_replace('<style wfd-invisible="true"', '<style', $htmlcode)); // load the modules // <div class="modulerow" data-module="mod_menu" data-title="a propos de joomla!" data-id="23" style="cursor:pointer;"> $regex2 = "#<div\s[^>]*class=\"modulerow([^\"]*)\"([^>]*)>(.*)<\/div>#siU"; // masque de recherche pour le tag $htmlcode = preg_replace_callback($regex2, array($this, 'replaceModule'), $htmlcode); // load the pages $regex3 = "#<div\s[^>]*class=\"pagerow([^\"]*)\"([^>]*)>(.*)<\/div>#siU"; // masque de recherche pour le tag $htmlcode = preg_replace_callback($regex3, array($this, 'replacePage'), $htmlcode); // loop through elements to be replaced in frontend // $regex_type = "#<div\s[^>]*class=\"cktype([^\"]*)\"([^>]*)>(.*?)<\/div>#siU"; // masque de recherche pour le tag // $htmlcode = preg_replace_callback($regex_type, array($this, 'replaceElement'), $htmlcode); if ($htmlcode) { $html = \Pagebuilderck\str_get_html($htmlcode); // find all acl in the page foreach($html->find('[data-acl-view]') as $e) { $aclview = explode(',', $e->attr['data-acl-view']); $user = JFactory::getUser(); $aclviewexists = array_intersect($user->groups, $aclview); if (! empty($aclviewexists)) { $e->outertext = ''; } } // find all types in the page foreach($html->find('div.cktype') as $e) { if ($e->attr['data-type'] !== 'text') { foreach($e->find('div.cktype') as $f) { $f->innertext = $this->replaceElement($f); } } $e->innertext = $this->replaceElement($e); } // find all google fonts, call them as stylesheet in the page header foreach($html->find('div.googlefontscall') as $e) { $regex = "#href=\"\s*[^>]*\?family=([^\"]*)\"[^>]*>#siU"; // replace all divs with class ckprops foreach(explode('<link', $e->innertext) as $call) { preg_match($regex, $call, $matches); $fontcalled = isset($matches[1]) && $matches[1] ? $matches[1] : ''; if ($fontcalled) PagebuilderckFrontHelper::addStylesheet('https://fonts.googleapis.com/css?family=' . $fontcalled); $e->innertext = ''; } } // find all google fonts, call them as stylesheet in the page header foreach($html->find('div.ckcustomcssfield') as $e) { $customcss = htmlspecialchars_decode($e->innertext); $e->outertext = ''; } // find the params foreach($html->find('div.pagebuilderckparams') as $e) { $stylestoload = isset($e->attr['data-styles']) ? $e->attr['data-styles'] : false; if ($stylestoload) $this->loadStyles($stylestoload); $e->outertext = ''; } $htmlcode = $html->save(); $html->clear(); unset($html); } $htmlcode = trim(str_replace("|URIROOT|", JUri::root(true), $htmlcode)); // remove the id="googlefontscall" to avoid html error in frontend $htmlcode = preg_replace('/ id="googlefontscall"/', '', $htmlcode); $regexGooglefont = "#<div\s[^>]*googlefontscall([^\"]*)\"[^>]*>(.*)<\/div>#siU"; // replace all divs with class ckprops $htmlcode = preg_replace_callback($regexGooglefont, array($this, 'replaceGooglefont'), $htmlcode); // remove the params div $regex = "#<div\s[^>]*pagebuilderckparams([^\"]*)\"[^>]*>[^<]*<\/div>#siU"; // replace all divs with class ckprops $htmlcode = preg_replace($regex, '', $htmlcode); // remove all the settings values (that are not needed in front) (TODO with parser) $regex = "#<div\s[^>]*ckprops([^\"]*)\"[^>]*>[^<]*<\/div>#siU"; // replace all divs with class ckprops $htmlcode = preg_replace($regex, '', $htmlcode); $htmlcode = preg_replace('/<div fieldslist="(.*?)"(.*?)><\/div>/', '', $htmlcode); // remove all the unwanted html code $regex = "#<div\s[^>]*cktype-button-add([^\"]*)\"[^>]*>[^<]*<\/div>#siU"; // replace all divs with class blockck-button-add $htmlcode = preg_replace($regex, '', $htmlcode); $regex = "#<div\s[^>]*blockck-button-add([^\"]*)\"[^>]*>[^<]*<\/div>#siU"; // replace all divs with class blockck-button-add $htmlcode = preg_replace($regex, '', $htmlcode); $regex = "#<div\s[^>]*rowck-button-add([^\"]*)\"[^>]*>[^<]*<\/div>#siU"; // replace all divs with class blockck-button-add $htmlcode = preg_replace($regex, '', $htmlcode); $regexStyle = "#<div\s[^>]*ckstyleresponsive([^\"]*)\"[^>]*>(.*)<\/div>#siU"; // replace all divs with class ckprops $htmlcode = preg_replace_callback($regexStyle, array($this, 'replaceResponsiveStyleTag'), $htmlcode); $regexStyle = "#<div\s[^>]*ckstyle([^\"]*)\"[^>]*>(.*)<\/div>#siU"; // replace all divs with class ckprops $htmlcode = preg_replace_callback($regexStyle, array($this, 'replaceStyleTag'), $htmlcode); $regexStyle2 = "#<style\s[^>]*ckcolumnwidth([^\"]*)\"[^>]*>(.*)<\/style>#siU"; // replace all divs with class ckprops $htmlcode = preg_replace_callback($regexStyle2, array($this, 'replaceResponsiveStyleTag'), $htmlcode); $regexText = "#CKTEXT\[(.*?)\]#"; // replace all divs with class ckprops // $htmlcode = preg_replace($regex, '', $htmlcode); $htmlcode = preg_replace_callback($regexText, array($this, 'replaceTranslation'), $htmlcode); $regexOnshow = "#onshow=\"(.*?)\"#"; // replace all divs with class ckprops $htmlcode = preg_replace($regexOnshow, '', $htmlcode); if ($this->item && isset($this->item->modified)) $this->searchAndReplaceDates($htmlcode, $this->item->created, $this->item->modified); $regexImg = "#<img(.*?)>#si"; // masque de recherche pour le tag // $htmlcode = preg_replace($find, '', $htmlcode); $htmlcode = preg_replace_callback($regexImg, array($this, 'replaceImage'), $htmlcode); $doc = JFactory::getDocument(); PagebuilderckFrontHelper::addStyleDeclaration($this->styleTags); $componentParams = JComponentHelper::getParams('com_pagebuilderck'); $responsiverange = $componentParams->get('responsiverange', 'reducing'); if (! empty(trim((string)$this->responsiveStyleTags4))) { PagebuilderckFrontHelper::addStyleDeclaration('@media only screen and (max-width:' . (int)$componentParams->get('responsive4value', '800') . 'px) ' . ($responsiverange == 'between' ? 'and (min-width:' . ((int)$componentParams->get('responsive3value', '640')+1) . 'px)' : '') . '{ ' . $this->responsiveStyleTags4 . ' }'); } if (! empty(trim((string)$this->responsiveStyleTags3))) { PagebuilderckFrontHelper::addStyleDeclaration('@media only screen and (max-width:' . (int)$componentParams->get('responsive3value', '640') . 'px) ' . ($responsiverange == 'between' ? 'and (min-width:' . ((int)$componentParams->get('responsive2value', '480')+1) . 'px)' : '') . '{ ' . $this->responsiveStyleTags3 . ' }'); } if (! empty(trim((string)$this->responsiveStyleTags2))) { PagebuilderckFrontHelper::addStyleDeclaration('@media only screen and (max-width:' . (int)$componentParams->get('responsive2value', '480') . 'px) ' . ($responsiverange == 'between' ? 'and (min-width:' . ((int)$componentParams->get('responsive1value', '320')+1) . 'px)' : '') . '{ ' . $this->responsiveStyleTags2 . ' }'); } if (! empty(trim((string)$this->responsiveStyleTags1))) { PagebuilderckFrontHelper::addStyleDeclaration('@media only screen and (max-width:' . (int)$componentParams->get('responsive1value', '320') . 'px){ ' . $this->responsiveStyleTags1 . ' }'); } // get the custom css option if ($customcss) { PagebuilderckFrontHelper::addStyleDeclaration($customcss); } } public function searchAndReplaceDates(&$text, $created, $modified) { $regexText = "#CKDATE_CREATED\[(.*?)\]#"; // replace all divs with class ckprops // $text = $article->text; // $created = $article->created; // $modified = $article->modified; $text = preg_replace_callback($regexText, function($matches) use ($text, $created) { // if (! $this->item) return $matches[0]; if (!$matches[1]) { $format = 'DATE_FORMAT_LC4'; } else { $format = $matches[1]; } $date = date(JText::_($format), strtotime($created)); return $date; }, $text); $regexText = "#CKDATE_MODIFIED\[(.*?)\]#"; // replace all divs with class ckprops $text = preg_replace_callback($regexText, function($matches) use ($text, $modified) { // if (! $this->item) return $matches[0]; if (!$matches[1]) { $format = 'DATE_FORMAT_LC4'; } else { $format = $matches[1]; } $date = date(JText::_($format), strtotime($modified)); return $date; }, $text); } /* * @param array the matching strings * * return the translated string */ public function replaceDateCreated($matches) { if (! $this->item) return $matches[0]; if (!$matches[1]) { $format = 'DATE_FORMAT_LC4'; } else { $format = $matches[1]; } $date = date(JText::_($format), strtotime($this->item->created)); return $date; } /* * @param array the matching strings * * return the translated string */ public function replaceDateModified($matches) { if (! $this->item) return $matches[0]; if (!$matches[1]) { $format = 'DATE_FORMAT_LC4'; } else { $format = $matches[1]; } $date = date(JText::_($format), strtotime($this->item->modified)); return $date; } /* * @param array the matching strings * * return the translated string */ public function replaceTranslation($matches) { if (!$matches[1]) return; return JText::_($matches[1]); } /* * @param array the matching strings * * return the update image tag */ public function replaceImage($matches) { if (!$matches[1]) return; $imgtag = $matches[0]; // get global component params $pagebuilderckParams = JComponentHelper::getParams('com_pagebuilderck'); // check for the image path, and fix it if (strpos($imgtag, 'data-src=')) { if ((int)$pagebuilderckParams->get('image_path_fix', 0, 'int') === 1) { // remove the src attribute, it will be created later $find = "# src=\"(.*?)\"#si"; // masque de recherche pour le tag $imgtag = preg_replace($find, '', $imgtag); if (strpos($imgtag, 'data-src="/')) { // fix url starting with a slash $find = "#data-src=\"/(.*?)\"#si"; // masque de recherche pour le tag $imgtag = preg_replace($find, ' src="' . JUri::root(true) . '/$1"', $imgtag); } else { // fix url not starting with a slash $find = "#data-src=\"(.*?)\"#si"; // masque de recherche pour le tag $imgtag = preg_replace($find, ' src="' . JUri::root(true) . '/$1"', $imgtag); } } else { $find = "#data-src=\"(.*?)\"#si"; // masque de recherche pour le tag $imgtag = preg_replace($find, '', $imgtag); } } // add lazy loading if ((int)$pagebuilderckParams->get('lazy_loading', 0, 'int') === 1) { $imgtag = str_replace ('<img', '<img loading="lazy"', $imgtag); } return $imgtag; } /* * @param array the matching strings * * return void */ public function replaceGooglefont($matches) { if (!isset($matches[2])) return; $fontfamilies = explode('<', $matches[2]); foreach ($fontfamilies as $fontfamily) { $fontfamily = trim($fontfamily); $fontfamily = str_replace('link href="', '', $fontfamily); $fontfamily = str_replace('" rel="stylesheet" type="text/css">', '', $fontfamily); if ($fontfamily) PagebuilderckFrontHelper::addStylesheet($fontfamily); } return; } /* * @param array the matching strings * * return the module cdoe */ public function replaceResponsiveStyleTag($matches) { if (!$matches[2]) return; $styleTag = trim($matches[2]); $styleTag = str_replace('<style>', '', $styleTag); $styleTag = str_replace('<style type="text/css">', '', $styleTag); $styleTag = str_replace('</style>', '', $styleTag); $styleTag = str_replace(' ', ' ', $styleTag); if ($styleTag) { if (stristr($matches[1], 'ckresponsiverange4')) { $this->responsiveStyleTags4 .= str_replace('.ckresponsiveactive[ckresponsiverange="4"] ', '', $styleTag); $this->responsiveStyleTags4 .= str_replace('.ckresponsiveactive[ckresponsiverange*="4"] ', '', $styleTag); } else if (stristr($matches[1], 'ckresponsiverange3')) { $this->responsiveStyleTags3 .= str_replace('.ckresponsiveactive[ckresponsiverange="3"] ', '', $styleTag); $this->responsiveStyleTags3 .= str_replace('.ckresponsiveactive[ckresponsiverange*="3"] ', '', $styleTag); } else if (stristr($matches[1], 'ckresponsiverange2')) { $this->responsiveStyleTags2 .= str_replace('.ckresponsiveactive[ckresponsiverange="2"] ', '', $styleTag); $this->responsiveStyleTags2 .= str_replace('.ckresponsiveactive[ckresponsiverange*="2"] ', '', $styleTag); } else if (stristr($matches[1], 'ckresponsiverange1')) { $this->responsiveStyleTags1 .= str_replace('.ckresponsiveactive[ckresponsiverange="1"] ', '', $styleTag); $this->responsiveStyleTags1 .= str_replace('.ckresponsiveactive[ckresponsiverange*="1"] ', '', $styleTag); } else if (stristr($styleTag, 'ckresponsiverange="4"')) { $this->responsiveStyleTags4 .= str_replace('[ckresponsiverange="4"] ', '', $styleTag); $this->responsiveStyleTags4 .= str_replace('[ckresponsiverange*="4"] ', '', $styleTag); } else if (stristr($styleTag, 'ckresponsiverange="3"')) { $this->responsiveStyleTags3 .= str_replace('[ckresponsiverange="3"] ', '', $styleTag); $this->responsiveStyleTags3 .= str_replace('[ckresponsiverange*="3"] ', '', $styleTag); } else if (stristr($styleTag, 'ckresponsiverange="2"')) { $this->responsiveStyleTags2 .= str_replace('[ckresponsiverange="2"] ', '', $styleTag); $this->responsiveStyleTags2 .= str_replace('[ckresponsiverange*="2"] ', '', $styleTag); } else if (stristr($styleTag, 'ckresponsiverange="1"')) { $this->responsiveStyleTags1 .= str_replace('[ckresponsiverange="1"] ', '', $styleTag); $this->responsiveStyleTags1 .= str_replace('[ckresponsiverange*="1"] ', '', $styleTag); } else if (stristr($styleTag, 'ckresponsiverange="4321"')) { $this->responsiveStyleTags1 .= str_replace('[ckresponsiverange="4321"] ', '', $styleTag); } else if (stristr($styleTag, 'ckresponsiverange="432"') || stristr($styleTag, 'ckresponsiverange="432')) { $this->responsiveStyleTags2 .= str_replace('[ckresponsiverange="432"] ', '', $styleTag); } else if (stristr($styleTag, 'ckresponsiverange="43"') || stristr($styleTag, 'ckresponsiverange="43')) { $this->responsiveStyleTags3 .= str_replace('[ckresponsiverange="43"] ', '', $styleTag); } else { if ($styleTag) $this->styleTags .= $styleTag; } } return ''; } /* * @param array the matching strings * * return the module cdoe */ public function replaceStyleTag($matches) { if (!$matches[2]) return; $styleTag = trim($matches[2]); $styleTag = str_replace('<style>', '', $styleTag); $styleTag = str_replace('<style type="text/css">', '', $styleTag); $styleTag = str_replace('</style>', '', $styleTag); $styleTag = str_replace(' ', ' ', $styleTag); $pagebuilderckParams = JComponentHelper::getParams('com_pagebuilderck'); // check for the image path, and fix it if (strpos($styleTag, 'url(\'/')) { if ((int)$pagebuilderckParams->get('image_path_fix', 0, 'int') === 1) { $find = "# url\('/(.*?)\'\)#si"; // masque de recherche pour le tag $styleTag = preg_replace($find, ' url(\'' . JUri::root(true) . '/$1\')' , $styleTag); } } if ($styleTag) $this->styleTags .= $styleTag; return ''; } /* * @param array the matching strings * * return the module code */ public function replaceModule($matches) { if (!$matches[2]) return; // look for the module ID $find = "#data-id=\"(.*?)\"#si"; // masque de recherche pour le tag preg_match($find, $matches[2], $result_id); if ($result_id && $result_id[1]) { return $this->renderModule($result_id[1]); } return ''; } /* * @param array the matching strings * * return the page code */ public function replacePage($matches) { if (!$matches[2]) return; // look for the module ID $find = "#data-id=\"(.*?)\"#si"; // masque de recherche pour le tag preg_match($find, $matches[2], $result_id); if ($result_id && $result_id[1]) { return $this->renderPage($result_id[1]); } return ''; } /* * @param object the element * * return the module cdoe */ public function replaceElement($e) { $type = $e->attr['data-type']; if ($type) { $new_e = $this->renderElement($type, $e); if ($new_e) { return $new_e; } else { return $e->innertext; } } else if ($type == 'audio') { return $this->renderAudioElement($e); } else { return '<p style="text-align:center;color:red;font-size:14px;">ERROR - PAGEBUILDER CK DEBUG : ELEMENT TYPE NOT FOUND</p>'; } return $e->innertext; } /* * @param object the element * * return the element html code for html5 audio */ public function renderCode($e) { // check if there is a plugin for this type, and if it is enabled if ( !JPluginHelper::isEnabled('pagebuilderck', 'code')) { return ''; } JPluginHelper::importPlugin( 'pagebuilderck' ); // $dispatcher = JEventDispatcher::getInstance(); $otheritems = Pagebuilderck\CKFof::triggerEvent( 'onPagebuilderckRenderItem' . ucfirst('code') , array($e)); // load only the first instance found, because each plugin type must be unique // add override feature here, look in the template $template = JFactory::getApplication()->getTemplate(); $overridefile = JPATH_ROOT . '/templates/' . $template . '/html/pagebuilderck/' . strtolower('code') . '.php'; // var_dump($otheritems); if (file_exists($overridefile)) { $item = $e; include_once $overridefile; } else { // normal use // $html = $otheritems[0]; } // echo $html; return ''; } /* * @param object the element * * return the element html code for html5 audio */ public function renderAudioElement($e) { $attrs = $e->find('.tab_audio'); $params = PagebuilderckFrontHelper::createParamsFromElement($attrs); $audiosrc = PagebuilderckFrontHelper::getSource($params->get('audiourl')); $html ='<audio style="width:100%;box-sizing:border-box;max-width:100%;" controls src="' . $audiosrc . '" ' . ($params->get('autoplayyes') == 'checked' ? 'autoplay' : '') . '>' . 'Your browser does not support the audio element.' . '</audio>'; $html2 = preg_replace('#<div class="audiock">(.*?)<\/div>#is', $html, $e->innertext); return $html2; } /* * @param string the element type * @param object the element * * return the element html code */ public function renderElement($type, $e) { // check if there is a plugin for this type, and if it is enabled if ( !JPluginHelper::isEnabled('pagebuilderck', $type)) { return ''; } $doc = JFactory::getDocument(); JPluginHelper::importPlugin( 'pagebuilderck' ); // $dispatcher = JEventDispatcher::getInstance(); $otheritems = Pagebuilderck\CKFof::triggerEvent( 'onPagebuilderckRenderItem' . ucfirst($type) , array($e)); ob_start(); if (count($otheritems) == 1) { // load only the first instance found, because each plugin type must be unique // add override feature here, look in the template $template = JFactory::getApplication()->getTemplate(); $overridefile = JPATH_ROOT . '/templates/' . $template . '/html/pagebuilderck/' . strtolower($type) . '.php'; if (file_exists($overridefile)) { $item = $e; include_once $overridefile; try { $class = 'plgPagebuilderck' . ucfirst($type) . 'Override'; $func = 'onPagebuilderckRenderItem' . ucfirst($type); $reflection = new ReflectionClass($class); $instance = $reflection->newInstanceWithoutConstructor(); if ($instance) { $html = $instance->$func($e); } } catch (Exception $e) { } } else { // normal use $html = $otheritems[0]; } echo $html; } else { echo '<p style="text-align:center;color:red;font-size:14px;">ERROR - PAGEBUILDER CK DEBUG : ELEMENT TYPE INSTANCE : ' . $type . '. Number of instances found : ' . count($otheritems) . '</p>'; } $element_code = ob_get_clean(); return $element_code; } /* * @param int the module ID * * return the module html code */ public function renderModule($module_id) { $document = JFactory::getDocument(); $renderer = $document->loadRenderer('module'); $mod = $this->getModule($module_id); if (empty($mod)) $mod = JModuleHelper::getModuleById($module_id); if (!$mod) return; $params = array('style' => 'xhtml'); ob_start(); echo $renderer->render($mod, $params); $module_code = ob_get_clean(); return $module_code; } public function getModule($module_id) { $app = JFactory::getApplication(); $groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels()); $lang = JFactory::getLanguage()->getTag(); $clientId = (int) $app->getClientId(); $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid') ->from('#__modules AS m') ->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = m.id') ->where('m.published = 1') ->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id') ->where('e.enabled = 1'); $date = JFactory::getDate(); $now = $date->toSql(); $nullDate = $db->getNullDate(); $query->where('(m.publish_up = ' . $db->quote($nullDate) . ' OR m.publish_up <= ' . $db->quote($now) . ')') ->where('(m.publish_down = ' . $db->quote($nullDate) . ' OR m.publish_down >= ' . $db->quote($now) . ')') ->where('m.access IN (' . $groups . ')') ->where('m.client_id = ' . $clientId) ->where('m.id = ' . (int) $module_id) // ->where('(mm.menuid = ' . (int) $Itemid . ' OR mm.menuid <= 0)'); ; // Filter by language if (\Pagebuilderck\CKFof::isSite() && $app->getLanguageFilter()) { $query->where('m.language IN (' . $db->quote($lang) . ',' . $db->quote('*') . ')'); } // $query->order('m.position, m.ordering'); // Set the query $db->setQuery($query); try { $module = $db->loadObject(); } catch (RuntimeException $e) { JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $e->getMessage()), JLog::WARNING, 'jerror'); return array(); } return $module; } /** * Module list * * @return array */ public static function getModuleList() { $app = JFactory::getApplication(); $Itemid = $app->input->getInt('Itemid'); $groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels()); $lang = JFactory::getLanguage()->getTag(); $clientId = (int) $app->getClientId(); $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid') ->from('#__modules AS m') ->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = m.id') ->where('m.published = 1') ->join('LEFT', '#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id') ->where('e.enabled = 1'); $date = JFactory::getDate(); $now = $date->toSql(); $nullDate = $db->getNullDate(); $query->where('(m.publish_up = ' . $db->quote($nullDate) . ' OR m.publish_up <= ' . $db->quote($now) . ')') ->where('(m.publish_down = ' . $db->quote($nullDate) . ' OR m.publish_down >= ' . $db->quote($now) . ')') ->where('m.access IN (' . $groups . ')') ->where('m.client_id = ' . $clientId) ->where('(mm.menuid = ' . (int) $Itemid . ' OR mm.menuid <= 0)'); // Filter by language if (\Pagebuilderck\CKFof::isSite() && $app->getLanguageFilter()) { $query->where('m.language IN (' . $db->quote($lang) . ',' . $db->quote('*') . ')'); } $query->order('m.position, m.ordering'); // Set the query $db->setQuery($query); try { $modules = $db->loadObjectList(); } catch (RuntimeException $e) { JLog::add(JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $e->getMessage()), JLog::WARNING, 'jerror'); return array(); } return $modules; } /** * Method to get an ojbect. * * @param integer The id of the object to get. * * @return mixed Object on success, false on failure. */ public function &getData($id = null) { if (empty($id)) { $id = $this->input->get('id', $id, 'int'); } if ($id === 0) { // check that the user has the rights to edit $authorised = ($user->authorise('core.create', 'com_pagebuilderck') || (count($user->getAuthorisedCategories('com_pagebuilderck', 'core.create')))); if ($authorised !== true) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); return false; } $item = CKFof::dbLoad($this->table, $id); } else { $query = "SELECT * FROM " . $this->table . " AS a" . " WHERE a.state = 1" . " AND a.id = " . (int) $id; $item = CKFof::dbLoadObject($query); } return $this->item; } /** * Method to save the form data. * * @param array The form data. * @return mixed The user id on success, false on failure. * @since 1.6 */ public function save($data) { $id = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('page.id'); $user = CKFof::getUser(); $data['htmlcode'] = $this->input->get('htmlcode', '', 'raw'); $data['htmlcode'] = str_replace(JUri::root(true), "|URIROOT|", $data['htmlcode']); if (isset($data['options']) && is_array($data['options'])) { $registry = new Registry; $registry->loadArray($data['options']); $data['params'] = (string) $registry; } // save the date $date = JFactory::getDate(); $data['modified'] = $date->toSql(); if ($id) { //Check the user can edit this item $authorised = $user->authorise('core.edit', 'page.' . $id); } else { //Check the user can create new items in this section $authorised = $user->authorise('core.create', 'com_pagebuilderck'); $data['created'] = $date->toSql(); } if ($authorised !== true) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); return false; } // make a backup before save PagebuilderckHelper::makeBackup($this->getData($data['id'])); $pageid = CKFof::dbStore($this->table, $data); return $pageid; } /* * @param int the module ID * * return the module html code */ public function renderPage($id) { include_once JPATH_ROOT . '/components/com_pagebuilderck/models/page.php'; $model = JModelLegacy::getInstance('Page', 'PagebuilderckModel'); $page = $model->getItem($id); ob_start(); if (isset($page->htmlcode) && $page->htmlcode) { echo $page->htmlcode; } $code = ob_get_clean(); return $code; } /* * @param string the styles comma separated * * return the css code */ private function loadStyles($stylestoload) { // Create a new query object. $db = CKFof::getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select('a.*'); $query->from('`#__pagebuilderck_styles` AS a'); $query->where('a.id in ( ' . $stylestoload .')'); // Do not list the trashed items $query->where('a.state > -1'); $db->setQuery($query); $styles = $db->loadObjectList(); foreach($styles as $style) { PagebuilderckFrontHelper::addStyleDeclaration($style->stylecode); } } } styles.php 0000644 00000000623 15247074252 0006611 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/styles.php'; index.html 0000644 00000000037 15247074252 0006551 0 ustar 00 <!DOCTYPE html><title></title> pages.php 0000644 00000000622 15247074252 0006364 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/pages.php'; element.php 0000644 00000000624 15247074252 0006720 0 ustar 00 <?php /** * @name Page Builder CK * @package com_pagebuilderck * @copyright Copyright (C) 2015. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr */ defined('_JEXEC') or die; require_once JPATH_ADMINISTRATOR . '/components/com_pagebuilderck/models/element.php'; banner.php 0000644 00000010221 15247110751 0006521 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); /** * Banner model for the Joomla Banners component. * * @since 1.5 */ class BannersModelBanner extends JModelLegacy { /** * Cached item object * * @var object * @since 1.6 */ protected $_item; /** * Clicks the URL, incrementing the counter * * @return void * * @since 1.5 */ public function click() { $item = $this->getItem(); if (empty($item)) { throw new Exception(JText::_('JERROR_PAGE_NOT_FOUND'), 404); } $id = $this->getState('banner.id'); // Update click count $db = $this->getDbo(); $query = $db->getQuery(true) ->update('#__banners') ->set('clicks = (clicks + 1)') ->where('id = ' . (int) $id); $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); } // Track clicks $trackClicks = $item->track_clicks; if ($trackClicks < 0 && $item->cid) { $trackClicks = $item->client_track_clicks; } if ($trackClicks < 0) { $config = JComponentHelper::getParams('com_banners'); $trackClicks = $config->get('track_clicks'); } if ($trackClicks > 0) { $trackDate = JFactory::getDate()->format('Y-m-d H:00:00'); $trackDate = JFactory::getDate($trackDate)->toSql(); $query->clear() ->select($db->quoteName('count')) ->from('#__banner_tracks') ->where('track_type=2') ->where('banner_id=' . (int) $id) ->where('track_date=' . $db->quote($trackDate)); $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); } $count = $db->loadResult(); $query->clear(); if ($count) { // Update count $query->update('#__banner_tracks') ->set($db->quoteName('count') . ' = (' . $db->quoteName('count') . ' + 1)') ->where('track_type=2') ->where('banner_id=' . (int) $id) ->where('track_date=' . $db->quote($trackDate)); } else { // Insert new count $query->insert('#__banner_tracks') ->columns( array( $db->quoteName('count'), $db->quoteName('track_type'), $db->quoteName('banner_id'), $db->quoteName('track_date') ) ) ->values('1, 2,' . (int) $id . ',' . $db->quote($trackDate)); } $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); } } } /** * Get the data for a banner. * * @return object * * @since 1.6 */ public function &getItem() { if (!isset($this->_item)) { /** @var JCacheControllerCallback $cache */ $cache = JFactory::getCache('com_banners', 'callback'); $id = $this->getState('banner.id'); // For PHP 5.3 compat we can't use $this in the lambda function below, so grab the database driver now to use it $db = $this->getDbo(); $loader = function ($id) use ($db) { $query = $db->getQuery(true) ->select( array( $db->quoteName('a.clickurl', 'clickurl'), $db->quoteName('a.cid', 'cid'), $db->quoteName('a.track_clicks', 'track_clicks'), $db->quoteName('cl.track_clicks', 'client_track_clicks'), ) ) ->from($db->quoteName('#__banners', 'a')) ->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid') ->where('a.id = ' . (int) $id); $db->setQuery($query); return $db->loadObject(); }; try { $this->_item = $cache->get($loader, array($id), md5(__METHOD__ . $id)); } catch (JCacheException $e) { $this->_item = $loader($id); } } return $this->_item; } /** * Get the URL for a banner * * @return string * * @since 1.5 */ public function getUrl() { $item = $this->getItem(); $url = $item->clickurl; // Check for links if (!preg_match('#http[s]?://|index[2]?\.php#', $url)) { $url = "http://$url"; } return $url; } } banners.php 0000644 00000021130 15247110751 0006705 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_banners * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; use Joomla\Utilities\ArrayHelper; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); /** * Banners model for the Joomla Banners component. * * @since 1.6 */ class BannersModelBanners extends JModelList { /** * 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.tag_search'); $id .= ':' . $this->getState('filter.client_id'); $id .= ':' . serialize($this->getState('filter.category_id')); $id .= ':' . serialize($this->getState('filter.keywords')); return parent::getStoreId($id); } /** * Method to get a JDatabaseQuery object for retrieving the data set from a database. * * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set. * * @since 1.6 */ protected function getListQuery() { $db = $this->getDbo(); $query = $db->getQuery(true); $ordering = $this->getState('filter.ordering'); $tagSearch = $this->getState('filter.tag_search'); $cid = $this->getState('filter.client_id'); $categoryId = $this->getState('filter.category_id'); $keywords = $this->getState('filter.keywords'); $randomise = ($ordering === 'random'); $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote(JFactory::getDate()->toSql()); $query->select( 'a.id as id,' . 'a.type as type,' . 'a.name as name,' . 'a.clickurl as clickurl,' . 'a.cid as cid,' . 'a.description as description,' . 'a.params as params,' . 'a.custombannercode as custombannercode,' . 'a.track_impressions as track_impressions,' . 'cl.track_impressions as client_track_impressions' ) ->from('#__banners as a') ->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid') ->where('a.state=1') ->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')') ->where('(a.imptotal = 0 OR a.impmade < a.imptotal)'); if ($cid) { $query->where('a.cid = ' . (int) $cid) ->where('cl.state = 1'); } // Filter by a single or group of categories if (is_numeric($categoryId)) { $type = $this->getState('filter.category_id.include', true) ? '= ' : '<> '; // Add subcategory check $includeSubcategories = $this->getState('filter.subcategories', false); $categoryEquals = 'a.catid ' . $type . (int) $categoryId; if ($includeSubcategories) { $levels = (int) $this->getState('filter.max_category_levels', '1'); // Create a subquery for the subcategory list $subQuery = $db->getQuery(true); $subQuery->select('sub.id') ->from('#__categories as sub') ->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt') ->where('this.id = ' . (int) $categoryId) ->where('sub.level <= this.level + ' . $levels); // Add the subquery to the main query $query->where('(' . $categoryEquals . ' OR a.catid IN (' . (string) $subQuery . '))'); } else { $query->where($categoryEquals); } } elseif (is_array($categoryId) && (count($categoryId) > 0)) { $categoryId = ArrayHelper::toInteger($categoryId); $categoryId = implode(',', $categoryId); if ($categoryId != '0') { $type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN'; $query->where('a.catid ' . $type . ' (' . $categoryId . ')'); } } if ($tagSearch) { if (!$keywords) { $query->where('0 != 0'); } else { $temp = array(); $config = JComponentHelper::getParams('com_banners'); $prefix = $config->get('metakey_prefix'); if ($categoryId) { $query->join('LEFT', '#__categories as cat ON a.catid = cat.id'); } foreach ($keywords as $keyword) { $condition1 = 'a.own_prefix=1 ' . ' AND a.metakey_prefix=SUBSTRING(' . $db->quote($keyword) . ',1,LENGTH( a.metakey_prefix)) ' . ' OR a.own_prefix=0 ' . ' AND cl.own_prefix=1 ' . ' AND cl.metakey_prefix=SUBSTRING(' . $db->quote($keyword) . ',1,LENGTH(cl.metakey_prefix)) ' . ' OR a.own_prefix=0 ' . ' AND cl.own_prefix=0 ' . ' AND ' . ($prefix == substr($keyword, 0, strlen($prefix)) ? '0 = 0' : '0 != 0'); $regexp = $db->quote("[[:<:]]" . $db->escape($keyword) . "[[:>:]]"); $condition2 = "a.metakey " . $query->regexp($regexp) . " "; if ($cid) { $condition2 .= " OR cl.metakey " . $query->regexp($regexp) . " "; } if ($categoryId) { $condition2 .= " OR cat.metakey " . $query->regexp($regexp) . " "; } $temp[] = "($condition1) AND ($condition2)"; } $query->where('(' . implode(' OR ', $temp) . ')'); } } // Filter by language if ($this->getState('filter.language')) { $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } $query->order('a.sticky DESC,' . ($randomise ? $query->Rand() : 'a.ordering')); return $query; } /** * Get a list of banners. * * @return array * * @since 1.6 */ public function getItems() { if ($this->getState('filter.tag_search')) { // Filter out empty keywords. $keywords = array_values(array_filter(array_map('trim', $this->getState('filter.keywords')), 'strlen')); // Re-set state before running the query. $this->setState('filter.keywords', $keywords); // If no keywords are provided, avoid running the query. if (!$keywords) { $this->cache['items'] = array(); return $this->cache['items']; } } if (!isset($this->cache['items'])) { $this->cache['items'] = parent::getItems(); foreach ($this->cache['items'] as &$item) { $item->params = new Registry($item->params); } } return $this->cache['items']; } /** * Makes impressions on a list of banners * * @return void * * @since 1.6 */ public function impress() { $trackDate = JFactory::getDate()->format('Y-m-d H:00:00'); $trackDate = JFactory::getDate($trackDate)->toSql(); $items = $this->getItems(); $db = $this->getDbo(); $query = $db->getQuery(true); if (!count($items)) { return; } foreach ($items as $item) { $bid[] = (int) $item->id; } // Increment impression made $query->clear() ->update('#__banners') ->set('impmade = (impmade + 1)') ->where('id IN (' . implode(',', $bid) . ')'); $db->setQuery($query); try { $db->execute(); } catch (JDatabaseExceptionExecuting $e) { JError::raiseError(500, $e->getMessage()); } foreach ($items as $item) { // Track impressions $trackImpressions = $item->track_impressions; if ($trackImpressions < 0 && $item->cid) { $trackImpressions = $item->client_track_impressions; } if ($trackImpressions < 0) { $config = JComponentHelper::getParams('com_banners'); $trackImpressions = $config->get('track_impressions'); } if ($trackImpressions > 0) { // Is track already created? // Update count $query->clear(); $query->update('#__banner_tracks') ->set($db->quoteName('count') . ' = (' . $db->quoteName('count') . ' + 1)') ->where('track_type=1') ->where('banner_id=' . (int) $item->id) ->where('track_date=' . $db->quote($trackDate)); $db->setQuery($query); try { $db->execute(); } catch (JDatabaseExceptionExecuting $e) { JError::raiseError(500, $e->getMessage()); } if ($db->getAffectedRows() === 0) { // Insert new count $query->clear(); $query->insert('#__banner_tracks') ->columns( array( $db->quoteName('count'), $db->quoteName('track_type'), $db->quoteName('banner_id'), $db->quoteName('track_date') ) ) ->values('1, 1, ' . (int) $item->id . ', ' . $db->quote($trackDate)); $db->setQuery($query); try { $db->execute(); } catch (JDatabaseExceptionExecuting $e) { JError::raiseError(500, $e->getMessage()); } } } } } } vendors.php 0000644 00000005717 15247110770 0006753 0 ustar 00 <?php /** * @package J2Store * @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org * @license GNU GPL v3 or later */ // No direct access to this file defined('_JEXEC') or die; class J2StoreModelVendors extends F0FModel { public function &getItem($id = null) { $user = JFactory::getUser(); $this->record = F0FTable::getAnInstance('Vendoruser','J2StoreTable'); $this->record->load($user->id); $this->record->products = F0FModel::getTmpInstance('Products' ,'J2StoreModel') ->vendor_id($this->record->j2store_vendor_id) ->enabled(1) ->getList(); return $this->record; } public function buildQuery($overrideLimits = false) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('#__j2store_vendors.*')->from("#__j2store_vendors as #__j2store_vendors"); $query->select($db->qn('#__j2store_addresses').'.j2store_address_id') ->select($db->qn('#__j2store_addresses').'.first_name') ->select($db->qn('#__j2store_addresses').'.last_name') ->select($db->qn('#__j2store_addresses').'.address_1') ->select($db->qn('#__j2store_addresses').'.address_2') ->select($db->qn('#__j2store_addresses').'.user_id') ->select($db->qn('#__j2store_addresses').'.email') ->select($db->qn('#__j2store_addresses').'.city') ->select($db->qn('#__j2store_addresses').'.zip') ->select($db->qn('#__j2store_addresses').'.zone_id') ->select($db->qn('#__j2store_addresses').'.country_id') ->select($db->qn('#__j2store_addresses').'.phone_1') ->select($db->qn('#__j2store_addresses').'.phone_2') ->select($db->qn('#__j2store_addresses').'.fax') ->select($db->qn('#__j2store_addresses').'.type') ->select($db->qn('#__j2store_addresses').'.company') ->select($db->qn('#__j2store_addresses').'.tax_number') ->select($db->qn('#__j2store_countries').'.country_name') ->select($db->qn('#__j2store_zones').'.zone_name') ->leftJoin('#__j2store_addresses ON #__j2store_addresses.j2store_address_id = #__j2store_vendors.address_id') ->leftJoin('#__j2store_countries ON #__j2store_countries.j2store_country_id = #__j2store_addresses.country_id') ->leftJoin('#__j2store_zones ON #__j2store_zones.j2store_zone_id = #__j2store_addresses.zone_id'); //$this->buildOrderbyQuery($query); return $query; } public function buildOrderbyQuery(&$query){ $state = $this->getState(); $app = JFactory::getApplication(); $filter_order_Dir = $app->input->getString('filter_order_Dir','asc'); $filter_order = $app->input->getString('filter_order','filter_name'); //check filter if($filter_order =='j2store_vendor_id' || $filter_order =='enabled' ){ $query->order('#__j2store_vendors.'.$filter_order.' '.$filter_order_Dir); }else if($filter_order =='country_name' ){ $query->order('#__j2store_countries.'.$filter_order.' '.$filter_order_Dir); }else if($filter_order =='zone_name' ){ $query->order('#__j2store_zones.'.$filter_order.' '.$filter_order_Dir); }else{ $query->order('#__j2store_addresses.'.$filter_order.' '.$filter_order_Dir); } } } callback.php 0000644 00000003421 15247110770 0007015 0 ustar 00 <?php /*------------------------------------------------------------------------ # com_j2store - J2Store # ------------------------------------------------------------------------ # author Ramesh Elamathi - Weblogicx India http://www.weblogicxindia.com # copyright Copyright (C) 2014 - 19 Weblogicxindia.com. All Rights Reserved. # @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Websites: http://j2store.org # Technical Support: Forum - http://j2store.org/forum/index.html -------------------------------------------------------------------------*/ defined ( '_JEXEC' ) or die ( 'Restricted access' ); class J2StoreModelCallback extends F0FModel { function runCallback($method) { $app = JFactory::getApplication (); $rawDataPost = $app->input->getArray($_POST); $rawDataGet = $app->input->getArray($_GET); $data = array_merge ( $rawDataGet, $rawDataPost ); // Some plugins result in an empty Itemid being added to the request // data, screwing up the payment callback validation in some cases (e.g. // PayPal). if (array_key_exists ( 'Itemid', $data )) { if (empty ( $data ['Itemid'] )) { unset ( $data ['Itemid'] ); } } $plugin_helper = J2Store::plugin(); $row = $plugin_helper->getPlugin($method); //sanity check if($row == false || $row->element != $method) return false; //undefined method. Do not execute //trigger a callback event J2Store::plugin()->event('Callback', array($row, $data)); //run the post payment trigger. Callback normally used in post payment. $jResponse = J2Store::plugin()->event('PostPayment', array ( $row, $data ) ); if (empty ( $jResponse )) return false; $status = false; foreach ( $jResponse as $response ) { $status = $status || $response; } return $status; } } forms/filter_fields.xml 0000644 00000005403 15247124615 0011240 0 ustar 00 <?xml version="1.0" encoding="utf-8"?> <form> <fieldset name="group" addfieldpath="/administrator/components/com_fields/models/fields"> <field name="context" type="fieldcontexts" onchange="this.form.submit();" /> </fieldset> <fields name="filter"> <field name="search" type="text" inputmode="search" label="" hint="JSEARCH_FILTER" class="js-stools-search-string" /> <field name="state" type="status" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_PUBLISHED</option> </field> <field name="group_id" type="fieldgroups" state="0,1,2" onchange="this.form.submit();" > <option value="">COM_FIELDS_VIEW_FIELDS_SELECT_GROUP</option> </field> <field name="assigned_cat_ids" type="category" onchange="this.form.submit();" > <option value="">COM_FIELDS_VIEW_FIELDS_SELECT_CATEGORY</option> </field> <field name="access" type="accesslevel" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_ACCESS</option> </field> <field name="language" type="contentlanguage" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_LANGUAGE</option> </field> </fields> <fields name="list"> <field name="fullordering" type="list" label="JGLOBAL_SORT_BY" description="JGLOBAL_SORT_BY" statuses="*,0,1,2,-2" onchange="this.form.submit();" default="a.ordering ASC" validate="options" > <option value="">JGLOBAL_SORT_BY</option> <option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option> <option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option> <option value="a.state ASC">JSTATUS_ASC</option> <option value="a.state DESC">JSTATUS_DESC</option> <option value="a.title ASC">JGLOBAL_TITLE_ASC</option> <option value="a.title DESC">JGLOBAL_TITLE_DESC</option> <option value="a.type ASC">COM_FIELDS_VIEW_FIELDS_SORT_TYPE_ASC</option> <option value="a.type DESC">COM_FIELDS_VIEW_FIELDS_SORT_TYPE_DESC</option> <option value="g.title ASC">COM_FIELDS_VIEW_FIELDS_SORT_GROUP_ASC</option> <option value="g.title DESC">COM_FIELDS_VIEW_FIELDS_SORT_GROUP_DESC</option> <option value="a.access ASC">JGRID_HEADING_ACCESS_ASC</option> <option value="a.access DESC">JGRID_HEADING_ACCESS_DESC</option> <option value="a.language ASC">JGRID_HEADING_LANGUAGE_ASC</option> <option value="a.language DESC">JGRID_HEADING_LANGUAGE_DESC</option> <option value="a.id ASC">JGRID_HEADING_ID_ASC</option> <option value="a.id DESC">JGRID_HEADING_ID_DESC</option> </field> <field name="limit" type="limitbox" label="COM_FIELDS_LIST_LIMIT" description="COM_FIELDS_LIST_LIMIT_DESC" class="input-mini" default="25" onchange="this.form.submit();" /> </fields> </form> archive.php 0000644 00000012315 15247133465 0006712 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_content * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JLoader::register('ContentModelArticles', __DIR__ . '/articles.php'); /** * Content Component Archive Model * * @since 1.5 */ class ContentModelArchive extends ContentModelArticles { /** * Model context string. * * @var string */ public $_context = 'com_content.archive'; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering The field to order on. * @param string $direction The direction to order on. * * @return void. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { parent::populateState(); $app = JFactory::getApplication(); // Add archive properties $params = $this->state->params; // Filter on archived articles $this->setState('filter.published', 2); // Filter on month, year $this->setState('filter.month', $app->input->getInt('month')); $this->setState('filter.year', $app->input->getInt('year')); // Optional filter text $this->setState('list.filter', $app->input->getString('filter-search')); // Get list limit $itemid = $app->input->get('Itemid', 0, 'int'); $limit = $app->getUserStateFromRequest('com_content.archive.list' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint'); $this->setState('list.limit', $limit); // Set the archive ordering $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); // No category ordering $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate); $this->setState('list.ordering', $secondary . ', a.created DESC'); $this->setState('list.direction', ''); } /** * Get the master query for retrieving a list of articles subject to the model state. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { $params = $this->state->params; $articleOrderDate = $params->get('order_date'); // Create a new query object. $query = parent::getListQuery(); // Add routing for archive // Sqlsrv changes $case_when = ' CASE WHEN '; $case_when .= $query->charLength('a.alias', '!=', '0'); $case_when .= ' THEN '; $a_id = $query->castAsChar('a.id'); $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $a_id . ' END as slug'; $query->select($case_when); $case_when = ' CASE WHEN '; $case_when .= $query->charLength('c.alias', '!=', '0'); $case_when .= ' THEN '; $c_id = $query->castAsChar('c.id'); $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':'); $case_when .= ' ELSE '; $case_when .= $c_id . ' END as catslug'; $query->select($case_when); // Filter on month, year // First, get the date field $queryDate = ContentHelperQuery::getQueryDate($articleOrderDate); if ($month = $this->getState('filter.month')) { $query->where($query->month($queryDate) . ' = ' . $month); } if ($year = $this->getState('filter.year')) { $query->where($query->year($queryDate) . ' = ' . $year); } return $query; } /** * Method to get the archived article list * * @access public * @return array */ public function getData() { $app = JFactory::getApplication(); // Lets load the content if it doesn't already exist if (empty($this->_data)) { // Get the page/component configuration $params = $app->getParams(); // Get the pagination request variables $limit = $app->input->get('limit', $params->get('display_num', 20), 'uint'); $limitstart = $app->input->get('limitstart', 0, 'uint'); $query = $this->_buildQuery(); $this->_data = $this->_getList($query, $limitstart, $limit); } return $this->_data; } /** * JModelLegacy override to add alternating value for $odd * * @param string $query The query. * @param integer $limitstart Offset. * @param integer $limit The number of records. * * @return array An array of results. * * @since 12.2 * @throws RuntimeException */ protected function _getList($query, $limitstart=0, $limit=0) { $result = parent::_getList($query, $limitstart, $limit); $odd = 1; foreach ($result as $k => $row) { $result[$k]->odd = $odd; $odd = 1 - $odd; } return $result; } /** * Gets the archived articles years * * @return array * * @since 3.6.0 */ public function getYears() { $db = $this->getDbo(); $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote(JFactory::getDate()->toSql()); $query = $db->getQuery(true); $years = $query->year($db->qn('created')); $query->select('DISTINCT (' . $years . ')') ->from($db->qn('#__content')) ->where($db->qn('state') . '= 2') ->where('(publish_up = ' . $nullDate . ' OR publish_up <= ' . $nowDate . ')') ->where('(publish_down = ' . $nullDate . ' OR publish_down >= ' . $nowDate . ')') ->order('1 ASC'); $db->setQuery($query); return $db->loadColumn(); } } article.php 0000644 00000023327 15247133465 0006721 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_content * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; /** * Content Component Article Model * * @since 1.5 */ class ContentModelArticle extends JModelItem { /** * Model context string. * * @var string */ protected $_context = 'com_content.article'; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 * * @return void */ protected function populateState() { $app = JFactory::getApplication('site'); // Load state from the request. $pk = $app->input->getInt('id'); $this->setState('article.id', $pk); $offset = $app->input->getUInt('limitstart'); $this->setState('list.offset', $offset); // Load the parameters. $params = $app->getParams(); $this->setState('params', $params); // TODO: Tune these values based on other permissions. $user = JFactory::getUser(); if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { $this->setState('filter.published', 1); $this->setState('filter.archived', 2); } $this->setState('filter.language', JLanguageMultilang::isEnabled()); } /** * Method to get article data. * * @param integer $pk The id of the article. * * @return object|boolean|JException Menu item data object on success, boolean false or JException instance on error */ public function getItem($pk = null) { $user = JFactory::getUser(); $pk = (!empty($pk)) ? $pk : (int) $this->getState('article.id'); if ($this->_item === null) { $this->_item = array(); } if (!isset($this->_item[$pk])) { try { $db = $this->getDbo(); $query = $db->getQuery(true) ->select( $this->getState( 'item.select', 'a.id, a.asset_id, a.title, a.alias, a.introtext, a.fulltext, ' . 'a.state, a.catid, a.created, a.created_by, a.created_by_alias, ' . // Use created if modified is 0 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, ' . 'a.images, a.urls, a.attribs, a.version, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language, a.xreference' ) ); $query->from('#__content AS a') ->where('a.id = ' . (int) $pk); // Join on category table. $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access') ->innerJoin('#__categories AS c on c.id = a.catid') ->where('c.published > 0'); // Join on user table. $query->select('u.name AS author') ->join('LEFT', '#__users AS u on u.id = a.created_by'); // Filter by language if ($this->getState('filter.language')) { $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } // Join over the categories to get parent category titles $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias') ->join('LEFT', '#__categories as parent ON parent.id = c.parent_id'); // Join on voting table $query->select('ROUND(v.rating_sum / v.rating_count, 0) AS rating, v.rating_count as rating_count') ->join('LEFT', '#__content_rating AS v ON a.id = v.content_id'); if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { // Filter by start and end dates. $nullDate = $db->quote($db->getNullDate()); $date = JFactory::getDate(); $nowDate = $db->quote($date->toSql()); $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by published state. $published = $this->getState('filter.published'); $archived = $this->getState('filter.archived'); if (is_numeric($published)) { $query->where('(a.state = ' . (int) $published . ' OR a.state =' . (int) $archived . ')'); } $db->setQuery($query); $data = $db->loadObject(); if (empty($data)) { return JError::raiseError(404, JText::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND')); } // Check for published state if filter set. if ((is_numeric($published) || is_numeric($archived)) && (($data->state != $published) && ($data->state != $archived))) { return JError::raiseError(404, JText::_('COM_CONTENT_ERROR_ARTICLE_NOT_FOUND')); } // Convert parameter fields to objects. $registry = new Registry($data->attribs); $data->params = clone $this->getState('params'); $data->params->merge($registry); $data->metadata = new Registry($data->metadata); // Technically guest could edit an article, but lets not check that to improve performance a little. if (!$user->get('guest')) { $userId = $user->get('id'); $asset = 'com_content.article.' . $data->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $data->params->set('access-edit', true); } // Now check if edit.own is available. elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $data->created_by) { $data->params->set('access-edit', true); } } } // Compute view access permissions. if ($access = $this->getState('filter.access')) { // If the access filter has been set, we already know this user can view. $data->params->set('access-view', true); } else { // If no access filter is set, the layout takes some responsibility for display of limited information. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); if ($data->catid == 0 || $data->category_access === null) { $data->params->set('access-view', in_array($data->access, $groups)); } else { $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups)); } } $this->_item[$pk] = $data; } catch (Exception $e) { if ($e->getCode() == 404) { // Need to go thru the error handler to allow Redirect to work. JError::raiseError(404, $e->getMessage()); } else { $this->setError($e); $this->_item[$pk] = false; } } } return $this->_item[$pk]; } /** * Increment the hit counter for the article. * * @param integer $pk Optional primary key of the article to increment. * * @return boolean True if successful; false otherwise and internal error set. */ public function hit($pk = 0) { $input = JFactory::getApplication()->input; $hitcount = $input->getInt('hitcount', 1); if ($hitcount) { $pk = (!empty($pk)) ? $pk : (int) $this->getState('article.id'); $table = JTable::getInstance('Content', 'JTable'); $table->load($pk); $table->hit($pk); } return true; } /** * Save user vote on article * * @param integer $pk Joomla Article Id * @param integer $rate Voting rate * * @return boolean Return true on success */ public function storeVote($pk = 0, $rate = 0) { if ($rate >= 1 && $rate <= 5 && $pk > 0) { $userIP = $_SERVER['REMOTE_ADDR']; // Initialize variables. $db = $this->getDbo(); $query = $db->getQuery(true); // Create the base select statement. $query->select('*') ->from($db->quoteName('#__content_rating')) ->where($db->quoteName('content_id') . ' = ' . (int) $pk); // Set the query and load the result. $db->setQuery($query); // Check for a database error. try { $rating = $db->loadObject(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } // There are no ratings yet, so lets insert our rating if (!$rating) { $query = $db->getQuery(true); // Create the base insert statement. $query->insert($db->quoteName('#__content_rating')) ->columns(array($db->quoteName('content_id'), $db->quoteName('lastip'), $db->quoteName('rating_sum'), $db->quoteName('rating_count'))) ->values((int) $pk . ', ' . $db->quote($userIP) . ',' . (int) $rate . ', 1'); // Set the query and execute the insert. $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } } else { if ($userIP != $rating->lastip) { $query = $db->getQuery(true); // Create the base update statement. $query->update($db->quoteName('#__content_rating')) ->set($db->quoteName('rating_count') . ' = rating_count + 1') ->set($db->quoteName('rating_sum') . ' = rating_sum + ' . (int) $rate) ->set($db->quoteName('lastip') . ' = ' . $db->quote($userIP)) ->where($db->quoteName('content_id') . ' = ' . (int) $pk); // Set the query and execute the update. $db->setQuery($query); try { $db->execute(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); return false; } } else { return false; } } return true; } JError::raiseWarning('SOME_ERROR_CODE', JText::sprintf('COM_CONTENT_INVALID_RATING', $rate), "JModelArticle::storeVote($rate)"); return false; } } articles.php 0000644 00000050264 15247133465 0007104 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_content * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; /** * This models supports retrieving lists of articles. * * @since 1.6 */ class ContentModelArticles extends JModelList { /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @see JController * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'catid', 'a.catid', 'category_title', 'state', 'a.state', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'ordering', 'a.ordering', 'featured', 'a.featured', 'language', 'a.language', 'hits', 'a.hits', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'images', 'a.images', 'urls', 'a.urls', 'filter_tag' ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * This method should only be called once per instantiation and is designed * to be called on the first call to the getState() method unless the model * configuration flag to ignore the request is set. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering An optional ordering field. * @param string $direction An optional direction (asc|desc). * * @return void * * @since 12.2 */ protected function populateState($ordering = 'ordering', $direction = 'ASC') { $app = JFactory::getApplication(); // List state information $value = $app->input->get('limit', $app->get('list_limit', 0), 'uint'); $this->setState('list.limit', $value); $value = $app->input->get('limitstart', 0, 'uint'); $this->setState('list.start', $value); $value = $app->input->get('filter_tag', 0, 'uint'); $this->setState('filter.tag', $value); $orderCol = $app->input->get('filter_order', 'a.ordering'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'a.ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = $app->input->get('filter_order_Dir', 'ASC'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $params = $app->getParams(); $this->setState('params', $params); $user = JFactory::getUser(); if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { // Filter on published for those who do not have edit or edit.state rights. $this->setState('filter.published', 1); } $this->setState('filter.language', JLanguageMultilang::isEnabled()); // Process show_noauth parameter if (!$params->get('show_noauth')) { $this->setState('filter.access', true); } else { $this->setState('filter.access', false); } $this->setState('layout', $app->input->getString('layout')); } /** * 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 .= ':' . serialize($this->getState('filter.published')); $id .= ':' . $this->getState('filter.access'); $id .= ':' . $this->getState('filter.featured'); $id .= ':' . serialize($this->getState('filter.article_id')); $id .= ':' . $this->getState('filter.article_id.include'); $id .= ':' . serialize($this->getState('filter.category_id')); $id .= ':' . $this->getState('filter.category_id.include'); $id .= ':' . serialize($this->getState('filter.author_id')); $id .= ':' . $this->getState('filter.author_id.include'); $id .= ':' . serialize($this->getState('filter.author_alias')); $id .= ':' . $this->getState('filter.author_alias.include'); $id .= ':' . $this->getState('filter.date_filtering'); $id .= ':' . $this->getState('filter.date_field'); $id .= ':' . $this->getState('filter.start_date_range'); $id .= ':' . $this->getState('filter.end_date_range'); $id .= ':' . $this->getState('filter.relative_date'); return parent::getStoreId($id); } /** * Get the master query for retrieving a list of articles subject to the model state. * * @return JDatabaseQuery * * @since 1.6 */ protected function getListQuery() { // Get the current user for authorisation checks $user = JFactory::getUser(); // Create a new query object. $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.id, a.title, a.alias, a.introtext, a.fulltext, ' . 'a.checked_out, a.checked_out_time, ' . 'a.catid, a.created, a.created_by, a.created_by_alias, ' . // Published/archived article in archive category is treats as archive article // If category is not published then force 0 'CASE WHEN c.published = 2 AND a.state > 0 THEN 2 WHEN c.published != 1 THEN 0 ELSE a.state END as state,' . // Use created if modified is 0 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . // Use created if publish_up is 0 'CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' . 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' . 'a.hits, a.xreference, a.featured, a.language, ' . ' ' . $query->length('a.fulltext') . ' AS readmore' ) ); $query->from('#__content AS a'); $params = $this->getState('params'); $orderby_sec = $params->get('orderby_sec'); // Join over the frontpage articles if required. if ($this->getState('filter.frontpage')) { if ($orderby_sec === 'front') { $query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id'); } else { $query->where('a.featured = 1'); } } elseif ($orderby_sec === 'front' || $this->getState('list.ordering') === 'fp.ordering') { $query->join('LEFT', '#__content_frontpage AS fp ON fp.content_id = a.id'); } // Join over the categories. $query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias') ->select('c.published, c.published AS parents_published') ->join('LEFT', '#__categories AS c ON c.id = a.catid'); // 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") ->select('ua.email AS author_email') ->join('LEFT', '#__users AS ua ON ua.id = a.created_by') ->join('LEFT', '#__users AS uam ON uam.id = a.modified_by'); // Join over the categories to get parent category titles $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias') ->join('LEFT', '#__categories as parent ON parent.id = c.parent_id'); if (JPluginHelper::isEnabled('content', 'vote')) { // Join on voting table $query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating, COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count') ->join('LEFT', '#__content_rating AS v ON a.id = v.content_id'); } // Filter by access level. if ($access = $this->getState('filter.access')) { $groups = implode(',', $user->getAuthorisedViewLevels()); $query->where('a.access IN (' . $groups . ')') ->where('c.access IN (' . $groups . ')'); } // Filter by published state $published = $this->getState('filter.published'); if (is_numeric($published) && $published == 2) { // If category is archived then article has to be published or archived. // If categogy is published then article has to be archived. $query->where('(c.published = 2 AND a.state > 0) OR (c.published = 1 AND a.state = 2)'); } elseif (is_numeric($published)) { // Category has to be published $query->where('c.published = 1 AND a.state = ' . (int) $published); } elseif (is_array($published)) { $published = ArrayHelper::toInteger($published); $published = implode(',', $published); // Category has to be published $query->where('c.published = 1 AND a.state IN (' . $published . ')'); } // Filter by featured state $featured = $this->getState('filter.featured'); switch ($featured) { case 'hide': $query->where('a.featured = 0'); break; case 'only': $query->where('a.featured = 1'); break; case 'show': default: // Normally we do not discriminate // between featured/unfeatured items. break; } // Filter by a single or group of articles. $articleId = $this->getState('filter.article_id'); if (is_numeric($articleId)) { $type = $this->getState('filter.article_id.include', true) ? '= ' : '<> '; $query->where('a.id ' . $type . (int) $articleId); } elseif (is_array($articleId)) { $articleId = ArrayHelper::toInteger($articleId); $articleId = implode(',', $articleId); $type = $this->getState('filter.article_id.include', true) ? 'IN' : 'NOT IN'; $query->where('a.id ' . $type . ' (' . $articleId . ')'); } // Filter by a single or group of categories $categoryId = $this->getState('filter.category_id'); if (is_numeric($categoryId)) { $type = $this->getState('filter.category_id.include', true) ? '= ' : '<> '; // Add subcategory check $includeSubcategories = $this->getState('filter.subcategories', false); $categoryEquals = 'a.catid ' . $type . (int) $categoryId; if ($includeSubcategories) { $levels = (int) $this->getState('filter.max_category_levels', '1'); // Create a subquery for the subcategory list $subQuery = $db->getQuery(true) ->select('sub.id') ->from('#__categories as sub') ->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt') ->where('this.id = ' . (int) $categoryId); if ($levels >= 0) { $subQuery->where('sub.level <= this.level + ' . $levels); } // Add the subquery to the main query $query->where('(' . $categoryEquals . ' OR a.catid IN (' . (string) $subQuery . '))'); } else { $query->where($categoryEquals); } } elseif (is_array($categoryId) && (count($categoryId) > 0)) { $categoryId = ArrayHelper::toInteger($categoryId); $categoryId = implode(',', $categoryId); if (!empty($categoryId)) { $type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN'; $query->where('a.catid ' . $type . ' (' . $categoryId . ')'); } } // Filter by author $authorId = $this->getState('filter.author_id'); $authorWhere = ''; if (is_numeric($authorId)) { $type = $this->getState('filter.author_id.include', true) ? '= ' : '<> '; $authorWhere = 'a.created_by ' . $type . (int) $authorId; } elseif (is_array($authorId)) { $authorId = ArrayHelper::toInteger($authorId); $authorId = implode(',', $authorId); if ($authorId) { $type = $this->getState('filter.author_id.include', true) ? 'IN' : 'NOT IN'; $authorWhere = 'a.created_by ' . $type . ' (' . $authorId . ')'; } } // Filter by author alias $authorAlias = $this->getState('filter.author_alias'); $authorAliasWhere = ''; if (is_string($authorAlias)) { $type = $this->getState('filter.author_alias.include', true) ? '= ' : '<> '; $authorAliasWhere = 'a.created_by_alias ' . $type . $db->quote($authorAlias); } elseif (is_array($authorAlias)) { $first = current($authorAlias); if (!empty($first)) { foreach ($authorAlias as $key => $alias) { $authorAlias[$key] = $db->quote($alias); } $authorAlias = implode(',', $authorAlias); if ($authorAlias) { $type = $this->getState('filter.author_alias.include', true) ? 'IN' : 'NOT IN'; $authorAliasWhere = 'a.created_by_alias ' . $type . ' (' . $authorAlias . ')'; } } } if (!empty($authorWhere) && !empty($authorAliasWhere)) { $query->where('(' . $authorWhere . ' OR ' . $authorAliasWhere . ')'); } elseif (empty($authorWhere) && empty($authorAliasWhere)) { // If both are empty we don't want to add to the query } else { // One of these is empty, the other is not so we just add both $query->where($authorWhere . $authorAliasWhere); } // Define null and now dates $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote(JFactory::getDate()->toSql()); // Filter by start and end dates. if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by Date Range or Relative Date $dateFiltering = $this->getState('filter.date_filtering', 'off'); $dateField = $this->getState('filter.date_field', 'a.created'); switch ($dateFiltering) { case 'range': $startDateRange = $db->quote($this->getState('filter.start_date_range', $nullDate)); $endDateRange = $db->quote($this->getState('filter.end_date_range', $nullDate)); $query->where( '(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField . ' <= ' . $endDateRange . ')' ); break; case 'relative': $relativeDate = (int) $this->getState('filter.relative_date', 0); $query->where( $dateField . ' >= DATE_SUB(' . $nowDate . ', INTERVAL ' . $relativeDate . ' DAY)' ); break; case 'off': default: break; } // Process the filter for list views with user-entered filters if (is_object($params) && ($params->get('filter_field') !== 'hide') && ($filter = $this->getState('list.filter'))) { // Clean filter variable $filter = StringHelper::strtolower($filter); $hitsFilter = (int) $filter; $filter = $db->quote('%' . $db->escape($filter, true) . '%', false); switch ($params->get('filter_field')) { case 'author': $query->where( 'LOWER( CASE WHEN a.created_by_alias > ' . $db->quote(' ') . ' THEN a.created_by_alias ELSE ua.name END ) LIKE ' . $filter . ' ' ); break; case 'hits': $query->where('a.hits >= ' . $hitsFilter . ' '); break; case 'title': default: // Default to 'title' if parameter is not valid $query->where('LOWER( a.title ) LIKE ' . $filter); break; } } // Filter by language if ($this->getState('filter.language')) { $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } // Filter by a single tag. $tagId = $this->getState('filter.tag'); if (!empty($tagId) && is_numeric($tagId)) { $query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId) ->join( 'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap') . ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id') . ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article') ); } // Add the list ordering clause. $query->order($this->getState('list.ordering', 'a.ordering') . ' ' . $this->getState('list.direction', 'ASC')); return $query; } /** * Method to get a list of articles. * * Overriden to inject convert the attribs field into a JParameter object. * * @return mixed An array of objects on success, false on failure. * * @since 1.6 */ public function getItems() { $items = parent::getItems(); $user = JFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); $groups = $user->getAuthorisedViewLevels(); $input = JFactory::getApplication()->input; // Get the global params $globalParams = JComponentHelper::getParams('com_content', true); // Convert the parameter fields into objects. foreach ($items as &$item) { $articleParams = new Registry($item->attribs); // Unpack readmore and layout params $item->alternative_readmore = $articleParams->get('alternative_readmore'); $item->layout = $articleParams->get('layout'); $item->params = clone $this->getState('params'); /*For blogs, article params override menu item params only if menu param = 'use_article' Otherwise, menu item params control the layout If menu item is 'use_article' and there is no article param, use global*/ if (($input->getString('layout') === 'blog') || ($input->getString('view') === 'featured') || ($this->getState('params')->get('layout_type') === 'blog')) { // Create an array of just the params set to 'use_article' $menuParamsArray = $this->getState('params')->toArray(); $articleArray = array(); foreach ($menuParamsArray as $key => $value) { if ($value === 'use_article') { // If the article has a value, use it if ($articleParams->get($key) != '') { // Get the value from the article $articleArray[$key] = $articleParams->get($key); } else { // Otherwise, use the global value $articleArray[$key] = $globalParams->get($key); } } } // Merge the selected article params if (count($articleArray) > 0) { $articleParams = new Registry($articleArray); $item->params->merge($articleParams); } } else { // For non-blog layouts, merge all of the article params $item->params->merge($articleParams); } // Get display date switch ($item->params->get('list_show_date')) { case 'modified': $item->displayDate = $item->modified; break; case 'published': $item->displayDate = ($item->publish_up == 0) ? $item->created : $item->publish_up; break; default: case 'created': $item->displayDate = $item->created; break; } // Compute the asset access permissions. // Technically guest could edit an article, but lets not check that to improve performance a little. if (!$guest) { $asset = 'com_content.article.' . $item->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $item->params->set('access-edit', true); } // Now check if edit.own is available. elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $item->created_by) { $item->params->set('access-edit', true); } } } $access = $this->getState('filter.access'); if ($access) { // If the access filter has been set, we already have only the articles this user can view. $item->params->set('access-view', true); } else { // If no access filter is set, the layout takes some responsibility for display of limited information. if ($item->catid == 0 || $item->category_access === null) { $item->params->set('access-view', in_array($item->access, $groups)); } else { $item->params->set('access-view', in_array($item->access, $groups) && in_array($item->category_access, $groups)); } } // Get the tags if ($item->params->get('show_tags')) { $item->tags = new JHelperTags; $item->tags->getItemTags('com_content.article', $item->id); } if ($item->params->get('show_associations')) { $item->associations = ContentHelperAssociation::displayAssociations($item->id); } } return $items; } /** * Method to get the starting number of items for the data set. * * @return integer The starting number of items available in the data set. * * @since 12.2 */ public function getStart() { return $this->getState('list.start'); } } categories.php 0000644 00000006612 15247133465 0007421 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_content * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; /** * This models supports retrieving lists of article categories. * * @since 1.6 */ class ContentModelCategories extends JModelList { /** * Model context string. * * @var string */ public $_context = 'com_content.categories'; /** * The category context (allows other extensions to derived from this model). * * @var string */ protected $_extension = 'com_content'; private $_parent = null; /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering The field to order on. * @param string $direction The direction to order on. * * @return void. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $this->setState('filter.extension', $this->_extension); // Get the parent id if defined. $parentId = $app->input->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 * * @param bool $recursive True if you want to return children recursively. * * @return mixed An array of data items on success, false on failure. * * @since 1.6 */ public function getItems($recursive = false) { $store = $this->getStoreId(); if (!isset($this->cache[$store])) { $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $params = new Registry; if ($active) { $params->loadString($active->params); } $options = array(); $options['countItems'] = $params->get('show_cat_num_articles_cat', 1) || !$params->get('show_empty_categories_cat', 0); $categories = JCategories::getInstance('Content', $options); $this->_parent = $categories->get($this->getState('filter.parentId', 'root')); if (is_object($this->_parent)) { $this->cache[$store] = $this->_parent->getChildren($recursive); } else { $this->cache[$store] = false; } } return $this->cache[$store]; } /** * Get the parent. * * @return object An array of data items on success, false on failure. * * @since 1.6 */ public function getParent() { if (!is_object($this->_parent)) { $this->getItems(); } return $this->_parent; } } category.php 0000644 00000030473 15247133465 0007113 0 ustar 00 <?php /** * @package Joomla.Site * @subpackage com_content * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\Registry\Registry; use Joomla\Utilities\ArrayHelper; /** * This models supports retrieving a category, the articles associated with the category, * sibling, child and parent categories. * * @since 1.5 */ class ContentModelCategory extends JModelList { /** * Category items data * * @var array */ protected $_item = null; protected $_articles = null; protected $_siblings = null; protected $_children = null; protected $_parent = null; /** * Model context string. * * @var string */ protected $_context = 'com_content.category'; /** * The category that applies. * * @access protected * @var object */ protected $_category = null; /** * The list of other newfeed categories. * * @access protected * @var array */ protected $_categories = null; /** * Constructor. * * @param array $config An optional associative array of configuration settings. * * @since 1.6 */ public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( 'id', 'a.id', 'title', 'a.title', 'alias', 'a.alias', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'catid', 'a.catid', 'category_title', 'state', 'a.state', 'access', 'a.access', 'access_level', 'created', 'a.created', 'created_by', 'a.created_by', 'modified', 'a.modified', 'ordering', 'a.ordering', 'featured', 'a.featured', 'language', 'a.language', 'hits', 'a.hits', 'publish_up', 'a.publish_up', 'publish_down', 'a.publish_down', 'author', 'a.author', 'filter_tag' ); } parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @param string $ordering The field to order on. * @param string $direction The direction to order on. * * @return void. * * @since 1.6 */ protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication('site'); $pk = $app->input->getInt('id'); $this->setState('category.id', $pk); $value = $app->input->get('filter_tag', 0, 'uint'); $this->setState('filter.tag', $value); // Load the parameters. Merge Global and Menu Item params into new object $params = $app->getParams(); $menuParams = new Registry; if ($menu = $app->getMenu()->getActive()) { $menuParams->loadString($menu->params); } $mergedParams = clone $menuParams; $mergedParams->merge($params); $this->setState('params', $mergedParams); $user = JFactory::getUser(); $asset = 'com_content'; if ($pk) { $asset .= '.category.' . $pk; } if ((!$user->authorise('core.edit.state', $asset)) && (!$user->authorise('core.edit', $asset))) { // Limit to published for people who can't edit or edit.state. $this->setState('filter.published', 1); } else { $this->setState('filter.published', array(0, 1, 2)); } // Process show_noauth parameter if (!$params->get('show_noauth')) { $this->setState('filter.access', true); } else { $this->setState('filter.access', false); } $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); // Optional filter text $search = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter-search', 'filter-search', '', 'string'); $this->setState('list.filter', $search); // Filter.order $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); if (!in_array($orderCol, $this->filter_fields)) { $orderCol = 'a.ordering'; } $this->setState('list.ordering', $orderCol); $listOrder = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', ''))) { $listOrder = 'ASC'; } $this->setState('list.direction', $listOrder); $this->setState('list.start', $app->input->get('limitstart', 0, 'uint')); // Set limit for query. If list, use parameter. If blog, add blog parameters for limit. if (($app->input->get('layout') === 'blog') || $params->get('layout_type') === 'blog') { $limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links'); $this->setState('list.links', $params->get('num_links')); } else { $limit = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint'); } $this->setState('list.limit', $limit); // Set the depth of the category query based on parameter $showSubcategories = $params->get('show_subcategory_content', '0'); if ($showSubcategories) { $this->setState('filter.max_category_levels', $params->get('show_subcategory_content', '1')); $this->setState('filter.subcategories', true); } $this->setState('filter.language', JLanguageMultilang::isEnabled()); $this->setState('layout', $app->input->getString('layout')); // Set the featured articles state $this->setState('filter.featured', $params->get('show_featured')); } /** * Get the articles in the category * * @return mixed An array of articles or false if an error occurs. * * @since 1.5 */ public function getItems() { $limit = $this->getState('list.limit'); if ($this->_articles === null && $category = $this->getCategory()) { $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); $model->setState('params', JFactory::getApplication()->getParams()); $model->setState('filter.category_id', $category->id); $model->setState('filter.published', $this->getState('filter.published')); $model->setState('filter.access', $this->getState('filter.access')); $model->setState('filter.language', $this->getState('filter.language')); $model->setState('filter.featured', $this->getState('filter.featured')); $model->setState('list.ordering', $this->_buildContentOrderBy()); $model->setState('list.start', $this->getState('list.start')); $model->setState('list.limit', $limit); $model->setState('list.direction', $this->getState('list.direction')); $model->setState('list.filter', $this->getState('list.filter')); $model->setState('filter.tag', $this->getState('filter.tag')); // Filter.subcategories indicates whether to include articles from subcategories in the list or blog $model->setState('filter.subcategories', $this->getState('filter.subcategories')); $model->setState('filter.max_category_levels', $this->getState('filter.max_category_levels')); $model->setState('list.links', $this->getState('list.links')); if ($limit >= 0) { $this->_articles = $model->getItems(); if ($this->_articles === false) { $this->setError($model->getError()); } } else { $this->_articles = array(); } $this->_pagination = $model->getPagination(); } return $this->_articles; } /** * Build the orderby for the query * * @return string $orderby portion of query * * @since 1.5 */ protected function _buildContentOrderBy() { $app = JFactory::getApplication('site'); $db = $this->getDbo(); $params = $this->state->params; $itemid = $app->input->get('id', 0, 'int') . ':' . $app->input->get('Itemid', 0, 'int'); $orderCol = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order', 'filter_order', '', 'string'); $orderDirn = $app->getUserStateFromRequest('com_content.category.list.' . $itemid . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd'); $orderby = ' '; if (!in_array($orderCol, $this->filter_fields)) { $orderCol = null; } if (!in_array(strtoupper($orderDirn), array('ASC', 'DESC', ''))) { $orderDirn = 'ASC'; } if ($orderCol && $orderDirn) { $orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', '; } $articleOrderby = $params->get('orderby_sec', 'rdate'); $articleOrderDate = $params->get('order_date'); $categoryOrderby = $params->def('orderby_pri', ''); $secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', '; $primary = ContentHelperQuery::orderbyPrimary($categoryOrderby); $orderby .= $primary . ' ' . $secondary . ' a.created '; return $orderby; } /** * Method to get a JPagination object for the data set. * * @return JPagination A JPagination object for the data set. * * @since 12.2 */ public function getPagination() { if (empty($this->_pagination)) { return null; } return $this->_pagination; } /** * Method to get category data for the current category * * @return object * * @since 1.5 */ public function getCategory() { if (!is_object($this->_item)) { if (isset( $this->state->params)) { $params = $this->state->params; $options = array(); $options['countItems'] = $params->get('show_cat_num_articles', 1) || !$params->get('show_empty_categories_cat', 0); $options['access'] = $params->get('check_access_rights', 1); } else { $options['countItems'] = 0; } $categories = JCategories::getInstance('Content', $options); $this->_item = $categories->get($this->getState('category.id', 'root')); // Compute selected asset permissions. if (is_object($this->_item)) { $user = JFactory::getUser(); $asset = 'com_content.category.' . $this->_item->id; // Check general create permission. if ($user->authorise('core.create', $asset)) { $this->_item->getParams()->set('access-create', true); } // TODO: Why aren't we lazy loading the children and siblings? $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 category. * * @return mixed An array of categories or false if an error occurs. * * @since 1.6 */ public function getParent() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_parent; } /** * Get the left sibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. * * @since 1.6 */ public function &getLeftSibling() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_leftsibling; } /** * Get the right sibling (adjacent) categories. * * @return mixed An array of categories or false if an error occurs. * * @since 1.6 */ public function &getRightSibling() { if (!is_object($this->_item)) { $this->getCategory(); } return $this->_rightsibling; } /** * Get the child categories. * * @return mixed An array of categories or false if an error occurs. * * @since 1.6 */ public function &getChildren() { if (!is_object($this->_item)) { $this->getCategory(); } // Order subcategories if (count($this->_children)) { $params = $this->getState()->get('params'); $orderByPri = $params->get('orderby_pri'); if ($orderByPri === 'alpha' || $orderByPri === 'ralpha') { $this->_children = ArrayHelper::sortObjects($this->_children, 'title', ($orderByPri === 'alpha') ? 1 : (-1)); } } return $this->_children; } /** * Increment the hit counter for the category. * * @param int $pk Optional primary key of the category to increment. * * @return boolean True if successful; false otherwise and internal error set. */ public function hit($pk = 0) { $input = JFactory::getApplication()->input; $hitcount = $input->getInt('hitcount', 1); if ($hitcount) { $pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id'); $table = JTable::getInstance('Category', 'JTable'); $table->load($pk); $table->hit($pk); } return true; } } forms/filter_articles.xml 0000644 00000007645 15247133465 0011615 0 ustar 00 <?xml version="1.0" encoding="utf-8"?> <form> <fields name="filter"> <field name="search" type="text" label="COM_CONTENT_MODAL_FILTER_SEARCH_LABEL" description="COM_CONTENT_MODAL_FILTER_SEARCH_DESC" hint="JSEARCH_FILTER" /> <field name="published" type="status" label="COM_CONTENT_FILTER_PUBLISHED" description="COM_CONTENT_FILTER_PUBLISHED_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_PUBLISHED</option> </field> <field name="category_id" type="category" label="JOPTION_FILTER_CATEGORY" extension="com_content" description="JOPTION_FILTER_CATEGORY_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_CATEGORY</option> </field> <field name="level" type="integer" first="1" last="10" step="1" label="JOPTION_FILTER_LEVEL" languages="*" description="JOPTION_FILTER_LEVEL_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_MAX_LEVELS</option> </field> <field name="access" type="accesslevel" label="JOPTION_FILTER_ACCESS" description="JOPTION_FILTER_ACCESS_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_ACCESS</option> </field> <field name="author_id" type="author" label="COM_CONTENT_FILTER_AUTHOR" description="COM_CONTENT_FILTER_AUTHOR_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_AUTHOR</option> </field> <field name="language" type="contentlanguage" label="JOPTION_FILTER_LANGUAGE" description="JOPTION_FILTER_LANGUAGE_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_LANGUAGE</option> <option value="*">JALL</option> </field> <field name="tag" type="tag" mode="nested" label="JOPTION_FILTER_TAG" description="JOPTION_FILTER_TAG_DESC" onchange="this.form.submit();" > <option value="">JOPTION_SELECT_TAG</option> </field> </fields> <fields name="list"> <field name="fullordering" type="list" label="COM_CONTENT_LIST_FULL_ORDERING" description="COM_CONTENT_LIST_FULL_ORDERING_DESC" onchange="this.form.submit();" default="a.title ASC" > <option value="">JGLOBAL_SORT_BY</option> <option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option> <option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option> <option value="a.state ASC">JSTATUS_ASC</option> <option value="a.state DESC">JSTATUS_DESC</option> <option value="a.title ASC">JGLOBAL_TITLE_ASC</option> <option value="a.title DESC">JGLOBAL_TITLE_DESC</option> <option value="category_title ASC">JCATEGORY_ASC</option> <option value="category_title DESC">JCATEGORY_DESC</option> <option value="association ASC" requires="associations">JASSOCIATIONS_ASC</option> <option value="association DESC" requires="associations">JASSOCIATIONS_DESC</option> <option value="a.access ASC">JGRID_HEADING_ACCESS_ASC</option> <option value="a.access DESC">JGRID_HEADING_ACCESS_DESC</option> <option value="a.created_by ASC">JAUTHOR_ASC</option> <option value="a.created_by DESC">JAUTHOR_DESC</option> <option value="language ASC">JGRID_HEADING_LANGUAGE_ASC</option> <option value="language DESC">JGRID_HEADING_LANGUAGE_DESC</option> <option value="a.created ASC">JDATE_ASC</option> <option value="a.created DESC">JDATE_DESC</option> <option value="a.id ASC">JGRID_HEADING_ID_ASC</option> <option value="a.id DESC">JGRID_HEADING_ID_DESC</option> <option value="a.featured ASC">JFEATURED_ASC</option> <option value="a.featured DESC">JFEATURED_DESC</option> <option value="a.hits ASC">JGLOBAL_HITS_ASC</option> <option value="a.hits DESC">JGLOBAL_HITS_DESC</option> </field> <field name="limit" type="limitbox" class="inputbox input-mini" default="25" label="COM_CONTENT_LIST_LIMIT" description="COM_CONTENT_LIST_LIMIT_DESC" onchange="this.form.submit();" /> </fields> </form>