本文整理汇总了PHP中Container::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::add方法的具体用法?PHP Container::add怎么用?PHP Container::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFormFieldContent
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);
}
示例2: setUp
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);
}
示例3: renderFormFieldContent
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);
}
示例4: add
/**
* 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;
}
示例5: renderFormFieldContent
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);
}
示例6: add
/**
* 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;
}
示例7: renderContent
/**
* @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);
}
}
示例8: add
/**
* 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;
}
示例9: printSlideShort
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";
//.........这里部分代码省略.........
示例10: TextAlignSP
$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();
示例11: printRepositoryShort
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;
}
示例12: getLayout
/**
* 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
//.........这里部分代码省略.........
示例13: buildContent
/**
* 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);
}
示例14: execute
/**
* 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: ") . $users . "\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>";
//.........这里部分代码省略.........
示例15: getTopicContents
/**
* 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)) {
//.........这里部分代码省略.........