/** * virtual constructor * * @param string $label * @return ref object * @access public * @static * @since 5/31/06 */ static function withLabel($label) { $button = new WLogicButton(); $button->setLabel($label); return $button; }
/** * Create a new Wizard for this action. Caching of this Wizard is handled by * {@link getWizard()} and does not need to be implemented here. * * @return object Wizard * @access public * @since 4/28/05 */ function createWizard() { $harmoni = Harmoni::instance(); $guiManager = Services::getService('GUIManager'); $currentTheme = $guiManager->getTheme(); // Instantiate the wizard, then add our steps. //$wizard = new LogicStepWizard(); // $wizard = SimpleStepWizard::withDefaultLayout(); $wizard = LogicStepWizard::withDefaultLayout(); $stepChangedListener = new WStepChangedListener("theme_editorAction::handleStepChange"); $updateListener = new WUpdateListener("theme_editorAction::handleUpdate"); $wizard->addEventListener($stepChangedListener); $wizard->addEventListener($updateListener); $stepContainer = $wizard->getStepContainer(); /********************************************************* * LOAD STEP *********************************************************/ $loadStep = $wizard->addStep('load_step', new WizardStep()); $loadStep->setDisplayName(_("This is the load step:")); ob_start(); // select list for listing themes user can access $loadChoice = $loadStep->addComponent('load_choice', new WSelectList()); //$loadChoice->addOption('', '(choose a theme to copy or edit)'); //$loadChoice->setValue(''); // get All themes that user can copy and populate list with them $theme_choices = $guiManager->getThemeListForUser(); foreach ($theme_choices as $idString => $dName) { $loadChoice->addOption($idString, $dName); } // add buttons... copy to new, update, create from scratch. $copyButton = $loadStep->addComponent('copy', WLogicButton::withLabel(_('Copy to New...'))); $loadButton = $loadStep->addComponent('load', WLogicButton::withLabel(_('Load for Edit...'))); $newButton = $loadStep->addComponent('new', WLogicButton::withLabel(_('Create Empty...'))); // create logic for buttons $newThemeRule = WLogicRule::withSteps(array('dd_step', 'home_step', 'save_step')); $copyButton->setLogic(WLogicRule::withSteps(array('home_step', 'save_step'))); $newButton->setLogic($newThemeRule); $loadButton->setLogic(WLogicRule::withSteps(array('home_step', 'save_step'))); // add markup for step print "<table>\n\t<tr>\n\t\t<td rowspan='3'>[[load_choice]]</td>"; print "\n\t\t<td>[[copy]]</td>\n\t</tr>"; print "\n\t<tr>\n\t\t<td>[[load]]</td>\n\t</tr>"; print "\n\t<tr>\n\t\t<td>[[new]]</td>\n\t</tr>"; //@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. $loadStep->setContent(ob_get_contents()); ob_end_clean(); /********************************************************* * DISPLAYNAME DESCRIPTION STEP *********************************************************/ $ddStep = $wizard->addStep('dd_step', new WizardStep()); // display name and description fields for theme $dName = $ddStep->addComponent('display_name', new WTextField()); $desc = $ddStep->addComponent('description', new WTextArea()); $ddStep->addComponent('next', new WNextStepButton($stepContainer)); // add markup for step ob_start(); print "\n<table width=100%>\n\t<tr>\n\t\t<td>"; print "\t<table>\n\t\t<tr>\n\t\t\t<td>" . _('Display Name:') . "</td>"; print "\n\t\t\t<td>[[display_name]]</td>\n\t\t</tr>"; print "\n\t\t<tr>\n\t\t<td>" . _('Description') . "</td>"; print "\n\t\t\t<td>[[description]]</td>\n\t\t</tr></table>"; print "\n\t</td><td align=right valign=bottom>"; print "\n\t\t[[next]]\n\t</td>\n</tr></table>"; $ddStep->setContent(ob_get_clean()); /********************************************************* * GLOBAL STYLES STEP *********************************************************/ $globalStep = $wizard->addStep('global_step', new WDynamicStep()); $globalStep->setDynamicFunction('theme_editorAction::globalStepCallBack'); /********************************************************* * HOME STEP AND EDITING STEPS *********************************************************/ $homeStep = $wizard->addStep('home_step', new WizardStep()); //===== BUTTONS =====// // Quick Manipulation $button = WLogicButton::withLabel('Quick and Easy Editing'); $homeStep->addComponent('quick', $button); $button->setLogic(WLogicRule::withSteps(array('quick_step', 'home_step'))); // D&D $button = WLogicButton::withLabel('Display Name and Description'); $homeStep->addComponent('d_d', $button); $button->setLogic(WLogicRule::withSteps(array('dd_step', 'home_step'))); // Global $button = WLogicButton::withLabel('Semi-obselete way to fix things'); $homeStep->addComponent('global', $button); $button->setLogic(WLogicRule::withSteps(array('global_step', 'home_step'))); // Start Over $button = new WCallbackButton(); $homeStep->addComponent('load', $button); $button->setEventAndLabel('theme_editorAction::resetToBeginning($this->getWizard());', 'Back to Beginning'); // Save $homeStep->addComponent('go_save', new WNextStepButton($wizard->_stepContainer, dgettext("polyphony", "Finish"))); // add markup for step ob_start(); // @todo iframe for previewing theme print "\n<table width=100%>\n\t<tr>\n\t\t<td>"; print "\n<table>"; print "\n\t<tr>"; 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>"; print "\n\t<tr>"; 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"; //////////////////////////////////////////////////////////////////////////////////// //Buttons and Steps // //remember that the editing steps are created here! /////////////////////////////////////////////////////////////////////////////////// print "\n\t</tr><tr>"; //options $name = "block1"; $label = "Background"; $explanation = "Edit the main background:"; $info = "Your entire site will apper on top of this block."; $arr = array(array('type' => BLOCK, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, false, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; //options $name = "block2"; $label = "Content"; $explanation = "Edit the appearance of your content. It should be easy to read."; $info = "In this step you can modify the look of your main content"; $arr = array(array('type' => BLOCK, 'index' => 2)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, true); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; print "\n\t</tr><tr>"; //options $name = "heading1"; $label = "Heading"; $explanation = "Edit the main Heading:"; $info = "This is where the name of each page should appear. It should be noticable."; $arr = array(array('type' => HEADING, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; //options $name = "heading2"; $label = "Subheading"; $explanation = "Edit the headings in your content"; $info = "To separate pieces of your content, you use headings like this. They should stand out from the main text."; $arr = array(array('type' => HEADING, 'index' => 2)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; print "\n\t</tr><tr>"; //options $name = "header"; $label = "Header"; $explanation = "Edit the header:"; $info = "This appears at the very top and likely won't change much."; $arr = array(array('type' => HEADER, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; //options $name = "footer"; $label = "Footer"; $explanation = "Edit the footer"; $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."; $arr = array(array('type' => FOOTER, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; print "\n\t</tr><tr>"; //options $name = "menu"; $label = "Menu"; $explanation = "Edit the Menu appearance:"; $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."; $arr = array(array('type' => MENU, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; //options $name = "menu_heading"; $label = "Menu Headings"; $explanation = "Edit the headings inside menus:"; $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."; $arr = array(array('type' => MENU_ITEM_HEADING, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; print "\n\t</tr><tr>"; //options $name = "menu_selected"; $label = "Selected"; $explanation = "Selected Menu Items"; $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."; $arr = array(array('type' => MENU_ITEM_LINK_SELECTED, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; //options $name = "menu_unselected"; $label = "Unselected"; $explanation = "Unselected Menu Items"; $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."; $arr = array(array('type' => MENU_ITEM_LINK_UNSELECTED, 'index' => 1)); //execute $this->addAnEditingStep($wizard, $name, $arr, $info, true, true, false); $button = WLogicButton::withLabel($label); $homeStep->addComponent($name . '_button', $button); $button->setLogic(WLogicRule::withSteps(array($name . '_step', 'home_step'))); print "\n\t\t<td>" . _($explanation) . "</td><td>[[" . $name . "_button]]</td>"; print "\n\t</tr><tr>"; print "\n\t\t<td>" . _('Go Back to the beginning and choose a theme to modify:') . "</td><td>[[load]]</td><td> </td>\n\t</tr>"; print "\n</table>"; print "\n\t</td></tr><tr><td align=right valign=bottom>"; print "\n\t\tSave and finish: [[go_save]]\n\t</td>\n</tr></table>"; print $this->addIFrame($homeStep); $homeStep->setContent(ob_get_clean()); /********************************************************* * SAVE STEP *********************************************************/ //@todo read the text that I tell it to print out. I suspect that this step should be deleted. $saveStep = $wizard->addStep('save_step', new WizardStep()); // how do you want to save your theme $saveStyle = $saveStep->addComponent('save_style', new WSelectList()); $saveStyle->addOption('new', _('Save as a new Theme')); $saveStyle->addOption('update', _('Save as updated Theme')); if (theme_editorAction::isAuthorizedToTemplate()) { $saveStyle->addOption('public', _('Save as new public Theme')); $saveStyle->addOption('delete', _('Remove Theme from system')); } $saveStep->addComponent('save', new WSaveButton()); $saveStep->addComponent('quit', new WCancelButton("Quit")); ob_start(); 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.\n\t\t\n\t\t<p> Here's the old text:</p>\n\t\t\n\t\t\n\t\tHere 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)."); print "<br/>"; print "<table width=100%><tr><td>[[save_style]][[save]]</td><td align=right>[[quit]]</td></tr></table>"; $saveStep->setContent(ob_get_clean()); //add steps: $wizard->setRequiredSteps(array('load_step')); return $wizard; }