piecemaker.admin.inc 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  1. <?php
  2. function piecemaker_profiles_page() {
  3. $profiles = db_query('SELECT * FROM {piecemaker_profiles}');
  4. if (!$profiles->rowCount()) {
  5. return t('There are no Piecemaker profiles yet. !link', array('!link' => l('Please add one.', 'admin/config/media/piecemaker/profiles/add')));
  6. }
  7. while ($profile = $profiles->fetch()) {
  8. $row = array();
  9. $row[] = $profile->title;
  10. $row[] = l('Edit', "admin/config/media/piecemaker/profiles/{$profile->pid}/edit");
  11. $row[] = l('Delete', "admin/config/media/piecemaker/profiles/{$profile->pid}/delete");
  12. $vars['rows'][] = $row;
  13. }
  14. $vars['header']= array(t('Profile Title'), t('Edit Profile'), t('Delete Profile'));
  15. return theme('table', $vars);
  16. }
  17. function piecemaker_settings_page($form, &$form_state) {
  18. if (!empty($form_state['submitted']) && !empty($form_state['rebuild'])) {
  19. unset($form_state['values']['piecemaker_default_transitions']['add'], $form_state['input']['piecemaker_default_transitions']['add']);
  20. }
  21. $form_state['#transition_element'] = 'piecemaker_default_transitions';
  22. $vals = _piecemaker_default_settings();
  23. $form['piecemaker_default_transitions'] = array(
  24. '#type' => 'fieldset',
  25. '#title' => t('Default Transitions'),
  26. '#tree' => TRUE,
  27. '#collapsible' => TRUE,
  28. '#collapsed' => FALSE,
  29. '#theme' => 'piecemaker_transition_form',
  30. '#prefix' => '<div id="transitions-wrap">',
  31. '#suffix' => '</div>',
  32. );
  33. $flash = _piecemaker_default_flash_settings();
  34. $form['flash_settings'] = array(
  35. '#type' => 'fieldset',
  36. '#title' => t('Flash Settings'),
  37. '#tree' => TRUE,
  38. '#collapsible' => TRUE,
  39. '#collapsed' => FALSE,
  40. );
  41. $form['flash_settings']['width'] = array(
  42. '#type' => 'textfield',
  43. '#title' => t('Flash Width'),
  44. '#description' => t('Width of Flash object. Should be larger then "Image Width" below.'),
  45. '#default_value' => $flash['width'],
  46. '#field_suffix' => 'pixels',
  47. );
  48. $form['flash_settings']['height'] = array(
  49. '#type' => 'textfield',
  50. '#title' => t('Flash Height'),
  51. '#description' => t('Height of Flash object. Should be larger then "Image Height" below.'),
  52. '#default_value' => $flash['height'],
  53. '#field_suffix' => 'pixels',
  54. );
  55. $form['flash_settings']['flashvars']['cssSource'] = array(
  56. '#type' => 'textfield',
  57. '#title' => t('Custom CSS'),
  58. '#default_value' => $flash['flashvars']['cssSource'],
  59. '#description' => t('A custom CSS file to use for this Piecemaker instance. If one is not provided the default piecemaker.css will be used. Please provide the path relative this Drupal install.'),
  60. );
  61. $form['flash_settings']['params'] = array(
  62. '#type' => 'fieldset',
  63. '#title' => t('Flash Paramaters'),
  64. '#theme' => 'piecemaker_profile_params',
  65. '#prefix' => '<div id="piecemaker-flash-params">',
  66. '#suffix' => '</div>',
  67. );
  68. $params = !empty($form_state['flash_settings']['params']) ? $form_state['flash_settings']['params'] : $flash['params'];
  69. foreach($params as $key => $value) {
  70. $form['flash_settings']['params'][$key]['key'] = array(
  71. '#type' => 'textfield',
  72. '#default_value' => $key,
  73. );
  74. $form['flash_settings']['params'][$key]['value'] = array(
  75. '#type' => 'textfield',
  76. '#default_value' => $value,
  77. );
  78. }
  79. $extra = !empty($form_state['params_extra']) ? $form_state['params_extra'] : 1;
  80. for ($i = 0; $i < $extra; $i++) {
  81. $form['flash_settings']['params'][$i]['key'] = array(
  82. '#type' => 'textfield',
  83. );
  84. $form['flash_settings']['params'][$i]['value'] = array(
  85. '#type' => 'textfield',
  86. );
  87. }
  88. $form['flash_settings']['params']['add'] = array(
  89. '#type' => 'submit',
  90. '#value' => t('Add Paramaters'),
  91. '#submit' => array('piecemaker_add_params_rows'),
  92. '#ajax' => array(
  93. 'wrapper' => 'piecemaker-flash-params',
  94. 'callback' => 'piecemaker_add_flash_params',
  95. ),
  96. );
  97. $transitions = variable_get('piecemaker_default_transitions', array());
  98. if (isset($form_state['unsaved_transitions']) && is_array($form_state['unsaved_transitions'])) {
  99. $transitions = $form_state['unsaved_transitions'];
  100. drupal_set_message('Transitions have not been saved yet. You must click "Save Settings" to save your changes.', 'warning');
  101. }
  102. $trans_options = _piecemaker_transitions();
  103. $weights = range(0, 50);
  104. $i = 1;
  105. foreach($transitions as $key => $transition) {
  106. $form['piecemaker_default_transitions'][$key]['weight'] = array(
  107. '#type' => 'select',
  108. '#options' => $weights,
  109. '#attributes' => array('class' => array('trans-weight')),
  110. '#default_value' => array($key),
  111. );
  112. $form['piecemaker_default_transitions'][$key]['Transition'] = array(
  113. '#type' => 'hidden',
  114. '#value' => $transition['Transition'],
  115. '#suffix' => $transition['Transition'],
  116. );
  117. $form['piecemaker_default_transitions'][$key]['Pieces'] = array(
  118. '#type' => 'hidden',
  119. '#value' => $transition['Pieces'],
  120. '#suffix' => $transition['Pieces'],
  121. );
  122. $form['piecemaker_default_transitions'][$key]['Time'] = array(
  123. '#type' => 'hidden',
  124. '#value' => $transition['Time'],
  125. '#suffix' => $transition['Time'],
  126. );
  127. $form['piecemaker_default_transitions'][$key]['Delay'] = array(
  128. '#type' => 'hidden',
  129. '#value' => $transition['Delay'],
  130. '#suffix' => $transition['Delay'],
  131. );
  132. $form['piecemaker_default_transitions'][$key]['DepthOffset'] = array(
  133. '#type' => 'hidden',
  134. '#value' => $transition['DepthOffset'],
  135. '#suffix' => $transition['DepthOffset'],
  136. );
  137. $form['piecemaker_default_transitions'][$key]['CubeDistance'] = array(
  138. '#type' => 'hidden',
  139. '#value' => $transition['CubeDistance'],
  140. '#suffix' => $transition['CubeDistance'],
  141. );
  142. $form['piecemaker_default_transitions'][$key]['action'] = array(
  143. '#type' => 'submit',
  144. '#value' => 'Delete Transition ' . $i,
  145. '#submit' => array('piecemaker_delete_transition'),
  146. '#ajax' => array(
  147. 'callback' => 'piecemaker_add_transition_ajax',
  148. 'wrapper' => 'transitions-wrap',
  149. 'effect' => 'fade',
  150. 'progress' => array(
  151. 'type' => 'throbber',
  152. 'message' => t('Deleting Transition'),
  153. ),
  154. ),
  155. );
  156. $i++;
  157. }
  158. $form['piecemaker_default_transitions']['add']['weight'] = array(
  159. '#type' => 'select',
  160. '#options' => $weights,
  161. '#attributes' => array('class' => array('trans-weight')),
  162. '#default_value' => array(50),
  163. );
  164. $form['piecemaker_default_transitions']['add']['Transition'] = array(
  165. '#type' => 'select',
  166. '#options' => $trans_options,
  167. '#description' => t('Transition type of the Tweener class. For more info on these types see the official Tweener Documentation and go to "Transition Types“". The best results are achieved by those transition types, which begin with easeInOut.'),
  168. );
  169. $pieces = range(0,10);
  170. unset($pieces[0]);
  171. $form['piecemaker_default_transitions']['add']['Pieces'] = array(
  172. '#type' => 'select',
  173. '#options' => $pieces,
  174. '#description' => t('Number of pieces to which the image is sliced'),
  175. );
  176. $form['piecemaker_default_transitions']['add']['Time'] = array(
  177. '#type' => 'textfield',
  178. '#description' => t('Time for one cube to turn'),
  179. '#default_value' => '1.2',
  180. );
  181. $form['piecemaker_default_transitions']['add']['Delay'] = array(
  182. '#type' => 'textfield',
  183. '#description' => t('Delay between the start of one cube to the start of the next cube'),
  184. '#default_value' => '.1',
  185. );
  186. $form['piecemaker_default_transitions']['add']['DepthOffset'] = array(
  187. '#type' => 'textfield',
  188. '#description' => t('The offset during transition on the z-axis. Value between 100 and 1000 are recommended. But go for experiments. :)'),
  189. '#default_value' => '300',
  190. );
  191. $form['piecemaker_default_transitions']['add']['CubeDistance'] = array(
  192. '#type' => 'textfield',
  193. '#description' => t('The distance between the cubes during transition. Values between 5 and 50 are recommended. But go for experiments.:)'),
  194. '#default_value' => '30',
  195. );
  196. $form['piecemaker_default_transitions']['add']['action'] = array(
  197. '#type' => 'submit',
  198. '#value' => 'Add Transition',
  199. '#submit' => array('piecemaker_add_transition'),
  200. '#ajax' => array(
  201. 'callback' => 'piecemaker_add_transition_ajax',
  202. 'wrapper' => 'transitions-wrap',
  203. 'effect' => 'fade',
  204. 'progress' => array(
  205. 'type' => 'throbber',
  206. 'message' => t('Adding Transition'),
  207. ),
  208. ),
  209. );
  210. $form['piecemaker_default_settings'] = array(
  211. '#type' => 'fieldset',
  212. '#title' => t('Default Settings'),
  213. '#tree' => TRUE,
  214. '#collapsible' => TRUE,
  215. '#collapsed' => TRUE,
  216. );
  217. $form['piecemaker_default_settings']['ImageWidth'] = array(
  218. '#type' => 'textfield',
  219. '#title' => t('Image Width'),
  220. '#description' => t('Width of every Image. ex: "900"'),
  221. '#default_value' => $vals['ImageWidth'],
  222. );
  223. $form['piecemaker_default_settings']['ImageHeight'] = array(
  224. '#type' => 'textfield',
  225. '#title' => t('Image Height'),
  226. '#description' => t('Height of every Image. ex: "360"'),
  227. '#default_value' => $vals['ImageHeight'],
  228. );
  229. $form['piecemaker_default_settings']['LoaderColor'] = array(
  230. '#type' => 'textfield',
  231. '#title' => t('Loader Color'),
  232. '#description' => t('Color of the cubes before the first image appears, also the color of the back sides of the cube, which become visible at some transition types. ex: "0x333333"'),
  233. '#default_value' => $vals['LoaderColor'],
  234. );
  235. $form['piecemaker_default_settings']['InnerSideColor'] = array(
  236. '#type' => 'textfield',
  237. '#title' => t('Inner Side Color'),
  238. '#description' => t('Color of the inner sides of the cube when sliced. ex: "0x222222"'),
  239. '#default_value' => $vals['InnerSideColor'],
  240. );
  241. $form['piecemaker_default_settings']['SideShadowAlpha'] = array(
  242. '#type' => 'textfield',
  243. '#title' => t('Side Shadow Alpha'),
  244. '#description' => t('Sides get darker when moved away from the front. This is the degree of darkness - 0 == no change, 1 == 100% black. ex: "0.8"'),
  245. '#default_value' => $vals['SideShadowAlpha'],
  246. );
  247. $form['piecemaker_default_settings']['DropShadowAlpha'] = array(
  248. '#type' => 'textfield',
  249. '#title' => t('Drop Shadow Alpha'),
  250. '#description' => t('Alpha of the drop shadow - 0 == no shadow, 1 == opaque. ex: "0.7"'),
  251. '#default_value' => $vals['DropShadowAlpha'],
  252. );
  253. $form['piecemaker_default_settings']['DropShadowDistance'] = array(
  254. '#type' => 'textfield',
  255. '#title' => t('Drop Shadow Distance'),
  256. '#description' => t('Distance of the shadow from the bottom of the image. ex: "25"'),
  257. '#default_value' => $vals['DropShadowDistance'],
  258. );
  259. $form['piecemaker_default_settings']['DropShadowScale'] = array(
  260. '#type' => 'textfield',
  261. '#title' => t('Drop Shadow Scale'),
  262. '#description' => t('As the shadow is blurred, it appears wider that the actual image, when not resized. Thus it‘s a good idea to make it slightly smaller. - 1 would be no resizing at all.. ex: "0.95"'),
  263. '#default_value' => $vals['DropShadowScale'],
  264. );
  265. $form['piecemaker_default_settings']['DropShadowBlurX'] = array(
  266. '#type' => 'textfield',
  267. '#title' => t('Drop Shadow Blur-X'),
  268. '#description' => t('Blur of the drop shadow on the x-axis. ex: "40"'),
  269. '#default_value' => $vals['DropShadowBlurX'],
  270. );
  271. $form['piecemaker_default_settings']['DropShadowBlurY'] = array(
  272. '#type' => 'textfield',
  273. '#title' => t('Drop Shadow Blur-Y'),
  274. '#description' => t('Blur of the drop shadow on the y-axis. ex: "4"'),
  275. '#default_value' => $vals['DropShadowBlurY'],
  276. );
  277. $form['piecemaker_default_settings']['MenuDistanceX'] = array(
  278. '#type' => 'textfield',
  279. '#title' => t('Menu Distance-X'),
  280. '#description' => t('Distance between two menu items (from center to center). ex: "20"'),
  281. '#default_value' => $vals['MenuDistanceX'],
  282. );
  283. $form['piecemaker_default_settings']['MenuDistanceY'] = array(
  284. '#type' => 'textfield',
  285. '#title' => t('Menu Distance-Y'),
  286. '#description' => t('Distance of the menu from the bottom of the image. ex: "50"'),
  287. '#default_value' => $vals['MenuDistanceY'],
  288. );
  289. $form['piecemaker_default_settings']['MenuColor1'] = array(
  290. '#type' => 'textfield',
  291. '#title' => t('Menu Color 1'),
  292. '#description' => t('Color of an inactive menu item. ex: "0x999999"'),
  293. '#default_value' => $vals['MenuColor1'],
  294. );
  295. $form['piecemaker_default_settings']['MenuColor2'] = array(
  296. '#type' => 'textfield',
  297. '#title' => t('Menu Color 2'),
  298. '#description' => t('Color of an active menu item. ex: "0x333333"'),
  299. '#default_value' => $vals['MenuColor2'],
  300. );
  301. $form['piecemaker_default_settings']['MenuColor3'] = array(
  302. '#type' => 'textfield',
  303. '#title' => t('Menu Color 3'),
  304. '#description' => t('Color of the inner circle of an active menu item. Should equal the background color of the whole thing.. ex: "0xFFFFFF"'),
  305. '#default_value' => $vals['MenuColor3'],
  306. );
  307. $form['piecemaker_default_settings']['ControlSize'] = array(
  308. '#type' => 'textfield',
  309. '#title' => t('Control Size'),
  310. '#description' => t('Size of the controls, which appear on rollover (play, stop, info, link) . ex: "100"'),
  311. '#default_value' => $vals['ControlSize'],
  312. );
  313. $form['piecemaker_default_settings']['ControlDistance'] = array(
  314. '#type' => 'textfield',
  315. '#title' => t('Control Distance'),
  316. '#description' => t('Distance between the controls (from the borders). ex: "20"'),
  317. '#default_value' => $vals['ControlDistance'],
  318. );
  319. $form['piecemaker_default_settings']['ControlColor1'] = array(
  320. '#type' => 'textfield',
  321. '#title' => t('Control Color 1'),
  322. '#description' => t('Background color of the controls. ex: "0x222222"'),
  323. '#default_value' => $vals['ControlColor1'],
  324. );
  325. $form['piecemaker_default_settings']['ControlColor2'] = array(
  326. '#type' => 'textfield',
  327. '#title' => t('Control Color 2'),
  328. '#description' => t('Font color of the controls. ex: "0xFFFFFF"'),
  329. '#default_value' => $vals['ControlColor2'],
  330. );
  331. $form['piecemaker_default_settings']['ControlAlpha'] = array(
  332. '#type' => 'textfield',
  333. '#title' => t('Control Alpha'),
  334. '#description' => t('Alpha of a control, when mouse is not over. ex: "0.8"'),
  335. '#default_value' => $vals['ControlAlpha'],
  336. );
  337. $form['piecemaker_default_settings']['ControlAlphaOver'] = array(
  338. '#type' => 'textfield',
  339. '#title' => t('Control Alpha Over'),
  340. '#description' => t('Alpha of a control, when mouse is over. ex: "0.95"'),
  341. '#default_value' => $vals['ControlAlphaOver'],
  342. );
  343. $form['piecemaker_default_settings']['ControlsX'] = array(
  344. '#type' => 'textfield',
  345. '#title' => t('Controls X'),
  346. '#description' => t('X-position of the point, which aligns the controls (measured from [0,0] of the image). ex: "450"'),
  347. '#default_value' => $vals['ControlsX'],
  348. );
  349. $form['piecemaker_default_settings']['ControlsY'] = array(
  350. '#type' => 'textfield',
  351. '#title' => t('Controls Y'),
  352. '#description' => t('Y-position of the point, which aligns the controls (measured from [0,0] of the image). ex: "280"'),
  353. '#default_value' => $vals['ControlsY'],
  354. );
  355. $form['piecemaker_default_settings']['ControlsAlign'] = array(
  356. '#type' => 'textfield',
  357. '#title' => t('Controls Align'),
  358. '#description' => t('Type of alignment from the point [controlsX, controlsY] - can be "center", "left" or "right". ex: "center"'),
  359. '#default_value' => $vals['ControlsAlign'],
  360. );
  361. $form['piecemaker_default_settings']['TooltipHeight'] = array(
  362. '#type' => 'textfield',
  363. '#title' => t('Tooltip Height'),
  364. '#description' => t('Height of the tooltip surface in the menu. ex: "31"'),
  365. '#default_value' => $vals['TooltipHeight'],
  366. );
  367. $form['piecemaker_default_settings']['TooltipColor'] = array(
  368. '#type' => 'textfield',
  369. '#title' => t('Tooltip Color'),
  370. '#description' => t('Color of the tooltip surface in the menu. ex: "0x222222"'),
  371. '#default_value' => $vals['TooltipColor'],
  372. );
  373. $form['piecemaker_default_settings']['TooltipTextY'] = array(
  374. '#type' => 'textfield',
  375. '#title' => t('Tooltip Text-Y'),
  376. '#description' => t('Y-distance of the tooltip text field from the top of the tooltip. ex: "5"'),
  377. '#default_value' => $vals['TooltipTextY'],
  378. );
  379. $form['piecemaker_default_settings']['TooltipTextStyle'] = array(
  380. '#type' => 'textfield',
  381. '#title' => t('Tooltip Text Style'),
  382. '#description' => t('The style of the tooltip text, specified in the CSS file. ex: "P-Italic"'),
  383. '#default_value' => $vals['TooltipTextStyle'],
  384. );
  385. $form['piecemaker_default_settings']['TooltipTextColor'] = array(
  386. '#type' => 'textfield',
  387. '#title' => t('Tooltip Text Color'),
  388. '#description' => t('Color of the tooltip text. ex: "0xFFFFFF"'),
  389. '#default_value' => $vals['TooltipTextColor'],
  390. );
  391. $form['piecemaker_default_settings']['TooltipMarginLeft'] = array(
  392. '#type' => 'textfield',
  393. '#title' => t('Tooltip Margin Left'),
  394. '#description' => t('Margin of the text to the left end of the tooltip. ex: "5"'),
  395. '#default_value' => $vals['TooltipMarginLeft'],
  396. );
  397. $form['piecemaker_default_settings']['TooltipMarginRight'] = array(
  398. '#type' => 'textfield',
  399. '#title' => t('Tooltip Margin Right'),
  400. '#description' => t('Margin of the text to the right end of the tooltip. ex: "7"'),
  401. '#default_value' => $vals['TooltipMarginRight'],
  402. );
  403. $form['piecemaker_default_settings']['TooltipTextSharpness'] = array(
  404. '#type' => 'textfield',
  405. '#title' => t('Tooltip Text Sharpness'),
  406. '#description' => t('Sharpness of the tooltip text (-400 to 400) - see Adobe Docs. ex: "50"'),
  407. '#default_value' => $vals['TooltipTextSharpness'],
  408. );
  409. $form['piecemaker_default_settings']['TooltipTextThickness'] = array(
  410. '#type' => 'textfield',
  411. '#title' => t('Tooltip Text Thickness'),
  412. '#description' => t('Thickness of the tooltip text (-400 to 400) - see Adobe Docs. ex: "-100"'),
  413. '#default_value' => $vals['TooltipTextThickness'],
  414. );
  415. $form['piecemaker_default_settings']['InfoWidth'] = array(
  416. '#type' => 'textfield',
  417. '#title' => t('Info Width'),
  418. '#description' => t('The width of the info text field. ex: "400"'),
  419. '#default_value' => $vals['InfoWidth'],
  420. );
  421. $form['piecemaker_default_settings']['InfoBackground'] = array(
  422. '#type' => 'textfield',
  423. '#title' => t('Info Background'),
  424. '#description' => t('The background color of the info text field. ex: "0xFFFFFF"'),
  425. '#default_value' => $vals['InfoBackground'],
  426. );
  427. $form['piecemaker_default_settings']['InfoBackgroundAlpha'] = array(
  428. '#type' => 'textfield',
  429. '#title' => t('Info Background Alpha'),
  430. '#description' => t('The alpha of the background of the info text, the image shines through, when smaller than 1. ex: "0.95"'),
  431. '#default_value' => $vals['InfoBackgroundAlpha'],
  432. );
  433. $form['piecemaker_default_settings']['InfoMargin'] = array(
  434. '#type' => 'textfield',
  435. '#title' => t('Info Margin'),
  436. '#description' => t('The margin of the text field in the info section to all sides. ex: "15"'),
  437. '#default_value' => $vals['InfoMargin'],
  438. );
  439. $form['piecemaker_default_settings']['InfoSharpness'] = array(
  440. '#type' => 'textfield',
  441. '#title' => t('Info Sharpness'),
  442. '#description' => t('Sharpness of the info text (see above). ex: "0"'),
  443. '#default_value' => $vals['InfoSharpness'],
  444. );
  445. $form['piecemaker_default_settings']['InfoThickness'] = array(
  446. '#type' => 'textfield',
  447. '#title' => t('Info Thickness'),
  448. '#description' => t('Thickness of the info text (see above). ex: "0"'),
  449. '#default_value' => $vals['InfoThickness'],
  450. );
  451. $form['piecemaker_default_settings']['Autoplay'] = array(
  452. '#type' => 'textfield',
  453. '#title' => t('Autoplay'),
  454. '#description' => t('Number of seconds from one transition to another, if not stopped. Set to 0 to disable autoplay. ex: "10"'),
  455. '#default_value' => $vals['Autoplay'],
  456. );
  457. $form['piecemaker_default_settings']['FieldOfView'] = array(
  458. '#type' => 'textfield',
  459. '#title' => t('Field Of View'),
  460. '#description' => t('See the official Adobe Docs. ex: "45"'),
  461. '#default_value' => $vals['FieldOfView'],
  462. );
  463. // Add the buttons.
  464. $form['actions'] = array('#type' => 'actions');
  465. $form['actions']['submit'] = array(
  466. '#type' => 'submit',
  467. '#value' => t('Save Settings'),
  468. '#weight' => -5,
  469. );
  470. return $form;
  471. }
  472. function piecemaker_settings_page_submit($form, &$form_state) {
  473. $default_transitions = array();
  474. variable_set('piecemaker_default_settings', $form_state['values']['piecemaker_default_settings']);
  475. $transitions = $form_state['values']['piecemaker_default_transitions'];
  476. //Get rid of the Add row since they didn't click it here.
  477. unset($transitions['add']);
  478. uasort($transitions, 'drupal_sort_weight');
  479. foreach ($transitions as $trans) {
  480. unset($trans['weight']);
  481. unset($trans['action']);
  482. $default_transitions[] = $trans;
  483. }
  484. variable_set('piecemaker_default_transitions', $default_transitions);
  485. $flash = $form_state['values']['flash_settings'];
  486. $params = $flash['params'];
  487. unset($params['add'], $flash['params']);
  488. foreach($params as $param) {
  489. if (!empty($param['value'])) {
  490. $flash['params'][$param['key']] = $param['value'];
  491. }
  492. }
  493. variable_set('piecemaker_default_flash_settings', $flash);
  494. }
  495. function piecemaker_add_transition($form, &$form_state) {
  496. $key = $form_state['#transition_element'];
  497. $transitions = $form_state['values'][$key];
  498. uasort($transitions, 'drupal_sort_weight');
  499. foreach ($transitions as $trans) {
  500. unset($trans['weight']);
  501. unset($trans['action']);
  502. $default_transitions[] = $trans;
  503. }
  504. $form_state['unsaved_transitions'] = $default_transitions;
  505. $form_state['rebuild'] = TRUE;
  506. drupal_set_message('Transition Added');
  507. }
  508. function piecemaker_delete_transition($form, &$form_state) {
  509. $elem = $form_state['#transition_element'];
  510. $default_transitions = array();
  511. $clicked = $form_state['clicked_button'];
  512. $key = $clicked['#parents'][1];
  513. $transitions = $form_state['values'][$elem];
  514. unset($transitions[$key]);
  515. //Kill the add row since it's not needed;
  516. unset($transitions['add']);
  517. uasort($transitions, 'drupal_sort_weight');
  518. foreach ($transitions as $trans) {
  519. unset($trans['weight']);
  520. $default_transitions[] = $trans;
  521. }
  522. $form_state['unsaved_transitions'] = $default_transitions;
  523. $form_state['rebuild'] = TRUE;
  524. drupal_set_message('Deleted Transition');
  525. }
  526. /**
  527. * Generates a Profile settings form
  528. *
  529. * The various settings available are defined by the Piecemaker Library.
  530. * The following settings have to be in place within the XML file to control the Piecemaker component. You can find them all in the Settings node.
  531. * - ImageWidth = "900" - Width of every Image
  532. * - ImageHeight = "360" - Height of every Image
  533. * - LoaderColor = "0x333333" - Color of the cubes before the first image appears, also the color of the back sides of the cube, which become visible at some transition types
  534. * - InnerSideColor = "0x222222" - Color of the inner sides of the cube when sliced
  535. * - SideShadowAlpha = "0.8" - Sides get darker when moved away from the front. This is the degree of darkness - 0 == no change, 1 == 100% black
  536. * - DropShadowAlpha = "0.7" - Alpha of the drop shadow - 0 == no shadow, 1 == opaque
  537. * - DropShadowDistance = "25" - Distance of the shadow from the bottom of the image
  538. * - DropShadowScale = "0.95" - As the shadow is blurred, it appears wider that the actual image, when not resized. Thus it‘s a good idea to make it slightly smaller. - 1 would be no resizing at all.
  539. * - DropShadowBlurX = "40" - Blur of the drop shadow on the x-axis
  540. * - DropShadowBlurY = "4" - Blur of the drop shadow on the y-axis
  541. * - MenuDistanceX = "20" - Distance between two menu items (from center to center)
  542. * - MenuDistanceY = "50" - Distance of the menu from the bottom of the image
  543. * - MenuColor1 = "0x999999" - Color of an inactive menu item
  544. * - MenuColor2 = "0x333333" - Color of an active menu item
  545. * - MenuColor3 = "0xFFFFFF" - Color of the inner circle of an active menu item. Should equal the background color of the whole thing.
  546. * - ControlSize = "100" - Size of the controls, which appear on rollover (play, stop, info, link)
  547. * - ControlDistance = "20" - Distance between the controls (from the borders)
  548. * - ControlColor1 = "0x222222" - Background color of the controls
  549. * - ControlColor2 = "0xFFFFFF" - Font color of the controls
  550. * - ControlAlpha = "0.8" - Alpha of a control, when mouse is not over
  551. * - ControlAlphaOver = "0.95" - Alpha of a control, when mouse is over
  552. * - ControlsX = "450" - X-position of the point, which aligns the controls (measured from [0,0] of the image)
  553. * - ControlsY = "280" - Y-position of the point, which aligns the controls (measured from [0,0] of the image)
  554. * - ControlsAlign = "center" - Type of alignment from the point [controlsX, controlsY] - can be "center", "left" or "right"
  555. * - TooltipHeight = "31" - Height of the tooltip surface in the menu
  556. * - TooltipColor = "0x222222" - Color of the tooltip surface in the menu
  557. * - TooltipTextY = "5" - Y-distance of the tooltip text field from the top of the tooltip
  558. * - TooltipTextStyle = "P-Italic" - The style of the tooltip text, specified in the CSS file
  559. * - TooltipTextColor = "0xFFFFFF" - Color of the tooltip text
  560. * - TooltipMarginLeft = "5" - Margin of the text to the left end of the tooltip
  561. * - TooltipMarginRight = "7" - Margin of the text to the right end of the tooltip
  562. * - TooltipTextSharpness = "50" - Sharpness of the tooltip text (-400 to 400) - see Adobe Docs
  563. * - TooltipTextThickness = "-100" - Thickness of the tooltip text (-400 to 400) - see Adobe Docs
  564. * - InfoWidth = "400" - The width of the info text field
  565. * - InfoBackground = "0xFFFFFF" - The background color of the info text field
  566. * - InfoBackgroundAlpha = "0.95" - The alpha of the background of the info text, the image shines through, when smaller than 1
  567. * - InfoMargin = "15" - The margin of the text field in the info section to all sides
  568. * - InfoSharpness = "0" - Sharpness of the info text (see above)
  569. * - InfoThickness = "0" - Thickness of the info text (see above)
  570. * - Autoplay = "10" - Number of seconds from one transition to another, if not stopped. Set to 0 to disable autoplay
  571. * - FieldOfView = "45" - see the official Adobe Docs
  572. *
  573. * @see piecemaker_profile_form_submit()
  574. * @ingroup forms
  575. * @param $form['settings']_state
  576. * An associative array containing the current state of the form; not used.
  577. * @param $profile
  578. * A Piecemaker profile object
  579. * @return
  580. * Form definition.
  581. */
  582. function piecemaker_profile_form($form, &$form_state, $profile = NULL) {
  583. if (!empty($form_state['submitted']) && !empty($form_state['rebuild'])) {
  584. unset($form_state['values']['transitions']['add'], $form_state['input']['transitions']['add']);
  585. unset($form_state['values']['flash_settings']['params'][0], $form_state['input']['flash_settings']['params'][0]);
  586. }
  587. $form_state['cache'] = TRUE;
  588. $form_state['#transition_element'] = 'transitions';
  589. $vals = !empty($profile->settings) ? $profile->settings : _piecemaker_default_settings();
  590. $flash = !empty($profile->flash_settings) ? $profile->flash_settings : _piecemaker_default_flash_settings();
  591. $form['pid'] = array(
  592. '#type' => 'value',
  593. '#value' => !empty($profile->pid) ? $profile->pid : NULL,
  594. );
  595. $form['title'] = array(
  596. '#type' => 'textfield',
  597. '#title' => t('Profile Name'),
  598. '#description' => t('A descriptive name for this Profile. It will be used when Profiles are listed out.'),
  599. '#default_value' => !empty($profile->title) ? $profile->title : NULL,
  600. '#required' => TRUE,
  601. );
  602. $form['flash_settings'] = array(
  603. '#type' => 'fieldset',
  604. '#title' => t('Flash Settings'),
  605. '#tree' => TRUE,
  606. '#collapsible' => TRUE,
  607. '#collapsed' => FALSE,
  608. );
  609. $form['flash_settings']['width'] = array(
  610. '#type' => 'textfield',
  611. '#title' => t('Flash Width'),
  612. '#description' => t('Width of Flash object. Should be larger then "Image Width" below.'),
  613. '#default_value' => $flash['width'],
  614. '#field_suffix' => 'pixels',
  615. );
  616. $form['flash_settings']['height'] = array(
  617. '#type' => 'textfield',
  618. '#title' => t('Flash Height'),
  619. '#description' => t('Height of Flash object. Should be larger then "Image Height" below.'),
  620. '#default_value' => $flash['height'],
  621. '#field_suffix' => 'pixels',
  622. );
  623. $form['flash_settings']['flashvars']['cssSource'] = array(
  624. '#type' => 'textfield',
  625. '#title' => t('Custom CSS'),
  626. '#default_value' => $flash['flashvars']['cssSource'],
  627. '#description' => t('A custom CSS file to use for this Piecemaker instance. If one is not provided the default piecemaker.css will be used. Please provide the path relative this Drupal install.'),
  628. );
  629. $form['flash_settings']['params'] = array(
  630. '#type' => 'fieldset',
  631. '#title' => t('Flash Paramaters'),
  632. '#theme' => 'piecemaker_profile_params',
  633. '#prefix' => '<div id="piecemaker-flash-params">',
  634. '#suffix' => '</div>',
  635. );
  636. $params = !empty($form_state['flash_settings']['params']) ? $form_state['flash_settings']['params'] : $flash['params'];
  637. foreach($params as $key => $value) {
  638. $form['flash_settings']['params'][$key]['key'] = array(
  639. '#type' => 'textfield',
  640. '#default_value' => $key,
  641. );
  642. $form['flash_settings']['params'][$key]['value'] = array(
  643. '#type' => 'textfield',
  644. '#default_value' => $value,
  645. );
  646. }
  647. $extra = !empty($form_state['params_extra']) ? $form_state['params_extra'] : 1;
  648. for ($i = 0; $i < $extra; $i++) {
  649. $form['flash_settings']['params'][$i]['key'] = array(
  650. '#type' => 'textfield',
  651. );
  652. $form['flash_settings']['params'][$i]['value'] = array(
  653. '#type' => 'textfield',
  654. );
  655. }
  656. $form['flash_settings']['params']['add'] = array(
  657. '#type' => 'submit',
  658. '#value' => t('Add Paramaters'),
  659. '#submit' => array('piecemaker_add_params_rows'),
  660. '#ajax' => array(
  661. 'wrapper' => 'piecemaker-flash-params',
  662. 'callback' => 'piecemaker_add_flash_params',
  663. ),
  664. );
  665. $transitions = !empty($profile->transitions) ? $profile->transitions : variable_get('piecemaker_default_transitions', array());
  666. if (isset($form_state['unsaved_transitions']) && is_array($form_state['unsaved_transitions'])) {
  667. $transitions = $form_state['unsaved_transitions'];
  668. drupal_set_message('Transitions have not been saved yet. You must click "Save Settings" to save your changes.', 'warning');
  669. }
  670. $form['transitions'] = array(
  671. '#type' => 'fieldset',
  672. '#title' => t('Transitions'),
  673. '#tree' => TRUE,
  674. '#collapsible' => TRUE,
  675. '#collapsed' => FALSE,
  676. '#theme' => 'piecemaker_transition_form',
  677. '#prefix' => '<div id="transitions-wrap">',
  678. '#suffix' => '</div>',
  679. );
  680. $trans_options = _piecemaker_transitions();
  681. $weights = range(0, 50);
  682. $i = 1;
  683. foreach($transitions as $key => $transition) {
  684. $form['transitions'][$key]['weight'] = array(
  685. '#type' => 'select',
  686. '#options' => $weights,
  687. '#attributes' => array('class' => array('trans-weight')),
  688. '#default_value' => array($key),
  689. );
  690. $form['transitions'][$key]['Transition'] = array(
  691. '#type' => 'hidden',
  692. '#value' => $transition['Transition'],
  693. '#suffix' => $transition['Transition'],
  694. );
  695. $form['transitions'][$key]['Pieces'] = array(
  696. '#type' => 'hidden',
  697. '#value' => $transition['Pieces'],
  698. '#suffix' => $transition['Pieces'],
  699. );
  700. $form['transitions'][$key]['Time'] = array(
  701. '#type' => 'hidden',
  702. '#value' => $transition['Time'],
  703. '#suffix' => $transition['Time'],
  704. );
  705. $form['transitions'][$key]['Delay'] = array(
  706. '#type' => 'hidden',
  707. '#value' => $transition['Delay'],
  708. '#suffix' => $transition['Delay'],
  709. );
  710. $form['transitions'][$key]['DepthOffset'] = array(
  711. '#type' => 'hidden',
  712. '#value' => $transition['DepthOffset'],
  713. '#suffix' => $transition['DepthOffset'],
  714. );
  715. $form['transitions'][$key]['CubeDistance'] = array(
  716. '#type' => 'hidden',
  717. '#value' => $transition['CubeDistance'],
  718. '#suffix' => $transition['CubeDistance'],
  719. );
  720. $form['transitions'][$key]['action'] = array(
  721. '#type' => 'submit',
  722. '#value' => 'Delete Transition ' . $i,
  723. '#submit' => array('piecemaker_delete_transition'),
  724. '#ajax' => array(
  725. 'callback' => 'piecemaker_add_transition_ajax',
  726. 'wrapper' => 'transitions-wrap',
  727. 'effect' => 'fade',
  728. 'progress' => array(
  729. 'type' => 'throbber',
  730. 'message' => t('Deleting Transition'),
  731. ),
  732. ),
  733. );
  734. $i++;
  735. }
  736. $form['transitions']['add']['weight'] = array(
  737. '#type' => 'select',
  738. '#options' => $weights,
  739. '#attributes' => array('class' => array('trans-weight')),
  740. '#default_value' => array(50),
  741. );
  742. $form['transitions']['add']['Transition'] = array(
  743. '#type' => 'select',
  744. '#options' => $trans_options,
  745. '#description' => t('Transition type of the Tweener class. For more info on these types see the official Tweener Documentation and go to "Transition Types“". The best results are achieved by those transition types, which begin with easeInOut.'),
  746. );
  747. $pieces = range(0,10);
  748. unset($pieces[0]);
  749. $form['transitions']['add']['Pieces'] = array(
  750. '#type' => 'select',
  751. '#options' => $pieces,
  752. '#description' => t('Number of pieces to which the image is sliced'),
  753. );
  754. $form['transitions']['add']['Time'] = array(
  755. '#type' => 'textfield',
  756. '#description' => t('Time for one cube to turn'),
  757. '#default_value' => '1.2',
  758. );
  759. $form['transitions']['add']['Delay'] = array(
  760. '#type' => 'textfield',
  761. '#description' => t('Delay between the start of one cube to the start of the next cube'),
  762. '#default_value' => '.1',
  763. );
  764. $form['transitions']['add']['DepthOffset'] = array(
  765. '#type' => 'textfield',
  766. '#description' => t('The offset during transition on the z-axis. Value between 100 and 1000 are recommended. But go for experiments. :)'),
  767. '#default_value' => '300',
  768. );
  769. $form['transitions']['add']['CubeDistance'] = array(
  770. '#type' => 'textfield',
  771. '#description' => t('The distance between the cubes during transition. Values between 5 and 50 are recommended. But go for experiments.:)'),
  772. '#default_value' => '30',
  773. );
  774. $form['transitions']['add']['action'] = array(
  775. '#type' => 'submit',
  776. '#value' => 'Add Transition',
  777. '#submit' => array('piecemaker_add_transition'),
  778. '#ajax' => array(
  779. 'callback' => 'piecemaker_add_transition_ajax',
  780. 'wrapper' => 'transitions-wrap',
  781. 'effect' => 'fade',
  782. 'progress' => array(
  783. 'type' => 'throbber',
  784. 'message' => t('Adding Transition'),
  785. ),
  786. ),
  787. );
  788. $form['settings'] = array(
  789. '#type' => 'fieldset',
  790. '#title' => t('Settings'),
  791. '#collapsible' => TRUE,
  792. '#collapsed' => FALSE,
  793. '#tree' => TRUE,
  794. );
  795. $form['settings']['ImageWidth'] = array(
  796. '#type' => 'textfield',
  797. '#title' => t('Image Width'),
  798. '#description' => t('Width of every Image. ex: "900"'),
  799. '#default_value' => $vals['ImageWidth'],
  800. '#field_suffix' => 'pixels',
  801. );
  802. $form['settings']['ImageHeight'] = array(
  803. '#type' => 'textfield',
  804. '#title' => t('Image Height'),
  805. '#description' => t('Height of every Image. ex: "360"'),
  806. '#default_value' => $vals['ImageHeight'],
  807. '#field_suffix' => 'pixels',
  808. );
  809. $form['settings']['LoaderColor'] = array(
  810. '#type' => 'textfield',
  811. '#title' => t('Loader Color'),
  812. '#description' => t('Color of the cubes before the first image appears, also the color of the back sides of the cube, which become visible at some transition types. ex: "0x333333"'),
  813. '#default_value' => $vals['LoaderColor'],
  814. );
  815. $form['settings']['InnerSideColor'] = array(
  816. '#type' => 'textfield',
  817. '#title' => t('Inner Side Color'),
  818. '#description' => t('Color of the inner sides of the cube when sliced. ex: "0x222222"'),
  819. '#default_value' => $vals['InnerSideColor'],
  820. );
  821. $form['settings']['SideShadowAlpha'] = array(
  822. '#type' => 'textfield',
  823. '#title' => t('Side Shadow Alpha'),
  824. '#description' => t('Sides get darker when moved away from the front. This is the degree of darkness - 0 == no change, 1 == 100% black. ex: "0.8"'),
  825. '#default_value' => $vals['SideShadowAlpha'],
  826. );
  827. $form['settings']['DropShadowAlpha'] = array(
  828. '#type' => 'textfield',
  829. '#title' => t('Drop Shadow Alpha'),
  830. '#description' => t('Alpha of the drop shadow - 0 == no shadow, 1 == opaque. ex: "0.7"'),
  831. '#default_value' => $vals['DropShadowAlpha'],
  832. );
  833. $form['settings']['DropShadowDistance'] = array(
  834. '#type' => 'textfield',
  835. '#title' => t('Drop Shadow Distance'),
  836. '#description' => t('Distance of the shadow from the bottom of the image. ex: "25"'),
  837. '#default_value' => $vals['DropShadowDistance'],
  838. );
  839. $form['settings']['DropShadowScale'] = array(
  840. '#type' => 'textfield',
  841. '#title' => t('Drop Shadow Scale'),
  842. '#description' => t('As the shadow is blurred, it appears wider that the actual image, when not resized. Thus it‘s a good idea to make it slightly smaller. - 1 would be no resizing at all.. ex: "0.95"'),
  843. '#default_value' => $vals['DropShadowScale'],
  844. );
  845. $form['settings']['DropShadowBlurX'] = array(
  846. '#type' => 'textfield',
  847. '#title' => t('Drop Shadow Blur-X'),
  848. '#description' => t('Blur of the drop shadow on the x-axis. ex: "40"'),
  849. '#default_value' => $vals['DropShadowBlurX'],
  850. );
  851. $form['settings']['DropShadowBlurY'] = array(
  852. '#type' => 'textfield',
  853. '#title' => t('Drop Shadow Blur-Y'),
  854. '#description' => t('Blur of the drop shadow on the y-axis. ex: "4"'),
  855. '#default_value' => $vals['DropShadowBlurY'],
  856. );
  857. $form['settings']['MenuDistanceX'] = array(
  858. '#type' => 'textfield',
  859. '#title' => t('Menu Distance-X'),
  860. '#description' => t('Distance between two menu items (from center to center). ex: "20"'),
  861. '#default_value' => $vals['MenuDistanceX'],
  862. );
  863. $form['settings']['MenuDistanceY'] = array(
  864. '#type' => 'textfield',
  865. '#title' => t('Menu Distance-Y'),
  866. '#description' => t('Distance of the menu from the bottom of the image. ex: "50"'),
  867. '#default_value' => $vals['MenuDistanceY'],
  868. );
  869. $form['settings']['MenuColor1'] = array(
  870. '#type' => 'textfield',
  871. '#title' => t('Menu Color 1'),
  872. '#description' => t('Color of an inactive menu item. ex: "0x999999"'),
  873. '#default_value' => $vals['MenuColor1'],
  874. );
  875. $form['settings']['MenuColor2'] = array(
  876. '#type' => 'textfield',
  877. '#title' => t('Menu Color 2'),
  878. '#description' => t('Color of an active menu item. ex: "0x333333"'),
  879. '#default_value' => $vals['MenuColor2'],
  880. );
  881. $form['settings']['MenuColor3'] = array(
  882. '#type' => 'textfield',
  883. '#title' => t('Menu Color 3'),
  884. '#description' => t('Color of the inner circle of an active menu item. Should equal the background color of the whole thing.. ex: "0xFFFFFF"'),
  885. '#default_value' => $vals['MenuColor3'],
  886. );
  887. $form['settings']['ControlSize'] = array(
  888. '#type' => 'textfield',
  889. '#title' => t('Control Size'),
  890. '#description' => t('Size of the controls, which appear on rollover (play, stop, info, link) . ex: "100"'),
  891. '#default_value' => $vals['ControlSize'],
  892. );
  893. $form['settings']['ControlDistance'] = array(
  894. '#type' => 'textfield',
  895. '#title' => t('Control Distance'),
  896. '#description' => t('Distance between the controls (from the borders). ex: "20"'),
  897. '#default_value' => $vals['ControlDistance'],
  898. );
  899. $form['settings']['ControlColor1'] = array(
  900. '#type' => 'textfield',
  901. '#title' => t('Control Color 1'),
  902. '#description' => t('Background color of the controls. ex: "0x222222"'),
  903. '#default_value' => $vals['ControlColor1'],
  904. );
  905. $form['settings']['ControlColor2'] = array(
  906. '#type' => 'textfield',
  907. '#title' => t('Control Color 2'),
  908. '#description' => t('Font color of the controls. ex: "0xFFFFFF"'),
  909. '#default_value' => $vals['ControlColor2'],
  910. );
  911. $form['settings']['ControlAlpha'] = array(
  912. '#type' => 'textfield',
  913. '#title' => t('Control Alpha'),
  914. '#description' => t('Alpha of a control, when mouse is not over. ex: "0.8"'),
  915. '#default_value' => $vals['ControlAlpha'],
  916. );
  917. $form['settings']['ControlAlphaOver'] = array(
  918. '#type' => 'textfield',
  919. '#title' => t('Control Alpha Over'),
  920. '#description' => t('Alpha of a control, when mouse is over. ex: "0.95"'),
  921. '#default_value' => $vals['ControlAlphaOver'],
  922. );
  923. $form['settings']['ControlsX'] = array(
  924. '#type' => 'textfield',
  925. '#title' => t('Controls X'),
  926. '#description' => t('X-position of the point, which aligns the controls (measured from [0,0] of the image). ex: "450"'),
  927. '#default_value' => $vals['ControlsX'],
  928. );
  929. $form['settings']['ControlsY'] = array(
  930. '#type' => 'textfield',
  931. '#title' => t('Controls Y'),
  932. '#description' => t('Y-position of the point, which aligns the controls (measured from [0,0] of the image). ex: "280"'),
  933. '#default_value' => $vals['ControlsY'],
  934. );
  935. $form['settings']['ControlsAlign'] = array(
  936. '#type' => 'textfield',
  937. '#title' => t('Controls Align'),
  938. '#description' => t('Type of alignment from the point [controlsX, controlsY] - can be "center", "left" or "right". ex: "center"'),
  939. '#default_value' => $vals['ControlsAlign'],
  940. );
  941. $form['settings']['TooltipHeight'] = array(
  942. '#type' => 'textfield',
  943. '#title' => t('Tooltip Height'),
  944. '#description' => t('Height of the tooltip surface in the menu. ex: "31"'),
  945. '#default_value' => $vals['TooltipHeight'],
  946. );
  947. $form['settings']['TooltipColor'] = array(
  948. '#type' => 'textfield',
  949. '#title' => t('Tooltip Color'),
  950. '#description' => t('Color of the tooltip surface in the menu. ex: "0x222222"'),
  951. '#default_value' => $vals['TooltipColor'],
  952. );
  953. $form['settings']['TooltipTextY'] = array(
  954. '#type' => 'textfield',
  955. '#title' => t('Tooltip Text-Y'),
  956. '#description' => t('Y-distance of the tooltip text field from the top of the tooltip. ex: "5"'),
  957. '#default_value' => $vals['TooltipTextY'],
  958. );
  959. $form['settings']['TooltipTextStyle'] = array(
  960. '#type' => 'textfield',
  961. '#title' => t('Tooltip Text Style'),
  962. '#description' => t('The style of the tooltip text, specified in the CSS file. ex: "P-Italic"'),
  963. '#default_value' => $vals['TooltipTextStyle'],
  964. );
  965. $form['settings']['TooltipTextColor'] = array(
  966. '#type' => 'textfield',
  967. '#title' => t('Tooltip Text Color'),
  968. '#description' => t('Color of the tooltip text. ex: "0xFFFFFF"'),
  969. '#default_value' => $vals['TooltipTextColor'],
  970. );
  971. $form['settings']['TooltipMarginLeft'] = array(
  972. '#type' => 'textfield',
  973. '#title' => t('Tooltip Margin Left'),
  974. '#description' => t('Margin of the text to the left end of the tooltip. ex: "5"'),
  975. '#default_value' => $vals['TooltipMarginLeft'],
  976. );
  977. $form['settings']['TooltipMarginRight'] = array(
  978. '#type' => 'textfield',
  979. '#title' => t('Tooltip Margin Right'),
  980. '#description' => t('Margin of the text to the right end of the tooltip. ex: "7"'),
  981. '#default_value' => $vals['TooltipMarginRight'],
  982. );
  983. $form['settings']['TooltipTextSharpness'] = array(
  984. '#type' => 'textfield',
  985. '#title' => t('Tooltip Text Sharpness'),
  986. '#description' => t('Sharpness of the tooltip text (-400 to 400) - see Adobe Docs. ex: "50"'),
  987. '#default_value' => $vals['TooltipTextSharpness'],
  988. );
  989. $form['settings']['TooltipTextThickness'] = array(
  990. '#type' => 'textfield',
  991. '#title' => t('Tooltip Text Thickness'),
  992. '#description' => t('Thickness of the tooltip text (-400 to 400) - see Adobe Docs. ex: "-100"'),
  993. '#default_value' => $vals['TooltipTextThickness'],
  994. );
  995. $form['settings']['InfoWidth'] = array(
  996. '#type' => 'textfield',
  997. '#title' => t('Info Width'),
  998. '#description' => t('The width of the info text field. ex: "400"'),
  999. '#default_value' => $vals['InfoWidth'],
  1000. );
  1001. $form['settings']['InfoBackground'] = array(
  1002. '#type' => 'textfield',
  1003. '#title' => t('Info Background'),
  1004. '#description' => t('The background color of the info text field. ex: "0xFFFFFF"'),
  1005. '#default_value' => $vals['InfoBackground'],
  1006. );
  1007. $form['settings']['InfoBackgroundAlpha'] = array(
  1008. '#type' => 'textfield',
  1009. '#title' => t('Info Background Alpha'),
  1010. '#description' => t('The alpha of the background of the info text, the image shines through, when smaller than 1. ex: "0.95"'),
  1011. '#default_value' => $vals['InfoBackgroundAlpha'],
  1012. );
  1013. $form['settings']['InfoMargin'] = array(
  1014. '#type' => 'textfield',
  1015. '#title' => t('Info Margin'),
  1016. '#description' => t('The margin of the text field in the info section to all sides. ex: "15"'),
  1017. '#default_value' => $vals['InfoMargin'],
  1018. );
  1019. $form['settings']['InfoSharpness'] = array(
  1020. '#type' => 'textfield',
  1021. '#title' => t('Info Sharpness'),
  1022. '#description' => t('Sharpness of the info text (see above). ex: "0"'),
  1023. '#default_value' => $vals['InfoSharpness'],
  1024. );
  1025. $form['settings']['InfoThickness'] = array(
  1026. '#type' => 'textfield',
  1027. '#title' => t('Info Thickness'),
  1028. '#description' => t('Thickness of the info text (see above). ex: "0"'),
  1029. '#default_value' => $vals['InfoThickness'],
  1030. );
  1031. $form['settings']['Autoplay'] = array(
  1032. '#type' => 'textfield',
  1033. '#title' => t('Autoplay'),
  1034. '#description' => t('Number of seconds from one transition to another, if not stopped. Set to 0 to disable autoplay. ex: "10"'),
  1035. '#default_value' => $vals['Autoplay'],
  1036. );
  1037. $form['settings']['FieldOfView'] = array(
  1038. '#type' => 'textfield',
  1039. '#title' => t('Field Of View'),
  1040. '#description' => t('See the official Adobe Docs. ex: "45"'),
  1041. '#default_value' => $vals['FieldOfView'],
  1042. );
  1043. // Add the buttons.
  1044. $form['actions'] = array('#type' => 'actions');
  1045. $form['actions']['submit'] = array(
  1046. '#type' => 'submit',
  1047. '#value' => t('Save Profile'),
  1048. '#weight' => -5,
  1049. );
  1050. if (!empty($profile->pid)) {
  1051. $form['actions']['delete'] = array(
  1052. '#type' => 'submit',
  1053. '#value' => t('Delete'),
  1054. '#weight' => -4,
  1055. '#submit' => array('piecemaker_profile_form_delete_submit'),
  1056. );
  1057. }
  1058. $form['actions']['cancel'] = array(
  1059. '#markup' => l('Cancel', 'admin/config/media/piecemaker'),
  1060. );
  1061. return $form;
  1062. }
  1063. /**
  1064. * Validates piecemaker_profile_form form submissions.
  1065. */
  1066. function piecemaker_profile_form_validate($form, &$form_state) {
  1067. }
  1068. /**
  1069. * Processes piecemaker_profile_form form submissions.
  1070. */
  1071. function piecemaker_profile_form_submit($form, &$form_state) {
  1072. $up = array();
  1073. $values['title'] = $form_state['values']['title'];
  1074. $values['settings'] = $form_state['values']['settings'];
  1075. $transitions = $form_state['values']['transitions'];
  1076. //Get rid of the Add row since they didn't click it here.
  1077. unset($transitions['add']);
  1078. uasort($transitions, 'drupal_sort_weight');
  1079. foreach ($transitions as $trans) {
  1080. unset($trans['weight']);
  1081. $values['transitions'][] = $trans;
  1082. }
  1083. if (!empty($form_state['values']['pid'])) {
  1084. $up = array('pid');
  1085. $values['pid'] = $form_state['values']['pid'];
  1086. }
  1087. $flash = $form_state['values']['flash_settings'];
  1088. $params = $flash['params'];
  1089. unset($params['add'], $flash['params']);
  1090. foreach($params as $param) {
  1091. if (!empty($param['value'])) {
  1092. $flash['params'][$param['key']] = $param['value'];
  1093. }
  1094. }
  1095. $values['flash_settings'] = $flash;
  1096. $success = drupal_write_record('piecemaker_profiles', $values, $up);
  1097. if (!$success) {
  1098. form_set_error('pid', 'There was a problem saving your profile data. Please try again.');
  1099. }
  1100. else {
  1101. drupal_set_message(t('Profile settings saved'));
  1102. $form_state['redirect'] = 'admin/config/media/piecemaker';
  1103. }
  1104. }
  1105. /**
  1106. * Processes delete button piecemaker_profile_form form submissions.
  1107. */
  1108. function piecemaker_profile_form_delete_submit($form, &$form_state) {
  1109. $pid = $form_state['values']['pid'];
  1110. $form_state['redirect'] = "admin/config/media/piecemaker/profiles/{$pid}/delete";
  1111. }
  1112. /**
  1113. * Menu callback -- ask for confirmation of piecemaker_profile deletion
  1114. */
  1115. function piecemaker_profile_delete_confirm($form, &$form_state, $profile) {
  1116. $form['#profile'] = $profile;
  1117. // Always provide entity id in the same form key as in the entity edit form.
  1118. $form['pid'] = array('#type' => 'value', '#value' => $profile->pid);
  1119. return confirm_form($form,
  1120. t('Are you sure you want to delete %title?', array('%title' => $profile->title)),
  1121. 'admin/config/media/piecemaker',
  1122. t('This action cannot be undone.'),
  1123. t('Delete'),
  1124. t('Cancel')
  1125. );
  1126. }
  1127. /**
  1128. * Execute piecemaker_profile deletion
  1129. */
  1130. function piecemaker_profile_delete_confirm_submit($form, &$form_state) {
  1131. if ($form_state['values']['confirm']) {
  1132. $profile = piecemaker_profile_load($form_state['values']['pid']);
  1133. $num_deleted = db_delete('piecemaker_profiles')
  1134. ->condition('pid', $form_state['values']['pid'])
  1135. ->execute();
  1136. watchdog('Piecemaker', 'Piecemaker Profile: deleted %title.', array('%title' => $profile->title));
  1137. drupal_set_message(t('Profile %title has been deleted.', array('%title' => $profile->title)));
  1138. }
  1139. $form_state['redirect'] = 'admin/config/media/piecemaker';
  1140. }
  1141. /**
  1142. * Form submit callback for Adding Flash params
  1143. */
  1144. function piecemaker_add_params_rows($form, &$form_state) {
  1145. // If this is a Ajax POST, add 1, otherwise add 5 more choices to the form.
  1146. if ($form_state['values']['flash_settings']['params']['add']) {
  1147. $n = $_GET['q'] == 'system/ajax' ? 1 : 3;
  1148. $form_state['params_extra'] = $n;
  1149. }
  1150. $flash = $form_state['values']['flash_settings'];
  1151. $params = $flash['params'];
  1152. unset($params['add'], $flash['params']);
  1153. foreach($params as $param) {
  1154. if (!empty($param['value'])) {
  1155. $flash['params'][$param['key']] = $param['value'];
  1156. }
  1157. }
  1158. $form_state['flash_settings']['params'] = $flash['params'];
  1159. $form_state['rebuild'] = TRUE;
  1160. drupal_set_message('Params added. You must save the profile for your changes to be made final.');
  1161. }
  1162. /**
  1163. * Provides the different Transition types
  1164. *
  1165. * @return
  1166. * An Array of the different transition type
  1167. */
  1168. function _piecemaker_transitions() {
  1169. $trans['easeNone'] = 'easeNone';
  1170. $trans['easeInQuad'] = 'easeInQuad';
  1171. $trans['easeOutQuad'] = 'easeOutQuad';
  1172. $trans['easeInOutQuad'] = 'easeInOutQuad';
  1173. $trans['easeOutInQuad'] = 'easeOutInQuad';
  1174. $trans['easeInCubic'] = 'easeInCubic';
  1175. $trans['easeOutCubic'] = 'easeOutCubic';
  1176. $trans['easeInOutCubic'] = 'easeInOutCubic';
  1177. $trans['easeOutInCubic'] = 'easeOutInCubic';
  1178. $trans['easeInQuart'] = 'easeInQuart';
  1179. $trans['easeOutQuart'] = 'easeOutQuart';
  1180. $trans['easeInOutQuart'] = 'easeInOutQuart';
  1181. $trans['easeOutInQuart'] = 'easeOutInQuart';
  1182. $trans['easeInQuint'] = 'easeInQuint';
  1183. $trans['easeOutQuint'] = 'easeOutQuint';
  1184. $trans['easeInOutQuint'] = 'easeInOutQuint';
  1185. $trans['easeOutInQuint'] = 'easeOutInQuint';
  1186. $trans['easeInSine'] = 'easeInSine';
  1187. $trans['easeOutSine'] = 'easeOutSine';
  1188. $trans['easeInOutSine'] = 'easeInOutSine';
  1189. $trans['easeOutInSine'] = 'easeOutInSine';
  1190. $trans['easeInCirc'] = 'easeInCirc';
  1191. $trans['easeOutCirc'] = 'easeOutCirc';
  1192. $trans['easeInOutCirc'] = 'easeInOutCirc';
  1193. $trans['easeOutInCirc'] = 'easeOutInCirc';
  1194. $trans['easeInExpo'] = 'easeInExpo';
  1195. $trans['easeOutExpo'] = 'easeOutExpo';
  1196. $trans['easeInOutExpo'] = 'easeInOutExpo';
  1197. $trans['easeOutInExpo'] = 'easeOutInExpo';
  1198. $trans['easeInElastic'] = 'easeInElastic';
  1199. $trans['easeOutElastic'] = 'easeOutElastic';
  1200. $trans['easeInOutElastic'] = 'easeInOutElastic';
  1201. $trans['easeOutInElastic'] = 'easeOutInElastic';
  1202. $trans['easeInBack'] = 'easeInBack';
  1203. $trans['easeOutBack'] = 'easeOutBack';
  1204. $trans['easeInOutBack'] = 'easeInOutBack';
  1205. $trans['easeOutInBack'] = 'easeOutInBack';
  1206. $trans['easeInBounce'] = 'easeInBounce';
  1207. $trans['easeOutBounce'] = 'easeOutBounce';
  1208. $trans['easeInOutBounce'] = 'easeInOutBounce';
  1209. $trans['easeOutInBounce'] = 'easeOutInBounce';
  1210. return $trans;
  1211. }