添加到 trunk

+YUCHENG HU+

git-svn-id: https://svn.code.sf.net/p/hawebs/svn@160 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
YuCheng Hu
2010-06-12 18:50:45 +00:00
parent f9dff482bc
commit 43791f1a01
11 changed files with 450 additions and 0 deletions
@@ -0,0 +1,2 @@
.button2-left .add_attachment {
background: url(../../plugins/editors-xtd/add_attachment.png) 100% 0 no-repeat; }
@@ -0,0 +1,131 @@
<?php
/**
* Add Attachments Button plugin
* @package Attachments
* @Copyright (C) 2007, 2008 Jonathan M. Cameron, All Rights Reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @link http://joomlacode.org/gf/project/attachments/frs/
* @author Jonathan M. Cameron
**/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.event.plugin');
class plgButtonAdd_attachment extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function plgAdd_attachment(& $subject, $config)
{
parent::__construct($subject, $config);
}
/**
* Add Attachment button
*
* @return a button
*/
function onDisplay($name)
{
// Avoid displaying the button for anything except content articles
global $option;
if ( $option != 'com_content' ) {
return new JObject();
}
// Get the article ID
$cid = JRequest::getVar( 'cid', array(0), '', 'array');
$id = 0;
if ( count($cid) > 0 ) {
$id = intval($cid[0]);
}
if ( $id == 0) {
$nid = JRequest::getVar( 'id', null);
if ( !is_null($nid) ) {
$id = intval($nid);
}
}
// Create the button object
$button = new JObject();
// Load the language file from the backend
$lang = & JFactory::getLanguage();
$lang->load('plg_frontend_attachments', JPATH_ADMINISTRATOR);
// ??? Where is the tooltip coming from?
// (Would like to use different tip for create article button)
// Figure out where we are and construct the right link and set
// up the style sheet (to get the visual for the button working)
global $mainframe;
$doc =& JFactory::getDocument();
if ( $mainframe->isAdmin() ) {
if ( $id == 0 ) {
// New article, explain that we can't add attachments until it is saved
// Load the language file from the frontend
$lang = & JFactory::getLanguage();
$lang->load('com_attachments', JPATH_SITE);
// Save the warning message for the pop-up window
require_once(JPATH_BASE.DS.'..'.DS.'components'.DS.'com_attachments'.DS.'helper.php');
$msg = JText::_('SAVE ARTICLE BEFORE ATTACHING')." ".JText::_('TRY APPLY BUTTON FIRST');
AttachmentsHelper::save_warning_message($msg);
$button->set('options', "{handler: 'iframe', size: {x: 400, y: 300}}");
$link = "index.php?option=com_attachments&task=warning&tmpl=component";
}
else {
$button->set('options', "{handler: 'iframe', size: {x: 800, y: 530}}");
$link = "index.php?option=com_attachments&task=add&article_id=$id&from=closeme";
}
$doc->addStyleSheet( $mainframe->getSiteURL() . 'plugins/editors-xtd/add_attachment.css',
'text/css', null, array() );
}
else {
if ( $id == 0 ) {
// Load the language file from the frontend
$lang = & JFactory::getLanguage();
$lang->load('com_attachments', JPATH_SITE);
// Save the warning message for the pop-up window
require_once(JPATH_BASE.DS.'components'.DS.'com_attachments'.DS.'helper.php');
$msg = JText::_('SAVE ARTICLE BEFORE ATTACHING');
AttachmentsHelper::save_warning_message($msg);
// New article, explain we can't add attachments until it is saved
$button->set('options', "{handler: 'iframe', size: {x: 400, y: 300}}");
$link = "index.php?option=com_attachments&task=warning&tmpl=component";
}
else {
$button->set('options', "{handler: 'iframe', size: {x: 700, y: 530}}");
$link = "index.php?option=com_attachments&task=upload&artid=$id&from=closeme";
}
$doc->addStyleSheet( JURI::Base() . 'plugins/editors-xtd/add_attachment.css',
'text/css', null, array() );
}
$button->set('modal', true);
$button->set('class', 'modal');
$button->set('text', JText::_('ADD ATTACHMENT'));
$button->set('name', 'add_attachment');
$button->set('link', $link);
$button->set('image', 'add_attachment.png');
return $button;
}
}
?>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="editors-xtd">
<name>Editor Button - AddAttachment</name>
<author>Jonathan M. Cameron</author>
<creationDate>August 17, 2008</creationDate>
<copyright>(C) 2007, 2008 Jonathan M. Cameron. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://joomlacode.org/gf/project/attachments/</authorUrl>
<version>1.3.4</version>
<description>ADD ATTACHMENT BUTTON PLUGIN INSTALLED</description>
<languages>
<language tag="en-GB">en-GB.plg_editors-xtd_add_attachment.ini</language>
</languages>
<files>
<filename plugin="add_attachment">add_attachment.php</filename>
<filename>add_attachment.png</filename>
<filename>add_attachment.css</filename>
</files>
</install>
@@ -0,0 +1,97 @@
<?php
/**
* @version $Id: image.php 12542 2009-07-22 17:40:48Z ian $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* Editor Image buton
*
* @package Editors-xtd
* @since 1.5
*/
class plgButtonImage extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function plgButtonImage(& $subject, $config)
{
parent::__construct($subject, $config);
}
/**
* Display the button
*
* @return array A two element array of ( imageName, textToInsert )
*/
function onDisplay($name)
{
global $mainframe;
$params =& JComponentHelper::getParams('com_media');
//Find out who has permission to upload and change the acl to let them.
$acl = & JFactory::getACL();
switch ($params->get('allowed_media_usergroup'))
{
case '1':
$acl->addACL( 'com_media', 'upload', 'users', 'publisher' );
break;
case '2':
$acl->addACL( 'com_media', 'upload', 'users', 'publisher' );
$acl->addACL( 'com_media', 'upload', 'users', 'editor' );
break;
case '3':
$acl->addACL( 'com_media', 'upload', 'users', 'publisher' );
$acl->addACL( 'com_media', 'upload', 'users', 'editor' );
$acl->addACL( 'com_media', 'upload', 'users', 'author' );
break;
case '4':
$acl->addACL( 'com_media', 'upload', 'users', 'publisher' );
$acl->addACL( 'com_media', 'upload', 'users', 'editor' );
$acl->addACL( 'com_media', 'upload', 'users', 'author' );
$acl->addACL( 'com_media', 'upload', 'users', 'registered' );
break;
}
//Make sure the user is authorized to view this page
$user = & JFactory::getUser();
if (!$user->authorize( 'com_media', 'popup' )) {
return;
}
$doc =& JFactory::getDocument();
$template = $mainframe->getTemplate();
$link = 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;e_name='.$name;
JHTML::_('behavior.modal');
$button = new JObject();
$button->set('modal', true);
$button->set('link', $link);
$button->set('text', JText::_('Image'));
$button->set('name', 'image');
$button->set('options', "{handler: 'iframe', size: {x: 570, y: 400}}");
return $button;
}
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="editors-xtd">
<name>Button - Image</name>
<author>Joomla! Project</author>
<creationDate>August 2004</creationDate>
<copyright>Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>1.0.0</version>
<description>DESCIMAGE</description>
<files>
<filename plugin="image">image.php</filename>
</files>
<params />
</install>
@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>
@@ -0,0 +1,68 @@
<?php
/**
* @version $Id: pagebreak.php 10709 2008-08-21 09:58:52Z eddieajau $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* Editor Pagebreak buton
*
* @package Editors-xtd
* @since 1.5
*/
class plgButtonPagebreak extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function plgButtonPagebreak(& $subject, $config)
{
parent::__construct($subject, $config);
}
/**
* Display the button
*
* @return array A two element array of ( imageName, textToInsert )
*/
function onDisplay($name)
{
global $mainframe;
$doc = & JFactory::getDocument();
$template = $mainframe->getTemplate();
$link = 'index.php?option=com_content&amp;task=ins_pagebreak&amp;tmpl=component&amp;e_name='.$name;
JHTML::_('behavior.modal');
$button = new JObject();
$button->set('modal', true);
$button->set('link', $link);
$button->set('text', JText::_('Pagebreak'));
$button->set('name', 'pagebreak');
$button->set('options', "{handler: 'iframe', size: {x: 400, y: 85}}");
return $button;
}
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="editors-xtd">
<name>Button - Pagebreak</name>
<author>Joomla! Project</author>
<creationDate>August 2004</creationDate>
<copyright>Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>1.5</version>
<description>DESCPAGEBREAK</description>
<files>
<filename plugin="pagebreak">pagebreak.php</filename>
</files>
<params />
</install>
@@ -0,0 +1,83 @@
<?php
/**
* @version $Id: readmore.php 10709 2008-08-21 09:58:52Z eddieajau $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* Editor Readmore buton
*
* @package Editors-xtd
* @since 1.5
*/
class plgButtonReadmore extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
function plgButtonReadmore(& $subject, $config)
{
parent::__construct($subject, $config);
}
/**
* readmore button
* @return array A two element array of ( imageName, textToInsert )
*/
function onDisplay($name)
{
global $mainframe;
$doc =& JFactory::getDocument();
$template = $mainframe->getTemplate();
// button is not active in specific content components
$getContent = $this->_subject->getContent($name);
$present = JText::_('ALREADY EXISTS', true) ;
$js = "
function insertReadmore(editor) {
var content = $getContent
if (content.match(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i)) {
alert('$present');
return false;
} else {
jInsertEditorText('<hr id=\"system-readmore\" />', editor);
}
}
";
$doc->addScriptDeclaration($js);
$button = new JObject();
$button->set('modal', false);
$button->set('onclick', 'insertReadmore(\''.$name.'\');return false;');
$button->set('text', JText::_('Readmore'));
$button->set('name', 'readmore');
// TODO: The button writer needs to take into account the javascript directive
//$button->set('link', 'javascript:void(0)');
$button->set('link', '#');
return $button;
}
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<install version="1.5" type="plugin" group="editors-xtd">
<name>Button - Readmore</name>
<author>Joomla! Project</author>
<creationDate>March 2006</creationDate>
<copyright>Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>1.5</version>
<description>DESCREADMORE</description>
<files>
<filename plugin="readmore">readmore.php</filename>
</files>
<params />
</install>