Пример #1
0
 /**
  * Method for uploading a file
  *
  * @since 1.5
  * @return void
  */
 function save()
 {
     $dispatcher = JDispatcher::getInstance();
     $params = JComponentHelper::getParams('com_playjoom');
     $allowableExtensions = $params->get('upload_cover_extensions', 'jpg,jpeg,png,gif');
     // Check for request forgeries
     JRequest::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
     // Get the user
     $user = JFactory::getUser();
     // Get some data from the request
     $file = JRequest::getVar('Filedata', '', 'files', 'array');
     $ArtistAlbum = JRequest::getVar('artistalbum');
     $this->folder = $this->input->get('folder', '', 'path');
     $return = null;
     $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Start uploading and save cover for: ' . $ArtistAlbum . ', file ' . $file['name'], 'priority' => JLog::INFO, 'section' => 'admin')));
     // Set the redirect
     //$this->setRedirect(JRoute::_('index.php?option=com_playjoom&view=covers'));
     $file['name'] = JFile::makeSafe($file['name']);
     if (isset($file['name'])) {
         // The request is valid
         $err = null;
         if (!PlayJoomMediaHelper::canUpload($file, $err, $allowableExtensions)) {
             // The file can't be upload
             JError::raiseNotice(100, JText::_($err));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'The file ' . $file['name'] . ' can\'t be upload. Error: ' . $err, 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         }
         //Get global tmp path
         $tmp_path = JFactory::getConfig()->get('tmp_path');
         $filepath = JPath::clean($tmp_path . '/image/' . strtolower($file['name']));
         // Trigger the onContentBeforeSave event.
         JPluginHelper::importPlugin('content');
         $object_file = new JObject($file);
         $object_file->filepath = $filepath;
         $result = $dispatcher->trigger('onContentBeforeSave', array('com_playjoom.file', &$object_file));
         if (in_array(false, $result, true)) {
             // There are some errors in the plugins
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Error occours before saving. ' . $object_file->getErrors(), 'priority' => JLog::ERROR, 'section' => 'admin')));
             JError::raiseWarning(100, JText::plural('COM_PLAYJOOM_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
             return false;
         }
         $file = (array) $object_file;
         if (JFile::exists($filepath)) {
             // File exists
             JError::raiseWarning(100, JText::_('COM_PLAYJOOM_ERROR_FILE_EXISTS'));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'File already exists. ' . $filepath, 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         } elseif (!$user->authorise('core.create', 'com_playjoom')) {
             // File does not exist and user is not authorised to create
             JError::raiseWarning(403, JText::_('COM_PLAYJOOM_ERROR_CREATE_NOT_PERMITTED'));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'The User ' . $user->get('username') . ' has not permitted to upload the file: ' . $file, 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         }
         if (!JFile::upload($file['tmp_name'], $file['filepath'])) {
             // Error in upload
             JError::raiseWarning(100, JText::_('COM_PLAYJOOM_ERROR_UNABLE_TO_UPLOAD_FILE'));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Unable to upload file: ' . $file['tmp_name'] . ' in path: ' . $file['filepath'], 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         } else {
             if (PlayJoomControllerAddCover::AddCover($file['filepath'], $ArtistAlbum)) {
                 // Trigger the onContentAfterSave event.
                 $dispatcher->trigger('onContentAfterSave', array('com_playjoom.file', &$object_file, true));
                 $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Saving cover complete. File: ' . $file['filepath'], 'priority' => JLog::INFO, 'section' => 'admin')));
                 $link = JRoute::_('index.php?option=com_playjoom&view=covers', false);
                 $msg = JText::sprintf('COM_PLAYJOOM_UPLOAD_COMPLETE', substr($file['filepath'], strlen(PLAYJOOM_BASE_PATH)));
                 $this->setRedirect($link, $msg);
                 //Delete temp cover file, after adding in database
                 unlink($file['filepath']);
                 return true;
             } else {
                 $this->setMessage(JText::sprintf('COM_PLAYJOOM_FAULTY_TOADD_DATABASE', substr($file['filepath'], strlen(PLAYJOOM_BASE_PATH))));
                 $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Not Possible to add the cover into the database', 'priority' => JLog::ERROR, 'section' => 'admin')));
                 //Delete temp cover file, after adding in database
                 unlink($file['filepath']);
             }
             return true;
         }
     } else {
         $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => JText::_('COM_PLAYJOOM_INVALID_REQUEST'), 'priority' => JLog::ERROR, 'section' => 'admin')));
         return false;
     }
 }
