tutto cho che serve attachments
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Manager for plugins for Attachments
|
||||
*
|
||||
* @package Attachments
|
||||
* @subpackage Attachments_Plugin_Framework
|
||||
*
|
||||
* @author Jonathan M. Cameron <jmcameron@jmcameron.net>
|
||||
* @copyright Copyright (C) 2009-2018 Jonathan M. Cameron, All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
|
||||
* @link http://joomlacode.org/gf/project/attachments/frs/
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
/**
|
||||
* Get the singleton plugin manager for attachments
|
||||
*
|
||||
* @return the plugin manager singleton object
|
||||
*/
|
||||
function &getAttachmentsPluginManager()
|
||||
{
|
||||
static $instance;
|
||||
|
||||
if (!is_object($instance))
|
||||
{
|
||||
require_once dirname(__FILE__) . '/attachments_plugin_manager.php';
|
||||
$instance = new AttachmentsPluginManager;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
|
||||
/** Make sure the plugin class is loaded for derived classes */
|
||||
require_once dirname(__FILE__) . '/attachments_plugin.php';
|
||||
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" group="attachments" version="2.5" method="upgrade">
|
||||
<name>plg_attachments_plugin_framework</name>
|
||||
<version>3.2.6</version>
|
||||
<creationDate>March 26, 2018</creationDate>
|
||||
<author>Jonathan M. Cameron</author>
|
||||
<authorEmail>jmcameron@jmcameron.net</authorEmail>
|
||||
<authorUrl>http://joomlacode.org/gf/project/attachments/</authorUrl>
|
||||
<copyright>(C) 2009-2018 Jonathan M. Cameron. All rights reserved.</copyright>
|
||||
<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
|
||||
<description>ATTACH_ATTACHMENTS_FOR_COMPONENTS_PLUGIN_FRAMEWORK_DESCRIPTION</description>
|
||||
|
||||
<scriptfile>install.php</scriptfile>
|
||||
|
||||
<files>
|
||||
<filename plugin="attachments_plugin_framework">attachments_plugin_framework.php</filename>
|
||||
<filename>attachments_plugin.php</filename>
|
||||
<filename>attachments_plugin_manager.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
|
||||
</extension>
|
||||
@ -0,0 +1,224 @@
|
||||
<?php
|
||||
/**
|
||||
* Manager for plugins for Attachments
|
||||
*
|
||||
* @package Attachments
|
||||
* @subpackage Attachments_Plugin_Framework
|
||||
*
|
||||
* @author Jonathan M. Cameron <jmcameron@jmcameron.net>
|
||||
* @copyright Copyright (C) 2009-2018 Jonathan M. Cameron, All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
|
||||
* @link http://joomlacode.org/gf/project/attachments/frs/
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
|
||||
/**
|
||||
* The class for the manager for attachments plugins
|
||||
*
|
||||
* AttachmentsPluginManager manages plugins for Attachments.
|
||||
* It knows how to create handlers for plugins for all
|
||||
* supported extensions.
|
||||
*
|
||||
* @package Attachments
|
||||
* @since 3.0
|
||||
*/
|
||||
class AttachmentsPluginManager extends JObject
|
||||
{
|
||||
/** A list of known parent_type names
|
||||
*/
|
||||
private $parent_types = Array();
|
||||
|
||||
/** An array of info about the installed entities.
|
||||
* Each item in the array is an associative array with the following entries:
|
||||
* 'id' - the unique name of entity as stored in the jos_attachments table (all lower case)
|
||||
* 'name' - the translated name of the entity
|
||||
* 'name_plural' - the translated plural name of the entity
|
||||
* 'parent_type' - the parent type for the entity
|
||||
*/
|
||||
private $entity_info = Array();
|
||||
|
||||
/** An associative array of attachment plugins
|
||||
*/
|
||||
private $plugin = Array();
|
||||
|
||||
/** Flag indicating if the language file haas been loaded
|
||||
*/
|
||||
private $language_loaded = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->loadLanguage();
|
||||
}
|
||||
|
||||
/**
|
||||
* See if a particular plugin is installed (avaliable)
|
||||
*
|
||||
* @param string $parent_type the name of the parent extension (eg, com_content)
|
||||
*
|
||||
* @return Boolean true if the plugin is available (false if not)
|
||||
*/
|
||||
public function attachmentsPluginInstalled($parent_type)
|
||||
{
|
||||
return in_array($parent_type, $this->parent_types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if an attachments plugin is enabled
|
||||
*
|
||||
* @param string $parent_type the name of the parent extension (eg, com_content)
|
||||
*
|
||||
* @return true if the attachment is enabled (false if disabled)
|
||||
*/
|
||||
public function attachmentsPluginEnabled($parent_type)
|
||||
{
|
||||
// Extract the component name (the part after 'com_')
|
||||
if (strpos($parent_type, 'com_') == 0)
|
||||
{
|
||||
$name = substr($parent_type, 4);
|
||||
|
||||
return JPluginHelper::isEnabled('attachments', "attachments_for_$name");
|
||||
}
|
||||
|
||||
// If the parent type does not conform to the naming convention, assume it is not enabled
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new parent type
|
||||
*
|
||||
* @param string $new_parent_type the name of the new parent extension (eg, com_content)
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
public function addParentType($new_parent_type)
|
||||
{
|
||||
if (in_array($new_parent_type, $this->parent_types))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->parent_types[] = $new_parent_type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of installed parent types
|
||||
*
|
||||
* @return an array of the installed parent types
|
||||
*/
|
||||
public function &getInstalledParentTypes()
|
||||
{
|
||||
return $this->parent_types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of installed parent entities
|
||||
*
|
||||
* @return array of entity info (see var $_entity_info definition above)
|
||||
*/
|
||||
public function &getInstalledEntityInfo()
|
||||
{
|
||||
if (count($this->entity_info) == 0)
|
||||
{
|
||||
// Add an option for each entity
|
||||
JPluginHelper::importPlugin('attachments');
|
||||
$apm = getAttachmentsPluginManager();
|
||||
|
||||
// Process all the parent types
|
||||
foreach ($this->parent_types as $parent_type)
|
||||
{
|
||||
$parent = $apm->getAttachmentsPlugin($parent_type);
|
||||
$entities = $parent->getEntities();
|
||||
|
||||
// Process each entity for this parent type
|
||||
foreach ($entities as $entity)
|
||||
{
|
||||
$centity = $parent->getCanonicalEntityId($entity);
|
||||
$this->entity_info[] = array(
|
||||
'id' => $centity,
|
||||
'name' => JText::_('ATTACH_' . $centity),
|
||||
'name_plural' => JText::_('ATTACH_' . $centity . 's'),
|
||||
'parent_type' => $parent_type
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->entity_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the langauge for this parent type
|
||||
*
|
||||
* @return true of the language was loaded successfullly
|
||||
*/
|
||||
public function loadLanguage()
|
||||
{
|
||||
if ($this->language_loaded)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
$this->language_loaded = $lang->load('plg_attachments_attachments_plugin_framework', dirname(__FILE__));
|
||||
|
||||
return $this->language_loaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin (attachments parent handler object)
|
||||
*
|
||||
* @param string $parent_type the name of the parent extension (eg, com_content)
|
||||
*
|
||||
* @return the parent handler object
|
||||
*/
|
||||
public function getAttachmentsPlugin($parent_type)
|
||||
{
|
||||
// Make sure the parent type is valid
|
||||
if (!in_array($parent_type, $this->parent_types))
|
||||
{
|
||||
$errmsg = JText::sprintf('ATTACH_ERROR_UNKNOWN_PARENT_TYPE_S', $parent_type) . ' (ERR 303)';
|
||||
JError::raiseError(406, $errmsg);
|
||||
}
|
||||
|
||||
// Instantiate the plugin object, if we have not already done it
|
||||
if (!array_key_exists($parent_type, $this->plugin))
|
||||
{
|
||||
$this->installPlugin($parent_type);
|
||||
}
|
||||
|
||||
return $this->plugin[$parent_type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the specified plugin
|
||||
*
|
||||
* @param string $parent_type the name of the parent extension (eg, com_content)
|
||||
*
|
||||
* @return true if successful (false if not)
|
||||
*/
|
||||
private function installPlugin($parent_type)
|
||||
{
|
||||
// Do nothing if the plugin is already installed
|
||||
if (array_key_exists($parent_type, $this->plugin))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Install the plugin
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
$className = 'AttachmentsPlugin_' . $parent_type;
|
||||
$this->plugin[$parent_type] = new $className($dispatcher);
|
||||
|
||||
return is_object($this->plugin[$parent_type]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
61
plugins/attachments/attachments_plugin_framework/install.php
Normal file
61
plugins/attachments/attachments_plugin_framework/install.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Attachments plugins framework installation script
|
||||
*
|
||||
* @package Attachments
|
||||
* @subpackage Attachments_Plugin_Framework
|
||||
*
|
||||
* @author Jonathan M. Cameron
|
||||
* @copyright Copyright (C) 2014-2018 Jonathan M. Cameron
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
|
||||
* @link http://joomlacode.org/gf/project/attachments/frs/
|
||||
*/
|
||||
|
||||
// No direct access
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
|
||||
/**
|
||||
* The attachments content plugin installation class
|
||||
*
|
||||
* @package Attachments
|
||||
*/
|
||||
class plgAttachmentsAttachments_plugin_frameworkInstallerScript
|
||||
{
|
||||
|
||||
/**
|
||||
* Attachments plugin uninstall function
|
||||
*
|
||||
* @param $parent : the installer parent
|
||||
*/
|
||||
public function uninstall($parent)
|
||||
{
|
||||
// List all the Attachments plugins
|
||||
$plugins = Array('plg_content_attachments',
|
||||
'plg_search_attachments',
|
||||
'plg_attachments_plugin_framework',
|
||||
'plg_attachments_for_content',
|
||||
'plg_editors-xtd_add_attachment_btn',
|
||||
'plg_editors-xtd_insert_attachments_token_btn',
|
||||
'plg_system_show_attachments_in_editor',
|
||||
'plg_quickicon_attachments'
|
||||
);
|
||||
|
||||
// To be safe, disable ALL attachments plugins first!
|
||||
foreach ($plugins as $plugin_name)
|
||||
{
|
||||
// Make the query to enable the plugin
|
||||
$db = JFactory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
$query->update('#__extensions')
|
||||
->set("enabled = 0")
|
||||
->where('type=' . $db->quote('plugin') . ' AND name=' . $db->quote($plugin_name));
|
||||
$db->setQuery($query);
|
||||
$db->query();
|
||||
|
||||
// NOTE: Do NOT complain if there was an error
|
||||
// (in case any plugin is already uninstalled and this query fails)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
; en-GB.plg_attachments_plugin_framework.ini
|
||||
; Attachments for Joomla! extension
|
||||
; Copyright (C) 2009-2018 Jonathan M. Cameron, All rights reserved.
|
||||
; License http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
|
||||
; Note : All ini files need to be saved as UTF-8 - No BOM
|
||||
|
||||
; English translation
|
||||
|
||||
ATTACH_ADD_ATTACHMENT_TO="Add Attachment to:"
|
||||
ATTACH_ATTACHMENTS_FOR_COMPONENTS_PLUGIN_FRAMEWORK_DESCRIPTION="The Attachments plugin framework plugin provides the plugin framework that enables adding attachments to the content parts of various types of components."
|
||||
ATTACH_ERROR_BAD_ENTITY_S_ID="ERROR: Unable to get valid %s ID!"
|
||||
ATTACH_ERROR_GETTING_PARENT_S_TITLE_FOR_ID_N="Error getting %s title for ID %d!"
|
||||
ATTACH_ERROR_INVALID_ENTITY_S_FOR_PARENT_S="ERROR: Invalid entity '%s' for parent '%s'!"
|
||||
ATTACH_ERROR_INVALID_PARENT_S_ID_N="ERROR: Invalid %s parent ID (%d)!"
|
||||
ATTACH_NOT_IMPLEMENTED="Not implemented!"
|
||||
@ -0,0 +1,10 @@
|
||||
; en-GB.plg_attachments_plugin_framework.sys.ini
|
||||
; Attachments for Joomla! extension
|
||||
; Copyright (C) 2009-2018 Jonathan M. Cameron, All rights reserved.
|
||||
; License http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
|
||||
; Note : All ini files need to be saved as UTF-8 - No BOM
|
||||
|
||||
; English translation
|
||||
|
||||
ATTACH_ATTACHMENTS_FOR_COMPONENTS_PLUGIN_FRAMEWORK_DESCRIPTION="The Attachments plugin framework plugin provides the plugin framework that enables adding attachments to the content parts of various types of components."
|
||||
PLG_ATTACHMENTS_PLUGIN_FRAMEWORK="Attachments - Plugin Framework"
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,15 @@
|
||||
; it-IT.plg_attachments_plugin_framework.ini
|
||||
; Attachments for Joomla! extension
|
||||
; Copyright (C) 2009-2013 Jonathan M. Cameron, All rights reserved.
|
||||
; License GNU GPL 3: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
; Note : All ini files need to be saved as UTF-8 - No BOM
|
||||
|
||||
; Italian translation by: Piero Mattirolo (2.0, 3.0), Lemminkainen (version 1.3.4)
|
||||
|
||||
ATTACH_ADD_ATTACHMENT_TO="Aggiungi allegato a:"
|
||||
ATTACH_ATTACHMENTS_FOR_COMPONENTS_PLUGIN_FRAMEWORK_DESCRIPTION="Questo plugin fornisce il framework di plugin che permette di aggiungere allegati a segmenti di contenuto di vari tipi di componenti."
|
||||
ATTACH_ERROR_BAD_ENTITY_S_ID="ERRORE: Impossibile ottenere ID %s valida!"
|
||||
ATTACH_ERROR_GETTING_PARENT_S_TITLE_FOR_ID_N="Errore nell'ottenere %s titolo per ID %d!"
|
||||
ATTACH_ERROR_INVALID_ENTITY_S_FOR_PARENT_S="ERRORE: Entità non valida '%s' per genitore '%s'!"
|
||||
ATTACH_ERROR_INVALID_PARENT_S_ID_N="ERROR: ID genitore %(i) non valida (%e)!"
|
||||
ATTACH_NOT_IMPLEMENTED="Non implementato!"
|
||||
@ -0,0 +1,10 @@
|
||||
; it-IT.plg_attachments_plugin_framework.sys.ini
|
||||
; Attachments for Joomla! extension
|
||||
; Copyright (C) 2009-2013 Jonathan M. Cameron, All rights reserved.
|
||||
; License GNU GPL 3: http://www.gnu.org/licenses/gpl-3.0.html
|
||||
; Note : All ini files need to be saved as UTF-8 - No BOM
|
||||
|
||||
; Italian translation by: Piero Mattirolo (2.0, 3.0), Lemminkainen (version 1.3.4)
|
||||
|
||||
ATTACH_ATTACHMENTS_FOR_COMPONENTS_PLUGIN_FRAMEWORK_DESCRIPTION="Questo plugin fornisce il framework di plugin che permette di aggiungere allegati a segmenti di contenuto di vari tipi di componenti."
|
||||
PLG_ATTACHMENTS_PLUGIN_FRAMEWORK="Allegati - Framework del Plugin"
|
||||
Reference in New Issue
Block a user