tutto cho che serve attachments

This commit is contained in:
2025-01-01 12:22:03 +01:00
parent d6f07ccdb2
commit 934dd6bf52
210 changed files with 5186 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="attachments" version="2.5" method="upgrade">
<name>plg_attachments_for_content</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_CONTENT_PLUGIN_DESCRIPTION</description>
<scriptfile>install.php</scriptfile>
<files>
<filename plugin="attachments_for_content">attachments_for_content.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
</extension>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,61 @@
<?php
/**
* Attachments plugins for content installation script
*
* @package Attachments
* @subpackage Attachments_Plugin_For_Content
*
* @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_for_contentInstallerScript
{
/**
* 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)
}
}
}

View File

@ -0,0 +1,14 @@
; en-GB.plg_attachments_for_content.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_ARTICLE="Article"
ATTACH_ARTICLES="Articles"
ATTACH_ATTACHMENTS_FOR_CONTENT_PLUGIN_DESCRIPTION="The Attachments for Content plugin enables adding attachments to content articles as well as category descriptions."
ATTACH_CATEGORY="Category"
ATTACH_CATEGORYS="Categories"
ATTACH_ERROR_UNRECOGNIZED_PARENT_STATE_S="ERROR: Unrecognized parent state (%s)"

View File

@ -0,0 +1,10 @@
; en-GB.plg_attachments_for_content.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_CONTENT_PLUGIN_DESCRIPTION="The Attachments for Content plugin enables adding attachments to content articles as well as category descriptions."
PLG_ATTACHMENTS_FOR_CONTENT="Attachments - For Content"

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,14 @@
; it-IT.plg_attachments_for_content.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_ARTICLE="Articolo"
ATTACH_ARTICLES="Articoli"
ATTACH_ATTACHMENTS_FOR_CONTENT_PLUGIN_DESCRIPTION="Questo plugin permette di aggiungere allegati agli articoli, come pure alle descrizioni di categorie."
ATTACH_CATEGORY="Categoria"
ATTACH_CATEGORYS="Categorie"
ATTACH_ERROR_UNRECOGNIZED_PARENT_STATE_S="ERROR: Stato del genitore non riconosciuto(%s)"

View File

@ -0,0 +1,10 @@
; it-IT.plg_attachments_for_content.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_CONTENT_PLUGIN_DESCRIPTION="Questo plugin permette di aggiungere allegati agli articoli, come pure alle descrizioni di categorie."
PLG_ATTACHMENTS_FOR_CONTENT="Allegati - Per contenuti"

File diff suppressed because it is too large Load Diff

View File

@ -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';

View File

@ -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>

View File

@ -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]);
}
}

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View 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)
}
}
}

View File

@ -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!"

View File

@ -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"

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -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!"

View File

@ -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"

View File

@ -0,0 +1,424 @@
<?php
/**
* Attachments plugin for inserting attachments lists into content
*
* @package Attachments
* @subpackage Main_Attachments_Plugin
*
* @author Jonathan M. Cameron <jmcameron@jmcameron.net>
* @copyright Copyright (C) 2007-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/
*/
defined('_JEXEC') or die('Restricted access');
/** Load the Attachments defines (if available) */
if (file_exists(JPATH_SITE . '/components/com_attachments/defines.php'))
{
require_once JPATH_SITE . '/components/com_attachments/defines.php';
require_once(JPATH_SITE . '/components/com_attachments/helper.php');
require_once(JPATH_SITE . '/components/com_attachments/javascript.php');
}
else
{
// Exit quietly if the attachments component has been uninstalled or deleted
return;
}
/**
* Attachments plugin
*
* @package Attachments
* @since 1.3.4
*/
class plgContentAttachments extends JPlugin
{
/**
* Constructor
*
* @param object &$subject The object to observe
* @param array $config An array that holds the plugin configuration
*
* @access protected
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
// Save this page's URL
$uri= JFactory::getURI();
$return = '&return=' . urlencode(base64_encode(JUri::current() . '?' . $uri->getQuery()));
$app = JFactory::getApplication();
$app->setUserState('com_attachments.current_url', $return);
$this->loadLanguage();
}
/**
* The content plugin that inserts the attachments list into content items
*
* @param string The context of the content being passed to the plugin.
* @param &object &$row the content object (eg, article) being displayed
* @param &object &$params the parameters
* @param int $page the 'page' number
*
* @return true if anything has been inserted into the content object
*/
public function onContentPrepare($context, &$row, &$params, $page = 0)
{
// Enable the following four diagnostic lines to see if a component uses onContentPrepare
// $msg = "<br/>onContentPrepare: CONTEXT: $context, OBJ: " . get_class($row) . ", VIEW: " . JRequest::getCmd('view');
// if (isset($row->text)) $row->text .= $msg;
// if (isset($row->introtext)) $row->introtext .= $msg;
// return;
// Set the parent info from the context
if (strpos($context, '.') === false)
{
// Assume the context is the parent_type
$parent_type = $context;
$parent_entity = 'default';
}
else
{
list ($parent_type, $parent_entity) = explode('.', $context, 2);
}
// This callback handles everything but articles
if ( $parent_type == 'com_content' )
{
if (in_array($parent_entity, Array('featured', 'article'))) {
return false;
}
if ($parent_entity == 'category.title') {
// Do not add attachments to categtory titles (Joomla 3 only)
return false;
}
if (($parent_entity == 'category') AND (isset($row->catid))) {
// Ignore the callback for articles on category blogs
if (version_compare(JVERSION, '3.4.0', 'lt')) {
return false;
}
}
$parent_entity = 'category';
// Older versions of Joomla do not deal well with category lists and
// it is necessary to use the show_attachments callback to display
// category descriptions in those cases.
if (version_compare(JVERSION, '2.5.10', 'lt') OR
(version_compare(JVERSION, '3.0', 'ge') AND version_compare(JVERSION, '3.1', 'lt'))) {
return false;
}
}
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
if ( ($parent_type == 'mod_custom') AND ($parent_entity == 'content') AND ($view == 'category') )
{
// Do not add attachments to categtory titles (Joomla 3.4+)
return false;
}
// Handle category blog articles specially
if (($context == 'com_content.category') AND ($view == 'category') AND ($layout == 'blog')) {
if (isset($row->id) and is_numeric($row->id)) {
$parent_entity = 'article';
}
}
if (version_compare(JVERSION, '3.7.0'))
{
# Ignore this for Joomla 3.7.0+ (seems to be new and category attachments are handled ok without it)
if ($context == 'com_content.categories')
return false;
}
// Get the article/parent handler
JPluginHelper::importPlugin('attachments');
$apm = getAttachmentsPluginManager();
if ( !$apm->attachmentsPluginInstalled($parent_type) ) {
// Exit quietly if there is no Attachments plugin to handle this parent_type
return false;
}
$parent = $apm->getAttachmentsPlugin($parent_type);
// If this attachments plugin is disabled, skip it
if ( ! $apm->attachmentsPluginEnabled($parent_type) ) {
return false;
}
// Get the parent ID
$parent_id = null;
if (isset($row->id) and is_numeric($row->id))
{
// If the $row has 'id', just use it
$parent_id = (int)$row->id;
}
else if ($parent_entity == 'category')
{
$db = JFactory::getDBO();
$description = $row->text;
$query = $db->getQuery(true);
$query->select('id')->from('#__categories');
$query->where('description=' . $db->quote($description));
$db->setQuery($query, 0, 1);
$result = $db->loadResult();
if ($result) {
$parent_id = (int)$result;
}
}
// Let the attachment pluging try to figure out the id
if ( $parent_id === null )
{
$parent_id = $parent->getParentId($row);
}
if ( $parent_id === null )
{
return false;
}
// Load the language
$lang = JFactory::getLanguage();
$lang->load('plg_content_attachments', dirname(__FILE__));
// Set up the refresh behavior
AttachmentsJavascript::setupJavascript();
// Always include the hide rule (since it may be needed to hide the custom tags)
JHtml::stylesheet('com_attachments/attachments_hide.css', Array(), true);
// Allow remapping of parent ID (eg, for Joomfish)
if (jimport('attachments_remapper.remapper'))
{
$parent_id = AttachmentsRemapper::remapParentID($parent_id, $parent_type, $parent_entity);
}
// Exit if we should not display attachments for this parent
if ( $parent->attachmentsHiddenForParent($row, $parent_id, $parent_entity) ) {
return false;
}
// Get the component parameters
jimport('joomla.application.component.helper');
$attachParams = JComponentHelper::getParams('com_attachments');
// Make sure we should be showing the category attachments
$always_show_category_attachments = $attachParams->get('always_show_category_attachments', false);
$all_but_article_views = $attachParams->get('hide_except_article_views', false);
if ( $all_but_article_views && !$always_show_category_attachments ) {
return false;
}
// Add the attachments list
$parent->insertAttachmentsList($row, $parent_id, $parent_entity);
// FOR DEBUGGING
// if (isset($row->text)) $row->text .= " [AP text CONTEXT($context) PE($parent_entity) ]";
// if (isset($row->introtext)) $row->introtext .= " [AP introtext CONTEXT($context) PE($parent_entity)]";
return true;
}
/**
* The content plugin that inserts the attachments list into content items
*
* @param string $context the context of the content being passed to the plugin.
* @param &object &$row the content object (eg, article) being displayed
* @param &object &$params the parameters
* @param int $page the 'page' number
*
* @return true if anything has been inserted into the content object
*/
public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
{
$view = JRequest::getCmd('view');
$layout = JRequest::getCmd('layout');
if (($context == 'com_content.category') AND ($view == 'category') AND ($layout == 'blog')) {
// Use onContentPrepare for category blog articles for Joomla 3.4+
if (version_compare(JVERSION, '3.4', 'ge')) {
return false;
}
}
// Set the parent info from the context
if (strpos($context, '.') === false)
{
// Assume the context is the parent_type
$parent_type = $context;
$parent_entity = '';
}
else
{
list ($parent_type, $parent_entity) = explode('.', $context, 2);
}
// ??? Do we need to filter to ensure only articles use this callback?
// Load the language
$lang = JFactory::getLanguage();
$lang->load('plg_content_attachments', dirname(__FILE__));
// Add the refresh javascript
AttachmentsJavascript::setupJavascript();
// Always include the hide rule (since it may be needed to hide the custom tags)
JHtml::stylesheet('com_attachments/attachments_hide.css', array(), true);
// Get the article/parent handler
JPluginHelper::importPlugin('attachments');
$apm = getAttachmentsPluginManager();
if (!$apm->attachmentsPluginInstalled($parent_type))
{
// Exit quietly if there is no Attachments plugin to handle this parent_type
return false;
}
$parent = $apm->getAttachmentsPlugin($parent_type);
// If this attachments plugin is disabled, skip it
if (!$apm->attachmentsPluginEnabled($parent_type))
{
return false;
}
// Figure out the parent entity
$parent_entity = $parent->determineParentEntity($row);
if (!$parent_entity)
{
return false;
}
// Get the parent ID
$parent_id = null;
if (isset( $row->id ) && ($row->id > 0)) {
$parent_id = (int) $row->id;
} else {
$parent_id = $parent->getParentId($row);
}
// Exit if there is no parent
if ($parent_id === false)
{
return false;
}
// Allow remapping of parent ID (eg, for Joomfish)
if (jimport('attachments_remapper.remapper'))
{
$parent_id = AttachmentsRemapper::remapParentID($parent_id, $parent_type, $parent_entity);
}
// Exit if we should not display attachments for this parent
if ($parent->attachmentsHiddenForParent($row, $parent_id, $parent_entity))
{
return false;
}
// Add the attachments list
$parent->insertAttachmentsList($row, $parent_id, $parent_entity);
// ??? if (isset($row->text)) $row->text .= " [OCBD text $context]";
// ??? if (isset($row->introtext)) $row->introtext .= " [OCBD introtext $context]";
return;
}
/**
* Set the parent_id for all attachments that were added to this
* content before it was saved the first time.
*
* This method is called right after the content is saved.
*
* @param string The context of the content being passed to the plugin.
* @param object $item A JTableContent object
* @param bool $isNew If the content is newly created
*
* @return void
*/
function onContentAfterSave($context, $item, $isNew )
{
if ( !$isNew ) {
// If the item is not new, this step is not needed
return true;
}
$ctxinfo = explode('.', $context);
$parent_type = $ctxinfo[0];
$parent_entity = $ctxinfo[1];
// Special handling for categories
if ( $parent_type == 'com_categories' ) {
$parent_type = 'com_content';
}
// Get the attachments associated with this newly created item.
// NOTE: We assume that all attachments that have parent_id=null
// and are created by the current user are for this item.
$user = JFactory::getUser();
$user_id = $user->get('id');
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*')->from('#__attachments');
$query->where('created_by=' . (int) $user_id . ' AND parent_id IS NULL');
$db->setQuery($query);
$attachments = $db->loadObjectList();
if ( $db->getErrorNum() ) {
$errmsg = $db->stderr() . ' (ERR 200)';
JError::raiseError(500, $errmsg);
}
// Exit if there are no new attachments
if ( count($attachments) == 0 ) {
return true;
}
// Change the attachment to the new content item!
JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_attachments/tables');
$atrow = JTable::getInstance('Attachment', 'AttachmentsTable');
foreach ($attachments as $attachment) {
// Fix for odd issue; on some systems, something is changing the
// parent_type in or out of the database
if ( ($attachment->parent_type) == 'com_media' AND
($attachment->parent_entity) == 'article' ) {
// Override/fix the incorrect parent type
$attachment->parent_type = 'com_content';
}
// Change the filename/URL as necessary
$error_msg = AttachmentsHelper::switch_parent($attachment, null, $item->id);
if ( $error_msg != '' ) {
$errmsg = JText::_($error_msg) . ' (ERR 201)';
JError::raiseError(500, $errmsg);
}
// Update the parent info
$atrow->load($attachment->id);
$atrow->parent_id = $item->id;
$atrow->parent_type = $parent_type;
$atrow->filename_sys = $attachment->filename_sys;
$atrow->url = $attachment->url;
if ( !$atrow->store() ) {
$errmsg = $attachment->getError() . ' (ERR 202)';
JError::raiseError(500, $errmsg);
}
}
return true;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="content" version="2.5" method="upgrade">
<name>plg_content_attachments</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) 2007-2018 Jonathan M. Cameron. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
<description>ATTACH_ATTACHMENTS_PLUGIN_DESCRIPTION</description>
<scriptfile>install.php</scriptfile>
<files>
<filename plugin="attachments">attachments.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
</extension>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,61 @@
<?php
/**
* Attachments plugin installation script
*
* @package Attachments
* @subpackage Attachments_Plugin
*
* @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 plgContentAttachmentsInstallerScript
{
/**
* 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)
}
}
}

View File

@ -0,0 +1,31 @@
; en-GB.plg_frontend_attachments.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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
; Just for the front end display
ATTACH_ACCESS_THIS_URL_S="Access this URL (%s)"
ATTACH_ADD_ATTACHMENT="Add attachment"
ATTACH_ATTACHMENTS="Attachments"
ATTACH_ATTACHMENTS_PLUGIN_DESCRIPTION="Attachments plugin: Displays a list of the attachments for article (or supported content item),"
ATTACH_ATTACHMENTS_TITLE="Attachments:"
ATTACH_CREATED="Created"
ATTACH_CREATOR="Creator"
ATTACH_DELETE_THIS_FILE="Delete this file"
ATTACH_DESCRIPTION="Description"
ATTACH_DOWNLOADS="Downloads"
ATTACH_DOWNLOAD_NOUN="Download"
ATTACH_DOWNLOAD_THIS_FILE_S="Download this file (%s)"
ATTACH_EXISTING_ATTACHMENTS="Existing&nbsp;Attachments:"
ATTACH_FILE="File"
ATTACH_FILE_SIZE="File size"
ATTACH_FILE_URL="File / URL"
ATTACH_S_KB="%s kB"
ATTACH_LAST_MODIFIED="Last modified"
ATTACH_REALLY_DELETE_ATTACHMENT="Really delete attachment?"
ATTACH_UPDATE_THIS_FILE="Update this file"
ATTACH_URL="URL"

View File

@ -0,0 +1,12 @@
; en-GB.plg_content_attachments.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
; For the plugin manager
ATTACH_ATTACHMENTS_PLUGIN_DESCRIPTION="Attachments plugin: Displays a list of the attachments for article (or supported content item),"
PLG_CONTENT_ATTACHMENTS="Content - Attachments"

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,30 @@
; it-IT.plg_frontend_attachments.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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)
; Just for the front end display
ATTACH_ACCESS_THIS_URL_S="Accedi a questo URL (%s)"
ATTACH_ADD_ATTACHMENT="Aggiungi Allegato"
ATTACH_ATTACHMENTS="Allegati"
ATTACH_ATTACHMENTS_PLUGIN_DESCRIPTION="Allegati: questo plugin mostrerà una lista degli allegati disponibili per ciascun articolo (o elemento di contenuto supportato), "
ATTACH_ATTACHMENTS_TITLE="Allegati:"
ATTACH_CREATED="Creato"
ATTACH_CREATOR="Autore"
ATTACH_DELETE_THIS_FILE="Cancella questo file"
ATTACH_DESCRIPTION="Descrizione"
ATTACH_DOWNLOADS="Downloads"
ATTACH_DOWNLOAD_NOUN="Download"
ATTACH_DOWNLOAD_THIS_FILE_S="Scarica questo file (%s)"
ATTACH_EXISTING_ATTACHMENTS="Allegati Esistenti"
ATTACH_FILE="File"
ATTACH_FILE_SIZE="Dimensione del File"
ATTACH_FILE_URL="File / URL"
ATTACH_LAST_MODIFIED="Modificato il"
ATTACH_REALLY_DELETE_ATTACHMENT="Confermi la cancellazione dell'allegato?"
ATTACH_UPDATE_THIS_FILE="Aggiorna questo file"
ATTACH_URL="URL:"

View File

@ -0,0 +1,12 @@
; it-IT.plg_content_attachments.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)
; For the plugin manager
ATTACH_ATTACHMENTS_PLUGIN_DESCRIPTION="Plugin allegati: visualizza una lista degli allegati per ogni articolo (o elemento di contenuto supportato),"
PLG_CONTENT_ATTACHMENTS="Contenuto - Allegati"

View File

@ -0,0 +1,87 @@
<?php
/**
* Attachments quickicon plugin
*
* @package Attachments
* @subpackage Attachments.Quickicon_Plugin
*
* @copyright Copyright (C) 2013-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/
* @author Jonathan M. Cameron
*/
// no direct access
defined( '_JEXEC' ) or die('Restricted access');
jimport('joomla.plugin.plugin');
/**
* Attachments quickcion plugin class
*
* @package Attachments
* @subpackage Attachments.Quickicon_Plugin
*/
class PlgQuickiconAttachments extends JPlugin
{
/*
* Constructor.
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
*/
public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
}
/**
* This method is called when the Quick Icons module is constructing its set
* of icons. You can return an array which defines a single icon and it will
* be rendered right after the stock Quick Icons.
*
* @param $context The calling context
*
* @return array A list of icon definition associative arrays, consisting of the
* keys link, image, text and access.
*
* @since 2.5
*/
public function onGetIcons($context)
{
// See if we should show the icon
if ($context != $this->params->get('context', 'mod_quickicon') ||
!JFactory::getUser()->authorise('core.manage', 'com_attachments'))
{
return;
}
// Add the CSS file
JHtml::stylesheet('com_attachments/attachments_quickicon.css', array(), true);
if (version_compare(JVERSION, '3.0', 'ge'))
{
$image = 'flag-2';
$icon = JUri::root() . '/media/com_attachments/images/attachments_logo48.png';
}
else
{
$image = JUri::root() . '/media/com_attachments/images/attachments_logo48.png';
$icon = '';
}
// Return the icon info for the quickicon system
return
array(
array(
'link' => 'index.php?option=com_attachments',
'image' => $image,
'icon' => $icon,
'text' => JText::_('PLG_QUICKICON_ATTACHMENTS_ICON'),
'id' => 'plg_quickicon_attachment'));
}
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="quickicon" version="2.5" method="upgrade">
<name>plg_quickicon_attachments</name>
<version>3.2.6</version>
<creationDate>March 26, 2018</creationDate>
<author>Jonathan M. Cameron</author>
<copyright>(C) 2007-2018 Jonathan M. Cameron. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
<authorEmail>jmcameron@jmcameron.net</authorEmail>
<authorUrl>http://joomlacode.org/gf/project/attachments/</authorUrl>
<description>PLG_QUICKICON_ATTACHMENTS_XML_DESCRIPTION</description>
<files>
<filename plugin="attachments">attachments.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
<config>
<fields name="params">
<fieldset name="basic">
<field name="context"
type="text"
default="mod_quickicon"
description="PLG_QUICKICON_ATTACHMENTS_GROUP_DESC"
label="PLG_QUICKICON_ATTACHMENTS_GROUP_LABEL"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,13 @@
; en-GB.plg_quickicon_attachments.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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
PLG_QUICKICON_ATTACHMENTS="Quick Icon - Attachments"
PLG_QUICKICON_ATTACHMENTS_GROUP_DESC="The group of this plugin (this value is compared with the group value used in <b>Quick Icons</b> modules to inject icons)"
PLG_QUICKICON_ATTACHMENTS_GROUP_LABEL="Group"
PLG_QUICKICON_ATTACHMENTS_ICON="Attachments Manager"
PLG_QUICKICON_ATTACHMENTS_XML_DESCRIPTION="Manage the attachments for articles, categories, and other content types."

View File

@ -0,0 +1,10 @@
; en-GB.plg_quickicon_attachments.sys.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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
PLG_QUICKICON_ATTACHMENTS="Quick Icon - Attachments"
PLG_QUICKICON_ATTACHMENTS_XML_DESCRIPTION="Manage the attachments for articles, categories, and other content types."

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,13 @@
; it-IT.plg_quickicon_attachments.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-2013 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
; Italian translation by: Piero Mattirolo (2.0-3.1), Lemminkainen (version 1.3.4)
PLG_QUICKICON_ATTACHMENTS="Icona rapida - Allegati"
PLG_QUICKICON_ATTACHMENTS_GROUP_DESC="Il gruppo di questo plugin (questo valore è confrontato con il valore del gruppo utilizzato nei moduli <b>Icone rapide</b> per inserire icone"
PLG_QUICKICON_ATTACHMENTS_GROUP_LABEL="Gruppo"
PLG_QUICKICON_ATTACHMENTS_ICON="Gestione Allegati"
PLG_QUICKICON_ATTACHMENTS_XML_DESCRIPTION="Gestisce allegati per articoli, categorie e altri tipi di contenuti"

View File

@ -0,0 +1,10 @@
; it-IT.plg_quickicon_attachments.sys.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-2013 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
; Italian translation by: Piero Mattirolo (2.0-3.1), Lemminkainen (version 1.3.4)
PLG_QUICKICON_ATTACHMENTS="Icona rapida - Allegati"
PLG_QUICKICON_ATTACHMENTS_XML_DESCRIPTION="Gestisce allegati per articoli, categorie e altri tipi di contenuti"

View File

@ -0,0 +1,286 @@
<?php
/**
* Attachments search plugin
*
* @package Attachments
* @subpackage Attachments_Search_Plugin
*
* @copyright Copyright (C) 2007-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/
* @author Jonathan M. Cameron
*/
// no direct access
defined( '_JEXEC' ) or die('Restricted access');
jimport('joomla.plugin.plugin');
/**
* Attachments Search plugin
*
* @package Attachments
*/
class plgSearchAttachments extends JPlugin
{
/**
* Constructor
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
}
/**
* @return array An array of search areas
*/
public function onContentSearchAreas()
{
static $areas = array(
'attachments' => 'ATTACH_ATTACHMENTS'
);
return $areas;
}
/**
* Attachments Search method
*
* The sql must return the following fields that are
* used in a common display routine: href, title, section, created, text,
* browsernav
* @param string Target search string
* @param string mathcing option, exact|any|all
* @param string ordering option, newest|oldest|popular|alpha|category
* @param mixed An array if restricted to areas, null if search all
*/
public function onContentSearch($text, $phrase='', $ordering='', $areas=null)
{
$user = JFactory::getUser();
// Exit if the search does not include attachments
if (is_array($areas)) {
if (!array_intersect( $areas, array_keys( $this->onContentSearchAreas()))) {
return array();
}
}
// Make sure we have something to search for
$text = JString::trim( $text );
if ($text == '') {
return array();
}
// load search limit from plugin params
$limit = $this->params->def('search_limit', 50);
// Get the component parameters
jimport('joomla.application.component.helper');
$attachParams = JComponentHelper::getParams('com_attachments');
$secure = $attachParams->get('secure', false);
$user_field_1 = false;
if ( JString::strlen($attachParams->get('user_field_1_name', '')) > 0 ) {
$user_field_1 = true;
$user_field_1_name = $attachParams->get('user_field_1_name');
}
$user_field_2 = false;
if ( JString::strlen($attachParams->get('user_field_2_name', '')) > 0 ) {
$user_field_2 = true;
$user_field_2_name = $attachParams->get('user_field_2_name');
}
$user_field_3 = false;
if ( JString::strlen($attachParams->get('user_field_3_name', '')) > 0 ) {
$user_field_3 = true;
$user_field_3_name = $attachParams->get('user_field_3_name');
}
$wheres = array();
// Create the search query
$db = JFactory::getDBO();
switch ($phrase) {
case 'exact':
$text = $db->quote( '%'.$db->escape( $text, true ).'%', false );
$user_fields_sql = '';
if ( $user_field_1 )
$user_fields_sql .= " OR (LOWER(a.user_field_1) LIKE $text)";
if ( $user_field_2 )
$user_fields_sql .= " OR (LOWER(a.user_field_2) LIKE $text)";
if ( $user_field_3 )
$user_fields_sql .= " OR (LOWER(a.user_field_3) LIKE $text)";
$where = "((LOWER(a.filename) LIKE $text)" .
" OR (LOWER(a.display_name) LIKE $text)" .
$user_fields_sql .
" OR (LOWER(a.description) LIKE $text))";
break;
default:
$words = explode( ' ', $text );
$wheres = array();
foreach ($words as $word) {
$word = $db->quote( '%'.$db->escape( $word, true ).'%', false );
$wheres2 = array();
$wheres2[] = "LOWER(a.filename) LIKE $word";
$wheres2[] = "LOWER(a.display_name) LIKE $word";
$wheres2[] = "LOWER(a.url) LIKE $word";
if ( $user_field_1 )
$wheres2[] = "LOWER(a.user_field_1) LIKE $word";
if ( $user_field_2 )
$wheres2[] = "LOWER(a.user_field_2) LIKE $word";
if ( $user_field_3 )
$wheres2[] = "LOWER(a.user_field_3) LIKE $word";
$wheres2[] = "LOWER(a.description) LIKE $word";
$wheres[] = implode( ' OR ', $wheres2 );
}
$where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')';
break;
}
// Set up the sorting
switch ( $ordering )
{
case 'oldest':
$order = 'a.created ASC';
break;
case 'newest':
$order = 'a.created DESC';
break;
case 'alpha':
default:
$order = 'a.filename DESC';
}
// Load the permissions functions
$user = JFactory::getUser();
$user_levels = implode(',', array_unique($user->getAuthorisedViewLevels()));
// Construct and execute the query
$query = $db->getQuery(true);
$query->select('*')->from('#__attachments AS a');
$query->where("( $where ) AND a.state = 1");
if ( !$user->authorise('core.admin') ) {
$query->where('a.access in ('.$user_levels.')');
}
$query->order($order);
$db->setQuery( $query, 0, $limit );
$attachments = $db->loadObjectList();
$count = count( $attachments );
// See if we are done
$results = Array();
if ( $count <= 0 ) {
return $results;
}
// Prepare to get parent info
JPluginHelper::importPlugin('attachments');
$apm = getAttachmentsPluginManager();
// Add the result data to the results of the search
$k = 0;
for ( $i = 0; $i < $count; $i++ ) {
$attachment = $attachments[$i];
// Get the parent handler
$parent_type = $attachment->parent_type;
$parent_entity = $attachment->parent_entity;
if ( !$apm->attachmentsPluginInstalled($parent_type) ) {
// Exit if there is no Attachments plugin to handle this parent_type, ignore it
continue;
}
$parent = $apm->getAttachmentsPlugin($parent_type);
// Ignore the attachment if the user may not see the parent
if ( ! $parent->userMayViewParent($attachment->parent_id, $parent_entity) ) {
continue;
}
// Ignore the attachment if the parent is not published
if ( ! $parent->isParentPublished($attachment->parent_id, $parent_entity) ) {
continue;
}
// Do not add the attachment if the user may not access it
if ( !$parent->userMayAccessAttachment($attachment)) {
continue;
}
// Add the parent title
$attachment->parent_title = $parent->getTitle($attachment->parent_id, $parent_entity);
// Construct the download URL if necessary
if ( $secure && $attachment->uri_type == 'file' ) {
$attachment->href =
JRoute::_("index.php?option=com_attachments&task=download&id=" . (int)$attachment->id);
}
else {
$attachment->href = $attachment->url;
}
if ( $attachment->display_name && (JString::strlen($attachment->display_name) > 0) ) {
$attachment->title = JString::str_ireplace('&#183;', '.', $attachment->display_name);
}
else {
if ( $attachment->uri_type == 'file' ) {
$attachment->title = $attachment->filename;
}
else {
$attachment->title = $attachment->url;
}
}
// Set the text to the string containing the search target
if ( JString::strlen($attachment->display_name) > 0 ) {
$text = $attachment->display_name .
" (" . JText::_('ATTACH_FILENAME_COLON') . " " . $attachment->filename . ") ";
}
else {
$text = JText::_('ATTACH_FILENAME_COLON') . " " . $attachment->filename;
}
if ( JString::strlen($attachment->description) > 0 ) {
$text .= " | " . JText::_('ATTACH_DESCRIPTION_COLON') . stripslashes($attachment->description);
}
if ( $user_field_1 && (JString::strlen($attachment->user_field_1) > 0) ) {
$text .= " | " . $user_field_1_name . ": " . stripslashes($attachment->user_field_1);
}
if ( $user_field_2 && (JString::strlen($attachment->user_field_2) > 0) ) {
$text .= " | " . $user_field_2_name . ": " . stripslashes($attachment->user_field_2);
}
if ( $user_field_3 && (JString::strlen($attachment->user_field_3) > 0) ) {
$text .= " | " . $user_field_3_name . ": " . stripslashes($attachment->user_field_3);
}
$attachment->text = $text;
$attachment->browsernav = 2;
$parent_entity_name = JText::_('ATTACH_' . $parent_entity);
$attachment->parent_entity_name = $parent_entity_name;
$parent_title = JText::_($parent->getTitle($attachment->parent_id, $parent_entity));
$attachment->section = JText::sprintf('ATTACH_ATTACHED_TO_PARENT_S_TITLE_S',
$parent_entity_name, $parent_title);
$results[$k] = $attachment;
$k++;
}
return $results;
}
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="search" version="2.6" method="upgrade">
<name>plg_search_attachments</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) 2007-2018 Jonathan M. Cameron. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
<description>ATTACH_ATTACHMENTS_SEARCH_PLUGIN_DESCRIPTION</description>
<files>
<filename plugin="attachments">attachments.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
<config>
<fields name="params">
<fieldset name="basic">
<field name="search_limit" type="text" size="5" default="50"
label="ATTACH_SEARCH_LIMIT" description="ATTACH_SEARCH_LIMIT_DESCRIPTION"/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,15 @@
; en-GB.plg_search_attachments.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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_ATTACHED_TO_PARENT_S_TITLE_S="Attached to %s: %s"
ATTACH_ATTACHMENTS="Attachments"
ATTACH_ATTACHMENTS_SEARCH_PLUGIN_DESCRIPTION="The attachments search plugin enables searching all attachment filenames/URLs and descriptions."
ATTACH_DESCRIPTION_COLON="Description:"
ATTACH_FILENAME_COLON="Filename:"
ATTACH_SEARCH_LIMIT="Search limit"
ATTACH_SEARCH_LIMIT_DESCRIPTION="Number of Search items to return"

View File

@ -0,0 +1,10 @@
; en-GB.plg_search_attachments.sys.sys.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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_SEARCH_PLUGIN_DESCRIPTION="The attachments search plugin enables searching all attachment filenames/URLs and descriptions."
PLG_SEARCH_ATTACHMENTS="Search - Attachments"

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,15 @@
; it-IT.plg_search_attachments.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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_ATTACHED_TO_PARENT_S_TITLE_S="Allegato a %s: %s"
ATTACH_ATTACHMENTS="Allegati"
ATTACH_ATTACHMENTS_SEARCH_PLUGIN_DESCRIPTION="Questo plugin consente di effettuare ricerche, comprendenti nomi di file/URL e descrizioni."
ATTACH_DESCRIPTION_COLON="Descrizione:"
ATTACH_FILENAME_COLON="Nome del File:"
ATTACH_SEARCH_LIMIT="Limita la ricerca"
ATTACH_SEARCH_LIMIT_DESCRIPTION="Numero di elementi da visualizzare"

View File

@ -0,0 +1,10 @@
; it-IT.plg_search_attachments.sys.sys.ini
; Attachments for Joomla! extension
; Copyright (C) 2007-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_SEARCH_PLUGIN_DESCRIPTION="Questo plugin consente di effettuare ricerche, comprendenti nomi di file/URL e descrizioni."
PLG_SEARCH_ATTACHMENTS="Cerca - Allegati"