Пример #1
0
 /**
  * Attach the Attachments CSS sheets for category pages
  *
  * @param	string	The context of the content being passed to the plugin.
  * @param	object	The article object.	 Note $article->text is also available
  * @param	object	The article params
  * @param	int		The 'page' number
  *
  * @return	void
  */
 public function onContentPrepare($context, &$row, &$params, $page = 0)
 {
     $view = JRequest::getCmd('view');
     $layout = JRequest::getWord('layout');
     if ($view == 'category') {
         $app = JFactory::getApplication();
         if ($app->isAdmin()) {
             return;
         }
         // Note if this is a category view, we must add attachment
         // javascript and CSS whether we know there are going to be
         // attachments later or not because when the attachments list is
         // created it, it is in the onAfterRender() callback, which means
         // that the headers have already been rendered, so we cannot go
         // go back and add headers (easily)
         // Not necessary in more recent versions of Joomla since it can
         // handled by the normal Attachments onContentPrepare callback
         if (version_compare(JVERSION, '3.1', 'ge') or version_compare(JVERSION, '2.5.10', 'ge')) {
             return;
         }
         $uri = JFactory::getURI();
         $base_url = $uri->root(true);
         AttachmentsJavascript::setupJavascript();
         AttachmentsJavascript::setupModalJavascript();
         // Add the style sheets
         JHtml::stylesheet('com_attachments/attachments_list.css', array(), true);
         JHtml::stylesheet('com_attachments/attachments_hide.css', array(), true);
         $lang = JFactory::getLanguage();
         if ($lang->isRTL()) {
             JHtml::stylesheet('com_attachments/attachments_list_rtl.css', array(), true);
         }
     }
 }
Пример #2
0
 /**
  * Display the edit view
  */
 public function display($tpl = null)
 {
     // For convenience
     $attachment = $this->attachment;
     // Prevent unallowed editing
     if (!$this->attachment->parent->userMayEditAttachment($attachment)) {
         $errmsg = JText::_('ATTACH_ERROR_NO_PERMISSION_TO_EDIT');
         return JError::raiseError(403, $errmsg . ' (ERR 178)');
     }
     // Construct derived data
     $attachment->parent_entity_name = JText::_('ATTACH_' . $attachment->parent_entity);
     if (!isset($attachment->modifier_name)) {
         AttachmentsHelper::addAttachmentUserNames($attachment);
     }
     // Compute the attachment size in kB
     $attachment->size_kb = (int) (10 * $attachment->file_size / 1024.0) / 10.0;
     // set up lists for form controls
     $this->lists = array();
     $this->lists['published'] = JHtml::_('select.booleanlist', 'state', 'class="inputbox"', $attachment->state);
     $this->lists['url_valid'] = JHtml::_('select.booleanlist', 'url_valid', 'class="inputbox" title="' . JText::_('ATTACH_URL_IS_VALID_TOOLTIP') . '"', $attachment->url_valid);
     // Construct the drop-down list for legal icon filenames
     $icon_filenames = array();
     require_once JPATH_COMPONENT_SITE . '/file_types.php';
     foreach (AttachmentsFileTypes::unique_icon_filenames() as $ifname) {
         $icon_filenames[] = JHtml::_('select.option', $ifname);
     }
     $this->lists['icon_filenames'] = JHtml::_('select.genericlist', $icon_filenames, 'icon_filename', 'class="inputbox" size="1"', 'value', 'text', $attachment->icon_filename);
     // If switching from article to URL default url_verify to true
     if ($attachment->uri_type == 'file' and $this->update == 'url') {
         $attachment->url_verify = true;
     }
     // Set up for checkboxes
     $this->relative_url_checked = $attachment->url_relative ? 'checked="yes"' : '';
     $this->verify_url_checked = $attachment->url_verify ? 'checked="yes"' : '';
     // Set up 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');
     $this->download_count_tooltip = JText::_('ATTACH_NUMBER_OF_DOWNLOADS') . '::' . JText::_('ATTACH_NUMBER_OF_DOWNLOADS_TOOLTIP');
     // Set up mootools/modal
     AttachmentsJavascript::setupModalJavascript();
     // 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 the toolbar
     $this->addToolBar();
     // Display the form
     parent::display($tpl);
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
 *
 * @copyright Copyright (C) 2007-2015 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 Attachments helper
require_once JPATH_SITE . '/components/com_attachments/helper.php';
require_once JPATH_SITE . '/components/com_attachments/javascript.php';
// Add the plugins stylesheet to style the list of attachments
$uri = JFactory::getURI();
// Add javascript
AttachmentsJavascript::setupJavascript();
AttachmentsJavascript::setupModalJavascript();
// For convenience
$attachment = $this->attachment;
$params = $this->params;
// Get the parent id and a few other convenience items
$parent_id = $attachment->parent_id;
if ($parent_id === null) {
    $parent_id = 0;
}
// Set up to toggle between uploading file/urls
if ($attachment->uri_type == 'file') {
    $upload_toggle_button_text = JText::_('ATTACH_ENTER_URL_INSTEAD');
    $upload_toggle_url = $this->upload_url_url;
    $upload_button_text = JText::_('ATTACH_UPLOAD_VERB');
} else {
    $upload_toggle_button_text = JText::_('ATTACH_SELECT_FILE_TO_UPLOAD_INSTEAD');
Пример #5
0
 /**
  * Return the HTML for the "Add Attachments" link
  *
  * @param int $parent_id ID of the parent object
  * @param string $parent_entity type of the entity involved
  * @param int $Itemid the menu item id for the display
  * @param string $from where the control should return to
  *
  * @return the HTML for the "Add Attachments" link
  */
 public static function attachmentButtonsHTML($parent_type, $parent_id, $parent_entity, $Itemid, $from)
 {
     AttachmentsJavascript::setupModalJavascript();
     // Generate the HTML for a	button for the user to click to get to a form to add an attachment
     if ($parent_type == 'com_content' && $parent_entity == 'default') {
         $url = "index.php?option=com_attachments&task=upload&article_id={$parent_id}&tmpl=component";
     } else {
         if ($parent_entity != 'default') {
             $parent_type .= ':' . $parent_entity;
         }
         $url = "index.php?option=com_attachments&task=upload" . "&parent_id={$parent_id}&parent_type={$parent_type}&tmpl=component";
     }
     if ($from) {
         // Add a var to give a hint of where to return to
         // $url .= "&from=$from";
         $url .= "&from=closeme";
     }
     $url = JRoute::_($url);
     $add_attachment_txt = JText::_('ATTACH_ADD_ATTACHMENT');
     $icon = JHtml::image('com_attachments/add_attachment.gif', $add_attachment_txt, null, true);
     $ahead = '<a class="modal-button" type="button" href="' . $url . '" ';
     $ahead .= "rel=\"{handler: 'iframe', size: {x: 920, y: 550}}\">";
     $links = $ahead . $icon . "</a>";
     $links .= $ahead . $add_attachment_txt . "</a>";
     return "\n<div class=\"addattach\">{$links}</div>\n";
 }