PageRenderTime 173ms CodeModel.GetById 51ms app.highlight 2ms RepoModel.GetById 78ms app.codeStats 0ms

/plugins/editors-xtd/image/image.php

https://github.com/joebushi/joomla
PHP | 63 lines | 27 code | 10 blank | 26 comment | 1 complexity | fa30592deed3f2fec68eaf757150f6d4 MD5 | raw file
 1<?php
 2/**
 3 * @version		$Id$
 4 * @package		Joomla
 5 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
 6 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 7 */
 8
 9// no direct access
10defined('_JEXEC') or die;
11
12jimport('joomla.plugin.plugin');
13
14/**
15 * Editor Image buton
16 *
17 * @package Editors-xtd
18 * @since 1.5
19 */
20class plgButtonImage extends JPlugin
21{
22	/**
23	 * Display the button
24	 *
25	 * @return array A two element array of (imageName, textToInsert)
26	 */
27	function onDisplay($name)
28	{
29		$app = &JFactory::getApplication();
30		$params = &JComponentHelper::getParams('com_media');
31		$ranks = array('publisher', 'editor', 'author', 'registered');
32		$acl = & JFactory::getACL();
33
34		// TODO: Fix this ACL call
35		//for($i = 0; $i < $params->get('allowed_media_usergroup', 3); $i++)
36		//{
37		//	$acl->addACL('com_media', 'popup', 'users', $ranks[$i]);
38		//}
39
40
41		// TODO: Fix this ACL call
42		//Make sure the user is authorized to view this page
43		$user = & JFactory::getUser();
44		if (!$user->authorize('com_media.popup')) {
45			//return;
46		}
47		$doc 		= &JFactory::getDocument();
48		$template 	= $app->getTemplate();
49
50		$link = 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;e_name='.$name;
51
52		JHtml::_('behavior.modal');
53
54		$button = new JObject;
55		$button->set('modal', true);
56		$button->set('link', $link);
57		$button->set('text', JText::_('Image'));
58		$button->set('name', 'image');
59		$button->set('options', "{handler: 'iframe', size: {x: 570, y: 400}}");
60
61		return $button;
62	}
63}