Source for file theme_editor.act.php

Documentation is available at theme_editor.act.php

  1. <?php
  2. /**
  3. * @package polyphony.gui
  4. *
  5. * @copyright Copyright &copy; 2006, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: theme_editor.act.php,v 1.4 2007/09/19 14:04:55 adamfranco Exp $
  9. */
  10.  
  11.  
  12. //Note: If you are interested in old CVS versions of this file, try theme_editor.act.php
  13.  
  14.  
  15.  
  16. /**
  17. *
  18. *
  19. * @package polyphony.gui
  20. *
  21. * @copyright Copyright &copy; 2006, Middlebury College
  22. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  23. *
  24. * @version $Id: theme_editor.act.php,v 1.4 2007/09/19 14:04:55 adamfranco Exp $
  25. */
  26.  
  27. define("theme_editorAction_wizardId", 'theme_editor_wizard3_');
  28.  
  29.  
  30. class theme_editorAction
  31. extends MainWindowAction
  32. {
  33.  
  34. /*
  35. GUI Management Notes:
  36.  
  37. Things are going well, but there a lot to be done. The main file is theme_editor.act.php and the GUIWizardComonents folder can be found in polyphony's library.
  38.  
  39. Here are things that NEED to be done:
  40.  
  41. * We need to get default themes that make sense. Design the themes FOR the theme_editor, USING THE NAMING CONVENTIONS OF THE THEME_EDITOR. Then we can make sure that we don't have two collections with different names giving conflicting style information. We should have about five or six. I beleive that adding something like rounded corners will not be affected by the editor, but be wary of adding images, since they can affect color choices.
  42. * We badly need to load and save themes. There are at least three options--create a new theme, modifiy an old theme, or copy and modify an old theme. As a hint, the first step (load_step) and this last step (save_step) both have choices on how to save--only one should. The other hint I can give you is that the saving and loading should be very easy, in theory. Just use the GUIManager to pull it off. I think you need to set the current theme)to be the one you want to save, then can the save function. Be sure that you restore the theme though, or the page will display the new theme--cool, but likely problematic. Also, don't forget that the wizard has a save button. I'd say remove this step completely, decide how you are loading in the load step, then use that save. Actually probably pretty easy.
  43.  
  44.  
  45. Saving may go something like this:
  46.  
  47. $oldTheme = $GUIManager->getTheme();
  48. $GUIManager->setTheme($themeToSave);
  49. $GUIManager->saveTheme();
  50. $GUIManager->setTheme($oldTheme);
  51.  
  52. Loading may go something like this:
  53.  
  54. $oldTheme = $GUIManager->getTheme();
  55. $GUIManager->loadTheme($themeIdToLoad);
  56. $loadedTheme = $GUIManager->getTheme();
  57. $GUIManager->setTheme($oldTheme);
  58.  
  59.  
  60. Here are things that SHOULD be done:
  61.  
  62. * There is currently no way to edit the hover style or the links. This is not very important except when we're editing MENU_LINK either selected or unselected.
  63. * The test page was in no way designed for what I'm using it for. A new test page really ought to be created that does NOT extend MainWindowAction or whatever it's called. It should show off most of the features that you can edit, if not all, and it should look like a Segue 2 page.
  64. * The wizard does not know which button was pressed once it gets to update or step change. This should be passed in in the context of the stepchange, perhaps.
  65.  
  66.  
  67.  
  68.  
  69. Here are things that might be nice:
  70.  
  71. * There is a color picker for quickly choosing menu themes. I think it is far too complicated right now, but it could be neat it it was modified to fit the WMoreOptions sort of pattern. May be more trouble than it's worth.
  72. * You can allow people to enter in new values, but then you assume that they understand whatever they are entering. For example, not many people understand hex values. If you do that then you should add validation. The selectornew had some validation problems, but they may be mostly fixed. Also, the logicwizard and validation is not entirely stable, so watch out.
  73. * It would be cool if there was several test pages you could see, and you could flip through them with radio buttons and hitting refresh. You can add two more files and them add code to the addIFrame method.
  74. * You can't currently edit the appearance of bullet lists or numbered lists, but it would be cool. You'd have to add the StyleComponents to the GUIManager in Harmoni and so forth.
  75.  
  76.  
  77. Here are some general notes:
  78.  
  79. * The regular expressions are not checked. Specificlly, the color should be able to be specified by rgb(255,0,255) or rgb(100%,0.23%,100%) but I don't think it can right now.
  80. * I've had difficulty with logging into concerto--it throws up a prompt box several times and crashes, but it seems only my machine is affected.
  81.  
  82.  
  83. */
  84.  
  85.  
  86. /**
  87. * Check Authorizations
  88. *
  89. * @return boolean
  90. * @access public
  91. * @since 4/26/05
  92. */
  93. function isAuthorizedToExecute () {
  94. $authZManager = Services::getService("AuthZ");
  95. $idManager = Services::getService("IdManager");
  96. if ($authZManager->isUserAuthorized(
  97. $idManager->getId("edu.middlebury.authorization.create_agent"),
  98. $idManager->getId("edu.middlebury.authorization.root")))
  99. {
  100. return TRUE;
  101. } else
  102. return FALSE;
  103. }
  104.  
  105. /**
  106. * Check Authorizations For Templating
  107. *
  108. * @return boolean
  109. * @access public
  110. * @since 4/26/05
  111. */
  112. function isAuthorizedToTemplate () {
  113. $authZManager = Services::getService("AuthZ");
  114. $idManager = Services::getService("IdManager");
  115. if ($authZManager->isUserAuthorized(
  116. $idManager->getId("edu.middlebury.authorization.create_agent"),
  117. $idManager->getId("edu.middlebury.authorization.root")))
  118. {
  119. return TRUE;
  120. } else
  121. return FALSE;
  122. }
  123.  
  124. /**
  125. * Return the "unauthorized" string to pring <em>Note: I think that's supposed to mean print--Tim</em>
  126. *
  127. * @return string
  128. * @access public
  129. * @since 4/26/05
  130. */
  131. function getUnauthorizedMessage () {
  132. return _("You are not authorized to access the Theme Interface.");
  133. }
  134.  
  135. /**
  136. * Return the heading text for this action, or an empty string.
  137. *
  138. * @return string
  139. * @access public
  140. * @since 4/26/05
  141. */
  142. function getHeadingText () {
  143. return _("Theme Management");
  144. }
  145.  
  146. /**
  147. * Build the content for this action
  148. *
  149. * @return boolean
  150. * @access public
  151. * @since 4/26/05
  152. */
  153. function buildContent () {
  154. $harmoni = Harmoni::instance();
  155. $guimanager = Services::getService('GUIManager');
  156. $currentTheme =$guimanager->getTheme();
  157.  
  158. $actionRows =$this->getActionRows();
  159. $cacheName = theme_editorAction_wizardId;// @todo create unique cache name;
  160.  
  161. $this->runWizard ( $cacheName, $actionRows );
  162. }
  163.  
  164. /**
  165. * Create a new Wizard for this action. Caching of this Wizard is handled by
  166. * {@link getWizard()} and does not need to be implemented here.
  167. *
  168. * @return object Wizard
  169. * @access public
  170. * @since 4/28/05
  171. */
  172. function createWizard () {
  173.  
  174.  
  175.  
  176.  
  177. $harmoni = Harmoni::instance();
  178. $guiManager = Services::getService('GUIManager');
  179.  
  180. $currentTheme =$guiManager->getTheme();
  181.  
  182. // Instantiate the wizard, then add our steps.
  183. //$wizard = new LogicStepWizard();
  184. // $wizard = SimpleStepWizard::withDefaultLayout();
  185. $wizard = LogicStepWizard::withDefaultLayout();
  186.  
  187. $stepChangedListener = new WStepChangedListener("theme_editorAction::handleStepChange");
  188. $updateListener = new WUpdateListener("theme_editorAction::handleUpdate");
  189. $wizard->addEventListener($stepChangedListener);
  190. $wizard->addEventListener($updateListener);
  191.  
  192. $stepContainer =$wizard->getStepContainer();
  193.  
  194. /*********************************************************
  195. * LOAD STEP
  196. *********************************************************/
  197.  
  198.  
  199.  
  200.  
  201. $loadStep =$wizard->addStep('load_step', new WizardStep());
  202. $loadStep->setDisplayName(_("This is the load step:"));
  203.  
  204. ob_start();
  205.  
  206.  
  207. // select list for listing themes user can access
  208. $loadChoice =$loadStep->addComponent('load_choice',
  209. new WSelectList());
  210. //$loadChoice->addOption('', '(choose a theme to copy or edit)');
  211. //$loadChoice->setValue('');
  212.  
  213. // get All themes that user can copy and populate list with them
  214. $theme_choices = $guiManager->getThemeListForUser();
  215.  
  216.  
  217.  
  218. foreach ($theme_choices as $idString => $dName) {
  219. $loadChoice->addOption($idString, $dName);
  220. }
  221.  
  222.  
  223.  
  224. // add buttons... copy to new, update, create from scratch.
  225. $copyButton =$loadStep->addComponent('copy',
  226. WLogicButton::withLabel(_('Copy to New...')));
  227. $loadButton =$loadStep->addComponent('load',
  228. WLogicButton::withLabel(_('Load for Edit...')));
  229. $newButton =$loadStep->addComponent('new',
  230. WLogicButton::withLabel(_('Create Empty...')));
  231.  
  232.  
  233.  
  234.  
  235.  
  236. // create logic for buttons
  237. $newThemeRule = WLogicRule::withSteps(array('dd_step', 'home_step','save_step'));
  238. $copyButton->setLogic(WLogicRule::withSteps(array('home_step','save_step')));
  239. $newButton->setLogic($newThemeRule);
  240. $loadButton->setLogic(WLogicRule::withSteps(array('home_step','save_step')));
  241.  
  242.  
  243.  
  244.  
  245. // add markup for step
  246.  
  247.  
  248.  
  249.  
  250. print "<table>\n\t<tr>\n\t\t<td rowspan='3'>[[load_choice]]</td>";
  251. print "\n\t\t<td>[[copy]]</td>\n\t</tr>";
  252. print "\n\t<tr>\n\t\t<td>[[load]]</td>\n\t</tr>";
  253. print "\n\t<tr>\n\t\t<td>[[new]]</td>\n\t</tr>";
  254.  
  255.  
  256. //@todo--perhaps a way to sample what each theme looks like would be helpful. An iframe could be useful here, but some modification is needed before it would work--the theme is not created until the step changes.
  257.  
  258. $loadStep->setContent(ob_get_contents());
  259. ob_end_clean();
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266. /*********************************************************
  267. * DISPLAYNAME DESCRIPTION STEP
  268. *********************************************************/
  269. $ddStep =$wizard->addStep('dd_step', new WizardStep());
  270.  
  271. // display name and description fields for theme
  272. $dName =$ddStep->addComponent('display_name', new WTextField());
  273. $desc =$ddStep->addComponent('description', new WTextArea());
  274. $ddStep->addComponent('next', new WNextStepButton($stepContainer));
  275.  
  276. // add markup for step
  277. ob_start();
  278. print "\n<table width=100%>\n\t<tr>\n\t\t<td>";
  279. print "\t<table>\n\t\t<tr>\n\t\t\t<td>"._('Display Name:')."</td>";
  280. print "\n\t\t\t<td>[[display_name]]</td>\n\t\t</tr>";
  281. print "\n\t\t<tr>\n\t\t<td>"._('Description')."</td>";
  282. print "\n\t\t\t<td>[[description]]</td>\n\t\t</tr></table>";
  283. print "\n\t</td><td align=right valign=bottom>";
  284. print "\n\t\t[[next]]\n\t</td>\n</tr></table>";
  285.  
  286.  
  287. $ddStep->setContent(ob_get_clean());
  288.  
  289. /*********************************************************
  290. * GLOBAL STYLES STEP
  291. *********************************************************/
  292. $globalStep =$wizard->addStep('global_step', new WDynamicStep());
  293. $globalStep->setDynamicFunction('theme_editorAction::globalStepCallBack');
  294.  
  295.  
  296. /*********************************************************
  297. * HOME STEP AND EDITING STEPS
  298. *********************************************************/
  299. $homeStep =$wizard->addStep('home_step', new WizardStep());
  300.  
  301. //===== BUTTONS =====//
  302. // Quick Manipulation
  303. $button = WLogicButton::withLabel('Quick and Easy Editing');
  304. $homeStep->addComponent('quick',$button);
  305. $button->setLogic(WLogicRule::withSteps(array('quick_step','home_step')));
  306.  
  307. // D&D
  308. $button = WLogicButton::withLabel('Display Name and Description');
  309. $homeStep->addComponent('d_d',$button);
  310. $button->setLogic(WLogicRule::withSteps(array('dd_step','home_step')));
  311.  
  312. // Global
  313. $button = WLogicButton::withLabel('Semi-obselete way to fix things');
  314. $homeStep->addComponent('global',$button);
  315. $button->setLogic(WLogicRule::withSteps(array('global_step','home_step')));
  316.  
  317.  
  318. // Start Over
  319. $button = new WCallbackButton();
  320. $homeStep->addComponent('load',$button);
  321. $button->setEventAndLabel('theme_editorAction::resetToBeginning($this->getWizard());','Back to Beginning');
  322.  
  323. // Save
  324. $homeStep->addComponent('go_save',
  325. new WNextStepButton($wizard->_stepContainer, dgettext("polyphony","Finish")));
  326.  
  327. // add markup for step
  328. ob_start();
  329. // @todo iframe for previewing theme
  330. print "\n<table width=100%>\n\t<tr>\n\t\t<td>";
  331. print "\n<table>";
  332. print "\n\t<tr>";
  333. print "\n\t\t<td colspan='2'>"._('Choose a few simple options for a quick customized theme:')."</td><td colspan='2'>[[quick]]</td>\n\r</tr>";
  334. print "\n\t<tr>";
  335. print "\n\t\t<td>"._('Edit the Display Name and Description of this theme:')."</td><td>[[d_d]]</td><td>"._('This is an old way to edit properties. It has the advantage that it can edit some global properties:')."</td><td>[[global]]</td>\n\t";
  336.  
  337.  
  338.  
  339. ////////////////////////////////////////////////////////////////////////////////////
  340. //Buttons and Steps
  341. //
  342. //remember that the editing steps are created here!
  343. ///////////////////////////////////////////////////////////////////////////////////
  344. print "\n\t</tr><tr>";
  345. //options
  346. $name = "block1";
  347. $label = "Background";
  348. $explanation = "Edit the main background:";
  349. $info = "Your entire site will apper on top of this block.";
  350. $arr = array(array('type'=>BLOCK,'index'=>1));
  351. //execute
  352. $this->addAnEditingStep($wizard, $name,$arr, $info, false, true, false);
  353. $button = WLogicButton::withLabel($label);
  354. $homeStep->addComponent($name.'_button',$button);
  355. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  356. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  357. //options
  358. $name = "block2";
  359. $label = "Content";
  360. $explanation = "Edit the appearance of your content. It should be easy to read.";
  361. $info = "In this step you can modify the look of your main content";
  362. $arr = array(array('type'=>BLOCK,'index'=>2));
  363. //execute
  364. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, true);
  365. $button = WLogicButton::withLabel($label);
  366. $homeStep->addComponent($name.'_button',$button);
  367. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  368. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  369. print "\n\t</tr><tr>";
  370. //options
  371. $name = "heading1";
  372. $label = "Heading";
  373. $explanation = "Edit the main Heading:";
  374. $info = "This is where the name of each page should appear. It should be noticable.";
  375. $arr = array(array('type'=>HEADING,'index'=>1));
  376. //execute
  377. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  378. $button = WLogicButton::withLabel($label);
  379. $homeStep->addComponent($name.'_button',$button);
  380. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  381. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  382. //options
  383. $name = "heading2";
  384. $label = "Subheading";
  385. $explanation = "Edit the headings in your content";
  386. $info = "To separate pieces of your content, you use headings like this. They should stand out from the main text.";
  387. $arr = array(array('type'=>HEADING,'index'=>2));
  388. //execute
  389. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  390. $button = WLogicButton::withLabel($label);
  391. $homeStep->addComponent($name.'_button',$button);
  392. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  393. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  394. print "\n\t</tr><tr>";
  395. //options
  396. $name = "header";
  397. $label = "Header";
  398. $explanation = "Edit the header:";
  399. $info = "This appears at the very top and likely won't change much.";
  400. $arr = array(array('type'=>HEADER,'index'=>1));
  401. //execute
  402. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  403. $button = WLogicButton::withLabel($label);
  404. $homeStep->addComponent($name.'_button',$button);
  405. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  406. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  407. //options
  408. $name = "footer";
  409. $label = "Footer";
  410. $explanation = "Edit the footer";
  411. $info = "This appears at the very bottom. It could look like the header for symmetry or could be completely different. *NOTE TO DEVELOPER* I really think the two should go on the same page. put the to WMultiCollections in a table, preferably side by side with labels at the top.";
  412. $arr = array(array('type'=>FOOTER,'index'=>1));
  413. //execute
  414. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  415. $button = WLogicButton::withLabel($label);
  416. $homeStep->addComponent($name.'_button',$button);
  417. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  418. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  419.  
  420.  
  421. print "\n\t</tr><tr>";
  422. //options
  423. $name = "menu";
  424. $label = "Menu";
  425. $explanation = "Edit the Menu appearance:";
  426. $info = "This mostly will change the background of the menu. *NOTE TO DEVELOPER* This only changes menu level one, so if you guys want menu level two, you'd better add it.";
  427. $arr = array(array('type'=>MENU,'index'=>1));
  428. //execute
  429. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  430. $button = WLogicButton::withLabel($label);
  431. $homeStep->addComponent($name.'_button',$button);
  432. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  433. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  434. //options
  435. $name = "menu_heading";
  436. $label = "Menu Headings";
  437. $explanation = "Edit the headings inside menus:";
  438. $info = "Menus do not necesarily have menu headings, but if they do, it would be nice if they stood out. *NOTE TO DEVELOPER* there are four things for the menu, but it should really be condensed. I think that a WBackGround Editor would be sufficient for the selected and unselected links, and a WFontEditor would probably be sufficient for the heading. If you didn't use the entire WMultiCollection, it would allow cascading of sensible things to cascade.";
  439. $arr = array(array('type'=>MENU_ITEM_HEADING,'index'=>1));
  440. //execute
  441. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  442. $button = WLogicButton::withLabel($label);
  443. $homeStep->addComponent($name.'_button',$button);
  444. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  445. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  446.  
  447. print "\n\t</tr><tr>";
  448. //options
  449. $name = "menu_selected";
  450. $label = "Selected";
  451. $explanation = "Selected Menu Items";
  452. $info = "This is what the current link probably looks like. *NOTE TO DEVELOPER* there are four things for the menu, but it should really be condensed. I think that a WBackGround Editor would be sufficient for the selected and unselected links, and a WFontEditor would probably be sufficient for the heading. If you didn't use the entire WMultiCollection, it would allow cascading of sensible things to cascade. Also, keep in mind that we don't currently edit those link colors, since it does not apply to link--bad business.";
  453. $arr = array(array('type'=>MENU_ITEM_LINK_SELECTED,'index'=>1));
  454. //execute
  455. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  456. $button = WLogicButton::withLabel($label);
  457. $homeStep->addComponent($name.'_button',$button);
  458. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  459. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  460. //options
  461. $name = "menu_unselected";
  462. $label = "Unselected";
  463. $explanation = "Unselected Menu Items";
  464. $info = "This is what the NON-current links probably looks like. *NOTE TO DEVELOPER* there are four things for the menu, but it should really be condensed. I think that a WBackGround Editor would be sufficient for the selected and unselected links, and a WFontEditor would probably be sufficient for the heading. If you didn't use the entire WMultiCollection, it would allow cascading of sensible things to cascade. Also, keep in mind that we don't currently edit those link colors, since it does not apply to link--bad business.";
  465. $arr = array(array('type'=>MENU_ITEM_LINK_UNSELECTED,'index'=>1));
  466. //execute
  467. $this->addAnEditingStep($wizard, $name,$arr, $info, true, true, false);
  468. $button = WLogicButton::withLabel($label);
  469. $homeStep->addComponent($name.'_button',$button);
  470. $button->setLogic(WLogicRule::withSteps(array($name.'_step','home_step')));
  471. print "\n\t\t<td>"._($explanation)."</td><td>[[".$name."_button]]</td>";
  472.  
  473.  
  474. print "\n\t</tr><tr>";
  475.  
  476. print "\n\t\t<td>"._('Go Back to the beginning and choose a theme to modify:')."</td><td>[[load]]</td><td>&nbsp;</td>\n\t</tr>";
  477. print "\n</table>";
  478. print "\n\t</td></tr><tr><td align=right valign=bottom>";
  479. print "\n\t\tSave and finish: [[go_save]]\n\t</td>\n</tr></table>";
  480.  
  481.  
  482.  
  483.  
  484. print $this->addIFrame($homeStep);
  485.  
  486. $homeStep->setContent(ob_get_clean());
  487.  
  488.  
  489. /*********************************************************
  490. * SAVE STEP
  491. *********************************************************/
  492.  
  493. //@todo read the text that I tell it to print out. I suspect that this step should be deleted.
  494.  
  495. $saveStep =$wizard->addStep('save_step', new WizardStep());
  496.  
  497. // how do you want to save your theme
  498. $saveStyle =$saveStep->addComponent('save_style', new WSelectList());
  499. $saveStyle->addOption('new', _('Save as a new Theme'));
  500. $saveStyle->addOption('update', _('Save as updated Theme'));
  501. if (theme_editorAction::isAuthorizedToTemplate()) {
  502. $saveStyle->addOption('public', _('Save as new public Theme'));
  503. $saveStyle->addOption('delete', _('Remove Theme from system'));
  504. }
  505.  
  506. $saveStep->addComponent('save', new WSaveButton());
  507. $saveStep->addComponent('quit', new WCancelButton("Quit"));
  508.  
  509. ob_start();
  510. print _("*NOTE TO DEVELOPER* This is not really edited from Shubert's old code, so if you're the one implementing save, that's too bad--not done. This is really not very liekly to help much. As a hint, the first step (load_step) and this last step should not both be here. Choose one or the other. The other hint I can give you is that the saving and loading should be very easy, in theory. Just use the GUIManager to pull it off. I think you need to set the current theme to be the one you want to save, then can the save function. Be sure that you restore the theme though, or the page will display the new theme--cool, but likely problematic. Also, don't forget that the wizard has a save button. I'd say remove this step completely, decide how you are loading in the load step, then use that save. Actually probably pretty easy.
  511. <p> Here's the old text:</p>
  512. Here you must choose how to save your Theme. You can save your work as a new Theme (if you were working on an existant Theme this will leave the original Theme unharmed). You can also save your work as an updated Theme, which will replace the original Theme you may have loaded (if you have permission to do so).");
  513. print "<br/>";
  514. print "<table width=100%><tr><td>[[save_style]][[save]]</td><td align=right>[[quit]]</td></tr></table>";
  515. $saveStep->setContent(ob_get_clean());
  516.  
  517. //add steps:
  518.  
  519. $wizard->setRequiredSteps(array('load_step'));
  520.  
  521. return $wizard;
  522.  
  523. }
  524.  
  525. /**
  526. * Save our results. Tearing down and unsetting the Wizard is handled by
  527. * in {@link runWizard()} and does not need to be implemented here.
  528. *
  529. * @param string $cacheName
  530. * @return boolean TRUE if save was successful and tear-down/cleanup of the
  531. * Wizard should ensue.
  532. * @access public
  533. * @since 4/28/05
  534. */
  535. function saveWizard ( $cacheName ) {
  536. //@todo this does not actually save the theme. Maybe it should. See the save step for hints.
  537.  
  538. $guiManager = Services::getService("GUI");
  539. $wizard =$this->getWizard($cacheName);
  540.  
  541.  
  542. if($wizard->validate()){
  543. print "success!";
  544. }else{
  545. print "fail!";
  546. return;
  547. }
  548. $theme = theme_editorAction::getTheme();
  549.  
  550. if(!is_null($theme)){
  551. print $theme->getCSS();
  552. }
  553. }
  554.  
  555.  
  556. /**
  557. * This adds an iframe to the page that previews the frame, plus a button to refresh the view
  558. *
  559. * @return void
  560. * @access public
  561. * @since 8/8/06
  562. */
  563. function addIFrame($theStep) {
  564.  
  565. //@todo It wouldn't be all that hard to add a series of three radio buttons, each allowing a new theme. It would be really cool and quite useful.
  566.  
  567. //@todo I'm not sure if its a good idea or easy, but here's an idea--every time the user changes something, the thing relods, probably through javascript. I suspect it would make work frustratingly slow and be difficult though.
  568.  
  569. $s = "";
  570. $harmoni = Harmoni::instance();
  571.  
  572. $url = $harmoni->request->quickURL("gui","test_page", array("theme"=>theme_editorAction_wizardId."__theme"));
  573.  
  574. $refreshButton =$theStep->addComponent('refresh_preview',
  575. WEventButton::withLabel(_('Refresh...')));
  576.  
  577.  
  578. $s .= "<hr />";
  579. $s .= "\n\t<table width='100%'><tr>";
  580. $s .= "\n\t\t<td align='left'><h2>Preview: </h2></td>";
  581. $s .= "\n\t\t<td align='right'>Refresh preview: [[refresh_preview]]</td>";
  582. $s .= "</tr></table>";
  583. $s .= "\n\t\t<div style='background-color: #FFF'>";
  584. $s .= "\n\t\t\t<iframe src='".$url."'width='100%' height='700' frameborder=1 scrolling='auto'>";
  585. $s .= "\n\t\t\t\t<a href='".$url."'>Preview</a>";
  586. $s .= "\n\t\t\t</iframe>";
  587. $s .= "\n\t\t</div>";
  588.  
  589. return $s;
  590. }
  591.  
  592.  
  593. /**
  594. *
  595. * @return void
  596. * @access public
  597. * @since 6/1/06
  598. */
  599. function handleUpdate ($source, $context) {
  600. //do you need control of the Wizard each step? This could be very useful. You could probably use this to replace the dynamic step if need be.
  601.  
  602. }
  603.  
  604.  
  605.  
  606. function globalStepCallBack($step){
  607. $s = "";
  608.  
  609. $wizard =$step->getWizard();
  610. $stepContainer =$wizard->getStepContainer();
  611. $theme = theme_editorAction::getTheme();
  612.  
  613. if(!is_null($theme)){
  614. $styleCollections =$theme->getStyleCollections();
  615.  
  616. $children =$step->getChildren();
  617. foreach(array_keys($children) as $key){
  618. $step->removeChild($key);
  619. }
  620.  
  621. //next step
  622. $step->setComponent('next', new WNextStepButton($stepContainer));
  623.  
  624.  
  625. $s.= "Global Styles:<br/>";
  626. $s.= "Here you can choose a few simple global attributes for your theme.<br/>";
  627. $s.= "\n<table width=100%>\n\t<tr>\n\t\t<td>";
  628. $s.= "<table border=0>\n\t";
  629.  
  630. $i = 0;
  631. foreach(array_keys($styleCollections) as $key){
  632. $i++;
  633. $name = 'collection_'.$i;
  634. $comp = new WStyleCollection("theme_editorAction::getTheme",$key);
  635. $step->setComponent($name,$comp);
  636. $s.= "\n\t<tr>";
  637. $s.= "\n\t\t<td>[[".$name."]]</td>";
  638. $s.= "\n\t</tr>";
  639. }
  640. $s.= "\n\t</table>";
  641. $s.= "\n\t</td><td align=right valign=bottom>";
  642. $s.= "\n\t\t[[next]]\n\t</td>\n</tr></table>";
  643. $s.= theme_editorAction::addIFrame($step);
  644. }
  645.  
  646. return $s;
  647. }
  648.  
  649.  
  650. /**
  651. * This gives the wizard control after each change in step and tells which the previous and current steps are.
  652. *
  653. * @return void
  654. * @access public
  655. * @since 6/1/06
  656. */
  657. function handleStepChange ($source, $context) {
  658. //@todo This function has a serious problem--it can't tell which button was pressed. It really ought to be part of the context, but it isn't. A new event listeneter for each button is silly, but a generic one might be possible. Another idea is just using a WCallback button. Another is storing the fieldname and passing that in.
  659.  
  660. //@todo This is unfortunate in that hitting back to this step will delete all your changes. If you fix the above problem, that should go away.
  661. $wizard =$source->getWizard();
  662. $values = $wizard->getAllValues();
  663. if($context['from']=="load_step"){
  664. if($context['to']=="dd_step"){
  665. $_SESSION[theme_editorAction_wizardId.'__theme'] = new SimpleLinesTheme();
  666. }else{
  667. $startingTheme=$values["load_step"]["load_choice"];
  668. $codeToExecute = '$_SESSION["'.theme_editorAction_wizardId.'__theme"] = new '.$startingTheme.'();';
  669. eval($codeToExecute);
  670. }
  671. }
  672. }
  673.  
  674.  
  675. function addAnEditingStep($wizard, $name, $arr, $info, $font, $bg, $text ){
  676.  
  677. $stepContainer =$wizard->getStepContainer();
  678.  
  679. $step =$wizard->addStep($name.'_step', new WizardStep());
  680. $step->addComponent('next', new WNextStepButton($stepContainer));
  681. $step->addComponent('main', new WMultiCollection("theme_editorAction::getTheme",$name,$arr,$font,$bg, $text));
  682. $s = "";
  683. $s.= $info;
  684. $s.= "<p>[[main]]</p>";
  685. $s.= "<p align='right'>[[next]]</p>";
  686. $s.= theme_editorAction::addIFrame($step);
  687. $step->setContent($s);
  688. }
  689.  
  690.  
  691.  
  692.  
  693.  
  694. /**
  695. * This is the all important function that gives the Wizard control after
  696. * all of its components have been updated since the last pagelaod
  697. *
  698. * @return void
  699. * @access public
  700. * @since 6/1/06
  701. */
  702. function resetToBeginning($wizard) {
  703. print "reset";
  704. $wizard->setRequiredSteps(array('load_step'));
  705. }
  706.  
  707. /**
  708. * Return the URL that this action should return to when completed.
  709. *
  710. * @return string
  711. * @access public
  712. * @since 4/28/05
  713. */
  714. function getReturnUrl () {
  715. $harmoni = Harmoni::instance();
  716. //@todo this, of course, should be in the user folder eventually.
  717. return $harmoni->request->quickURL("admin", "main");
  718. }
  719.  
  720.  
  721. function getTheme(){
  722. return $_SESSION[theme_editorAction_wizardId."__theme"];
  723. }
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732. }

Documentation generated on Wed, 19 Sep 2007 10:27:22 -0400 by phpDocumentor 1.3.0RC3