/**
  * 
  * init gallery by record
  */
 public function initByRecord($record)
 {
     UniteFunctionsUG::validateNotEmpty($record, "record empty");
     $this->id = UniteFunctionsUG::getVal($record, "id");
     $this->title = UniteFunctionsUG::getVal($record, "title");
     $this->alias = UniteFunctionsUG::getVal($record, "alias");
     $this->ordering = UniteFunctionsUG::getVal($record, "ordering");
     $this->type = UniteFunctionsUG::getVal($record, "type");
     //set type title:
     if (!empty($this->type)) {
         try {
             UniteFunctionsUG::validateNotEmpty($this->type, "Gallery Type");
             $objGalleries = new UniteGalleryGalleries();
             $this->objType = $objGalleries->getGalleryTypeByName($this->type);
             $this->typeTitle = $this->objType->getTypeTitle();
             $this->isTypeExists = true;
         } catch (Exception $e) {
             $this->isTypeExists = false;
             $this->typeTitle = $this->type . " - gallery type not exists!";
         }
     }
     $this->arrParams = array();
     $params = UniteFunctionsUG::getVal($record, "params");
     if (!empty($params)) {
         $this->arrParams = (array) json_decode($params);
     }
 }
 /**
  * 
  * get galleries array from galleris folder with settings from config.xml from each gallery
  */
 private function initArrGalleryTypes()
 {
     $arrOrder = $this->getArrOrder();
     $strErrorPrefix = __("Load galleries error", UNITEGALLERY_TEXTDOMAIN);
     $arrDirs = UniteFunctionsUG::getDirList(GlobalsUG::$pathGalleries);
     $arrGalleries = array();
     //reorder arrdirs:
     $arrDirsNew = array();
     $arrDirs = UniteFunctionsUG::arrayToAssoc($arrDirs);
     foreach ($arrOrder as $dir) {
         if (array_key_exists($dir, $arrDirs)) {
             $arrDirsNew[] = $dir;
             unset($arrDirs[$dir]);
         }
     }
     $arrDirsNew = array_merge($arrDirsNew, $arrDirs);
     foreach ($arrDirsNew as $dir) {
         $pathGallery = GlobalsUG::$pathGalleries . $dir . "/";
         if (is_dir($pathGallery) == false) {
             continue;
         }
         $objGallery = new UniteGalleryGalleryType();
         $objGallery->initByFolder($dir);
         $galleryName = $objGallery->getName();
         $arrGalleries[$galleryName] = $objGallery;
     }
     self::$arrGalleryTypes = $arrGalleries;
 }
Exemplo n.º 3
0
<?php

