Example #1
0
 /**
  * 
  * delete rows
  */
 public function delete($table, $where)
 {
     UniteFunctionsRev::validateNotEmpty($table, "table name");
     UniteFunctionsRev::validateNotEmpty($where, "where");
     $query = "delete from {$table} where {$where}";
     $this->wpdb->query($query);
     $this->checkForErrors("Delete query error");
 }
Example #2
0
 /**
  *
  * delete rows
  */
 public function delete($table, $where)
 {
     UniteFunctionsRev::validateNotEmpty($table, "table name");
     UniteFunctionsRev::validateNotEmpty($where, "where");
     list($field, $value) = explode('=', $where);
     $collection = Mage::getModel('nwdrevslider/' . $table)->getCollection();
     $collection->addFieldToFilter($field, trim($value, '"\''));
     foreach ($collection as $_item) {
         $_item->delete();
     }
 }
 /**
  * 
  * update slide image from data
  */
 public function updateSlideImageFromData($data)
 {
     $sliderID = UniteFunctionsRev::getVal($data, "slider_id");
     $slider = new RevSlider();
     $slider->initByID($sliderID);
     $slideID = UniteFunctionsRev::getVal($data, "slide_id");
     $urlImage = UniteFunctionsRev::getVal($data, "url_image");
     UniteFunctionsRev::validateNotEmpty($urlImage);
     $imageID = UniteFunctionsRev::getVal($data, "image_id");
     if ($slider->isSlidesFromPosts()) {
         if (!empty($imageID)) {
             UniteFunctionsWPRev::updatePostThumbnail($slideID, $imageID);
         }
     } else {
         $this->initByID($slideID);
         $arrUpdate = array();
         $arrUpdate["image"] = $urlImage;
         $arrUpdate["image_id"] = $imageID;
         $this->updateParamsInDB($arrUpdate);
     }
     return $urlImage;
 }
