コード例 #1
0
ファイル: category.php プロジェクト: scarsroga/blog-soa
 function multipleupload()
 {
     JResponse::allowCache(false);
     // Chunk Files
     header('Content-type: text/plain; charset=UTF-8');
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     // Invalid Token
     JRequest::checkToken('request') or jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 100, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_INVALID_TOKEN'))));
     jimport('joomla.client.helper');
     $app = JFactory::getApplication();
     $ftp = JClientHelper::setCredentialsFromRequest('ftp');
     $user = JFactory::getUser();
     $path = PhocaGalleryPath::getPath();
     $return = $this->input->get('return-url', null, 'base64');
     $format = $this->input->get('format', 'html', 'cmd');
     $viewBack = $this->input->get('viewback', '', 'string');
     $tab = $this->input->get('tab', 0, 'int');
     $catid = $this->input->get('id', '', 'string');
     $rating = $this->input->get('rating', '', 'string');
     $Itemid = $this->input->get('Itemid', 0, 'int');
     $limitStart = $this->input->get('limitstart', 0, 'int');
     $paramsC = JComponentHelper::getParams('com_phocagallery');
     $model = $this->getModel('category');
     $catid = (int) $catid;
     // USER RIGHT - UPLOAD - - - - - - - - - - -
     // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
     $rightDisplayUpload = 0;
     $catAccess = PhocaGalleryAccess::getCategoryAccess((int) $catid);
     if (!empty($catAccess)) {
         $rightDisplayUpload = PhocaGalleryAccess::getUserRight('uploaduserid', $catAccess->uploaduserid, 2, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     // USER RIGHT - FOLDER - - - - - - - - - - - -
     $rightFolder = '';
     if (isset($catAccess->userfolder)) {
         $rightFolder = $catAccess->userfolder;
     }
     // - - - - - - - - - - - - - - - - - - - - - -
     if ($rightDisplayUpload == 1) {
         if ($rightFolder == '') {
             jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_DEFINED'))));
             return false;
         }
         if (!JFolder::exists($path->image_abs . $rightFolder . DS)) {
             jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_USER_FOLDER_NOT_EXISTS'))));
             return false;
         }
         // Check the size of all images by users
         /*	$maxUserImageSize 	= (int)$paramsC->get( 'user_images_max_size', 20971520 );
         			$allFileSize		= PhocaGalleryFileUploadFront::getSizeAllOriginalImages($file, $this->_user->id);
         
         			if ($maxUserImageSize > 0 && (int) $allFileSize > $maxUserImageSize) {
         				$errUploadMsg = JText::_('COM_PHOCAGALLERY_WARNING_USERIMAGES_TOOLARGE');	
         				$app->redirect($redirectUrl, $errUploadMsg);
         				return false;
         			}*/
         // Sending and setting data for common realsingleupload function
         $this->input->set('folder', $rightFolder);
         //Set the right path for uploaded image (category folder included)
         $this->input->set('return-url', base64_encode($return));
         // set return url
         $fileName = PhocaGalleryFileUpload::realMultipleUpload(1);
         if ($fileName != '') {
             // Saving file name into database with relative path
             $fileName = $rightFolder . '/' . strtolower($fileName);
             if (PhocaGalleryControllerCategory::save((int) $catid, $fileName, false, $succeeded, $errUploadMsg, false)) {
                 jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'OK', 'code' => 200, 'message' => JText::_('COM_PHOCAGALERY_SUCCESS') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_IMAGES_UPLOADED'))));
                 return true;
             } else {
                 jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'))));
                 return false;
             }
         }
     } else {
         jexit(json_encode(array('jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCAGALLERY_ERROR') . ': ', 'details' => JTEXT::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'))));
         return false;
     }
 }
コード例 #2
0
 function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $document =& JFactory::getDocument();
     $uri =& JFactory::getURI();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     $this->params =& $app->getParams();
     $user =& JFactory::getUser();
     $path = PhocaGalleryPath::getPath();
     $this->itemId = $app->input->get('Itemid', 0, 'int');
     $neededAccessLevels = PhocaGalleryAccess::getNeededAccessLevels();
     $access = PhocaGalleryAccess::isAccess($user->getAuthorisedViewLevels(), $neededAccessLevels);
     $this->tmpl['pi'] = 'media/com_phocagallery/images/';
     $this->tmpl['pp'] = 'index.php?option=com_phocagallery&view=user&controller=user';
     $this->tmpl['pl'] = 'index.php?option=com_users&view=login&return=' . base64_encode($this->tmpl['pp'] . '&Itemid=' . $this->itemId);
     // LIBRARY
     $library =& PhocaGalleryLibrary::getLibrary();
     //$libraries['pg-css-ie'] 			= $library->getLibrary('pg-css-ie');
     // Only registered users
     if (!$access) {
         $app->redirect(JRoute::_($this->tmpl['pl'], false), JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
         exit;
     }
     $this->tmpl['gallerymetakey'] = $this->params->get('gallery_metakey', '');
     $this->tmpl['gallerymetadesc'] = $this->params->get('gallery_metadesc', '');
     if ($this->tmpl['gallerymetakey'] != '') {
         $document->setMetaData('keywords', $this->tmpl['gallerymetakey']);
     }
     if ($this->tmpl['gallerymetadesc'] != '') {
         $document->setMetaData('description', $this->tmpl['gallerymetadesc']);
     }
     PhocaGalleryRenderFront::renderAllCSS();
     // = = = = = = = = = = =
     // PANE
     // = = = = = = = = = = =
     // - - - - - - - - - -
     // ALL TABS
     // - - - - - - - - - -
     // UCP is disabled (security reasons)
     if ((int) $this->params->get('enable_user_cp', 0) == 0) {
         $app->redirect(JURI::base(true), JText::_('COM_PHOCAGALLERY_UCP_DISABLED'));
         exit;
     }
     $this->tmpl['tab'] = $app->input->get('tab', 0, 'string');
     $this->tmpl['maxuploadchar'] = $this->params->get('max_upload_char', 1000);
     $this->tmpl['maxcreatecatchar'] = $this->params->get('max_create_cat_char', 1000);
     $this->tmpl['dp'] = PhocaGalleryRenderInfo::getPhocaIc((int) $this->params->get('display_phoca_info', 1));
     $this->tmpl['showpageheading'] = $this->params->get('show_page_heading', 1);
     $this->tmpl['javaboxwidth'] = $this->params->get('java_box_width', 480);
     $this->tmpl['javaboxheight'] = $this->params->get('java_box_height', 480);
     $this->tmpl['enableuploadavatar'] = $this->params->get('enable_upload_avatar', 1);
     $this->tmpl['uploadmaxsize'] = $this->params->get('upload_maxsize', 3145728);
     $this->tmpl['uploadmaxsizeread'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['uploadmaxsize']);
     $this->tmpl['uploadmaxreswidth'] = $this->params->get('upload_maxres_width', 3072);
     $this->tmpl['uploadmaxresheight'] = $this->params->get('upload_maxres_height', 2304);
     $this->tmpl['multipleuploadchunk'] = $this->params->get('multiple_upload_chunk', 0);
     $this->tmpl['displaytitleupload'] = $this->params->get('display_title_upload', 0);
     $this->tmpl['displaydescupload'] = $this->params->get('display_description_upload', 0);
     $this->tmpl['enablejava'] = $this->params->get('enable_java', -1);
     $this->tmpl['enablemultiple'] = $this->params->get('enable_multiple', 0);
     $this->tmpl['ytbupload'] = $this->params->get('youtube_upload', 0);
     $this->tmpl['multipleuploadmethod'] = $this->params->get('multiple_upload_method', 1);
     $this->tmpl['multipleresizewidth'] = $this->params->get('multiple_resize_width', -1);
     $this->tmpl['multipleresizeheight'] = $this->params->get('multiple_resize_height', -1);
     $this->tmpl['usersubcatcount'] = $this->params->get('user_subcat_count', 5);
     $this->tmpl['userimagesmaxspace'] = $this->params->get('user_images_max_size', 20971520);
     $this->tmpl['iepx'] = '<div style="font-size:1px;height:1px;margin:0px;padding:0px;">&nbsp;</div>';
     //Subcateogry
     $this->tmpl['parentid'] = $app->input->get('parentcategoryid', 0, 'int');
     $document->addScript(JURI::base(true) . '/media/com_phocagallery/js/comments.js');
     $document->addCustomTag(PhocaGalleryRenderFront::renderOnUploadJS());
     $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionCreateCatJS((int) $this->tmpl['maxcreatecatchar']));
     $document->addCustomTag(PhocaGalleryRenderFront::userTabOrdering());
     // SubCategory + Image
     $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionCreateSubCatJS((int) $this->tmpl['maxcreatecatchar']));
     $document->addCustomTag(PhocaGalleryRenderFront::saveOrderUserJS());
     $model = $this->getModel('user');
     $ownerMainCategory = $model->getOwnerMainCategory($user->id);
     $this->tmpl['usertab'] = 1;
     $this->tmpl['createcategory'] = 1;
     $this->tmpl['createsubcategory'] = 1;
     $this->tmpl['images'] = 1;
     $this->tmpl['displayupload'] = 1;
     // Tabs
     $displayTabs = 0;
     if ((int) $this->tmpl['usertab'] == 0) {
         $currentTab['user'] = -1;
     } else {
         $currentTab['user'] = $displayTabs;
         $displayTabs++;
     }
     if ((int) $this->tmpl['createcategory'] == 0) {
         $currentTab['createcategory'] = -1;
     } else {
         $currentTab['createcategory'] = $displayTabs;
         $displayTabs++;
     }
     if ((int) $this->tmpl['createsubcategory'] == 0) {
         $currentTab['createsubcategory'] = -1;
     } else {
         $currentTab['createsubcategory'] = $displayTabs;
         $displayTabs++;
     }
     if ((int) $this->tmpl['displayupload'] == 0) {
         $currentTab['images'] = -1;
     } else {
         $currentTab['images'] = $displayTabs;
         $displayTabs++;
     }
     $this->tmpl['displaytabs'] = $displayTabs;
     $this->tmpl['currenttab'] = $currentTab;
     // ACTION
     $this->tmpl['action'] = $uri->toString();
     $this->tmpl['ftp'] = !JClientHelper::hasCredentials('ftp');
     $this->assignRef('session', JFactory::getSession());
     // SEF problem
     $isThereQM = false;
     $isThereQM = preg_match("/\\?/i", $this->tmpl['action']);
     if ($isThereQM) {
         $amp = '&';
         // will be translated to htmlspecialchars
     } else {
         $amp = '?';
     }
     $this->tmpl['actionamp'] = $this->tmpl['action'] . $amp;
     $this->tmpl['istheretab'] = false;
     $this->tmpl['istheretab'] = preg_match("/tab=/i", $this->tmpl['action']);
     // EDIT - subcategory, image
     $this->tmpl['task'] = $app->input->get('task', '', 'string');
     $id = $app->input->get('id', '', 'string');
     $idAlias = $id;
     // - - - - - - - - - - -
     // USER (AVATAR)
     // - - - - - - - - - - -
     $this->tmpl['user'] = $user->name;
     $this->tmpl['username'] = $user->username;
     $this->tmpl['useravatarimg'] = JHtml::_('image', $this->tmpl['pi'] . 'phoca_thumb_m_no_image.png', '');
     $this->tmpl['useravatarapproved'] = 0;
     $userAvatar = $model->getUserAvatar($user->id);
     if ($userAvatar) {
         $pathAvatarAbs = $path->avatar_abs . 'thumbs' . DS . 'phoca_thumb_m_' . $userAvatar->avatar;
         $pathAvatarRel = $path->avatar_rel . 'thumbs/phoca_thumb_m_' . $userAvatar->avatar;
         if (JFile::exists($pathAvatarAbs)) {
             $this->tmpl['useravatarimg'] = '<img src="' . JURI::base(true) . '/' . $pathAvatarRel . '?imagesid=' . md5(uniqid(time())) . '" alt="" />';
             $this->tmpl['useravatarapproved'] = $userAvatar->approved;
         }
     }
     if ($ownerMainCategory) {
         $this->tmpl['usermaincategory'] = $ownerMainCategory->title;
     } else {
         $this->tmpl['usermaincategory'] = JHtml::_('image', $this->tmpl['pi'] . 'icon-unpublish.png', JText::_('COM_PHOCAGALLERY_NOT_CREATED')) . ' (' . JText::_('COM_PHOCAGALLERY_NOT_CREATED') . ')';
     }
     $this->tmpl['usersubcategory'] = $model->getCountUserSubCat($user->id);
     $this->tmpl['usersubcategoryleft'] = (int) $this->tmpl['usersubcatcount'] - (int) $this->tmpl['usersubcategory'];
     if ((int) $this->tmpl['usersubcategoryleft'] < 0) {
         $this->tmpl['usersubcategoryleft'] = 0;
     }
     $this->tmpl['userimages'] = $model->getCountUserImage($user->id);
     $this->tmpl['userimagesspace'] = $model->getSumUserImage($user->id);
     $this->tmpl['userimagesspaceleft'] = (int) $this->tmpl['userimagesmaxspace'] - (int) $this->tmpl['userimagesspace'];
     if ((int) $this->tmpl['userimagesspaceleft'] < 0) {
         $this->tmpl['userimagesspaceleft'] = 0;
     }
     $this->tmpl['userimagesspace'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['userimagesspace']);
     $this->tmpl['userimagesspaceleft'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['userimagesspaceleft']);
     $this->tmpl['userimagesmaxspace'] = PhocaGalleryFile::getFileSizeReadable($this->tmpl['userimagesmaxspace']);
     // - - - - - - - - - - -
     // MAIN CATEGORY
     // - - - - - - - - - - -
     $ownerMainCategory = $model->getOwnerMainCategory($user->id);
     if (!empty($ownerMainCategory->id)) {
         if ((int) $ownerMainCategory->published == 1) {
             $this->tmpl['categorycreateoredithead'] = JText::_('COM_PHOCAGALLERY_MAIN_CATEGORY');
             $this->tmpl['categorycreateoredit'] = JText::_('COM_PHOCAGALLERY_EDIT');
             $this->tmpl['categorytitle'] = $ownerMainCategory->title;
             $this->tmpl['categoryapproved'] = $ownerMainCategory->approved;
             $this->tmpl['categorydescription'] = $ownerMainCategory->description;
             $this->tmpl['categorypublished'] = 1;
         } else {
             $this->tmpl['categorypublished'] = 0;
         }
     } else {
         $this->tmpl['categorycreateoredithead'] = JText::_('COM_PHOCAGALLERY_MAIN_CATEGORY');
         $this->tmpl['categorycreateoredit'] = JText::_('COM_PHOCAGALLERY_CREATE');
         $this->tmpl['categorytitle'] = '';
         $this->tmpl['categorydescription'] = '';
         $this->tmpl['categoryapproved'] = '';
         $this->tmpl['categorypublished'] = -1;
     }
     // - - - - - - - - - - -
     // SUBCATEGORY
     // - - - - - - - - - - -
     if (!empty($ownerMainCategory->id)) {
         // EDIT
         $this->tmpl['categorysubcatedit'] = $model->getCategory((int) $id, $user->id);
         $this->tmpl['displaysubcategory'] = 1;
         // Get All Data - Subcategories
         $this->tmpl['subcategoryitems'] = $model->getDataSubcat($user->id);
         $this->tmpl['subcategorytotal'] = count($this->tmpl['subcategoryitems']);
         $model->setTotalSubCat($this->tmpl['subcategorytotal']);
         $this->tmpl['subcategorypagination'] = $model->getPaginationSubCat($user->id);
         $this->tmpl['subcategoryitems'] = array_slice($this->tmpl['subcategoryitems'], (int) $this->tmpl['subcategorypagination']->limitstart, (int) $this->tmpl['subcategorypagination']->limit);
         $filter_state_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_state', 'filter_state_subcat', '', 'word');
         $filter_catid_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_catid', 'filter_catid_subcat', 0, 'int');
         $filter_order_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_order', 'filter_order_subcat', 'a.ordering', 'cmd');
         $filter_order_Dir_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.filter_order_Dir', 'filter_order_Dir_subcat', '', 'word');
         $search_subcat = $app->getUserStateFromRequest($this->_context_subcat . '.search', 'phocagallerysubcatsearch', '', 'string');
         if (strpos($search_subcat, '"') !== false) {
             $search_subcat = str_replace(array('=', '<'), '', $search_subcat);
         }
         $search_subcat = JString::strtolower($search_subcat);
         $categories = $model->getCategoryList($user->id);
         if (!empty($categories)) {
             $javascript = 'class="inputbox" onchange="document.phocagallerysubcatform.submit();"';
             $tree = array();
             $text = '';
             $tree = PhocaGalleryCategory::CategoryTreeOption($categories, $tree, 0, $text, -1);
             array_unshift($tree, JHtml::_('select.option', '0', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_CATEGORY') . ' -', 'value', 'text'));
             $lists_subcat['catid'] = JHtml::_('select.genericlist', $tree, 'filter_catid_subcat', $javascript, 'value', 'text', $filter_catid_subcat);
         }
         $this->tmpl['parentcategoryid'] = $filter_catid_subcat;
         // state filter
         //$lists['state']		= JHtml::_('grid.state',  $filter_state );
         $state_subcat[] = JHtml::_('select.option', '', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_STATE') . ' -');
         $state_subcat[] = JHtml::_('select.option', 'P', JText::_('COM_PHOCAGALLERY_PUBLISHED'));
         $state_subcat[] = JHtml::_('select.option', 'U', JText::_('COM_PHOCAGALLERY_UNPUBLISHED'));
         $lists_subcat['state'] = JHtml::_('select.genericlist', $state_subcat, 'filter_state_subcat', 'class="inputbox" size="1" onchange="document.phocagallerysubcatform.submit();"', 'value', 'text', $filter_state_subcat);
         // table ordering
         $lists_subcat['order_Dir'] = $filter_order_Dir_subcat;
         $lists_subcat['order'] = $filter_order_subcat;
         $this->tmpl['subcategoryordering'] = $lists_subcat['order'] == 'a.ordering';
         //Ordering allowed ?
         // search filter
         $lists_subcat['search'] = $search_subcat;
     } else {
         $this->tmpl['displaysubcategory'] = 0;
     }
     // - - - - - - - - - - -
     // IMAGES
     // - - - - - - - - - - -
     if (!empty($ownerMainCategory->id)) {
         $catAccess = PhocaGalleryAccess::getCategoryAccess((int) $ownerMainCategory->id);
         // EDIT
         $this->tmpl['imageedit'] = $model->getImage((int) $id, $user->id);
         $this->tmpl['imageitems'] = $model->getDataImage($user->id);
         $this->tmpl['imagetotal'] = $model->getTotalImage($user->id);
         $this->tmpl['imagepagination'] = $model->getPaginationImage($user->id);
         $filter_state_image = $app->getUserStateFromRequest($this->_context_image . '.filter_state', 'filter_state_image', '', 'word');
         $filter_catid_image = $app->getUserStateFromRequest($this->_context_image . '.filter_catid', 'filter_catid_image', 0, 'int');
         $filter_order_image = $app->getUserStateFromRequest($this->_context_image . '.filter_order', 'filter_order_image', 'a.ordering', 'cmd');
         $filter_order_Dir_image = $app->getUserStateFromRequest($this->_context_image . '.filter_order_Dir', 'filter_order_Dir_image', '', 'word');
         $search_image = $app->getUserStateFromRequest($this->_context_image . '.search', 'phocagalleryimagesearch', '', 'string');
         if (strpos($search_image, '"') !== false) {
             $search_image = str_replace(array('=', '<'), '', $search_image);
         }
         $search_image = JString::strtolower($search_image);
         $categoriesImage = $model->getCategoryList($user->id);
         if (!empty($categoriesImage)) {
             $javascript = 'class="inputbox" size="1" onchange="document.phocagalleryimageform.submit();"';
             $tree = array();
             $text = '';
             $tree = PhocaGalleryCategory::CategoryTreeOption($categoriesImage, $tree, 0, $text, -1);
             array_unshift($tree, JHtml::_('select.option', '0', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_CATEGORY') . ' -', 'value', 'text'));
             $lists_image['catid'] = JHtml::_('select.genericlist', $tree, 'filter_catid_image', $javascript, 'value', 'text', $filter_catid_image);
         }
         // state filter
         $state_image[] = JHtml::_('select.option', '', '- ' . JText::_('COM_PHOCAGALLERY_SELECT_STATE') . ' -');
         $state_image[] = JHtml::_('select.option', 'P', JText::_('COM_PHOCAGALLERY_FIELD_PUBLISHED_LABEL'));
         $state_image[] = JHtml::_('select.option', 'U', JText::_('COM_PHOCAGALLERY_FIELD_UNPUBLISHED_LABEL'));
         $lists_image['state'] = JHtml::_('select.genericlist', $state_image, 'filter_state_image', 'class="inputbox" size="1" onchange="document.phocagalleryimageform.submit();"', 'value', 'text', $filter_state_image);
         // table ordering
         $lists_image['order_Dir'] = $filter_order_Dir_image;
         $lists_image['order'] = $filter_order_image;
         $this->tmpl['imageordering'] = $lists_image['order'] == 'a.ordering';
         //Ordering allowed ?
         // search filter
         $lists_image['search'] = $search_image;
         $this->tmpl['catidimage'] = $filter_catid_image;
         // Upload
         $this->tmpl['displayupload'] = 0;
         // USER RIGHT - UPLOAD - - - - - - - - - - -
         // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
         $rightDisplayUpload = 0;
         // default is to null (all users cannot upload)
         if (!empty($catAccess)) {
             $rightDisplayUpload = PhocaGalleryAccess::getUserRight('uploaduserid', $catAccess->uploaduserid, 2, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
         }
         if ($rightDisplayUpload == 1) {
             $this->tmpl['displayupload'] = 1;
             $document->addCustomTag(PhocaGalleryRenderFront::renderDescriptionUploadJS((int) $this->tmpl['maxuploadchar']));
         }
         // - - - - - - - - - - - - - - - - - - - - -
         // USER RIGHT - ACCESS - - - - - - - - - - -
         $rightDisplay = 1;
         //default is set to 1 (all users can see the category)
         if (!empty($catAccess)) {
             $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $catAccess->accessuserid, 0, $user->getAuthorisedViewLevels(), $user->get('id', 0), 1);
         }
         if ($rightDisplay == 0) {
             $app->redirect(JRoute::_($this->tmpl['pl'], false), JText::_('COM_PHOCAGALLERY_NOT_AUTHORISED_ACTION'));
             exit;
         }
         // - - - - - - - - - - - - - - - - - - - - -
         // = = = = = = = = = =
         // U P L O A D
         // = = = = = = = = = =
         // - - - - - - - - - - -
         // Upload
         // - - - - - - - - - - -
         if ((int) $this->tmpl['displayupload'] == 1) {
             $sU = new PhocaGalleryFileUploadSingle();
             $sU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . 'task=upload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
             $sU->tab = $this->tmpl['currenttab']['images'];
             $this->tmpl['su_output'] = $sU->getSingleUploadHTML(1);
             $this->tmpl['su_url'] = htmlspecialchars($this->tmpl['action'] . $amp . 'task=upload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
         }
         // - - - - - - - - - - -
         // Youtube Upload (single upload form can be used)
         // - - - - - - - - - - -
         if ((int) $this->tmpl['ytbupload'] > 0) {
             $sYU = new PhocaGalleryFileUploadSingle();
             $sYU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . 'task=ytbupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
             $sYU->tab = $this->tmpl['currenttab']['images'];
             $this->tmpl['syu_output'] = $sYU->getSingleUploadHTML(1);
             $this->tmpl['syu_url'] = htmlspecialchars($this->tmpl['action'] . $amp . 'task=ytbupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&viewback=category&tab=' . $this->tmpl['currenttab']['images']);
         }
         // - - - - - - - - - - -
         // Multiple Upload
         // - - - - - - - - - - -
         // Get infos from multiple upload
         $muFailed = $app->input->get('mufailed', '0', 'int');
         $muUploaded = $app->input->get('muuploaded', '0', 'int');
         $this->tmpl['mu_response_msg'] = $muUploadedMsg = '';
         if ($muUploaded > 0) {
             $muUploadedMsg = JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded;
         }
         if ($muFailed > 0) {
             $muFailedMsg = JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed;
         }
         if ($muFailed > 0 && $muUploaded > 0) {
             $this->tmpl['mu_response_msg'] = '<div class="alert alert-info">' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '<br />' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
         } else {
             if ($muFailed > 0 && $muUploaded == 0) {
                 $this->tmpl['mu_response_msg'] = '<div class="alert alert-error">' . JText::_('COM_PHOCAGALLERY_COUNT_NOT_UPLOADED_IMG') . ': ' . $muFailed . '</div>';
             } else {
                 if ($muFailed == 0 && $muUploaded > 0) {
                     $this->tmpl['mu_response_msg'] = '<div class="alert alert-success">' . JText::_('COM_PHOCAGALLERY_COUNT_UPLOADED_IMG') . ': ' . $muUploaded . '</div>';
                 } else {
                     $this->tmpl['mu_response_msg'] = '';
                 }
             }
         }
         if ((int) $this->tmpl['enablemultiple'] == 1 && (int) $this->tmpl['displayupload'] == 1) {
             PhocaGalleryFileUploadMultiple::renderMultipleUploadLibraries();
             $mU = new PhocaGalleryFileUploadMultiple();
             $mU->frontEnd = 2;
             $mU->method = $this->tmpl['multipleuploadmethod'];
             $mU->url = htmlspecialchars($this->tmpl['action'] . $amp . 'controller=user&task=multipleupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images'] . '&catid=' . $this->tmpl['catidimage']);
             $mU->reload = htmlspecialchars($this->tmpl['action'] . $amp . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images']);
             $mU->maxFileSize = PhocaGalleryFileUploadMultiple::getMultipleUploadSizeFormat($this->tmpl['uploadmaxsize']);
             $mU->chunkSize = '1mb';
             $mU->imageHeight = $this->tmpl['multipleresizeheight'];
             $mU->imageWidth = $this->tmpl['multipleresizewidth'];
             $mU->imageQuality = 100;
             $mU->renderMultipleUploadJS(0, $this->tmpl['multipleuploadchunk']);
             $this->tmpl['mu_output'] = $mU->getMultipleUploadHTML();
         }
         // - - - - - - - - - - -
         // Java Upload
         // - - - - - - - - - - -
         if ((int) $this->tmpl['enablejava'] == 1 && (int) $this->tmpl['displayupload'] == 1) {
             $jU = new PhocaGalleryFileUploadJava();
             $jU->width = $this->tmpl['javaboxwidth'];
             $jU->height = $this->tmpl['javaboxheight'];
             $jU->resizewidth = $this->tmpl['multipleresizewidth'];
             $jU->resizeheight = $this->tmpl['multipleresizeheight'];
             $jU->uploadmaxsize = $this->tmpl['uploadmaxsize'];
             $jU->returnUrl = htmlspecialchars($this->tmpl['action'] . $amp . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images']);
             $jU->url = htmlspecialchars($this->tmpl['action'] . $amp . 'controller=user&task=javaupload&' . $this->session->getName() . '=' . $this->session->getId() . '&' . JSession::getFormToken() . '=1&tab=' . $this->tmpl['currenttab']['images'] . '&catid=' . $this->tmpl['catidimage']);
             $jU->source = JURI::root(true) . '/components/com_phocagallery/assets/jupload/wjhk.jupload.jar';
             $this->tmpl['ju_output'] = $jU->getJavaUploadHTML();
         }
     } else {
         $this->tmpl['displayupload'] = 0;
     }
     if (!empty($ownerMainCategory->id)) {
         $this->tmpl['ps'] = '&tab=' . $this->tmpl['currenttab']['createsubcategory'] . '&limitstartsubcat=' . $this->tmpl['subcategorypagination']->limitstart . '&limitstartimage=' . $this->tmpl['imagepagination']->limitstart;
     } else {
         $this->tmpl['ps'] = '&tab=' . $this->tmpl['currenttab']['createsubcategory'];
     }
     if (!empty($ownerMainCategory->id)) {
         $this->tmpl['psi'] = '&tab=' . $this->tmpl['currenttab']['images'] . '&limitstartsubcat=' . $this->tmpl['subcategorypagination']->limitstart . '&limitstartimage=' . $this->tmpl['imagepagination']->limitstart;
     } else {
         $this->tmpl['psi'] = '&tab=' . $this->tmpl['currenttab']['images'];
     }
     // ASIGN
     $this->assignRef('listssubcat', $lists_subcat);
     $this->assignRef('listsimage', $lists_image);
     //$this->assignRef( 'tmpl', $this->tmpl);
     //$this->assignRef( 'params', $this->params);
     $this->assignRef('session', JFactory::getSession());
     $this->_prepareDocument();
     parent::display($tpl);
 }
コード例 #3
0
ファイル: user.php プロジェクト: optimosolution/marhk
 function removeimage()
 {
     $id = JRequest::getVar('id', '', 'get', 'string', JREQUEST_NOTRIM);
     $model = $this->getModel('user');
     $isOwnerCategory = $model->isOwnerCategoryImage((int) $this->_user->id, (int) $id);
     $errorMsg = '';
     if ($isOwnerCategory) {
         // USER RIGHT - DELETE - - - - - - - - -
         // 2, 2 means that user access will be ignored in function getUserRight for display Delete button
         $rightDisplayDelete = 0;
         $catAccess = PhocaGalleryAccess::getCategoryAccess((int) $isOwnerCategory);
         if (!empty($catAccess)) {
             $rightDisplayDelete = PhocaGalleryAccess::getUserRight('deleteuserid', $catAccess->deleteuserid, 2, $this->_user->authorisedLevels(), $this->_user->get('id', 0), 0);
         }
         // - - - - - - - - - - - - - - - - - - -
         if (!$model->deleteimage((int) $id, $errorMsg)) {
             $msg = JText::_('COM_PHOCAGALLERY_ERROR_DELETING_ITEM');
         } else {
             $msg = JText::_('COM_PHOCAGALLERY_SUCCESS_DELETING_ITEM');
         }
     } else {
         $app = JFactory::getApplication();
         $app->redirect($this->_loginurl, $this->_loginstr);
         exit;
     }
     $limitStartUrl = $this->getLimitStartUrl(0, 'image', (int) $isOwnerCategory);
     $this->setRedirect(JRoute::_($this->_url . $limitStartUrl->subcat . $limitStartUrl->image, false), $msg);
 }