예제 #1
0
파일: view.html.php 프로젝트: 01J/bealtine
    public function display($tpl = null)
    {
        $app = JFactory::getApplication();
        $user = JFactory::getUser();
        $uri = JFactory::getURI();
        $path = PhocaGalleryPath::getPath();
        $this->params = $app->getParams();
        $this->tmplGeo = array();
        $this->tmpl = array();
        $this->itemId = $app->input->get('Itemid', 0, 'int');
        $document = JFactory::getDocument();
        $library = PhocaGalleryLibrary::getLibrary();
        $this->tmpl['action'] = $uri->toString();
        // CSS
        PhocaGalleryRenderFront::renderAllCSS();
        // Params
        $this->tmpl['display_name'] = 1;
        //$this->params->get( 'display_name', 1);
        $this->tmpl['image_categories_size'] = $this->params->get('image_categories_size', 1);
        $display_categories_geotagging = $this->params->get('display_categories_geotagging', 0);
        $display_access_category = $this->params->get('display_access_category', 1);
        $display_empty_categories = $this->params->get('display_empty_categories', 0);
        $hideCatArray = explode(',', trim($this->params->get('hide_categories', '')));
        $showCatArray = explode(',', trim($this->params->get('show_categories', '')));
        $showParentCatArray = explode(',', trim($this->params->get('show_parent_categories', '')));
        $this->tmpl['categoriesimageordering'] = $this->params->get('categories_image_ordering', 10);
        $this->tmpl['categoriesdisplayavatar'] = $this->params->get('categories_display_avatar');
        $this->tmpl['categories_description'] = $this->params->get('categories_description', '');
        $this->tmpl['phocagallery_width'] = $this->params->get('phocagallery_width', '');
        $this->tmpl['phocagallery_center'] = $this->params->get('phocagallery_center', '');
        $this->tmpl['display_rating'] = $this->params->get('display_rating', 0);
        $this->tmpl['categories_box_space'] = $this->params->get('categories_box_space', '');
        $this->tmpl['display_cat_desc_box'] = $this->params->get('display_cat_desc_box', 0);
        $this->tmpl['char_cat_length_name'] = $this->params->get('char_cat_length_name', 9);
        $this->tmpl['categories_mosaic_images'] = $this->params->get('categories_mosaic_images', 0);
        $this->tmpl['diff_thumb_height'] = $this->params->get('diff_thumb_height', 0);
        // L E G A C Y ===
        $this->tmpl['equalpercentagewidth'] = $this->params->get('equal_percentage_width', 1);
        $this->tmpl['categoriesboxwidth'] = $this->params->get('categories_box_width', '33%');
        $this->tmpl['categoriescolumns'] = $this->params->get('categories_columns', 1);
        $this->tmpl['displayrating'] = $this->params->get('display_rating', 0);
        $this->tmpl['display_image_categories'] = $this->params->get('display_image_categories', 1);
        if ($this->tmpl['display_image_categories'] == 1) {
        } else {
            // If legacy no different height, no mosaic
            $this->tmpl['diff_thumb_height'] = 0;
            $this->tmpl['categories_mosaic_images'] = 0;
        }
        // END L E G A C Y ===
        switch ($this->tmpl['image_categories_size']) {
            // medium
            case 1:
                $this->tmpl['picasa_correct_width'] = (int) $this->params->get('medium_image_width', 100);
                $this->tmpl['picasa_correct_height'] = (int) $this->params->get('medium_image_height', 100);
                $this->tmpl['imagewidth'] = (int) $this->params->get('medium_image_width', 100);
                $this->tmpl['imageheight'] = (int) $this->params->get('medium_image_height', 100);
                $this->tmpl['class_suffix'] = 'medium';
                if ($this->tmpl['categories_mosaic_images'] == 1) {
                    $this->tmpl['imagewidth'] = (int) $this->params->get('medium_image_width', 100) * 3;
                    $this->tmpl['imageheight'] = (int) $this->params->get('medium_image_height', 100) * 2;
                }
                break;
                // small
            // small
            case 0:
            default:
                $this->tmpl['picasa_correct_width'] = (int) $this->params->get('small_image_width', 50);
                $this->tmpl['picasa_correct_height'] = (int) $this->params->get('small_image_height', 50);
                $this->tmpl['imagewidth'] = (int) $this->params->get('small_image_width', 50);
                $this->tmpl['imageheight'] = (int) $this->params->get('small_image_height', 50);
                $this->tmpl['class_suffix'] = 'small';
                if ($this->tmpl['categories_mosaic_images'] == 1) {
                    $this->tmpl['imagewidth'] = (int) $this->params->get('small_image_width', 50) * 3;
                    $this->tmpl['imageheight'] = (int) $this->params->get('small_image_height', 50) * 2;
                }
                break;
        }
        $this->tmpl['boxsize'] = PhocaGalleryImage::setBoxSize($this->tmpl, 1);
        if ($this->tmpl['diff_thumb_height'] == 2) {
            $document->addScript(JURI::base(true) . '/components/com_phocagallery/assets/masonry/masonry.min.js');
            $document->addCustomTag('<script type="text/javascript">
			window.onload = function() {
			  var wall = new Masonry( document.getElementById(\'pg-msnr-container\'), {
				isFitWidth: true
			  });
			};
			</script>');
        }
        $s = '#phocagallery {' . "\n";
        if ($this->tmpl['phocagallery_center'] != '') {
            $s .= '   margin: 0 auto; text-align: center;' . "\n";
        }
        if ($this->tmpl['phocagallery_width'] != '') {
            $s .= '   width: ' . $this->tmpl['phocagallery_width'] . 'px;' . "\n";
        }
        $s .= '}' . "\n";
        if ($this->tmpl['phocagallery_center'] != '') {
            $s = "\n" . '#pg-msnr-container {' . "\n";
            $s .= '   margin: 0 auto;' . "\n";
            $s .= '}' . "\n";
        }
        $s .= '.pg-csv-box {' . "\n";
        $s .= '   height: ' . $this->tmpl['boxsize']['height'] . 'px;' . "\n";
        $s .= '   width: ' . $this->tmpl['boxsize']['width'] . 'px;' . "\n";
        $s .= '}' . "\n";
        $s .= '.pg-csv-box-img {' . "\n";
        $s .= '   height: ' . $this->tmpl['imageheight'] . 'px;' . "\n";
        $s .= '   width: ' . $this->tmpl['imagewidth'] . 'px;' . "\n";
        $s .= '}' . "\n";
        $document->addCustomTag('<style type="text/css">' . $s . '</style>');
        // Image next to Category in Categories View is ordered by Random as default
        $categoriesImageOrdering = PhocaGalleryOrdering::getOrderingString($this->tmpl['categoriesimageordering']);
        // MODEL
        $model = $this->getModel();
        $this->tmpl['ordering'] = $model->getOrdering();
        $this->categories = $this->get('data');
        // Add link and unset the categories which user cannot see (if it is enabled in params)
        // If it will be unset while access view, we must sort the keys from category array - ACCESS
        $unSet = 0;
        foreach ($this->categories as $key => $item) {
            // Unset empty categories if it is set
            if ($display_empty_categories == 0) {
                if ($this->categories[$key]->numlinks < 1) {
                    unset($this->categories[$key]);
                    $unSet = 1;
                    continue;
                }
            }
            // Set only selected category ID
            if (!empty($showCatArray[0]) && is_array($showCatArray)) {
                $unSetHCA = 0;
                foreach ($showCatArray as $valueHCA) {
                    if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                        $unSetHCA = 0;
                        $unSet = 0;
                        break;
                    } else {
                        $unSetHCA = 1;
                        $unSet = 1;
                    }
                }
                if ($unSetHCA == 1) {
                    unset($this->categories[$key]);
                    continue;
                }
            }
            // Unset hidden category
            if (!empty($hideCatArray) && is_array($hideCatArray)) {
                $unSetHCA = 0;
                foreach ($hideCatArray as $valueHCA) {
                    if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                        unset($this->categories[$key]);
                        $unSet = 1;
                        $unSetHCA = 1;
                        break;
                    }
                }
                if ($unSetHCA == 1) {
                    continue;
                }
            }
            // Unset not set parent categories - only categories which have specific parent id will be displayed
            if (!empty($showParentCatArray[0]) && is_array($showParentCatArray)) {
                $unSetPHCA = 0;
                foreach ($showParentCatArray as $valuePHCA) {
                    if ((int) trim($valuePHCA) == $this->categories[$key]->parent_id) {
                        $unSetPHCA = 0;
                        //$unSet  	= 0;
                        break;
                    } else {
                        $unSetPHCA = 1;
                        $unSet = 1;
                    }
                }
                if ($unSetPHCA == 1) {
                    unset($this->categories[$key]);
                    continue;
                }
            }
            // Link
            $this->categories[$key]->link = PhocaGalleryRoute::getCategoryRoute($item->id, $item->alias);
            // USER RIGHT - ACCESS - - - - -
            // First Check - check if we can display category
            $rightDisplay = 1;
            if (!empty($this->categories[$key])) {
                $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->getAuthorisedViewLevels(), $user->get('id', 0), $display_access_category);
            }
            // Second Check - if we can display hidden category, set Key icon for them
            //                if we don't have access right to see them
            // Display Key Icon (in case we want to display unaccessable categories in list view)
            $rightDisplayKey = 1;
            if ($display_access_category == 1) {
                // we simulate that we want not to display unaccessable categories
                // so if we get rightDisplayKey = 0 then the key will be displayed
                if (!empty($this->categories[$key])) {
                    $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->getAuthorisedViewLevels(), $user->get('id', 0), 0);
                    // 0 - simulation
                }
            }
            // Is Ext Image Album?
            $extCategory = PhocaGalleryImage::isExtImage($this->categories[$key]->extid, $this->categories[$key]->extfbcatid);
            // DISPLAY AVATAR, IMAGE(ordered), IMAGE(not ordered, not recursive) OR FOLDER ICON
            $displayAvatar = 0;
            if ($this->tmpl['categoriesdisplayavatar'] == 1 && isset($this->categories[$key]->avatar) && $this->categories[$key]->avatar != '' && $this->categories[$key]->avatarapproved == 1 && $this->categories[$key]->avatarpublished == 1) {
                $sizeString = PhocaGalleryImageFront::getSizeString($this->tmpl['image_categories_size']);
                $pathAvatarAbs = $path->avatar_abs . 'thumbs' . DS . 'phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
                $pathAvatarRel = $path->avatar_rel . 'thumbs/phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
                if (JFile::exists($pathAvatarAbs)) {
                    $this->categories[$key]->linkthumbnailpath = $pathAvatarRel;
                    $displayAvatar = 1;
                }
            }
            if ($displayAvatar == 0) {
                if ($extCategory) {
                    if ($this->tmpl['categories_mosaic_images'] == 1) {
                        if ($this->tmpl['categoriesimageordering'] == 10) {
                            // Special cannot be used in this case:
                            $categoriesImageOrdering = 1;
                            // set to default ordering
                        }
                        $this->categories[$key]->filenames = PhocaGalleryImageFront::getCategoryImages($this->categories[$key]->id, $categoriesImageOrdering);
                        $this->categories[$key]->mosaic = PhocaGalleryImageFront::renderMosaic($this->categories[$key]->filenames, $this->tmpl['image_categories_size'], 1, $this->tmpl['picasa_correct_width'], $this->tmpl['picasa_correct_height']);
                    } else {
                        if ($this->tmpl['categoriesimageordering'] != 10) {
                            $imagePic = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering, 1);
                            if ($rightDisplayKey == 0) {
                                $imagePic = new StdClass();
                                $imagePic->exts = '';
                                $imagePic->extm = '';
                                $imagePic->extw = '';
                                $imagePic->exth = '';
                            }
                            $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($imagePic->exts, $imagePic->extm, $imagePic->extw, $imagePic->exth, $this->tmpl['image_categories_size'], $rightDisplayKey);
                            $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                            $this->categories[$key]->extw = $fileThumbnail->extw;
                            $this->categories[$key]->exth = $fileThumbnail->exth;
                            $this->categories[$key]->extpic = $fileThumbnail->extpic;
                        } else {
                            $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($this->categories[$key]->exts, $this->categories[$key]->extm, $this->categories[$key]->extw, $this->categories[$key]->exth, $this->tmpl['image_categories_size'], $rightDisplayKey);
                            $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                            $this->categories[$key]->extw = $fileThumbnail->extw;
                            $this->categories[$key]->exth = $fileThumbnail->exth;
                            $this->categories[$key]->extpic = $fileThumbnail->extpic;
                        }
                    }
                } else {
                    if ($this->tmpl['categories_mosaic_images'] == 1) {
                        if ($this->tmpl['categoriesimageordering'] == 10) {
                            // Special cannot be used in this case:
                            $categoriesImageOrdering = 1;
                            // set to default ordering
                        }
                        $this->categories[$key]->filenames = PhocaGalleryImageFront::getCategoryImages($this->categories[$key]->id, $categoriesImageOrdering);
                        $this->categories[$key]->mosaic = PhocaGalleryImageFront::renderMosaic($this->categories[$key]->filenames, $this->tmpl['image_categories_size']);
                    } else {
                        // Standard Internal Image
                        if ($this->tmpl['categoriesimageordering'] != 10) {
                            $this->categories[$key]->filename = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering);
                        }
                        $fileThumbnail = PhocaGalleryImageFront::displayCategoriesImageOrFolder($this->categories[$key]->filename, $this->tmpl['image_categories_size'], $rightDisplayKey);
                        $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                    }
                }
            }
            if ($rightDisplay == 0) {
                unset($this->categories[$key]);
                $unSet = 1;
            }
            // - - - - - - - - - - - - - - -
        }
        // ACCESS - - - - - -
        // In case we unset some category from the list, we must sort the array new
        if ($unSet == 1) {
            $this->categories = array_values($this->categories);
        }
        // - - - - - - - - - - - - - - - -
        // Do Pagination - we can do it after reducing all unneeded $this->categories, not before
        $totalCount = count($this->categories);
        $model->setTotal($totalCount);
        $this->tmpl['pagination'] = $this->get('pagination');
        $this->categories = array_slice($this->categories, (int) $this->tmpl['pagination']->limitstart, (int) $this->tmpl['pagination']->limit);
        // - - - - - - - - - - - - - - - -
        $this->tmpl['ems'] = '';
        // L E G A C Y ===
        $this->tmpl['countcategories'] = count($this->categories);
        $this->tmpl['begin'] = array();
        $this->tmpl['end'] = array();
        $this->tmpl['begin'][0] = 0;
        // first
        $this->tmpl['begin'][1] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns']);
        $this->tmpl['end'][0] = $this->tmpl['begin'][1] - 1;
        for ($j = 2; $j < (int) $this->tmpl['categoriescolumns']; $j++) {
            $this->tmpl['begin'][$j] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns'] * $j);
            $this->tmpl['end'][$j - 1] = $this->tmpl['begin'][$j] - 1;
        }
        $this->tmpl['end'][$j - 1] = $this->tmpl['countcategories'] - 1;
        // last
        $this->tmpl['endfloat'] = $this->tmpl['countcategories'] - 1;
        if ($this->tmpl['equalpercentagewidth'] == 1) {
            $fixedWidth = 100 / (int) (int) $this->tmpl['categoriescolumns'];
            $this->tmpl['fixedwidthstyle1'] = 'width:' . $fixedWidth . '%;';
            $this->tmpl['fixedwidthstyle2'] = 'width:' . $fixedWidth . '%;';
        } else {
            $this->tmpl['fixedwidthstyle1'] = '';
            //'margin: 10px;';
            $this->tmpl['fixedwidthstyle2'] = '';
            //'margin: 0px;';
        }
        // END L E G A C Y ===
        $this->_prepareDocument();
        if ($display_categories_geotagging == 1) {
            // Params
            $this->tmplGeo['categorieslng'] = $this->params->get('categories_lng', '');
            $this->tmplGeo['categorieslat'] = $this->params->get('categories_lat', '');
            $this->tmplGeo['categorieszoom'] = $this->params->get('categories_zoom', 2);
            $this->tmplGeo['googlemapsapikey'] = $this->params->get('google_maps_api_key', '');
            $this->tmplGeo['categoriesmapwidth'] = $this->params->get('categories_map_width', '');
            $this->tmplGeo['categoriesmapheight'] = $this->params->get('categorires_map_height', 500);
            // If no lng and lat will be added, Phoca Gallery will try to find it in categories
            if ($this->tmplGeo['categorieslat'] == '' || $this->tmplGeo['categorieslng'] == '') {
                phocagalleryimport('phocagallery.geo.geo');
                $latLng = PhocaGalleryGeo::findLatLngFromCategory($this->categories);
                $this->tmplGeo['categorieslng'] = $latLng['lng'];
                $this->tmplGeo['categorieslat'] = $latLng['lat'];
            }
            $this->assignRef('tmplGeo', $this->tmplGeo);
            parent::display('map');
        } else {
            parent::display($tpl);
        }
    }
