/** * HTML view display method * * @param string $tpl The name of the template file to parse * @return void * @since 3.0 */ public function display($tpl = null) { JToolBarHelper::title(JText::_('COM_JOOMGALLERY_AJAX_UPLOAD'), 'upload'); $this->_doc->addScriptDeclaration(' var jg_filenamewithjs = ' . ($this->_config->get('jg_filenamewithjs') ? 'true' : 'false') . ';'); // Load Fine Uploader resources $this->_doc->addStyleSheet($this->_ambit->getScript('fineuploader/fineuploader.css')); $this->_doc->addScript($this->_ambit->getScript('fineuploader/js/fineuploader' . (JFactory::getConfig()->get('debug') ? '' : '.min') . '.js')); $this->fileSizeLimit = 0; $this->chunkSize = 0; $post_max_size = @ini_get('post_max_size'); if (!empty($post_max_size)) { $post_max_size = JoomHelper::iniToBytes($post_max_size); $this->chunkSize = (int) min(500000, (int) (0.8 * $post_max_size)); } $upload_max_filesize = @ini_get('upload_max_filesize'); if (!empty($upload_max_filesize)) { $upload_max_filesize = JoomHelper::iniToBytes($upload_max_filesize); $this->fileSizeLimit = $upload_max_filesize; } $this->editFilename = $this->_config->get('jg_useorigfilename'); JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $this->form = JForm::getInstance(_JOOM_OPTION . '.ajaxupload', 'ajaxupload'); $this->form->setFieldAttribute('access', 'default', (int) JFactory::getConfig()->get('access')); if ($this->_config->get('jg_useorigfilename')) { $this->form->setFieldAttribute('imgtitle', 'required', 'false'); } $this->sidebar = JHtmlSidebar::render(); parent::display($tpl); }
/** * HTML view display method * * @access public * @param string $tpl The name of the template file to parse * @return void * @since 1.5.5 */ function display($tpl = null) { JForm::addFormPath(JPATH_COMPONENT_ADMINISTRATOR . '/models/forms'); // Initialise some variables $this->page = 1; $this->e_name = $this->_mainframe->getUserStateFromRequest('joom.mini.e_name', 'e_name', 'text', 'string'); $this->images_fields = array('type', 'position', 'linked', 'linked_type', 'alttext', 'class', 'linkedtext'); $this->extended = $this->_mainframe->getUserStateFromRequest('joom.mini.extended', 'extended', 1, 'int'); $this->upload_catid = $this->_mainframe->input->getInt('upload_category'); $this->prefix = $this->_mainframe->getUserStateFromRequest('joom.mini.prefix', 'prefix', 'joom', 'cmd'); // Decide which tabs have to be displayed $this->tabs = array('images' => true); if ($this->extended > 0) { $this->tabs = array('images' => true, 'categories' => true, 'upload' => true, 'createcategory' => true); } if ($this->upload_catid) { $this->tabs = array('upload' => true); } // Images tab if (isset($this->tabs['images'])) { // Also display the options for inserting images into articles if ($this->extended > 0) { $plugin = JPluginHelper::getPlugin('content', 'joomplu'); if (!$this->upload_catid && !count($plugin)) { $this->_mainframe->enqueueMessage(JText::_('COM_JOOMGALLERY_MINI_MSG_NOT_INSTALLED_OR_ACTIVATED'), 'notice'); $params = ''; } else { $params = $plugin->params; } // Load plugin parameters $this->params = new JRegistry(); $this->params->loadString($params); $this->images_form = JForm::getInstance(_JOOM_OPTION . '.mini.images', 'mini.images'); $fields_default_values = array('type' => 'thumb', 'position' => '', 'linked' => 0, 'linked_type' => 'orig', 'alttext' => '', 'class' => '', 'linkedtext' => ''); foreach ($this->images_fields as $field) { $this->images_form->setFieldAttribute($field, 'default', $this->params->get('default_' . $field, $fields_default_values[$field])); } // Hidden images $this->_mainframe->setUserState('joom.mini.showhidden', $this->params->get('showhidden')); } // Pagination $this->total = $this->get('TotalImages'); // Calculation of the number of total pages $limit = $this->_mainframe->getUserStateFromRequest('joom.mini.limit', 'limit', 30, 'int'); if (!$limit) { $this->totalpages = 1; } else { $this->totalpages = floor($this->total / $limit); $offcut = $this->total % $limit; if ($offcut > 0) { $this->totalpages++; } } $totalimages = $this->total; $this->total = number_format($this->total, 0, JText::_('COM_JOOMGALLERY_COMMON_DECIMAL_SEPARATOR'), JText::_('COM_JOOMGALLERY_COMMON_THOUSANDS_SEPARATOR')); // Get the current page $this->page = JRequest::getInt('page', 0); if ($this->page > $this->totalpages) { $this->page = $this->totalpages; } if ($this->page < 1) { $this->page = 1; } // Limitstart $limitstart = ($this->page - 1) * $limit; JRequest::setVar('limitstart', $limitstart); if ($this->total <= $limit) { $limitstart = 0; JRequest::setVar('limitstart', $limitstart); } JRequest::setVar('limit', $limit); require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/pagination.php'; $onclick = 'javascript:ajaxRequest(\'index.php?option=' . _JOOM_OPTION . '&view=mini&format=json\', %u); return false;'; $this->pagination = new JoomPagination($totalimages, $limitstart, $limit, '', null, $onclick); $this->images = $this->get('Images'); $this->catid = $this->_mainframe->getUserStateFromRequest('joom.mini.catid', 'catid', 0, 'int'); foreach ($this->images as $key => $image) { $image->thumb_src = null; $thumb = $this->_ambit->getImg('thumb_path', $image); if ($image->imgthumbname && is_file($thumb)) { $imginfo = getimagesize($thumb); $image->thumb_src = $this->_ambit->getImg('thumb_url', $image); $image->thumb_width = $imginfo[0]; $image->thumb_height = $imginfo[1]; $this->image = $image; $overlib = $this->loadTemplate('overlib'); $image->overlib = str_replace(array("\r\n", "\r", "\n"), '', htmlspecialchars($overlib, ENT_QUOTES, 'UTF-8')); } $this->images[$key] = $image; } // Limit Box $limits = array(); // Create the option list for ($i = 5; $i <= 30; $i += 5) { $limits[] = JHtml::_('select.option', $i); } $limits[] = JHtml::_('select.option', '50'); $limits[] = JHtml::_('select.option', '100'); $limits[] = JHtml::_('select.option', '0', JText::_('JALL')); $url = 'index.php?option=' . _JOOM_OPTION . '&view=mini&format=json'; $this->lists = array(); $this->lists['limit'] = JHtml::_('select.genericlist', $limits, 'limit', 'class="inputbox input-mini" size="1" onchange="javascript:ajaxRequest(\'' . $url . '\', 0, \'limit=\' + this[this.selectedIndex].value)"', 'value', 'text', $limit); $this->lists['image_categories'] = JHtml::_('joomselect.categorylist', $this->catid, 'catid', 'onchange="javascript:ajaxRequest(\'' . $url . '\', 0, \'catid=\' + document.id(\'catid\').value)"', null, '- ', 'filter'); $this->object = $this->_mainframe->getUserStateFromRequest('joom.mini.object', 'object', '', 'cmd'); $this->search = $this->_mainframe->getUserStateFromRequest('joom.mini.search', 'search', '', 'string'); } // Categories tab if (isset($this->tabs['categories'])) { $this->categories_form = JForm::getInstance(_JOOM_OPTION . '.mini.categories', 'mini.categories'); $this->categories_form->setFieldAttribute('category_catid', 'onchange', str_replace('joom_', $this->prefix . '_', $this->categories_form->getFieldAttribute('category_catid', 'onchange'))); $categories_fields = array('category_mode', 'category_limit', 'category_columns', 'category_ordering', 'category_linkedtext'); foreach ($categories_fields as $field) { $this->categories_form->setFieldAttribute($field, 'default', $this->params->get('default_' . $field)); } } // Upload tab if (isset($this->tabs['upload'])) { $this->upload_form = JForm::getInstance(_JOOM_OPTION . '.mini.upload', 'mini.upload'); if ($this->upload_catid) { $this->upload_form->setFieldAttribute('catid', 'default', $this->upload_catid); } $this->fileSizeLimit = $this->_mainframe->isSite() ? $this->_config->get('jg_maxfilesize') : 0; $this->chunkSize = 0; $post_max_size = @ini_get('post_max_size'); if (!empty($post_max_size)) { $post_max_size = JoomHelper::iniToBytes($post_max_size); $this->chunkSize = (int) min(500000, (int) (0.8 * $post_max_size)); } $upload_max_filesize = @ini_get('upload_max_filesize'); if (!empty($upload_max_filesize)) { $upload_max_filesize = JoomHelper::iniToBytes($upload_max_filesize); if ($this->fileSizeLimit <= 0 || $this->fileSizeLimit > $upload_max_filesize) { $this->fileSizeLimit = $upload_max_filesize; } } $this->editFilename = $this->_mainframe->isSite() ? $this->_config->get('jg_useruseorigfilename') : $this->_config->get('jg_useorigfilename'); $this->delete_original = $this->_mainframe->isSite() ? $this->_config->get('jg_delete_original_user') == 2 : $this->_config->get('jg_delete_original') == 2; JText::script('COM_JOOMGALLERY_MINI_TYPE'); JText::script('COM_JOOMGALLERY_MINI_POSITION'); JText::script('COM_JOOMGALLERY_MINI_ALTTEXT'); JText::script('COM_JOOMGALLERY_COMMON_THUMBNAIL'); JText::script('COM_JOOMGALLERY_MINI_DETAIL'); JText::script('COM_JOOMGALLERY_MINI_ORIGINAL'); JText::script('JNONE'); JText::script('JGLOBAL_CENTER'); JText::script('JGLOBAL_LEFT'); JText::script('JGLOBAL_RIGHT'); } // Create category tab if (isset($this->tabs['createcategory'])) { $this->category_form = JForm::getInstance(_JOOM_OPTION . '.mini.category', 'mini.category'); JText::script('COM_JOOMGALLERY_MINI_PLEASE_ENTER_TEXT'); } // The parameter object is necessary for the even if it // doesn't contain any data (this simplifies things) if (!isset($this->params)) { $this->params = new JRegistry(); $this->params->loadString(''); } // Set some default values before possibly modifying the view $this->upload_categories = null; $this->parent_categories = null; $this->upload_enabled = true; $this->createcat_enabled = true; // If we are in frontend modify the view by adding possibility to // change the category select boxes according to the plugin settings if (!$this->upload_catid && $this->_mainframe->isSite()) { $this->modifyView(); } JText::script('JLIB_FORM_FIELD_INVALID'); // Build the sorted message list $messages = $this->_mainframe->getMessageQueue(); $this->messages = array(); if (is_array($messages) && !empty($messages)) { foreach ($messages as $msg) { if (isset($msg['type']) && isset($msg['message'])) { $this->messages[$msg['type']][] = $msg['message']; } } } parent::display($tpl); }
/** * Returns the HTML for the FineUploader inclusion * * @return string The HTML for the FineUploader inclusion * @since 3.2 */ protected function getInput() { $app = JFactory::getApplication(); $config = JoomConfig::getInstance(); $url = JRoute::_('index.php?option=' . _JOOM_OPTION . '&controller=ajaxupload&task=upload', false); if ($app->isSite()) { $url = JRoute::_('index.php?option=' . _JOOM_OPTION . '&task=ajaxupload.upload', false); } $fileSizeLimit = $app->isSite() ? $config->get('jg_maxfilesize') : 0; $chunkSize = 0; $post_max_size = @ini_get('post_max_size'); if (!empty($post_max_size)) { $post_max_size = JoomHelper::iniToBytes($post_max_size); $chunkSize = (int) min(500000, (int) (0.8 * $post_max_size)); } $upload_max_filesize = @ini_get('upload_max_filesize'); if (!empty($upload_max_filesize)) { $upload_max_filesize = JoomHelper::iniToBytes($upload_max_filesize); if ($fileSizeLimit <= 0 || $fileSizeLimit > $upload_max_filesize) { $fileSizeLimit = $upload_max_filesize; } } $editFilename = $app->isSite() ? $config->get('jg_useruseorigfilename') : $config->get('jg_useorigfilename'); $prefix = $this->element['field_id_prefix']; $isMini = $this->element['mini'] && $this->element['mini'] != 'false'; $redirect = $this->element['redirect']; $insertOptions = $this->element['insert_options'] && $this->element['insert_options'] != 'false'; $formId = $this->element['form_id']; $catidField = $this->element['catid_field'] ? $this->element['catid_field'] : 'catid'; if (!$formId) { throw new RuntimeException('Attribute \'form_id\' is required for the fineuploader field.'); } ob_start(); ?> <div id="fine-uploader"></div> <script type="text/javascript"> jQuery(document).ready(function() { var uploader = new qq.FineUploader({ element: jQuery('#fine-uploader')[0], request: { endpoint: '<?php echo $url . '&format=raw'; ?> ', paramsInBody: true }, chunking: { enabled: true, partSize: <?php echo $chunkSize; ?> }, autoUpload: false, display: { fileSizeOnSubmit: true }, text: { failUpload: '<?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_UPLOAD_FAILED', true); ?> ', formatProgress: '{percent}% ' + '<?php echo JText::_('COM_JOOMGALLERY_COMMON_OF', true); ?> ' +' {total_size}', waitingForResponse: '<?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_PROCESSING', true); ?> ' }, failedUploadTextDisplay: { mode: 'custom' }, dragAndDrop: { extraDropzones: [] }, fileTemplate: 'qq-template', classes: { success: 'alert-success', fail: 'alert-error', debugText: 'qq-upload-debug-text', thumb: 'qq-upload-thumb', options: 'qq-upload-options', note: 'qq-upload-note' }, validation: { allowedExtensions: ['jpg', 'jpeg', 'jpe', 'gif', 'png'], acceptFiles: 'image/*', sizeLimit: <?php echo $fileSizeLimit; ?> }, messages: { typeError: '{file}: ' + '<?php echo JText::_('COM_JOOMGALLERY_COMMON_ALERT_WRONG_EXTENSION', true); ?> ', sizeError: '{file}: ' + '<?php echo JText::sprintf('COM_JOOMGALLERY_UPLOAD_OUTPUT_MAX_ALLOWED_FILESIZE', $fileSizeLimit, array('jsSafe' => true)); ?> ', fileNameError: '{file}: ' + '<?php echo JText::_('COM_JOOMGALLERY_COMMON_ALERT_WRONG_FILENAME', true); ?> ', fileNameDouble: '{file}: ' + '<?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_FILENAME_DOUBLE', true); ?> ', minSizeError: '{file}: ' + '<?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_FILE_TOO_SMALL', true); ?> ' + ' {minSizeLimit}.', emptyError: '{file} : ' + '<?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_FILE_EMPTY', true); ?> ', noFilesError: '<?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_NO_FILES', true); ?> ', onLeave: '<?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_ALERT_ON_LEAVE', true); ?> ' }, debug: true, maxConnections: 1, disableCancelForFormUploads: true, callbacks: { onComplete: function(id, fileName, response) { var item = this.getItemByFileId(id); <?php if ($isMini) { if ($insertOptions) { ?> // Display options if the upload was successful and if the image is published if(response.success && !document.id('published0').checked) { displayInsertOptions(this, item, fileName, response); } <?php } else { ?> // Reload the page if published images were uploaded (so the user can see them instantly on the page) if(response.success && !document.id('published0').checked) { window.parent.SqueezeBox.addEvent('onClose', function(){window.parent.location.reload();}); } <?php } } ?> if(response.debug_output) { var element = item.getElementsByClassName("qq-upload-debug-text-selector")[0]; element.innerHTML = response.debug_output; } if(this.requestParams.hasOwnProperty("filecounter")) { this.requestParams.filecounter = this.requestParams.filecounter + 1; this.setParams(this.requestParams); } if(jQuery('#<?php echo $prefix; ?> generictitle').length > 0) { if(!jQuery('#<?php echo $prefix; ?> generictitle').prop('checked')) { jQuery('#<?php echo $prefix; ?> imgtitleid-' + id)<?php echo $isMini ? '.remove();' : ".attr('readonly', 'true');"; ?> } } <?php if ($redirect) { ?> if(response.success) { uploader.fileCount--; var redirect = '<?php echo $redirect; ?> '; if(uploader.fileCount == 0 && redirect != '') { // Redirect only if all file uploads were successful location.href = redirect; } } <?php } ?> }, onValidate: function(fileData) { if(!jg_filenamewithjs) { var searchwrongchars = /[^a-zA-Z0-9_-]/; if(searchwrongchars.test(fileData.name.substr(0, fileData.name.lastIndexOf('.')))) { this._itemError('fileNameError', fileData.name); return false; } } for (var i = 0; i < this._storedIds.length; i++) { var fileName = this.getName(this._storedIds[i]); if(fileName && fileName == fileData.name) { this._itemError('fileNameDouble', fileData.name); return false; } } }, onSubmitted: function(id, fileName) { if(jQuery('#<?php echo $prefix; ?> generictitle').length > 0) { if(!jQuery('#<?php echo $prefix; ?> generictitle').prop('checked')) { var fileItemContainer = this.getItemByFileId(id); jQuery(fileItemContainer).find('.qq-upload-cancel').after('<input id="<?php echo $prefix; ?> imgtitleid-' + id +'" class="qq-edit-imgtitle qq-editing" tabindex="0" type="text" value="" placeholder="' + '<?php echo JText::_('COM_JOOMGALLERY_COMMON_ENTER_IMAGE_TITLE', true); ?> ' + '" required aria-required="true">'); jQuery('#<?php echo $prefix; ?> imgtitleid-' + id).change(function() { if(jQuery(this).val().trim() != '') { jQuery(this).removeClass('invalid').attr('aria-invalid', 'false'); } }); } } }, onUpload: function(id, fileName) { if(jQuery('#<?php echo $prefix; ?> generictitle').length > 0) { if(!jQuery('#<?php echo $prefix; ?> generictitle').prop('checked')) { this.requestParams.imgtitle = jQuery('#<?php echo $prefix; ?> imgtitleid-' + id).val(); this.setParams(this.requestParams); } } } } }); jQuery('#triggerClearUploadList').click(function() { uploader.reset(); jQuery('#triggerClearUploadList').addClass('hidden'); }); jQuery('#triggerUpload').click(function() { Joomla.removeMessages(); if(uploader._storedIds.length == 0) { alert('<?php echo JText::_('COM_JOOMGALLERY_COMMON_ALERT_YOU_MUST_SELECT_ONE_IMAGE', true); ?> '); return false; } var form = document.getElementById('<?php echo $formId; ?> '); if(!document.formvalidator.isValid(form)) { var msg = new Array(); msg.push('<?php echo JText::_('JGLOBAL_VALIDATION_FORM_FAILED', true); ?> '); if(form.imgtitle && form.imgtitle.hasClass('invalid')) { msg.push('<?php echo JText::_("COM_JOOMGALLERY_COMMON_ALERT_IMAGE_MUST_HAVE_TITLE", true); ?> '); } if(form.catid.hasClass('invalid')) { msg.push('<?php echo JText::_("COM_JOOMGALLERY_COMMON_ALERT_YOU_MUST_SELECT_CATEGORY", true); ?> '); } alert(msg.join('\n')); return false; } <?php if ($isMini) { ?> // For new upload procedure scrolling is allowed for the first image jg_scrolled = false; <?php } ?> if(jQuery('#<?php echo $prefix; ?> generictitle').length > 0) { if(!jQuery('#<?php echo $prefix; ?> generictitle').prop('checked')) { var valid = true; for(var i = 0; i < uploader._storedIds.length; i++) { if(jQuery('#<?php echo $prefix; ?> imgtitleid-' + uploader._storedIds[i]).val().trim() == '') { valid = false; jQuery('#<?php echo $prefix; ?> imgtitleid-' + uploader._storedIds[i]).addClass('invalid').attr('aria-invalid', 'true'); } } if(!valid) { alert('<?php echo JText::_("COM_JOOMGALLERY_COMMON_ALERT_IMAGE_MUST_HAVE_TITLE", true); ?> '); return valid; } } } // Prepare request parameters uploader.requestParams = new Object(); uploader.requestParams.catid = jQuery('#<?php echo $prefix . $catidField; ?> ').val(); if(jQuery('#<?php echo $prefix; ?> imgtitle').length > 0) { if(jQuery('#<?php echo $prefix; ?> generictitle').prop('checked')) { uploader.requestParams.imgtitle = jQuery('#<?php echo $prefix; ?> imgtitle').val(); } } if(jQuery('#<?php echo $prefix; ?> filecounter').length > 0) { var filecounter = parseInt(jQuery('#<?php echo $prefix; ?> filecounter').val()); if(!isNaN(filecounter)) { uploader.requestParams.filecounter = filecounter; } } <?php if (!$isMini) { ?> uploader.requestParams.imgtext = jQuery('#<?php echo $prefix; ?> imgtext').val(); uploader.requestParams.debug = jQuery('#<?php echo $prefix; ?> debug').prop('checked') ? 1 : 0; <?php if ($app->isSite()) { ?> uploader.requestParams.published = jQuery('#<?php echo $prefix; ?> published').val(); <?php } else { ?> uploader.requestParams.published = jQuery('#<?php echo $prefix; ?> published0').prop('checked') ? 0 : 1; uploader.requestParams.imgauthor = jQuery('#<?php echo $prefix; ?> imgauthor').val(); uploader.requestParams.access = jQuery('#<?php echo $prefix; ?> access').val(); <?php } } else { ?> uploader.requestParams.published = jQuery('#<?php echo $prefix; ?> published0').prop('checked') ? 0 : 1; <?php } ?> if(jQuery('#<?php echo $prefix; ?> original_delete').length > 0) { uploader.requestParams.original_delete = jQuery('#<?php echo $prefix; ?> original_delete').prop('checked') ? 1 : 0; } uploader.requestParams.create_special_gif = jQuery('#<?php echo $prefix; ?> create_special_gif').prop('checked') ? 1 : 0; uploader.setParams(uploader.requestParams); uploader.fileCount = uploader._storedIds.length; uploader.uploadStoredFiles(); jQuery('#triggerClearUploadList').removeClass('hidden'); }); if(jQuery('#<?php echo $prefix; ?> generictitle').length > 0) { jQuery('#<?php echo $prefix; ?> generictitle').change(function() { if(jQuery(this).prop('checked')) { jQuery('#<?php echo $prefix; ?> imgtitle').addClass('required'); jQuery('#<?php echo $prefix; ?> imgtitle').attr('aria-required', 'true').attr('required', 'required'); jQuery('#<?php echo $prefix; ?> imgtitle-lbl').attr('aria-invalid', 'false'); jQuery('#<?php echo $prefix; ?> imgtitle').parent().parent().show(750); if(jQuery('#<?php echo $prefix; ?> filecounter').length > 0 ) { jQuery('#<?php echo $prefix; ?> filecounter').val('1'); jQuery('#<?php echo $prefix; ?> filecounter').parent().parent().show(750); } for(var i = 0; i < uploader._storedIds.length; i++) { jQuery('#<?php echo $prefix; ?> imgtitleid-' + uploader._storedIds[i]).remove(); } } else { jQuery('#<?php echo $prefix; ?> imgtitle').val(''); if(jQuery('#<?php echo $prefix; ?> filecounter').length > 0 ) { jQuery('#<?php echo $prefix; ?> filecounter').val(''); } jQuery('#<?php echo $prefix; ?> imgtitle').removeClass('required'); jQuery('#<?php echo $prefix; ?> imgtitle').removeAttr('aria-required').removeAttr('aria-invalid').removeAttr('required'); jQuery('#<?php echo $prefix; ?> imgtitle-lbl').removeAttr('aria-invalid'); jQuery('#<?php echo $prefix; ?> imgtitle').removeClass('invalid'); jQuery('#<?php echo $prefix; ?> imgtitle-lbl').removeClass('invalid'); jQuery('#<?php echo $prefix; ?> imgtitle').parent().parent().hide(750); if(jQuery('#<?php echo $prefix; ?> filecounter').length > 0 ) { jQuery('#<?php echo $prefix; ?> filecounter').parent().parent().hide(750); } for(var i = 0; i < uploader._storedIds.length; i++) { var fileItemContainer = uploader.getItemByFileId(uploader._storedIds[i]); jQuery(fileItemContainer).find('.qq-upload-cancel').after('<input id="<?php echo $prefix; ?> imgtitleid-' + uploader._storedIds[i] +'" class="qq-edit-imgtitle qq-editing" tabindex="0" type="text" value="" placeholder="' + '<?php echo JText::_('COM_JOOMGALLERY_COMMON_ENTER_IMAGE_TITLE', true); ?> ' + '" required aria-required="true">'); jQuery('#<?php echo $prefix; ?> imgtitleid-' + uploader._storedIds[i]).change(function() { if(jQuery(this).val().trim() != '') { jQuery(this).removeClass('invalid').attr('aria-invalid', 'false'); } }); } } }); } }); </script> <script type="text/template" id="qq-template"> <div class="qq-uploader-selector qq-uploader span12"> <div class="qq-upload-drop-area-selector qq-upload-drop-area span12" qq-hide-dropzone> <span><?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_DRAGZONETEXT', true); ?> </span> </div> <div class="qq-upload-button-selector qq-upload-button btn btn-large btn-success"> <div><i class="icon-plus icon-plus"></i> <?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_SELECT_IMAGES', true); ?> </div> </div> <div class="small"><?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_DRAGNDROPHINT'); ?> </div> <span class="qq-drop-processing-selector qq-drop-processing"> <span><?php echo JText::_('COM_JOOMGALLERY_AJAXUPLOAD_DROPPROCESSINGTEXT', true); ?> </span> <span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span> </span> <ul class="qq-upload-list-selector qq-upload-list"> <li class="alert"> <div class="qq-progress-bar-container-selector"> <div class="qq-progress-bar-selector qq-progress-bar"></div> </div> <span class="qq-upload-spinner-selector qq-upload-spinner"></span> <img class="qq-thumbnail-selector thumbnail" qq-max-size="50" qq-server-scale="<?php echo !$isMini ? 'true' : 'false'; ?> "> <?php if ($editFilename) { echo '<span class="qq-edit-filename-icon-selector qq-edit-filename-icon"></span>'; } ?> <span class="qq-upload-file-selector qq-upload-file"></span> <?php if ($editFilename) { echo '<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">'; } ?> <span class="qq-upload-size-selector qq-upload-size badge"></span> <a class="qq-upload-cancel-selector qq-upload-cancel btn btn-mini" href="#"><?php echo JText::_('COM_JOOMGALLERY_COMMON_CANCEL', true); ?> </a> <span class="qq-upload-status-text-selector qq-upload-status-text"></span> <span class="qq-upload-debug-text-selector qq-upload-debug-text"></span> <?php if ($isMini) { ?> <div class="qq-upload-options-selector qq-upload-options form-horizontal hide"></div> <div class="qq-upload-note-selector qq-upload-note hide small center"><?php echo JText::_('COM_JOOMGALLERY_MINI_AJAX_UPLOAD_NOTE', true); ?> </div> <?php } ?> </li> </ul> </div> </script> <?php $html = ob_get_contents(); ob_end_clean(); return $html; }
/** * HTML view display method * * @param string $tpl The name of the template file to parse * @return void * @since 1.5.5 */ public function display($tpl = null) { if (!$this->_config->get('jg_userspace')) { $msg = JText::_('JERROR_ALERTNOAUTHOR'); $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), $msg, 'notice'); } // Additional security check for unregistered users if (!$this->_user->get('id') && !$this->_config->get('jg_unregistered_permissions')) { $this->_mainframe->redirect(JRoute::_('index.php?view=gallery', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_LOGGED'), 'notice'); } if (!$this->_config->get('jg_disableunrequiredchecks') && !count(JoomHelper::getAuthorisedCategories('joom.upload'))) { $this->_mainframe->redirect(JRoute::_('index.php?view=userpanel', false), JText::_('COM_JOOMGALLERY_COMMON_MSG_YOU_ARE_NOT_ALLOWED_TO_UPLOAD'), 'notice'); } $params = $this->_mainframe->getParams(); // Breadcrumbs if ($this->_config->get('jg_completebreadcrumbs')) { $breadcrumbs = $this->_mainframe->getPathway(); $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL'), 'index.php?view=userpanel'); $breadcrumbs->addItem(JText::_('COM_JOOMGALLERY_COMMON_UPLOAD_NEW_IMAGE')); } // Header and footer JoomHelper::prepareParams($params); $pathway = null; if ($this->_config->get('jg_showpathway')) { $pathway = '<a href="' . JRoute::_('index.php?view=userpanel') . '">' . JText::_('COM_JOOMGALLERY_COMMON_USER_PANEL') . '</a>'; $pathway .= ' » ' . JText::_('COM_JOOMGALLERY_COMMON_UPLOAD_NEW_IMAGE'); } $backtarget = JRoute::_('index.php?view=gallery'); $backtext = JText::_('COM_JOOMGALLERY_COMMON_BACK_TO_GALLERY'); // Get number of images and hits in gallery $numbers = JoomHelper::getNumberOfImgHits(); // Load modules at position 'top' $modules['top'] = JoomHelper::getRenderedModules('top'); if (count($modules['top'])) { $params->set('show_top_modules', 1); } // Load modules at position 'btm' $modules['btm'] = JoomHelper::getRenderedModules('btm'); if (count($modules['btm'])) { $params->set('show_btm_modules', 1); } $count = $this->get('ImageNumber'); if ($count >= $this->_config->get('jg_maxuserimage')) { $timespan = $this->_config->get('jg_maxuserimage_timespan'); $msg = JText::sprintf('COM_JOOMGALLERY_UPLOAD_OUTPUT_MAY_ADD_MAX_OF', $this->_config->get('jg_maxuserimage'), $timespan > 0 ? JText::plural('COM_JOOMGALLERY_UPLOAD_NEW_IMAGE_MAXCOUNT_TIMESPAN', $timespan) : ''); $this->_mainframe->redirect(JRoute::_('index.php?view=userpanel', false), $msg, 'notice'); } $inputcounter = $this->_config->get('jg_maxuserimage') - $count; $remainder = $inputcounter; if ($inputcounter > $this->_config->get('jg_maxuploadfields')) { $inputcounter = $this->_config->get('jg_maxuploadfields'); } $this->assignRef('count', $count); $this->assignRef('remainder', $remainder); $this->assignRef('inputcounter', $inputcounter); $this->_doc->addScriptDeclaration(' var jg_inputcounter = ' . $inputcounter . ';'); $this->assignRef('params', $params); $this->assignRef('pathway', $pathway); $this->assignRef('modules', $modules); $this->assignRef('backtarget', $backtarget); $this->assignRef('backtext', $backtext); $this->assignRef('numberofpics', $numbers[0]); $this->assignRef('numberofhits', $numbers[1]); JHtml::_('behavior.formvalidation'); JHtml::_('behavior.tooltip'); $this->uploads = array(); $types = array('single', 'ajax', 'batch', 'java'); $tab = $this->_mainframe->input->get('tab'); $active_found = false; foreach ($types as $type) { if ($this->_config->get('jg_userupload' . $type)) { $this->uploads[$type] = array('title' => 'COM_JOOMGALLERY_UPLOAD_TAB_' . strtoupper($type) . '_UPLOAD', 'active' => false); if ($tab == $type) { $this->uploads[$type]['active'] = true; $active_found = true; } } } // One tab has to be active if (!$active_found && count($this->uploads)) { // Reset the array in order to be able to use the key of the first element reset($this->uploads); $this->uploads[key($this->uploads)]['active'] = true; } $this->_doc->addScriptDeclaration(' var jg_filenamewithjs = ' . ($this->_config->get('jg_filenamewithjs') ? 'true' : 'false') . ';'); $this->_doc->addScript($this->_ambit->getScript('upload.js')); JText::script('COM_JOOMGALLERY_COMMON_ALERT_IMAGE_MUST_HAVE_TITLE'); JText::script('COM_JOOMGALLERY_COMMON_ALERT_YOU_MUST_SELECT_ONE_IMAGE'); JText::script('COM_JOOMGALLERY_COMMON_ALERT_WRONG_EXTENSION'); JText::script('COM_JOOMGALLERY_COMMON_ALERT_WRONG_FILENAME'); JText::script('COM_JOOMGALLERY_UPLOAD_ALERT_FILENAME_DOUBLE_ONE'); JText::script('COM_JOOMGALLERY_UPLOAD_ALERT_FILENAME_DOUBLE_TWO'); // AJAX Drag'n'Drop Upload if ($this->_config->get('jg_useruploadajax')) { $this->_doc->addStyleSheet($this->_ambit->getScript('fineuploader/fineuploader.css')); $this->_doc->addScript($this->_ambit->getScript('fineuploader/js/fineuploader' . (JFactory::getConfig()->get('debug') ? '' : '.min') . '.js')); $this->fileSizeLimit = $this->_config->get('jg_maxfilesize'); $this->chunkSize = 0; $post_max_size = @ini_get('post_max_size'); if (!empty($post_max_size)) { $post_max_size = JoomHelper::iniToBytes($post_max_size); $this->chunkSize = (int) min(500000, (int) (0.8 * $post_max_size)); } $upload_max_filesize = @ini_get('upload_max_filesize'); if (!empty($upload_max_filesize)) { $upload_max_filesize = JoomHelper::iniToBytes($upload_max_filesize); if ($this->fileSizeLimit <= 0 || $this->fileSizeLimit > $upload_max_filesize) { $this->fileSizeLimit = $upload_max_filesize; } } $this->editFilename = $this->_config->get('jg_useruseorigfilename'); $model = $this->getModel(); $this->ajax_redirect = $model->getRedirectUrlAfterUpload('ajax'); } JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); $this->single_form = JForm::getInstance(_JOOM_OPTION . '.upload', 'upload'); $this->ajax_form = JForm::getInstance(_JOOM_OPTION . '.ajaxupload', 'ajaxupload'); $this->batch_form = JForm::getInstance(_JOOM_OPTION . '.batchupload', 'batchupload'); $this->applet_form = JForm::getInstance(_JOOM_OPTION . '.jupload', 'jupload'); $this->single_form->setFieldAttribute('arrscreenshot', 'quantity', $inputcounter); if ($this->_config->get('jg_useorigfilename')) { $this->single_form->setFieldAttribute('imgtitle', 'required', 'false'); $this->ajax_form->setFieldAttribute('imgtitle', 'required', 'false'); $this->batch_form->setFieldAttribute('imgtitle', 'required', 'false'); $this->applet_form->setFieldAttribute('imgtitle', 'required', 'false'); } if (!$this->_config->get('jg_disableunrequiredchecks')) { // Set default user upload category $defaultUserUploadCategory = $this->get('DefaultUserUploadCategory'); $this->single_form->setValue('catid', null, $defaultUserUploadCategory); $this->ajax_form->setValue('catid', null, $defaultUserUploadCategory); $this->batch_form->setValue('catid', null, $defaultUserUploadCategory); $this->applet_form->setValue('catid', null, $defaultUserUploadCategory); } parent::display($tpl); }