-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjoomshadowbox.php
More file actions
102 lines (95 loc) · 4.16 KB
/
joomshadowbox.php
File metadata and controls
102 lines (95 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
// $HeadURL: https://joomgallery.org/svn/joomgallery/JG-3/Plugins/JoomShadowbox/trunk/joomshadowbox.php $
// $Id: joomshadowbox.php 4184 2013-04-08 15:52:21Z chraneco $
/****************************************************************************************\
** Plugin 'JoomShadowbox' 2.0 **
** By: JoomGallery::ProjectTeam **
** Copyright (C) 2010 - 2010 Patrick Alt **
** Released under GNU GPL Public License **
** License: http://www.gnu.org/copyleft/gpl.html or have a look **
** at administrator/components/com_joomgallery/LICENSE.TXT **
\****************************************************************************************/
defined('_JEXEC') or die('Direct Access to this location is not allowed.');
require_once JPATH_ADMINISTRATOR.'/components/com_joomgallery/helpers/openimageplugin.php';
/**
* JoomGallery Shadowbox Plugin
*
* With this plugin JoomGallery is able to use
* Shadowbox (http://www.shadowbox-js.com/) for displaying images.
*
* NOTE: Please remember that Shadowbox is licensed under the terms
* of the 'Shadowbox.js License' (http://www.shadowbox-js.com/LICENSE,
* http://www.shadowbox-js.com/#license).
*
* @package Joomla
* @subpackage JoomGallery
* @since 1.5
*/
class plgJoomGalleryJoomShadowbox extends JoomOpenImagePlugin
{
/**
* Name of this popup box
*
* @var string
* @since 3.0
*/
protected $title = 'Shadowbox';
/**
* Initializes the box by adding all necessary JavaScript and CSS files.
* This is done only once per page load.
*
* Please use the document object of Joomla! to add JavaScript and CSS files, e.g.:
* <code>
* $doc = JFactory::getDocument();
* $doc->addStyleSheet(JUri::root().'media/plg_exampleopenimage/css/exampleopenimage.css');
* $doc->addScript(JUri::root().'media/plg_exampleopenimage/js/exampleopenimage.js');
* $doc->addScriptDeclaration(" jQuery(document).ready(function(){ExampleOpenImage.init()}");
* </code>
*
* or if using Mootools or jQuery the respective JHtml method:
* <code>
* JHtml::_('jquery.framework');
* JHtml::_('behavior.framework');
* </code>
*
* @return void
* @since 3.0
*/
protected function init()
{
$doc = JFactory::getDocument();
$doc->addStyleSheet(JURI::root().'media/plg_joomshadowbox/shadowbox.css');
JHtml::_('behavior.framework');
$doc->addScript(JURI::root().'media/plg_joomshadowbox/shadowbox.js');
$doc->addScriptDeclaration(' Shadowbox.init();');
}
/**
* This method should set an associative array of attributes for the 'a'-Tag (key/value pairs) which opens the image.
*
* <code>
* $attribs['data-rel'] = 'examplebox';
* $attribs['data-group'] = $group;
* </code>
*
* The example above will create a link tag like that: <a href="<image URL>" data-rel="examplebox" group="<image group>" ... >
*
* ($attribs is passed by references and should only be filled)
*
* By default the attribute 'href' is filled with the URL to the image which shall be opened. You only have to set that
* attribute if you want to change that (the image URL is passed in the third argument of this method).
*
* NOTE!!!: You are not allowed to set the attributes 'title' and 'class' because these are handled internally by JoomGallery.
*
* @param array $attribs Associative array of HTML attributes which you have to fill
* @param object $image An object holding all the relevant data about the image to open
* @param string $img_url The URL to the image which shall be openend
* @param string $group The name of an image group, most popup boxes are able to group the images with that
* @param string $type 'orig' for original image, 'img' for detail image or 'thumb' for thumbnail
* @return void
* @since 3.0
*/
protected function getLinkAttributes(&$attribs, $image, $img_url, $group, $type)
{
$attribs['rel'] = 'shadowbox['.$group.'];player=img';
}
}