예제 #2
0
 function store($data, $return)
 {
     //If this file doesn't exists don't save it
     if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) {
         $this->setError('File not exists');
         return false;
     }
     $data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0);
     //If there is no title and no alias, use filename as title and alias
     if (!isset($data['title']) || isset($data['title']) && $data['title'] == '') {
         $data['title'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
     }
     if (!isset($data['alias']) || isset($data['alias']) && $data['alias'] == '') {
         $data['alias'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
     }
     //clean alias name (no bad characters)
     //$data['alias'] = PhocaGalleryText::getAliasName($data['alias']);
     if (!isset($data['longitude']) || isset($data['longitude']) && $data['longitude'] == '' || (!isset($data['latitude']) || isset($data['latitude']) && $data['latitude'] == '')) {
         phocagalleryimport('phocagallery.geo.geo');
         $coords = PhocaGalleryGeo::getGeoCoords($data['filename']);
         if (!isset($data['longitude']) || isset($data['longitude']) && $data['longitude'] == '') {
             $data['longitude'] = $coords['longitude'];
         }
         if (!isset($data['latitude']) || isset($data['latitude']) && $data['latitude'] == '') {
             $data['latitude'] = $coords['latitude'];
         }
         if ((!isset($data['zoom']) || isset($data['zoom']) && $data['zoom'] == '') && $data['longitude'] != '' && $data['latitude'] != '') {
             $data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
         }
     }
     $row =& $this->getTable('phocagallery', 'Table');
     // Bind the form fields to the Phoca gallery table
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Create the timestamp for the date
     $row->date = gmdate('Y-m-d H:i:s');
     // if new item, order last in appropriate group
     if (!$row->id) {
         $where = 'catid = ' . (int) $row->catid;
         $row->ordering = $row->getNextOrder($where);
     }
     // Make sure the Phoca gallery table is valid
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Store the Phoca gallery table to the database
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     //Create thumbnail small, medium, large
     $returnFrontMessage = PhocaGalleryFileThumbnail::getOrCreateThumbnail($row->filename, $return, 1, 1, 1, 1);
     if ($returnFrontMessage == 'Success') {
         return true;
     } else {
         return false;
     }
 }
예제 #3
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user =& JFactory::getUser();
     $uri =& JFactory::getURI();
     $path =& PhocaGalleryPath::getPath();
     $this->params = $app->getParams();
     $this->tmplGeo = array();
     $this->tmpl['categories_description'] = $this->params->get('categories_description', '');
     $image_categories_size = $this->params->get('image_categories_size', 4);
     $medium_image_width = (int) $this->params->get('medium_image_width', 100) + 18;
     $medium_image_height = (int) $this->params->get('medium_image_height', 100) + 18;
     $small_image_width = (int) $this->params->get('small_image_width', 50) + 18;
     $small_image_height = (int) $this->params->get('small_image_height', 50) + 18;
     $this->tmpl['phocagallerywidth'] = $this->params->get('phocagallery_width', '');
     $this->tmpl['categoriescolumns'] = $this->params->get('categories_columns', 1);
     $this->tmpl['displayrating'] = $this->params->get('display_rating', 0);
     $this->tmpl['phocagallerycenter'] = $this->params->get('phocagallery_center', '');
     $this->tmpl['categoriesimageordering'] = $this->params->get('categories_image_ordering', 9);
     $this->tmpl['displayimagecategories'] = $this->params->get('display_image_categories', 1);
     $display_categories_geotagging = $this->params->get('display_categories_geotagging', 0);
     $display_access_category = $this->params->get('display_access_category', 1);
     $display_empty_categories = $this->params->get('display_empty_categories', 0);
     $hideCatArray = explode(',', trim($this->params->get('hide_categories', '')));
     $showCatArray = explode(',', trim($this->params->get('show_categories', '')));
     $this->tmpl['equalpercentagewidth'] = $this->params->get('equal_percentage_width');
     $this->tmpl['categoriesdisplayavatar'] = $this->params->get('categories_display_avatar');
     $this->tmpl['categoriesboxwidth'] = $this->params->get('categories_box_width');
     $this->tmpl['enablecustomcss'] = $this->params->get('enable_custom_css', 0);
     $this->tmpl['customcss'] = $this->params->get('custom_css', '');
     // = = = = = = = = = =
     // CSS
     // = = = = = = = = = =
     $document =& JFactory::getDocument();
     $library =& PhocaGalleryLibrary::getLibrary();
     JHtml::stylesheet('components/com_phocagallery/assets/phocagallery.css');
     if ($this->tmpl['enablecustomcss'] == 1) {
         JHtml::stylesheet('components/com_phocagallery/assets/phocagallerycustom.css');
         PhocaGalleryRenderFront::displayCustomCSS($this->tmpl['customcss']);
     } else {
         $libraries['pg-css-ie'] = $library->getLibrary('pg-css-ie');
         // CSS for IE 8
         if ($libraries['pg-css-ie']->value == 0) {
             $document->addCustomTag("<!--[if lt IE 8]>\n<link rel=\"stylesheet\" href=\"" . JURI::base(true) . "/components/com_phocagallery/assets/phocagalleryieall.css\" type=\"text/css\" />\n<![endif]-->");
             $library->setLibrary('pg-css-ie', 1);
         }
     }
     // = = = = = = = = = =
     // Correct Picasa Images - get Info
     switch ($image_categories_size) {
         // medium
         case 1:
         case 5:
             $this->tmpl['picasa_correct_width'] = (int) $this->params->get('medium_image_width', 100);
             $this->tmpl['picasa_correct_height'] = (int) $this->params->get('medium_image_height', 100);
             $this->tmpl['class_suffix'] = 'medium';
             break;
         case 0:
         case 4:
         default:
             $this->tmpl['picasa_correct_width'] = (int) $this->params->get('small_image_width', 50);
             $this->tmpl['picasa_correct_height'] = (int) $this->params->get('small_image_height', 50);
             $this->tmpl['class_suffix'] = 'small';
             break;
     }
     // - - - - - - - - - - - - - - -
     // Get background for the image
     $catImg = PhocaGalleryImageFront::getCategoriesImageBackground($image_categories_size, $small_image_width, $small_image_height, $medium_image_height, $medium_image_width);
     $this->tmpl['imagebg'] = $catImg->image;
     $this->tmpl['imagewidth'] = $catImg->width;
     //$total					= $this->get('total');
     //$this->tmpl['pagination']	= &$this->get('pagination');
     // Image next to Category in Categories View is ordered by Random as default
     $categoriesImageOrdering = PhocaGalleryOrdering::getOrderingString($this->tmpl['categoriesimageordering']);
     // MODEL
     $model =& $this->getModel();
     $this->tmpl['ordering'] =& $model->getOrdering();
     $this->categories = $this->get('data');
     // Add link and unset the categories which user cannot see (if it is enabled in params)
     // If it will be unset while access view, we must sort the keys from category array - ACCESS
     $unSet = 0;
     foreach ($this->categories as $key => $item) {
         // Unset empty categories if it is set
         if ($display_empty_categories == 0) {
             if ($this->categories[$key]->numlinks < 1) {
                 unset($this->categories[$key]);
                 $unSet = 1;
                 continue;
             }
         }
         // Set only selected category ID
         if (!empty($showCatArray[0]) && is_array($showCatArray)) {
             $unSetHCA = 0;
             foreach ($showCatArray as $valueHCA) {
                 if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                     $unSetHCA = 0;
                     $unSet = 0;
                     break;
                 } else {
                     $unSetHCA = 1;
                     $unSet = 1;
                 }
             }
             if ($unSetHCA == 1) {
                 unset($this->categories[$key]);
                 continue;
             }
         }
         // Unset hidden category
         if (!empty($hideCatArray) && is_array($hideCatArray)) {
             $unSetHCA = 0;
             foreach ($hideCatArray as $valueHCA) {
                 if ((int) trim($valueHCA) == $this->categories[$key]->id) {
                     unset($this->categories[$key]);
                     $unSet = 1;
                     $unSetHCA = 1;
                     break;
                 }
             }
             if ($unSetHCA == 1) {
                 continue;
             }
         }
         // Link
         //$this->categories[$key]->link	= JRoute::_('index.php?option=com_phocagallery&view=category&id='. $item->slug.'&Itemid='. JRequest::getVar('Itemid', 0, '', 'int') );
         $this->categories[$key]->link = PhocaGalleryRoute::getCategoryRoute($item->id, $item->alias);
         // USER RIGHT - ACCESS - - - - -
         // First Check - check if we can display category
         $rightDisplay = 1;
         if (!empty($this->categories[$key])) {
             $rightDisplay = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->authorisedLevels(), $user->get('id', 0), $display_access_category);
         }
         // Second Check - if we can display hidden category, set Key icon for them
         //                if we don't have access right to see them
         // Display Key Icon (in case we want to display unaccessable categories in list view)
         $rightDisplayKey = 1;
         if ($display_access_category == 1) {
             // we simulate that we want not to display unaccessable categories
             // so if we get rightDisplayKey = 0 then the key will be displayed
             if (!empty($this->categories[$key])) {
                 $rightDisplayKey = PhocaGalleryAccess::getUserRight('accessuserid', $this->categories[$key]->accessuserid, $this->categories[$key]->access, $user->authorisedLevels(), $user->get('id', 0), 0);
                 // 0 - simulation
             }
         }
         // Is Ext Image Album?
         $extCategory = PhocaGalleryImage::isExtImage($this->categories[$key]->extid, $this->categories[$key]->extfbcatid);
         // DISPLAY AVATAR, IMAGE(ordered), IMAGE(not ordered, not recursive) OR FOLDER ICON
         $displayAvatar = 0;
         if ($this->tmpl['categoriesdisplayavatar'] == 1 && isset($this->categories[$key]->avatar) && $this->categories[$key]->avatar != '' && $this->categories[$key]->avatarapproved == 1 && $this->categories[$key]->avatarpublished == 1) {
             $sizeString = PhocaGalleryImageFront::getSizeString($image_categories_size);
             $pathAvatarAbs = $path->avatar_abs . 'thumbs' . DS . 'phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
             $pathAvatarRel = $path->avatar_rel . 'thumbs/phoca_thumb_' . $sizeString . '_' . $this->categories[$key]->avatar;
             if (JFile::exists($pathAvatarAbs)) {
                 $this->categories[$key]->linkthumbnailpath = $pathAvatarRel;
                 $displayAvatar = 1;
             }
         }
         if ($displayAvatar == 0) {
             if ($extCategory) {
                 if ($this->tmpl['categoriesimageordering'] != 10) {
                     $imagePic = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering, 1);
                     $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($imagePic->exts, $imagePic->extm, $imagePic->extw, $imagePic->exth, $image_categories_size, $rightDisplayKey);
                 } else {
                     $fileThumbnail = PhocaGalleryImageFront::displayCategoriesExtImgOrFolder($this->categories[$key]->exts, $this->categories[$key]->extm, $this->categories[$key]->extw, $this->categories[$key]->exth, $image_categories_size, $rightDisplayKey);
                 }
                 $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
                 $this->categories[$key]->extw = $fileThumbnail->extw;
                 $this->categories[$key]->exth = $fileThumbnail->exth;
                 $this->categories[$key]->extpic = $fileThumbnail->extpic;
             } else {
                 if ($this->tmpl['categoriesimageordering'] != 10) {
                     $this->categories[$key]->filename = PhocaGalleryImageFront::getRandomImageRecursive($this->categories[$key]->id, $categoriesImageOrdering);
                 }
                 $fileThumbnail = PhocaGalleryImageFront::displayCategoriesImageOrFolder($this->categories[$key]->filename, $image_categories_size, $rightDisplayKey);
                 $this->categories[$key]->linkthumbnailpath = $fileThumbnail->rel;
             }
         }
         if ($rightDisplay == 0) {
             unset($this->categories[$key]);
             $unSet = 1;
         }
         // - - - - - - - - - - - - - - -
     }
     $this->tmpl['mtb'] = PhocaGalleryRenderInfo::getPhocaIc((int) $this->params->get('display_phoca_info', 1));
     // ACCESS - - - - - -
     // In case we unset some category from the list, we must sort the array new
     if ($unSet == 1) {
         $this->categories = array_values($this->categories);
     }
     // - - - - - - - - - - - - - - - -
     // Do Pagination - we can do it after reducing all unneeded $this->categories, not before
     $totalCount = count($this->categories);
     $model->setTotal($totalCount);
     $this->tmpl['pagination'] =& $this->get('pagination');
     $this->categories = array_slice($this->categories, (int) $this->tmpl['pagination']->limitstart, (int) $this->tmpl['pagination']->limit);
     // - - - - - - - - - - - - - - - -
     // Display Image of Categories Description
     /*	if ($this->params->get('image') != -1) {
     			$attribs['align']	= $this->params->get('image_align');
     			$attribs['hspace']	= 6;
     			// Use the static HTML library to build the image tag
     			$this->tmpl['image'] 		= JHtml::_('image', 'images/stories/'.$this->params->get('image'), '', $attribs);
     		}*/
     // ACTION
     $this->tmpl['action'] = $uri->toString();
     //Design
     $this->tmpl['countcategories'] = count($this->categories);
     $this->tmpl['begin'] = array();
     $this->tmpl['end'] = array();
     $this->tmpl['begin'][0] = 0;
     // first
     $this->tmpl['begin'][1] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns']);
     $this->tmpl['end'][0] = $this->tmpl['begin'][1] - 1;
     for ($j = 2; $j < (int) $this->tmpl['categoriescolumns']; $j++) {
         $this->tmpl['begin'][$j] = ceil($this->tmpl['countcategories'] / (int) $this->tmpl['categoriescolumns'] * $j);
         $this->tmpl['end'][$j - 1] = $this->tmpl['begin'][$j] - 1;
     }
     $this->tmpl['end'][$j - 1] = $this->tmpl['countcategories'] - 1;
     // last
     $this->tmpl['endfloat'] = $this->tmpl['countcategories'] - 1;
     if ($this->tmpl['equalpercentagewidth'] == 1) {
         $fixedWidth = 100 / (int) (int) $this->tmpl['categoriescolumns'];
         $this->tmpl['fixedwidthstyle1'] = 'width:' . $fixedWidth . '%;';
         $this->tmpl['fixedwidthstyle2'] = 'width:' . $fixedWidth . '%;';
     } else {
         $this->tmpl['fixedwidthstyle1'] = '';
         //'margin: 10px;';
         $this->tmpl['fixedwidthstyle2'] = '';
         //'margin: 0px;';
     }
     // ASSIGN
     //$this->assignRef('tmpl',		$this->tmpl);
     $this->assignRef('params', $this->params);
     $this->_prepareDocument();
     if ($display_categories_geotagging == 1) {
         // PARAMS - - - - - - - - - -
         $this->tmplGeo['categorieslng'] = $this->params->get('categories_lng', '');
         $this->tmplGeo['categorieslat'] = $this->params->get('categories_lat', '');
         $this->tmplGeo['categorieszoom'] = $this->params->get('categories_zoom', 2);
         $this->tmplGeo['googlemapsapikey'] = $this->params->get('google_maps_api_key', '');
         $this->tmplGeo['categoriesmapwidth'] = $this->params->get('categories_map_width', '');
         $this->tmplGeo['categoriesmapheight'] = $this->params->get('categorires_map_height', 500);
         // - - - - - - - - - - - - - - -
         // if no lng and lat will be added, Phoca Gallery will try to find it in categories
         if ($this->tmplGeo['categorieslat'] == '' || $this->tmplGeo['categorieslng'] == '') {
             phocagalleryimport('phocagallery.geo.geo');
             $latLng = PhocaGalleryGeo::findLatLngFromCategory($this->categories);
             $this->tmplGeo['categorieslng'] = $latLng['lng'];
             $this->tmplGeo['categorieslat'] = $latLng['lat'];
         }
         $this->assignRef('tmplGeo', $this->tmplGeo);
         parent::display('map');
     } else {
         parent::display($tpl);
     }
 }