Пример #2
0
 /**
  * Upload a file
  *
  * @since 1.5
  */
 function upload()
 {
     $dispatcher = JDispatcher::getInstance();
     $params = JComponentHelper::getParams('com_playjoom');
     // Check for request forgeries
     if (!JSession::checkToken('request')) {
         $response = array('status' => '0', 'error' => JText::_('JINVALID_TOKEN'));
         echo json_encode($response);
         return;
     }
     // Get the user
     $user = JFactory::getUser();
     $input = JFactory::getApplication()->input;
     JLog::addLogger(array('text_file' => 'upload.error.php'), JLog::ALL, array('upload'));
     // Get some data from the request
     $file = JRequest::getVar('Filedata', '', 'files', 'array');
     $folder = JRequest::getVar('folder', '', 'path');
     $return = $input->post->get('return-url', null, 'base64');
     $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Start uploading file.json: ' . $folder . DIRECTORY_SEPARATOR . $file['name'], 'priority' => JLog::INFO, 'section' => 'admin')));
     if ($_SERVER['CONTENT_LENGTH'] > $params->get('upload_maxsize', 100) * 1024 * 1024 || $_SERVER['CONTENT_LENGTH'] > (int) ini_get('upload_max_filesize') * 1024 * 1024 || $_SERVER['CONTENT_LENGTH'] > (int) ini_get('post_max_size') * 1024 * 1024 || $_SERVER['CONTENT_LENGTH'] > (int) ini_get('memory_limit') * 1024 * 1024) {
         $response = array('status' => '0', 'error' => JText::_('COM_PLAYJOOM_ERROR_WARNFILETOOLARGE'));
         echo json_encode($response);
         return;
     }
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     // Make the filename safe
     $file['name'] = JFile::makeSafe($file['name']);
     if (isset($file['name'])) {
         // The request is valid
         $err = null;
         $filepath = JPath::clean(PLAYJOOM_BASE_PATH . '/' . $folder . '/' . strtolower($file['name']));
         $allowableExtensions = $params->get('upload_audio_extensions', 'mp3,wav,flac');
         if (!PlayJoomMediaHelper::canUpload($file, $err, $allowableExtensions)) {
             JLog::add('Invalid: ' . $filepath . ': ' . $err, JLog::INFO, 'upload');
             $response = array('status' => '0', 'error' => JText::_($err));
             echo json_encode($response);
             return;
         }
         // Trigger the onContentBeforeSave event.
         JPluginHelper::importPlugin('content');
         $dispatcher = JEventDispatcher::getInstance();
         $object_file = new JObject($file);
         $object_file->filepath = $filepath;
         $result = $dispatcher->trigger('onContentBeforeSave', array('com_playjoom.file', &$object_file));
         if (in_array(false, $result, true)) {
             // There are some errors in the plugins
             JLog::add('Errors before save: ' . $filepath . ' : ' . implode(', ', $object_file->getErrors()), JLog::INFO, 'upload');
             $response = array('status' => '0', 'error' => JText::plural('COM_PLAYJOOM_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
             echo json_encode($response);
             return;
         }
         if (JFile::exists($filepath)) {
             // File exists
             JLog::add('File exists: ' . $filepath . ' by user_id ' . $user->id, JLog::INFO, 'upload');
             $response = array('status' => '0', 'error' => JText::_('COM_PLAYJOOM_ERROR_FILE_EXISTS'));
             echo json_encode($response);
             return;
         } elseif (!$user->authorise('core.create', 'com_playjoom')) {
             // File does not exist and user is not authorised to create
             JLog::add('Create not permitted: ' . $filepath . ' by user_id ' . $user->id, JLog::INFO, 'upload');
             $response = array('status' => '0', 'error' => JText::_('COM_PLAYJOOM_ERROR_CREATE_NOT_PERMITTED'));
             echo json_encode($response);
             return;
         }
         $file = (array) $object_file;
         if (!JFile::upload($file['tmp_name'], $file['filepath'])) {
             // Error in upload
             JLog::add('Error on upload: ' . $filepath, JLog::INFO, 'upload');
             $response = array('status' => '0', 'error' => JText::_('COM_PLAYJOOM_ERROR_UNABLE_TO_UPLOAD_FILE'));
             echo json_encode($response);
             return;
         } else {
             // Trigger the onContentAfterSave event.
             $dispatcher->trigger('onContentAfterSave', array('com_playjoom.file', &$object_file, true));
             JLog::add($folder, JLog::INFO, 'upload');
             $response = array('status' => '1', 'error' => JText::sprintf('COM_PLAYJOOM_UPLOAD_COMPLETE', substr($file['filepath'], strlen(PLAYJOOM_BASE_PATH))));
             echo json_encode($response);
             return;
         }
     } else {
         $response = array('status' => '0', 'error' => JText::_('COM_PLAYJOOM_ERROR_BAD_REQUEST'));
         echo json_encode($response);
         return;
     }
 }
Пример #3
0
$coverthumb = PlayJoomMediaHelper::getCoverThumb($ImageContent, $this->_tmp_img);
?>
		<tr>
			<td>
				<?php 
echo $coverthumb;
?>
			</td>
			<td class="description">
				<?php 
echo $this->escape($this->_tmp_img->title);
?>
			</td>
			<td class="filesize">
				<?php 
echo PlayJoomMediaHelper::parseSize($this->_tmp_img->size);
?>
			</td>
		<?php 
if ($user->authorise('core.delete', 'com_playjoom')) {
    ?>
			<td>
				<a class="delete-item" target="_top" href="index.php?option=com_playjoom&amp;task=file.delete&amp;tmpl=index&amp;<?php 
    echo JSession::getFormToken();
    ?>
=1&amp;folder=<?php 
    echo rtrim(strtr(base64_encode($this->state->folder), '+/', '-_'), '=');
    ?>
&amp;rm[]=<?php 
    echo $this->_tmp_img->name;
    ?>
Пример #4
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $config = JComponentHelper::getParams('com_playjoom');
     //Get User Objects
     $user = JFactory::getUser();
     $canDo = PlayJoomHelper::getActions();
     $lang = JFactory::getLanguage();
     $style = $app->getUserStateFromRequest('media.list.layout', 'layout', 'details', 'word');
     $document = JFactory::getDocument();
     $document->setBuffer($this->loadTemplate('navigation'), 'modules', 'submenu');
     JHtml::_('behavior.framework', false);
     $document->addScript(JURI::base(true) . '/components/com_playjoom/assets/js/mediamanager.js');
     JHtml::_('stylesheet', 'media/mediamanager.css', array(), true);
     if ($lang->isRTL()) {
         JHtml::_('stylesheet', 'media/mediamanager_rtl.css', array(), true);
     }
     if ($config->get('enable_flash', 1)) {
         $fileTypes = $config->get('upload_audio_extensions', 'mp3,wav,flac');
         $types = explode(',', $fileTypes);
         $displayTypes = '';
         // this is what the user sees
         $filterTypes = '';
         // this is what controls the logic
         $firstType = true;
         foreach ($types as $type) {
             if (!$firstType) {
                 $displayTypes .= ', ';
                 $filterTypes .= '; ';
             } else {
                 $firstType = false;
             }
             $displayTypes .= '*.' . $type;
             $filterTypes .= '*.' . $type;
         }
         $typeString = '{ \'' . JText::_('COM_PLAYJOOM_FILES', 'true') . ' (' . $displayTypes . ')\': \'' . $filterTypes . '\' }';
         PlayJoomMediaHelper::AddUploaderScripts('upload-flash', array('onBeforeStart' => 'function(){ Uploader.setOptions({url: document.id(\'uploadForm\').action + \'&folder=\' + document.id(\'mediamanager-form\').folder.value}); }', 'onComplete' => 'function(){ MediaManager.refreshFrame(); }', 'targetURL' => '\\document.id(\'uploadForm\').action', 'typeFilter' => $typeString, 'fileSizeMax' => (int) ($config->get('upload_maxsize', 100) * 1024 * 1024)));
     }
     if (DIRECTORY_SEPARATOR == '\\') {
         $base = str_replace(DIRECTORY_SEPARATOR, "\\\\", PLAYJOOM_BASE_PATH);
     } else {
         $base = PLAYJOOM_BASE_PATH;
     }
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $base = null;
     }
     $js = "\n\t\t\tvar basepath = '" . $base . "';\n\t\t\tvar viewstyle = '" . $style . "';\n\t\t";
     $document->addScriptDeclaration($js);
     /*
      * Display form for FTP credentials?
      * Don't set them here, as there are other functions called before this one if there is any file write operation
      */
     $ftp = !JClientHelper::hasCredentials('ftp');
     $session = JFactory::getSession();
     $state = $this->get('state');
     $this->assignRef('session', $session);
     $this->assignRef('config', $config);
     $this->assignRef('state', $state);
     $this->assign('require_ftp', $ftp);
     //Add Toolbar and access check
     if ($canDo->get('core.edit') || $canDo->get('core.create') && !JRequest::getVar('id') || JAccess::check($user->get('id'), 'core.admin') == 1) {
         // Set the toolbar
         $this->addToolBar();
         // Display the template
         parent::display($tpl);
         echo JHtml::_('behavior.keepalive');
     } else {
         JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
     }
 }
Пример #5
0
 /**
  * Build imagelist
  *
  * @param string $listFolder The image directory to display
  * @since 1.5
  */
 function getList()
 {
     static $list;
     // Only process the list once per request
     if (is_array($list)) {
         return $list;
     }
     // Get current path from request
     $current = $this->getState('folder');
     // If undefined, set to empty
     if ($current == 'dW5kZWZpbmVk') {
         $current = '';
     }
     // Initialise variables.
     if (strlen($current) > 0) {
         if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
             $basePath = str_replace('\\/', '\\', $current);
         } else {
             $basePath = PLAYJOOM_BASE_PATH . DIRECTORY_SEPARATOR . $current;
         }
     } else {
         $basePath = PLAYJOOM_BASE_PATH;
     }
     $mediaBase = str_replace(DIRECTORY_SEPARATOR, '/', PLAYJOOM_BASE_PATH . '/');
     $images = array();
     $folders = array();
     $docs = array();
     $fileList = false;
     $folderList = false;
     if (file_exists($basePath)) {
         // Get the list of files and folders from the given folder
         $fileList = JFolder::files($basePath);
         $folderList = JFolder::folders($basePath);
     }
     // Iterate over the files if they exist
     if ($fileList !== false) {
         foreach ($fileList as $file) {
             if (is_file($basePath . '/' . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
                 $tmp = new JObject();
                 $tmp->name = $file;
                 $tmp->title = $file;
                 $tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $file));
                 $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
                 $tmp->size = filesize($tmp->path);
                 $ext = strtolower(JFile::getExt($file));
                 switch ($ext) {
                     // Image
                     case 'jpg':
                     case 'png':
                     case 'gif':
                     case 'xcf':
                     case 'odg':
                     case 'bmp':
                     case 'jpeg':
                     case 'ico':
                         $info = @getimagesize($tmp->path);
                         $tmp->width = @$info[0];
                         $tmp->height = @$info[1];
                         $tmp->type = @$info[2];
                         $tmp->mime = @$info['mime'];
                         if ($info[0] > 60 || $info[1] > 60) {
                             $dimensions = PlayJoomMediaHelper::imageResize($info[0], $info[1], 60);
                             $tmp->width_60 = $dimensions[0];
                             $tmp->height_60 = $dimensions[1];
                         } else {
                             $tmp->width_60 = $tmp->width;
                             $tmp->height_60 = $tmp->height;
                         }
                         if ($info[0] > 26 || $info[1] > 26) {
                             $dimensions = PlayJoomMediaHelper::imageResize($info[0], $info[1], 26);
                             $tmp->width_26 = $dimensions[0];
                             $tmp->height_26 = $dimensions[1];
                         } else {
                             $tmp->width_26 = $tmp->width;
                             $tmp->height_26 = $tmp->height;
                         }
                         $images[] = $tmp;
                         break;
                         // Non-image document
                     // Non-image document
                     default:
                         $tmp->icon_32 = "administrator/components/com_playjoom/images/mime-icon-32/" . $ext . ".png";
                         $tmp->icon_16 = "administrator/components/com_playjoom/images/mime-icon-16/" . $ext . ".png";
                         $docs[] = $tmp;
                         break;
                 }
             }
         }
     }
     // Iterate over the folders if they exist
     if ($folderList !== false) {
         foreach ($folderList as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $folder));
             $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
             $count = PlayJoomMediaHelper::countFiles($tmp->path);
             $tmp->files = $count[0];
             $tmp->folders = $count[1];
             $folders[] = $tmp;
         }
     }
     $list = array('folders' => $folders, 'docs' => $docs, 'images' => $images);
     return $list;
 }