Example #4
0
 public function loadXMLFile($filepath)
 {
     if (!file_exists($filepath)) {
         UniteFunctionsRev::throwError("File: '{$filepath}' not exists!!!");
     }
     $obj = simplexml_load_file($filepath);
     if (empty($obj)) {
         UniteFunctionsRev::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) UniteFunctionsRev::getVal($attribs, "name");
         $sapLabel = (string) UniteFunctionsRev::getVal($attribs, "label");
         if ($sapLabel != '' && isset(RevsliderPrestashop::$lang[$sapLabel])) {
             $sapLabel = RevsliderPrestashop::$lang[$sapLabel];
         }
         $sapIcon = (string) UniteFunctionsRev::getVal($attribs, "icon");
         UniteFunctionsRev::validateNotEmpty($sapName, "sapName");
         UniteFunctionsRev::validateNotEmpty($sapLabel, "sapLabel");
         $this->addSap($sapLabel, $sapName, false, $sapIcon);
         //--- add fields
         $fieldset = (array) $fieldset;
         $fields = $fieldset["field"];
         if (is_array($fields) == false) {
             $fields = array($fields);
         }
         foreach ($fields as $field) {
             $attribs = $field->attributes();
             $fieldType = (string) UniteFunctionsRev::getVal($attribs, "type");
             $fieldName = (string) UniteFunctionsRev::getVal($attribs, "name");
             $fieldLabel = (string) UniteFunctionsRev::getVal($attribs, "label");
             if ($fieldLabel != '' && isset(RevsliderPrestashop::$lang[$fieldLabel])) {
                 $fieldLabel = RevsliderPrestashop::$lang[$fieldLabel];
             }
             $fieldDefaultValue = (string) UniteFunctionsRev::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:
             UniteFunctionsRev::validateNotEmpty($fieldType, "type");
             //validate name
             if ($fieldType != self::TYPE_HR && $fieldType != self::TYPE_CONTROL && $fieldType != "bulk_control_start" && $fieldType != "bulk_control_end") {
                 UniteFunctionsRev::validateNotEmpty($fieldName, "name");
             }
             switch ($fieldType) {
                 case self::TYPE_CHECKBOX:
                     $fieldDefaultValue = UniteFunctionsRev::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();
                     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_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, $arrParams);
                     break;
                 case self::TYPE_CONTROL:
                     $parent = UniteFunctionsRev::getVal($arrParams, "parent");
                     $child = UniteFunctionsRev::getVal($arrParams, "child");
                     $ctype = UniteFunctionsRev::getVal($arrParams, "ctype");
                     $value = UniteFunctionsRev::getVal($arrParams, "value");
                     $this->addControl($parent, $child, $ctype, $value);
                     break;
                 case "bulk_control_start":
                     $parent = UniteFunctionsRev::getVal($arrParams, "parent");
                     $ctype = UniteFunctionsRev::getVal($arrParams, "ctype");
                     $value = UniteFunctionsRev::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:
                     UniteFunctionsRev::throwError("wrong type: {$fieldType}");
                     break;
             }
         }
     }
 }
 /**
  * 
  * replace image urls
  */
 public function replaceImageUrlsFromData($data)
 {
     $sliderID = UniteFunctionsRev::getVal($data, "sliderid");
     $urlFrom = UniteFunctionsRev::getVal($data, "url_from");
     UniteFunctionsRev::validateNotEmpty($urlFrom, "url from");
     $urlTo = UniteFunctionsRev::getVal($data, "url_to");
     $this->initByID($sliderID);
     $arrSildes = $this->getSlides();
     foreach ($arrSildes as $slide) {
         //$slide1 = new RevSlide();
         $slide->replaceImageUrls($urlFrom, $urlTo);
     }
 }
 /**
  * 
  * update slide image from data
  */
 public function updateSlideImageFromData($data)
 {
     $slideID = UniteFunctionsRev::getVal($data, "slide_id");
     $this->initByID($slideID);
     $urlImage = UniteFunctionsRev::getVal($data, "url_image");
     UniteFunctionsRev::validateNotEmpty($urlImage);
     $arrUpdate = array();
     $arrUpdate["image"] = $urlImage;
     $this->updateParamsInDB($arrUpdate);
     return $urlImage;
 }
 /**
  * 
  * duplicate slide in db
  */
 public function duplicateSlide($slideID)
 {
     $slide = $this->getSlide($slideID);
     $sliderID = $slide["sliderid"];
     $order = $slide["ordering"];
     $newOrder = $order + 1;
     $this->shiftOrder($sliderID, $newOrder);
     //do duplication
     $sqlSelect = "select " . GlobalsUniteRev::FIELDS_SLIDE . " from " . GlobalsUniteRev::TABLE_SLIDES . " where id={$slideID}";
     $sqlInsert = "insert into " . GlobalsUniteRev::TABLE_SLIDES . " (" . GlobalsUniteRev::FIELDS_SLIDE . ") ({$sqlSelect})";
     $this->db->runSql($sqlInsert);
     $lastID = $this->db->getLastInsertID();
     UniteFunctionsRev::validateNotEmpty($lastID, "last insert id");
     //update order
     $arrUpdate = array("ordering" => $newOrder);
     $this->db->update(GlobalsUniteRev::TABLE_SLIDES, $arrUpdate, "id={$lastID}");
     return $lastID;
 }
    /**
     * 
     * output slider body
     */
    private function putBody()
    {
        $params = $this->params;
        try {
            $bannerWidth = $params->get("slider_width");
            $bannerHeight = $params->get("slider_height");
            UniteFunctionsRev::validateNotEmpty($bannerWidth, "banner width");
            UniteFunctionsRev::validateNotEmpty($bannerHeight, "banner height");
            $sliderType = $params->get("slider_type", "fixed");
            //set wrapper height
            $wrapperHeigh = $bannerHeight;
            //add thumb height
            if ($params->get("navigaion_type", "none") == "thumb") {
                $wrapperHeigh += $params->get("thumb_height");
            }
            $this->sliderHtmlID = "rev_slider_" . $this->sliderID . "_" . self::$counter;
            $this->sliderHtmlID_wrapper = $this->sliderHtmlID . "_wrapper";
            $containerStyle = "";
            //set position:
            $sliderPosition = $params->get("position", "center");
            switch ($sliderPosition) {
                case "center":
                default:
                    $containerStyle .= "margin:0px auto;";
                    break;
                case "left":
                    $containerStyle .= "float:left;";
                    break;
                case "right":
                    $containerStyle .= "float:right;";
                    break;
            }
            //add background color
            $backgrondColor = trim($params->get("background_color"));
            if (!empty($backgrondColor)) {
                $containerStyle .= "background-color:{$backgrondColor};";
            }
            //set padding
            $containerStyle .= "padding:" . $params->get("padding", "5") . "px;";
            //set margin:
            if ($sliderPosition != "center") {
                $containerStyle .= "margin-left:" . $params->get("margin_left", "0") . "px;";
                $containerStyle .= "margin-right:" . $params->get("margin_right", "0") . "px;";
            }
            $containerStyle .= "margin-top:" . $params->get("margin_top", "0") . "px;";
            $containerStyle .= "margin-bottom:" . $params->get("margin_bottom", "0") . "px;";
            //set height and width:
            $bannerStyle = "display:none;";
            //add background image (to banner style)
            $showBackgroundImage = $params->get("show_background_image", "false");
            if ($showBackgroundImage == "true") {
                $backgroundImage = $params->get("background_image");
                if (!empty($backgroundImage)) {
                    $bannerStyle .= "background-image:url({$backgroundImage});background-repeat:no-repeat;";
                }
            }
            //set wrapper and slider class:
            $sliderWrapperClass = "rev_slider_wrapper";
            $sliderClass = "rev_slider";
            switch ($sliderType) {
                default:
                case "fixed":
                    $bannerStyle .= "height:{$bannerHeight}px;width:{$bannerWidth}px;";
                    $containerStyle .= "height:{$bannerHeight}px;width:{$bannerWidth}px;";
                    break;
                case "responsitive":
                    $this->putResponsitiveStyles();
                    break;
                case "fullwidth":
                    $sliderWrapperClass .= " fullwidthbanner-container";
                    $sliderClass .= " fullwidthabanner";
                    $bannerStyle .= "max-height:{$bannerHeight}px;height:{$bannerHeight}px;";
                    $containerStyle .= "max-height:{$bannerHeight}px;";
                    break;
            }
            $htmlTimerBar = "";
            if ($params->get("show_timerbar", "true") == "true") {
                $timerPosition = $params->get("timebar_position", "top");
                if ($timerPosition == "top") {
                    $htmlTimerBar = '<div class="tp-bannertimer"></div>';
                } else {
                    $htmlTimerBar = '<div class="tp-bannertimer tp-bottom"></div>';
                }
            }
            $containerStyle .= "direction:ltr;";
            // put js in body
            if ($this->putJSInBody == true) {
                ?>
						<script type="text/javascript" src="<?php 
                echo $this->urlJsPlugins;
                ?>
"></script>
						<script type="text/javascript" src="<?php 
                echo $this->urlJsRevolution;
                ?>
"></script>
					<?php 
            }
            ?>
	
				
				<!-- START REVOLUTION SLIDER ver. <?php 
            echo GlobalsUniteRev::$version;
            ?>
 -->
				
				<div id="<?php 
            echo $this->sliderHtmlID_wrapper;
            ?>
" class="<?php 
            echo $sliderWrapperClass;
            ?>
" style="<?php 
            echo $containerStyle;
            ?>
">
					<div id="<?php 
            echo $this->sliderHtmlID;
            ?>
" class="<?php 
            echo $sliderClass;
            ?>
" style="<?php 
            echo $bannerStyle;
            ?>
">						
						<?php 
            $this->putSlides();
            ?>
						<?php 
            echo $htmlTimerBar;
            ?>
					</div>
				</div>
				<?php 
            $this->putJS();
            ?>
				<!-- END REVOLUTION SLIDER -->
				<?php 
        } catch (Exception $e) {
            $message = $e->getMessage();
            $this->putErrorMessage($message);
        }
    }
 /**
  * 
  * operate actions
  */
 public function operate()
 {
     $this->operations = new HelperUniteOperationsRev();
     $this->action = UniteFunctionsRev::getPostVariable("action");
     if (empty($this->action)) {
         $this->action = UniteFunctionsRev::getPostVariable("client_action");
     }
     $this->data = UniteFunctionsRev::getPostVariable("data", array());
     try {
         switch ($this->action) {
             case "add_slide":
                 $slideID = $this->operations->addSlideFromData($this->data);
                 UniteFunctionsRev::ajaxResponseSuccess("");
                 break;
             case "update_slider_duplicate":
                 $sliderID = $this->saveSlider();
                 $newSliderID = $this->operations->duplicateSlider($sliderID);
                 UniteFunctionsRev::ajaxResponseData(array("newSliderID" => $newSliderID));
                 break;
             case "update_slider":
                 $sliderID = $this->saveSlider();
                 UniteFunctionsRev::ajaxResponseData(array("sliderID" => $sliderID));
                 break;
             case "update_slide_close":
             case "update_slide_new":
             case "update_slide":
                 $slideID = $this->saveSlide();
                 UniteFunctionsRev::ajaxResponseData(array("slideID" => $slideID));
                 break;
             case "update_slide_duplicate":
                 $slideID = $this->saveSlide();
                 $newSlideID = $this->operations->duplicateSlide($slideID);
                 UniteFunctionsRev::ajaxResponseData(array("slideID" => $newSlideID));
                 break;
             case "get_captions_css":
                 $contentCSS = $this->operations->getCaptionsContent();
                 UniteFunctionsRev::ajaxResponseData($contentCSS);
                 break;
             case "update_captions_css":
                 $arrCaptions = $this->operations->updateCaptionsContentData($this->data);
                 UniteFunctionsRev::ajaxResponseSuccess("CSS file saved succesfully!", array("arrCaptions" => $arrCaptions));
                 break;
             case "restore_captions_css":
                 $this->operations->restoreCaptionsCss();
                 $contentCSS = $this->operations->getCaptionsContentOgirinal();
                 UniteFunctionsRev::ajaxResponseData($contentCSS);
                 break;
             case "get_release_log":
                 $content = HelperUniteRev::getReleaseLogContent();
                 UniteFunctionsRev::ajaxResponseData($content);
                 break;
             case "preview_slide":
                 $this->operations->putSlidePreviewByData($this->data);
                 break;
             case "preview_slider":
                 $sliderID = UniteFunctionsRev::getPostVariable("sliderid");
                 UniteFunctionsRev::validateNotEmpty($sliderID, "SliderID");
                 $this->operations->previewOutput($sliderID);
                 break;
             case "update_items_order":
                 $this->operations->updateSlidesOrderFromData($this->data);
                 UniteFunctionsRev::ajaxResponseSuccess("order updated");
                 break;
             case "toggle_publish_state":
                 //publish / unpublish item
                 $newState = $this->operations->publishUnpublishItemFromData($this->data);
                 UniteFunctionsRev::ajaxResponseSuccess("state updated", array("newstate" => $newState));
                 break;
             case "delete_slide":
                 $this->operations->deleteSlideFromData($this->data);
                 UniteFunctionsRev::ajaxResponseSuccess("Slide Deleted");
                 break;
             case "duplicate_slide":
                 $this->operations->duplicateSlideFromData($this->data);
                 UniteFunctionsRev::ajaxResponseSuccess("Slide Duplicated");
                 break;
             default:
                 UniteFunctionsRev::ajaxResponseError("ajax action not found: " . $this->action);
                 break;
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         UniteFunctionsRev::ajaxResponseError($message);
     }
     exit;
 }
 /**
  * 
  * update slides order from data
  */
 public function updateSlidesOrderFromData($data)
 {
     $sliderID = UniteFunctionsRev::getVal($data, "sliderID");
     $arrIDs = UniteFunctionsRev::getVal($data, "arrIDs");
     UniteFunctionsRev::validateNotEmpty($arrIDs, "slides");
     $this->initByID($sliderID);
     foreach ($arrIDs as $index => $slideID) {
         $order = $index + 1;
         $arrUpdate = array("slide_order" => $order);
         $where = array("id" => $slideID);
         $this->db->update(GlobalsRevSlider::$table_slides, $arrUpdate, $where);
     }
 }
Example #11
0
 /**
  * 
  * insert variables to some table
  */
 public function update($tableName, $arrData, $where)
 {
     UniteFunctionsRev::validateNotEmpty($tableName, "table cannot be empty");
     UniteFunctionsRev::validateNotEmpty($where, "where cannot be empty");
     if (is_array($where)) {
         $where = $this->getWhereString($where);
     }
     $strFields = "";
     foreach ($arrData as $field => $value) {
         $value = "'" . $this->escape($value) . "'";
         if ($strFields != "") {
             $strFields .= ",";
         }
         $strFields .= "{$field}={$value}";
     }
     $updateQuery = "update {$tableName} set {$strFields} where {$where}";
     //$updateQuery = "update #__revslider_css set params='{\"font-size\":\"50px\",\"line-height\":\"67px\",\"font-weight\":\"700\",\"font-family\":\"\'Roboto\', sans-serif\",\"color\":\"#ffffff\",\"text-decoration\":\"none\",\"background-color\":\"rgba(141, 68, 173, 0.65)\",\"padding\":\"0px 15px 5px 15px\",\"border-width\":\"0px\",\"border-color\":\"rgb(34, 34, 34)\",\"border-style\":\"none\"}',hover='\"\"',settings='{\"hover\":\"false\"}' where handle = '.tp-caption.roboto'";
     $numRows = $this->runSql($updateQuery, "update error");
     //dmp($updateQuery);dmp($numRows);exit();
     return $numRows;
 }
Example #12
0
 /**
  * 
  * insert variables to some table
  */
 public function update($tableName, $arrData, $where)
 {
     UniteFunctionsRev::validateNotEmpty($tableName, "table cannot be empty");
     UniteFunctionsRev::validateNotEmpty($where, "where cannot be empty");
     $strFields = "";
     foreach ($arrData as $field => $value) {
         $value = "'" . $this->escape($value) . "'";
         if ($strFields != "") {
             $strFields .= ",";
         }
         $strFields .= "{$field}={$value}";
     }
     $updateQuery = "update {$tableName} set {$strFields} where {$where}";
     $numRows = $this->runSql($updateQuery, "update error");
     return $numRows;
 }
Example #13
0
 /**
  * 
  * pub bullets set html
  * @param mixed $set - can be array or set name
  */
 public static function getBulletsHtml($set, $num = 5)
 {
     if ($num < 3) {
         $num = 3;
     }
     if (gettype($set) == "string") {
         $set = HelperUniteRev::getBulletsSet($set);
     }
     $options = $set["options"];
     $imgLeft = UniteFunctionsRev::getVal($set, "url_bgleft");
     $imgRight = UniteFunctionsRev::getVal($set, "url_bgright");
     $imgCenter = UniteFunctionsRev::getVal($set, "url_bgrepeat");
     $idBackground = false;
     if (!empty($imgCenter)) {
         $idBackground = true;
         //validate background fields
         UniteFunctionsRev::validateArrayFieldExists($options, "bg_height,bg_left_width,bg_right_width,padding_top", "getBulletsHtml, background field not found in options");
         UniteFunctionsRev::validateNotEmpty($imgRight, "right image");
         UniteFunctionsRev::validateNotEmpty($imgLeft, "left image");
     }
     $space_middle = UniteFunctionsRev::getVal($options, "space_middle", 3);
     $html = "";
     //Width Background
     if ($idBackground == true) {
         $bgHeight = $options["bg_height"];
         $bgWidthLeft = $options["bg_left_width"];
         $bgWidthRight = $options["bg_right_width"];
         $paddingTop = $options["padding_top"];
         $styleLeft = "float:left;height:{$bgHeight}px;width:{$bgWidthLeft}px;background-image:url(\"{$imgLeft}\");background-repeat:no-repeat;";
         $styleRight = "float:left;height:{$bgHeight}px;width:{$bgWidthLeft}px;background-image:url(\"{$imgRight}\");background-repeat:no-repeat;";
         $styleCenter = "float:left;height:{$bgHeight}px;background-image:url(\"{$imgCenter}\");background-repeat:releat-x;";
         $html .= "<div class='bullets_left' style='{$styleLeft}' ></div>";
         $html .= "<div class='bullets_middle' style='{$styleCenter}'>";
         $html .= "<div class='bullets_inner' style='padding-top:" . $paddingTop . "px;'>";
         $html .= '<ul>';
         for ($i = 0; $i < $num; $i++) {
             $urlBullet = $set["url_normal"];
             if ($i == 1) {
                 $urlBullet = $set["url_active"];
             }
             $styleLI = "";
             if ($i > 0) {
                 $styleLI = "margin-left:" . $space_middle . "px";
             }
             $html .= "<li style='{$styleLI}'><img src='{$urlBullet}'/></li>";
         }
         $html .= '</ul>';
         $html .= '</div>';
         $html .= '</div>';
         $html .= "<div class='bullets_right' style='{$styleRight}'></div>";
     } else {
         //no background:
         $html .= '<ul>';
         for ($i = 0; $i < $num; $i++) {
             $urlBullet = $set["url_normal"];
             if ($i == 1) {
                 $urlBullet = $set["url_active"];
             }
             $styleLI = "";
             if ($i > 0) {
                 $styleLI = "margin-left:" . $space_middle . "px";
             }
             $html .= "<li style='{$styleLI}'><img src='{$urlBullet}'/></li>";
         }
         $html .= '</ul>';
     }
     $html .= '<div class="clear"></div>';
     return $html;
 }