Exemplo n.º 1
0
 protected static function _findItem($needles = null)
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu('site');
     // Prepare the reverse lookup array.
     if (self::$lookup === null) {
         self::$lookup = array();
         $component = JComponentHelper::getComponent('com_djmediatools');
         $items = $menus->getItems('component_id', $component->id);
         if (count($items)) {
             foreach ($items as $item) {
                 if (isset($item->query) && isset($item->query['view'])) {
                     $view = $item->query['view'];
                     if (!isset(self::$lookup[$view])) {
                         self::$lookup[$view] = array();
                     }
                     if (isset($item->query['id'])) {
                         self::$lookup[$view][$item->query['id']] = $item->id;
                     }
                 }
             }
         }
     }
     if ($needles) {
         foreach ($needles as $view => $ids) {
             if (isset(self::$lookup[$view])) {
                 foreach ($ids as $id) {
                     if (isset(self::$lookup[$view][(int) $id])) {
                         return self::$lookup[$view][(int) $id];
                     }
                 }
             }
         }
     } else {
         $active = $menus->getActive();
         if ($active && $active->component == 'com_djmediatools') {
             return $active->id;
         }
     }
     return null;
 }
Exemplo n.º 2
0
 protected function _prepareDocument()
 {
     $app = JFactory::getApplication();
     $menus = $app->getMenu();
     $pathway = $app->getPathway();
     $title = null;
     JHTML::_('behavior.framework');
     $this->document->addScript('components/com_djmediatools/assets/js/default.js');
     // Because the application sets a default page title,
     // we need to get it from the menu item itself
     $menu = $menus->getActive();
     if ($menu) {
         $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
     } else {
         $this->params->def('page_heading', JText::_('COM_DJMEDIATOOLS'));
     }
     $title = $this->params->get('page_title', '');
     $id = (int) @$menu->query['id'];
     // if the menu item does not concern this article
     if ($menu && ($menu->query['option'] != 'com_djmediatools' || $menu->query['view'] != 'category' || $id != $this->category->id)) {
         if ($this->category->title) {
             $title = $this->category->title;
         }
         $path = array(array('title' => $title, 'link' => ''));
         $model = JModelLegacy::getInstance('Categories', 'DJMediaToolsModel', array('ignore_request' => false));
         $category = $model->getItem($this->category->parent_id);
         if ($category) {
             while ($category != 'root' && ($menu->query['option'] != 'com_djmediatools' || $id != $category->id)) {
                 $category->slug = $category->alias ? $category->id . ':' . $category->alias : $category->id;
                 $path[] = array('title' => $category->title, 'link' => JRoute::_(DJMediatoolsHelperRoute::getCategoryRoute($category->slug, $category->parent_id)));
                 $category = $model->getItem($category->parent_id);
             }
         }
         $path = array_reverse($path);
         foreach ($path as $item) {
             $pathway->addItem($item['title'], $item['link']);
         }
     }
     if (empty($title)) {
         $title = $app->getCfg('sitename');
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
     }
     $this->document->setTitle($title);
     if ($this->params->get('menu-meta_description')) {
         $this->document->setDescription($this->params->get('menu-meta_description'));
     }
     if ($this->params->get('menu-meta_keywords')) {
         $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
     }
     if ($this->params->get('robots')) {
         $this->document->setMetadata('robots', $this->params->get('robots'));
     }
 }
Exemplo n.º 3
0
			<a class="dj-prev" href="<?php 
    echo JRoute::_(DJMediatoolsHelperRoute::getItemRoute($this->slides[$this->current - 1]->id, $this->album->id . ':' . $this->album->alias));
    ?>
"><?php 
    echo $this->escape($this->slides[$this->current - 1]->title);
    ?>
</a>
		<?php 
}
?>
		<?php 
if ($this->current < count($this->slides) - 1) {
    ?>
	
			<a class="dj-next" href="<?php 
    echo JRoute::_(DJMediatoolsHelperRoute::getItemRoute($this->slides[$this->current + 1]->id, $this->album->id . ':' . $this->album->alias));
    ?>
"><?php 
    echo $this->escape($this->slides[$this->current + 1]->title);
    ?>
</a>
		<?php 
}
?>
		
		<div class="dj-count"><?php 
echo JText::sprintf('COM_DJMEDIATOOLS_ITEM_CURRENT_OF_TOTAL', $this->current + 1, count($this->slides));
?>
</div>
	</div>
