PageRenderTime 36ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/leoblog/classes/LeoblogOwlCarousel.php

https://gitlab.com/elasa/shop2.elasa.ir
PHP | 363 lines | 321 code | 11 blank | 31 comment | 2 complexity | 05e63def2f7e0acf6bc3385476950e12 MD5 | raw file
  1. <?php
  2. /**
  3. * Leo Prestashop Blockleoblogs for Prestashop 1.6.x
  4. *
  5. * @package blockleoblogs
  6. * @version 3.0
  7. * @author http://www.leotheme.com
  8. * @copyright Copyright (C) October 2013 LeoThemes.com <@emai:leotheme@gmail.com>
  9. * <info@leotheme.com>.All rights reserved.
  10. * @license GNU General Public License version 2
  11. */
  12. if (!class_exists('LeoblogOwlCarousel'))
  13. {
  14. class LeoblogOwlCarousel
  15. {
  16. const MODULE_NAME = 'leotempcp';
  17. public static function l($string, $specific = false, $name = '')
  18. {
  19. if (empty($name))
  20. {
  21. # validate module
  22. $name = self::MODULE_NAME;
  23. }
  24. return Translate::getModuleTranslation($name, $string, ($specific) ? $specific : $name);
  25. }
  26. const ENABLE = '1';
  27. const DISABLE = '0';
  28. public static function getEnableOptions()
  29. {
  30. return array(array(
  31. 'id' => 'active_on',
  32. 'value' => self::ENABLE,
  33. 'label' => self::l('Enabled')
  34. ),
  35. array(
  36. 'id' => 'active_off',
  37. 'value' => self::DISABLE,
  38. 'label' => self::l('Disabled')
  39. ));
  40. }
  41. const CAROUSEL_BOOTSTRAP = 'carousel_bootstrap';
  42. const CAROUSEL_OWL = 'carousel_owl';
  43. public static function getCaroulseOptions()
  44. {
  45. return array(
  46. array(
  47. 'value' => self::CAROUSEL_BOOTSTRAP,
  48. 'name' => self::l('Bootstrap'),
  49. ),
  50. array(
  51. 'value' => self::CAROUSEL_OWL,
  52. 'name' => self::l('Own Carousel'),
  53. ),
  54. );
  55. }
  56. const TRANSITIONSTYLE_FADE = 'fade';
  57. const TRANSITIONSTYLE_BACKSLIDE = 'backSlide';
  58. const TRANSITIONSTYLE_GODOWN = 'goDown';
  59. const TRANSITIONSTYLE_FADEUP = 'fadeUp';
  60. public static function getTransitionStyleOptions()
  61. {
  62. return array(
  63. array(
  64. 'value' => self::TRANSITIONSTYLE_FADE,
  65. 'name' => self::l('Fade'),
  66. ),
  67. array(
  68. 'value' => self::TRANSITIONSTYLE_BACKSLIDE,
  69. 'name' => self::l('Back Slide'),
  70. ),
  71. array(
  72. 'value' => self::TRANSITIONSTYLE_GODOWN,
  73. 'name' => self::l('Go Down'),
  74. ),
  75. array(
  76. 'value' => self::TRANSITIONSTYLE_FADEUP,
  77. 'name' => self::l('Fade Up'),
  78. ),
  79. );
  80. }
  81. /**
  82. * Declare owl carousel inputs of form in Backend
  83. */
  84. public function getOwlCarouselAdminFormOptions()
  85. {
  86. return array(
  87. # config for Owl Carousel - BEGIN
  88. array(
  89. 'type' => 'text',
  90. 'label' => $this->l('Items Per Row'),
  91. 'name' => 'owl_items',
  92. 'default' => 3,
  93. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  94. 'class' => 'fixed-width-xl digits',
  95. 'desc' => $this->l('This variable allows you to set the maximum amount of items displayed at a time with the widest browser width'),
  96. 'required' => true,
  97. ),
  98. array(
  99. 'type' => 'text',
  100. 'label' => $this->l('Number of rows'),
  101. 'name' => 'owl_rows',
  102. 'default' => 1,
  103. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  104. 'class' => 'fixed-width-xl digits',
  105. 'required' => true,
  106. ),
  107. array(
  108. 'type' => 'text',
  109. 'label' => $this->l('Auto Play'),
  110. 'name' => 'owl_autoPlay',
  111. 'default' => 8000,
  112. 'desc' => $this->l('Enter Time(miniseconds) to play carousel. Value 0 to stop.'),
  113. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  114. 'class' => 'fixed-width-xl digits',
  115. ),
  116. array(
  117. 'type' => 'switch',
  118. 'label' => $this->l('Stop On Hover'),
  119. 'name' => 'owl_stopOnHover',
  120. 'default' => self::ENABLE,
  121. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  122. 'values' => self::getEnableOptions(),
  123. 'desc' => $this->l('Stop "Auto Play" on mouse hover.'),
  124. ),
  125. array(
  126. 'type' => 'switch',
  127. 'label' => $this->l('Auto Height'),
  128. 'name' => 'owl_autoHeight',
  129. 'default' => self::DISABLE,
  130. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  131. 'values' => self::getEnableOptions(),
  132. ),
  133. array(
  134. 'type' => 'switch',
  135. 'label' => $this->l('Reponsive'),
  136. 'name' => 'owl_responsive',
  137. 'default' => self::ENABLE,
  138. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  139. 'values' => self::getEnableOptions(),
  140. ),
  141. /*
  142. array(
  143. 'type' => 'select',
  144. 'label' => $this->l('Transition Style'),
  145. 'name' => 'owl_transitionStyle',
  146. 'default' => LeomanagewidgetsOwlCarousel::TRANSITIONSTYLE_FADE,
  147. 'form_group_class' => 'carousel_type_sub carousel_type-' . self::CAROUSEL_OWL,
  148. 'options' => array(
  149. 'query' => LeomanagewidgetsOwlCarousel::getTransitionStyleOptions(),
  150. 'id' => 'value',
  151. 'name' => 'name'
  152. )
  153. ),
  154. */
  155. array(
  156. 'type' => 'switch',
  157. 'label' => $this->l('Mouse Drag'),
  158. 'name' => 'owl_mouseDrag',
  159. 'desc' => $this->l('Turn off/on mouse events.'),
  160. 'values' => self::getEnableOptions(),
  161. 'default' => self::ENABLE,
  162. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  163. ),
  164. array(
  165. 'type' => 'switch',
  166. 'label' => $this->l('Touch Drag'),
  167. 'name' => 'owl_touchDrag',
  168. 'desc' => $this->l('Turn off/on touch events.'),
  169. 'values' => self::getEnableOptions(),
  170. 'default' => self::ENABLE,
  171. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  172. ),
  173. array(
  174. 'type' => 'switch',
  175. 'label' => $this->l('Navigation'),
  176. 'name' => 'owl_navigation',
  177. 'desc' => $this->l('Display "next" and "prev" buttons.'),
  178. 'values' => self::getEnableOptions(),
  179. 'default' => self::ENABLE,
  180. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  181. ),
  182. array(
  183. 'type' => 'text',
  184. 'name' => 'owl_slideSpeed',
  185. 'label' => $this->l('Slide Speed'),
  186. 'desc' => $this->l('Slide speed in milliseconds. Time to next/drag/tough each item. Ex 200.'),
  187. 'default' => '200',
  188. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  189. 'class' => 'fixed-width-xl digits',
  190. ),
  191. array(
  192. 'type' => 'html',
  193. 'name' => 'noname',
  194. 'html_content' => '<div class="space"><strong>'.$this->l('Items for Screens').'</strong><hr/></div>',
  195. 'default' => 'novalue',
  196. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  197. ),
  198. array(
  199. 'type' => 'text',
  200. 'name' => 'owl_itemsDesktop',
  201. 'label' => $this->l('Items Desktop (~1199)'),
  202. 'desc' => $this->l('This allows you to preset the number of slides visible with ItemsDesktop (1199). Value 0 to disable. (Ex 4).'),
  203. 'default' => '0',
  204. 'form_group_class' => 'required carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  205. 'class' => 'digits',
  206. //'required' => 'true',
  207. ),
  208. array(
  209. 'type' => 'text',
  210. 'name' => 'owl_itemsDesktopSmall',
  211. 'label' => $this->l('Items Desktop Small (~979)'),
  212. 'desc' => $this->l('This allows you to preset the number of slides visible with itemsDesktopSmall (979px). Value 0 to disable. (Ex 3).'),
  213. 'default' => '0',
  214. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  215. 'class' => 'digits',
  216. ),
  217. array(
  218. 'type' => 'text',
  219. 'name' => 'owl_itemsTablet',
  220. 'label' => $this->l('Items Tablet (~768)'),
  221. 'desc' => $this->l('This allows you to preset the number of slides visible with itemsTablet (768). Value 0 to disable. (Ex 2).'),
  222. 'default' => '0',
  223. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  224. 'class' => 'digits',
  225. ),
  226. array(
  227. 'type' => 'text',
  228. 'name' => 'owl_itemsTabletSmall',
  229. 'label' => $this->l('Items Tablet Small (~640)'),
  230. 'desc' => $this->l('This allows you to preset the number of slides visible with itemsTabletSmall (640). Value 0 to disable. (Ex 2).'),
  231. 'default' => '0',
  232. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  233. 'class' => 'digits',
  234. ),
  235. array(
  236. 'type' => 'text',
  237. 'name' => 'owl_itemsMobile',
  238. 'label' => $this->l('Items Mobile (~479)'),
  239. 'desc' => $this->l('This allows you to preset the number of slides visible with itemsmobile (360). Value 0 to disable. (Ex 1).'),
  240. 'default' => '0',
  241. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  242. 'class' => 'digits',
  243. ),
  244. array(
  245. 'type' => 'text',
  246. 'name' => 'owl_itemsCustom',
  247. 'label' => $this->l('Items Custom'),
  248. //'desc' => $this->l('(Advance User) Example: [[0, 2], [400, 4], [700, 6], [1000, 8], [1200, 10], [1600, 16]]. The format is [x,y] whereby x=browser width and y=number of slides displayed. Value 0 to disable.'),
  249. 'desc' => $this->l('(Advance User) Example: [[320, 1], [360, 1], [480, 2], [568, 2], [600, 2], [640, 2], [768, 3], [900, 3], [960, 3], [1024, 4]]. The format is [x,y] whereby x=browser width and y=number of slides displayed. Override all above Items. Value 0 to disable.'),
  250. 'default' => '0',
  251. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  252. 'class' => 'owl_items_custom',
  253. ),
  254. array(
  255. 'type' => 'html',
  256. 'name' => 'noname',
  257. 'html_content' => '<div class="space"><strong>'.$this->l('Effect').'</strong><hr/></div>',
  258. 'default' => 'novalue',
  259. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  260. ),
  261. array(
  262. 'type' => 'switch',
  263. 'label' => $this->l('Lazy Load'),
  264. 'name' => 'owl_lazyLoad',
  265. 'default' => self::DISABLE,
  266. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  267. 'values' => self::getEnableOptions(),
  268. ),
  269. array(
  270. 'type' => 'switch',
  271. 'label' => $this->l('Lazy Effect'),
  272. 'name' => 'owl_lazyEffect',
  273. 'default' => self::ENABLE,
  274. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  275. 'values' => self::getEnableOptions(),
  276. 'desc' => $this->l('Default is fadeIn on 400ms speed.'),
  277. ),
  278. array(
  279. 'type' => 'switch',
  280. 'label' => $this->l('Lazy Follow'),
  281. 'name' => 'owl_lazyFollow',
  282. 'is_bool' => true,
  283. 'desc' => $this->l('When pagination used, it skips loading the images from pages that got skipped. It only loads the images that get displayed in viewport. If set to false, all images get loaded when pagination used. It is a sub setting of the lazy load function.'),
  284. 'values' => self::getEnableOptions(),
  285. 'default' => self::ENABLE,
  286. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  287. ),
  288. array(
  289. 'type' => 'html',
  290. 'name' => 'noname',
  291. 'html_content' => '<div class="space"><strong>'.$this->l('Pagination').'</strong><hr/></div>',
  292. 'default' => 'novalue',
  293. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  294. ),
  295. array(
  296. 'type' => 'switch',
  297. 'label' => $this->l('Show Pagination'),
  298. 'name' => 'owl_pagination',
  299. 'values' => self::getEnableOptions(),
  300. 'default' => self::ENABLE,
  301. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  302. ),
  303. array(
  304. 'type' => 'switch',
  305. 'label' => $this->l('Show Pagination Numbers'),
  306. 'name' => 'owl_paginationNumbers',
  307. 'values' => self::getEnableOptions(),
  308. 'default' => self::DISABLE,
  309. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  310. ),
  311. array(
  312. 'type' => 'text',
  313. 'name' => 'owl_paginationSpeed',
  314. 'label' => $this->l('Pagination Speed'),
  315. 'desc' => $this->l('Enter Time(miniseconds) to next/prev page. Ex 800.'),
  316. 'default' => '800',
  317. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  318. 'class' => 'digits',
  319. ),
  320. array(
  321. 'type' => 'switch',
  322. 'label' => $this->l('Rewind Nav'),
  323. 'name' => 'owl_rewindNav',
  324. 'is_bool' => true,
  325. 'desc' => $this->l('Slide to first page. Use "Rewind Speed" to change animation speed.'),
  326. 'values' => self::getEnableOptions(),
  327. 'default' => self::ENABLE,
  328. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  329. ),
  330. array(
  331. 'type' => 'text',
  332. 'name' => 'owl_rewindSpeed',
  333. 'label' => $this->l('Rewind Speed'),
  334. 'desc' => $this->l('Enter Time(miniseconds) to back first page. "Rewind Nav" must be enable. Ex 1000'),
  335. 'default' => '1000',
  336. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  337. 'class' => 'digits',
  338. ),
  339. array(
  340. 'type' => 'switch',
  341. 'label' => $this->l('Scroll Per Page'),
  342. 'name' => 'owl_scrollPerPage',
  343. 'is_bool' => true,
  344. 'desc' => $this->l('Scroll per page not per item. This affect next/prev buttons and mouse/touch dragging. Use "Slide Speed" to change animation speed.'),
  345. 'values' => self::getEnableOptions(),
  346. 'default' => self::DISABLE,
  347. 'form_group_class' => 'carousel_type_sub carousel_type-'.self::CAROUSEL_OWL,
  348. ),
  349. );
  350. }
  351. }
  352. }