private function renderFormFieldContent($renderApi, $unit) { $this->formSubmit = new \FormSubmit(); $fieldId = 'field' . $unit->getId(); $properties = $unit->getFormValues(); $labelText = $properties["fieldLabel"]; $listType = $properties["listType"]; //select, checkbox, radio $postRequest = $this->getPostValue($unit); $choiceBox = new \ChoiceBox(); if ($listType === \ListType::RADIO || $listType === \ListType::CHECKBOX) { $required = $renderApi->getFormValue($unit, 'enableRequired'); $formField = $choiceBox->getRadioCheckbox($renderApi, $unit, $fieldId, $postRequest, $required); } elseif ($listType === \ListType::DROP_DOWN) { $formField = $choiceBox->getSelectField($renderApi, $unit, $fieldId, $postRequest); } $label = new \Label(); $labelProperties = $label->getElementProperties(); $labelProperties->addAttribute("for", $fieldId); $label->add(new \Span($labelText)); if ($formField) { $elementProperties = $formField->getElementProperties(); $wrapper = new \Container(); $wrapper->add($label); $wrapper->add($formField); echo $wrapper->renderElement(); } $renderApi->renderChildren($unit); }
protected function setUp() { $this->application = new Application(); $this->application->add(new OrganizeFileCommand()); $this->command = $this->application->find('organizer:files'); $this->commandTester = new CommandTester($this->command); }
private function renderFormFieldContent($renderApi, $unit) { $this->formSubmit = new \FormSubmit(); $fieldId = 'field' . $unit->getId(); $properties = $unit->getFormValues(); $labelText = $properties["fieldLabel"]; $fieldType = $properties["textType"]; //input,list,textarea $postRequest = $this->getPostValue($unit); if ($properties['type'] === \InputType::STRING && $fieldType !== FieldType::TEXTAREA || $properties['type'] === \InputType::EMAIL || $properties['type'] === \InputType::NUMERIC) { $formField = new \TextField(); $elementProperties = $formField->getElementProperties(); $elementProperties->setId($fieldId); $elementProperties->addAttribute("name", $fieldId); $elementProperties->addAttribute('value', $postRequest); if (isset($properties['type'])) { if ($properties['type'] === \InputType::EMAIL) { $elementProperties->addAttribute("type", \InputType::EMAIL); } if ($properties['type'] === \InputType::NUMERIC) { $elementProperties->addAttribute("type", \InputType::NUMERIC); } } } elseif ($fieldType === FieldType::TEXTAREA) { $formField = new \TextareaField(); $elementProperties = $formField->getElementProperties(); $elementProperties->setId($fieldId); $elementProperties->addAttribute("name", $fieldId); $formField->setContent($postRequest); } $label = new \Label(); $labelProperties = $label->getElementProperties(); $labelProperties->addAttribute("for", $fieldId); $label->add(new \Span($labelText)); if ($formField) { $wrapper = new \Container(); $wrapper->add($label); $wrapper->add($formField); $elementProperties = $formField->getElementProperties(); if ($this->formSubmit->isValid($renderApi, $unit) && !$this->isValidValue($unit, $postRequest)) { $elementProperties->addClass('vf__error'); $wrapper->add($this->getErrorMessage($unit, $postRequest)); } $this->setRequiredField($renderApi, $unit, $elementProperties); $this->setPlaceholderText($renderApi, $unit, $elementProperties); echo $wrapper->renderElement(); } $renderApi->renderChildren($unit); }
/** * Add an element to the table. * * @param $element The element to be added * @param $row The row to add the element to. Count starts from 0. * @param $column The column to add the element to. Count starts from 0. */ public function add($element, $row = -1, $column = -1) { if ($element->parent != null) { throw new Exception("Element being added to table already has a parent"); } if ($row == -1 || $column == -1) { parent::add($element); } else { $this->tableElements[$row][$column][] = $element; parent::add($element); } return $this; }
private function renderFormFieldContent($renderApi, $unit) { $buttonId = 'field' . $unit->getId(); $properties = $unit->getFormValues(); $buttonLabel = $properties["fieldLabel"]; $formField = new \ButtonField(); $elementProperties = $formField->getElementProperties(); $elementProperties->setId($buttonId); $elementProperties->addClass("submitButton"); $elementProperties->addAttribute("name", $buttonId); $elementProperties->addAttribute("value", $buttonLabel); $wrapper = new \Container(); $wrapper->add($formField); echo $wrapper->renderElement(); $renderApi->renderChildren($unit); }
/** * Add an element to the table. * * @param $element The element to be added * @param $row The row to add the element to. Count starts from 0. * @param $column The column to add the element to. Count starts from 0. */ public function add() { $args = func_get_args(); $element = $args[0]; $row = isset($args[1]) ? $args[1] : null; $column = isset($args[2]) ? $args[2] : null; if ($element->parent != null) { throw new Exception("Element being added to table already has a parent"); } if ($row === null || $column === null) { parent::add($element); } else { $this->tableElements[$row][$column][] = $element; parent::add($element); } return $this; }
/** * @param RenderAPI $renderApi * @param Unit $unit * @param ModuleInfo $moduleInfo */ public function renderContent($renderApi, $unit, $moduleInfo) { $formSend = false; $this->http = new \Request(); $form = new \Form(); $honeyPotComponent = new \HoneyPotComponent(); $this->formSubmit = new \FormSubmit(); $postRequest = $this->formSubmit->getPostValues(); $elementProperties = $form->getElementProperties(); $elementProperties->setId("form" . str_replace("-", "", $unit->getId())); $elementProperties->addAttribute('action', $_SERVER['REQUEST_URI'] . '#' . $unit->getId()); $elementProperties->addAttribute('method', 'post'); $elementProperties->addAttribute('enctype', 'multipart/form-data'); $form->add($honeyPotComponent->getHoneyPot()); $form->add($honeyPotComponent->getFormUnitIdentifier($unit->getId())); if ($this->formSubmit->isValid($renderApi, $unit) && count($postRequest) > 0 && $honeyPotComponent->isValidHoneyPot($postRequest) && $this->hasValidFormData($renderApi, $unit)) { $this->formSubmit->setFieldLabelsToFormValueSet($renderApi); try { $this->sentEmail($renderApi, $unit, $postRequest); $formSend = true; } catch (\Exception $e) { $errorText = new \Span(); $errorText->setContent("Unable to send email:<br />" . $e->getMessage()); $errorContainer = new \Container(); $errorContainer->add($errorText); $errorContainer->getElementProperties()->addClass('vf__main_error'); $form->add($errorContainer); } } if ($formSend) { $confirmationText = new \Span(); $confirmationText->setContent(preg_replace('/\\n/', '<br>', $renderApi->getFormValue($unit, 'confirmationText'))); $confirmationContainer = new \Container(); $confirmationContainer->add($confirmationText); $confirmationContainer->getElementProperties()->addClass('confirmationText'); $form->add($confirmationContainer); echo $form->renderElement(); } else { echo $form->renderElementProgressive($renderApi, $unit); } }
/** * Adds the given menu item to this container. The only difference from the * familiar <code>add()</code> method of the Container class is that now * explicit checking is performed to make sure that the given component * is indeed a <code>menuItem</code> and not just any component. * <br /><br /> * Warning: The <code>add()</code> method allows the user to add the same * instance of an object multiple times. With menus, this is extremely unadvised because * the menu might end up with multiple selected menu items at the same time. * @access public * @param ref object menuItem The menuItem to add. If it is selected, then the * old selected menu item will be automatically deselected. * @param string width The available width for the added menuItem. If null, will be ignored. * @param string height The available height for the added menuItem. If null, will be ignored. * @param integer alignmentX The horizontal alignment for the added menuItem. Allowed values are * <code>LEFT</code>, <code>CENTER</code>, and <code>RIGHT</code>. * If null, will be ignored. * @param integer alignmentY The vertical alignment for the added menuItem. Allowed values are * <code>TOP</code>, <code>CENTER</code>, and <code>BOTTOM</code>. * If null, will be ignored. * @return ref object The menuItem that was just added. **/ function add($menuItem, $width = null, $height = null, $alignmentX = null, $alignmentY = null) { // ** parameter validation // some weird class checking here - would have been much simpler if PHP // supported multiple inheritance $rule1 = ExtendsValidatorRule::getRule("MenuItemLink"); $rule2 = ExtendsValidatorRule::getRule("MenuItemHeading"); $rule3 = ExtendsValidatorRule::getRule("MenuItem"); $rule4 = ExtendsValidatorRule::getRule("SubMenu"); ArgumentValidator::validate($menuItem, OrValidatorRule::getRule(OrValidatorRule::getRule(OrValidatorRule::getRule($rule1, $rule2), $rule3), $rule4), true); // ** end of parameter validation parent::add($menuItem, $width, $height, $alignmentX, $alignmentY); // if the given menuItem is selected, then select it if ($menuItem instanceof MenuItemLink) { if ($menuItem->isSelected()) { $id = $this->getComponentsCount(); $this->select($id); } } return $menuItem; }
function printSlideShort($asset, $params, $slideshowIdString, $num) { $harmoni = Harmoni::instance(); $container = new Container(new YLayout(), BLOCK, EMPHASIZED_BLOCK); $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container."); $fillContainerSC->addSP(new MinHeightSP("88%")); $container->addStyle($fillContainerSC); $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text"); $centered->addSP(new TextAlignSP("center")); $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $authZ = Services::getService("AuthZ"); // Get our record and its data $slideRecords = $asset->getRecordsByRecordStructure($idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure")); if ($slideRecords->hasNext()) { $slideRecord = $slideRecords->next(); // Text-Position $textPosition = getFirstPartValueFromRecord("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.text_position", $slideRecord); // Display Metadata $displayMetadata = getFirstPartValueFromRecord("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.display_metadata", $slideRecord); // Media $mediaIdStringObj = getFirstPartValueFromRecord("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id", $slideRecord); if (strlen($mediaIdStringObj->asString())) { $mediaId = $idManager->getId($mediaIdStringObj->asString()); } else { $mediaId = null; } } // ------------------------------------------ ob_start(); print "\n\t<a style='cursor: pointer;'"; print " onclick='Javascript:window.open("; print '"' . VIEWER_URL . "?&source="; print urlencode($harmoni->request->quickURL('exhibitions', "slideshowOutlineXml", array('slideshow_id' => $slideshowIdString))); print '&start=' . ($num - 1) . '", '; print '"_blank", '; print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"'; print ")'>"; $viewerATag = ob_get_clean(); /********************************************************* * Media *********************************************************/ if (isset($mediaId) && $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $mediaId) && $_SESSION["show_thumbnail"] == 'true') { $mediaAsset = $repositoryManager->getAsset($mediaId); $mediaAssetId = $mediaAsset->getId(); $mediaAssetRepository = $mediaAsset->getRepository(); $mediaAssetRepositoryId = $mediaAssetRepository->getId(); $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($mediaAsset); if ($thumbnailURL !== FALSE) { $thumbSize = $_SESSION["thumbnail_size"] . "px"; ob_start(); print "\n<div style='height: {$thumbSize}; width: {$thumbSize}; margin: auto;'>"; print $viewerATag; print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' style='max-height: {$thumbSize}; max-width: {$thumbSize};' class='thumbnail_image' />"; print "\n\t</a>"; print "\n</div>"; $component = new UnstyledBlock(ob_get_clean()); $component->addStyle($centered); $container->add($component, "100%", null, CENTER, CENTER); } // other files $fileRecords = $mediaAsset->getRecordsByRecordStructure($idManager->getId("FILE")); } // Link to viewer $numFiles = 0; if (isset($fileRecords)) { while ($fileRecords->hasNext()) { $record = $fileRecords->next(); $numFiles++; } } ob_start(); print "\n<div height='15px; font-size: small;'>"; print $viewerATag; print _("Open in Viewer"); if ($numFiles > 1) { print " (" . ($numFiles - 1) . " " . _("more files") . ")"; } print "\n\t</a>"; print "\n</div>"; $component = new UnstyledBlock(ob_get_clean()); $component->addStyle($centered); $container->add($component, "100%", null, CENTER, CENTER); // Title ob_start(); if ($_SESSION["show_displayName"] == 'true') { print "\n\t<div style='font-weight: bold; height: 50px; overflow: auto;'>" . htmlspecialchars($asset->getDisplayName()) . "</div>"; } // Caption if ($_SESSION["show_description"] == 'true') { $description = HtmlString::withValue($asset->getDescription()); $description->clean(); if (isset($thumbnailURL)) { print "\n\t<div style='font-size: smaller; height: 100px; overflow: auto;'>"; } else { print "\n\t<div style='font-size: smaller; height: " . ($_SESSION["thumbnail_size"] + 100) . "px; overflow: auto;'>"; } print $description->asString(); if (isset($displayMetadata) && $displayMetadata->isTrue() && isset($mediaId) && $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $mediaId)) { print "\t\t\t<hr/>\n"; $mediaAsset = $repositoryManager->getAsset($mediaId); printTargetAsset($mediaAsset); } // Unauthorized to view Media Message if (isset($mediaId) && !$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $mediaId)) { print "\t\t\t<div style='font-size: large; font-weight: bold; border: 2px dotted; padding: 5px;'>"; $harmoni = Harmoni::instance(); print "\n\t\t\t\t<p>"; print _("You are not authorized to view the media for this slide."); print "</p>\n\t\t\t\t<p>"; print _("If you have not done so, please go to "); print "<a href='" . $harmoni->request->quickURL("home", "welcome"); print "'>Concerto</a>"; print _(" and log in."); print "\t\t\t\t</p>\n\t\t\t</div>\n"; } print "</div>"; } $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, TOP); // Controls ob_start(); // Authorization Icons print _("Slide: ") . AuthZPrinter::getAZIcon($asset->getId()); if (isset($mediaId) && $mediaId) { print "<br/>" . _("Media: ") . AuthZPrinter::getAZIcon($mediaId); } $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, BOTTOM); return $container; }
$mainContentStyle->addSP(new TextAlignSP("justify")); // ============================================================================= // Create some containers & components. This stuff would normally go in an action. // ============================================================================= $xLayout = new XLayout(); $yLayout = new YLayout(); $mainBox = new Container($yLayout, BLANK, 1, $mainBoxStyle); $h1 = new Component("Home", MENU_ITEM_LINK_SELECTED, 1, $menuItemsStyle); $h2 = new Component("Pictures", MENU_ITEM_LINK_SELECTED, 1, $menuItemsStyle); $h3 = new Component("Guestbook", MENU_ITEM_LINK_SELECTED, 1, $menuItemsStyle); $h4 = new Component("Links", MENU_ITEM_LINK_SELECTED, 1, $menuItemsStyle); $menuBox = new Container($xLayout, BLANK, 1, $menuBoxStyle); $menuBox->add($h1, null, null, CENTER, CENTER); $menuBox->add($h2, null, null, CENTER, CENTER); $menuBox->add($h3, null, null, CENTER, CENTER); $menuBox->add($h4, null, null, CENTER, CENTER); $temp = new Container($yLayout, BLANK, 3); $temp->add($menuBox, null, null, RIGHT); $menuBox1 = $menuBox; $menuBox1->setLayout($yLayout); $mainContent = new Container($xLayout, BLANK, 1); $mainText = new Component("<p>Angelo de la Cruz, 46, was released Tuesday -- one day after the Philippine government completed the withdrawal of its 51-member humanitarian contingent from Iraq in compliance with kidnappers' demands.</p><p>De la Cruz was turned over to officials at the United Arab Emirates Embassy in Baghdad before he was transferred to the Philippine Embassy. He will be flown to Abu Dhabi for a medical evaluation, a UAE government statement said. </p><p>"I am very, very happy. His health is okay ... His family is waiting for him," a tearful Arsenia de la Cruz told reporters at her country's embassy in Amman, minutes after talking by telephone to her husband in Baghdad. </p><p>Mrs. de la Cruz had been staying in the Jordanian capital, awaiting word on her husband.</p><p>"I would not let him go back to the Middle East another time," The Associated Press quoted her as saying.</p><p>Earlier Tuesday, the Philippine President Gloria Macapagal Arroyo said on national television she had also spoken to the former hostage. </p><p>"I'm happy to announce that our long national vigil involving Angelo [de] la Cruz is over. I thank the Lord Almighty for his blessings," Arroyo said.</p><p>"His health is good, his spirits high and he sends best wishes to every Filipino for their thoughts and prayers." </p><p>Initial reports on de la Cruz's condition appeared promising. "He's here. He's with us. He's fine," a UAE Embassy official said before the transfer.</p><p>Kidnappers had threatened to behead the father of eight children, who was taken hostage on July 7, if the Philippines did not withdraw its forces from Iraq. </p><p>The Arabic-language news network Al-Jazeera read a statement from the kidnappers last week, saying they would free de la Cruz when "the last Filipino leaves Iraq on a date that doesn't go beyond the end of this month."</p>", BLANK, 1); $mainText->addStyle($mainContentStyle); $mainContent->add($menuBox1, null, null, null, TOP); $mainContent->add($mainText, "100%", null, null, TOP); $mainBox->add($temp, "100%", null, RIGHT, CENTER); $mainBox->add($mainContent, "100%", null, null, null); $theme = new Theme("Sample Page Theme", "This is the theme from examples/sample_page.php"); $theme->addGlobalStyle($bodyStyle); $theme->setComponent($mainBox); $theme->printPage();
function printRepositoryShort($repository) { $harmoni = Harmoni::instance(); ob_start(); $repositoryId = $repository->getId(); print "\n\t<div style='font-weight: bold' title='" . _("ID#") . ": " . $repositoryId->getIdString() . "'>" . $repository->getDisplayName() . "</div>"; $description = HtmlString::withValue($repository->getDescription()); $description->trim(500); print "\n\t<div style='font-size: smaller;'>" . $description->asString() . "</div>"; RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository); $xLayout = new XLayout(); $layout = new Container($xLayout, BLANK, 1); $layout2 = new Block(ob_get_contents(), EMPHASIZED_BLOCK); $layout->add($layout2, null, null, CENTER, CENTER); ob_end_clean(); return $layout; }
/** * Returns a layout of the Results * * @param optional mixed $shouldPrintFunction A callback function that will * return a boolean specifying whether or not to filter a given result. * If null, all results are printed. * @return object Layout A layout containing the results/page links * @access public * @date 8/5/04 */ function getLayout($shouldPrintFunction = NULL) { $defaultTextDomain = textdomain("polyphony"); $startingNumber = $this->getStartingNumber(); $yLayout = new YLayout(); $container = new Container($yLayout, OTHER, 1); $endingNumber = $startingNumber + $this->_pageSize - 1; $numItems = 0; $resultContainer = new Container($this->_resultLayout, OTHER, 1); if (count($this->_array)) { reset($this->_array); // trash the items before our starting number while ($numItems + 1 < $startingNumber && $numItems < count($this->_array) && current($this->_array) !== false) { $item = current($this->_array); next($this->_array); // Ignore this if it should be filtered. if (is_null($shouldPrintFunction)) { $shouldPrint = true; } else { $shouldPrint = call_user_func_array($shouldPrintFunction, array($item)); } if ($shouldPrint) { $numItems++; } } // print up to $this->_pageSize items $pageItems = 0; while ($numItems < $endingNumber && $numItems < count($this->_array) && current($this->_array) !== false) { $item = current($this->_array); next($this->_array); // Only Act if this item isn't to be filtered. if (is_null($shouldPrintFunction)) { $shouldPrint = true; } else { $shouldPrint = call_user_func_array($shouldPrintFunction, array($item)); } if ($shouldPrint) { $numItems++; $pageItems++; $itemArray = array($item); $params = array_merge($itemArray, $this->_callbackParams); // Add in our starting number to the end so that that it is accessible. $params[] = $numItems; // If the callback function is null, assume that we have an // array of GUI components that can be used directly if (is_null($this->_callbackFunction)) { $itemComponent = $item; } else { // The following call returns an object, but notices are given // if an '&' is used. $itemComponent = call_user_func_array($this->_callbackFunction, $params); } $resultContainer->add($itemComponent, null, null, CENTER, TOP); // If $itemComponent is not unset, since it is an object, // it may references to it made in add() will be changed. unset($itemComponent); } } //if we have a partially empty last row, add more empty layouts // to better-align the columns // while ($pageItems % $this->_numColumns != 0) { // $currentRow->addComponent(new Content(" ")); // $pageItems++; // } // find the count of items while (true) { $item = current($this->_array); if (!$item) { break; } next($this->_array); // Ignore this if it should be filtered. if (!is_object($item)) { var_dump($item); } if (is_null($shouldPrintFunction)) { $shouldPrint = true; } else { $shouldPrint = call_user_func_array($shouldPrintFunction, array($item)); } if ($shouldPrint) { $numItems++; } } } else { $text = new Block("<ul><li>" . _("No items are available.") . "</li></ul>", STANDARD_BLOCK); $resultContainer->add($text, null, null, CENTER, CENTER); } /********************************************************* * Page Links * ------------ * print out links to skip to more items if the number of Items is greater * than the number we display on the page *********************************************************/ if ($linksHTML = $this->getPageLinks($startingNumber, $numItems)) { // Add the links to the page $pageLinkBlock = new UnstyledBlock($linksHTML, BLANK); $container->add($pageLinkBlock, "100%", null, CENTER, CENTER); $pageLinkBlock->addStyle($this->_linksStyleCollection); } $container->add($resultContainer, "100%", null, LEFT, CENTER); if ($numItems > $this->_pageSize) { $container->add($pageLinkBlock, null, null, CENTER, CENTER); } $this->numItemsPrinted = $numItems; textdomain($defaultTextDomain); return $container; }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $themeIndex = $harmoni->request->get("theme"); if ($themeIndex) { if (isset($_SESSION[$themeIndex])) { $theme = $_SESSION[$themeIndex]; $guiManager = Services::getService("GUI"); $guiManager->setTheme($theme); } else { print "Could not find any thing at " . $themeIndex; } } else { print "The theme index was not passed in."; } // initialize layouts and theme $xLayout = new XLayout(); $yLayout = new YLayout(); $flowLayout = new FlowLayout(); // now create all the containers and components $block1 = new Container($yLayout, BLOCK, 1); $row0 = new Footer("This the Header, which is likely consistent across pages.", 1); $block1->add($row0, "100%", null, CENTER, CENTER); $row1 = new Container($xLayout, OTHER, 1); $header1 = new Heading("A Harmoni GUI example.<br />Level-1 heading.\n", 1); $row1->add($header1, null, null, CENTER, CENTER); $menu1 = new Menu($xLayout, 1); $menu1_item1 = new MenuItemHeading("Main Menu:\n", 1); $menu1_item2 = new MenuItemLink("Home", "http://www.google.com", true, 1); $menu1_item3 = new MenuItemLink("Theme Settings", "http://www.middlebury.edu", false, 1); $menu1_item4 = new MenuItemLink("Manage Themes", "http://www.cnn.com", false, 1); $menu1->add($menu1_item1, "25%", null, CENTER, CENTER); $menu1->add($menu1_item2, "25%", null, CENTER, CENTER); $menu1->add($menu1_item3, "25%", null, CENTER, CENTER); $menu1->add($menu1_item4, "25%", null, CENTER, CENTER); $row1->add($menu1, "500px", null, RIGHT, BOTTOM); $block1->add($row1, "100%", null, RIGHT, CENTER); $row2 = new Block("\n\t\t\tThis is some text in a Level-2 text block.\n\t\t\t<p>This is where you would put your <strong>content.</strong> web site. A link might look like <a href=\"http://et.middlebury.edu/\">this</a>. It is probably important to make this look good. </p>\n", 2); $block1->add($row2, "100%", null, CENTER, CENTER); $row3 = new Container($xLayout, OTHER, 1); $menu2 = new Menu($yLayout, 1); $menu2_item1 = new MenuItemHeading("Sub-menu:\n", 1); $menu2_item2 = new MenuItemLink("The Architecture", "http://www.google.com", true, 1); $menu2_item3 = new MenuItemLink("The Framework", "http://www.middlebury.edu", false, 1); $menu2_item4 = new MenuItemLink("Google: Searching", "http://www.cnn.com", false, 1); $menu2_item5 = new MenuItemLink("Slashdot", "http://www.slashdot.org", false, 1); $menu2_item6 = new MenuItemLink("Background Ex", "http://www.depechemode.com", false, 1); $menu2->add($menu2_item1, "100%", null, LEFT, CENTER); $menu2->add($menu2_item2, "100%", null, LEFT, CENTER); $menu2->add($menu2_item3, "100%", null, LEFT, CENTER); $menu2->add($menu2_item4, "100%", null, LEFT, CENTER); $menu2->add($menu2_item5, "100%", null, LEFT, CENTER); $menu2->add($menu2_item6, "100%", null, LEFT, CENTER); $row3->add($menu2, "150px", null, LEFT, TOP); $stories = new Container($yLayout, OTHER, 1); $heading2_1 = new Heading("The Architecture. Level-2 heading.", 2); $stories->add($heading2_1, "100%", null, CENTER, CENTER); $story1 = new Block("\n\t<p>\n\t\tHarmoni's architecture is built on a popular <strong>module/action</strong> model, in which your PHP program\n\t\tcontains multiple <em>modules</em>, each of which contain multiple executable <em>actions</em>. All you,\n\t\tas an application developer, need to write are the action files (or classes, or methods, however you\n\t\tchoose to do it). The following diagram gives a (simplified) example of the execution path/flow of\n\t\ta typical PHP program written under Harmoni:\n\t</p>", 2); $stories->add($story1, "100%", null, CENTER, CENTER); $heading2_2 = new Heading("The Framework. Level-2 heading.", 2); $stories->add($heading2_2, "100%", null, CENTER, CENTER); $story2 = new Block("\n\t\t\t\t\t<p>\n\t\t\t\t\t\tAlongside the architecture, Harmoni offers a number of <strong>Services</strong>. The services are built with two\n\t\t\t\t\t\tgoals: 1) to save you the time of writing the same code over and over again, and 2) to offer a uniform\n\t\t\t\t\t\tenvironment and abstraction layer between a specific function and the back-end implementation of that function.\n\t\t\t\t\t\tIn simpler words, the File StorageHandler, for example, is used by your program by calling methods like\n\t\t\t\t\t\t<em>" . '$storageHandler->store($thisFile, $here)' . "</em>. Someone using your program can configure Harmoni\n\t\t\t\t\t\tto store that file in a database, on a filesystem, to make backups transparently, or store on a \n\t\t\t\t\t\tmixture of databases and filesystems and other mediums. This allows your program, using the same \n\t\t\t\t\t\tcode, to store files in a very flexible manner, extending your audience and making for easier installation.\n\t\t\t\t\t</p>\n\t\t\t\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tA short list of the included Services follows:\n\t\t\t\t\t</p>", 2); $stories->add($story2, "100%", null, CENTER, CENTER); $row3->add($stories, null, null, CENTER, TOP); $contributors = new Block("\n\t\t\t\t<h2>\n\t\t\t\t\tLevel Three block\n\t\t\t\t</h2>\n\t\t\t\t\n\t\t\t\t<h3>\n\t\t\t\t\tEmpahsis\n\t\t\t\t</h3>\n\t\t\t\t\n\t\t\t\t<p>\n\t\t\t\t\tThis type of block may be useful for emphasizing this and that. It may not actually be included, but I might as well add it, just for kicks. Maybe it could look really cool if you used it.\n\t\t\t\t</p>\n\t\t\t", 3); $row3->add($contributors, "250px", null, LEFT, TOP); $block1->add($row3, "100%", null, CENTER, CENTER); $row4 = new Footer("This the footer, wheich may or may not be similar to the Header", 1); $block1->add($row4, "100%", null, CENTER, CENTER); $actionRows->add($block1, "100%", null, LEFT, CENTER); }
/** * Execute the Action * * @param object Harmoni $harmoni * @return mixed * @access public * @since 4/25/05 */ function execute() { $xLayout = new XLayout(); $yLayout = new YLayout(); $harmoni = Harmoni::instance(); $mainScreen = new Container($yLayout, BLOCK, 1); // :: Top Row :: // The top row for the logo and status bar. $headRow = new Container($xLayout, HEADER, 1); // The logo $logo = new Component("\n<a href='" . MYPATH . "/'> <img src='" . LOGO_URL . "' \n\t\t\t\t\t\t\tstyle='border: 0px;' alt='" . _("Concerto Logo'") . "/> </a>", BLANK, 1); $headRow->add($logo, null, null, LEFT, TOP); // Language Bar $harmoni->history->markReturnURL("polyphony/language/change"); $languageText = "\n<form action='" . $harmoni->request->quickURL("language", "change") . "' method='post'>"; $harmoni->request->startNamespace("polyphony"); $languageText .= "\n\t<div style='text-align: center'>\n\t<select name='" . $harmoni->request->getName("language") . "'>"; $harmoni->request->endNamespace(); $langLoc = Services::getService('Lang'); $currentCode = $langLoc->getLanguage(); $languages = $langLoc->getLanguages(); ksort($languages); foreach ($languages as $code => $language) { $languageText .= "\n\t\t<option value='" . $code . "'" . ($code == $currentCode ? " selected='selected'" : "") . ">"; $languageText .= $language . "</option>"; } $languageText .= "\n\t</select>"; $languageText .= "\n\t<input type='submit' />"; $languageText .= "\n\t</div>\n</form>"; $languageBar = new Component($languageText, BLANK, 1); $headRow->add($languageBar, null, null, LEFT, TOP); // Pretty Login Box $loginRow = new Container($yLayout, OTHER, 1); $headRow->add($loginRow, null, null, RIGHT, TOP); ob_start(); $authN = Services::getService("AuthN"); $agentM = Services::getService("Agent"); $idM = Services::getService("Id"); $authTypes = $authN->getAuthenticationTypes(); $users = ''; while ($authTypes->hasNext()) { $authType = $authTypes->next(); $id = $authN->getUserId($authType); if (!$id->isEqual($idM->getId('edu.middlebury.agents.anonymous'))) { $agent = $agentM->getAgent($id); $exists = false; foreach (explode("+", $users) as $user) { if ($agent->getDisplayName() == $user) { $exists = true; } } if (!$exists) { if ($users == '') { $users .= $agent->getDisplayName(); } else { $users .= " + " . $agent->getDisplayName(); } } } } if ($users != '') { print "\n<div style='text-align: right'><small>"; if (count(explode("+", $users)) == 1) { print _("User: "******"\t"; } else { print _("Users: ") . $users . "\t"; } print "<a href='" . $harmoni->request->quickURL("auth", "logout") . "'>" . _("Log Out") . "</a></small></div>"; } else { // set bookmarks for success and failure $harmoni->history->markReturnURL("polyphony/display_login"); $harmoni->history->markReturnURL("polyphony/login_fail", $harmoni->request->quickURL("user", "main")); $harmoni->request->startNamespace("harmoni-authentication"); $usernameField = $harmoni->request->getName("username"); $passwordField = $harmoni->request->getName("password"); $harmoni->request->endNamespace(); $harmoni->request->startNamespace("polyphony"); print "\n<div style='text-align: right'>" . "\n<form action='" . $harmoni->request->quickURL("auth", "login") . "' align='right' method='post'><small>" . "\n\t" . _("Username:"******" <input type='text' size='8' \n\t\t\t\t\tname='{$usernameField}'/>" . "\n\t" . _("Password:"******" <input type='password' size ='8' \n\t\t\t\t\tname='{$passwordField}'/>" . "\n\t <input type='submit' value='Log In' />" . "\n</small></form></div>\n"; $harmoni->request->endNamespace(); } $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, TOP); // User tools ob_start(); print "<div style='font-size: small; margin-top: 8px;'>"; print "<a href='" . $harmoni->request->quickURL("user", "main") . "'>"; print _("User Tools"); print "</a>"; print " | "; print "<a href='" . $harmoni->request->quickURL("admin", "main") . "'>"; print _("Admin Tools"); print "</a>"; print "</div>"; $loginRow->add(new Component(ob_get_clean(), BLANK, 2), null, null, RIGHT, BOTTOM); //Add the headerRow to the mainScreen $mainScreen->add($headRow, "100%", null, LEFT, TOP); // :: Center Pane :: $centerPane = $mainScreen->add(new Container($xLayout, OTHER, 1), "100%", null, LEFT, TOP); // use the result from previous actions if ($harmoni->printedResult) { $contentDestination = new Container($yLayout, OTHER, 1); $centerPane->add($contentDestination, null, null, LEFT, TOP); $contentDestination->add(new Block($harmoni->printedResult, 1), null, null, TOP, CENTER); $harmoni->printedResult = ''; } else { $contentDestination = $centerPane; } // use the result from previous actions if (is_object($harmoni->result)) { $contentDestination->add($harmoni->result, null, null, CENTER, TOP); } else { if (is_string($harmoni->result)) { $contentDestination->add(new Block($harmoni->result, STANDARD_BLOCK), null, null, CENTER, TOP); } } // Menu Column $menuColumn = $centerPane->add(new Container($yLayout, OTHER, 1), "140px", null, LEFT, TOP); // Main menu $menuGenerator = new ConcertoMenuGenerator(); $menuColumn->add($menuGenerator->generateMainMenu(), "140px", null, LEFT, TOP); // RSS Links $outputHandler = $harmoni->getOutputHandler(); if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction()) && RequestContext::value('collection_id')) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id'))); $title = _("RSS feed of the most recently added Assets"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('collection', 'rss_latest', array('collection_id' => RequestContext::value('collection_id'), 'order' => 'modification')); $title = _("RSS feed of the most recently changed Assets"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } /* if (preg_match("/^collections\..+$/", $harmoni->getCurrentAction())) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('collection', 'rss_all_latest'); $title = _("RSS feed of the most recently added Assets across all Collections"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('collections', 'rss_all_latest', array('order' => 'modification')); $title = _("RSS feed of the most recently changed Assets across all Collections"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } */ if (preg_match("/^exhibitions\\.browse_exhibition\$/", $harmoni->getCurrentAction()) && RequestContext::value('exhibition_id')) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('exhibition_id' => RequestContext::value('exhibition_id'))); $title = _("RSS feed of the most recently added Slideshows in this Exhibition"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('order' => 'modification', 'exhibition_id' => RequestContext::value('exhibition_id'))); $title = _("RSS feed of the most recently changed Slideshows in this Exhibition"); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<link rel='alternate' type='application/rss+xml'" . " title='" . $title . "' href='" . $url . "'/>"); print "\n\t\t<a href='" . $url . "' style='white-space: nowrap;' title='" . $title . "'>"; print "\n\t\t\t<img src='" . POLYPHONY_PATH . "icons/rss_icon02.png' border='0' alt='" . _("RSS Icon") . "'/>"; print "\n\t\t\t" . _("RSS: recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } /* if (preg_match("/^exhibitions\.browse$/", $harmoni->getCurrentAction())) { ob_start(); print "<div style='font-size: small; padding-left: 5px;'>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows'); $title = _("RSS feed of the most recently added Slideshows across all Exhibitions"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all newest"); print "\n\t\t</a><br/>"; $url = $harmoni->request->quickURL('exhibitions', 'rss_latest_slideshows', array('order' => 'modification')); $title = _("RSS feed of the most recently changed Slideshows across all Exhibitions"); $outputHandler->setHead($outputHandler->getHead() ."\n\t\t<link rel='alternate' type='application/rss+xml'" ." title='".$title."' href='".$url."'/>"); print "\n\t\t<a href='".$url."' style='white-space: nowrap;' title='".$title."'>"; print "\n\t\t\t<img src='".POLYPHONY_PATH."icons/rss_icon02.png' border='0' alt='"._("RSS Icon")."'/>"; print "\n\t\t\t"._("RSS: all recently updated"); print "\n\t\t</a>"; print "\n</div>"; $menuColumn->add(new Block(ob_get_clean(), HIGHLIT_BLOCK), "100%", null, LEFT, TOP); } */ // Basket $basket = Basket::instance(); if (preg_match("/^(collection|asset)\\.browse(Asset)?\$/", $harmoni->getCurrentAction())) { $menuColumn->add(AssetPrinter::getMultiEditOptionsBlock(), "100%", null, LEFT, TOP); } $menuColumn->add($basket->getSmallBasketBlock(EMPHASIZED_BLOCK), "100%", null, LEFT, TOP); // Collection Tags if (preg_match("/^(collection|asset|tags)\\./", $harmoni->getCurrentAction()) && $this->getCurrentRepository()) { $harmoni->request->passthrough("collection_id"); $harmoni->request->passthrough("asset_id"); $menuColumn->add(new Block("<strong>" . _("Tags in this Collection: ") . "</strong>" . TagAction::getTagCloudForRepository($this->getCurrentRepository(), 'concerto'), EMPHASIZED_BLOCK), "100%", null, LEFT, TOP); $harmoni->request->forget("collection_id"); $harmoni->request->forget("asset_id"); } // :: Footer :: $footer = new Container(new XLayout(), FOOTER, 1); $helpText = "<a target='_blank' href='"; $helpText .= $harmoni->request->quickURL("help", "browse_help"); $helpText .= "'>" . _("Help") . "</a>"; $footer->add(new UnstyledBlock($helpText), "50%", null, LEFT, BOTTOM); if (!isset($_SESSION['ConcertoVersion'])) { $document = new DOMDocument(); // attempt to load (parse) the xml file if ($document->load(MYDIR . "/doc/raw/changelog/changelog.xml")) { $versionElems = $document->getElementsByTagName("version"); $latest = $versionElems->item(0); $_SESSION['ConcertoVersion'] = $latest->getAttribute('number'); if (preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $latest->getAttribute('date'), $matches)) { $_SESSION['ConcertoCopyrightYear'] = $matches[1]; } else { $_SESSION['ConcertoCopyrightYear'] = $latest->getAttribute('date'); } } else { $_SESSION['ConcertoVersion'] = "2.x.x"; $_SESSION['ConcertoCopyrightYear'] = "2006"; } } $footerText = "<a href='" . $harmoni->request->quickURL('window', 'changelog') . "' target='_blank'>Concerto v." . $_SESSION['ConcertoVersion'] . "</a> "; $footerText .= "©" . $_SESSION['ConcertoCopyrightYear'] . " Middlebury College <a href='http://concerto.sourceforge.net'>"; $footerText .= _("about"); $footerText .= "</a>"; $footer->add(new UnstyledBlock($footerText), "50%", null, RIGHT, BOTTOM); $mainScreen->add($footer, "100%", null, RIGHT, BOTTOM); return $mainScreen; }
/** * Answer the contents of the current topic * * @param string $topic * @return object Component * @access public * @since 12/9/05 */ function getTopicContents($topic) { $topicContainer = new Container(new YLayout(), BLANK, 1); $tocPart = $this->_tableOfContents->getTableOfContentsPart($topic); try { $document = $this->getTopicXmlDocument($topic); } catch (DOMException $e) { $topicContainer->add(new Block(_("Could not load help topic:") . "<br/><br/>" . $e->getMessage(), STANDARD_BLOCK)); return $topicContainer; } $xpath = new DOMXPath($document); $bodyElements = $xpath->query("/html/body"); if (!$bodyElements->length) { $topicContainer->add(new Block(_("This topic has no information yet."), STANDARD_BLOCK)); return $topicContainer; } $body = $bodyElements->item(0); if ($tocPart && !is_null($document->documentElement)) { $this->updateSrcTags($document->documentElement, $tocPart->urlPath . "/"); } // put custom style sheets in the page's head $headElements = $xpath->query("/html/head"); $head = $headElements->item(0); $newHeadText = ''; foreach ($head->childNodes as $child) { $newHeadText .= $document->saveXML($child) . "\n\t\t"; } $harmoni = Harmoni::instance(); $outputHandler = $harmoni->getOutputHandler(); $outputHandler->setHead($outputHandler->getHead() . $newHeadText); /********************************************************* * Page TOC *********************************************************/ $currentLevel = 1; $toc = new TOC_Printer(); foreach ($body->childNodes as $element) { unset($level); switch ($element->nodeName) { case 'h1': $level = 1; case 'h2': if (!isset($level)) { $level = 2; } case 'h3': if (!isset($level)) { $level = 3; } case 'h4': if (!isset($level)) { $level = 4; } $heading = $element->textContent; $anchor = strtolower(preg_replace('/[^a-zA-Z0-9_]/', '', $element->textContent)); if ($level > $currentLevel) { while ($level > $currentLevel) { $toc = $toc->addLevel(); $currentLevel++; } } else { if ($level < $currentLevel) { while ($level < $currentLevel) { $toc = $toc->removeLevel(); $currentLevel--; } } } $toc->addHtml("<a href='#{$anchor}'>{$heading}</a>"); } } $toc = $toc->getRoot(); if ($toc->numChildren() > 1 || $toc->hasMoreLevels()) { $topicContainer->add(new Block($toc->getHtml(), STANDARD_BLOCK)); } /********************************************************* * Content of the page *********************************************************/ ob_start(); foreach ($body->childNodes as $element) { switch ($element->nodeName) { case 'h1': $heading = new Heading($element->textContent, 1); case 'h2': if (!isset($heading)) { $heading = new Heading($element->textContent, 2); } case 'h3': if (!isset($heading)) { $heading = new Heading($element->textContent, 3); } case 'h4': if (!isset($heading)) { $heading = new Heading($element->textContent, 4); } $heading->setPreHTML("<a name=\"" . strtolower(preg_replace('/[^a-zA-Z0-9_]/', '', $element->textContent)) . "\"></a>"); // Finish off our previous block if it had contents. $previousBlockText = ob_get_clean(); if (strlen(trim($previousBlockText))) { $topicContainer->add(new Block($this->linkify($previousBlockText), STANDARD_BLOCK)); } // create our heading element $topicContainer->add($heading); unset($heading); // Start a new buffer for the next block contents. ob_start(); break; default: print $document->saveXML($element) . "\n"; } } $topicContainer->add(new Block($this->linkify(ob_get_clean()), STANDARD_BLOCK)); return $topicContainer; }
/** * Visit a fixed organizer and return the GUI component [a container] * that corresponds to it. Traverse-to/add child components. * * @param object FixedOrganizerSiteComponent $organizer * @return object Component * @access public * @since 4/3/06 */ public function visitFixedOrganizer(FixedOrganizerSiteComponent $organizer) { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $organizer->getQualifierId())) { $tdStyles = 'border: 1px solid #F00; padding: 6px;'; } else { $tdStyles = ''; } $guiContainer = new Container(new TableLayout($organizer->getNumColumns(), $tdStyles), BLANK, 1); // Add controls bar and border $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $organizer->getQualifierId())) { $canAdd = true; } else { $canAdd = false; } $numCells = $organizer->getTotalNumberOfCells(); for ($i = 0; $i < $numCells; $i++) { $child = $organizer->getSubcomponentForCell($i); if (is_object($child)) { $childComponent = $child->acceptVisitor($this); if ($childComponent) { $guiContainer->add($childComponent, $child->getWidth(), null, null, TOP); } else { $childComponent = $guiContainer->add(new Blank(), $child->getWidth(), null, null, TOP); } } else { $this->_emptyCellContainers[$organizer->getId() . '_cell:' . $i] = $guiContainer; $this->_emptyCellPlaceholders[$organizer->getId() . '_cell:' . $i] = $guiContainer->addPlaceholder(); $childComponent = $guiContainer->getComponent($this->_emptyCellPlaceholders[$organizer->getId() . '_cell:' . $i]); } if ($canAdd) { $this->wrapAsDroppable($childComponent, $organizer->getId() . "_cell:" . $i, array_keys($organizer->getVisibleComponentsForPossibleAdditionToCell($i))); } } if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $organizer->getQualifierId())) { $controlsHTML = $this->getBarPreHTML('#F00', $organizer, '1px') . $this->getControlsHTML($organizer, $organizer->getDisplayName(), $organizer->acceptVisitor($this->_controlsVisitor), '#F00', '#F99', '#F66', 0, '1px'); $guiContainer->setPreHTML($controlsHTML . "\n<div style='z-index: 0;'>" . $guiContainer->getPreHTML($null = null)); $guiContainer->setPostHTML($guiContainer->getPostHTML($null = null) . "</div>" . $this->getBarPostHTML()); if (count($organizer->getVisibleDestinationsForPossibleAddition())) { $this->wrapAsDraggable($guiContainer, $organizer->getId(), 'FixedOrganizer'); } } return $guiContainer; }
function test_generic_container() { $comp = new Container(new FlowLayout(), MENU, 5); $c = new Component("Hello!", FOOTER, 4); $c1 = $comp->add($c, "12px", "2em", LEFT, BOTTOM); $this->assertReference($c1, $c); $this->assertReference($comp->getComponent(1), $c); $this->assertIdentical($comp->getComponentWidth(1), "12px"); $this->assertIdentical($comp->getComponentHeight(1), "2em"); $this->assertIdentical($comp->getComponentAlignmentX(1), LEFT); $this->assertIdentical($comp->getComponentAlignmentY(1), BOTTOM); $this->assertIdentical($comp->getComponentsCount(), 1); $c = new Component("Hello!", MENU_ITEM_LINK_SELECTED, 2); $c2 = $comp->add($c, "16px", "6em", RIGHT, CENTER); $this->assertReference($c2, $c); $this->assertReference($comp->getComponent(2), $c); $this->assertIdentical($comp->getComponentsCount(), 2); $c = new Component("Hello!", MENU_ITEM_LINK_UNSELECTED, 5); $c3 = $comp->add($c, "6px", "2em", CENTER, TOP); $this->assertReference($c3, $c); $this->assertReference($comp->getComponent(3), $c); $this->assertIdentical($comp->getComponentsCount(), 3); $c = $comp->remove(2); $this->assertReference($c, $c2); $this->assertNull($comp->getComponent(2)); $this->assertIdentical($comp->getComponentsCount(), 2); $comp->removeAll(); $this->assertIdentical($comp->_components, array()); $this->assertIdentical($comp->getComponentsCount(), 0); }
/* Test delete() */ $testdelete = new Container(); assert('!$testdelete->is_set("bla")'); $testdelete->set('bla', 'woeiwoei'); assert('$testdelete->is_set("bla")'); $testdelete->delete('bla'); assert('!$testdelete->is_set("bla")'); /* Test underscores and dashes juggling */ $c = new Container(); $c->set('foo_bar', 'baz'); assert('$c->get("foo-bar") === "baz"'); assert('$c->get("foo_bar") === "baz"'); $c->set('foo-bar', 'baz2'); assert('$c->get("foo-bar") === "baz2"'); assert('$c->get("foo_bar") === "baz2"'); $c->add('some-list', 'value'); $c->add('some_list', 'value'); assert('count($c->get("some-list")) === 2'); /* Test getdefault() and setdefault() */ $c = new Container(); assert('$c->getdefault("foo", "defaultvalue") === "defaultvalue"'); $c->set('foo', 'anothervalue'); assert('$c->getdefault("foo", "defaultvalue") === "anothervalue"'); assert('$c->is_set("bar") === false'); $c->setdefault('bar', 'somevalue'); assert('$c->get("bar") === "somevalue"'); $c->set('bar', 'anothervalue'); assert('$c->get("bar") === "anothervalue"'); $c->setdefault('bar', 'somevalue'); /* should do nothing */ assert('$c->get("bar") === "anothervalue"');
/** * * * @param <##> * @return <##> * @access public * @since 1/18/06 */ public function printSiteShort(Asset $asset, $action, $num, Slot $otherSlot = null) { $harmoni = Harmoni::instance(); $assetId = $asset->getId(); $authZ = Services::getService('AuthZ'); $idMgr = Services::getService('Id'); if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId) && !$otherSlot->isUserOwner()) { return new UnstyledBlock('', BLANK); } $container = new Container(new YLayout(), BLOCK, STANDARD_BLOCK); $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container."); $fillContainerSC->addSP(new MinHeightSP("88%")); // $fillContainerSC->addSP(new WidthSP("100%")); // $fillContainerSC->addSP(new BorderSP("3px", "solid", "#F00")); $container->addStyle($fillContainerSC); $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text"); $centered->addSP(new TextAlignSP("center")); // Use the alias instead of the Id if it is available. $viewUrl = SiteDispatcher::getSitesUrlForSiteId($assetId->getIdString()); $slotManager = SlotManager::instance(); try { $sitesTrueSlot = $slotManager->getSlotBySiteId($assetId); } catch (Exception $e) { } // Print out the content ob_start(); print "\n\t<div class='portal_list_slotname'>"; if (isset($sitesTrueSlot)) { if (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname()) { print $sitesTrueSlot->getShortname(); } else { print $otherSlot->getShortname(); $targets = array(); $target = $otherSlot->getAliasTarget(); while ($target) { $targets[] = $target->getShortname(); if ($target->isAlias()) { $target = $target->getAliasTarget(); } else { $target = null; } } print "\n<br/>"; print str_replace('%1', implode(' » ', $targets), _("(an alias of %1)")); // Add Alias info. // if ($otherSlot->isAlias()) { // ob_start(); // // print _("This slot is an alias of ").$slot->getAliasTarget()->getShortname(); // // $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, TOP); // } } } else { print _("ID#") . ": " . $assetId->getIdString(); } print "\n\t</div>"; print "\n\t<div class='portal_list_site_title'>"; if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { print "\n\t\t<a href='" . $viewUrl . "'>"; print "\n\t\t\t<strong>" . HtmlString::getSafeHtml($asset->getDisplayName()) . "</strong>"; print "\n\t\t</a>"; print "\n\t\t<br/>"; print "\n\t\t<a href='" . $viewUrl . "' style='font-size: smaller;'>"; print "\n\t\t\t" . $viewUrl; print "\n\t\t</a>"; } print "\n\t</div>"; print "\n\t<div class='portal_list_controls'>\n\t\t"; $controls = array(); if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $controls[] = "<a href='" . $viewUrl . "'>" . _("view") . "</a>"; } // Hide all edit links if not authenticated to prevent web spiders from traversing them if ($this->isAuthenticated) { // While it is more correct to check modify permission permission, doing // so forces us to check AZs on the entire site until finding a node with // authorization or running out of nodes to check. Since edit-mode actions // devolve into view-mode if no authorization is had by the user, just // show the links all the time to cut page loads from 4-6 seconds to // less than 1 second. if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $controls[] = "<a href='" . SiteDispatcher::quickURL($action->getUiModule(), 'editview', array('node' => $assetId->getIdString())) . "'>" . _("edit") . "</a>"; } // if ($action->getUiModule() == 'ui2') { // $controls[] = "<a href='".SiteDispatcher::quickURL($action->getUiModule(), 'arrangeview', array('node' => $assetId->getIdString()))."'>"._("arrange")."</a>"; // } // add link to tracking if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $trackUrl = $harmoni->request->quickURL("participation", "actions", array('node' => $assetId->getIdString())); ob_start(); print " <a target='_blank' href='" . $trackUrl . "'"; print ' onclick="'; print "var url = '" . $trackUrl . "'; "; print "window.open(url, 'site_map', 'width=600,height=600,resizable=yes,scrollbars=yes'); "; print "return false;"; print '"'; print ">" . _("track") . "</a>"; $controls[] = ob_get_clean(); } if (!is_null($otherSlot) && $otherSlot->isAlias() && $otherSlot->isUserOwner()) { $controls[] = "<a href='" . $harmoni->request->quickURL('slots', 'remove_alias', array('slot' => $otherSlot->getShortname())) . "' onclick=\"if (!confirm('" . str_replace("%1", $otherSlot->getShortname(), str_replace("%2", $otherSlot->getAliasTarget()->getShortname(), _("Are you sure that you want \\'%1\\' to no longer be an alias of \\'%2\\'?"))) . "')) { return false; }\">" . _("remove alias") . "</a>"; } else { if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.delete'), $assetId)) { $controls[] = "<a href='" . $harmoni->request->quickURL($action->getUiModule(), 'deleteComponent', array('node' => $assetId->getIdString())) . "' onclick=\"if (!confirm('" . _("Are you sure that you want to permenantly delete this site?") . "')) { return false; }\">" . _("delete") . "</a>"; } } // Add a control to select this site for copying. This should probably // have its own authorization, but we'll use add_children/modify for now. if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $assetId)) { if (isset($sitesTrueSlot) && (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname())) { $controls[] = Segue_Selection::instance()->getAddLink(SiteDispatcher::getSiteDirector()->getSiteComponentFromAsset($asset)); } } } print implode("\n\t\t | ", $controls); print "\n\t</div>"; if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $description = HtmlString::withValue($asset->getDescription()); $description->trim(25); print "\n\t<div class='portal_list_site_description'>" . $description->asString() . "</div>"; } print "\n\t<div style='clear: both;'></div>"; print $this->getExportControls($assetId, $otherSlot, $sitesTrueSlot); $component = new UnstyledBlock(ob_get_clean()); $container->add($component, "100%", null, LEFT, TOP); return $container; }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $cm = Services::getService("CourseManagement"); $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); $pageRows = new Container(new YLayout(), OTHER, 1); $harmoni = Harmoni::instance(); $searchNumber = RequestContext::value('search_number'); if (is_null($searchNumber)) { $searchNumber = ""; } ob_start(); /*************************************************************************************************** * The following performs a wild-card search through LDAP and sucks the courses into the database. * ***************************************************************************************************/ $self = $harmoni->request->quickURL(); print "<h2>Search for course offerings by the following criteria:</h2>" . ""; print "\n\t<form action='{$self}' method='post'>\n\t\t\t\n\t<div>"; print "<table>"; print "\n\t<tr><td>Number: </td><td><input type='text' name='search_number' value='" . $searchNumber . "'/></td></tr>"; print "\n\t<tr><td>Term: </td><td><select name='search_term'>"; print "\n\t<option value=''"; print "selected='selected'"; print ">Choose a term</option>"; //@TODO this sorting is probably pretty slow--it's multiple queries per term. $numOfImproperOfferingTerms = -1; $terms = $cm->getTerms(); while ($terms->hasNextTerm()) { $term = $terms->nextTerm(); $schedule = $term->getSchedule(); if ($schedule->hasNextScheduleItem()) { $item1 = $schedule->nextScheduleItem(); $terms2[$item1->getStart()] = $term; } else { $terms2[$numOfImproperOfferingTerms] = $term; $numOfImproperOfferingTerms--; } } krsort($terms2); foreach ($terms2 as $term) { $id = $term->getId(); print "\n\t<option value='" . $id->getIdString() . "'"; /*if($searchTerm==$id->getIdString()){ print "selected='selected'"; }*/ print ">" . $term->getDisplayName() . "</option>"; } print "\n\t</select></td></tr>"; print "\n</table>"; print "\n\t<p><input type='submit' value='" . _("Search") . "'/></p>"; print "\n\t</div></form>"; //$actionRows =$this->getActionRows(); $actionRows->add(new Block(ob_get_contents(), 2), "100%", null, CENTER, TOP); ob_end_clean(); $searchTerm = RequestContext::value('search_term'); if (is_null($searchTerm)) { $searchTerm = ""; } /* if ($search_criteria = $harmoni->request->get('search_criteria')) { //$typeParts = explode("::", @html_entity_decode($search_type, ENT_COMPAT, 'UTF-8')); $searchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "TokenSearch"); //$searchType = new HarmoniType("Agent & Group Search", "edu.middlebury.harmoni", "WildcardSearch"); $string= "*".$search_criteria."*"; $agents =$agentManager->getAgentsBySearch($string, $searchType); print "search: " . $search_criteria; while ($agents->hasNext()) { $agent =$agents->next(); $id =$agent->getId(); $harmoni->history->markReturnURL("polyphony/agents/edit_agent_details"); print "\n<p align='center'><a href='".$harmoni->request->quickURL("agents","edit_agent_details", array("agentId"=>$id->getIdString()))."'>"; print "\n".$agent->getDisplayName()."</a>"; print "\n - <a href=\"Javascript:alert('"._("Id:").'\n\t'.addslashes($id->getIdString())."')\">Id</a></p>"; } print "\n</div>"; $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); } */ if ($searchNumber != "" || $searchTerm != "") { ob_start(); $pageRows->add(new Heading("Canonical course search results", STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_start(); print "<p><h2>Search Results</h2></p>"; $searchType = new ClassTokenSearch(); $string = "*" . $searchNumber . "*"; $DNs = $searchType->getClassDNsBySearch($string); print "search: " . $searchNumber; /* $dbHandler = Services::getService("DBHandler"); $query= new SelectQuery; $query->addTable('cm_offer'); $query->addColumn('id'); if($searchNumber!=null){ $query->addWhere("number like '%".addslashes($searchNumber)."%'"); } if($searchTerm!=null){ $query->addWhere("fk_cm_term='".addslashes($searchTerm)."'"); } $res =$dbHandler->query($query);*/ $sections = array(); $cm = Services::getService("CourseManagement"); $im = Services::getService("Id"); foreach ($DNs as $idString) { if (substr($idString, strlen($idString) - 42, 42) != ",OU=Classes,OU=Groups,DC=middlebury,DC=edu") { continue; } $len = 0; while ($idString[$len + 3] != "," && $len < strlen($idString)) { $len++; } $name = substr($idString, 3, $len); /* if(!$term somthings $searchTerm){ //continue } */ //filter out semesters if (substr($name, strlen($name) - 4, 1) != "-") { continue; } //filter out gym--actually, that's not fair, is it? //if(substr($name,0,4)=="phed"){ // // continue; //} $sections[] = suck_by_agentAction::_figureOut($name, $agentId = null); } $offerings = array(); $termId = null; if ($searchTerm != "") { //$term = substr($name, strlen($name)-3,3); $idManager = Services::getService("Id"); // $term =$cm->getTerm($idManager->getId($searchTerm)); // $termId =$term->getId(); $termId = $idManager->getId($searchTerm); } foreach ($sections as $section) { $offering = $section->getCourseOffering(); $term2 = $offering->getTerm(); $term2Id = $term2->getId(); if (!is_null($termId) && !$termId->isEqual($term2Id)) { continue; } $offeringId = $offering->getId(); $offerings[$offeringId->getIdString()] = $offering; } /* foreach($DNs as $DN){ $id =$im->getId($row['id']); $array[] =$cm->getCourseOffering($id); }*/ $iter = new HarmoniCourseOfferingIterator($offerings); edit_agent_detailsAction::printCourseOfferings($iter); $actionRows->add(new Block(ob_get_contents(), 2), "100%", null, CENTER, TOP); ob_end_clean(); } }
// now create all the containers and components $block1 = new Container($yLayout, BLOCK, 1); $row1 = new Container($xLayout, OTHER, 1); $header1 = new Heading("A Harmoni GUI example.<br />Level-1 heading.\n", 1); $row1->add($header1, null, null, CENTER, CENTER); $menu1 = new Menu($xLayout, 1); $menu1_item1 = new MenuItemHeading("Main Menu:\n", 1); $menu1_item2 = new MenuItemLink("Home", "http://www.google.com", true, 1); $menu1_item3 = new MenuItemLink("Theme Settings", "http://www.middlebury.edu", false, 1); $menu1_item4 = new MenuItemLink("Manage Themes", "http://www.cnn.com", false, 1); $menu1->add($menu1_item1, "25%", null, CENTER, CENTER); $menu1->add($menu1_item2, "25%", null, CENTER, CENTER); $menu1->add($menu1_item3, "25%", null, CENTER, CENTER); $menu1->add($menu1_item4, "25%", null, CENTER, CENTER); $row1->add($menu1, "500px", null, RIGHT, BOTTOM); $block1->add($row1, "100%", null, RIGHT, CENTER); $row2 = new Block("\n\t\t\tThis is some text in a Level-2 text block.\n\t\t\t<p>Welcome to the <strong>Harmoni Architecture/Framework</strong> web site. The Harmoni Project is a joint effort\n\t\t\tbetween PHP Web/Database programmers located at <a href=\"http://et.middlebury.edu/\">Middlebury College's\n\t\t\tEducational Technology</a> department and the <a href=\"http://www.colleges.org/\">Associated Colleges\n\t\t\tof the South</a>. The project is built entirely using PHP's OOP (Object Oriented Programming) model, allowing\n\t\t\tthe code to be easily extended and enhanced with no loss of functionality or backward-compatibility. Our\n\t\t\tprogrammers also document all their code with <strong>PHPDoc</strong> inline comments to make use of our API's a\n\t\t\tlittle easier for you.</p>\n", 2); $block1->add($row2, "100%", null, CENTER, CENTER); $row3 = new Container($xLayout, OTHER, 1); $menu2 = new Menu($yLayout, 1); $menu2_item1 = new MenuItemHeading("Sub-menu:\n", 1); $menu2_item2 = new MenuItemLink("The Architecture", "http://www.google.com", true, 1); $menu2_item3 = new MenuItemLink("The Framework", "http://www.middlebury.edu", false, 1); $menu2_item4 = new MenuItemLink("Google: Searching", "http://www.cnn.com", false, 1); $menu2_item5 = new MenuItemLink("Slashdot", "http://www.slashdot.org", false, 1); $menu2_item6 = new MenuItemLink("Background Ex", "http://www.depechemode.com", false, 1); $menu2->add($menu2_item1, "100%", null, LEFT, CENTER); $menu2->add($menu2_item2, "100%", null, LEFT, CENTER); $menu2->add($menu2_item3, "100%", null, LEFT, CENTER); $menu2->add($menu2_item4, "100%", null, LEFT, CENTER); $menu2->add($menu2_item5, "100%", null, LEFT, CENTER);
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); $pageRows = new Container(new YLayout(), OTHER, 1); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-agents"); $agentManager = Services::getService("Agent"); $idManager = Services::getService("Id"); $cm = Services::getService("CourseManagement"); /********************************************************* * the select menu *********************************************************/ // Users header //$actionRows->add(new Heading(_("Select Term"), 2), "100%", null, LEFT, CENTER); ob_start(); $self = $harmoni->request->quickURL(); $lastTerm = $harmoni->request->get("term_name"); $term_name = RequestContext::name("term_name"); //$search_type_name = RequestContext::name("search_type"); print _("<p align='center'>Select a Term") . ": </p>"; print <<<END \t\t<form action='{$self}' method='post'> \t\t\t<div> \t\t \t\t\t<p align='center'><select name='{$term_name}'> END; $searchTypes = $agentManager->getAgentSearchTypes(); $classId = $idManager->getId("OU=Classes,OU=Groups,DC=middlebury,DC=edu "); $classes = $agentManager->getGroup($classId); $terms = $classes->getGroups(false); while ($terms->hasNext()) { $termGroup = $terms->next(); $termName = $termGroup->getDisplayName(); $term = $this->_getTerm($termName); $id = $term->getId(); $idString = $id->getIdString(); print "\n\t\t<option value='" . $idString . "'"; if ($harmoni->request->get('term_name') == $idString) { print " selected='selected'"; } print ">" . $term->getDisplayName() . "</option>"; } print "\n\t</select>"; print "\n\t<input type='submit' value='" . _("Suck!") . "' />"; //print "\n\t<a href='".$harmoni->request->quickURL()."'>"; print "\n</p>\n</div></form>"; print "\n <p align='center'>Sucking may take a few minutes</p>"; $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); /********************************************************* * the agent search results *********************************************************/ ob_start(); if ($termIdString = $harmoni->request->get('term_name')) { $classId = $idManager->getId("OU=Classes,OU=Groups,DC=middlebury,DC=edu "); $classes = $agentManager->getGroup($classId); $terms = $classes->getGroups(false); while ($terms->hasNext()) { $termGroup = $terms->next(); $termName = $termGroup->getDisplayName(); $term = $this->_getTerm($termName); $id = $term->getId(); if ($termIdString == $id->getIdString()) { break; } } $pageRows->add(new Heading(_("Courses Sucked from " . $term->getDisplayName() . ""), 2), "100%", null, LEFT, CENTER); ob_start(); $last = ""; $sections = $termGroup->getGroups(false); while ($sections->hasNext()) { $section = $sections->next(); $sectionName = $section->getDisplayName(); if (substr($sectionName, 0, 4) == "phed") { continue; } if (substr($sectionName, 0, strlen($sectionName) - 5) != $last) { $last = substr($sectionName, 0, strlen($sectionName) - 5); $canonicalCourseId = $this->_getCanonicalCourse($sectionName); } } print "Success!"; // Create a layout for this group using the GroupPrinter $groupLayout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $pageRows->add($groupLayout, "100%", null, LEFT, CENTER); //} // In order to preserve proper nesting on the HTML output, the checkboxes // are all in the pagerows layout instead of actionrows. $actionRows->add($pageRows, null, null, CENTER, CENTER); } textdomain($defaultTextDomain); }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); $pageRows = new Container(new YLayout(), OTHER, 1); $harmoni = Harmoni::instance(); // start our namespace $harmoni->history->markReturnURL("polyphony/authorization/edit_authorizations"); $harmoni->request->startNamespace("polyphony-authorizations"); $harmoni->request->passthrough(); $agentManager = Services::getService("Agent"); $idManager = Services::getService("Id"); $everyoneId = $idManager->getId("edu.middlebury.agents.everyone"); $usersId = $idManager->getId("edu.middlebury.agents.users"); /********************************************************* * Buttons *********************************************************/ ob_start(); print "<table width='100%'><tr><td align='left'>"; print "<a href='" . $harmoni->request->quickURL("admin", "main") . "'><button>" . _("Return to the Admin Tools") . "</button></a>"; print "</td><td align='right'>"; print "<input type='button'"; print " onclick='Javascript:submitAgentChoice()'"; print " value='" . _("Edit Authorizations for the selected User/Group") . " -->' />"; print "</td></tr></table>"; $submit = new Block(ob_get_contents(), STANDARD_BLOCK); $actionRows->add($submit, "100%", null, LEFT, CENTER); ob_end_clean(); // Users header $actionRows->add(new Heading("Users", 2), "100%", null, LEFT, CENTER); /********************************************************* * the agent search form *********************************************************/ ob_start(); $self = $harmoni->request->quickURL(); $lastCriteria = $harmoni->request->get('search_criteria'); $search_criteria_name = RequestContext::name('search_criteria'); $search_type_name = RequestContext::name('search_type'); print _("Search For Users") . ": "; print <<<END \t\t<form action='{$self}' method='post'> \t\t\t<div> \t\t\t<input type='text' name='{$search_criteria_name}' value='{$lastCriteria}' /> \t\t\t<br /><select name='{$search_type_name}'> END; $searchTypes = $agentManager->getAgentSearchTypes(); while ($searchTypes->hasNext()) { $type = $searchTypes->next(); $typeString = $type->getDomain() . "::" . $type->getAuthority() . "::" . $type->getKeyword(); print "\n\t\t<option value='" . htmlspecialchars($typeString, ENT_QUOTES) . "'"; if ($harmoni->request->get("search_type") == $typeString) { print " selected='selected'"; } print ">" . htmlspecialchars($typeString) . "</option>"; } print "\n\t</select>"; print "\n\t<br /><input type='submit' value='" . _("Search") . "' />"; print "\n\t<a href='" . $harmoni->request->quickURL() . "'>"; print "\n\t\t<input type='button' value='" . _("Clear") . "' />\n\t</a>"; print "\n</div>\n</form>"; $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK)); ob_end_clean(); /********************************************************* * Form and Javascript *********************************************************/ // In order to preserve proper nesting on the HTML output put the form // around the row layout ob_start(); $errorString = _("You must select a User or Group."); $agentFieldName = RequestContext::name("agentId"); print <<<END \t\t \t\t<script type='text/javascript'> \t\t//<![CDATA[ \t\t \t\t\t// Make sure a selection has been made and submit if it has. \t\t\tfunction submitAgentChoice() { \t\t\t\tvar f;\t\t \t\t\t\tfor (i = 0; i < document.forms.length; i++) { \t\t\t\t\tf = document.forms[i];\t\t\t \t\t\t\t\tif (f.id == 'chooseform') { \t\t\t\t\t\tvar form = f; \t\t\t\t\t\tbreak; \t\t\t\t\t} \t\t\t\t} \t\t\t\t \t\t\t\tvar radioArray = form.agentId; \t\t\t\tvar isChecked = false; \t\t\t\t \t\t\t\tfor (i=0; i<radioArray.length; i++) { \t\t\t\t\tif (radioArray[i].checked) { \t\t\t\t\t\tisChecked = true; \t\t\t\t\t} \t\t\t\t} \t\t\t\t \t\t\t\tif (isChecked) { \t\t\t\t\tform.submit(); \t\t\t\t} else { \t\t\t\t\talert("{$errorString}"); \t\t\t\t} \t\t\t} \t\t\t \t\t//]]> \t\t</script> \t\t END; print "<form id='chooseform' method='post' action='" . $harmoni->request->quickURL("authorization", "edit_authorizations") . "'>\n"; $pageRows->setPreHTML(ob_get_contents()); ob_end_clean(); $pageRows->setPostHTML("</form>"); /********************************************************* * the agent search results *********************************************************/ $search_criteria = $harmoni->request->get("search_criteria"); $search_type = $harmoni->request->get("search_type"); if ($search_criteria && $search_type) { $typeParts = explode("::", $search_type); $searchType = new HarmoniType($typeParts[0], $typeParts[1], $typeParts[2]); $agents = new MultiIteratorIterator(); $agents->addIterator($agentManager->getGroupsBySearch($search_criteria, $searchType)); $agents->addIterator($agentManager->getAgentsBySearch($search_criteria, $searchType)); print <<<END \t\t \t\t \t\t<table> \t\t\t<tr> \t\t\t\t<td valign='top'> \t\t\t\t\t<div style=' \t\t\t\t\t\tborder: 1px solid #000; \t\t\t\t\t\twidth: 15px; \t\t\t\t\t\theight: 15px; \t\t\t\t\t\ttext-align: center; \t\t\t\t\t\ttext-decoration: none; \t\t\t\t\t\tfont-weight: bold; \t\t\t\t\t'> \t\t\t\t\t\t- \t\t\t\t\t</div> \t\t\t\t</td> \t\t\t\t<td> END; print "\n\t\t\t" . _("Search Results"); print <<<END \t\t\t\t</td> \t\t\t</tr> \t\t</table> \t\t<div style=' \t\t\tmargin-left: 13px; \t\t\tmargin-right: 0px; \t\t\tmargin-top:0px; \t\t\tpadding-left: 10px; \t\t\tborder-left: 1px solid #000; \t\t'> END; while ($agents->hasNext()) { $agent = $agents->next(); if ($agent->isGroup()) { $this->printGroup($agent); } else { $this->printMember($agent); } print "<br />"; } print "\n</div>"; $pageRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); } /********************************************************* * Groups *********************************************************/ // Users header $pageRows->add(new Heading(_("Groups"), 2), "100%", null, LEFT, CENTER); // Loop through all of the Groups $childGroupIds = array(); $groups = $agentManager->getGroupsBySearch($null = null, new Type("Agent & Group Search", "edu.middlebury.harmoni", "RootGroups")); while ($groups->hasNext()) { $group = $groups->next(); $groupId = $group->getId(); // Create a layout for this group using the GroupPrinter ob_start(); GroupPrinter::printGroup($group, $harmoni, 2, array($this, "printGroup"), array($this, "printMember")); $groupLayout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $pageRows->add($groupLayout, "100%", null, LEFT, CENTER); } $pageRows->add($submit, "100%", null, LEFT, CENTER); $actionRows->add($pageRows); $harmoni->request->endNamespace(); textdomain($defaultTextDomain); }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); $pageRows = new Container(new YLayout(), OTHER, 1); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-agents"); $harmoni->request->passthrough(); // register this action as the return-point for the following operations: $harmoni->history->markReturnURL("polyphony/agents/add_to_group"); $harmoni->history->markReturnURL("polyphony/agents/remove_from_group"); $agentManager = Services::getService("Agent"); $idManager = Services::getService("Id"); $everyoneId = $idManager->getId("edu.middlebury.agents.everyone"); $usersId = $idManager->getId("edu.middlebury.agents.users"); $allGroupsId = $idManager->getId("edu.middlebury.agents.all_groups"); /********************************************************* * the agent search form *********************************************************/ // Users header $actionRows->add(new Heading(_("Users"), 2), "100%", null, LEFT, CENTER); ob_start(); $self = $harmoni->request->quickURL(); $lastCriteria = $harmoni->request->get("search_criteria"); $search_criteria_name = RequestContext::name("search_criteria"); $search_type_name = RequestContext::name("search_type"); print _("Search For Users") . ": "; print <<<END \t\t<form action='{$self}' method='post'> \t\t\t<div> \t\t\t<input type='text' name='{$search_criteria_name}' value='{$lastCriteria}' /> \t\t\t<br /><select name='{$search_type_name}'> END; $searchTypes = $agentManager->getAgentSearchTypes(); while ($searchTypes->hasNext()) { $type = $searchTypes->next(); $typeString = htmlspecialchars($type->getDomain() . "::" . $type->getAuthority() . "::" . $type->getKeyword()); print "\n\t\t<option value='{$typeString}'"; if ($harmoni->request->get("search_type") == $typeString) { print " selected='selected'"; } print ">{$typeString}</option>"; } print "\n\t</select>"; print "\n\t<br /><input type='submit' value='" . _("Search") . "' />"; print "\n\t<a href='" . $harmoni->request->quickURL() . "'>"; print "<input type='button' value='" . _("Clear") . "' /></a>"; print "\n</div>\n</form>"; $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); /********************************************************* * the agent search results *********************************************************/ ob_start(); if (($search_criteria = $harmoni->request->get('search_criteria')) && ($search_type = $harmoni->request->get('search_type'))) { $typeParts = explode("::", @html_entity_decode($search_type, ENT_COMPAT, 'UTF-8')); $searchType = new HarmoniType($typeParts[0], $typeParts[1], $typeParts[2]); $agents = new MultiIteratorIterator(); $agents->addIterator($agentManager->getAgentsBySearch($search_criteria, $searchType)); $agents->addIterator($agentManager->getGroupsBySearch($search_criteria, $searchType)); print "search: " . $search_criteria; print <<<END \t\t \t\t \t\t<table> \t\t\t<tr> \t\t\t\t<td valign='top'> \t\t\t\t\t<div style=' \t\t\t\t\t\tborder: 1px solid #000; \t\t\t\t\t\twidth: 15px; \t\t\t\t\t\theight: 15px; \t\t\t\t\t\ttext-align: center; \t\t\t\t\t\ttext-decoration: none; \t\t\t\t\t\tfont-weight: bold; \t\t\t\t\t'> \t\t\t\t\t\t- \t\t\t\t\t</div> \t\t\t\t</td> \t\t\t\t<td> END; print "\n\t\t\t" . _("Search Results"); print <<<END \t\t\t\t</td> \t\t\t</tr> \t\t</table> \t\t<div style=' \t\t\tmargin-left: 13px; \t\t\tmargin-right: 0px; \t\t\tmargin-top:0px; \t\t\tpadding-left: 10px; \t\t\tborder-left: 1px solid #000; \t\t'> END; while ($agents->hasNext()) { $agent = $agents->next(); group_membershipAction::printMember($agent); print "<br />"; } print "\n</div>"; $pageRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); } /********************************************************* * Groups *********************************************************/ $pageRows->add(new Heading(_("Groups"), 2), "100%", null, LEFT, CENTER); // Define some global variables to store javascript array definitions // for validating adding/removing inputs. $GLOBALS['decendent_groups_string'] = ""; $GLOBALS['child_groups_string'] = ""; $GLOBALS['child_agents_string'] = ""; // Loop through all of the Root Groups $groups = $agentManager->getGroupsBySearch($null = null, new Type("Agent & Group Search", "edu.middlebury.harmoni", "RootGroups")); while ($groups->hasNext()) { $group = $groups->next(); $groupId = $group->getId(); // Create a layout for this group using the GroupPrinter ob_start(); GroupPrinter::printGroup($group, $harmoni, 2, array($this, "printGroup"), array($this, "printMember")); $groupLayout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $pageRows->add($groupLayout, "100%", null, LEFT, CENTER); } /********************************************************* * Javascript for validating checkboxes, * Form Definition. *********************************************************/ ob_start(); // Create translated errorstrings $cannotAddGroup = _("Cannot add group"); $toItsself = _("to itself"); $deselecting = _("Deselecting"); $toOwnDesc = _("to its own descendent"); $groupString = _("Group"); $isAlreadyInGroup = _("is alread in this group"); $agentString = _("Agent"); $fromItsself = _("from itself"); $cannotRemoveGroup = _("Cannot remove group"); $notInGroup = _("is not in this group"); $confirmAdd = _("Are you sure that you wish to add the selected Groups and Agents to Group"); $confirmRemove = _("Are you sure that you wish to remove the selected Groups and Agents from Group"); $destinationgroup_name = RequestContext::name("destinationgroup"); $operation_name = RequestContext::name("operation"); $actionURL = $harmoni->request->quickURL("agents", "add_to_group"); // Print out a Javascript function for submitting our groups choices $decendentGroups = $GLOBALS['decendent_groups_string']; $childGroups = $GLOBALS['child_groups_string']; $childAgents = $GLOBALS['child_agents_string']; print <<<END \t\t \t\t<script type='text/javascript'> \t\t//<![CDATA[ \t\t \t\t\t// Validate ancestory and submit to add checked to the group \t\t\tfunction submitCheckedToGroup ( destGroupId ) { \t\t\t\tvar f; \t\t\t\tvar form; \t\t\t\tfor (i = 0; i < document.forms.length; i++) { \t\t\t\t\tf = document.forms[i];\t\t\t \t\t\t\t\tif (f.id == 'memberform') { \t\t\t\t\t\tform = f; \t\t\t\t\t\tbreak; \t\t\t\t\t} \t\t\t\t} \t\t\t\t \t\t\t\tvar elements = form.elements; \t\t\t\tvar i; \t\t\t\tvar numToAdd = 0; \t\t\t\t\t\t \t\t\t\tfor (i = 0; i < elements.length; i++) { \t\t\t\t\tvar element = elements[i]; \t\t\t\t\t \t\t\t\t\tif (element.type == 'checkbox' && element.checked == true) { \t\t\t\t\t\t \t\t\t\t\t\tif (element.className == 'group') { \t\t\t\t\t\t\t// Check that the destination is not the new member \t\t\t\t\t\t\tif ( element.id == destGroupId ) { \t\t\t\t\t\t\t\talert ("{$cannotAddGroup} " + element.id + " {$toItsself}. {$deselecting}..."); \t\t\t\t\t\t\t\telement.checked = false; \t\t\t\t\t\t\t\tcontinue; \t\t\t\t\t\t\t} \t\t\t\t\t\t\t \t\t\t\t\t\t\t// Check that the destination is not a decendent of the new member \t\t\t\t\t\t\tif ( in_array(destGroupId, decendentGroups[element.id]) ) { \t\t\t\t\t\t\t\talert ("{$cannotAddGroup} " + element.id + " {$toOwnDesc}. {$deselecting}..."); \t\t\t\t\t\t\t\telement.checked = false; \t\t\t\t\t\t\t\tcontinue; \t\t\t\t\t\t\t} \t\t\t\t\t\t\t \t\t\t\t\t\t\t// Check that the new member is not already a child of the destination \t\t\t\t\t\t\tif ( in_array(element.id, childGroups[destGroupId]) ) { \t\t\t\t\t\t\t\talert ("{$groupString} " + element.id + " {$isAlreadyInGroup}. {$deselecting}..."); \t\t\t\t\t\t\t\telement.checked = false; \t\t\t\t\t\t\t\tcontinue; \t\t\t\t\t\t\t} \t\t\t\t\t\t} else { \t\t\t\t\t\t\t// Check that the new member is not already a child of the destination \t\t\t\t\t\t\tif ( in_array(element.id, childAgents[destGroupId]) ) { \t\t\t\t\t\t\t\talert ("{$agentString} " + element.id + " {$isAlreadyInGroup}. {$deselecting}..."); \t\t\t\t\t\t\t\telement.checked = false; \t\t\t\t\t\t\t\tcontinue; \t\t\t\t\t\t\t} \t\t\t\t\t\t} \t\t\t\t\t\t \t\t\t\t\t\t// If we haven't skipped back to the top of the loop yet, increment our ticker. \t\t\t\t\t\tnumToAdd++; \t\t\t\t\t} \t\t\t\t} \t\t\t\t \t\t\t\t \t\t\t\tif (numToAdd && confirm("{$confirmAdd} " + destGroupId + "?")) { \t\t\t\t\tform.destinationgroup.value = destGroupId; \t\t\t\t\tform.submit(); \t\t\t\t} \t\t\t} \t\t\t \t\t\t// Validate that the check are children and submit to remove them from the group \t\t\tfunction submitCheckedFromGroup ( destGroupId ) { \t\t\t\tvar f; \t\t\t\tvar form; \t\t\t\tfor (i = 0; i < document.forms.length; i++) { \t\t\t\t\tf = document.forms[i];\t\t\t \t\t\t\t\tif (f.id == 'memberform') { \t\t\t\t\t\tform = f; \t\t\t\t\t\tbreak; \t\t\t\t\t} \t\t\t\t}\t\t \t\t\t\t \t\t\t\tvar elements = form.elements; \t\t\t\tvar i; \t\t\t\tvar numToAdd = 0; \t\t\t\t\t\t\t\t \t\t\t\tfor (i = 0; i < elements.length; i++) { \t\t\t\t\tvar element = elements[i]; \t\t\t\t\t \t\t\t\t\tif (element.type == 'checkbox' && element.checked == true) { \t\t\t\t\t\t// Check that the destination is not the new member \t\t\t\t\t\tif ( element.id == destGroupId ) { \t\t\t\t\t\t\talert ("{$cannotRemoveGroup} " + element.id + " {$fromItsself}. {$deselecting}..."); \t\t\t\t\t\t\telement.checked = false; \t\t\t\t\t\t\tcontinue; \t\t\t\t\t\t} \t\t\t\t\t\t \t\t\t\t\t\tif (element.className == 'group') {\t\t\t\t\t \t\t\t\t\t\t\t// Check that the new member is not already a child of the destination \t\t\t\t\t\t\tif ( !in_array(element.id, childGroups[destGroupId]) ) { \t\t\t\t\t\t\t\talert ("{$groupString} " + element.id + " {$notInGroup}. {$deselecting}..."); \t\t\t\t\t\t\t\telement.checked = false; \t\t\t\t\t\t\t\tcontinue; \t\t\t\t\t\t\t} \t\t\t\t\t\t} else { \t\t\t\t\t\t\t// Check that the new member is not already a child of the destination \t\t\t\t\t\t\tif ( !in_array(element.id, childAgents[destGroupId]) ) { \t\t\t\t\t\t\t\talert ("{$agentString} " + element.id + " {$notInGroup}. {$deselecting}..."); \t\t\t\t\t\t\t\telement.checked = false; \t\t\t\t\t\t\t\tcontinue; \t\t\t\t\t\t\t} \t\t\t\t\t\t} \t\t\t\t\t\t \t\t\t\t\t\t// If we haven't skipped back to the top of the loop yet, increment our ticker. \t\t\t\t\t\tnumToAdd++; \t\t\t\t\t} \t\t\t\t} \t\t\t\t \t\t\t\tif (numToAdd && confirm("{$confirmRemove} " + destGroupId + "?")) { \t\t\t\t\tform.destinationgroup.value = destGroupId; \t\t\t\t\tform.action = form.action.replace('add_to_group','remove_from_group'); \t\t\t\t\tform.submit(); \t\t\t\t} \t\t\t} \t\t\t \t\t\tfunction in_array( aValue, anArray) { \t\t\t\tfor (i = 0; i < anArray.length; i++) { \t\t\t\t\tif (anArray[i] == aValue) \t\t\t\t\t\treturn true; \t\t\t\t} \t\t\t\t \t\t\t\treturn false; \t\t\t} \t\t\t \t\t\t// Decendent Groups \t\t\tvar decendentGroups = new Array (); {$decendentGroups} \t\t \t\t\t// Child Groups \t\t\tvar childGroups = new Array (); {$childGroups} \t\t\t \t\t\t// Child Agents \t\t\tvar childAgents = new Array (); {$childAgents} \t\t\t \t\t//]]> \t\t</script> \t\t \t\t<form id='memberform' method='post' action='{$actionURL}'> \t\t<input type='hidden' id='destinationgroup' name='{$destinationgroup_name}' value=''/> \t\t END; $pageRows->setPreHTML(ob_get_contents()); ob_end_clean(); $pageRows->setPostHTML("</form>"); // In order to preserve proper nesting on the HTML output, the checkboxes // are all in the pagerows layout instead of actionrows. $actionRows->add($pageRows, null, null, CENTER, CENTER); textdomain($defaultTextDomain); }
$txfName = new Textfield("name" . $rowId, $etagenRow->getNamedAttribute("name")); $btnRaumplan = new Button("uploadImage" . $rowId, "Raumplan hochladen"); $btnDelete = new Button("delete" . $rowId . "homecontrol_etagen", "entfernen"); $imgRaumplan = ""; if (isset($_REQUEST["uploadImage" . $rowId]) && $_REQUEST["uploadImage" . $rowId] == "Raumplan hochladen") { $hdnImg = new Hiddenfield("uploadImage" . $rowId, $_REQUEST["uploadImage" . $rowId]); $imgUploader = new ImageUploader("/pics/raumplan", "RP_", "homecontrol_etagen", "pic", $rowId, $hdnImg, $rowId . ".jpg"); $imgUploader->show(); $imgRaumplan = new Image(getDbValue("homecontrol_etagen", "pic", "id=" . $rowId)); } else { $imgRaumplan = new Image(getEtagenImagePath($rowId)); } $imgRaumplan->setGenerated(false); $imgRaumplan->setWidth(140); $cBtnRaumplan = new Container(); $cBtnRaumplan->add($btnRaumplan); $cBtnRaumplan->add(new Text("<br>JPG Datei mit den Maßen: 600x340", 1, false, false, false, false)); $r = $tblEtagen->createRow(); $r->setStyle("padding", "10px 5px"); $r->setVAlign("middle"); $r->setAttribute(0, $txfName); $r->setAttribute(1, $imgRaumplan); $r->setAttribute(2, $cBtnRaumplan); $r->setAttribute(3, $btnDelete); $tblEtagen->addRow($r); } $fEt = new Form(); $okBtn = new Button("DbTableUpdatehomecontrol_etagen", "Speichern"); $okBtn->setStyle("display", "none"); $fEt->add($okBtn); $fEt->add($tblEtagen);
/** * Execute the Action * * @param object Harmoni $harmoni * @return mixed * @access public * @since 4/25/05 */ function execute() { $harmoni = Harmoni::instance(); $xLayout = new XLayout(); $yLayout = new YLayout(); $mainScreen = new Container($yLayout, BLANK, 1); if (defined('SEGUE_SITE_HEADER')) { $this->siteMessage = $mainScreen->add(new Component(str_replace('[[SITE_OWNER_MESSAGE]]', '', SEGUE_SITE_HEADER), BLANK, 1), "100%", null, CENTER, TOP); } // :: login, links and commands $this->headRow = $mainScreen->add(new Container($xLayout, BLANK, 1), "100%", null, CENTER, TOP); $rightHeadColumn = $this->headRow->add(new Container($yLayout, BLANK, 1), null, null, CENTER, TOP); $rightHeadColumn->add($this->getLoginComponent(), null, null, RIGHT, TOP); // BACKGROUND $backgroundContainer = $mainScreen->add(new Container($yLayout, BLOCK, BACKGROUND_BLOCK)); // :: Top Row :: // The top row for the logo and status bar. $headRow = new Container($xLayout, HEADER, 1); // The logo $logo = new Component("\n<a href='" . MYPATH . "/'> <img src='" . LOGO_URL . "' \n\t\t\t\t\t\t\tstyle='border: 0px;' alt='" . _("Segue Logo'") . "/> </a>", BLANK, 1); $headRow->add($logo, null, null, LEFT, TOP); // Language Bar $harmoni->history->markReturnURL("polyphony/language/change"); $languageText = "\n<form action='" . $harmoni->request->quickURL("language", "change") . "' method='post'>"; $harmoni->request->startNamespace("polyphony"); $languageText .= "\n\t<div style='text-align: right'>\n\t<select style='font-size: 10px' name='" . $harmoni->request->getName("language") . "'>"; $harmoni->request->endNamespace(); $langLoc = Services::getService('Lang'); $currentCode = $langLoc->getLanguage(); $languages = $langLoc->getLanguages(); ksort($languages); foreach ($languages as $code => $language) { $languageText .= "\n\t\t<option value='" . $code . "'" . ($code == $currentCode ? " selected='selected'" : "") . ">"; $languageText .= $language . "</option>"; } $languageText .= "\n\t</select>"; $languageText .= "\n\t<input class='button small' value='Set language' type='submit' /> "; $languageText .= "\n\t</div>\n</form>"; $languageBar = new Component($languageText, BLANK, 1); $headRow->add($languageBar, null, null, LEFT, BOTTOM); // Pretty Login Box // $loginRow = new Container($yLayout, OTHER, 1); // $headRow->add($loginRow, null, null, RIGHT, TOP); // $loginRow->add($this->getLoginComponent(), null, null, RIGHT, TOP); //Add the headerRow to the backgroundContainer $backgroundContainer->add($headRow, "100%", null, LEFT, TOP); // :: Center Pane :: $centerPane = new Container($xLayout, BLANK, 1); $backgroundContainer->add($centerPane, "100%", null, LEFT, TOP); // Main menu $mainMenu = SegueMenuGenerator::generateMainMenu($harmoni->getCurrentAction()); // use the result from previous actions if ($harmoni->printedResult) { $contentDestination = new Container($yLayout, OTHER, 1); $centerPane->add($contentDestination, null, null, LEFT, TOP); $contentDestination->add(new Block($harmoni->printedResult, 1), null, null, TOP, CENTER); $harmoni->printedResult = ''; } else { $contentDestination = $centerPane; } // use the result from previous actions if (is_object($harmoni->result)) { $contentDestination->add($harmoni->result, null, null, CENTER, TOP); } else { if (is_string($harmoni->result)) { $contentDestination->add(new Block($harmoni->result, STANDARD_BLOCK), null, null, CENTER, TOP); } } $centerPane->add($mainMenu, "140px", null, LEFT, TOP); // Right Column // $rightColumn = $centerPane->add(new Container($yLayout, OTHER, 1), "140px", null, LEFT, TOP); // Basket // $basket = Basket::instance(); // $rightColumn->add($basket->getSmallBasketBlock(), "100%", null, LEFT, TOP); // if (preg_match("/^(collection|asset)\.browse$/", $harmoni->getCurrentAction())) // $rightColumn->add(AssetPrinter::getMultiEditOptionsBlock(), "100%", null, LEFT, TOP); // :: Footer :: $footer = new Container(new XLayout(), BLANK, 1); if ($harmoni->getData('help_topic')) { $helpLink = Help::link($harmoni->getData('help_topic')); } else { $helpLink = Help::link(); } $footer->add(new UnstyledBlock($helpLink), "50%", null, LEFT, BOTTOM); $footer->add(new UnstyledBlock(self::getVersionText()), "50%", null, RIGHT, BOTTOM); $mainScreen->add($footer, "100%", null, RIGHT, BOTTOM); if (defined('SEGUE_SITE_FOOTER')) { $mainScreen->add(new UnstyledBlock(SEGUE_SITE_FOOTER), "100%", null, CENTER, BOTTOM); } return $mainScreen; }
/** * Prepare and declare wui for overview */ function prepare_overview() { global $lang, $db, $sid, $specialID; // initializing $doc = doc(); $oid = value("oid", "NUMERIC"); if ($this->membersCount > $this->mincard && $this->developer) $this->deleteable = true; // process moving up and moving down.... if ($this->saction == "up" && ($this->editor || $this->developer)) { $this->move("UP"); } else if ($this->saction == "down" && ($this->editor || $this->developer)) { $this->move("DOWN"); } // process adding of items... if (($this->saction == "addci_".$this->clti) && ($this->editor || $this->developer)) { $this->createItems(); } // process delete ... if ($this->saction == "delete" && value("back") != $lang->get("no") && ($this->editor || $this->developer)) { $this->deleteItem(); } if ((($this->action == "editsingle" || (value("status") == "editsingle" && $this->action != $lang->get("back"))) && $this->editor) && ! $this->forceEditAll) { for ($i = 0; $i < count($this->members); $i++) { if ($this->eid == $this->members[$i][1]) { $this->add(new Hidden("status", "editsingle")); $this->add(new Hidden("eid", $this->eid)); $this->add(new Hidden("processing", "yes")); $this->getSingleEdit($this->members[$i][1]); } } } else { // draw the main view of the content-envelope if ($this->membersCount == 1 && $this->maxcard == 1 && $this->mincard == 1) { $labeltext = "<b>" . $this->name . "</b>"; // Draw the title bar $container = new HtmlContainer('box', 'headbox',2); // Edit-Button if ($this->editor && ! $this->editState) { $menuLabel = crLink($lang->get("edit"), $doc . "?sid=$sid&oid=$oid&action=editsingle&eid=" . $this->members[0][1], "box"); } else { $menuLabel = ' '; } $table = '<table width="100%" border="0" cellpadding="0" cellspacing="0">'; $table.= '<tr><td>'.$labeltext.'</td>'; $table.= '<td align="right"><b>'.$menuLabel.'</b></td></tr>'; $table.= '</table>'; $container->add($table); $this->add($container); $this->add(new Cell('', '', 2, 10, 10)); $this->getSingleEdit($this->members[0][1]); // processing of lists. } else { $labeltext = '<b>'.$this->name.'</b>'; $container2 = new HtmlContainer('box', 'headbox',2); if ($this->mincard != 1 || $this->maxcard != 1) { $labeltext .= " ($this->mincard - $this->maxcard)"; } $menuLabel = ""; // Add-Button if ($this->membersCount < $this->maxcard) { $toggleButton = new LinkButtonInline("toggle_create_".$this->clti, $lang->get("create_instances", "Create Instances"), "box", "button", "toggle('crinst_".$this->clti."')"); $menuLabel .= $toggleButton->draw(); } $table = '<table width="100%" border="0" cellpadding="0" cellspacing="0">'; $table.= '<tr><td>'.$labeltext.'</td>'; $table.= '<td align="right"><b>'.$menuLabel.'</b></td></tr>'; $table.= '</table>'; $container2->add($table); $this->add($container2); // Add Toggle-Field $container = new Container(3); $container->add(new Label("lbl", $lang->get("number_of_instances", "Please specify how many instances you want to create"), "standardlight", 3)); $container->add(new Input("number_of_instances".$this->clti, "1", "standardlight", 2, "", 100)); if ($this->editState) { $createInstancesJS = "javascript:if (confirm('".$lang->get("confirm_unsaved_changes", "Note: Unsaved changes will be lost if you proceed. If you have already edited something, you may cancel now and save your work. Proceed ?")."')) { document.form1.saction.value='addci_".$this->clti."';document.form1.submit(); };"; } else { $createInstancesJS = "javascript:document.form1.saction.value='addci_".$this->clti."';document.form1.submit();"; } $container->add(new ButtonInCell("create_".$this->clti, $lang->get("create_instances", "Create instances"), "standardlight navelement", "button", $createInstancesJS)); $this->add(new IDWrapper("crinst_".$this->clti, $container, "embedded", ' style="display:none;" ', 3)); $this->add(new Cell('clc', '', 2,10,10)); // draw list content $container0 = array(); for ($i = 0; $i < $this->membersCount; $i++) { $labeltext = $this->name . ' '.($i + 1) . "/" . $this->maxcard . " " . $this->members[$i][0] . ""; // Draw one instance $table = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'; $table.= '<tr><td width="200">'.$labeltext.'</td>'; $table.= '<td align="right">'; $menuLabel = ""; // Edit-Button if ($this->editState) { $menuLabel = crLink($lang->get("up"), "javascript:confirmAction('".$lang->get("confirm_unsaved_changes")."', '".$doc."?sid=$sid&oid=$oid&saction=up&eid=".$this->members[$i][1]."');", "box"); $menuLabel .= " ".crLink($lang->get("down"), "javascript:confirmAction('".$lang->get("confirm_unsaved_changes")."', '".$doc . "?sid=$sid&oid=$oid&saction=down&eid=" . $this->members[$i][1]."');", "box"); $menuLabel .= "  " . crLink($lang->get("delete"), "javascript:if (confirm('".$lang->get("confirm_unsaved_changes")."')) { confirmAction('".$lang->get("confirm_delete", "Do you really want to delete this item?")."', '". $doc . "?sid=$sid&oid=$oid&saction=delete&eid=" . $this->members[$i][1]."') } ;", "box"); } else { $menuLabel = crLink($lang->get("up"), $doc . "?sid=$sid&oid=$oid&saction=up&eid=" . $this->members[$i][1], "box"); $menuLabel .= " ".crLink($lang->get("down"), $doc . "?sid=$sid&oid=$oid&saction=down&eid=" . $this->members[$i][1], "box"); $menuLabel .= "  " . crLink($lang->get("delete"), "javascript:confirmAction('".$lang->get("confirm_delete", "Do you really want to delete this item?")."', '". $doc . "?sid=$sid&oid=$oid&saction=delete&eid=" . $this->members[$i][1]."');", "box"); } if ($this->editor && !$this->editState) $menuLabel .= " ".crLink($lang->get("edit"), $doc . "?sid=$sid&oid=$oid&action=editsingle&eid=" . $this->members[$i][1], "box"); $table.= $menuLabel; $table.= '</td></tr></table>'; $container0[$i] = new HTMLContainer('subbox', 'headbox2', 2); $container0[$i]->add($table); $this->add($container0[$i]); $this->getSingleEdit($this->members[$i][1]); $this->add(new Cell('clc', '', 2, 10,10)); } } } }
require_once "statsmenu.php"; require_once "widgets/statsdiagram.php"; require_once "widgets/statssummary.php"; require_once "widgets/print_button.php"; require_once "phpOpenTracker.php"; $print = value("print"); if ($print) { $menu = new WUIInterface(); } else { // setting up menu $menu = new StatsMenu(); $menu->addMenuEntry($lang->get("overview", "Overview"), "report.php"); $menu->addMenuEntry($lang->get("visitors", "Visitors"), "visitors.php"); $menu->addMenuEntry($lang->get("pages", "Pages"), "pages.php"); //$menu->addMenuEntry($lang->get("indiv_pages", "Individual pages"), "pages_individual.php"); $menu->addMenuEntry($lang->get("weekday", "Weekdays"), "weekdays.php"); $menu->addMenuEntry($lang->get("hour", "Hours"), "hours.php"); $menu->addMenuEntry($lang->get("referer", "Referer"), "referer.php"); $menu->addMenuEntry($lang->get("environment", "Environment"), "environment.php"); $menu->addMenuEntry($lang->get("paths", "Clickpaths"), "paths.php"); } $page = new page("Statistics"); // retrieving datainformations $statsinfo = new Statsinfo(); $form = new Container(3); $form->add(new AlignedLabel("lbl", '<h1>' . $statsinfo->getRangeTitle() . '</h1>', "center", "", 3)); if (!$print) { $form->add(new PrintButton()); } else { echo "<script language='JavaScript'>window.print();</script>"; }
/** * Returns a layout of the Results * * @param optional string $shouldPrintFunction The name of a function that will * return a boolean specifying whether or not to filter a given result. * If null, all results are printed. * @return object Layout A layout containing the results/page links * @access public * @date 8/5/04 */ function getLayout($shouldPrintFunction = NULL) { $defaultTextDomain = textdomain("polyphony"); $startingNumber = $this->getStartingNumber(); $yLayout = new YLayout(); $container = new Container($yLayout, OTHER, 1); $endingNumber = $startingNumber + $this->_pageSize - 1; $numItems = 0; $resultContainer = new Container($this->_resultLayout, OTHER, 1); if ($this->_iterator->hasNext()) { // trash the items before our starting number while ($this->_iterator->hasNext() && $numItems + 1 < $startingNumber) { $item = $this->_iterator->next(); // Ignore this if it should be filtered. if (is_null($shouldPrintFunction)) { $shouldPrint = true; } else { $shouldPrint = call_user_func_array($shouldPrintFunction, array($item)); } if ($shouldPrint) { $numItems++; } } // print up to $this->_pageSize items $pageItems = 0; while ($this->_iterator->hasNext() && $numItems < $endingNumber) { $item = $this->_iterator->next(); // Only Act if this item isn't to be filtered. if (is_null($shouldPrintFunction)) { $shouldPrint = true; } else { $shouldPrint = call_user_func_array($shouldPrintFunction, array($item)); } if ($shouldPrint) { $numItems++; $pageItems++; $itemArray = array($item); $params = array_merge($itemArray, $this->_callbackParams); // Add in our starting number to the end so that that it is accessible. $params[] = $numItems; $itemLayout = call_user_func_array($this->_callbackFunction, $params); $resultContainer->add($itemLayout, floor(100 / $this->_numColumns) . "%", "100%", CENTER, TOP); // If $itemLayout is not unset, since it is an object, // it may references to it made in add() will be changed. unset($itemLayout); } } //if we have a partially empty last row, add more empty layouts // to better-align the columns // while ($pageItems % $this->_numColumns != 0) { // $currentRow->addComponent(new Content(" ")); // $pageItems++; // } // find the count of items while ($this->_iterator->hasNext()) { $item = $this->_iterator->next(); // Ignore this if it should be filtered. if (is_null($shouldPrintFunction)) { $shouldPrint = true; } else { $shouldPrint = call_user_func_array($shouldPrintFunction, array($item)); } if ($shouldPrint) { $numItems++; } } } else { $text = new Block("<ul><li>" . _("No items are available.") . "</li></ul>", STANDARD_BLOCK); $resultContainer->add($text, null, null, CENTER, CENTER); } /********************************************************* * Page Links * ------------ * print out links to skip to more items if the number of Items is greater * than the number we display on the page *********************************************************/ if ($linksHTML = $this->getPageLinks($startingNumber, $numItems)) { // Add the links to the page $pageLinkBlock = new Block($linksHTML, BACKGROUND_BLOCK); $container->add($pageLinkBlock, "100%", null, CENTER, CENTER); $styleCollection = new StyleCollection("*.result_page_links", "result_page_links", "Result Page Links", "Links to other pages of results."); $styleCollection->addSP(new MarginTopSP("10px")); $pageLinkBlock->addStyle($styleCollection); } $container->add($resultContainer, "100%", null, LEFT, CENTER); if ($numItems > $this->_pageSize) { $container->add($pageLinkBlock, null, null, CENTER, CENTER); } $this->numItemsPrinted = $numItems; textdomain($defaultTextDomain); return $container; }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $defaultTextDomain = textdomain("polyphony"); $actionRows = $this->getActionRows(); $pageRows = new Container(new YLayout(), OTHER, 1); $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-agents"); $agentManager = Services::getService("Agent"); $idManager = Services::getService("Id"); $everyoneId = $idManager->getId("edu.middlebury.agents.everyone"); $usersId = $idManager->getId("edu.middlebury.agents.users"); /********************************************************* * the agent search form *********************************************************/ // Users header $actionRows->add(new Heading(_("Users"), 2), "100%", null, LEFT, CENTER); ob_start(); $self = $harmoni->request->quickURL(); $lastCriteria = $harmoni->request->get("search_criteria"); $search_criteria_name = RequestContext::name("search_criteria"); $search_type_name = RequestContext::name("search_type"); print _("Search For Users") . ": "; print <<<END \t\t<form action='{$self}' method='post'> \t\t\t<div> \t\t\t<input type='text' name='{$search_criteria_name}' value='{$lastCriteria}' /> \t\t\t<br /><select name='{$search_type_name}'> END; $searchTypes = $agentManager->getAgentSearchTypes(); while ($searchTypes->hasNext()) { $type = $searchTypes->next(); $typeString = htmlspecialchars($type->getDomain() . "::" . $type->getAuthority() . "::" . $type->getKeyword()); print "\n\t\t<option value='{$typeString}'"; if ($harmoni->request->get("search_type") == $typeString) { print " selected='selected'"; } print ">{$typeString}</option>"; } print "\n\t</select>"; print "\n\t<br /><input type='submit' value='" . _("Search") . "' />"; print "\n\t<a href='" . $harmoni->request->quickURL() . "'>"; print "<input type='button' value='" . _("Clear") . "' /></a>"; print "\n</div>\n</form>"; $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); /********************************************************* * the agent search results *********************************************************/ ob_start(); if (($search_criteria = $harmoni->request->get('search_criteria')) && ($search_type = $harmoni->request->get('search_type'))) { $typeParts = explode("::", @html_entity_decode($search_type, ENT_COMPAT, 'UTF-8')); $searchType = new HarmoniType($typeParts[0], $typeParts[1], $typeParts[2]); $agents = $agentManager->getAgentsBySearch($search_criteria, $searchType); print "search: " . $search_criteria; print <<<END \t\t \t\t \t\t<table> \t\t\t<tr> \t\t\t\t<td valign='top'> \t\t\t\t\t<div style=' \t\t\t\t\t\tborder: 1px solid #000; \t\t\t\t\t\twidth: 15px; \t\t\t\t\t\theight: 15px; \t\t\t\t\t\ttext-align: center; \t\t\t\t\t\ttext-decoration: none; \t\t\t\t\t\tfont-weight: bold; \t\t\t\t\t'> \t\t\t\t\t\t- \t\t\t\t\t</div> \t\t\t\t</td> \t\t\t\t<td> END; print "\n\t\t\t" . _("Search Results"); print <<<END \t\t\t\t</td> \t\t\t</tr> \t\t</table> \t\t<div style=' \t\t\tmargin-left: 13px; \t\t\tmargin-right: 0px; \t\t\tmargin-top:0px; \t\t\tpadding-left: 10px; \t\t\tborder-left: 1px solid #000; \t\t'> END; while ($agents->hasNext()) { $agent = $agents->next(); group_browseAction::printMember($agent); print "<br />"; } print "\n</div>"; $pageRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); } /********************************************************* * Groups *********************************************************/ $pageRows->add(new Heading(_("Groups"), 2), "100%", null, LEFT, CENTER); // Loop through all of the Root Groups $childGroupIds = array(); $groups = $agentManager->getGroupsBySearch($null = null, new Type("Agent & Group Search", "edu.middlebury.harmoni", "RootGroups")); while ($groups->hasNext()) { $group = $groups->next(); $groupId = $group->getId(); // Create a layout for this group using the GroupPrinter ob_start(); GroupPrinter::printGroup($group, $harmoni, 2, array($this, "printGroup"), array($this, "printMember")); $groupLayout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $pageRows->add($groupLayout, "100%", null, LEFT, CENTER); } // In order to preserve proper nesting on the HTML output, the checkboxes // are all in the pagerows layout instead of actionrows. $actionRows->add($pageRows, null, null, CENTER, CENTER); textdomain($defaultTextDomain); $harmoni->request->endNamespace(); }