</div>
Exemplo n.º 4
0
 * (at your option) any later version.
 *
 * DJ-MediaTools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with DJ-MediaTools. If not, see <http://www.gnu.org/licenses/>.
 *
 */
defined('_JEXEC') or die;
?>

<a class="dj-category" href="<?php 
echo JRoute::_(DJMediatoolsHelperRoute::getCategoryRoute($this->item->slug, $this->item->parent_id));
?>
">
	<span class="dj-category-in" style="width: <?php 
echo $this->params->get('cwidth', 200);
?>
px; height: <?php 
echo $this->params->get('cheight', 150);
?>
px;
		background-image: url(<?php 
echo $this->item->thumb;
?>
); background-position: center center; background-repeat: no-repeat;">		
		<?php 
if ($this->params->get('show_cat_titles')) {
Exemplo n.º 5
0
 protected function _getLinkedCover($match)
 {
     $id = $match[1];
     preg_match('/src="([^"]+)"/i', $match[0], $tmp);
     $src = isset($tmp[1]) ? $tmp[1] : '';
     preg_match('/style="([^"]+)"/i', $match[0], $tmp);
     $style = isset($tmp[1]) ? $tmp[1] : '';
     preg_match('/title="([^"]+)"/i', $match[0], $tmp);
     $title = isset($tmp[1]) ? $tmp[1] : '';
     preg_match('/width="([^"]+)"/i', $match[0], $tmp);
     $width = isset($tmp[1]) ? $tmp[1] : '600';
     if (!isset(self::$covers[$id])) {
         $app = JFactory::getApplication();
         $document = JFactory::getDocument();
         $model = JModelLegacy::getInstance('Categories', 'DJMediatoolsModel', array('ignore_request' => true));
         $model->setState('category.id', $id);
         $model->setState('filter.published', 1);
         $params = $model->getParams(false);
         $category = $model->getItem();
         if ($category === false) {
             return '';
             // no category
         }
         // get layout helper
         $helper = DJMediatoolsLayoutHelper::getInstance($params->get('layout', 'slideshow'));
         $mid = $category->id . 'p';
         $params->set('gallery_id', $mid);
         $params->set('category', $category->id . ':' . $category->alias);
         $params->set('source', $category->source);
         $params = $helper->getParams($params);
         $slides = $helper->getSlides($params);
         if (!isset($slides[0])) {
             return '';
             // no items
         }
         $helper->addModal($params);
         $document->addStyleSheet('components/com_djmediatools/assets/css/default.css');
         $juri_root = JURI::root(true);
         $src = !empty($juri_root) ? str_replace($juri_root . '/', '', $src) : $src;
         if (!($image = DJImageResizer::createThumbnail($src, 'media/djmediatools/cache', $width, 0, 'toWidth', 75))) {
             $image = $src;
         }
         if (strcasecmp(substr($image, 0, 4), 'http') != 0 && !empty($image)) {
             $image = JURI::root(true) . '/' . $image;
         }
         $link = JRoute::_(DJMediatoolsHelperRoute::getItemRoute($slides[0]->id, $params->get('category')));
         self::$covers[$id] = '<img class="djalbum_img" src="' . $image . '" alt="' . $title . '" width="' . $width . '" />';
         self::$covers[$id] = '<a class="djmodal" href="' . $link . '">' . self::$covers[$id] . '<span class="djalbum_link_tip">' . JText::_('COM_DJMEDIATOOLS_SHOW_GALLERY') . '</span>' . '</a>';
         self::$covers[$id] = '<span class="djalbum_link" style="' . $style . ' width:' . $width . 'px;">' . self::$covers[$id] . '</span>';
     }
     return self::$covers[$id];
 }
Exemplo n.º 6
0
 public function getSlides(&$params)
 {
     // taking the slides from the source
     $app = JFactory::getApplication();
     $slides = null;
     $source = $params->get('source');
     switch ($source) {
         case 'component':
             $slides = $this->getImagesFromDJMediatools($params);
             break;
         default:
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('djmediatools', $source);
             $results = $dispatcher->trigger('onAlbumPrepare', array(&$source, &$params));
             if (isset($results[0])) {
                 $slides = $results[0];
             }
             break;
     }
     $comments = (int) $params->get('comments', 0);
     $host = str_replace(JURI::root(true), '', JURI::root());
     $host = preg_replace('/\\/$/', '', $host);
     $item_link = $params->get('link_image', 1) == 3 ? true : false;
     if (is_array($slides) && count($slides) > 0) {
         foreach ($slides as $key => $slide) {
             if (!($slide->resized_image = DJImageResizer::createThumbnail($slide->image, 'media/djmediatools/cache', $params->get('image_width'), $params->get('image_height'), $params->get('resizing', 'crop'), $params->get('quality', 90)))) {
                 $slide->resized_image = $slide->image;
             }
             if (!($slide->thumb_image = DJImageResizer::createThumbnail($slide->image, 'media/djmediatools/cache', $params->get('thumb_width'), $params->get('thumb_height'), 'crop', 80))) {
                 $slide->thumb_image = $slide->resized_image;
             }
             // fix path for SEF links but not for external image urls
             if (strcasecmp(substr($slide->image, 0, 4), 'http') != 0 && !empty($slide->image)) {
                 $slide->image = JURI::root(true) . '/' . $slide->image;
             }
             if (strcasecmp(substr($slide->resized_image, 0, 4), 'http') != 0 && !empty($slide->resized_image)) {
                 $slide->resized_image = JURI::root(true) . '/' . $slide->resized_image;
             }
             if (strcasecmp(substr($slide->thumb_image, 0, 4), 'http') != 0 && !empty($slide->thumb_image)) {
                 $slide->thumb_image = JURI::root(true) . '/' . $slide->thumb_image;
             }
             if (!isset($slide->full_desc)) {
                 $slide->full_desc = $slide->description;
             }
             $slide->description = $this->truncateDescription($slide->description, $params->get('limit_desc'));
             if (!isset($slide->target)) {
                 $slide->target = $this->getSlideTarget($slide->link);
             }
             if (!isset($slide->alt)) {
                 $slide->alt = $slide->title;
             }
             // id has to be defined in source plugin otherwise the array index and title will be used
             if (!isset($slide->id)) {
                 $slide->id = $key . ':' . JFilterOutput::stringURLSafe($slide->title);
             }
             if ($item_link || $comments) {
                 $slide->item_link = JRoute::_(DJMediatoolsHelperRoute::getItemRoute($slide->id, $params->get('category')));
             }
             if (empty($slide->comments)) {
                 switch ($comments) {
                     // comments should be declared in source plugin to display the same comments which are assigned to the original item
                     case 1:
                         // jcomments
                         $slide->comments = array('id' => (int) $slide->id, 'group' => 'djmediatool-' . $source . '-a' . (int) $params->get('category'));
                         break;
                     case 2:
                         // disqus
                         $disqus_shortname = $params->get('disqus_shortname', '');
                         if (!empty($disqus_shortname)) {
                             $slide->comments = array();
                             $slide->comments['url'] = $host . $slide->item_link;
                             $slide->comments['identifier'] = $disqus_shortname . '-djmt-' . $source . '-a' . (int) $params->get('category') . '-id' . (int) $slide->id;
                         }
                         break;
                     case 3:
                         // facebook
                         $slide->comments = $host . $slide->item_link;
                         break;
                     case 4:
                         //komento
                         // not implemented
                         break;
                 }
             }
         }
     } else {
         $slides = null;
     }
     if ($params->get('link_image', 1) == 3) {
         $this->addModal($params);
     }
     return $slides;
 }
Exemplo n.º 7
0
 public function getSlides(&$params)
 {
     // taking the slides from the source
     $app = JFactory::getApplication();
     $slides = null;
     $source = $params->get('source');
     switch ($source) {
         case 'component':
             $slides = $this->getImagesFromDJMediatools($params);
             break;
         default:
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('djmediatools', $source);
             $results = $dispatcher->trigger('onAlbumPrepare', array(&$source, &$params));
             if (isset($results[0])) {
                 $slides = $results[0];
             }
             break;
     }
     //djdebug($params);
     $root = JURI::root(true);
     $host = str_replace($root, '', JURI::root());
     $host = preg_replace('/\\/$/', '', $host);
     $item_link = $params->get('link_image', 1) == 3 ? true : false;
     $comments = (int) $params->get('comments', 0);
     // we need to calculate slider width for calculation of 'sizes' image attribute
     $slider_width = $params->get('image_width') + $params->get('space_between_images');
     if ($params->get('show_desc') && in_array($params->get('desc_position'), array('left', 'right'))) {
         $slider_width += $params->get('desc_width');
     }
     $slider_width *= $params->get('visible_images');
     $slider_width -= $params->get('space_between_images');
     if ($this->_prefix == 'tabber') {
         $slider_width += $params->get('tab_width');
     }
     if (is_array($slides) && count($slides) > 0) {
         foreach ($slides as $key => $slide) {
             $resized = true;
             if (!($slide->resized_image = DJImageResizer::createThumbnail($slide->image, 'media/djmediatools/cache', $params->get('image_width'), $params->get('image_height'), $params->get('resizing', 'crop'), $params->get('quality', 90), true))) {
                 $slide->resized_image = $slide->image;
                 $resized = false;
             }
             $path = JPath::clean(JPATH_ROOT . DS . str_replace('/', DS, $slide->resized_image));
             $size = @getimagesize($path);
             $slide->size = (object) array('w' => $size[0], 'h' => $size[1]);
             $srcset = array();
             if ($resized) {
                 $srcset[$slide->size->w] = $root . '/' . $slide->resized_image . ' ' . $slide->size->w . 'w';
                 $filename = JFile::getName($slide->resized_image);
                 $folder = str_replace($filename, '', $slide->resized_image);
                 foreach (DJImageResizer::$widths as $w) {
                     if ($slide->size->w <= $w) {
                         continue;
                     }
                     // create path to image of $w width and add 'w' descriptor
                     $wpath = '/' . $folder . '_' . $w . 'w/' . $filename;
                     if (JFile::exists(JPATH_ROOT . $wpath)) {
                         $srcset[$w] = $root . $wpath . ' ' . $w . 'w';
                     }
                 }
                 $slide->srcset = implode(', ', $srcset);
                 $slide->sizes = floor(100 * $slide->size->w / $slider_width) . 'vw';
             }
             if (!($slide->thumb_image = DJImageResizer::createThumbnail($slide->resized_image, 'media/djmediatools/cache', $params->get('thumb_width'), $params->get('thumb_height'), 'crop', 80))) {
                 $slide->thumb_image = $slide->resized_image;
             }
             // fix path for SEF links but not for external image urls
             if (strcasecmp(substr($slide->image, 0, 4), 'http') != 0 && !empty($slide->image)) {
                 $slide->image = $root . '/' . $slide->image;
             }
             if (strcasecmp(substr($slide->resized_image, 0, 4), 'http') != 0 && !empty($slide->resized_image)) {
                 $slide->resized_image = $root . '/' . $slide->resized_image;
             }
             if (strcasecmp(substr($slide->thumb_image, 0, 4), 'http') != 0 && !empty($slide->thumb_image)) {
                 $slide->thumb_image = $root . '/' . $slide->thumb_image;
             }
             if (!isset($slide->full_desc)) {
                 $slide->full_desc = $slide->description;
             }
             $slide->description = $this->truncateDescription($slide->description, $params->get('limit_desc'));
             if (!isset($slide->target)) {
                 $slide->target = $this->getSlideTarget($slide->link);
             }
             if (!isset($slide->alt)) {
                 $slide->alt = $slide->title;
             }
             // id has to be defined in source plugin otherwise the array index and title will be used
             if (!isset($slide->id)) {
                 $slide->id = $key . ':' . JFilterOutput::stringURLSafe($slide->title);
             }
             if ($item_link || $comments) {
                 $slide->item_link = JRoute::_(DJMediatoolsHelperRoute::getItemRoute($slide->id, $params->get('category')));
             }
             if (empty($slide->comments)) {
                 switch ($comments) {
                     // comments should be declared in source plugin to display the same comments which are assigned to the original item
                     case 1:
                         // jcomments
                         $slide->comments = array('id' => (int) $slide->id, 'group' => 'djmediatool-' . $source . '-a' . (int) $params->get('category'));
                         break;
                     case 2:
                         // disqus
                         $disqus_shortname = $params->get('disqus_shortname', '');
                         if (!empty($disqus_shortname)) {
                             $slide->comments = array();
                             $slide->comments['url'] = $host . $slide->item_link;
                             $slide->comments['identifier'] = $disqus_shortname . '-djmt-' . $source . '-a' . (int) $params->get('category') . '-id' . (int) $slide->id;
                         }
                         break;
                     case 3:
                         // facebook
                         $slide->comments = $host . $slide->item_link;
                         break;
                     case 4:
                         //komento
                         // not implemented
                         break;
                 }
             }
         }
     } else {
         $slides = null;
     }
     if ($params->get('link_image', 1) == 3) {
         $this->addModal($params);
     }
     return $slides;
 }