/**
 * @package Unite Gallery
 * @author UniteCMS.net / Valiano
 * @copyright (C) 2012 Unite CMS, All Rights Reserved. 
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 * */
defined('_JEXEC') or die('Restricted access');
$objGalleries = new UniteGalleryGalleries();
$arrGalleryTypes = $objGalleries->getArrGalleryTypesShort();
$arrGalleries = $objGalleries->getArrGalleries("title");
$headerTitle = __("Galleries", UNITEGALLERY_TEXTDOMAIN);
require HelperUG::getPathTemplate("galleries");
 /**
  * 
  * onAjax action handler
  */
 public static function onAjaxAction()
 {
     $actionType = UniteFunctionsUG::getPostGetVariable("action");
     if ($actionType != "unitegallery_ajax_action") {
         return false;
     }
     $gallery = new UniteGalleryGallery();
     $galleries = new UniteGalleryGalleries();
     $categories = new UniteGalleryCategories();
     $items = new UniteGalleryItems();
     $operations = new UGOperations();
     $action = UniteFunctionsUG::getPostGetVariable("client_action");
     $data = UniteFunctionsUG::getPostVariable("data");
     $data = UniteProviderFunctionsUG::normalizeAjaxInputData($data);
     $galleryType = UniteFunctionsUG::getPostVariable("gallery_type");
     $urlGalleriesView = HelperUG::getGalleriesView();
     try {
         switch ($action) {
             case "gallery_actions":
                 $galleryID = UniteFunctionsUG::getVal($data, "galleryID");
                 $galleryAction = UniteFunctionsUG::getVal($data, "gallery_action");
                 $galleryData = UniteFunctionsUG::getVal($data, "gallery_data", array());
                 self::onGalleryAjaxAction($galleryType, $galleryAction, $galleryData, $galleryID);
                 break;
             case "get_thumb_url":
                 $urlImage = UniteFunctionsUG::getVal($data, "urlImage");
                 $imageID = UniteFunctionsUG::getVal($data, "imageID");
                 $urlThumb = $operations->getThumbURLFromImageUrl($urlImage, $imageID);
                 $arrData = array("urlThumb" => $urlThumb);
                 HelperUG::ajaxResponseData($arrData);
                 break;
             case "add_category":
                 $catData = $categories->addFromData();
                 HelperUG::ajaxResponseData($catData);
                 break;
             case "remove_category":
                 $response = $categories->removeFromData($data);
                 HelperUG::ajaxResponseSuccess(__("The category deleted successfully.", UNITEGALLERY_TEXTDOMAIN), $response);
                 break;
             case "update_category":
                 $categories->updateFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Category updated.", UNITEGALLERY_TEXTDOMAIN));
                 break;
             case "update_cat_order":
                 $categories->updateOrderFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Order updated.", UNITEGALLERY_TEXTDOMAIN));
                 break;
             case "add_item":
                 $itemData = $items->addFromData($data);
                 HelperUG::ajaxResponseData($itemData);
                 break;
             case "get_item_data":
                 $response = $items->getItemData($data);
                 HelperUG::ajaxResponseData($response);
                 break;
             case "update_item_data":
                 $response = $items->updateItemData($data);
                 HelperUG::ajaxResponseSuccess(__("Item data updated!", UNITEGALLERY_TEXTDOMAIN), $response);
                 break;
             case "remove_items":
                 $response = $items->removeItemsFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Items Removed", UNITEGALLERY_TEXTDOMAIN), $response);
                 break;
             case "get_cat_items":
                 $responeData = $items->getCatItemsHtmlFromData($data);
                 //update category param if inside gallery
                 $gallery->updateItemsCategoryFromData($data);
                 HelperUG::ajaxResponseData($responeData);
                 break;
             case "update_item_title":
                 $items->updateItemTitleFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Item Title Updated", UNITEGALLERY_TEXTDOMAIN));
                 break;
             case "duplicate_items":
                 $response = $items->duplicateItemsFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Items Duplicated", UNITEGALLERY_TEXTDOMAIN), $response);
                 break;
             case "update_items_order":
                 $items->saveOrderFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Order Saved", UNITEGALLERY_TEXTDOMAIN));
                 break;
             case "copy_move_items":
                 $response = $items->copyMoveItemsFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Done Operation", UNITEGALLERY_TEXTDOMAIN), $response);
                 break;
             case "create_gallery":
                 $galleryID = $galleries->addGaleryFromData($galleryType, $data);
                 $urlView = HelperUG::getGalleryView($galleryID);
                 HelperUG::ajaxResponseSuccessRedirect(__("Gallery Created", UNITEGALLERY_TEXTDOMAIN), $urlView);
                 break;
             case "delete_gallery":
                 $galleries->deleteGalleryFromData($data);
                 HelperUG::ajaxResponseSuccessRedirect(__("Gallery deleted", UNITEGALLERY_TEXTDOMAIN), $urlGalleriesView);
                 break;
             case "update_gallery":
                 $galleries->updateGalleryFromData($data);
                 HelperUG::ajaxResponseSuccess(__("Gallery Updated"));
                 break;
             case "duplicate_gallery":
                 $galleries->duplicateGalleryFromData($data);
                 HelperUG::ajaxResponseSuccessRedirect(__("Gallery duplicated", UNITEGALLERY_TEXTDOMAIN), $urlGalleriesView);
                 break;
             case "update_plugin":
                 if (method_exists("UniteProviderFunctionsUG", "updatePlugin")) {
                     UniteProviderFunctionsUG::updatePlugin();
                 } else {
                     echo "Functionality Don't Exists";
                 }
                 break;
             case "export_gallery_settings":
                 $galleryID = UniteFunctionsUG::getPostGetVariable("galleryid");
                 $galleries->exportGallerySettings($galleryID);
                 break;
             case "import_gallery_settings":
                 $galleryID = UniteFunctionsUG::getPostGetVariable("galleryid");
                 $galleries->importGallerySettingsFromUploadFile($galleryID);
                 break;
             default:
                 HelperUG::ajaxResponseError("wrong ajax action: <b>{$action}</b> ");
                 break;
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         $errorMessage = $message;
         if (GlobalsUG::SHOW_TRACE == true) {
             $trace = $e->getTraceAsString();
             $errorMessage = $message . "<pre>" . $trace . "</pre>";
         }
         HelperUG::ajaxResponseError($errorMessage);
     }
     //it's an ajax action, so exit
     HelperUG::ajaxResponseError("No response output on <b> {$action} </b> action. please check with the developer.");
     exit;
 }
    /**
     * 
     * the form
     */
    public function form($instance)
    {
        $galleries = new UniteGalleryGalleries();
        $arrGalleries = $galleries->getArrGalleriesShort();
        $galleryID = UniteFunctionsUG::getVal($instance, "unitegallery");
        if (empty($arrGalleries)) {
            echo __("No galleries found, Please create a gallery", UNITEGALLERY_TEXTDOMAIN);
        } else {
            $fieldCat = "unitegallery_cat";
            $fieldIDCat = $this->get_field_id($fieldCat);
            $fieldNameCat = $this->get_field_name($fieldCat);
            $categoryID = UniteFunctionsUG::getVal($instance, "unitegallery_cat");
            $objCategories = new UniteGalleryCategories();
            $arrCats = $objCategories->getCatsShort("component");
            $selectCats = UniteFunctionsUG::getHTMLSelect($arrCats, $categoryID, 'name="' . $fieldNameCat . '" id="' . $fieldIDCat . '"', true);
            //output gallries select
            $field = "unitegallery";
            $fieldID = $this->get_field_id($field);
            $fieldName = $this->get_field_name($field);
            $selectGalleries = UniteFunctionsUG::getHTMLSelect($arrGalleries, $galleryID, 'name="' . $fieldName . '" id="' . $fieldID . '"', true);
            ?>
				<div style="padding-top:10px;padding-bottom:10px;">
				
				<?php 
            _e("Title", UNITEGALLERY_TEXTDOMAIN);
            ?>
: 
				<input type="text" id="<?php 
            echo $this->get_field_id("title");
            ?>
" name="<?php 
            echo $this->get_field_name("title");
            ?>
" value="<?php 
            echo UniteFunctionsUG::getVal($instance, 'title');
            ?>
" />
				
				<br><br>
				
				<?php 
            _e("Choose Gallery", UNITEGALLERY_TEXTDOMAIN);
            ?>
: 
				<?php 
            echo $selectGalleries;
            ?>
				
				<br><br>
				<?php 
            _e("Choose Category", UNITEGALLERY_TEXTDOMAIN);
            ?>
: 
				
				<?php 
            echo $selectCats;
            ?>
				
				</div>
				
				<br>
			<?php 
        }
    }
Exemplo n.º 6
0
// no direct access
defined('_JEXEC') or die;
global $uniteGalleryVersion;
$uniteGalleryVersion = "1.7.5";
$currentFile = __FILE__;
$currentFolder = dirname($currentFile);
//include frameword files
require_once $currentFolder . '/inc_php/framework/include_framework.php';
require_once $currentFolder . '/inc_php/unitegallery_globals.class.php';
require_once $currentFolder . '/inc_php/unitegallery_globals_gallery.class.php';
require_once $currentFolder . '/inc_php/unitegallery_operations.class.php';
require_once $currentFolder . '/inc_php/unitegallery_categories.class.php';
require_once $currentFolder . '/inc_php/unitegallery_item.class.php';
require_once $currentFolder . '/inc_php/unitegallery_items.class.php';
require_once $currentFolder . '/inc_php/unitegallery_galleries.class.php';
require_once $currentFolder . '/inc_php/unitegallery_gallery.class.php';
require_once $currentFolder . '/inc_php/unitegallery_gallery_type.class.php';
require_once $currentFolder . '/inc_php/unitegallery_items.class.php';
require_once $currentFolder . '/inc_php/unitegallery_helper.class.php';
require_once $currentFolder . '/inc_php/unitegallery_helper_gallery.class.php';
//include all gallery files
$objGalleries = new UniteGalleryGalleries();
$arrGalleries = $objGalleries->getArrGalleryTypes();
foreach ($arrGalleries as $gallery) {
    $filepathIncludes = $gallery->getPathIncludes();
    $pathGallery = $gallery->getPathGallery();
    if (file_exists($filepathIncludes)) {
        require $filepathIncludes;
    }
}