primo commit
This commit is contained in:
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/**
|
||||
* Attachments component
|
||||
*
|
||||
* @package Attachments
|
||||
* @subpackage Attachments_Component
|
||||
*
|
||||
* @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');
|
||||
|
||||
// Load the tooltip behavior.
|
||||
JHtml::_('behavior.tooltip');
|
||||
|
||||
// Add the plugins stylesheet to style the list of attachments
|
||||
$document = JFactory::getDocument();
|
||||
$uri = JFactory::getURI();
|
||||
|
||||
$attachment = $this->attachment;
|
||||
|
||||
$upload_id = 'upload';
|
||||
|
||||
|
||||
// Show buttons for adding the attachments to other entitites (if appropriate)
|
||||
$alt_parent_html = '';
|
||||
$editor = JRequest::getWord('editor');
|
||||
$exceptions = Array('article', 'category', 'add_to_parent');
|
||||
if ( !in_array($editor, $exceptions) ) {
|
||||
|
||||
$base_url = $uri->base(true) . "/index.php?option=com_attachments&task=attachment.add";
|
||||
|
||||
// Add a footer section with buttons to attach files to the supported content types/entities
|
||||
$alt_parent_html .= '<div id="attachmentsPotentialParents">';
|
||||
$alt_parent_html .= '<p>';
|
||||
|
||||
// For normal LTR, put the label on the left
|
||||
if ( !$lang->isRTL() ) {
|
||||
$alt_parent_html .= '<span>' . JText::_('ATTACH_ADD_ATTACHMENT_TO') . '</span> ';
|
||||
}
|
||||
|
||||
// Create all the buttons
|
||||
foreach ($this->entity_info as $einfo) {
|
||||
$parent_type = $einfo['parent_type'];
|
||||
$centity = $einfo['id'];
|
||||
$cename = $einfo['name'];
|
||||
if ( ($parent_type != $attachment->parent_type) || ($centity != $attachment->parent_entity) ) {
|
||||
$url = $base_url . "&parent_type=" . $parent_type;
|
||||
$tooltip = JText::sprintf('ATTACH_ADD_ATTACHMENT_TO_S_INSTEAD_OF_S_TOOLTIP',
|
||||
$cename, $attachment->parent_entity_name);
|
||||
if ( $centity != 'default' ) {
|
||||
$url .= '.' . $centity;
|
||||
}
|
||||
if ( $attachment->uri_type == 'url' ) {
|
||||
$url .= '&uri=url';
|
||||
}
|
||||
$alt_parent_html .= " <a class=\"changeButton\" href=\"$url\" title=\"$tooltip\">$cename</a>";
|
||||
}
|
||||
}
|
||||
|
||||
// For normal RTL, put the label on the right
|
||||
if ( $lang->isRTL() ) {
|
||||
$alt_parent_html .= '<span>' . JText::_('ATTACH_ADD_ATTACHMENT_TO') . '</span>';
|
||||
}
|
||||
|
||||
$alt_parent_html .= '</p>';
|
||||
$alt_parent_html .= '</div>';
|
||||
}
|
||||
|
||||
|
||||
if ( $attachment->parent_title ) {
|
||||
echo "<h1>" . JText::sprintf('ATTACH_PARENT_S_COLON_S', $attachment->parent_entity_name, $attachment->parent_title) . "</h1>";
|
||||
}
|
||||
|
||||
?>
|
||||
<form class="attachmentsBackend" enctype="multipart/form-data"
|
||||
name="adminForm" id="adminForm"
|
||||
action="<?php echo $this->save_url; ?>" method="post">
|
||||
<fieldset class="adminform">
|
||||
<legend><?php echo JText::_('ATTACH_ADD_ATTACHMENT'); ?></legend>
|
||||
<table class="admintable">
|
||||
<?php if ( !$this->new_parent && !$attachment->parent_id ): ?>
|
||||
<tr>
|
||||
<td class="key"><label for="parent_title"><?php echo $this->selpar_label ?></label></td>
|
||||
<td><?php echo $alt_parent_html; ?>
|
||||
<input id="parent_title" value="<?php echo $attachment->parent_title ?>" disabled="disabled" type="text" size="60" />
|
||||
<a class="modal-button" type="button"
|
||||
href="<?php echo $this->selpar_btn_url ?>" title="<?php echo $this->selpar_btn_tooltip ?>"
|
||||
rel="{handler: 'iframe', size: {x: 800, y: 450}}"><?php echo $this->selpar_btn_text ?></a>
|
||||
<input id="parent_id" name="parent_id" value="-1" type="hidden" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ( $attachment->uri_type == 'file' ): ?>
|
||||
<tr>
|
||||
<td class="key"><label for="upload" id="upload_file_label"><?php echo JText::_('ATTACH_ATTACH_FILE_COLON') ?></label></td>
|
||||
<td>
|
||||
<a class="changeButton" href="<?php echo $this->upload_toggle_url ?>"
|
||||
title="<?php echo $this->upload_toggle_tooltip; ?>"><?php
|
||||
echo $this->upload_toggle_button_text;?></a><br />
|
||||
<input type="file" name="upload" id="<?php echo $upload_id; ?>"
|
||||
size="74" maxlength="1024" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key"><label for="display_name" class="hasTip" title="<?php echo $this->display_filename_tooltip; ?>"
|
||||
><?php echo JText::_('ATTACH_DISPLAY_FILENAME'); ?></label></td>
|
||||
<td>
|
||||
<input type="text" name="display_name" id="display_name" size="75" maxlength="80"
|
||||
title="<?php echo $this->display_filename_tooltip; ?>" class="hasTip"
|
||||
value="<?php echo $attachment->display_name ?>" /><span class="optional"><?php echo JText::_('ATTACH_OPTIONAL'); ?></span>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td class="key"><label for="upload" class="hasTip"
|
||||
title="<?php echo $this->enter_url_tooltip ?>"><?php echo JText::_('ATTACH_ENTER_URL') ?></label></td>
|
||||
<td>
|
||||
<label for="verify_url"><?php echo JText::_('ATTACH_VERIFY_URL_EXISTENCE') ?></label>
|
||||
<input type="checkbox" name="verify_url" value="verify" <?php echo $this->verify_url_checked ?>
|
||||
title="<?php echo JText::_('ATTACH_VERIFY_URL_EXISTENCE_TOOLTIP'); ?>" />
|
||||
<label for="url_relative"><?php echo JText::_('ATTACH_RELATIVE_URL') ?></label>
|
||||
<input type="checkbox" name="url_relative" value="relative" <?php echo $this->relative_url_checked ?>
|
||||
title="<?php echo JText::_('ATTACH_RELATIVE_URL_TOOLTIP'); ?>" />
|
||||
<a class="changeButton" href="<?php echo $this->upload_toggle_url ?>"
|
||||
title="<?php echo $this->upload_toggle_tooltip; ?>"><?php
|
||||
echo $this->upload_toggle_button_text;?></a><br />
|
||||
|
||||
<input type="text" name="url" id="<?php echo $upload_id; ?>"
|
||||
size="86" title="<?php echo JText::_('ATTACH_ENTER_URL_TOOLTIP'); ?>"
|
||||
value="<?php echo $attachment->url; ?>" /><br /><?php
|
||||
echo JText::_('ATTACH_NOTE_ENTER_URL_WITH_HTTP'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key"><label for="display_name" title="<?php echo $this->display_url_tooltip; ?>" class="hasTip"
|
||||
><?php echo JText::_('ATTACH_DISPLAY_URL'); ?></label></td>
|
||||
<td>
|
||||
<input type="text" name="display_name" id="display_name" size="75" maxlength="80"
|
||||
title="<?php echo $this->display_url_tooltip; ?>" class="hasTip"
|
||||
value="<?php echo $attachment->display_name ?>" /> <?php echo JText::_('ATTACH_OPTIONAL'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td class="key"><label for="description"
|
||||
title="<?php echo JText::_('ATTACH_DESCRIPTION_DESCRIPTION'); ?>"
|
||||
><?php echo JText::_('ATTACH_DESCRIPTION'); ?></label></td>
|
||||
<td>
|
||||
<input type="text" name="description" id="description"
|
||||
title="<?php echo JText::_('ATTACH_DESCRIPTION_DESCRIPTION'); ?>"
|
||||
size="75" maxlength="255" value="<?php echo stripslashes($attachment->description) ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $this->may_publish ): ?>
|
||||
<tr>
|
||||
<td class="key"><label><?php echo JText::_('ATTACH_PUBLISHED'); ?></label></td>
|
||||
<td><?php echo $this->lists['published']; ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<tr>
|
||||
<td class="key"><label for="access" class="hasTip" title="<?php echo $this->access_level_tooltip ?>"><?php echo JText::_('JFIELD_ACCESS_LABEL'); ?></label></td>
|
||||
<td><?php echo $this->access_level; ?></td>
|
||||
</tr>
|
||||
<?php if ( $this->show_user_field_1 ): ?>
|
||||
<tr>
|
||||
<td class="key"><label for="user_field_1"><?php echo $this->user_field_1_name; ?></label></td>
|
||||
<td><input type="text" name="user_field_1" id="user_field_1" size="75" maxlength="100" value="" /></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ( $this->show_user_field_2 ): ?>
|
||||
<tr>
|
||||
<td class="key"><label for="user_field_2"><?php echo $this->user_field_2_name; ?></label></td>
|
||||
<td><input type="text" name="user_field_2" id="user_field_2" size="75" maxlength="100" value="" /></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ( $this->show_user_field_3 ): ?>
|
||||
<tr>
|
||||
<td class="key"><label for="user_field_3"><?php echo $this->user_field_3_name; ?></label></td>
|
||||
<td><input type="text" name="user_field_3" id="user_field_3" size="75" maxlength="100" value="" /></td>
|
||||
<tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</fieldset>
|
||||
<?php if ( $this->new_parent ): ?>
|
||||
<input type="hidden" name="new_parent" value="1" />
|
||||
<?php elseif ( $attachment->parent_id ): ?>
|
||||
<input type="hidden" name="parent_id" value="<?php echo $attachment->parent_id; ?>" />
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="524288" />
|
||||
<input type="hidden" name="save_type" value="upload" />
|
||||
<input type="hidden" name="parent_type" value="<?php echo $attachment->parent_type; ?>" />
|
||||
<input type="hidden" name="parent_entity" value="<?php echo $attachment->parent_entity; ?>" />
|
||||
<input type="hidden" name="uri_type" value="<?php echo $attachment->uri_type; ?>" />
|
||||
<input type="hidden" name="option" value="<?php echo $this->option;?>" />
|
||||
<input type="hidden" name="task" value="attachment.add" />
|
||||
<input type="hidden" name="from" value="<?php echo $this->from; ?>" />
|
||||
<?php if ( $this->from == 'closeme' ): ?>
|
||||
<div class="form_buttons" align="center">
|
||||
<input type="submit" name="Submit" class="button"
|
||||
onclick="javascript: submitbutton('attachment.saveNew')"
|
||||
value="<?php echo JText::_('ATTACH_UPLOAD_VERB'); ?>" />
|
||||
<span class="right">
|
||||
<input type="button" name="cancel" value="<?php echo JText::_('ATTACH_CANCEL'); ?>"
|
||||
onClick="window.parent.SqueezeBox.close();" />
|
||||
</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php echo JHtml::_( 'form.token' ); ?>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
// Show the existing attachments
|
||||
if ( ($attachment->uri_type == 'file') && $attachment->parent_id ) {
|
||||
/** Get the Attachments controller class */
|
||||
require_once(JPATH_ADMINISTRATOR.'/components/com_attachments/controllers/list.php');
|
||||
$controller = new AttachmentsControllerList();
|
||||
$controller->displayString($attachment->parent_id, $attachment->parent_type, $attachment->parent_entity,
|
||||
'ATTACH_EXISTING_ATTACHMENTS', false, false, true, $this->from);
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
||||
183
administrator/components/com_attachments/views/add/view.html.php
Normal file
183
administrator/components/com_attachments/views/add/view.html.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* Attachments component
|
||||
*
|
||||
* @package Attachments
|
||||
* @subpackage Attachments_Component
|
||||
*
|
||||
* @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');
|
||||
|
||||
// Access check.
|
||||
if (!JFactory::getUser()->authorise('core.create', 'com_attachments')) {
|
||||
return JError::raiseError(404, JText::_('JERROR_ALERTNOAUTHOR') . ' (ERR 172)');
|
||||
}
|
||||
|
||||
/** Define the legacy classes, if necessary */
|
||||
require_once(JPATH_SITE.'/components/com_attachments/legacy/view.php');
|
||||
|
||||
/** Include the Attachments javascript classes */
|
||||
require_once(JPATH_SITE.'/components/com_attachments/javascript.php');
|
||||
|
||||
|
||||
/**
|
||||
* HTML View class for adding new attachments
|
||||
*
|
||||
* @package Attachments
|
||||
*/
|
||||
class AttachmentsViewAdd extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* Display the add/create view
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// For convenience below
|
||||
$attachment = $this->attachment;
|
||||
$parent_id = $attachment->parent_id;
|
||||
$parent_type = $attachment->parent_type;
|
||||
$parent_entity = $attachment->parent_entity;
|
||||
$attachment->parent_entity_name = JText::_('ATTACH_' . $attachment->parent_entity);
|
||||
$parent_entity_name = $attachment->parent_entity_name;
|
||||
$params = $this->params;
|
||||
|
||||
// Prevent unallowed editing PID PE
|
||||
if (!$this->parent->userMayAddAttachment($parent_id, $parent_entity, $this->new_parent))
|
||||
{
|
||||
$errmsg = JText::sprintf('ATTACH_ERROR_NO_PERMISSION_TO_UPLOAD_S',
|
||||
$attachment->parent_entity_name);
|
||||
return JError::raiseError(403, $errmsg . ' (ERR 173)');
|
||||
}
|
||||
|
||||
// Construct derived data
|
||||
$this->relative_url_checked = $attachment->url_relative ? 'checked="yes"' : '';
|
||||
$this->verify_url_checked = $attachment->url_verify ? 'checked="yes"' : '';
|
||||
|
||||
// Construct some tooltips
|
||||
$this->enter_url_tooltip = JText::_('ATTACH_ENTER_URL') . '::' . JText::_('ATTACH_ENTER_URL_TOOLTIP');
|
||||
$this->display_filename_tooltip = JText::_('ATTACH_DISPLAY_FILENAME') . '::' . JText::_('ATTACH_DISPLAY_FILENAME_TOOLTIP');
|
||||
$this->display_url_tooltip = JText::_('ATTACH_DISPLAY_URL') . '::' . JText::_('ATTACH_DISPLAY_URL_TOOLTIP');
|
||||
|
||||
// Add the published selection
|
||||
$this->lists = Array();
|
||||
$this->lists['published'] = JHtml::_('select.booleanlist', 'state',
|
||||
'class="inputbox"', $attachment->state);
|
||||
|
||||
// Set up the access field
|
||||
require_once(JPATH_COMPONENT_ADMINISTRATOR.'/models/fields/accesslevels.php');
|
||||
$this->access_level = JFormFieldAccessLevels::getAccessLevels('access', 'access', null);
|
||||
$this->access_level_tooltip = JText::_('JFIELD_ACCESS_LABEL') . '::' . JText::_('JFIELD_ACCESS_DESC');
|
||||
|
||||
// Handle user field 1
|
||||
$show_user_field_1 = false;
|
||||
$user_field_1_name = $params->get('user_field_1_name', '');
|
||||
if ( $user_field_1_name != '' ) {
|
||||
$show_user_field_1 = true;
|
||||
$this->user_field_1_name = $user_field_1_name;
|
||||
}
|
||||
$this->show_user_field_1 = $show_user_field_1;
|
||||
|
||||
// Handle user field 2
|
||||
$show_user_field_2 = false;
|
||||
$user_field_2_name = $params->get('user_field_2_name', '');
|
||||
if ( $user_field_2_name != '' ) {
|
||||
$show_user_field_2 = true;
|
||||
$this->user_field_2_name = $user_field_2_name;
|
||||
}
|
||||
$this->show_user_field_2 = $show_user_field_2;
|
||||
|
||||
// Handle user field 3
|
||||
$show_user_field_3 = false;
|
||||
$user_field_3_name = $params->get('user_field_3_name', '');
|
||||
if ( $user_field_3_name != '' ) {
|
||||
$show_user_field_3 = true;
|
||||
$this->user_field_3_name = $user_field_3_name;
|
||||
}
|
||||
$this->show_user_field_3 = $show_user_field_3;
|
||||
|
||||
// Set up to toggle between uploading file/urls
|
||||
if ( $attachment->uri_type == 'file' ) {
|
||||
$upload_toggle_button_text = JText::_('ATTACH_ENTER_URL_INSTEAD');
|
||||
$upload_toggle_tooltip = JText::_('ATTACH_ENTER_URL_INSTEAD_TOOLTIP');
|
||||
$upload_toggle_url = 'index.php?option=com_attachments&task=attachment.add&uri=url';
|
||||
}
|
||||
else {
|
||||
$upload_toggle_button_text = JText::_('ATTACH_SELECT_FILE_TO_UPLOAD_INSTEAD');
|
||||
$upload_toggle_tooltip = JText::_('ATTACH_SELECT_FILE_TO_UPLOAD_INSTEAD_TOOLTIP');
|
||||
$upload_toggle_url = 'index.php?option=com_attachments&task=attachment.add&uri=file';
|
||||
}
|
||||
if ( $this->from == 'closeme' ) {
|
||||
$upload_toggle_url .= '&tmpl=component';
|
||||
}
|
||||
if ( $this->from ) {
|
||||
$upload_toggle_url .= '&from=' . $this->from;
|
||||
}
|
||||
|
||||
// Update the toggle URL to not forget if the parent is not simply an article
|
||||
if ( !( ($parent_type == 'com_content') && ($parent_entity == 'default')) ) {
|
||||
$upload_toggle_url .= "&parent_type=$parent_type";
|
||||
if ( $parent_entity != 'default' ) {
|
||||
$upload_toggle_url .= ".$parent_entity";
|
||||
}
|
||||
}
|
||||
|
||||
// If this is for an existing content item, modify the URL appropriately
|
||||
if ( $this->new_parent ) {
|
||||
$upload_toggle_url .= "&parent_id=0,new";
|
||||
}
|
||||
elseif ( $parent_id && ($parent_id != -1) ) {
|
||||
$upload_toggle_url .= "&parent_id=$parent_id";
|
||||
}
|
||||
if ( JRequest::getWord('editor') ) {
|
||||
$upload_toggle_url .= "&editor=" . JRequest::getWord('editor');
|
||||
}
|
||||
|
||||
$this->upload_toggle_button_text = $upload_toggle_button_text;
|
||||
$this->upload_toggle_url = $upload_toggle_url;
|
||||
$this->upload_toggle_tooltip = $upload_toggle_tooltip;
|
||||
|
||||
// Set up the 'select parent' button
|
||||
$this->selpar_label = JText::sprintf('ATTACH_SELECT_ENTITY_S_COLON', $parent_entity_name);
|
||||
$this->selpar_btn_text = ' ' . JText::sprintf('ATTACH_SELECT_ENTITY_S', $parent_entity_name) . ' ';
|
||||
$this->selpar_btn_tooltip = JText::sprintf('ATTACH_SELECT_ENTITY_S_TOOLTIP', $parent_entity_name);
|
||||
$this->selpar_btn_url = $this->parent->getSelectEntityURL($parent_entity);
|
||||
|
||||
// Add the style sheets
|
||||
JHtml::stylesheet('com_attachments/attachments_admin_form.css', Array(), true);
|
||||
$lang = JFactory::getLanguage();
|
||||
if ( $lang->isRTL() ) {
|
||||
JHtml::stylesheet('com_attachments/attachments_admin_form_rtl.css', Array(), true);
|
||||
}
|
||||
|
||||
// Set up mootools/modal
|
||||
AttachmentsJavascript::setupModalJavascript();
|
||||
|
||||
// Set the toolbar
|
||||
$this->addToolBar();
|
||||
|
||||
// Display the form
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the toolbar
|
||||
*/
|
||||
protected function addToolBar()
|
||||
{
|
||||
JRequest::setVar('hidemainmenu', true);
|
||||
JToolBarHelper::title(JText::_('ATTACH_ADD_ATTACHMENT'));
|
||||
|
||||
JToolBarHelper::apply('attachment.applyNew');
|
||||
JToolBarHelper::save('attachment.saveNew');
|
||||
JToolBarHelper::save2new('attachment.save2New');
|
||||
|
||||
JToolBarHelper::cancel('attachment.cancel', 'JTOOLBAR_CANCEL');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user