/** * * get gallery data from xml file */ private function initDataFromXml() { $errorPrefix = $this->filepathXmlFile . " parsing error:"; if (!file_exists($this->filepathXmlFile)) { UniteFunctionsUG::throwError("File: '{$filepath}' not exists!!!"); } $obj = simplexml_load_file($this->filepathXmlFile); if (empty($obj)) { UniteFunctionsUG::throwError("Wrong xml file format: {$this->filepathXmlFile}"); } $objGeneral = $obj->general; if (empty($objGeneral)) { UniteFunctionsUG::throwError($errorPrefix . "General section not found."); } //get general data $arrData = (array) $objGeneral; $this->name = UniteFunctionsUG::getVal($arrData, "name"); $this->typeTitle = UniteFunctionsUG::getVal($arrData, "title"); $this->isPublished = UniteFunctionsUG::getVal($arrData, "published"); $this->isPublished = UniteFunctionsUG::strToBool($this->isPublished); $this->itemsType = UniteFunctionsUG::getVal($arrData, "items_type", "all"); //validatopm UniteFunctionsUG::validateNotEmpty($this->name, $errorPrefix); UniteFunctionsUG::validateNotEmpty($this->typeTitle, $errorPrefix); }
<?php defined('_JEXEC') or die('Restricted access'); //require settings $galleryID = GlobalsUGGallery::$galleryID; //enable tabs if disabled $enableTabs = GlobalsUGGallery::$gallery->getParam("enable_category_tabs"); $enableTabs = UniteFunctionsUG::strToBool($enableTabs); if ($enableTabs == false) { GlobalsUGGallery::$gallery->updateParam("enable_category_tabs", "true"); } require GlobalsUG::$pathHelpersSettings . "categorytab_main.php"; require GlobalsUG::$pathHelpersSettings . "categorytab_params.php"; $outputMain = new UniteSettingsProductUG(); $outputParams = new UniteSettingsProductSidebarUG(); $galleryTitle = GlobalsUGGallery::$gallery->getTitle(); $headerTitle = $galleryTitle . __(" - [settings]", UNITEGALLERY_TEXTDOMAIN); $arrValues = GlobalsUGGallery::$gallery->getParams(); //set setting values from the slider $settingsMain->setStoredValues($arrValues); $settingsParams->setStoredValues($arrValues); $outputMain->init($settingsMain); $outputParams->init($settingsParams); require HelperGalleryUG::getPathHelperTemplate("gallery_categorytabs");
/** * * get some param */ protected function getParam($name, $validateMode = null) { if (is_array($this->arrParams) == false) { $this->arrParams = array(); } if (array_key_exists($name, $this->arrParams)) { $arrParams = $this->arrParams; $value = $this->arrParams[$name]; } else { if (is_array($this->arrOriginalParams) == false) { $this->arrOriginalParams = array(); } $arrParams = $this->arrOriginalParams; $value = UniteFunctionsUG::getVal($this->arrOriginalParams, $name); } switch ($validateMode) { case self::VALIDATE_EXISTS: if (array_key_exists($name, $arrParams) == false) { UniteFunctionsUG::throwError("The param: {$name} don't exists"); } break; case self::VALIDATE_NUMERIC: if (is_numeric($value) == false) { UniteFunctionsUG::throwError("The param: {$name} is not numeric"); } break; case self::VALIDATE_SIZE: if (strpos($value, "%") === false && is_numeric($value) == false) { UniteFunctionsUG::throwError("The param: {$name} is not size"); } break; case self::FORCE_SIZE: $isPercent = strpos($value, "%") !== false; if ($isPercent == false && is_numeric($value) == false) { UniteFunctionsUG::throwError("The param: {$name} is not size"); } if ($isPercent == false) { $value .= "px"; } break; case self::FORCE_NUMERIC: $value = floatval($value); $value = (double) $value; break; case self::FORCE_BOOLEAN: $value = UniteFunctionsUG::strToBool($value); break; case self::TRIM: $value = trim($value); break; } return $value; }
/** * * init item by db record */ public function initByDBRecord($record) { $this->isInited = true; $this->data = $record; $jsonParams = UniteFunctionsUG::getVal($record, "params"); $this->id = UniteFunctionsUG::getVal($record, "id"); $this->params = array(); if (!empty($jsonParams)) { $this->params = (array) json_decode($jsonParams); } $this->title = UniteFunctionsUG::getVal($record, "title"); $this->imageID = UniteFunctionsUG::getVal($record, "imageid"); $this->type = UniteFunctionsUG::getVal($record, "type"); $this->content = UniteFunctionsUG::getVal($record, "content"); $this->contentID = UniteFunctionsUG::getVal($record, "contentid"); $published = UniteFunctionsUG::getVal($record, "published"); $this->isPublished = UniteFunctionsUG::strToBool($published); //set image by url $this->urlImage = UniteFunctionsUG::getVal($record, "url_image"); if (empty($this->urlImage)) { $this->urlImage = $this->getParam("image"); } //HelperUG::URLtoFull($this->getParam("image")); $this->urlThumb = UniteFunctionsUG::getVal($record, "url_thumb"); if (empty($this->urlThumb)) { $this->urlThumb = $this->getParam("thumb"); } if (!empty($this->imageID)) { $this->urlImage = UniteProviderFunctionsUG::getImageUrlFromImageID($this->imageID); $this->urlThumb = UniteProviderFunctionsUG::getThumbUrlFromImageID($this->imageID); } $this->urlImage = HelperUG::URLtoFull($this->urlImage); $this->urlThumb = HelperUG::URLtoFull($this->urlThumb); $this->initParamsByType(); $this->migrateParamsNewValues(); }
$classAdvanced = "selected"; break; } } //category tabs $enableTabs = GlobalsUGGallery::$gallery->getParam("enable_category_tabs"); $enableTabs = UniteFunctionsUG::strToBool($enableTabs); if ($enableTabs == false) { $classCategoryTabs .= " unite-tab-hidden"; } if (!empty($classCategoryTabs)) { $classCategoryTabs = "class='{$classCategoryTabs}'"; } //-------- advanced tab $showAdvanced = GlobalsUGGallery::$gallery->getParam("show_advanced_tab"); $showAdvanced = UniteFunctionsUG::strToBool($showAdvanced); if ($showAdvanced == false) { $classAdvanced .= " unite-tab-hidden"; } if (!empty($classAdvanced)) { $classAdvanced = "class='{$classAdvanced}'"; } global $ugMaxItems; ?> <div class='settings_tabs'> <ul class="list-tabs-settings"> <li <?php echo $classSettings; ?> >
/** * * load settings from xml file */ public function loadXMLFile($filepath) { if (!file_exists($filepath)) { UniteFunctionsUG::throwError("File: '{$filepath}' not exists!!!"); } $obj = simplexml_load_file($filepath); if (empty($obj)) { UniteFunctionsUG::throwError("Wrong xml file format: {$filepath}"); } $fieldsets = $obj->fieldset; if (!@count($obj->fieldset)) { $fieldsets = array($fieldsets); } $this->addSection("Xml Settings"); foreach ($fieldsets as $fieldset) { //Add Section $attribs = $fieldset->attributes(); $sapName = (string) UniteFunctionsUG::getVal($attribs, "name"); $sapLabel = (string) UniteFunctionsUG::getVal($attribs, "label"); $sapIcon = (string) UniteFunctionsUG::getVal($attribs, "icon"); $loadFrom = (string) UniteFunctionsUG::getVal($attribs, "loadfrom"); UniteFunctionsUG::validateNotEmpty($sapName, "sapName"); if (!empty($loadFrom)) { $this->addExternalSettings($sapName, $loadFrom); continue; } UniteFunctionsUG::validateNotEmpty($sapLabel, "sapLabel"); $this->addSap($sapLabel, $sapName, false, $sapIcon); //--- add fields $fieldset = (array) $fieldset; $fields = UniteFunctionsUG::getVal($fieldset, "field"); if (empty($fields)) { $fields = array(); } else { if (is_array($fields) == false) { $fields = array($fields); } } foreach ($fields as $field) { $attribs = $field->attributes(); $fieldType = (string) UniteFunctionsUG::getVal($attribs, "type"); $fieldName = (string) UniteFunctionsUG::getVal($attribs, "name"); $fieldLabel = (string) UniteFunctionsUG::getVal($attribs, "label"); $fieldDefaultValue = (string) UniteFunctionsUG::getVal($attribs, "default"); //all other params will be added to "params array". $arrMustParams = array("type", "name", "label", "default"); $arrParams = array(); foreach ($attribs as $key => $value) { $key = (string) $key; $value = (string) $value; //skip must params: if (in_array($key, $arrMustParams)) { continue; } $arrParams[$key] = $value; } $options = $this->getOptionsFromXMLField($field, $fieldName); //validate must fields: UniteFunctionsUG::validateNotEmpty($fieldType, "type"); //validate name if ($fieldType != self::TYPE_HR && $fieldType != self::TYPE_CONTROL && $fieldType != "bulk_control_start" && $fieldType != "bulk_control_end") { UniteFunctionsUG::validateNotEmpty($fieldName, "name"); } switch ($fieldType) { case self::TYPE_CHECKBOX: $fieldDefaultValue = UniteFunctionsUG::strToBool($fieldDefaultValue); $this->addCheckbox($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_COLOR: $this->addColorPicker($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_HR: $this->addHr($fieldName); break; case self::TYPE_TEXT: $this->addTextBox($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_MULTIPLE_TEXT: $this->addMultipleTextBox($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_STATIC_TEXT: $this->addStaticText($fieldLabel, $fieldName, $arrParams); break; case self::TYPE_IMAGE: $this->addImage($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_SELECT: $this->addSelect($fieldName, $options, $fieldLabel, $fieldDefaultValue, $arrParams); break; case self::TYPE_CHECKBOX: $this->addChecklist($fieldName, $options, $fieldLabel, $fieldDefaultValue, $arrParams); break; case self::TYPE_RADIO: $this->addRadio($fieldName, $options, $fieldLabel, $fieldDefaultValue, $arrParams); break; case self::TYPE_BOOLEAN: $options = array("true" => "Yes", "false" => "No"); $this->addRadio($fieldName, $options, $fieldLabel, $fieldDefaultValue, $arrParams); break; case self::TYPE_TEXTAREA: $this->addTextArea($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_CUSTOM: $this->add($fieldName, $fieldDefaultValue, $fieldLabel, self::TYPE_CUSTOM, $arrParams); break; case self::TYPE_BUTTON: $this->addButton($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; case self::TYPE_CONTROL: $parent = UniteFunctionsUG::getVal($arrParams, "parent"); $child = UniteFunctionsUG::getVal($arrParams, "child"); $ctype = UniteFunctionsUG::getVal($arrParams, "ctype"); $value = UniteFunctionsUG::getVal($arrParams, "value"); $this->addControl($parent, $child, $ctype, $value); break; case "bulk_control_start": $parent = UniteFunctionsUG::getVal($arrParams, "parent"); $ctype = UniteFunctionsUG::getVal($arrParams, "ctype"); $value = UniteFunctionsUG::getVal($arrParams, "value"); $this->startBulkControl($parent, $ctype, $value); break; case "bulk_control_end": $this->endBulkControl(); break; case "codemirror": $this->addCodemirror($fieldName, $fieldDefaultValue, $fieldLabel, $arrParams); break; default: UniteFunctionsUG::throwError("wrong type: {$fieldType}"); break; } } } }
/** * draw radio input */ protected function drawRadioInput($setting) { $items = $setting["items"]; $counter = 0; $settingID = $setting["id"]; $isDisabled = UniteFunctionsUG::getVal($setting, "disabled"); $isDisabled = UniteFunctionsUG::strToBool($isDisabled); $settingName = $setting["name"]; ?> <span id="<?php echo $settingID; ?> " class="radio_wrapper"> <?php foreach ($items as $value => $text) { $counter++; $radioID = $settingID . "_" . $counter; $strChecked = ""; if ($value == $setting["value"]) { $strChecked = " checked"; } $strDisabled = ""; if ($isDisabled) { $strDisabled = 'disabled = "disabled"'; } $props = "style=\"cursor:pointer;\" {$strChecked} {$strDisabled}"; ?> <input type="radio" id="<?php echo $radioID; ?> " value="<?php echo $value; ?> " name="<?php echo $settingName; ?> " <?php echo $props; ?> /> <label for="<?php echo $radioID; ?> " ><?php echo $text; ?> </label> <?php } ?> </span> <?php }
/** * get front html from data */ public function getHtmlFrontFromData($data) { $catID = UniteFunctionsUG::getVal($data, "catid"); $galleryID = UniteFunctionsUG::getVal($data, "galleryID"); UniteFunctionsUG::validateNumeric($catID, "category id"); if (empty($galleryID)) { UniteFunctionsUG::throwError("The gallery ID not given"); } //get thumb resolution param from the gallery $gallery = new UniteGalleryGallery(); $gallery->initByID($galleryID); //validate if enable categories $enableCatTabs = $gallery->getParam('enable_category_tabs'); $enableCatTabs = UniteFunctionsUG::strToBool($enableCatTabs); if ($enableCatTabs == false) { UniteFunctionsUG::throwError("The tabs functionality disabled"); } //check that the category id inside the params $params = $gallery->getParams(); $tabCatIDs = $gallery->getParam("categorytabs_ids"); $arrTabIDs = explode(",", $tabCatIDs); if (in_array($catID, $arrTabIDs) == false) { UniteFunctionsUG::throwError("Get items not alowed for this category"); } //get thumb size $thumbSize = $gallery->getParam("thumb_resolution"); $bigImageSize = $gallery->getParam("big_image_resolution"); //get arrItems $arrItems = $this->getCatItems($catID); //get items html $htmlItems = $this->getItemsHtmlFront($arrItems, $thumbSize, $bigImageSize); return $htmlItems; }