예제 #4
0
 protected function _addAllImagesFromFolder(&$existingImages, $category_id, $fullPath, $rel_path, $data = array())
 {
     $count = 0;
     $fileList = JFolder::files($fullPath);
     natcasesort($fileList);
     // Iterate over the files if they exist
     //file - abc.img, file_no - folder/abc.img
     if ($fileList !== false) {
         foreach ($fileList as $filename) {
             $storedfilename = ltrim(str_replace(DS, '/', JPath::clean($rel_path . DS . $filename)), '/');
             $ext = strtolower(JFile::getExt($filename));
             // Don't create thumbnails from defined files (don't save them into a database)...
             $dontCreateThumb = PhocaGalleryFileThumbnail::dontCreateThumb($filename);
             if ($dontCreateThumb == 1) {
                 $ext = '';
                 // WE USE $ext FOR NOT CREATE A THUMBNAIL CLAUSE
             }
             if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg') {
                 if (JFile::exists($fullPath . DS . $filename) && substr($filename, 0, 1) != '.' && strtolower($filename) !== 'index.html' && !$this->_ImageExist($existingImages, $storedfilename, $category_id)) {
                     $row = $this->getTable('phocagallery');
                     $datam = array();
                     $datam['published'] = $data['published'];
                     $datam['catid'] = $category_id;
                     $datam['filename'] = $storedfilename;
                     $datam['approved'] = $data['approved'];
                     $datam['language'] = $data['language'];
                     if ($data['title'] != '') {
                         $datam['title'] = $data['title'];
                     } else {
                         $datam['title'] = PhocaGalleryFile::getTitleFromFile($filename);
                     }
                     if ($data['alias'] != '') {
                         $datam['alias'] = $data['alias'];
                     } else {
                         $datam['alias'] = $datam['title'];
                         //PhocaGalleryText::getAliasName($datam['title']);
                     }
                     $datam['imgorigsize'] = PhocaGalleryFile::getFileSize($datam['filename'], 0);
                     $datam['format'] = PhocaGalleryFile::getFileFormat($datam['filename']);
                     // Geo
                     phocagalleryimport('phocagallery.geo.geo');
                     $coords = PhocaGalleryGeo::getGeoCoords($datam['filename']);
                     $datam['longitude'] = $coords['longitude'];
                     $datam['latitude'] = $coords['latitude'];
                     if ($datam['latitude'] != '' && $datam['longitude'] != '') {
                         $datam['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
                     }
                     // Save
                     // Bind the form fields to the Phoca gallery table
                     if (!$row->bind($datam)) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                     // Create the timestamp for the date
                     $row->date = gmdate('Y-m-d H:i:s');
                     // if new item, order last in appropriate group
                     if (!$row->id) {
                         $where = 'catid = ' . (int) $row->catid;
                         $row->ordering = $row->getNextOrder($where);
                     }
                     // Make sure the Phoca gallery table is valid
                     if (!$row->check()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                     // Store the Phoca gallery table to the database
                     if (!$row->store()) {
                         $this->setError($this->_db->getErrorMsg());
                         return false;
                     }
                     if ($this->firstImageFolder == '') {
                         $this->setFirstImageFolder($row->filename);
                     }
                     $image = new JObject();
                     $image->filename = $storedfilename;
                     $image->catid = $category_id;
                     $existingImages[] =& $image;
                     $count++;
                 }
             }
         }
     }
     //	$this->setImageCount($count);
     return $count;
 }
예제 #5
0
 function save($data)
 {
     $params =& JComponentHelper::getParams('com_phocagallery');
     $clean_thumbnails = $params->get('clean_thumbnails', 0);
     $fileOriginalNotExist = 0;
     if ((int) $data['extid'] > 0) {
         $data['imgorigsize'] = 0;
         if ($data['title'] == '') {
             $data['title'] = 'External Image';
         }
     } else {
         //If this file doesn't exists don't save it
         if (!PhocaGalleryFile::existsFileOriginal($data['filename'])) {
             //$this->setError('Original File does not exist');
             //return false;
             $fileOriginalNotExist = 1;
             $errorMsg = JText::_('COM_PHOCAGALLERY_ORIGINAL_IMAGE_NOT_EXIST');
         }
         $data['imgorigsize'] = PhocaGalleryFile::getFileSize($data['filename'], 0);
         $data['format'] = PhocaGalleryFile::getFileFormat($data['filename']);
         //If there is no title and no alias, use filename as title and alias
         if ($data['title'] == '') {
             $data['title'] = PhocaGalleryFile::getTitleFromFile($data['filename']);
         }
     }
     if ($data['extlink1link'] != '') {
         $extlink1 = str_replace('http://', '', $data['extlink1link']);
         $data['extlink1'] = $extlink1 . '|' . $data['extlink1title'] . '|' . $data['extlink1target'] . '|' . $data['extlink1icon'];
     } else {
         $data['extlink1'] = $data['extlink1link'] . '|' . $data['extlink1title'] . '|' . $data['extlink1target'] . '|' . $data['extlink1icon'];
     }
     if ($data['extlink2link'] != '') {
         $extlink2 = str_replace('http://', '', $data['extlink2link']);
         $data['extlink2'] = $extlink2 . '|' . $data['extlink2title'] . '|' . $data['extlink2target'] . '|' . $data['extlink2icon'];
     } else {
         $data['extlink2'] = $data['extlink2link'] . '|' . $data['extlink2title'] . '|' . $data['extlink2target'] . '|' . $data['extlink2icon'];
     }
     // Geo
     if ($data['longitude'] == '' || $data['latitude'] == '') {
         phocagalleryimport('phocagallery.geo.geo');
         $coords = PhocaGalleryGeo::getGeoCoords($data['filename']);
         if ($data['longitude'] == '') {
             $data['longitude'] = $coords['longitude'];
         }
         if ($data['latitude'] == '') {
             $data['latitude'] = $coords['latitude'];
         }
         if ($data['latitude'] != '' && $data['longitude'] != '' && $data['zoom'] == '') {
             $data['zoom'] = PhocaGallerySettings::getAdvancedSettings('geozoom');
         }
     }
     if ($data['alias'] == '') {
         $data['alias'] = $data['title'];
     }
     //clean alias name (no bad characters)
     //$data['alias'] = PhocaGalleryText::getAliasName($data['alias']);
     // if new item, order last in appropriate group
     //if (!$row->id) {
     //	$where = 'catid = ' . (int) $row->catid ;
     //	$row->ordering = $row->getNextOrder( $where );
     //}
     // = = = = = = = = = =
     // Initialise variables;
     $dispatcher = JDispatcher::getInstance();
     $table = $this->getTable();
     $pk = !empty($data['id']) ? $data['id'] : (int) $this->getState($this->getName() . '.id');
     $isNew = true;
     // Include the content plugins for the on save events.
     JPluginHelper::importPlugin('content');
     // Load the row if saving an existing record.
     if ($pk > 0) {
         $table->load($pk);
         $isNew = false;
     }
     // Bind the data.
     if (!$table->bind($data)) {
         $this->setError($table->getError());
         return false;
     }
     if (intval($table->date) == 0) {
         $table->date = JFactory::getDate()->toSql();
     }
     // Prepare the row for saving
     $this->prepareTable($table);
     // Check the data.
     if (!$table->check()) {
         $this->setError($table->getError());
         return false;
     }
     // Trigger the onContentBeforeSave event.
     /*$result = $dispatcher->trigger($this->event_before_save, array($this->option.'.'.$this->name, $table, $isNew));
     		if (in_array(false, $result, true)) {
     			$this->setError($table->getError());
     			return false;
     		}*/
     // Store the data.
     if (!$table->store()) {
         $this->setError($table->getError());
         return false;
     }
     // Store to ref table
     if (!isset($data['tags'])) {
         $data['tags'] = array();
     }
     if ((int) $table->id > 0) {
         PhocaGalleryTag::storeTags($data['tags'], (int) $table->id);
     }
     // Clean the cache.
     $cache = JFactory::getCache($this->option);
     $cache->clean();
     // Trigger the onContentAfterSave event.
     //$dispatcher->trigger($this->event_after_save, array($this->option.'.'.$this->name, $table, $isNew));
     $pkName = $table->getKeyName();
     if (isset($table->{$pkName})) {
         $this->setState($this->getName() . '.id', $table->{$pkName});
     }
     $this->setState($this->getName() . '.new', $isNew);
     // = = = = = =
     $task = JRequest::getVar('task');
     if (isset($table->{$pkName})) {
         $id = $table->{$pkName};
     }
     if ((int) $data['extid'] > 0 || $fileOriginalNotExist == 1) {
     } else {
         // - - - - - - - - - - - - - - - - - -
         //Create thumbnail small, medium, large
         //file - abc.img, file_no - folder/abc.img
         //Get folder variables from Helper
         //Create thumbnails small, medium, large
         $refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.thumbs';
         $task = JRequest::getVar('task');
         if (isset($table->{$pkName}) && $task == 'apply') {
             $id = $table->{$pkName};
             $refresh_url = 'index.php?option=com_phocagallery&task=phocagalleryimg.edit&id=' . (int) $id;
         }
         if ($task == 'save2new') {
             // Don't create automatically thumbnails in case, we are going to add new image
         } else {
             $file_thumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($data['filename'], $refresh_url, 1, 1, 1);
         }
         //Clean Thumbs Folder if there are thumbnail files but not original file
         if ($clean_thumbnails == 1) {
             phocagalleryimport('phocagallery.file.filefolder');
             PhocaGalleryFileFolder::cleanThumbsFolder();
         }
         // - - - - - - - - - - - - - - - - - - - - -
     }
     return true;
 }