Advertisement
Guest User

Untitled

a guest
Jul 10th, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 58.94 KB | None | 0 0
  1. <?php
  2. /*
  3.  * @package     Joomla.Framework
  4.  * @copyright   Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  5.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  6.  *
  7.  * @component Phoca Plugin
  8.  * @copyright Copyright (C) Jan Pavelka www.phoca.cz
  9.  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later;
  10.  */
  11.  
  12. use Joomla\CMS\Component\ComponentHelper;
  13. use Joomla\CMS\Factory;
  14. use Joomla\CMS\HTML\HTMLHelper;
  15. use Joomla\CMS\Language\Text;
  16. use Joomla\CMS\Layout\FileLayout;
  17. use Joomla\CMS\Router\Route;
  18. use Joomla\CMS\Uri\Uri;
  19.  
  20. defined('_JEXEC') or die('Restricted access');
  21. jimport('joomla.plugin.plugin');
  22.  
  23.  
  24. class plgContentPhocaGallery extends JPlugin
  25. {
  26.     public $_plugin_number = 0;
  27.     public $_plugin_number_category_view = 0;
  28.  
  29.     public function __construct(&$subject, $config) {
  30.         parent::__construct($subject, $config);
  31.         $this->loadLanguage();
  32.     }
  33.  
  34.     public function _setPluginNumber() {
  35.         $this->_plugin_number = (int)$this->_plugin_number + 1;
  36.  
  37.     }
  38.  
  39.     public function _setPluginNumberCategoryView() {
  40.         $this->_plugin_number_category_view = (int)$this->_plugin_number_category_view + 1;
  41.     }
  42.  
  43.     public function onContentPrepare($context, &$article, &$params, $page = 0) {
  44.  
  45.         $app  = Factory::getApplication();
  46.         $view = $app->input->get('view');
  47.  
  48.         if ($view == 'tag') {
  49.             return;
  50.         }
  51.  
  52.         if ($context == 'com_finder.indexer') {
  53.             return true;
  54.         }
  55.  
  56.         // Not an article (plugin is used outside com_content
  57.         if (!isset($article->id)) {
  58.             $article->id = 0;
  59.         }
  60.  
  61.         // Include Phoca Gallery
  62.         if (!JComponentHelper::isEnabled('com_phocagallery', true)) {
  63.             echo '<div class="alert alert-danger">Phoca Gallery Error: Phoca Gallery component is not installed or not published on your system</div>';
  64.             return;
  65.         }
  66.  
  67.  
  68.         $db       = Factory::getDBO();
  69.         $document = Factory::getDocument();
  70.         $user       = Factory::getUser();
  71.         //$component    = 'com_phocaphoto';
  72.         //$paramsC      = JComponentHelper::getParams($component) ;
  73.         //$param        = (int)$this->params->get( 'medium_image_width', 100 );
  74.         $detail_window = $this->params->get('detail_window', 1);
  75.         $display_title = $this->params->get('display_title', 1);
  76.         $photoswipe_display_caption = $this->params->get('photoswipe_display_caption', 1);
  77.  
  78.         // Start Plugin
  79.         $regex_one     = '/({phocagallery\s*)(.*?)(})/si';
  80.         $regex_all     = '/{phocagallery\s*.*?}/si';
  81.         $matches       = array();
  82.         $count_matches = preg_match_all($regex_all, $article->text, $matches, PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER);
  83.  
  84.         $lang = Factory::getLanguage();
  85.         $lang->load('com_phocagallery');
  86.  
  87.  
  88.         // Start if count_matches
  89.         if ($count_matches != 0) {
  90.  
  91.             //HtmlHelper::stylesheet('media/plg_content_phocagallery/css/phocagallery.css');
  92.  
  93.  
  94.             if (!class_exists('PhocaGalleryLoader')) {
  95.                 require_once(JPATH_ADMINISTRATOR . '/components/com_phocagallery/libraries/loader.php');
  96.             }
  97.  
  98.             phocagalleryimport('phocagallery.path.path');
  99.             phocagalleryimport('phocagallery.file.filethumbnail');
  100.             phocagalleryimport('phocagallery.render.renderdetailwindow');
  101.             phocagalleryimport('phocagallery.render.renderfront');
  102.             phocagalleryimport('phocagallery.file.file');
  103.             phocagalleryimport('phocagallery.category.category');
  104.             phocagalleryimport('phocagallery.html.categoryhtml');
  105.             phocagalleryimport('phocagallery.access.access');
  106.             phocagalleryimport('phocagallery.image.imagefront');
  107.             phocagalleryimport('phocagallery.path.route');
  108.             phocagalleryimport('phocagallery.ordering.ordering');
  109.  
  110.             $paramsC            = ComponentHelper::getParams('com_phocagallery');
  111.             $large_image_width  = (int)$paramsC->get('large_image_width', 640);
  112.             $large_image_height = (int)$paramsC->get('large_image_height', 480);
  113.             $medium_image_width = $paramsC->get( 'medium_image_width', 256 );
  114.             $medium_image_height= $paramsC->get( 'medium_image_height', 192 );
  115.             $categories_image_ordering      = $paramsC->get( 'categories_image_ordering', 10 );
  116.  
  117.             // Categories
  118.             $hide_categories        = $paramsC->get( 'hide_categories', '');
  119.  
  120.             for ($i = 0; $i < $count_matches; $i++) {
  121.  
  122.                 $o = '';
  123.                 $this->_setPluginNumber();
  124.  
  125.                 // Plugin variables
  126.                 $view = '';
  127.                 $id   = 0;
  128.                 $max  = 0;
  129.                 $imageid                = 0;
  130.                 $limitstart = 0;
  131.                 $limitcount = 0;
  132.                 $imageordering = 1;
  133.  
  134.                 $image_categories_size          = 'medium';
  135.                 $img_cat                           = 1;
  136.  
  137.                 // Get plugin parameters
  138.                 $phocagallery = $matches[0][$i][0];
  139.                 preg_match($regex_one, $phocagallery, $phocagallery_parts);
  140.                 $parts          = explode("|", $phocagallery_parts[2]);
  141.                 $values_replace = array("/^'/", "/'$/", "/^&#39;/", "/&#39;$/", "/<br \/>/");
  142.  
  143.                 foreach ($parts as $key => $value) {
  144.  
  145.                     $values = explode("=", $value, 2);
  146.  
  147.                     foreach ($values_replace as $key2 => $values2) {
  148.                         $values = preg_replace($values2, '', $values);
  149.                     }
  150.  
  151.                     // Get plugin parameters from article
  152.                     if ($values[0] == 'view') {                 $view = $values[1];}
  153.                     else if ($values[0] == 'id') {              $id = $values[1];}
  154.                     else if ($values[0] == 'categoryid') {      $id = $values[1];}// Backward compatibility - categoryid is alias for id
  155.                     else if($values[0]=='imageid')          {$imageid               = $values[1];}
  156.                     else if ($values[0] == 'max') {             $max = $values[1];}
  157.                     else if ($values[0] == 'limitstart') {             $limitstart = $values[1];}
  158.                     else if ($values[0] == 'limitcount') {             $limitcount = $values[1];}
  159.                     else if ($values[0] == 'imageordering') {             $imageordering = $values[1];}
  160.  
  161.                     // Categories
  162.                     else if($values[0]=='hidecategories')   {$hide_categories       = $values[1];}
  163.                     else if($values[0]=='imagecategoriessize')  {$image_categories_size         = $values[1];}
  164.                     else if($values[0]=='imagecategories')      {$img_cat               = $values[1];}
  165.                 }
  166.  
  167.  
  168.  
  169.                 if ((int)$this->_plugin_number < 2) {
  170.                     PhocaGalleryRenderFront::renderAllCSS();
  171.                     $layoutSVG  = new FileLayout('svg_definitions', null, array('component' => 'com_phocagallery'));
  172.  
  173.                     // SVG Definitions
  174.                     $d          = array();
  175.                    $o .= $layoutSVG->render($d);
  176.  
  177.                 }
  178.  
  179.  
  180.                 //--------------------------
  181.                 // DISPLAYING OF CATEGORIES (link doesn't work if there is no menu link)
  182.                 //--------------------------
  183.                 if ($view == 'categories') {
  184.  
  185.                     $catid        = $id;
  186.                     $hideCat      = trim($hide_categories);
  187.                     $hideCatArray = explode(',', $hideCat);
  188.                     $hideCatSql   = '';
  189.                     if (is_array($hideCatArray)) {
  190.                         foreach ($hideCatArray as $value) {
  191.                             $hideCatSql .= ' AND cc.id != ' . (int)trim($value) . ' ';
  192.                         }
  193.                     }
  194.                     $uniqueCatSql = '';
  195.                     if ($catid > 0) {
  196.                         $uniqueCatSql = ' AND cc.id = ' . $catid . '';
  197.                     }
  198.  
  199.  
  200.                     //CATEGORIES
  201.                     $queryc = 'SELECT cc.*, a.catid, COUNT(a.id) AS numlinks,'
  202.                         . ' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(\':\', cc.id, cc.alias) ELSE cc.id END as slug'
  203.                         . ' FROM #__phocagallery_categories AS cc'
  204.                         . ' LEFT JOIN #__phocagallery AS a ON a.catid = cc.id'
  205.                         . ' WHERE a.published = 1'
  206.                         . ' AND cc.published = 1'
  207.                         . ' AND cc.approved = 1'
  208.                         . ' AND a.approved = 1'
  209.                         . ' AND a.language IN (' . $db->Quote(Factory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'
  210.                         . ' AND cc.language IN (' . $db->Quote(Factory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'
  211.                         . $hideCatSql
  212.                         . $uniqueCatSql
  213.                         . ' GROUP BY cc.id'
  214.                         . ' ORDER BY cc.ordering';
  215.  
  216.                     //SUBCATEGORIES
  217.                     $querysc = 'SELECT cc.title AS text, cc.id AS value, cc.parent_id as parentid'
  218.                         . ' FROM #__phocagallery_categories AS cc'
  219.                         . ' WHERE cc.published = 1'
  220.                         . ' AND cc.approved = 1'
  221.                         . ' AND cc.language IN (' . $db->Quote(Factory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'
  222.                         . ' ORDER BY cc.ordering';
  223.  
  224.  
  225.                     $data_outcome_array = array();
  226.  
  227.                     $db->setQuery($queryc);
  228.                     $outcome_data = $db->loadObjectList();
  229.  
  230.                     $db->setQuery($querysc);
  231.                     $outcome_subcategories = $db->loadObjectList();
  232.  
  233.                     $tree = array();
  234.                     $text = '';
  235.                     $tree = PhocaGalleryCategoryhtml::CategoryTreeOption($outcome_subcategories, $tree, 0, $text, -1);
  236.  
  237.                     foreach ($tree as $key => $value) {
  238.                         foreach ($outcome_data as $key2 => $value2) {
  239.                             if ($value->value == $value2->id) {
  240.  
  241.                                 $data_outcome                    = new stdClass();
  242.                                 $data_outcome->id                = $value2->id;
  243.                                 $data_outcome->parent_id         = $value2->parent_id;
  244.                                 $data_outcome->title             = $value->text;
  245.                                 $data_outcome->name              = $value2->name;
  246.                                 $data_outcome->alias             = $value2->alias;
  247.                                 $data_outcome->image             = $value2->image;
  248.                                 $data_outcome->section           = $value2->section;
  249.                                 $data_outcome->image_position    = $value2->image_position;
  250.                                 $data_outcome->description       = $value2->description;
  251.                                 $data_outcome->published         = $value2->published;
  252.                                 $data_outcome->editor            = $value2->editor;
  253.                                 $data_outcome->ordering          = $value2->ordering;
  254.                                 $data_outcome->access            = $value2->access;
  255.                                 $data_outcome->accessuserid      = $value2->accessuserid;
  256.                                 $data_outcome->uploaduserid      = $value2->uploaduserid;
  257.                                 $data_outcome->deleteuserid      = $value2->deleteuserid;
  258.                                 $data_outcome->count             = $value2->count;
  259.                                 $data_outcome->params            = $value2->params;
  260.                                 $data_outcome->catid             = $value2->catid;
  261.                                 $data_outcome->numlinks          = $value2->numlinks;
  262.                                 $data_outcome->slug              = $value2->slug;
  263.                                 $data_outcome->link              = PhocaGalleryRoute::getCategoryRoute($value2->id, $value2->alias);
  264.                                 $data_outcome->filename          = '';
  265.                                 $data_outcome->linkthumbnailpath = '';
  266.                                 $data_outcome->extm              = '';
  267.                                 $data_outcome->exts              = '';
  268.                                 $data_outcome->extw              = '';
  269.                                 $data_outcome->exth              = '';
  270.                                 $data_outcome->extid             = '';
  271.  
  272.                                 //FILENAME
  273.                                 $queryfn = 'SELECT filename, extm, exts, extw, exth, extid'
  274.                                     . ' FROM #__phocagallery'
  275.                                     . ' WHERE catid=' . $value2->id
  276.                                     . ' AND published = 1'
  277.                                     . ' AND approved = 1'
  278.                                     . ' AND language IN (' . $db->Quote(Factory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')'
  279.                                     . ' ORDER BY ordering LIMIT 1';
  280.                                 $db->setQuery($queryfn);
  281.                                 $outcome_filename       = $db->loadObjectList();
  282.                                 $data_outcome->filename = $outcome_filename[0]->filename;
  283.                                 $data_outcome->extm     = $outcome_filename[0]->extm;
  284.                                 $data_outcome->exts     = $outcome_filename[0]->exts;
  285.                                 $data_outcome->extw     = $outcome_filename[0]->extw;
  286.                                 $data_outcome->exth     = $outcome_filename[0]->exth;
  287.                                 $data_outcome->extid    = $outcome_filename[0]->extid;
  288.  
  289.  
  290.  
  291.                                 // Display Key Icon (in case we want to display unaccessable categories in list view)
  292.                                 $rightDisplayKey  = 1;
  293.  
  294.                                 // we simulate that we want not to display unaccessable categories
  295.                                 // so we get rightDisplayKey = 0 then the key will be displayed
  296.  
  297.                                 //$rightDisplayKey = PhocaGalleryAccess::getUserRight ('accessuserid', $category->accessuserid ,$category->access, $user->get('aid', 0), $user->get('id', 0), 0);
  298.                                 $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $data_outcome->accessuserid, $data_outcome->access, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
  299.  
  300.  
  301.                                 // Is Ext Image Album?
  302.                                 if (!isset($data_outcome->extfbcatid)) {$data_outcome->extfbcatid = '';}
  303.                                 $extCategory = PhocaGalleryImage::isExtImage($data_outcome->extid, $data_outcome->extfbcatid);
  304.  
  305.                                 if ($extCategory) {
  306.  
  307.  
  308.                                     $data_outcome->rightdisplaykey              = $rightDisplayKey;
  309.                                     if ($categories_image_ordering != 10) {
  310.                                         $imagePic       = PhocaGalleryImageFront::getRandomImageRecursive($data_outcome->id,$categories_image_ordering, 1);
  311.                                         if ($rightDisplayKey == 0) {
  312.                                             $imagePic = new StdClass();
  313.                                             $imagePic->exts = '';
  314.                                             $imagePic->extm = '';
  315.                                             $imagePic->extw = '';
  316.                                             $imagePic->exth = '';
  317.                                         }
  318.                                         $fileThumbnail  = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($imagePic->exts,$imagePic->extm, $imagePic->extw,$imagePic->exth, $image_categories_size, $rightDisplayKey);
  319.  
  320.                                         if ($rightDisplayKey == 0) {
  321.                                                 $data_outcome->rightdisplaykey = 0;// Lock folder will be displayed
  322.                                                 $data_outcome->linkthumbnailpath = '';
  323.                                             } else if (!$fileThumbnail) {
  324.                                                 $data_outcome->linkthumbnailpath = '';// Standard folder will be displayed
  325.                                             } else {
  326.                                                 $data_outcome->linkthumbnailpath    = $fileThumbnail->rel;
  327.                                                 $data_outcome->extw             = $fileThumbnail->extw;
  328.                                                 $data_outcome->exth             = $fileThumbnail->exth;
  329.                                                 $data_outcome->extpic               = $fileThumbnail->extpic;
  330.                                             }
  331.  
  332.                                     } else {
  333.                                         $fileThumbnail      = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($data_outcome->exts,$data_outcome->extm, $data_outcome->extw, $data_outcome->exth, $image_categories_size, $rightDisplayKey);
  334.  
  335.                                         if ($rightDisplayKey == 0) {
  336.                                                 $data_outcome->rightdisplaykey = 0;// Lock folder will be displayed
  337.                                                 $data_outcome->linkthumbnailpath = '';
  338.                                             } else if (!$fileThumbnail) {
  339.                                                 $data_outcome->linkthumbnailpath = '';// Standard folder will be displayed
  340.                                             } else {
  341.                                                 $data_outcome->linkthumbnailpath    = $fileThumbnail->rel;
  342.                                                 $data_outcome->extw             = $fileThumbnail->extw;
  343.                                                 $data_outcome->exth             = $fileThumbnail->exth;
  344.                                                 $data_outcome->extpic               = $fileThumbnail->extpic;
  345.                                             }
  346.  
  347.  
  348.                                     }
  349.  
  350.                                 } else {
  351.  
  352.                                     $data_outcome->rightdisplaykey              = $rightDisplayKey;
  353.  
  354.                                     if (isset($v->image_id) && $v->image_id > 0) {
  355.                                         // User has selected image in category edit
  356.                                         $selectedImg = PhocaGalleryImageFront::setFileNameByImageId((int)$v->image_id);
  357.  
  358.  
  359.                                         if (isset($selectedImg->filename) && ($selectedImg->filename != '' && $selectedImg->filename != '-')) {
  360.                                             $fileThumbnail  = PhocaGalleryImageFront::displayCategoriesImageOrFolder($selectedImg->filename, $image_categories_size, $rightDisplayKey);
  361.  
  362.                                             if ($rightDisplayKey == 0) {
  363.                                                 $data_outcome->rightdisplaykey = 0;// Lock folder will be displayed
  364.                                                 $data_outcome->linkthumbnailpath = '';
  365.                                             } else if (!$fileThumbnail) {
  366.                                                 $data_outcome->linkthumbnailpath = '';// Standard folder will be displayed
  367.                                             } else {
  368.                                                 $data_outcome->filename          = $selectedImg->filename;
  369.                                                 $data_outcome->linkthumbnailpath = $fileThumbnail->rel;
  370.                                             }
  371.  
  372.  
  373.                                         } else if (isset($selectedImg->exts) && isset($selectedImg->extm) && $selectedImg->exts != '' && $selectedImg->extm != '') {
  374.                                             $fileThumbnail      = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($selectedImg->exts, $selectedImg->extm, $selectedImg->extw, $selectedImg->exth, $image_categories_size, $rightDisplayKey);
  375.  
  376.  
  377.  
  378.                                             if ($rightDisplayKey == 0) {
  379.                                                 $data_outcome->rightdisplaykey = 0;// Lock folder will be displayed
  380.                                                 $data_outcome->linkthumbnailpath = '';
  381.                                             } else if (!$fileThumbnail) {
  382.                                                 $data_outcome->linkthumbnailpath = '';// Standard folder will be displayed
  383.                                             } else {
  384.                                                 $data_outcome->linkthumbnailpath    = $fileThumbnail->rel;
  385.                                                 $data_outcome->extw             = $fileThumbnail->extw;
  386.                                                 $data_outcome->exth             = $fileThumbnail->exth;
  387.                                                 $data_outcome->extpic               = $fileThumbnail->extpic;
  388.                                             }
  389.  
  390.                                         }
  391.  
  392.                                     } else {
  393.  
  394.                                         // Standard Internal Image
  395.                                         if ($categories_image_ordering != 10) {
  396.                                             $data_outcome->filename = PhocaGalleryImageFront::getRandomImageRecursive($data_outcome->id, $categories_image_ordering);
  397.                                         }
  398.                                         $fileThumbnail  = PhocaGalleryImageFront::displayCategoriesImageOrFolder($data_outcome->filename, $image_categories_size, $rightDisplayKey);
  399.  
  400.                                         if ($rightDisplayKey == 0) {
  401.                                             $data_outcome->rightdisplaykey = 0;// Lock folder will be displayed
  402.                                             $data_outcome->linkthumbnailpath = '';
  403.                                         } else if (!$fileThumbnail) {
  404.                                             $data_outcome->linkthumbnailpath = '';// Standard folder will be displayed
  405.                                         } else {
  406.                                             $data_outcome->linkthumbnailpath = $fileThumbnail->rel;
  407.                                         }
  408.  
  409.  
  410.  
  411.                                     }
  412.  
  413.  
  414.                                 }
  415.  
  416.  
  417.                                 $data_outcome_array[] = $data_outcome;
  418.                             }
  419.                         }
  420.                     }
  421.  
  422.                     $o .= '<div class="pg-categories-items-box">';
  423.  
  424.  
  425.  
  426.                     if ($img_cat == 1) {
  427.                         foreach ($data_outcome_array as $k => $item) {
  428.  
  429.  
  430.                             $o .= '<div class="pg-category-box">';
  431.  
  432.                             if (isset($item->rightdisplaykey) && $item->rightdisplaykey == 0) {
  433.  
  434.                                 $o .= '<div class="pg-category-box-image pg-svg-box">';
  435.                                 $o .= '<svg alt="' . htmlspecialchars($item->title) . '" class="ph-si ph-si-lock-medium pg-image c-Image c-Image--shaded" style="width:' . $medium_image_width . 'px;height:' . $medium_image_height . 'px" itemprop="thumbnail"><use xlink:href="#ph-si-lock"></use></svg>';
  436.                                 $o .= '</div>';
  437.                             } else {
  438.  
  439.                                 if ($image_categories_size == 2 || $image_categories_size == 3 || $item->linkthumbnailpath == '') {
  440.                                     // Folders instead of icons
  441.                                     $o .= '<div class="pg-category-box-image pg-svg-box">';
  442.                                     $o .= '<a href="' . Route::_($item->link) . '"><svg alt="' . htmlspecialchars($item->title) . '" class="ph-si ph-si-category pg-image c-Image c-Image--shaded" style="width:' . $medium_image_width . 'px;height:' . $medium_image_height . 'px" itemprop="thumbnail"><use xlink:href="#ph-si-category"></use></svg></a>';
  443.                                     $o .= '</div>';
  444.                                 } else {
  445.                                     // Images
  446.                                     $o .= '<div class="pg-category-box-image">';
  447.                                     $o .= '<a href="' . Route::_($item->link) . '">' . HTMLHelper::_('image', $item->linkthumbnailpath, $item->title) . '</a>';
  448.                                     $o .= '</div>';
  449.                                 }
  450.  
  451.  
  452.                             }
  453.  
  454.                             $o .= '<div class="pg-category-box-info">';
  455.                             $o .= '<div class="pg-category-box-title">';
  456.                             $o .= '<svg class="ph-si ph-si-category"><use xlink:href="#ph-si-category"></use></svg>';
  457.                             $o .= '<a href="' . Route::_($item->link) . '">' . $item->title . '</a>';
  458.                             $o .= $item->numlinks > 0 ? ' <span class="pg-category-box-count">(' . $item->numlinks . ')</span>' : '';
  459.                             $o .= '</div>';
  460.  
  461.  
  462.                             /*if ($this->t['display_cat_desc_box'] == 1 && $item->description != '') {
  463.                                 $o .= '<div class="pg-category-box-description">' . strip_tags($item->description) . '</div>';
  464.                             } else if ($this->t['display_cat_desc_box'] == 2 && $item->description != '') {
  465.                                 $o .= '<div class="pg-category-box-description">' . (HTMLHelper::_('content.prepare', $item->description, 'com_phocagallery.category')) . '</div>';
  466.                             }*/
  467.  
  468.                             //$this->cv = $item;
  469.                             //$o .= $this->loadTemplate('rating');
  470.  
  471.                             $o .= '</div>';// pg-category-box-info
  472.                             $o .= '</div>';// pg-category-box
  473.                         }
  474.  
  475.                     } else {
  476.                         $o .= '<ul>';
  477.  
  478.                         foreach ($data_outcome_array as $item) {
  479.  
  480.  
  481.                             $o .='<li>'
  482.                              .'<a href="'.Route::_($item->link).'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'
  483.                              . $item->title.'</a>&nbsp;<span class="small">('.$item->numlinks.')</span>'
  484.                              .'</li>';
  485.                         }
  486.                         $o .= '</ul>';
  487.                     }
  488.  
  489.                     $o .= '</div>';
  490.                 }
  491.  
  492.  
  493.                 //--------------------------
  494.                 // DISPLAYING OF CATEGORY (link doesn't work if there is no menu link)
  495.                 //--------------------------
  496.  
  497.  
  498.                 if ($view == 'category') {
  499.  
  500.                     $this->_setPluginNumberCategoryView();
  501.                     $layoutBI   = new FileLayout('box_image', null, array('component' => 'com_phocagallery'));
  502.  
  503.  
  504.                     $limit = '';
  505.                     $where = '';
  506.  
  507.                     // Only one image
  508.                     if ((int)$imageid > 0) {
  509.                         $where = ' AND a.id = '. $imageid;
  510.                     }
  511.  
  512.                     // Max is the limit, if limitcount is smaller than max, use the limitcount
  513.                     if ((int)$limitcount < (int)$max) {
  514.                         $max = $limitcount;
  515.                     }
  516.                     if ((int)$limitcount > 0 && (int)$max == 0) {
  517.                         $max = $limitcount;
  518.                     }
  519.  
  520.                     if ($view == 'category') {
  521.                         if ($max > 0) {
  522.                             $limit = ' LIMIT '.(int)$limitstart.',' . (int)$max;
  523.                         }
  524.                         $where .= ' AND a.catid = ' . (int)$id;
  525.                     } else if ($view == 'image') {
  526.                         $where .= ' AND a.id =' . (int)$id;
  527.                     } else {
  528.                         if ($max > 0) {
  529.                             $limit = ' LIMIT '.(int)$limitstart.',' . (int)$max;
  530.                         }
  531.                     }
  532.  
  533.  
  534.                     $ordering = PhocaGalleryOrdering::getOrderingString($imageordering);
  535.  
  536.  
  537.                     $query = 'SELECT a.id, a.catid, a.title, a.alias, a.filename, a.description, a.extm, a.exts, a.extw, a.exth, a.extid, a.extl, a.exto'
  538.                         . ' FROM #__phocagallery AS a'
  539.                         . ' WHERE a.published = 1'
  540.                         . ' AND a.approved = 1'
  541.                         . $where
  542.                         .$ordering['output']
  543.                         . $limit;
  544.  
  545.                     $db->setQuery($query);
  546.                     $images = $db->loadObjectList();
  547.  
  548.                     /*if ($i == 0) {
  549.                         // First instance - start the block but do not end it until last instance is rendered
  550.                         $o .= '<div id="pg-msnr-container" class="pg-photoswipe pg-msnr-container" itemscope itemtype="http://schema.org/ImageGallery">';
  551.                     }*/
  552.  
  553.                     if (!empty($images)) {
  554.  
  555.                         //require_once( JPATH_ADMINISTRATOR.'/components/com_phocaphoto/helpers/phocaphoto.php' );
  556.                         //$path = PhocaPhotoHelper::getPath();
  557.  
  558.  
  559.  
  560.                         if ((int)$this->_plugin_number_category_view < 2) {
  561.                             HtmlHelper::_('jquery.framework', false);
  562.  
  563.                             /*if ($detail_window == 2) {
  564.                                 HtmlHelper::stylesheet( 'media/com_phocaphoto/js/prettyphoto/css/prettyPhoto.css' );
  565.                                 $document->addScript(JURI::root(true).'/media/com_phocaphoto/js/prettyphoto/js/jquery.prettyPhoto.js');
  566.  
  567.                                 $js = "\n". 'jQuery(document).ready(function(){
  568.                                     jQuery("a[rel^=\'prettyPhoto\']").prettyPhoto({'."\n";
  569.                                 $js .= '  \'social_tools\': 0'."\n";
  570.                                 $js .= '  });
  571.                                 });'."\n";
  572.                                 $document->addScriptDeclaration($js);
  573.                             } else {*/
  574.  
  575.                             //$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/photoswipe/css/photoswipe.css');
  576.                             //$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/photoswipe/css/default-skin/default-skin.css');
  577.                             //$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/photoswipe/css/photoswipe-style.css');
  578.  
  579.                             $wa = $document->getWebAssetManager();
  580.                             $wa->registerAndUseStyle('plg_content_phocagallery.photoswipe', 'media/com_phocagallery/js/photoswipe/css/photoswipe.css', array('version' => 'auto'));
  581.                             $wa->registerAndUseStyle('plg_content_phocagallery.photoswipe.default', 'media/com_phocagallery/js/photoswipe/css/default-skin/default-skin.css', array('version' => 'auto'));
  582.                             $wa->registerAndUseStyle('plg_content_phocagallery.photoswipe.style', 'media/com_phocagallery/js/photoswipe/css/photoswipe-style.css', array('version' => 'auto'));
  583.  
  584.  
  585.                             /*}*/
  586.                         }
  587.  
  588.                         /*$nc = (int)$columns_cats;
  589.                         $nw = 3;
  590.                         if ($nc > 0) {
  591.                             $nw = 12/$nc;//1,2,3,4,6,12
  592.                         }
  593.                     */
  594.                         $count = 0;
  595.                         if (count($images) > 1) {
  596.                             $count = 1;
  597.                         }
  598.  
  599.                         /*$o .= '<div class="row">';*/
  600.  
  601.                         $o .= '<div id="pg-msnr-container-a' . (int)$article->id . '-p' . (int)$this->_plugin_number_category_view . '" class="pg-photoswipe pg-msnr-container pg-category-items-box" itemscope itemtype="http://schema.org/ImageGallery">';
  602.  
  603.  
  604.                         //$o .= '<div class="ph-gallery-plugin-container pg-category-view pg-cv">';
  605.                         ///* id="pg-msnr-container-a'.(int)$article->id . '-p'. (int)$this->_plugin_number.'"
  606.  
  607.                         $class = '';
  608.                         if ($display_title == 1) {
  609.                             $class = ' ph-incl-title';
  610.                         }
  611.  
  612.                         foreach ($images as $k => $v) {
  613.  
  614.                             $o .= '<div class="pg-item-box">'. "\n";// BOX START
  615.                             //$o .= '<div class="ph-gallery-plugin-box' . $class . '">';
  616.                             //$o .= '<div class="ph-gallery-plugin-image-container">';
  617.                             //$o .= '<div class="ph-gallery-plugin-image-box">';
  618.  
  619.                             /*  if ($count == 1) {
  620.                                     $o .= '<div class="col-sm-6 col-md-'.$nw.'">';
  621.                                     $o .= '<div class="thumbnail ph-thumbnail">';
  622.                                 } else {
  623.                                     $o .= '<div class="ph-thumbnail-one">';
  624.                                 }*/
  625.  
  626.                             $image = PhocaGalleryFileThumbnail::getThumbnailName($v->filename, 'medium');
  627.  
  628.  
  629.                             if ($v->extm != '') {
  630.                                 $imageM = $v->extm;
  631.                                 $imageL = $v->extl;
  632.                             } else {
  633.                                 $imageMO = PhocaGalleryFileThumbnail::getThumbnailName($v->filename, 'medium');
  634.                                 if (isset($imageMO->rel) && $imageMO->rel != '') {
  635.                                     $imageM = JURI::base(false) . $imageMO->rel;
  636.                                 }
  637.                                 $imageLO = PhocaGalleryFileThumbnail::getThumbnailName($v->filename, 'large');
  638.                                 if (isset($imageLO->rel) && $imageLO->rel != '') {
  639.                                     $imageL = JURI::base(false) . $imageLO->rel;
  640.                                 }
  641.                             }
  642.  
  643.                             $o .= '<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">';
  644.                             if ($imageL != '') {
  645.                                 /*if ($count == 1) {
  646.                                     $o .= '<a href="'.$imageL.'" rel="prettyPhoto[\'pp_gal_plugin'.(int)$this->_plugin_number.'\']">';
  647.                                 } else {
  648.                                     $o .= '<a href="'.$imageL.'" rel="prettyPhoto">';
  649.                                 }*/
  650.  
  651.                                 // TODO SIZE
  652.                                 $w = $large_image_width;
  653.                                 $h = $large_image_height;
  654.                                 if (isset($v->extw) && $v->extw != '') {
  655.                                     $extWA = explode(',', $v->extw);
  656.                                     if (isset($extWA[0])) {
  657.                                         $w = $extWA[0];
  658.                                     }
  659.                                 }
  660.  
  661.                                 if (isset($v->exth) && $v->exth != '') {
  662.                                     $extHA = explode(',', $v->exth);
  663.                                     if (isset($extHA[0])) {
  664.                                         $h = $extHA[0];
  665.                                     }
  666.                                 }
  667.  
  668.  
  669.                                 /*if ($detail_window == 2) {
  670.  
  671.                                     if ($count == 1) {
  672.                                         $o .= '<a href="'.$imageL.'" rel="prettyPhoto[\'pp_gal_plugin'.(int)$this->_plugin_number.'\']">';
  673.                                     } else {
  674.                                         $o .= '<a href="'.$imageL.'" rel="prettyPhoto">';
  675.                                     }
  676.  
  677.                                 } else {*/
  678.                                 ///$o .= '<a class="pg-photoswipe-button" href="' . $imageL . '" itemprop="contentUrl" data-size="' . $w . 'x' . $h . '" >';
  679.                                 /*}*/
  680.                                 $v->datasize = 'data-size="' . $w . 'x' . $h . '"';
  681.  
  682.                             }
  683.  
  684.                          /*   if ($imageM != '') {
  685.                                 $o .= '<img src="' . $imageM . '" alt="' . $v->title . '" class="c-Image c-Image--shaded" itemprop="thumbnail" />';
  686.                             }
  687.  
  688.                             if ($imageL != '') {
  689.                                 $o .= '</a>';
  690.  
  691.                             }*/
  692.  
  693.                             // Display BOX IMAGE
  694.                             // LAYOUT: components/com_phocagallery/layouts/box_image.php
  695.                             $v->class       = 'pg-photoswipe-button';
  696.                             $v->class2      = 'pg-photoswipe-button-copy';
  697.                             $v->class3      = 'pg-bs-modal-button';
  698.                             $v->link        = $imageL;
  699.                             $v->link2       = 'javascript:void(0)';
  700.                             //$v->link3     = $siteLink;
  701.                             //$v->linkorig      = $imgLinkOrig;
  702.                                             $v->linkthumbnailpath = $imageM;
  703.                             $v->onclick     = '';
  704.                             $v->itemprop        = 'contentUrl';
  705.                             $v->onclick2        = 'document.getElementById(\'pgImg'.$v->id.'\').click();';
  706.                             $v->onclick3        = $v->onclick;
  707.                             $v->oimgalt  = $v->title;
  708.                             $d          = array();
  709.                             $d['item']  = $v;
  710.                             $d['t']     = [];
  711.                             $o .= $layoutBI->render($d);
  712.  
  713.  
  714.                             if ($photoswipe_display_caption > 0) {
  715.  
  716.                                 $caption = $v->title;
  717.  
  718.                                 if ($photoswipe_display_caption == 2) {
  719.                                     $caption = $v->description;
  720.                                 }
  721.  
  722.                                 if ($photoswipe_display_caption == 3) {
  723.  
  724.                                     $caption = '';
  725.                                     if ($v->title != '') {
  726.                                         $caption .= $v->title . '<br>';
  727.                                     }
  728.                                     $caption .= $v->description;
  729.                                 }
  730.  
  731.                                 $o .= '<figcaption itemprop="caption description">'.$caption.'</figcaption>';
  732.                             }
  733.  
  734.  
  735.                             $o .= '</figure>';
  736.  
  737.                             if ($display_title == 1) {
  738.  
  739.  
  740.                                 $o .= '<div class="pg-item-box-title image">' . "\n";
  741.  
  742.                                 $o .= '<svg class="ph-si ph-si-image"><use xlink:href="#ph-si-image"></use></svg>' . "\n";
  743.                                 $o .= ' <a class="' . $v->class2 . '" title="' . htmlentities($v->title, ENT_QUOTES, 'UTF-8') . '"'
  744.                                     . ' data-img-title="' . $v->title . '" href="' . Route::_($v->link2) . '"';
  745.  
  746.                                 if ($v->onclick2 != '') {
  747.                                     $o .= 'onclick="' . $v->onclick2 . '"';
  748.                                 }
  749.                                 $o .= ' >';
  750.                                 $o .= '' . $v->title . '';
  751.                                 $o .= '</a>';
  752.  
  753.                                 $o .= '</div>' . "\n";
  754.  
  755.  
  756.  
  757.  
  758.  
  759.                             }
  760.  
  761.  
  762.  
  763.  
  764.                             //$o .= '</div>'; // end ph-gallery-plugin-image-box
  765.  
  766.                             //$o .= '</div>';// end ph-gallery-plugin-image-container
  767.                             /*if ($display_title == 1) {
  768.                                 $o .= '<div class="ph-gallery-plugin-image-title">' . $v->title . '</div>';
  769.                             }*/
  770.  
  771.                             $o .= '</div>';// end ph-gallery-plugin-box
  772.  
  773.                             /*if ($count == 1) {
  774.                                 $o .= '</div>'; // end column
  775.                             }*/
  776.  
  777.                         }
  778.                         //$o .= '</div>';
  779.                        // $o .= '</div>';// end ph-gallery-plugin-container
  780.  
  781.                         $o .= '</div>';// end psw
  782.                     }
  783.  
  784.                 }
  785.  
  786.                 //--------------------------
  787.                 // DISPLAYING OF CATEGORY - MASONRY
  788.                 //--------------------------
  789.  
  790.  
  791.                 if ($view == 'category-masonry') {
  792.  
  793.                     $document->addStyleSheet(Uri::root(true) . '/media/plg_content_phocagallery/css/phocagallery-masonry.css');
  794.  
  795.                     $limit = '';
  796.                     $where = '';
  797.  
  798.                     // Max is the limit, if limitcount is smaller than max, use the limitcount
  799.                     if ((int)$limitcount < (int)$max) {
  800.                         $max = $limitcount;
  801.                     }
  802.                     if ((int)$limitcount > 0 && (int)$max == 0) {
  803.                         $max = $limitcount;
  804.                     }
  805.  
  806.                     if ($view == 'category-masonry') {
  807.                         if ($max > 0) {
  808.                             $limit = ' LIMIT '.(int)$limitstart.',' . (int)$max;
  809.                         }
  810.                         $where = ' AND a.catid = ' . (int)$id;
  811.                     } else if ($view == 'image') {
  812.                         $where = ' AND a.id =' . (int)$id;
  813.                     } else {
  814.                         if ($max > 0) {
  815.                             $limit = ' LIMIT '.(int)$limitstart.',' . (int)$max;
  816.                         }
  817.                     }
  818.  
  819.  
  820.                     $ordering = PhocaGalleryOrdering::getOrderingString($imageordering);
  821.  
  822.  
  823.                     $query = 'SELECT a.id, a.catid, a.title, a.alias, a.filename, a.description, a.extm, a.exts, a.extw, a.exth, a.extid, a.extl, a.exto'
  824.                         . ' FROM #__phocagallery AS a'
  825.                         . ' WHERE a.published = 1'
  826.                         . ' AND a.approved = 1'
  827.                         . $where
  828.                         .$ordering['output']
  829.                         . $limit;
  830.  
  831.                     $db->setQuery($query);
  832.                     $images = $db->loadObjectList();
  833.  
  834.                     /*if ($i == 0) {
  835.                         // First instance - start the block but do not end it until last instance is rendered
  836.                         $o .= '<div id="pg-msnr-container" class="pg-photoswipe pg-msnr-container" itemscope itemtype="http://schema.org/ImageGallery">';
  837.                     }*/
  838.  
  839.                     if (!empty($images)) {
  840.  
  841.                         //require_once( JPATH_ADMINISTRATOR.'/components/com_phocaphoto/helpers/phocaphoto.php' );
  842.                         //$path = PhocaPhotoHelper::getPath();
  843.  
  844.                         if ((int)$this->_plugin_number_category_view < 2) {
  845.                             HtmlHelper::_('jquery.framework', false);
  846.  
  847.                             /*if ($detail_window == 2) {
  848.                                 HtmlHelper::stylesheet( 'media/com_phocaphoto/js/prettyphoto/css/prettyPhoto.css' );
  849.                                 $document->addScript(JURI::root(true).'/media/com_phocaphoto/js/prettyphoto/js/jquery.prettyPhoto.js');
  850.  
  851.                                 $js = "\n". 'jQuery(document).ready(function(){
  852.                                     jQuery("a[rel^=\'prettyPhoto\']").prettyPhoto({'."\n";
  853.                                 $js .= '  \'social_tools\': 0'."\n";
  854.                                 $js .= '  });
  855.                                 });'."\n";
  856.                                 $document->addScriptDeclaration($js);
  857.                             } else {*/
  858.  
  859.                             //$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/photoswipe/css/photoswipe.css');
  860.                            // $document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/photoswipe/css/default-skin/default-skin.css');
  861.                             //$document->addStyleSheet(Uri::root(true) . '/media/com_phocagallery/js/photoswipe/css/photoswipe-style.css');
  862.                             $wa = $document->getWebAssetManager();
  863.                             $wa->registerAndUseStyle('plg_content_phocagallery.photoswipe', 'media/com_phocagallery/js/photoswipe/css/photoswipe.css', array('version' => 'auto'));
  864.                             $wa->registerAndUseStyle('plg_content_phocagallery.photoswipe.default', 'media/com_phocagallery/js/photoswipe/css/default-skin/default-skin.css', array('version' => 'auto'));
  865.                             $wa->registerAndUseStyle('plg_content_phocagallery.photoswipe.style', 'media/com_phocagallery/js/photoswipe/css/photoswipe-style.css', array('version' => 'auto'));
  866.  
  867.                             /*}*/
  868.                         }
  869.  
  870.                         /*$nc = (int)$columns_cats;
  871.                         $nw = 3;
  872.                         if ($nc > 0) {
  873.                             $nw = 12/$nc;//1,2,3,4,6,12
  874.                         }
  875.                     */
  876.                         $count = 0;
  877.                         if (count($images) > 1) {
  878.                             $count = 1;
  879.                         }
  880.  
  881.                         /*$o .= '<div class="row">';*/
  882. // pg-category-items-box pg-photoswipe pg-msnr-container
  883.                         $o .= '<div id="pg-msnr-container-a' . (int)$article->id . '-p' . (int)$this->_plugin_number_category_view . '" class="pg-photoswipe pg-msnr-container pg-masonry" itemscope itemtype="http://schema.org/ImageGallery">';
  884.  
  885.  
  886.                         //$o .= '<div class="ph-gallery-plugin-container pg-category-view pg-cv">';
  887.                         ///* id="pg-msnr-container-a'.(int)$article->id . '-p'. (int)$this->_plugin_number.'"
  888.  
  889.                         $class = '';
  890.                         if ($display_title == 1) {
  891.                             $class = ' ph-incl-title';
  892.                         }
  893.  
  894.                         foreach ($images as $k => $v) {
  895.  
  896.                             $o .= '<div class="pg-masonry-item">'. "\n";// BOX START
  897.  
  898.  
  899.                             $image = PhocaGalleryFileThumbnail::getThumbnailName($v->filename, 'medium');
  900.  
  901.  
  902.                             if ($v->extm != '') {
  903.                                 $imageM = $v->extm;
  904.                                 $imageL = $v->extl;
  905.                             } else {
  906.                                 $imageMO = PhocaGalleryFileThumbnail::getThumbnailName($v->filename, 'medium');
  907.                                 if (isset($imageMO->rel) && $imageMO->rel != '') {
  908.                                     $imageM = JURI::base(false) . $imageMO->rel;
  909.                                 }
  910.                                 $imageLO = PhocaGalleryFileThumbnail::getThumbnailName($v->filename, 'large');
  911.                                 if (isset($imageLO->rel) && $imageLO->rel != '') {
  912.                                     $imageL = JURI::base(false) . $imageLO->rel;
  913.                                 }
  914.                             }
  915.  
  916.                             $o .= '<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">';
  917.                             if ($imageL != '') {
  918.                                 /*if ($count == 1) {
  919.                                     $o .= '<a href="'.$imageL.'" rel="prettyPhoto[\'pp_gal_plugin'.(int)$this->_plugin_number.'\']">';
  920.                                 } else {
  921.                                     $o .= '<a href="'.$imageL.'" rel="prettyPhoto">';
  922.                                 }*/
  923.  
  924.                                 // TODO SIZE
  925.                                 $w = $large_image_width;
  926.                                 $h = $large_image_height;
  927.                                 if (isset($v->extw) && $v->extw != '') {
  928.                                     $extWA = explode(',', $v->extw);
  929.                                     if (isset($extWA[0])) {
  930.                                         $w = $extWA[0];
  931.                                     }
  932.                                 }
  933.  
  934.                                 if (isset($v->exth) && $v->exth != '') {
  935.                                     $extHA = explode(',', $v->exth);
  936.                                     if (isset($extHA[0])) {
  937.                                         $h = $extHA[0];
  938.                                     }
  939.                                 }
  940.  
  941.  
  942.                                 /*if ($detail_window == 2) {
  943.  
  944.                                     if ($count == 1) {
  945.                                         $o .= '<a href="'.$imageL.'" rel="prettyPhoto[\'pp_gal_plugin'.(int)$this->_plugin_number.'\']">';
  946.                                     } else {
  947.                                         $o .= '<a href="'.$imageL.'" rel="prettyPhoto">';
  948.                                     }
  949.  
  950.                                 } else {*/
  951.                                 ///$o .= '<a class="pg-photoswipe-button" href="' . $imageL . '" itemprop="contentUrl" data-size="' . $w . 'x' . $h . '" >';
  952.                                 /*}*/
  953.                                 $v->datasize = 'data-size="' . $w . 'x' . $h . '"';
  954.  
  955.                             }
  956.  
  957.                          /*   if ($imageM != '') {
  958.                                 $o .= '<img src="' . $imageM . '" alt="' . $v->title . '" class="c-Image c-Image--shaded" itemprop="thumbnail" />';
  959.                             }
  960.  
  961.                             if ($imageL != '') {
  962.                                 $o .= '</a>';
  963.  
  964.                             }*/
  965.  
  966.                             // Display BOX IMAGE
  967.                             // LAYOUT: components/com_phocagallery/layouts/box_image.php
  968.                             $v->class       = 'pg-photoswipe-button';
  969.                             $v->class2      = 'pg-photoswipe-button-copy';
  970.                             $v->class3      = 'pg-bs-modal-button';
  971.                             $v->link        = $imageL;
  972.                             $v->link2       = 'javascript:void(0)';
  973.                             //$v->link3     = $siteLink;
  974.                             //$v->linkorig      = $imgLinkOrig;
  975.                                             $v->linkthumbnailpath = $imageL;
  976.                             $v->onclick     = '';
  977.                             $v->itemprop        = 'contentUrl';
  978.                             $v->onclick2        = 'document.getElementById(\'pgImg'.$v->id.'\').click();';
  979.                             $v->onclick3        = $v->onclick;
  980.                             $v->oimgalt  = $v->title;
  981.                            /* $d          = array();
  982.                             $d['item']  = $v;
  983.                             $d['t']     = [];
  984.                             $o .= $layoutBI->render($d);*/
  985.  
  986.  
  987.  
  988.  
  989.                             $o .= '<a class="'.$v->class.'" href="'. $v->link.'" data-img-title="'.$v->title.'" id="pgImg'.$v->id.'"';
  990.  
  991.                             if (isset($v->onclick) && $v->onclick != '') {
  992.                                 $o .= ' onclick="'.$v->onclick.'"';
  993.                             }
  994.  
  995.                             if (isset($v->itemprop) && $v->itemprop != '') {
  996.                                 $o .= ' itemprop="'.$v->itemprop.'"';
  997.                             }
  998.  
  999.                             if (isset($v->datasize)) { $o .= ' '. $v->datasize;}
  1000.  
  1001.                             if (isset($v->videocode) && $v->videocode != '' && $v->videocode != '0') {
  1002.                                 $o .= ' data-type="video" data-video="<div class=\'ph-pswp-wrapper\'><div class=\'ph-pswp-video-wrapper\'>' . str_replace('"', "'", PhocaGalleryYoutube::displayVideo($v->videocode)) . '</div></div>"';
  1003.                             }
  1004.  
  1005.                             $o .= ' >';
  1006.  
  1007.                            // $o .= '<div class="item">';
  1008.                             $o .= HTMLHelper::_( 'image', isset($v->extid) & (int)$v->extid> 0 ? $v->extm : $v->linkthumbnailpath, $v->oimgalt, array( 'class' => 'pg-image c-Image c-Image--shaded', 'itemprop' => "thumbnail"));
  1009.  
  1010.  
  1011.                            // $o .= '</div>';
  1012.  
  1013.                             $o .= '</a>';
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.                             if ($photoswipe_display_caption > 0) {
  1020.  
  1021.                                 $caption = $v->title;
  1022.  
  1023.                                 if ($photoswipe_display_caption == 2) {
  1024.                                     $caption = $v->description;
  1025.                                 }
  1026.  
  1027.                                 if ($photoswipe_display_caption == 3) {
  1028.  
  1029.                                     $caption = '';
  1030.                                     if ($v->title != '') {
  1031.                                         $caption .= $v->title . '<br>';
  1032.                                     }
  1033.                                     $caption .= $v->description;
  1034.                                 }
  1035.  
  1036.                                 $o .= '<figcaption itemprop="caption description">'.$caption.'</figcaption>';
  1037.                             }
  1038.  
  1039.  
  1040.                             $o .= '</figure>';
  1041.  
  1042.  
  1043.  
  1044.                             //$o .= '</div>'; // end ph-gallery-plugin-image-box
  1045.  
  1046.                             //$o .= '</div>';// end ph-gallery-plugin-image-container
  1047.                             /*if ($display_title == 1) {
  1048.                                 $o .= '<div class="ph-gallery-plugin-image-title">' . $v->title . '</div>';
  1049.                             }*/
  1050.  
  1051.                             $o .= '</div>';// end ph-gallery-plugin-box
  1052.  
  1053.                             /*if ($count == 1) {
  1054.                                 $o .= '</div>'; // end column
  1055.                             }*/
  1056.  
  1057.                         }
  1058.                         //$o .= '</div>';
  1059.                        // $o .= '</div>';// end ph-gallery-plugin-container
  1060.  
  1061.                         $o .= '</div>';// end pswp
  1062.                     }
  1063.  
  1064.                 }
  1065.  
  1066.                 /*if ($i == ($count_matches - 1)) {
  1067.                     // Last instance - stop the block here
  1068.                     $o .= '</div>';
  1069.                 }*/
  1070.  
  1071.  
  1072.                 $article->text = preg_replace($regex_all, $o, $article->text, 1);
  1073.             }
  1074.            
  1075.             $article->text = $this->loadPhotoswipeBottomPlugin(1, 1) . $article->text;
  1076.             return true;
  1077.         }
  1078.     }
  1079.  
  1080.  
  1081.     public function loadPhotoswipeBottomPlugin($forceSlideshow = 0, $forceSlideEffect = 0) {
  1082.  
  1083.         //$paramsC              = ComponentHelper::getParams('com_phocagallery') ;
  1084.         $photoswipe_slideshow   = 1;//$paramsC->get( 'photoswipe_slideshow', 1 );
  1085.         $photoswipe_slide_effect= 1;//$paramsC->get( 'photoswipe_slide_effect', 0 );
  1086.  
  1087.  
  1088.         if ($forceSlideshow == 1) {
  1089.             $photoswipe_slideshow = 1;
  1090.         }
  1091.         if ($forceSlideEffect == 1) {
  1092.             $photoswipe_slide_effect = 1;
  1093.         }
  1094.  
  1095.  
  1096.         $o = '<!-- Root element of PhotoSwipe. Must have class pswp. -->
  1097. <div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
  1098.  
  1099.    <!-- Background of PhotoSwipe.
  1100.         It\'s a separate element, as animating opacity is faster than rgba(). -->
  1101.    <div class="pswp__bg"></div>
  1102.  
  1103.    <!-- Slides wrapper with overflow:hidden. -->
  1104.    <div class="pswp__scroll-wrap">
  1105.  
  1106.        <!-- Container that holds slides. PhotoSwipe keeps only 3 slides in DOM to save memory. -->
  1107.        <!-- don\'t modify these 3 pswp__item elements, data is added later on. -->
  1108.        <div class="pswp__container">
  1109.            <div class="pswp__item"></div>
  1110.            <div class="pswp__item"></div>
  1111.            <div class="pswp__item"></div>
  1112.        </div>
  1113.  
  1114.        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
  1115.        <div class="pswp__ui pswp__ui--hidden">
  1116.  
  1117.            <div class="pswp__top-bar">
  1118.  
  1119.                <!--  Controls are self-explanatory. Order can be changed. -->
  1120.  
  1121.                <div class="pswp__counter"></div>
  1122.  
  1123.                <button class="pswp__button pswp__button--close" title="'.Text::_('COM_PHOCAGALLERY_CLOSE').'"></button>
  1124.  
  1125.                <button class="pswp__button pswp__button--share" title="'.Text::_('COM_PHOCAGALLERY_SHARE').'"></button>
  1126.  
  1127.                <button class="pswp__button pswp__button--fs" title="'.Text::_('COM_PHOCAGALERY_TOGGLE_FULLSCREEN').'"></button>
  1128.  
  1129.                <button class="pswp__button pswp__button--zoom" title="'.Text::_('COM_PHOCAGALLERY_ZOOM_IN_OUT').'"></button>';
  1130.  
  1131.                 if ($photoswipe_slideshow == 1) {
  1132.                     $o .= '<!-- custom slideshow button: -->
  1133.                     <button class="pswp__button pswp__button--playpause" title="'.Text::_('COM_PHOCAGALLERY_PLAY_SLIDESHOW').'"></button>
  1134.                     <span id="phTxtPlaySlideshow" style="display:none">'.Text::_('COM_PHOCAGALLERY_PLAY_SLIDESHOW').'</span>
  1135.                     <span id="phTxtPauseSlideshow" style="display:none">'.Text::_('COM_PHOCAGALLERY_PAUSE_SLIDESHOW').'</span>';
  1136.                 }
  1137.  
  1138.                 $o .= '<!-- Preloader -->
  1139.                <!-- element will get class pswp__preloader--active when preloader is running -->
  1140.                <div class="pswp__preloader">
  1141.                    <div class="pswp__preloader__icn">
  1142.                      <div class="pswp__preloader__cut">
  1143.                        <div class="pswp__preloader__donut"></div>
  1144.                      </div>
  1145.                    </div>
  1146.                </div>
  1147.            </div>
  1148.  
  1149.            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
  1150.                <div class="pswp__share-tooltip"></div>
  1151.            </div>
  1152.  
  1153.            <button class="pswp__button pswp__button--arrow--left" title="'.Text::_('COM_PHOCAGALLERY_PREVIOUS').'">
  1154.            </button>
  1155.  
  1156.            <button class="pswp__button pswp__button--arrow--right" title="'.Text::_('COM_PHOCAGALLERY_NEXT').'">
  1157.            </button>
  1158.  
  1159.            <div class="pswp__caption">
  1160.                <div class="pswp__caption__center"></div>
  1161.            </div>
  1162.  
  1163.          </div>
  1164.  
  1165.        </div>
  1166.  
  1167. </div>';
  1168.  
  1169.  
  1170.                 $wa = Factory::getDocument()->getWebAssetManager();
  1171.                 $wa->registerAndUseScript('plg_content_phocagallery.photoswipe', 'media/com_phocagallery/js/photoswipe/js/photoswipe.min.js', array('version' => 'auto'), ['defer' => true]);
  1172.                 $wa->registerAndUseScript('plg_content_phocagallery.photoswipe.default', 'media/com_phocagallery/js/photoswipe/js/photoswipe-ui-default.min.js', array('version' => 'auto'), ['defer' => true]);
  1173.  
  1174.  
  1175. //$o .=   '<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe.min.js"></script>'. "\n"
  1176. //      .'<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe-ui-default.min.js"></script>'. "\n";
  1177.  
  1178. if ($photoswipe_slide_effect == 1) {
  1179.     //$o .= '<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe-initialize-ratio.js"></script>'. "\n";
  1180.     $wa->registerAndUseScript('plg_content_phocagallery.photoswipe.initialize.ratio', 'media/com_phocagallery/js/photoswipe/js/photoswipe-initialize-ratio.js', array('version' => 'auto'), ['defer' => true]);
  1181. } else {
  1182.     //$o .= '<script src="'.Uri::root(true).'/media/com_phocagallery/js/photoswipe/js/photoswipe-initialize.js"></script>'. "\n";
  1183.     $wa->registerAndUseScript('plg_content_phocagallery.photoswipe.initialize.ratio', 'media/com_phocagallery/js/photoswipe/js/photoswipe-initialize.js', array('version' => 'auto'), ['defer' => true]);
  1184. }
  1185.  
  1186.         return $o;
  1187.     }
  1188. }
  1189.  
  1190. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement