PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/revslider/inc_php/revslider_operations.class.php

https://github.com/alniko009/magic
PHP | 410 lines | 280 code | 57 blank | 73 comment | 9 complexity | 917f19eecc0bbef60232ced9e3549c83 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. class RevOperations extends UniteElementsBaseRev{
  3. /**
  4. *
  5. * get button classes
  6. */
  7. public function getButtonClasses(){
  8. $arrButtons = array(
  9. "red"=>"Red Button",
  10. "green"=>"Green Button",
  11. "blue"=>"Blue Button",
  12. "orange"=>"Orange Button",
  13. "darkgrey"=>"Darkgrey Button",
  14. "lightgrey"=>"Lightgrey Button",
  15. );
  16. return($arrButtons);
  17. }
  18. /**
  19. *
  20. * get easing functions array
  21. */
  22. public function getArrEasing($toAssoc = true){
  23. $arrEasing = array(
  24. "easeOutBack",
  25. "easeInQuad",
  26. "easeOutQuad",
  27. "easeInOutQuad",
  28. "easeInCubic",
  29. "easeOutCubic",
  30. "easeInOutCubic",
  31. "easeInQuart",
  32. "easeOutQuart",
  33. "easeInOutQuart",
  34. "easeInQuint",
  35. "easeOutQuint",
  36. "easeInOutQuint",
  37. "easeInSine",
  38. "easeOutSine",
  39. "easeInOutSine",
  40. "easeInExpo",
  41. "easeOutExpo",
  42. "easeInOutExpo",
  43. "easeInCirc",
  44. "easeOutCirc",
  45. "easeInOutCirc",
  46. "easeInElastic",
  47. "easeOutElastic",
  48. "easeInOutElastic",
  49. "easeInBack",
  50. "easeOutBack",
  51. "easeInOutBack",
  52. "easeInBounce",
  53. "easeOutBounce",
  54. "easeInOutBounce"
  55. );
  56. if($toAssoc)
  57. $arrEasing = UniteFunctionsRev::arrayToAssoc($arrEasing);
  58. return($arrEasing);
  59. }
  60. /**
  61. *
  62. * get arr end easing
  63. */
  64. public function getArrEndEasing(){
  65. $arrEasing = $this->getArrEasing(false);
  66. $arrEasing = array_merge(array("nothing"),$arrEasing);
  67. $arrEasing = UniteFunctionsRev::arrayToAssoc($arrEasing);
  68. $arrEasing["nothing"] = "No Change";
  69. return($arrEasing);
  70. }
  71. /**
  72. *
  73. * get transition array
  74. */
  75. public function getArrTransition(){
  76. $arrTransition = array(
  77. "random"=>"Random",
  78. "fade"=>"Fade",
  79. "slidehorizontal"=>"Slide Horizontal",
  80. "slidevertical"=>"Slide Vertical",
  81. "boxslide"=>"Box Slide",
  82. "boxfade"=>"Box Fade",
  83. "slotzoom-horizontal"=>"SlotZoom Horizontal",
  84. "slotslide-horizontal"=>"SlotSlide Horizontal",
  85. "slotfade-horizontal"=>"SlotFade Horizontal",
  86. "slotzoom-vertical"=>"SlotZoom Vertical",
  87. "slotslide-vertical"=>"SlotSlide Vertical",
  88. "slotfade-vertical"=>"SlotFade Vertical",
  89. "curtain-1"=>"Curtain 1",
  90. "curtain-2"=>"Curtain 2",
  91. "curtain-3"=>"Curtain 3",
  92. "slideleft"=>"Slide Left",
  93. "slideright"=>"Slide Right",
  94. "slideup"=>"Slide Up",
  95. "slidedown"=>"Slide Down",
  96. "papercut"=>"Premium - Paper Cut",
  97. "3dcurtain-horizontal"=>"Premium - 3D Curtain Horizontal",
  98. "3dcurtain-vertical"=>"Premium - 3D Curtain Vertical",
  99. "flyin"=>"Premium - Fly In",
  100. "turnoff"=>"Premium - Turn Off",
  101. "cubic"=>"Premium - Cubic"
  102. );
  103. return($arrTransition);
  104. }
  105. /**
  106. *
  107. * get random transition
  108. */
  109. public static function getRandomTransition(){
  110. $arrTrans = self::getArrTransition();
  111. unset($arrTrans["random"]);
  112. $trans = array_rand($arrTrans);
  113. return($trans);
  114. }
  115. /**
  116. *
  117. * get animations array
  118. */
  119. public function getArrAnimations(){
  120. $arrAnimations = array(
  121. "fade"=>"Fade",
  122. "sft"=>"Short from Top",
  123. "sfb"=>"Short from Bottom",
  124. "sfr"=>"Short from Right",
  125. "sfl"=>"Short from Left",
  126. "lft"=>"Long from Top",
  127. "lfb"=>"Long from Bottom",
  128. "lfr"=>"Long from Right",
  129. "lfl"=>"Long from Left",
  130. "randomrotate"=>"Random Rotate"
  131. );
  132. return($arrAnimations);
  133. }
  134. /**
  135. *
  136. * get "end" animations array
  137. */
  138. public function getArrEndAnimations(){
  139. $arrAnimations = array(
  140. "auto"=>"Choose Automatic",
  141. "fadeout"=>"Fade Out",
  142. "stt"=>"Short to Top",
  143. "stb"=>"Short to Bottom",
  144. "stl"=>"Short to Left",
  145. "str"=>"Short to Right",
  146. "ltt"=>"Long to Top",
  147. "ltb"=>"Long to Bottom",
  148. "ltl"=>"Long to Left",
  149. "ltr"=>"Long to Right",
  150. "randomrotateout"=>"Random Rotate Out"
  151. );
  152. return($arrAnimations);
  153. }
  154. /**
  155. *
  156. * parse css file and get the classes from there.
  157. */
  158. public function getArrCaptionClasses($contentCSS){
  159. //parse css captions file
  160. $parser = new UniteCssParserRev();
  161. $parser->initContent($contentCSS);
  162. $arrCaptionClasses = $parser->getArrClasses();
  163. return($arrCaptionClasses);
  164. }
  165. /**
  166. *
  167. * get the select classes html for putting in the html by ajax
  168. */
  169. private function getHtmlSelectCaptionClasses($contentCSS){
  170. $arrCaptions = $this->getArrCaptionClasses($contentCSS);
  171. $htmlSelect = UniteFunctionsRev::getHTMLSelect($arrCaptions,"","id='layer_caption' name='layer_caption'",true);
  172. return($htmlSelect);
  173. }
  174. /**
  175. *
  176. * get contents of the css file
  177. */
  178. public function getCaptionsContent(){
  179. $contentCSS = file_get_contents(GlobalsRevSlider::$filepath_captions);
  180. return($contentCSS);
  181. }
  182. /**
  183. *
  184. * update captions css file content
  185. * @return new captions html select
  186. */
  187. public function updateCaptionsContentData($content){
  188. $content = stripslashes($content);
  189. $content = trim($content);
  190. UniteFunctionsRev::writeFile($content, GlobalsRevSlider::$filepath_captions);
  191. //output captions array
  192. $arrCaptions = $this->getArrCaptionClasses($content);
  193. return($arrCaptions);
  194. }
  195. /**
  196. *
  197. * copy from original css file to the captions css.
  198. */
  199. public function restoreCaptionsCss(){
  200. if(!file_exists(GlobalsRevSlider::$filepath_captions_original))
  201. UniteFunctionsRev::throwError("The original css file: captions_original.css doesn't exists.");
  202. $success = @copy(GlobalsRevSlider::$filepath_captions_original, GlobalsRevSlider::$filepath_captions);
  203. if($success == false)
  204. UniteFunctionsRev::throwError("Failed to restore from the original captions file.");
  205. }
  206. /**
  207. *
  208. * preview slider output
  209. * if output object is null - create object
  210. */
  211. public function previewOutput($sliderID,$output = null){
  212. if($sliderID == "empty_output"){
  213. $this->loadingMessageOutput();
  214. exit();
  215. }
  216. if($output == null)
  217. $output = new RevSliderOutput();
  218. $slider = new RevSlider();
  219. $slider->initByID($sliderID);
  220. $isWpmlExists = UniteWpmlRev::isWpmlExists();
  221. $useWpml = $slider->getParam("use_wpml","off");
  222. $wpmlActive = false;
  223. if($isWpmlExists && $useWpml == "on"){
  224. $wpmlActive = true;
  225. $arrLanguages = UniteWpmlRev::getArrLanguages(false);
  226. //set current lang to output
  227. $currentLang = UniteFunctionsRev::getPostGetVariable("lang");
  228. if(empty($currentLang))
  229. $currentLang = UniteWpmlRev::getCurrentLang();
  230. if(empty($currentLang))
  231. $currentLang = $arrLanguages[0];
  232. $output->setLang($currentLang);
  233. $selectLangChoose = UniteFunctionsRev::getHTMLSelect($arrLanguages,$currentLang,"id='select_langs'",true);
  234. }
  235. $output->setPreviewMode();
  236. //put the output html
  237. $urlPlugin = RevSliderAdmin::$url_plugin."rs-plugin/";
  238. $urlPreviewPattern = UniteBaseClassRev::$url_ajax_actions."&client_action=preview_slider&sliderid={$sliderID}&lang=[lang]";
  239. ?>
  240. <html>
  241. <head>
  242. <link rel='stylesheet' href='<?php echo $urlPlugin?>css/settings.css' type='text/css' media='all' />
  243. <link rel='stylesheet' href='<?php echo $urlPlugin?>css/captions.css' type='text/css' media='all' />
  244. <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
  245. <script type='text/javascript' src='<?php echo $urlPlugin?>js/jquery.themepunch.revolution.min.js'></script>
  246. </head>
  247. <body style="padding:0px;margin:0px;">
  248. <?php if($wpmlActive == true):?>
  249. <div style="margin-bottom:10px;text-align:center;">
  250. <?php _e("Choose language")?>: <?php echo $selectLangChoose?>
  251. </div>
  252. <script type="text/javascript">
  253. var g_previewPattern = '<?php echo $urlPreviewPattern?>';
  254. jQuery("#select_langs").change(function(){
  255. var lang = this.value;
  256. var pattern = g_previewPattern;
  257. var urlPreview = pattern.replace("[lang]",lang);
  258. location.href = urlPreview;
  259. });
  260. </script>
  261. <?php endif?>
  262. <?php
  263. $output->putSliderBase($sliderID);
  264. ?>
  265. </body>
  266. </html>
  267. <?php
  268. exit();
  269. }
  270. /**
  271. *
  272. * output loading message
  273. */
  274. public function loadingMessageOutput(){
  275. ?>
  276. <div class="message_loading_preview">Loading Preview...</div>
  277. <?php
  278. }
  279. /**
  280. *
  281. * put slide preview by data
  282. */
  283. public function putSlidePreviewByData($data){
  284. if($data == "empty_output"){
  285. $this->loadingMessageOutput();
  286. exit();
  287. }
  288. $data = UniteFunctionsRev::jsonDecodeFromClientSide($data);
  289. $slideID = $data["slideid"];
  290. $slide = new RevSlide();
  291. $slide->initByID($slideID);
  292. $sliderID = $slide->getSliderID();
  293. $output = new RevSliderOutput();
  294. $output->setOneSlideMode($data);
  295. $this->previewOutput($sliderID,$output);
  296. }
  297. /**
  298. * update general settings
  299. */
  300. public function updateGeneralSettings($data){
  301. $strSettings = serialize($data);
  302. $params = new RevSliderParams();
  303. $params->updateFieldInDB("general", $strSettings);
  304. }
  305. /**
  306. *
  307. * get general settigns values.
  308. */
  309. public function getGeneralSettingsValues(){
  310. $params = new RevSliderParams();
  311. $strSettings = $params->getFieldFromDB("general");
  312. $arrValues = array();
  313. if(!empty($strSettings))
  314. $arrValues = unserialize($strSettings);
  315. return($arrValues);
  316. }
  317. /**
  318. * update language filter in session
  319. */
  320. public function updateLangFilter($data){
  321. $lang = UniteFunctionsRev::getVal($data, "lang");
  322. $sliderID = UniteFunctionsRev::getVal($data, "sliderid");
  323. if(!isset($_SESSION))
  324. return(false);
  325. $_SESSION["revslider_lang_filter"] = $lang;
  326. return($sliderID);
  327. }
  328. /**
  329. *
  330. * get lang filter value from session
  331. */
  332. public function getLangFilterValue(){
  333. if(!isset($_SESSION))
  334. return("all");
  335. $langFitler = UniteFunctionsRev::getVal($_SESSION, "revslider_lang_filter","all");
  336. return($langFitler);
  337. }
  338. }
  339. ?>