Пример #6
0
 /**
  * Method for uploading a file
  *
  * @since 1.5
  * @return void
  */
 function upload()
 {
     $dispatcher = JDispatcher::getInstance();
     $params = JComponentHelper::getParams('com_playjoom');
     // Check for request forgeries
     JRequest::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
     // Get the user
     $user = JFactory::getUser();
     // Get some data from the request
     $file = JRequest::getVar('Filedata', '', 'files', 'array');
     $return = $this->input->post->get('return-url', null, 'base64');
     $this->folder = $this->input->get('folder', '', 'path');
     $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Start uploading file: ' . $this->folder . DIRECTORY_SEPARATOR . $file['name'], 'priority' => JLog::INFO, 'section' => 'admin')));
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     // Set the redirect
     if ($return) {
         $this->setRedirect(base64_decode($return) . '&view=media&folder=' . $this->folder);
     }
     // Make the filename safe
     $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Make file name safe: ' . $file['name'], 'priority' => JLog::INFO, 'section' => 'admin')));
     $file['name'] = JFile::makeSafe($file['name']);
     if (isset($file['name'])) {
         // The request is valid
         $err = null;
         $allowableExtensions = $params->get('upload_audio_extensions', 'mp3,wav,flac');
         if (!PlayJoomMediaHelper::canUpload($file, $err, $allowableExtensions)) {
             // The file can't be upload
             JError::raiseNotice(100, JText::_($err));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Can not uploading file: ' . $file['name'] . 'Error: ' . $err, 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         }
         $filepath = JPath::clean(PLAYJOOM_BASE_PATH . '/' . $this->folder . '/' . strtolower($file['name']));
         // Trigger the onContentBeforeSave event.
         JPluginHelper::importPlugin('content');
         $object_file = new JObject($file);
         $object_file->filepath = $filepath;
         $result = $dispatcher->trigger('onContentBeforeSave', array('com_playjoom.file', &$object_file));
         if (in_array(false, $result, true)) {
             // There are some errors in the plugins
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Error occours before saving. ' . $object_file->getErrors(), 'priority' => JLog::ERROR, 'section' => 'admin')));
             JError::raiseWarning(100, JText::plural('COM_PLAYJOOM_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
             return false;
         }
         $file = (array) $object_file;
         if (JFile::exists($file['filepath'])) {
             // File exists
             JError::raiseWarning(100, JText::_('COM_PLAYJOOM_ERROR_FILE_EXISTS'));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'File already exists. ' . $file['name'], 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         } elseif (!$user->authorise('core.create', 'com_playjoom')) {
             // File does not exist and user is not authorised to create
             JError::raiseWarning(403, JText::_('COM_PLAYJOOM_ERROR_CREATE_NOT_PERMITTED'));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'The User ' . $user->get('username') . ' has not permitted to upload the file: ' . $file, 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         }
         if (!JFile::upload($file['tmp_name'], $file['filepath'])) {
             // Error in upload
             JError::raiseWarning(100, JText::_('COM_PLAYJOOM_ERROR_UNABLE_TO_UPLOAD_FILE'));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Unable to upload file: ' . $file['tmp_name'] . ' in path: ' . $file['filepath'], 'priority' => JLog::ERROR, 'section' => 'admin')));
             return false;
         } else {
             // Trigger the onContentAfterSave event.
             $dispatcher->trigger('onContentAfterSave', array('com_playjoom.file', &$object_file, true));
             $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Upload complete. Temp filename: ' . $file['tmp_name'] . ', filepath: ' . $file['filepath'], 'priority' => JLog::INFO, 'section' => 'admin')));
             $this->setMessage(JText::sprintf('COM_PLAYJOOM_UPLOAD_COMPLETE', substr($file['filepath'], strlen(PLAYJOOM_BASE_PATH))));
             return true;
         }
     } else {
         $this->setRedirect('index.php', JText::_('COM_PLAYJOOM_INVALID_REQUEST'), 'error');
         return false;
     }
 }
Пример #7
0
    /**
     * Add unobtrusive javascript support for the advanced uploader.
     *
     * @param   string  $id            An index.
     * @param   array   $params        An array of options for the uploader.
     * @param   string  $upload_queue  The HTML id of the upload queue element (??).
     *
     * @return  void
     *
     * @since   11.1
     */
    public static function AddUploaderScripts($id = 'file-upload', $params = array(), $upload_queue = 'upload-queue')
    {
        // Include MooTools framework
        self::framework();
        JHtml::_('script', 'administrator/components/com_playjoom/assets/js/swf.js', true, false);
        JHtml::_('script', 'administrator/components/com_playjoom/assets/js/progressbar.js', true, false);
        JHtml::_('script', 'administrator/components/com_playjoom/assets/js/uploader.js', true, false);
        $document = JFactory::getDocument();
        if (!isset(self::$loaded[__METHOD__])) {
            JText::script('COM_PLAYJOOM_UPLOADER_FILENAME');
            JText::script('COM_PLAYJOOM_UPLOADER_UPLOAD_COMPLETED');
            JText::script('COM_PLAYJOOM_UPLOADER_ERROR_OCCURRED');
            JText::script('COM_PLAYJOOM_UPLOADER_ALL_FILES');
            JText::script('COM_PLAYJOOM_UPLOADER_PROGRESS_OVERALL');
            JText::script('COM_PLAYJOOM_UPLOADER_CURRENT_TITLE');
            JText::script('COM_PLAYJOOM_UPLOADER_REMOVE');
            JText::script('COM_PLAYJOOM_UPLOADER_REMOVE_TITLE');
            JText::script('COM_PLAYJOOM_UPLOADER_CURRENT_FILE');
            JText::script('COM_PLAYJOOM_UPLOADER_CURRENT_PROGRESS');
            JText::script('COM_PLAYJOOM_UPLOADER_FILE_ERROR');
            JText::script('COM_PLAYJOOM_UPLOADER_FILE_SUCCESSFULLY_UPLOADED');
            JText::script('COM_PLAYJOOM_UPLOADER_VALIDATION_ERROR_DUPLICATE');
            JText::script('COM_PLAYJOOM_UPLOADER_VALIDATION_ERROR_SIZELIMITMIN');
            JText::script('COM_PLAYJOOM_UPLOADER_VALIDATION_ERROR_SIZELIMITMAX');
            JText::script('COM_PLAYJOOM_UPLOADER_VALIDATION_ERROR_FILELISTMAX');
            JText::script('COM_PLAYJOOM_UPLOADER_VALIDATION_ERROR_FILELISTSIZEMAX');
            JText::script('COM_PLAYJOOM_UPLOADER_ERROR_HTTPSTATUS');
            JText::script('COM_PLAYJOOM_UPLOADER_ERROR_SECURITYERROR');
            JText::script('COM_PLAYJOOM_UPLOADER_ERROR_IOERROR');
            JText::script('COM_PLAYJOOM_UPLOADER_ALL_FILES');
        }
        if (isset(self::$loaded[__METHOD__][$id])) {
            return;
        }
        $onFileSuccess = '\\function(file, response) {
			var json = new Hash(JSON.decode(response, true) || {});
	
			if (json.get(\'status\') == \'1\') {
				file.element.addClass(\'file-success\');
				file.info.set(\'html\', \'<strong>\' + Joomla.JText._(\'COM_PLAYJOOM_UPLOADER_FILE_SUCCESSFULLY_UPLOADED\') + \'</strong>\');
			} else {
				file.element.addClass(\'file-failed\');
				file.info.set(\'html\', \'<strong>\' +
					Joomla.JText._(\'COM_PLAYJOOM_UPLOADER_ERROR_OCCURRED\',
						\'An Error Occurred\').substitute({ error: json.get(\'error\') }) + \'</strong>\');
			}
		}';
        // Setup options object
        $opt['verbose'] = true;
        $opt['url'] = isset($params['targetURL']) ? $params['targetURL'] : null;
        $opt['path'] = isset($params['swf']) ? $params['swf'] : JURI::root(true) . '/administrator/components/com_playjoom/assets/swf/uploader.swf';
        $opt['height'] = isset($params['height']) && $params['height'] ? (int) $params['height'] : null;
        $opt['width'] = isset($params['width']) && $params['width'] ? (int) $params['width'] : null;
        $opt['multiple'] = isset($params['multiple']) && !$params['multiple'] ? false : true;
        $opt['queued'] = isset($params['queued']) && !$params['queued'] ? (int) $params['queued'] : null;
        $opt['target'] = isset($params['target']) ? $params['target'] : '\\document.id(\'upload-browse\')';
        $opt['instantStart'] = isset($params['instantStart']) && $params['instantStart'] ? true : false;
        $opt['allowDuplicates'] = isset($params['allowDuplicates']) && !$params['allowDuplicates'] ? false : true;
        // limitSize is the old parameter name.  Remove in 1.7
        $opt['fileSizeMax'] = isset($params['limitSize']) && $params['limitSize'] ? (int) $params['limitSize'] : null;
        // fileSizeMax is the new name.  If supplied, it will override the old value specified for limitSize
        $opt['fileSizeMax'] = isset($params['fileSizeMax']) && $params['fileSizeMax'] ? (int) $params['fileSizeMax'] : $opt['fileSizeMax'];
        $opt['fileSizeMin'] = isset($params['fileSizeMin']) && $params['fileSizeMin'] ? (int) $params['fileSizeMin'] : null;
        // limitFiles is the old parameter name.  Remove in 1.7
        $opt['fileListMax'] = isset($params['limitFiles']) && $params['limitFiles'] ? (int) $params['limitFiles'] : null;
        // fileListMax is the new name.  If supplied, it will override the old value specified for limitFiles
        $opt['fileListMax'] = isset($params['fileListMax']) && $params['fileListMax'] ? (int) $params['fileListMax'] : $opt['fileListMax'];
        $opt['fileListSizeMax'] = isset($params['fileListSizeMax']) && $params['fileListSizeMax'] ? (int) $params['fileListSizeMax'] : null;
        // types is the old parameter name.  Remove in 1.7
        $opt['typeFilter'] = isset($params['types']) ? '\\' . $params['types'] : '\\{Joomla.JText._(\'JLIB_HTML_BEHAVIOR_UPLOADER_ALL_FILES\'): \'*.*\'}';
        $opt['typeFilter'] = isset($params['typeFilter']) ? '\\' . $params['typeFilter'] : $opt['typeFilter'];
        // Optional functions
        $opt['createReplacement'] = isset($params['createReplacement']) ? '\\' . $params['createReplacement'] : null;
        $opt['onFileComplete'] = isset($params['onFileComplete']) ? '\\' . $params['onFileComplete'] : null;
        $opt['onBeforeStart'] = isset($params['onBeforeStart']) ? '\\' . $params['onBeforeStart'] : null;
        $opt['onStart'] = isset($params['onStart']) ? '\\' . $params['onStart'] : null;
        $opt['onComplete'] = isset($params['onComplete']) ? '\\' . $params['onComplete'] : null;
        $opt['onFileSuccess'] = isset($params['onFileSuccess']) ? '\\' . $params['onFileSuccess'] : $onFileSuccess;
        if (!isset($params['startButton'])) {
            $params['startButton'] = 'upload-start';
        }
        if (!isset($params['clearButton'])) {
            $params['clearButton'] = 'upload-clear';
        }
        $opt['onLoad'] = '\\function() {
				document.id(\'' . $id . '\').removeClass(\'hide\'); // we show the actual UI
				document.id(\'upload-noflash\').destroy(); // ... and hide the plain form
	
				// We relay the interactions with the overlayed flash to the link
				this.target.addEvents({
					click: function() {
						return false;
					},
					mouseenter: function() {
						this.addClass(\'hover\');
					},
					mouseleave: function() {
						this.removeClass(\'hover\');
						this.blur();
					},
					mousedown: function() {
						this.focus();
					}
				});
	
				// Interactions for the 2 other buttons
	
				document.id(\'' . $params['clearButton'] . '\').addEvent(\'click\', function() {
					Uploader.remove(); // remove all files
					return false;
				});
	
				document.id(\'' . $params['startButton'] . '\').addEvent(\'click\', function() {
					Uploader.start(); // start upload
					return false;
				});
			}';
        $options = PlayJoomMediaHelper::getJSObject($opt);
        //$options = JHtml::getJSObject($opt);
        // Attach tooltips to document
        $uploaderInit = 'window.addEvent(\'domready\', function(){
				var Uploader = new FancyUpload2(document.id(\'' . $id . '\'), document.id(\'' . $upload_queue . '\'), ' . $options . ' );
				});';
        $document->addScriptDeclaration($uploaderInit);
        // Set static array
        self::$loaded[__METHOD__][$id] = true;
        return;
    }
Пример #8
0
 * @copyright Copyright (C) 2010-2012 by www.teglo.info. All rights reserved.
 * @license	GNU/GPL, see LICENSE.php
 * @PlayJoom Component
 * @date $Date$
 * @revision $Revision$
 * @author $Author$
 * @headurl $HeadURL$
 */
// No direct access.
defined('_JEXEC') or die;
$user = JFactory::getUser();
$params = new JRegistry();
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onContentBeforeDisplay', array('com_playjoom.file', &$this->_tmp_img, &$params));
$ImageContent = file_get_contents($this->_tmp_img->path);
$coverthumb = PlayJoomMediaHelper::getCoverThumb($ImageContent, $this->_tmp_img);
?>
		<div class="imgOutline">
			<div class="imgTotal">
				<div class="imgBorder center">
					<?php 
echo $coverthumb;
?>
				</div>
			</div>
			<div class="controls">
			<?php 
if ($user->authorise('core.delete', 'com_playjoom')) {
    ?>
				<a class="delete-item" target="_top" href="index.php?option=com_playjoom&amp;task=file.delete&amp;tmpl=index&amp;<?php 
    echo JSession::getFormToken();