/** * Create the wizard * * @return object Wizard * @access public * @since 11/14/07 */ public function createWizard() { // Instantiate the wizard, then add our steps. $wizard = SingleStepWizard::withText("<div>\n" . "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n" . "<tr>\n" . "<td align='left' width='50%'>\n" . "[[save_and_choose]]\n" . "<br/>[[cancel_and_choose]]\n" . "</td>\n" . "<td align='right' width='50%'>\n" . "[[_save]]\n" . "<br/>[[_cancel]]\n" . "</td></tr></table>" . "</div>\n" . "<hr/>\n" . "<div>\n" . "[[_steps]]" . "</div>\n"); $wizard->addComponent("choose_user", new ButtonPressedListener("edu.middlebury.segue.choose_user")); $button = $wizard->addComponent("save_and_choose", WSaveButton::withLabel("<< " . _("Save and Choose User"))); $button->addEvent("edu.middlebury.segue.choose_user"); $button = $wizard->addComponent("cancel_and_choose", WCancelButton::withLabel("<< " . _("Cancel and Choose User"))); $button->addEvent("edu.middlebury.segue.choose_user"); $step = $wizard->addStep("permissions", new WizardStep()); $step->addComponent("perms_table", $this->getPermissionsMatrix()); $agent = $this->getAgent(); if ($agent->isGroup()) { $type = _("group"); } else { $type = _("user"); } $title = str_replace("%1", $type, str_replace("%2", $agent->getDisplayName(), _("Roles for %1 '%2'"))); ob_start(); print "\n<h2>" . $title . "</h2>"; print "\n<p>"; print _("Roles are additive -- this means that you can add additional roles (but not remove them) for child-nodes."); print "\n</p>\n"; print "\n<p>"; print _("Note: Segue 2 does not currently support role-effective dates."); print "\n</p>\n"; print "\n<p>"; print _("Tip: Hold down the <em>SHIFT</em> key while clicking to revoke roles from child-nodes."); print "\n</p>\n"; print "[[perms_table]]"; $step->setContent(ob_get_clean()); return $wizard; }
/** * Create a new Wizard for this action. Caching of this Wizard is handled by * {@link getWizard()} and does not need to be implemented here. * @access public * @since 7/18/05 */ function createWizard() { $wizard = SimpleWizard::withText("<table border='0' style='margin-top:20px' >\n" . "\n<tr><td><h3>" . _("File type:") . "</h3></td></tr>" . "\n<tr><td>" . _("The type of file to be imported: ") . "</td>" . "\n<td>[[file_type]]</td></tr>" . "\n<tr><td>" . _("Is this file an archive? ") . "</td>" . "\n<td>[[is_archived]]</td></tr>" . "\n<tr><td><h3>" . _("Import type:") . "</h3></td></tr>" . "\n<tr><td>" . _("The type of import to execute: ") . "</td>" . "\n<td>[[import_type]]</td></tr>" . "\n<tr><td><h3>" . _("File:") . "</h3></td></tr>" . "\n<tr><td>" . _("The file to be imported: ") . "</td>" . "\n<td>[[filename]]</td>" . "<tr>\n" . "<td align='left'>\n" . "[[_cancel]]" . "</td>\n" . "<td align='right'>\n" . "[[_save]]" . "</td></tr></table>"); $select = $wizard->addComponent("file_type", new WSelectList()); // $select->addOption("Tab-Delimited", "Tab-Delimited"); $select->addOption("XML", "XML"); // $select->addOption("Exif", "Exif"); // $select->setValue("Tab-Delimited"); $archive = $wizard->addComponent("is_archived", WCheckBox::withLabel("is Archived")); $type = $wizard->addComponent("import_type", new WSelectList()); // $type->addOption("update", "update"); // need exceptions for nodes not existing $type->addOption("insert", "insert"); //$type->addOption("replace", "replace"); $fileField = $wizard->addComponent("filename", new WFileUploadField()); $save = $wizard->addComponent("_save", WSaveButton::withLabel("Import")); $cancel = $wizard->addComponent("_cancel", new WCancelButton()); //$fileField->setErrorText("<nobr>"._("A value for this field is required.")."</nobr>"); //$fileField->setErrorRule(new WECNonZeroRegex("[\\w]+")); return $wizard; }
/** * 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 9/28/05 */ function createWizard() { // Instantiate the wizard $wizard = SimpleWizard::withText("\n<h3>" . _("Click <em>Export</em> to Export Concerto") . "</h3>" . "\n<br/>" . _("The current content of concerto will be exported and presented as an archive for download. Once the archive is downloaded click <em>Cancel</em> to go back.") . "\n<br/><h3>" . _("Archive:") . "</h3>" . "<table border='0' style='margin-top:20px' >\n" . "\n<tr><td>" . _("Archive Name: ") . "</td>" . "<td>[[filepath]]</td></tr>" . "\n<tr><td>" . _("Compression: ") . "</td>" . "<td>[[compression]]</td></tr>" . "<tr>\n" . "<td align='left'>\n" . "[[_cancel]]" . "</td>\n" . "<td align='right'>\n" . "[[_save]]" . "</td></tr></table>"); // Create the properties. $fileNameProp = $wizard->addComponent("filepath", new WTextField()); // $datefield =$wizard->addComponent("effective_date", new WTextField()); // $date = DateAndTime::Now(); // $datefield->setValue($date->asString()); // // $date2field =$wizard->addComponent("expiration_date", new WTextField()); // // if (is_object($date2)) // $date2field->setValue($date->asString()); $type = $wizard->addComponent("compression", new WSelectList()); $type->setValue(".tar.gz"); $type->addOption(".tar.gz", _("gzip")); // $type->addOption(".zip", _("zip")); // $type->addOption(".bz2", _("bz2")); $save = $wizard->addComponent("_save", WSaveButton::withLabel("Export")); $cancel = $wizard->addComponent("_cancel", new WCancelButton()); return $wizard; }
/** * Create the wizard * * @return object Wizard * @access public * @since 6/4/08 */ public function createWizard() { $wizard = SimpleWizard::withText("\n<h2>" . dgettext("polyphony", "Visitor Registration") . "</h2>" . "\n<p>" . dgettext("polyphony", "Please fill out the form below. After you click the 'Register' button an email will be sent with a link to confirm your registration. You must confirm your registration before you will be able to log in.") . "</p>" . "\n<table class='visitor_registration'>" . "\n\t<tr>\n\t\t<th>" . dgettext("polyphony", "EMail Address:<br/>(This is your login handle)") . "</th>\n\t\t<td>[[email]]</td>\n\t</tr>" . "\n\t<tr>\n\t\t<th>" . dgettext("polyphony", "Full Name:") . "</th>\n\t\t<td>[[name]]</td>\n\t</tr>" . "\n\t<tr>\n\t\t<th>" . dgettext("polyphony", "Password:"******"<br/>" . dgettext("polyphony", "Password Again:") . "</th>\n\t\t<td>[[password]]</td>\n\t</tr>" . "\n</table>" . "\n[[captcha]]" . "\n<table width='100%' border='0' style='margin-top:20px' >\n" . "<tr>\n" . "</td>\n" . "<td align='left' width='50%'>\n" . "[[_cancel]]" . "<td align='right' width='50%'>\n" . "[[_save]]" . "</td></tr></table>"); $property = $wizard->addComponent("email", new WTextField()); $property->setStartingDisplayText(dgettext("polyphony", "*****@*****.**")); $property->setErrorText(dgettext("polyphony", "A valid email address is required.")); $property->setErrorRule(new WECNonZeroRegex("^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\\-+)|([A-Za-z0-9]+\\.+)|([A-Za-z0-9]+\\++))*[A-Za-z0-9]+@((\\w+\\-+)|(\\w+\\.))*\\w{1,63}\\.[a-zA-Z]{2,6}\$")); $property = $wizard->addComponent("name", new WTextField()); $property->setStartingDisplayText(dgettext("polyphony", "John Doe")); $property->setErrorText(dgettext("polyphony", "A value for this field is required - allowed characters: letters, spaces, ,.'-.")); $property->setErrorRule(new WECNonZeroRegex("^[\\w\\040,\\.'-]{3,}\$")); $property = $wizard->addComponent("password", new WPasswordPair()); $property->setErrorText(dgettext("polyphony", "Passwords must be between 8 and 100 characters.")); $property->setErrorRule(new WECNonZeroRegex("^.{8,100}\$")); if (!defined('RECAPTCHA_PUBLIC_KEY')) { throw new ConfigurationErrorException("RECAPTCHA_PUBLIC_KEY not defined."); } if (!defined('RECAPTCHA_PRIVATE_KEY')) { throw new ConfigurationErrorException("RECAPTCHA_PRIVATE_KEY not defined."); } $property = $wizard->addComponent("captcha", new WReCaptcha(RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY)); $wizard->addComponent("_save", WSaveButton::withLabel("Register")); $wizard->addComponent("_cancel", new WCancelButton()); return $wizard; }
/** * Create a new Wizard for this action. Caching of this Wizard is handled by * {@link getWizard()} and does not need to be implemented here. * @access public * @since 7/18/05 */ function createWizard() { $harmoni = Harmoni::Instance(); $wizard = SimpleWizard::withText("<table border='0' style='margin-top:20px' >\n" . "\n<tr><td><h3>" . _("Source data type:") . "</h3></td>" . "\n<td style='font-size: small;'>" . "* Please see the <strong>Help</strong> below for more information." . "</td></tr>" . "\n<tr><td>" . _("The format of data to be imported: ") . "</td>" . "\n<td>[[file_type]]</td></tr>" . "\n<tr><td>" . _("Is this file a Zip/GZip/BZip/Tar archive?<br/>If checked, the archive will be decompressed and all files in it will be imported.") . "</td>" . "\n<td>[[is_archived]]</td></tr>" . "\n<tr><td><h3>" . _("Import type:") . "</h3></td></tr>" . "\n<tr><td>" . _("The type of import to execute: ") . "</td>" . "\n<td>[[import_type]]</td></tr>" . "\n<tr><td><h3>" . _("File:") . "</h3></td></tr>" . "\n<tr><td>" . _("The Zip/GZip/BZip/Tar/XML achive file or a single file to be imported: ") . "</td>" . "\n<td>[[filename]]</td></tr>" . "\n<tr><td><h3>" . _("Parent Asset:") . "</h3></td></tr>" . "\n<tr><td>" . _("If specified, all Assets imported will be placed below this parent. ") . "</td>" . "\n<td>[[parent]]</td></tr>" . "<tr>\n" . "<td align='left'>\n" . "[[_cancel]]" . "</td>\n" . "<td align='right'>\n" . "[[_save]]" . "</td></tr></table>"); $select = $wizard->addComponent("file_type", new WSelectList()); $select->addOption("XML", "XML"); $select->addOption("Tab-Delimited", "Tab-Delimited"); $select->addOption("Exif", "Exif"); $select->addOption("FilesOnly", "Files Only (no metadata)"); $select->setValue("FilesOnly"); $archive = $wizard->addComponent("is_archived", WCheckBox::withLabel("is Archived")); $archive->setChecked(true); $type = $wizard->addComponent("import_type", new WSelectList()); // $type->addOption("update", "update"); // need exceptions for nodes not existing $type->addOption("insert", "insert"); //$type->addOption("replace", "replace"); $fileField = $wizard->addComponent("filename", new WFileUploadField()); $parent = $wizard->addComponent("parent", new WSelectList()); $parent->addOption("", "none"); $rootAssets = $this->getRootAssets(); while ($rootAssets->hasNext()) { $this->addAssetOption($parent, $rootAssets->next()); } if (RequestContext::value('parent')) { $parent->setValue(RequestContext::value('parent')); } $save = $wizard->addComponent("_save", WSaveButton::withLabel("Import")); $cancel = $wizard->addComponent("_cancel", new WCancelButton()); //$fileField->setErrorText("<nobr>"._("A value for this field is required.")."</nobr>"); //$fileField->setErrorRule(new WECNonZeroRegex("[\\w]+")); return $wizard; }
/** * Answer a wizard step for advanced theme editing. * * @return object WizardStep * @access protected * @since 5/15/08 */ protected function getAdvancedStep() { $component = $this->getSiteComponent(); $step = new WizardStep(); $step->setDisplayName(_("Advanced Editing")); $harmoni = Harmoni::instance(); ob_start(); print "\n<h2>" . _("Advanced Theme Editing") . "</h2>"; $theme = $component->getTheme(); if (!$theme->supportsModification()) { print "\n<p>" . _("You currently are using a read-only theme. You can make a copy of this theme for just this site that you can then modify.") . "</p>"; $about = _("Modifying a theme requires knowledge of %1Cascading Style Sheets (CSS)%2 and %3Hypertext Markup Language (HTML)%4"); $about = str_replace('%1', "<a href='http://www.w3schools.com/Css/css_intro.asp' target='_blank'>", $about); $about = str_replace('%2', "</a>", $about); $about = str_replace('%3', "<a href='http://www.w3schools.com/html/html_intro.asp' target='_blank'>", $about); $about = str_replace('%4', "</a>", $about); print "\n<p>" . $about . "</p>"; $property = $step->addComponent('create_copy', WSaveButton::withLabel(_("Create Local Theme Copy"))); print "[[create_copy]]"; $step->setContent(ob_get_clean()); return $step; } print "\n<div class='theme_edit_step'>"; $modSess = $theme->getModificationSession(); /********************************************************* * Information *********************************************************/ print "\n<h3>" . _("Theme Information") . "</h3>"; print "\n<table class='info_table'><tr><td>"; $property = $step->addComponent('display_name', new WSafeHtmlTextField()); $property->setSize(40); $property->setValue($theme->getDisplayName()); $property->setErrorRule(new WECRegex('[a-zA-Z0-9]+')); $property->setErrorText(_("You must specify a name.")); print "\n<h4>" . _("Display Name") . "</h4>\n[[display_name]]"; $property = $step->addComponent('description', new WSafeHtmlTextArea()); $property->setRows(10); $property->setColumns(40); $property->setValue($theme->getDescription()); print "\n<br/><h4>" . _("Description") . "</h4>\n[[description]]"; print "\n</td><td>"; $property = $step->addComponent('thumbnail', new WFileUploadField()); $property->setAcceptedMimetypes(array('image/png', 'image/jpeg', 'image/gif')); print "\n<h4>" . _("Thumbnail") . "</h4>\n[[thumbnail]]"; print "<div><br/>" . _("Current Thumbnail: ") . "<br/>"; try { $currentThumbnail = $theme->getThumbnail(); $property->setStartingDisplay($currentThumbnail->getBasename(), $currentThumbnail->getSize()); print "\n\t<img src='" . $harmoni->request->quickUrl('gui2', 'theme_thumbnail', array('theme' => $theme->getIdString(), 'rand' => rand(1, 10000))) . "' width='200px'/>"; } catch (UnknownIdException $e) { print "<em>" . _("none") . "</em>"; } print "</div>"; print "\n</td></tr></table>"; /********************************************************* * Global CSS *********************************************************/ print "\n<table class='info_table'><tr><td style='width: 350px;'>"; print "\n<h3>" . _("Theme Data") . "</h3>"; print "\n<p>" . _("In the text areas below, add the CSS and HTML for your theme.") . "</p>"; print "\n<p>" . _("The CSS snippets will be combined together in the order listed into a single file.") . "</p>"; print "\n<p>" . _("The HTML snippets will wrap the various components on the screen and must contain <code>[[CONTENT]]</code> placeholder for the content of the component. Any classes you want to refer to in the CSS will need to be added to the HTML snippets.") . "</p>"; $property = $step->addComponent('global_css', new WSafeCssTextArea()); $value = $modSess->getGlobalCss(); $property->setValue($value); $property->setColumns(40); $property->setWrap('off'); $property->setRows(min(40, max(20, substr_count($value, "\n") + 1))); print "\n<h4>" . _("Global CSS") . "</h4>\n[[global_css]]"; /********************************************************* * Images *********************************************************/ print "\n</td><td>"; print "\n<h3>" . _("Images") . "</h3>"; print "\n<p>" . _("You may upload images to your theme. These images must be JPG, PNG, or GIF images. To use them in your HTML or CSS, reference them with relative urls in an 'images' directory such as <code>images/background_image.jpg</code>.") . "</p>"; print "\n[[images]]"; $collection = $step->addComponent('images', new WRepeatableComponentCollection()); $collection->setContent('./images/[[path_prefix]]/[[image]] [[orig_path_prefix]]'); $property = $collection->addComponent('path_prefix', new WTextField()); $property->setSize('10'); $property->setErrorRule(new WECRegex('^([a-zA-Z0-9_-]+)?(\\/[a-zA-Z0-9_-]+)*$')); $property->setErrorText(_("Subdirectories can only contain letters, numbers, and underscore characters.")); $property = $collection->addComponent('orig_path_prefix', new WHiddenField()); $property = $collection->addComponent('image', new WFileUploadField()); $property->setAcceptedMimetypes(array('image/png', 'image/jpeg', 'image/gif')); foreach ($theme->getImages() as $image) { $collection->addValueCollection(array('path_prefix' => dirname($image->getPath()), 'orig_path_prefix' => dirname($image->getPath()), 'image' => array('name' => $image->getBasename(), 'size' => $image->getSize(), 'type' => $image->getMimeType(), 'starting_name' => $image->getBasename(), 'starting_size' => $image->getSize()))); } print "\n</td></tr></table>"; /********************************************************* * Other CSS and Templates *********************************************************/ print "\n<table class='theme_advanced_table'>"; foreach ($modSess->getComponentTypes() as $type) { // print "\n\t<tr>\n\t\t<th colspan='2'>".$type."</th>\n\t</tr>"; print "\n\t<tr>"; print "\n\t\t<th>" . $type . " CSS</th>"; print "\n\t\t<th>" . $type . " HTML</th>"; print "\n\t</tr>"; print "\n\t<tr>"; print "\n\t\t<td>[[" . $type . "-css]]</td>"; print "\n\t\t<td>[[" . $type . "-html]]</td>"; print "\n\t</tr>"; $cssProperty = $step->addComponent($type . '-css', new WSafeCssTextArea()); $value = $modSess->getCssForType($type); $cssLines = substr_count($value, "\n"); $cssProperty->setValue($value); $cssProperty->setColumns(40); $cssProperty->setWrap('off'); $htmlProperty = $step->addComponent($type . '-html', new WSafeHtmlTextArea()); $value = $modSess->getTemplateForType($type); $htmlLines = substr_count($value, "\n"); $htmlProperty->setValue($value); $htmlProperty->setColumns(60); $htmlProperty->setWrap('off'); $htmlProperty->setErrorRule(new WECRegex('(\\[\\[CONTENT\\]\\]|^$)')); $htmlProperty->setErrorText(_("Template HTML must contain a [[CONTENT]] placeholder or be blank.")); // Extend the text-areas to fit the content if needed. $numLines = max(10, $cssLines + 1, $htmlLines + 1); $numLines = min($numLines, 50); $cssProperty->setRows($numLines); $htmlProperty->setRows($numLines); } print "\n</table>"; /********************************************************* * Options *********************************************************/ $property = $step->addComponent('options', new WTextArea()); $property->setRows(40); $property->setColumns(100); $property->setWrap('off'); $property->setValue($modSess->getOptionsDocument()->saveXMLWithWhiteSpace()); $property->setErrorRule(new XmlSchemaRule(HARMONI . '/Gui2/theme_options.xsd')); print "\n<h3>" . _("Theme Options") . "</h3>"; $help = _("In the text area below you can add an XML document that describes any options for this theme. This document must conform to the %1. (View an example %2.)"); $schema = "<a href='" . $harmoni->request->quickURL('gui2', 'view_options_schema') . "' target='_blank'>" . _("options schema") . "</a>"; $example = "<a href='" . $harmoni->request->quickURL('gui2', 'view_options_example') . "' target='_blank'>" . _("options document") . "</a>"; print "\n<p>" . str_replace('%1', $schema, str_replace('%2', $example, $help)) . "</p>"; print "\n<p>" . _("Each option defines a set of choices for the user. These choices are composed of one or more settings. When a choice is used, all occurrances of the marker in the CSS and HTML above will be replaced with the value of that setting.") . "</p>"; print "\n[[options]]"; print "\n</div>"; $step->setContent(ob_get_clean()); return $step; }
/** * Create a new Wizard for this action. Caching of this Wizard is handled by * {@link getWizard()} and does not need to be implemented here. * @access public * @since 7/18/05 */ function createWizard() { //$repository =$this->getRepository(); $wizard = SimpleWizard::withText("\n<h3>" . _("File type") . "</h3>" . "\n" . _("The type of file to be imported: ") . "\n<br />[[file_type]]" . "\n<h3>" . _("Import type") . "\n" . _("The type of import to execute: ") . "\n<br />[[import_type]]" . "\n<h3>" . _("File") . "</h3>" . "\n" . _("The file to be imported: ") . "\n<br />[[filename]]" . "<table width='100%' border='0' style='margin-top:20px' >\n" . "<tr>\n" . "<td align='left' width='50%'>\n" . "[[_cancel]]" . "</td>\n" . "<td align='right' width='50%'>\n" . "[[_save]]" . "</td></tr></table>"); // :: Name and Description :: //$step =$wizard->addStep("fileupload", new WizardStep()); //$step->setDisplayName(_("Archive Type and File Upload")); $select = $wizard->addComponent("file_type", new WSelectList()); // $select->addOption("Tab-Delimited", "Tab-Delimited"); $select->addOption("XML", "XML"); // $select->addOption("Exif", "Exif"); // $select->setValue("Tab-Delimited"); $type = $wizard->addComponent("import_type", new WSelectList()); // $type->addOption("update", "update"); // need exceptions for nodes not existing $type->addOption("insert", "insert"); //$type->addOption("replace", "replace"); $fileField = $wizard->addComponent("filename", new WFileUploadField()); $save = $wizard->addComponent("_save", WSaveButton::withLabel("Import")); $cancel = $wizard->addComponent("_cancel", new WCancelButton()); //$fileField->setErrorText("<nobr>"._("A value for this field is required.")."</nobr>"); //$fileField->setErrorRule(new WECNonZeroRegex("[\\w]+")); return $wizard; }
/** * 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 9/28/05 */ function createWizard() { $harmoni = Harmoni::Instance(); $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $repository = $repositoryManager->getRepository($idManager->getId($harmoni->request->get("collection_id"))); // Instantiate the wizard, then add our steps. $wizard = SimpleWizard::withText("\n<h3>" . _("Click <em>Export</em> to Export the <em>") . $repository->getDisplayName() . _("</em> Collection out of <em>Concerto</em>") . "</h3>" . "\n<br/>" . _("The current content of <em>") . $repository->getDisplayName() . _("</em> will be exported and presented as an archive for download. Once the archive is downloaded click <em>Cancel</em> to go back.") . "\n<br/><h3>" . _("Archive:") . "</h3>" . "<table border='0' style='margin-top:20px' >\n" . "\n<tr><td>" . _("Archive Name: ") . "</td>" . "<td>[[filepath]]</td></tr>" . "\n<tr><td>" . _("Compression: ") . "</td>" . "<td>[[compression]]</td></tr>" . "<tr>\n" . "<td align='left'>\n" . "[[_cancel]]" . "</td>\n" . "<td align='right'>\n" . "[[_save]]" . "</td></tr></table>"); // Create the properties. $fileNameProp = $wizard->addComponent("filepath", new WTextField()); // $fileNameProp->setErrorText("<nobr>"._("The archive name must not have an extension")."</nobr>"); // $fileNameProp->setErrorRule(new WECRegex("\.")); $type = $wizard->addComponent("compression", new WSelectList()); $type->setValue(".tar.gz"); $type->addOption(".tar.gz", _("gzip")); // $type->addOption(".zip", _("zip")); // $type->addOption(".bz2", _("bz2")); $save = $wizard->addComponent("_save", WSaveButton::withLabel("Export")); $cancel = $wizard->addComponent("_cancel", new WCancelButton()); return $wizard; }
/** * Virtual constructor for a custom label * * @param string $label * @return object WSaveButton * @access public * @static * @since 7/27/05 */ static function withLabel($label) { $button = new WSaveButton(); $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() { $repository = $this->getRepository(); $repositoryId = $this->getRepositoryId(); $harmoni = Harmoni::instance(); $idManager = Services::getService("Id"); $authZManager = Services::getService("AuthZ"); $returnUrl = $harmoni->request->mkURLWithPassthrough(); $returnUrl->setValue("wizardSkipToStep", "schema"); // Instantiate the wizard, then add our steps. $wizard = SimpleStepWizard::withDefaultLayout(); // :: Step One :: $stepOne = $wizard->addStep("namedesc", new WizardStep()); $stepOne->setDisplayName(_("Name & Description")); // Create the step text ob_start(); $displayNameProp = $stepOne->addComponent("display_name", new WTextField()); $displayNameProp->setValue($repository->getDisplayName()); $displayNameProp->setErrorText(_("A value for this field is required.")); $displayNameProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); print "\n<h2>" . _("Name") . "</h2>"; print "\n" . _("The Name for this <em>Collection</em>: "); print "\n<br />[[display_name]]"; $fieldname = RequestContext::name('description'); $descriptionProp = $stepOne->addComponent("description", WTextArea::withRowsAndColumns(10, 80)); $descriptionProp->setValue($repository->getDescription()); print "\n<h2>" . _("Description") . "</h2>"; print "\n" . _("The Description for this <em>Collection</em>: "); print "\n<br />[[description]]"; print "\n<div style='width: 400px'> </div>"; $stepOne->setContent(ob_get_contents()); ob_end_clean(); // :: Schema Selection :: $selectStep = $wizard->addStep("schema", new WizardStep()); $selectStep->setDisplayName(_("Schema Selection")); // get an iterator of all RecordStructures $recordStructures = $repository->getRecordStructures(); $setManager = Services::getService("Sets"); $set = $setManager->getPersistentSet($repositoryId); ob_start(); print "<h2>" . _("Select Cataloging Schemas") . "</h2>"; print "\n<p>" . _("Select which cataloging schemas you wish to appear during <em>Asset</em> creation and editing. <em>Assets</em> can hold data in any of the schemas, but only the ones selected here will be available when adding new data.") . "</p>"; if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_rec_struct"), $repositoryId)) { $fieldname = RequestContext::name('create_schema'); $button = $selectStep->addComponent("_create_schema", WSaveButton::withLabel(_("Save Changes and Create a New Schema"))); print "\n<p>" . _("If none of the schemas listed below fit your needs, please click the button below to save your changes and create a new schema.") . "</p>"; print "\n[[_create_schema]]"; } print "\n<br /><table border='1'>"; print "\n\t<tr>"; print "\n\t<th>" . _("Display Name") . "</th>"; print "\n\t<th>" . _("Description") . "</th>"; print "\n\t<th>" . _("Order/Position") . "</th>"; print "\n\t</tr>"; // Get the number of info structures $numRecordStructures = 0; while ($recordStructures->hasNext()) { $recordStructure = $recordStructures->next(); $numRecordStructures++; } $assetContentStructureId = $idManager->getId("edu.middlebury.harmoni.repository.asset_content"); $recordStructures = $repository->getRecordStructures(); while ($recordStructures->hasNext()) { $recordStructure = $recordStructures->next(); $recordStructureId = $recordStructure->getId(); // Don't list the asset Content structure. if ($recordStructureId->isEqual($assetContentStructureId)) { continue; } // Create the properties. // 'in set' property $fieldname = "schema_" . str_replace(".", "__", $recordStructureId->getIdString()); $property = $selectStep->addComponent($fieldname, new WCheckBox()); if ($set->isInSet($recordStructureId)) { $property->setChecked(true); } else { $property->setChecked(false); } $property->setLabel($recordStructure->getDisplayName()); $property->setStyle("font-weight: 900;"); // Order property $orderFieldName = $fieldname . "_position"; $property = $selectStep->addComponent($orderFieldName, new WSelectList()); if ($set->isInSet($recordStructureId)) { $property->setValue(strval($set->getPosition($recordStructureId) + 1)); } else { $property->setValue(0); } print "\n<tr><td valign='top'>"; print "\n\t[[{$fieldname}]]"; // print "\n\t<strong>".a."</strong>"; $description = HtmlString::withValue($recordStructure->getDescription()); $description->trim(100); // trim to 100 words print "\n</td><td valign='top'>\n\t<div style='font-style: italic'>" . $description->asString() . "</div>"; $harmoni->history->markReturnURL("concerto/collection/edit/" . $repositoryId->getIdString(), $returnUrl); $links = array(); // Schema Details ob_start(); print " <a href='"; print $harmoni->request->quickURL("schema", "view", array("collection_id" => $repositoryId->getIdString(), "recordstructure_id" => $recordStructureId->getIdString(), "__skip_to_step" => 2)); print "'>" . _("Details") . "</a>"; $links[] = ob_get_clean(); // Schema Edit if (method_exists($recordStructure, 'createPartStructure') && (preg_match("/^Repository::.+\$/i", $recordStructureId->getIdString()) && ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_rec_struct"), $repositoryId) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_authority_list"), $repositoryId)) || ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_rec_struct"), $idManager->getId("edu.middlebury.authorization.root")) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_authority_list"), $repositoryId)))) { $harmoni->history->markReturnURL("concerto/schema/edit-return/" . $recordStructureId->getIdString(), $returnUrl); ob_start(); print "<a href='"; print $harmoni->request->quickURL("schema", "edit", array("collection_id" => $repositoryId->getIdString(), "recordstructure_id" => $recordStructureId->getIdString())); print "'>" . _("Edit") . "</a>"; $links[] = ob_get_clean(); } // Schema Copy $authZManager = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (method_exists($recordStructure, 'createPartStructure') && (preg_match("/^Repository::.+\$/i", $recordStructureId->getIdString()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.convert_rec_struct"), $repositoryId) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.convert_rec_struct"), $idManager->getId("edu.middlebury.authorization.root")))) { $button = $selectStep->addComponent("duplicate_schema__" . str_replace('.', '_', $recordStructureId->getIdString()), WSaveButton::withLabel(_("Duplicate Schema Only"))); $button->addConfirm(_("Are you sure that you wish to duplicate this Schema?")); $links[] = "[[duplicate_schema__" . str_replace('.', '_', $recordStructureId->getIdString()) . "]]"; if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $repositoryId)) { $button = $selectStep->addComponent("duplicate_copy_records__" . str_replace('.', '_', $recordStructureId->getIdString()), WSaveButton::withLabel(_("Duplicate Schema and Records"))); $button->addConfirm(_("Are you sure that you wish to duplicate this Schema\\nand all Records that use it?")); $links[] = "[[duplicate_copy_records__" . str_replace('.', '_', $recordStructureId->getIdString()) . "]]"; } $harmoni->history->markReturnURL("concerto/schema/duplicate-return/" . $recordStructureId->getIdString(), $returnUrl); } // Schema Delete $authZManager = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (method_exists($recordStructure, 'createPartStructure') && (preg_match("/^Repository::.+\$/i", $recordStructureId->getIdString()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete_rec_struct"), $repositoryId) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete_rec_struct"), $idManager->getId("edu.middlebury.authorization.root")))) { $button = $selectStep->addComponent("_delete_schema__" . str_replace('.', '_', $recordStructureId->getIdString()), WSaveButton::withLabel(_("Delete"))); $button->addConfirm(_("Are you sure that you wish to delete this Schema\\nand Records in all Assets in this Collection that use it?")); $button->addConfirm(_("This Schema can only be deleted if there are no Records\\nin any other Collection that use it.\\n\\nAre you sure that there are no Records that use this Schema?\\n\\nContinue to delete?")); $harmoni->history->markReturnURL("concerto/schema/delete-return/" . $recordStructureId->getIdString(), $returnUrl); $links[] = "[[_delete_schema__" . str_replace('.', '_', $recordStructureId->getIdString()) . "]]"; } print implode(" | ", $links); print "\n</td><td valign='top'>"; print "\n\t[[{$orderFieldName}]]"; for ($i = 0; $i <= $numRecordStructures; $i++) { // print "\n\t\t<option value='$i' [['$orderFieldname' == '$i'|selected='selected'|]]>".(($i)?$i:"")."</option>"; $property->addOption($i, $i ? $i : ""); } print "\n</td></tr>"; } print "\n</table>"; $selectStep->setContent(ob_get_clean()); return $wizard; }
/** * 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() { // Instantiate the wizard, then add our steps. ob_start(); print "<h2>" . _("Create Group") . "</h2>"; print "<b>" . _("Display name") . "</b>: [[display_name]]<br/>"; print "<b>" . _("Description") . " (" . _("optional") . ")" . "</b>: <br/>[[description]] <br/>"; print "<b>" . _("Type") . "</b>: [[type]] (" . _("or use fields below to create a new type") . ")<br/>"; print "<br/>"; print "<b>" . _("Type domain") . "</b>: [[type_domain]]<br/>"; print "<b>" . _("Type authority") . "</b>: [[type_authority]]<br/>"; print "<b>" . _("Type keyword") . "</b>: [[type_keyword]]<br/>"; print "<b>" . _("Type description") . "</b>:<br/> [[type_description]]<br/>"; print "<div align='right'>[[_cancel]]\n[[_save]]</div>"; print "[[members]]"; if (RequestContext::value("agents") && count($list = unserialize(RequestContext::value("agents"))) > 0 && is_array($list)) { // print out a list of agents print "<div>" . _("The group will be created with the following members:") . "<ul>\n"; $agentManager = Services::getService("Agent"); $idManager = Services::getService("Id"); foreach ($list as $idString) { $id = $idManager->getId($idString); if ($agentManager->isGroup($id)) { $agent = $agentManager->getGroup($id); $name = _("Group") . ": " . $agent->getDisplayName(); } else { if ($agentManager->isAgent($id)) { $agent = $agentManager->getAgent($id); $name = _("Agent") . ": " . $agent->getDisplayName(); } } print "<li>{$name}</li>\n"; } print "</ul></div>"; } $wizard = SimpleWizard::withText(ob_get_contents()); ob_end_clean(); // Create the properties. $displayNameProp = $wizard->addComponent("display_name", new WTextField()); $displayNameProp->setErrorText(_("A value for this field is required.")); $displayNameProp->setErrorRule(new WECNonZeroRegex("[\\w]+")); $descriptionProp = $wizard->addComponent("description", WTextArea::withRowsAndColumns(3, 50)); $property = $wizard->addComponent("type", new WSelectList()); $property->addOption("NONE", _("Use Fields Below...")); $agentMgr = Services::getService("Agent"); $types = $agentMgr->getGroupTypes(); while ($types->hasNext()) { $type = $types->next(); $typeKey = urlencode(HarmoniType::typeToString($type)); $property->addOption($typeKey, HarmoniType::typeToString($type)); } $property->setValue("NONE"); $property = $wizard->addComponent("type_domain", new WTextField()); $property->setStartingDisplayText(_("Domain, i.e. 'groups'")); $property = $wizard->addComponent("type_authority", new WTextField()); $property->setStartingDisplayText(_("Authority, i.e. 'edu.middlebury'")); $property = $wizard->addComponent("type_keyword", new WTextField()); $property->setStartingDisplayText(_("Keyword, i.e 'classes")); $property = $wizard->addComponent("type_description", WTextArea::withRowsAndColumns(3, 50)); $wizard->addComponent("_save", WSaveButton::withLabel(_("Create Group"))); $wizard->addComponent("_cancel", new WCancelButton()); $members = $wizard->addComponent("members", new WHiddenField()); if (RequestContext::value("agents")) { // the members of the group to be created. an array of agent ids $members->setValue(RequestContext::value("agents")); } return $wizard; }
function createWizard() { $list = $this->_getAgentList(); if (count($list) > 1) { $string = dgettext("polyphony", "You are editing properties for multiple agents. Existing values are not displayed unless they are the same for all agents. To change a value, be sure to select the checkbox next to the field to indicate you want the field updated."); } else { $string = dgettext("polyphony", "You are editing properties for one agent. Existing values are displayed in the fields."); } $wizardText = <<<END <div style='font-weight: bolder'>{$string}</div> <div> [[properties]] </div> <div align='right'> [[_cancel]] [[_save]] </div> END; $wizard = SimpleWizard::withText($wizardText); // get a lsit of agents that cannot be edited $idManager = Services::getService("Id"); $agentManager = Services::getService("Agent"); $values = array(); $valuesSame = array(); $valueCount = array(); foreach ($list as $idString) { $idObj = $idManager->getId($idString); $agent = $agentManager->getAgentOrGroup($idObj); $properties = $agent->getProperties(); // put this agent's properties into an array. $propArray = array(); while ($properties->hasNext()) { $propObj = $properties->next(); $typeObj = $propObj->getType(); $typeString = $typeObj->asString(); if (!isset($propArray[$typeString])) { $propArray[$typeString] = array(); } $keys = $propObj->getKeys(); while ($keys->hasNext()) { $key = $keys->next(); $propArray[$typeString][$key] = $propObj->getProperty($key); } } // now go through all the keys we've seen and check if they are the same. $types = array_unique(array_merge(array_keys($propArray), array_keys($values))); foreach ($types as $typeString) { if (!isset($values[$typeString])) { $values[$typeString] = array(); $valuesSame[$typeString] = array(); $valueCount[$typeString] = array(); } if (!isset($propArray[$typeString])) { $propArray[$typeString] = array(); } $keys = array_unique(array_merge(array_keys($propArray[$typeString]), array_keys($values[$typeString]))); foreach ($keys as $key) { if (!isset($valueCount[$typeString][$key])) { $valueCount[$typeString][$key] = 0; } if (!isset($values[$typeString][$key])) { $valuesSame[$typeString][$key] = true; $values[$typeString][$key] = $propArray[$typeString][$key]; $valueCount[$typeString][$key]++; continue; } if ($valuesSame[$typeString][$key] === false) { continue; } $theValue = isset($propArray[$typeString][$key]) ? $propArray[$typeString][$key] : null; if ($theValue) { $valueCount[$typeString][$key]++; } if ($values[$typeString][$key] != $theValue) { $valuesSame[$typeString][$key] = false; } } } } $wizard->addComponent("_save", WSaveButton::withLabel(dgettext("polyphony", "Update"))); $wizard->addComponent("_cancel", new WCancelButton()); $collection = $wizard->addComponent("properties", new WAddFromListRepeatableComponentCollection()); $collection->setStartingNumber(0); $propertyManager = Services::getService("Property"); $collection->addOptionCollection(dgettext("polyphony", "New Key..."), $value = null); unset($array); $allProperties = $propertyManager->getAllPropertyKeys(); foreach ($allProperties as $key) { $collection->addOptionCollection($key, $array = array('key' => $key, 'update' => false, 'value' => '')); unset($array); } $keyComponent = $collection->addComponent("key", new WTextField()); $keyComponent->setSize(15); $collection->addComponent("type", new WHiddenField()); $typeText = $collection->addComponent("type_text", new WText()); $typeText->setStyle("color: #666;"); $valueComponent = $collection->addComponent("value", new WTextField()); $valueComponent->setSize(40); if (count($list) > 1) { // $valueComponent->addOnChange("alert(this.id+'_update_dummy');"); $valueComponent->addOnChange("if (this.value != '' && this.value != '" . dgettext("polyphony", "(multiple values exist)") . "')" . "{" . "getWizardElement(this.id+'_update').value = '1';" . "getWizardElement(this.id+'_update_dummy').checked = true;" . "}"); $collection->addComponent("value_update", new WCheckBox()); } // now add the default values for all of these foreach (array_keys($values) as $typeString) { $typeArray = $values[$typeString]; $typeSameArray = $valuesSame[$typeString]; $typeObj = HarmoniType::fromString($typeString); // now the keys foreach (array_keys($typeArray) as $key) { $valuesArray = array('key' => $key, 'type' => $typeString, 'type_text' => "(" . $typeObj->getKeyword() . ")", 'update' => false, 'value' => ''); $newSet = $collection->addValueCollection($valuesArray); $newSet["key"]->setEnabled(false, true); $newSet["key"]->setStyle("border: 0px;"); // <-- not sure if this actually works as desired. // if the values are the same and there are as many values as there are agents (otherwise, some didn't have a value), // add the value in to the display. if ($typeSameArray[$key] && $valueCount[$typeString][$key] == count($list)) { $newSet['value']->setValue($typeArray[$key]); } else { $newSet['value']->setStartingDisplayText(dgettext("polyphony", "(multiple values exist)")); } } } if (count($values) == 0) { $collection->setStartingNumber(1); } if (count($list) > 1) { $collection->setElementLayout("\n<table width='100%'><tr>\n\t<td>[[value_update]]</td>\n\t<td>[[key]]</td>\n\t<td>[[type_text]]</td>\n\t<td><span style='font-weight: bolder; font-size: larger;'>=</span></td>\n\t<td align='right'>[[value]]</td>\n\t<td>[[type]]</td>\n</tr></table"); } else { $collection->setElementLayout("\n<table width='100%'><tr>\n\t<td>[[key]]</td>\n\t<td>[[type_text]]</td>\n\t<td><span style='font-weight: bolder; font-size: larger;'>=</span></td>\n\t<td align='right'>[[value]]</td>\n\t<td>[[type]]</td>\n</tr></table>"); } return $wizard; }
/** * creates the wizard * * @return object Wizard * @access public * @since 10/24/05 */ function createWizard() { $harmoni = Harmoni::Instance(); $wizard = SimpleWizard::withText("\n<h2>" . dgettext("polyphony", "Old Password") . "</h2>" . "\n<br />[[old_password]]" . "\n<h2>" . dgettext("polyphony", "New Password") . "</h2>" . "\n" . dgettext("polyphony", "Please enter your new password twice") . "\n<br />[[new_password]]" . "\n<br />[[n_p_again]]" . "<table width='100%' border='0' style='margin-top:20px' >\n" . "<tr>\n" . "</td>\n" . "<td align='left' width='50%'>\n" . "[[_cancel]]" . "<td align='right' width='50%'>\n" . "[[_save]]" . "</td></tr></table>"); $error = $harmoni->request->get("error"); if (!is_null($error)) { print $error; } $pass = $wizard->addComponent("old_password", new WPasswordField()); $pass = $wizard->addComponent("new_password", new WPasswordField()); $pass = $wizard->addComponent("n_p_again", new WPasswordField()); $save = $wizard->addComponent("_save", WSaveButton::withLabel("Change Password")); $cancel = $wizard->addComponent("_cancel", new WCancelButton()); return $wizard; }