PageRenderTime 49ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/files/wp-slidedeck2/2.1.20121115/lenses/tool-kit/lens.php

https://gitlab.com/Mirros/jsdelivr
PHP | 489 lines | 402 code | 23 blank | 64 comment | 80 complexity | 0e34de0e5ce5ab3ac1232456ac9a2290 MD5 | raw file
  1. <?php
  2. class SlideDeckLens_ToolKit extends SlideDeckLens_Scaffold {
  3. var $options_model = array(
  4. 'Appearance' => array(
  5. 'accentColor' => array(
  6. 'value' => "#3ea0c1"
  7. ),
  8. 'frame' => array(
  9. 'name' => 'frame',
  10. 'type' => 'select',
  11. 'value' => 'frame',
  12. 'values' => array(
  13. 'frame' => 'Thick',
  14. 'hairline' => 'Hairline',
  15. 'none' => 'None',
  16. ),
  17. 'label' => 'Border/Frame',
  18. 'description' => "Choose the thickness of the frame around your SlideDeck",
  19. 'weight' => 40
  20. ),
  21. 'text-position' => array(
  22. 'name' => 'text-position',
  23. 'type' => 'select',
  24. 'values' => array(
  25. 'title-pos-top' => 'Top',
  26. 'title-pos-bottom' => 'Bottom',
  27. 'title-pos-left' => 'Left',
  28. 'title-pos-right' => 'Right',
  29. 'title-pos-fill' => 'Fill Slide'
  30. ),
  31. 'value' => 'title-pos-top',
  32. 'label' => 'Caption Position',
  33. 'description' => "Choose where to place the caption text on the slide",
  34. 'weight' => 50
  35. ),
  36. 'text-color' => array(
  37. 'name' => 'text-color',
  38. 'type' => 'select',
  39. 'values' => array(
  40. 'title-dark' => 'Dark',
  41. 'title-light' => 'Light'
  42. ),
  43. 'value' => 'title-dark',
  44. 'label' => 'Text Color Variation',
  45. 'weight' => 60
  46. ),
  47. 'hideSpines' => array(
  48. 'type' => 'hidden',
  49. 'value' => true
  50. )
  51. ),
  52. 'Navigation' => array(
  53. 'navigation-position' => array(
  54. 'name' => 'navigation-position',
  55. 'type' => 'radio',
  56. 'attr' => array(
  57. 'class' => "fancy"
  58. ),
  59. 'values' => array(
  60. 'nav-pos-top' => 'Top',
  61. 'nav-pos-bottom' => 'Bottom',
  62. 'nav-pos-left' => 'Left',
  63. 'nav-pos-right' => 'Right',
  64. ),
  65. 'value' => 'nav-pos-bottom',
  66. 'label' => 'Navigation Position',
  67. 'description' => "Choose where the navigation panel resides",
  68. 'weight' => 10
  69. ),
  70. 'navigation-type' => array(
  71. 'name' => 'navigation-type',
  72. 'type' => 'select',
  73. 'values' => array(
  74. 'nav-dots' => 'Dots',
  75. 'nav-thumb' => 'Thumbnails',
  76. 'no-nav' => 'Turn Navigation Off'
  77. ),
  78. 'value' => 'nav-dots',
  79. 'label' => 'Navigation Type',
  80. 'description' => "Note: Dots Navigation Type is limited to a max of 10. If you have more than 10 slides, Thumbnails is better for your users.",
  81. 'weight' => 20
  82. ),
  83. 'navigation-style' => array(
  84. 'name' => 'navigation-style',
  85. 'type' => 'select',
  86. 'values' => array(
  87. 'nav-default' => 'Inside slide area',
  88. 'nav-bar' => 'In its own bar',
  89. 'nav-hanging' => 'Hanging outside'
  90. ),
  91. 'value' => 'nav-default',
  92. 'label' => 'Navigation Style',
  93. 'description' => "Change the location of the SlideDeck's navigation elements. This may cause the caption position to be chnaged.",
  94. 'weight' => 30
  95. ),
  96. 'arrow-style' => array(
  97. 'name' => 'arrow-style',
  98. 'type' => 'select',
  99. 'values' => array(
  100. 'arrowstyle-1' => 'Default',
  101. 'arrowstyle-2' => 'Pointer Arrow',
  102. 'arrowstyle-3' => 'Hairline Arrow',
  103. 'arrowstyle-4' => 'Short Small Arrow',
  104. 'arrowstyle-5' => 'Circle Hairline Button Arrow',
  105. 'arrowstyle-6' => 'Circle Play Button Arrow',
  106. 'arrowstyle-7' => 'Circle Pointer Button Arrow',
  107. 'arrowstyle-8' => 'Circle Play Arrow',
  108. 'arrowstyle-9' => 'Circle Pointer Arrow'
  109. ),
  110. 'value' => 'arrowstyle-7',
  111. 'label' => 'Arrow Style',
  112. 'description' => "Pick an arrow style that best matches your website's design.",
  113. 'weight' => 40,
  114. 'interface' => array(
  115. 'type' => 'thumbnails-flyout',
  116. 'values' => array(
  117. 'arrowstyle-1' => '/lenses/tool-kit/images/arrowstyle_1.thumb.png',
  118. 'arrowstyle-2' => '/lenses/tool-kit/images/arrowstyle_2.thumb.png',
  119. 'arrowstyle-3' => '/lenses/tool-kit/images/arrowstyle_3.thumb.png',
  120. 'arrowstyle-4' => '/lenses/tool-kit/images/arrowstyle_4.thumb.png',
  121. 'arrowstyle-5' => '/lenses/tool-kit/images/arrowstyle_5.thumb.png',
  122. 'arrowstyle-6' => '/lenses/tool-kit/images/arrowstyle_6.thumb.png',
  123. 'arrowstyle-7' => '/lenses/tool-kit/images/arrowstyle_7.thumb.png',
  124. 'arrowstyle-8' => '/lenses/tool-kit/images/arrowstyle_8.thumb.png',
  125. 'arrowstyle-9' => '/lenses/tool-kit/images/arrowstyle_9.thumb.png',
  126. )
  127. )
  128. ),
  129. 'nav-arrow-style' => array(
  130. 'name' => 'nav-arrow-style',
  131. 'type' => 'select',
  132. 'values' => array(
  133. 'nav-arrow-style-1' => 'Button',
  134. 'nav-arrow-style-2' => 'Arrow'
  135. ),
  136. 'value' => 'nav-arrow-style-1',
  137. 'label' => 'Thumbnail Arrow Style',
  138. 'weight' => 50,
  139. 'description' => "Pick an arrow style for the Thumbnail Navigation"
  140. ),
  141. )
  142. );
  143. function __construct(){
  144. parent::__construct();
  145. add_filter( "{$this->namespace}_get_slides", array( &$this, "slidedeck_get_slides" ), 11, 2 );
  146. }
  147. /**
  148. * Adding the accent-color class to the <a> tags if Twitter
  149. *
  150. * @param array $slides Array of Slides
  151. * @param array $slidedeck The SlideDeck object being rendered
  152. *
  153. * @uses SlideDeckLens_Scaffold::is_valid()
  154. *
  155. * @return array
  156. */
  157. function slidedeck_get_slides( $slides, $slidedeck ){
  158. if( $this->is_valid( $slidedeck['lens'] ) ){
  159. foreach( $slides as &$slide ){
  160. if( $slidedeck['source'] == 'twitter' ){
  161. $slide['content'] = preg_replace( '/\<a /', '<a class="accent-color" ', $slide['content'] );
  162. }
  163. }
  164. }
  165. return $slides;
  166. }
  167. function slidedeck_render_slidedeck_before($html, $slidedeck){
  168. if( $this->is_valid( $slidedeck['lens'] ) ) {
  169. $html .= '<div class="sd-wrapper">';
  170. }
  171. return $html;
  172. }
  173. function slidedeck_render_slidedeck_after($html, $slidedeck){
  174. if( $this->is_valid( $slidedeck['lens'] ) ) {
  175. $html .= '</div>';
  176. }
  177. return $html;
  178. }
  179. /**
  180. * Add appropriate classes for this Lens to the SlideDeck frame
  181. *
  182. * @param array $slidedeck_classes Classes to be applied
  183. * @param array $slidedeck The SlideDeck object being rendered
  184. *
  185. * @return array
  186. */
  187. function slidedeck_frame_classes( $slidedeck_classes, $slidedeck ) {
  188. if( $this->is_valid( $slidedeck['lens'] ) ) {
  189. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['navigation-type'];
  190. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['frame'];
  191. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['navigation-style'];
  192. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['navigation-position'];
  193. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['text-position'];
  194. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['text-color'];
  195. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['show-title'];
  196. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['nav-arrow-style'];
  197. $slidedeck_classes[] = $this->prefix . $slidedeck['options']['arrow-style'];
  198. }
  199. return $slidedeck_classes;
  200. }
  201. function slidedeck_dimensions( &$width, &$height, &$outer_width, &$outer_height, &$slidedeck ) {
  202. global $SlideDeckPlugin;
  203. if( $this->is_valid( $slidedeck['lens'] ) ) {
  204. $og_w = $width;
  205. $og_h = $height;
  206. $og_ow = $outer_width;
  207. $og_oh = $outer_height;
  208. $size = $SlideDeckPlugin->SlideDeck->get_closest_size($slidedeck);
  209. switch( $slidedeck['options']['frame'] ){
  210. case 'frame':
  211. $width = $og_w - 24;
  212. $height = $og_h - 24;
  213. if( $slidedeck['options']['navigation-type'] != 'no-nav' ) {
  214. if( $slidedeck['options']['navigation-style'] == 'nav-hanging' ) {
  215. if( $slidedeck['options']['navigation-type'] == 'nav-thumb' ) {
  216. /**
  217. * This conditional handles the thumbnails when the nav
  218. * is hanging on the outside of the deck.
  219. */
  220. switch( $size ){
  221. case 'large':
  222. case 'medium':
  223. $height = $og_h - 94;
  224. break;
  225. case 'small':
  226. $height = $og_h - 70;
  227. break;
  228. }
  229. switch( $slidedeck['options']['navigation-position'] ){
  230. case 'nav-pos-left':
  231. case 'nav-pos-right':
  232. $height = $og_h - 24;
  233. $width = $og_w - 94;
  234. break;
  235. }
  236. }
  237. if( $slidedeck['options']['navigation-type'] == 'nav-dots' ) {
  238. /**
  239. * This conditional handles the nav dots when the nav
  240. * is hanging on the outside of the deck.
  241. */
  242. switch( $size ){
  243. case 'large':
  244. case 'medium':
  245. $height = $og_h - 57;
  246. break;
  247. case 'small':
  248. $height = $og_h - 47;
  249. break;
  250. }
  251. switch( $slidedeck['options']['navigation-position'] ){
  252. case 'nav-pos-top':
  253. $height = $og_h - 55;
  254. break;
  255. case 'nav-pos-left':
  256. case 'nav-pos-right':
  257. /**
  258. * If the dot nav is in its own bar or hanging
  259. * and the position is left or right, then we
  260. * need to make room at the edge for it.
  261. */
  262. $height = $og_h - 24;
  263. $width = $og_w - 54;
  264. break;
  265. }
  266. }
  267. }
  268. if( $slidedeck['options']['navigation-style'] == 'nav-bar' ) {
  269. /**
  270. * The following conditionals apply to the navigation in its own bar
  271. */
  272. if( $size == 'large' ) {
  273. $height = $og_h - 66;
  274. }
  275. switch( $slidedeck['options']['navigation-position'] ){
  276. case 'nav-pos-top':
  277. switch( $slidedeck['options']['navigation-type'] ){
  278. case 'nav-dots':
  279. $height = $og_h - 44;
  280. break;
  281. case 'nav-thumb':
  282. $height = $og_h - 85;
  283. if( $size == 'small' ) {
  284. $height = $og_h - 68;
  285. }
  286. break;
  287. }
  288. break;
  289. case 'nav-pos-bottom':
  290. switch( $slidedeck['options']['navigation-type'] ){
  291. case 'nav-dots':
  292. $height = $og_h - 46;
  293. break;
  294. case 'nav-thumb':
  295. $height = $og_h - 85;
  296. if( $size == 'small' ) {
  297. $height = $og_h - 68;
  298. }
  299. break;
  300. }
  301. break;
  302. case 'nav-pos-left':
  303. case 'nav-pos-right':
  304. switch( $slidedeck['options']['navigation-type'] ){
  305. case 'nav-dots':
  306. /**
  307. * If the dot nav is in its own bar
  308. * and the position is left or right, then we
  309. * need to make room at the edge for it.
  310. */
  311. $width = $og_w - 46;
  312. $height = $og_h - 24;
  313. break;
  314. case 'nav-thumb':
  315. /**
  316. * For the thumbnail navigation on the left
  317. * or the right we'll maintain the $height and
  318. * adjust the $width accordingly.
  319. */
  320. $width = $og_w - 85;
  321. $height = $og_h - 24;
  322. if( $size == 'small' ) {
  323. $width = $og_w - 71;
  324. }
  325. break;
  326. }
  327. break;
  328. }
  329. }
  330. }
  331. break;
  332. case 'none':
  333. case 'hairline':
  334. if( $slidedeck['options']['frame'] == 'hairline' ){
  335. $width = $og_w - 2;
  336. $height = $og_h - 2;
  337. }
  338. switch( $slidedeck['options']['navigation-position'] ){
  339. case 'nav-pos-left':
  340. case 'nav-pos-right':
  341. switch( $slidedeck['options']['navigation-type'] ){
  342. case 'nav-thumb':
  343. switch( $slidedeck['options']['navigation-style'] ){
  344. case 'nav-bar':
  345. case 'nav-hanging':
  346. switch( $size ){
  347. case 'large':
  348. case 'medium':
  349. $width = $og_w - 73;
  350. break;
  351. case 'small':
  352. $width = $og_w - 58;
  353. break;
  354. }
  355. break;
  356. case 'nav-default':
  357. switch( $size ){
  358. case 'large':
  359. case 'medium':
  360. //$width = $og_w - 73;
  361. break;
  362. case 'small':
  363. //$width = $og_w - 58;
  364. break;
  365. }
  366. break;
  367. }
  368. break;
  369. case 'nav-dots':
  370. if( in_array( $slidedeck['options']['navigation-style'], array('nav-bar', 'nav-hanging') ) ){
  371. /**
  372. * If the dot nav is in its own bar
  373. * and the position is left or right, then we
  374. * need to make room at the edge for it.
  375. */
  376. $width = $og_w - 32;
  377. }
  378. break;
  379. }
  380. break;
  381. case 'nav-pos-top':
  382. case 'nav-pos-bottom':
  383. if( $slidedeck['options']['navigation-type'] != 'no-nav' ) {
  384. if( $slidedeck['options']['navigation-style'] == 'nav-bar' ) {
  385. if($slidedeck['options']['navigation-type'] == 'nav-dots' ) {
  386. if($slidedeck['options']['navigation-position'] == 'nav-pos-top' ) {
  387. if( $size == 'small' || $size == 'medium' ){
  388. $height = $og_h - 2;
  389. }
  390. if( $size == 'large' ){
  391. $height = $og_h - 32;
  392. }
  393. }else{
  394. $height = $og_h - 34;
  395. }
  396. }
  397. if( $slidedeck['options']['navigation-type'] == 'nav-thumb' ) {
  398. if( $size == 'large' ) {
  399. $height = $og_h - 71;
  400. }
  401. if( $size == 'medium' ) {
  402. $height = $og_h - 74;
  403. }
  404. if( $size == 'small' ){
  405. $height = $og_h - 60;
  406. }
  407. }
  408. }
  409. if( $slidedeck['options']['navigation-style'] == 'nav-hanging' ) {
  410. if( $slidedeck['options']['navigation-type'] == 'nav-thumb' ) {
  411. if( $size == 'large' || $size == 'medium' ) {
  412. $height = $og_h - 72;
  413. }
  414. if( $size == 'small' ){
  415. $height = $og_h - 66;
  416. }
  417. }
  418. if( $slidedeck['options']['navigation-type'] == 'nav-dots' ) {
  419. if($slidedeck['options']['navigation-position'] == 'nav-pos-top' ) {
  420. if( $size == 'large' || $size == 'medium' ) {
  421. $height = $og_h - 36;
  422. }
  423. if( $size == 'small' ){
  424. $height = $og_h - 54;
  425. $outer_height = $og_h - 26;
  426. }
  427. }else{
  428. if( $size == 'large' || $size == 'medium' ) {
  429. $height = $og_h - 36;
  430. }
  431. if( $size == 'small' ){
  432. $height = $og_h - 34;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. break;
  439. }
  440. break;
  441. }
  442. }
  443. }
  444. /**
  445. * Making the SlideDeck process as a vertical deck
  446. *
  447. * In this case, we'll only try to process the deck as vertical if
  448. * the navigation is on the right or left.
  449. *
  450. * @param boolean $process_as_vertical default boolean - false
  451. * @param array $slidedeck The SlideDeck object being rendered
  452. *
  453. * @uses SlideDeckLens_Scaffold::is_valid()
  454. *
  455. * @return boolean
  456. */
  457. function slidedeck_process_as_vertical( $process_as_vertical, $slidedeck ){
  458. $vertical_navigation_positions = array( 'nav-pos-left', 'nav-pos-right' );
  459. if( $this->is_valid( $slidedeck['lens'] ) ) {
  460. if( in_array( $slidedeck['options']['navigation-position'], $vertical_navigation_positions ) ){
  461. $process_as_vertical = true;
  462. }
  463. }
  464. return $process_as_vertical;
  465. }
  466. }