Beispiel #1
0
 /**
  * Answer a links back to the main Segue pages
  * 
  * @return object GUIComponent
  * @access public
  * @since 1/12/07
  */
 function getCommandsComponent()
 {
     $harmoni = Harmoni::instance();
     ob_start();
     print "<div class='commands'>";
     print "<a href='";
     print SiteDispatcher::quickURL('view', 'html');
     print "' title='" . _("Go to View-Mode") . "'>";
     print _("view") . "</a>";
     print " | <a href='";
     print SiteDispatcher::quickURL('ui2', 'editview');
     print "' title='" . _("Go to Edit-Mode") . "'>";
     print _("edit") . "</a>";
     print " | " . _("header/footer");
     print " | <a href='";
     print SiteDispatcher::quickURL('ui2', 'arrangeview');
     print "' title='" . _("Go to Arrange-Mode") . "'>";
     print _("arrange") . "</a>";
     // Add permissions button
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     // Rather than checking the entire site, we will just check the current node.
     // This forces users who are not site-wide admins to browse to the place where
     // they are administrators in order to see the permissions button, but
     // cuts load-times for non-admins on a given large site from 35s to 1.4s.
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_authorizations"), SiteDispatcher::getCurrentNode()->getQualifierId())) {
         $url = SiteDispatcher::quickURL("roles", "choose_agent", array("node" => SiteDispatcher::getCurrentNodeId(), "returnModule" => $harmoni->request->getRequestedModule(), "returnAction" => $harmoni->request->getRequestedAction()));
         print " | \n\t<a href='#' onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>";
         print _("roles") . "</a>";
     }
     print " | " . self::getUiSwitchForm();
     print "</div>";
     $ret = new Component(ob_get_clean(), BLANK, 2);
     return $ret;
 }
 /**
  * Answer the plugin content for a block
  * 
  * @param object BlockSiteComponent $block
  * @return string
  * @access public
  * @since 1/7/08
  */
 function getPluginContent($block)
 {
     if ($block->getId() != $this->_node->getId()) {
         return parent::getPluginContent($block);
     }
     $harmoni = Harmoni::instance();
     $pluginManager = Services::getService('PluginManager');
     $plugin = $pluginManager->getPlugin($block->getAsset());
     ob_start();
     print "\n<form action='" . SiteDispatcher::quickURL('versioning', 'compare_versions', array('node' => SiteDispatcher::getCurrentNodeId())) . "' method='post'>";
     print "\n\t<div style='float: right;'>";
     print "\n\t<input type='submit' value='" . _("Compare Selected Revisions &raquo;") . "'";
     if (count($plugin->getVersions()) <= 1) {
         print " disabled='disabled'";
     }
     print "/>";
     print "\n\t</div>";
     print "\n\t<div style='float: left;'>\n\t\t<a href='" . $harmoni->history->getReturnURL('view_history_' . $block->getId()) . "'>";
     print "\n\t\t\t<input type='button' value='" . _("&laquo; Go Back") . "'/>\n\t\t</a>\n\t</div>";
     print "\n\t\t<input type='hidden' name='module' value='versioning'/>";
     print "\n\t<input type='hidden' name='action' value='compare_versions'/>";
     print "\n\t<input type='hidden' name='node' value='" . SiteDispatcher::getCurrentNodeId() . "'/>";
     print $this->getVersionTable($plugin);
     print "\n</form>";
     print $this->getVersionChoiceJS();
     return ob_get_clean();
 }
 /**
  * Process changes to the site components. This is the method that the various
  * actions that modify the site should override.
  * 
  * @param object SiteDirector $director
  * @return void
  * @access public
  * @since 4/14/06
  */
 function processChanges(SiteDirector $director)
 {
     $component = $director->getSiteComponentById(SiteDispatcher::getCurrentNodeId());
     // Do not allow delete of the root menu.
     if (method_exists($component, 'isRootMenu')) {
         if ($component->isRootMenu()) {
             $this->returnToCallerPage();
             exit;
         }
     }
     $this->findSafeReturnNode($director, $component);
     $organizer = $component->getParentComponent();
     if ($organizer) {
         $organizer->detatchSubcomponent($component);
     }
     $rootSiteComponent = $director->getRootSiteComponent(SiteDispatcher::getCurrentNodeId());
     // If we are deleting the site unhitch it from the slot
     if ($rootSiteComponent->getId() == SiteDispatcher::getCurrentNodeId()) {
         $slotMgr = SlotManager::instance();
         $idMgr = Services::getService("Id");
         try {
             $slot = $slotMgr->getSlotBySiteId($idMgr->getId(SiteDispatcher::getCurrentNodeId()));
             $slot->deleteSiteId();
         } catch (Exception $e) {
         }
     }
     $director->deleteSiteComponent($component);
 }
 /**
  * Answer the plugin content for a block
  * 
  * @param object BlockSiteComponent $block
  * @return string
  * @access public
  * @since 1/7/08
  */
 function getPluginContent($block)
 {
     if ($block->getId() != $this->_node->getId()) {
         return parent::getPluginContent($block);
     }
     $harmoni = Harmoni::instance();
     $pluginManager = Services::getService('PluginManager');
     $plugin = $pluginManager->getPlugin($block->getAsset());
     if (!strlen(RequestContext::value('late_rev'))) {
         return _("No version specified");
     }
     $lateVersion = $plugin->getVersion(RequestContext::value('late_rev'));
     if (RequestContext::value('early_rev')) {
         $earlyVersion = $plugin->getVersion(RequestContext::value('early_rev'));
     } else {
         $earlyVersion = $lateVersion->getPrecedingVersion();
     }
     ob_start();
     // 		print "\n<h3 class='diff_title'>"._("Selected Versions")."</h3>";
     print "\n<a href='";
     $browseHistoryUrl = SiteDispatcher::quickURL($harmoni->request->getRequestedModule(), 'view_history', array('node' => SiteDispatcher::getCurrentNodeId(), 'early_rev' => RequestContext::value('early_rev'), 'late_rev' => RequestContext::value('late_rev')));
     print $browseHistoryUrl;
     $harmoni->history->markReturnUrl('revert_' . $block->getId(), $browseHistoryUrl);
     print "'>";
     print "\n<input type='button' value='" . _('&laquo; Choose Versions') . "'/>";
     print "</a>";
     print "\n<table class='version_compare'>";
     print "\n\t<thead>";
     print "\n\t\t<tr>";
     print "\n\t\t\t<th>";
     print $this->getHeadingBlock($earlyVersion);
     print "\n\t\t\t</th>";
     print "\n\t\t\t<th>";
     print $this->getHeadingBlock($lateVersion);
     print "\n\t\t\t</th>";
     print "\n\t\t</tr>";
     print "\n\t</thead>";
     print "\n\t<tbody>";
     print "\n\t\t<tr>";
     print "\n\t\t\t<td>";
     print $earlyVersion->getMarkup();
     print "\n\t\t\t</td>";
     print "\n\t\t\t<td>";
     print $lateVersion->getMarkup();
     print "\n\t\t\t</td>";
     print "\n\t\t</tr>";
     print "\n\t</tbody>";
     print "\n</table>";
     print "\n<h3 class='diff_title'>" . _("Changes") . "</h3>";
     print $plugin->getVersionDiff($earlyVersion->getVersionXml(), $lateVersion->getVersionXml());
     return ob_get_clean();
 }
 /**
  * Process changes to the site components. This is the method that the various
  * actions that modify the site should override.
  * 
  * @param object SiteDirector $director
  * @return void
  * @access public
  * @since 4/14/06
  */
 function processChanges(SiteDirector $director)
 {
     $component = $director->getSiteComponentById(SiteDispatcher::getCurrentNodeId());
     $component->acceptVisitor(new ModifySettingsSiteVisitor());
     /*********************************************************
      * Log the event
      *********************************************************/
     if (Services::serviceRunning("Logging")) {
         $loggingManager = Services::getService("Logging");
         $log = $loggingManager->getLogForWriting("Segue");
         $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
         $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Component Modified", $component->getComponentClass() . " modified.");
         $item->addNodeId($component->getQualifierId());
         $site = $component->getDirector()->getRootSiteComponent($component->getId());
         if (!$component->getQualifierId()->isEqual($site->getQualifierId())) {
             $item->addNodeId($site->getQualifierId());
         }
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
 }
 /**
  * Answer the form for Adding new components
  * 
  * @param string $organizerId
  * @param integer $cellIndex
  * @param array $allowed Which component Types to allow addition of: segue::edu.middlebury::Block, segue::edu.middlebury::NavBlock
  * @return string The form HTML
  * @access public
  * @since 4/14/06
  */
 function getAddFormHTML($organizerId, $cellIndex, $allowed, $isMenu = FALSE)
 {
     ob_start();
     $harmoni = Harmoni::instance();
     print "\n\t<a style='text-align: center; display: inline;'";
     print " onclick='this.style.display=\"none\"; this.nextSibling.style.display=\"block\";'";
     print ">";
     if ($isMenu) {
         print "\n\t\t\t" . _("+ Page...");
     } else {
         print "\n\t\t\t" . _("+ Content");
     }
     print "\n\t</a>";
     print "<form action='";
     print $harmoni->request->quickURL('ui2', 'addComponent', array('returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->_action));
     print "' method='post' ";
     print " style='display: none' class='ui2_add_form'>";
     print "\n\t<input type='hidden' name='" . RequestContext::name('organizerId') . "' value='" . $organizerId . "'/>";
     if (!is_null($cellIndex)) {
         print "\n\t<input type='hidden' name='" . RequestContext::name('cellIndex') . "' value='" . $cellIndex . "'/>";
     }
     //print "\n\t<div class='block2Content' style='text-align: center;'";
     print "\n\t\t<select class='ui2_page_select' name='" . RequestContext::name('componentType') . "'>";
     $inCat = false;
     foreach ($allowed as $type) {
         if (is_string($type)) {
             if ($inCat) {
                 print "\n\t\t\t</optgroup>";
             }
             $inCat = true;
             print "\n\t\t\t<optgroup label='{$type}'>";
         } else {
             $this->printTypeOption($type);
         }
     }
     if ($inCat) {
         print "\n\t\t\t</optgroup>";
     }
     print "\n\t\t</select> ";
     print "\n\t\t<div style='white-space: nowrap;'>" . _("Title: ");
     if ($isMenu) {
         print "(" . Help::link('Adding Pages and Sections') . ")";
         print "\n\t\t\t<br/><input class='ui2_title_field_page' name='" . RequestContext::name('displayName') . "' type='text' size='20'/>";
     } else {
         print Help::link('Adding Content');
         print "\n\t\t\t<br/><input class='ui2_title_field_content' name='" . RequestContext::name('displayName') . "' type='text' size='20'/>";
     }
     print "\n\t\t</div>";
     print "\n\t\t<div style='white-space: nowrap; margin: 5px;'>";
     print "\n\t\t\t<input type='button' value='" . _('Create') . "'";
     print " onclick='";
     print "var hasTitle = false; ";
     print "var regex = /[^\\s\\n\\t]+/; ";
     print "for (var i = 0; i < this.form.elements.length; i++) { ";
     print "var elem = this.form.elements[i]; ";
     print "if (elem.name == \"" . RequestContext::name('displayName') . "\") { ";
     print "if (elem.value.match(regex)) { ";
     print "hasTitle = true;";
     print "}";
     print "}";
     print "}";
     print "if (!hasTitle) { ";
     print "alert(\"" . _("A title is required") . "\");";
     print "} else { ";
     print "this.form.submit();";
     print "}";
     print "' />";
     print "\n\t\t\t<input type='button' ";
     print "onclick='this.parentNode.parentNode.style.display=\"none\"; this.parentNode.parentNode.previousSibling.style.display=\"inline\";'";
     print " value='" . _("Cancel") . "'/>";
     print "\n\t\t</div>";
     print "</form>";
     return ob_get_clean();
 }
Beispiel #7
0
 /**
  * Answer the nodeId
  * 
  * @return string
  * @access public
  * @since 7/30/07
  */
 function getNodeId()
 {
     return SiteDispatcher::getCurrentNodeId();
 }
Beispiel #8
0
 /**
  * Create the wizard
  * 
  * @return object Wizard
  * @access public
  * @since 11/14/07
  */
 public function createWizard()
 {
     // Instantiate the wizard, then add our steps.
     $wizard = SingleStepWizard::withText("<div>\n" . "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n" . "<tr>\n" . "<td align='left' width='50%'>\n" . "[[_cancel]]\n" . "</td>\n" . "<td align='right' width='50%'>\n" . "</td></tr></table>" . "</div>\n" . "<hr/>\n" . "<div>\n" . "[[_steps]]" . "</div>\n");
     $wizard->_returnModule = RequestContext::value('returnModule');
     $wizard->_returnAction = RequestContext::value('returnAction');
     $cancelButton = $wizard->getChild('_cancel');
     $cancelButton->setLabel(_("Close"));
     $step = $wizard->addStep("agents", new WizardStep());
     ob_start();
     print "\n<h2>" . _("Roles") . "</h2>";
     print "\n<p>";
     print _("Choose a user or group to edit roles for.");
     print "\n</p>\n";
     $agentMgr = Services::getService("Agent");
     $idMgr = Services::getService("Id");
     $harmoni = Harmoni::instance();
     $roleMgr = SegueRoleManager::instance();
     $everyoneId = $idMgr->getId("edu.middlebury.agents.everyone");
     $instituteId = $idMgr->getId("edu.middlebury.institute");
     $membersId = $this->getSite()->getMembersGroup()->getId();
     $agents = array();
     $agents[] = $agentMgr->getGroup($everyoneId);
     $agents[] = $agentMgr->getGroup($instituteId);
     $agents[] = $agentMgr->getGroup($membersId);
     $agentIdsWithRoles = $roleMgr->getAgentsWithRoleAtLeast($roleMgr->getRole('reader'), $this->getSiteId(), true);
     foreach ($agentIdsWithRoles as $id) {
         if (!$id->isEqual($everyoneId) && !$id->isEqual($instituteId) && !$id->isEqual($membersId)) {
             // We ran into a case where roles weren't clearing when an agent
             // was deleted, log this issue and skip rather than crashing the
             // choose agent screen.
             try {
                 $agents[] = $agentMgr->getAgentOrGroup($id);
             } catch (UnknownIdException $e) {
                 HarmoniErrorHandler::logException($e, 'Segue');
             }
         }
     }
     if (count($agents)) {
         print "\n<table width='100%' class='search_results' cellspacing='0'>";
         $i = 0;
         foreach ($agents as $agent) {
             print "\n\t<tr class='search_result_item'>";
             print "\n\t\t<td class='color{$i}'>";
             print "\n\t\t\t<a href='#' onclick=\"AgentInfoPanel.run('" . addslashes($agent->getId()->getIdString()) . "', '" . addslashes($agent->getDisplayName()) . "', this); return false;\">";
             print $agent->getDisplayName();
             print "</a>";
             // print out site members
             if ($agent->getId()->isEqual($membersId)) {
                 $harmoni->request->forget('returnAction');
                 $harmoni->request->forget('returnModule');
                 $harmoni->request->forget('agent');
                 $url = SiteDispatcher::quickURL('agent', 'modify_members');
                 $harmoni->request->passthrough('returnAction');
                 $harmoni->request->passthrough('returnModule');
                 $harmoni->request->passthrough('agent');
                 print "\n\t\t\t <button onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>" . _("Add/Remove Members") . "</button>";
                 print " (" . Help::link('Site-Members') . ")";
                 print "\n<br/>";
                 print "\n<span style='font-size: smaller'>";
                 print _("This is a custom group of users that are associated with this site. Users and groups can manually be made site-members or users can self-register using the 'Join Site' plugin if it is enabled.");
                 print "</span>";
                 $membersGroup = $this->getSite()->getMembersGroup();
                 $subGroups = $membersGroup->getGroups(true);
                 print "\n<table width='100%' class='search_results' cellspacing='0'>";
                 while ($subGroups->hasNext()) {
                     print "\n\t<tr class='search_result_item'>";
                     print "\n\t\t<td>";
                     print "&nbsp;&nbsp;" . $subGroups->next()->getDisplayName();
                     print "\n\t\t</td></tr>";
                 }
                 $members = $membersGroup->getMembers(false);
                 while ($members->hasNext()) {
                     print "\n\t<tr class='search_result_item'>";
                     print "\n\t\t<td>";
                     print "&nbsp;&nbsp;" . $members->next()->getDisplayName();
                     print "\n\t\t</td></tr>";
                 }
                 print "\n</table><br/>";
             }
             print "\n\t\t</td>";
             print "\n\t\t<td valign='top' class='color{$i}' style='text-align: right; white-space: nowrap;'>";
             $url = SiteDispatcher::quickURL('roles', 'modify', array('node' => SiteDispatcher::getCurrentNodeId(), 'agent' => $agent->getId()->getIdString()));
             print "\n\t\t\t<button onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>" . _("Modify Roles &raquo;") . "</button>";
             print "\n\t\t</td>";
             print "\n\t</tr>";
             $i = intval(!$i);
         }
         print "\n</table>";
     }
     $property = $step->addComponent("search", new WSearchField());
     $property->setSearchSource(new AgentSearchSource());
     print "\n<div style='margin-top: 20px; border-top: 1px solid; padding: 5px;'>";
     print "\n<h3>" . _("Assign roles to other users/groups") . "</h3>";
     print _("Search for other users/groups.  Once found you will be able to assign roles to these other users/groups.  To assign roles to students in a class, type in the course code (e.g. span0101a-f08)") . "<br/><br/>";
     print _("User/group name: ") . " [[search]]";
     print "</div>";
     $step->setContent(ob_get_clean());
     return $wizard;
 }
 /**
  * Check Authorizations
  * 
  * @param optional Id $assetId The Id of the asset the thread is attached to.
  * @return boolean
  * @access public
  * @since 11/8/07
  */
 public function canViewComments(Id $assetId = null)
 {
     // Check Authorizations
     $authZ = Services::getService('AuthZ');
     $idManager = Services::getService("Id");
     if (is_null($assetId)) {
         $harmoni = Harmoni::instance();
         $harmoni->request->startNamespace(null);
         $assetId = $idManager->getId(SiteDispatcher::getCurrentNodeId());
         $harmoni->request->endNamespace();
     }
     if ($authZ->isUserAuthorized($idManager->getId('edu.middlebury.authorization.view_comments'), $assetId)) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Answer the Url for this component id.
  *
  * Note: this is clunky that this object has to know about harmoni and 
  * what action to target. Maybe rewrite...
  * 
  * @param string $id
  * @return string
  * @access public
  * @since 4/4/06
  */
 protected function getUrlForComponent($id)
 {
     $harmoni = Harmoni::instance();
     if ($harmoni->request->getRequestedModule() == 'versioning') {
         $origUrl = $harmoni->history->getReturnURL('view_history_' . SiteDispatcher::getCurrentNodeId());
         $module = $harmoni->request->getModuleFromUrl($origUrl);
         if ($module == false) {
             $module = 'ui1';
         }
         $action = $harmoni->request->getActionFromUrl($origUrl);
         if ($action == false) {
             $action = 'view';
         }
     } else {
         $module = $harmoni->request->getRequestedModule();
         $action = $harmoni->request->getRequestedAction();
     }
     return SiteDispatcher::quickURL($module, $action, array("node" => $id));
 }
 /**
  * Print the reorder form
  * 
  * @param object SiteComponent $siteComponent
  * @return void
  * @access public
  * @since 9/20/07
  */
 public function printReorderForm(SiteComponent $siteComponent)
 {
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $harmoni = Harmoni::instance();
     $parent = $siteComponent->getParentComponent();
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $parent->getQualifierId())) {
         $url = $harmoni->request->quickURL($this->module, 'reorder', array('returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->action));
         $harmoni->request->startNamespace('reorder');
         $organizer = $siteComponent->getParentComponent();
         $myCell = $organizer->getCellForSubcomponent($siteComponent);
         print "\n\t\t\t\t\t<form class='ui1_controls reorder_form_" . $parent->getId() . "' action='" . $url . "' method='post' style='display: none'>";
         print "\n\t<input type='hidden' name='" . RequestContext::name('node') . "' value='" . $siteComponent->getId() . "' />";
         print "\n\t<select name='" . RequestContext::name('position') . "' onchange='this.form.submit();'>";
         for ($i = 0; $i < $organizer->getTotalNumberOfCells(); $i++) {
             print "\n\t\t<option value='{$i}'";
             if ($myCell == $i) {
                 print " selected='selected'";
             }
             print ">" . ($i + 1) . "</option>";
         }
         print "\n\t</select>";
         print "\n\t<input type='button' onclick=\"";
         print "hideReorder('" . $parent->getId() . "'); ";
         print "\" value='" . _("Cancel") . "'/>";
         print "\n\t\t\t\t\t</form>";
         $harmoni->request->endNamespace();
     }
 }
Beispiel #12
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     /*********************************************************
      * Split sites based on their location-category
      *********************************************************/
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     try {
         $slot = $rootSiteComponent->getSlot();
         // Mark the site as viewed
         Segue_AccessLog::instance()->touch($slot->getShortname());
     } catch (UnknownIdException $e) {
         // No slot for the site....
     }
     $authZ = Services::getService("AuthZ");
     $recordManager = Services::getService("RecordManager");
     //
     // Begin Optimizations
     //
     // The code below queues up authorizations for all visible nodes,
     // as well as pre-fetches all of the RecordSets that have data
     // specific to the visible nodes.
     $visibleComponents = SiteDispatcher::getSiteDirector()->getVisibleComponents(SiteDispatcher::getCurrentNodeId());
     $preCacheIds = array();
     foreach ($visibleComponents as $component) {
         $id = $component->getQualifierId();
         $authZ->getIsAuthorizedCache()->queueId($id);
         $preCacheIds[] = $id->getIdString();
     }
     $recordManager->preCacheRecordsFromRecordSetIDs($preCacheIds);
     //
     // End Optimizations
     //
     $this->mainScreen = new Container(new YLayout(), BLOCK, BACKGROUND_BLOCK);
     $this->addHead($this->mainScreen);
     CommentManager::instance()->disableCommenting();
     CommentManager::instance()->disableSorting();
     $this->addSiteContent($this->mainScreen);
     return $this->mainScreen;
 }
 /**
  * Answer controls for MenuOrganizer SiteComponents
  * 
  * @param SiteComponent $siteComponent
  * @return string
  * @access public
  * @since 4/17/06
  */
 public function visitMenuOrganizer(MenuOrganizerSiteComponent $siteComponent)
 {
     // 		$this->controlsStart($siteComponent);
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $harmoni = Harmoni::instance();
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) {
         $url = SiteDispatcher::quickURL('ui1', 'editMenu', array('node' => $siteComponent->getId(), 'returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->action));
         ob_start();
         print "\n\t\t\t\t<div style='text-align: center;'>";
         print "\n\t\t\t\t\t<a href='" . $url . "'>";
         print _("[ menu display options ]");
         print "</a>";
         print "\n\t\t\t\t</div>";
         $controls = ob_get_clean();
     } else {
         $controls = '';
     }
     return $controls;
     // 		return $this->controlsEnd($siteComponent);
 }
 /**
  * Print theme controls
  * 
  * @param SiteComponent $siteComponent
  * @return void
  * @access public
  * @since 5/20/08
  */
 function printTheme($siteComponent)
 {
     print "\n\t\t\t\t<tr><td class='ui2_settingborder'>";
     print "\n\t\t\t\t<div class='ui2_settingtitle'>";
     print "\n\t\t\t\t\t" . _('Theme: ') . "\n\t\t\t\t</div>";
     print "\n\t\t\t\t<div style='font-size: smaller; text-align: left;'>";
     print _("Current Theme") . ": ";
     $theme = $siteComponent->getTheme();
     print $theme->getDisplayName();
     print "\n\t\t\t\t</div>";
     print "\n\t\t\t\t</td><td class='ui2_settingborder' colspan='2'>";
     print "\n\t\t\t\t\t<button class='ui2_field'  name='" . RequestContext::name('theme') . "'";
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $harmoni = Harmoni::instance();
     if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) {
         print " readonly='readonly'";
     } else {
         $url = SiteDispatcher::quickURL('ui1', 'editSite', array('node' => $siteComponent->getId(), 'returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnModule' => $this->module, 'returnAction' => $this->action, 'wizardSkipToStep' => "theme"));
         print " onclick='";
         print "window.location = \"" . $url . "\".urlDecodeAmpersands(); return false;";
         print "'";
     }
     print ">";
     print _("Choose Theme");
     print "</button>";
     print "\n\t\t\t\t</td></tr>";
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) {
         print "\n\t\t\t\t<tr><td class='ui2_settingborder'>";
         print "\n\t\t\t\t<div class='ui2_settingtitle'>";
         print "\n\t\t\t\t\t" . _('Theme Options: ') . "\n\t\t\t\t</div>";
         print "\n\t\t\t\t<div style='font-size: smaller; text-align: left;'>";
         print _("Change the colors, fonts, etcetera, for this theme.") . "";
         print "\n\t\t\t\t</div>";
         print "\n\t\t\t\t</td><td class='ui2_settingborder' colspan='2'>";
         print "\n\t\t\t\t\t<button class='ui2_field'  name='" . RequestContext::name('theme') . "'";
         $authZ = Services::getService("AuthZ");
         $idManager = Services::getService("Id");
         $harmoni = Harmoni::instance();
         $url = SiteDispatcher::quickURL('ui1', 'theme_options', array('node' => $siteComponent->getId(), 'returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnModule' => $this->module, 'returnAction' => $this->action));
         print " onclick='";
         print "window.location = \"" . $url . "\".urlDecodeAmpersands(); return false;";
         print "'";
         print ">";
         print _("Change Theme Options");
         print "</button>";
         print "\n\t\t\t\t</td></tr>";
     }
 }
 /**
  * Delete any stored data needed as part of the delete process
  * 
  * @return void
  * @access public
  * @since 10/16/06
  */
 function deleteAndCleanUpData()
 {
     // Delete our group.
     $group = $this->getMembersGroup();
     $members = $group->getMembers(FALSE);
     while ($members->hasNext()) {
         $group->remove($members->next());
     }
     $childGroups = $group->getGroups(FALSE);
     while ($childGroups->hasNext()) {
         $group->remove($childGroups->next());
     }
     $agentMgr = Services::getService('Agent');
     $agentMgr->deleteGroup($group->getId());
     // Unhitch from our slot.
     $slotMgr = SlotManager::instance();
     $idMgr = Services::getService("Id");
     try {
         $slot = $slotMgr->getSlotBySiteId($idMgr->getId(SiteDispatcher::getCurrentNodeId()));
         $slot->deleteSiteId();
     } catch (Exception $e) {
     }
     parent::deleteAndCleanUpData();
 }
 /**
  * Answer the markup for a set of search results
  * 
  * @param string $fieldName
  * @param array $results An array of WSearchResult objects
  * @return string
  * @access public
  * @since 11/27/07
  */
 public function getResultsMarkup($fieldName, $results)
 {
     $harmoni = Harmoni::instance();
     if (count($results)) {
         print "\n\t<table id='" . RequestContext::name($fieldName) . "_output' class='search_results' cellspacing='0'>";
         $colorKey = 0;
         foreach ($results as $result) {
             print "\n\t\t<tr class='search_result_item '>";
             print "\n\t\t\t<td class='color" . $colorKey . "'>";
             print $result->getMarkup();
             print "\n\t\t\t</td>";
             print "\n\t\t\t<td class='action_button color" . $colorKey . "'>";
             $url = $harmoni->request->quickURL('roles', 'modify', array('node' => SiteDispatcher::getCurrentNodeId(), 'agent' => $result->getIdString()));
             print "\n\t\t\t<button onclick='window.location = \"{$url}\".urlDecodeAmpersands(); return false;'>" . _("Modify Roles &raquo;") . "</button>";
             print "\n\t\t\t</td>";
             print "\n\t\t</tr>";
             $colorKey = intval(!$colorKey);
         }
         print "\n\t</table>";
     }
 }
Beispiel #17
0
 /**
  * Answer the HTML string for the visitor registration link if available, null otherwise.
  * 
  * @return string
  * @access public
  * @since 2/23/09
  */
 public function getVisitorRegistrationLink()
 {
     $harmoni = Harmoni::instance();
     $authN = Services::getService("AuthN");
     // Visitor Registration Link
     $authTypes = $authN->getAuthenticationTypes();
     $hasVisitorType = false;
     $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors");
     while ($authTypes->hasNext()) {
         $authType = $authTypes->next();
         if ($visitorType->isEqual($authType)) {
             $hasVisitorType = true;
             break;
         }
     }
     if ($hasVisitorType && !$authN->isUserAuthenticatedWithAnyType()) {
         $harmoni->request->startNamespace(null);
         $url = $harmoni->request->mkURL("user", "visitor_reg");
         // Add return info to the visitor registration url
         $visitorReturnModules = array('view', 'ui1', 'ui2', 'versioning');
         if (in_array($harmoni->request->getRequestedModule(), $visitorReturnModules)) {
             $url->setValue('returnModule', $harmoni->request->getRequestedModule());
             $url->setValue('returnAction', $harmoni->request->getRequestedAction());
             $url->setValue('returnKey', 'node');
             $url->setValue('returnValue', SiteDispatcher::getCurrentNodeId());
         }
         $harmoni->request->endNamespace();
         return "\n\t<a href='" . $url->write() . "'>" . _("Visitor Registration") . "</a>";
     }
     return null;
 }
 /**
  * Answer the form for Adding new components
  * 
  * @param string $organizerId
  * @param integer $cellIndex
  * @param array $allowed Which components to allow addition of: MenuOrganizer, FlowOrganizer, FixedOrganizer
  * @return string The form HTML
  * @access public
  * @since 4/14/06
  */
 function getInsertFormHTML($director, $organizerId, $cellIndex, $allowed)
 {
     ob_start();
     $harmoni = Harmoni::instance();
     print "\n<form action='";
     print $harmoni->request->quickURL('ui2', 'addComponent', array('returnNode' => SiteDispatcher::getCurrentNodeId(), 'returnAction' => $this->_action));
     print "' method='post'>";
     print "\n\t<input type='hidden' name='" . RequestContext::name('organizerId') . "' value='" . $organizerId . "'/>";
     print "\n\t<input type='hidden' name='" . RequestContext::name('cellIndex') . "' value='" . $cellIndex . "'/>";
     print "\n\t<div style='text-decoration: underline; cursor: pointer; white-space: nowrap;'";
     print "onclick='this.style.display=\"none\"; this.nextSibling.style.display=\"block\";'";
     print ">";
     print "\n\t\t" . _("Insert New...");
     print "\n\t</div>";
     print "<div style='display: none'>";
     // Selection of our menu target
     if (in_array('MenuOrganizer', $allowed)) {
         $menuTarget = $this->getDefaultMenuTargetId($director, $organizerId, $cellIndex);
         if (!$menuTarget) {
             $menuTarget = 'NewCellInNavOrg';
         }
         // 			print "<br/>".$menuTarget;
         print "\n\t\t\t<input type='hidden' name='" . RequestContext::name('menuTarget') . "' value='" . $menuTarget . "'/>";
     }
     print "\n\t\t<select name='" . RequestContext::name('componentType') . "'>";
     foreach ($allowed as $type) {
         print "\n\t\t\t<option value='" . $type->asString() . "'>";
         if (isset($this->_classNames[$type->getKeyword()])) {
             print $this->_classNames[$type->getKeyword()];
         } else {
             print $type->getKeyword();
         }
         print "</option>";
     }
     print "\n\t\t</select>";
     print "\n\t\t<div style=''>";
     print "\n\t\t\t<input type='submit' value='" . _('Create') . "'/>";
     print "\n\t\t\t<input type='button' ";
     print "onclick='this.parentNode.parentNode.style.display=\"none\"; this.parentNode.parentNode.previousSibling.style.display=\"block\";'";
     print " value='" . _("Cancel") . "'/>";
     print "\n\t\t</div>";
     print "\n\t</div>";
     print "</form>";
     return ob_get_clean();
 }
Beispiel #19
0
 /**
  * Print Node info html
  * 
  * @param object SiteComponent $siteComponent
  * @return void
  * @access protected
  * @since 3/17/08
  */
 protected function printNodeInfo(SiteComponent $siteComponent, $inMenu = false)
 {
     $harmoni = Harmoni::instance();
     print $this->getTabs() . "\t";
     if ($siteComponent->getId() == SiteDispatcher::getCurrentNodeId()) {
         print "<div class='info current'>";
     } else {
         print "<div class='info'>";
     }
     print $this->getTabs() . "\t\t";
     print "<div class='title'>";
     $nodeUrl = SiteDispatcher::quickURL('view', 'html', array('node' => $siteComponent->getId()));
     if (!$inMenu) {
         print "<a href='" . $nodeUrl . "' ";
         print ' onclick="';
         print "if (window.opener) { ";
         print "window.opener.location = this.href; ";
         print "return false; ";
         print '}" ';
         print " title='" . _("View this node") . "'>";
     }
     print $siteComponent->getDisplayName();
     if (!$inMenu) {
         print "</a>";
     }
     print "</div>";
     $nodeDescription = HtmlString::withValue($siteComponent->getDescription());
     $nodeDescription->stripTagsAndTrim(5);
     print $this->getTabs() . "\t\t";
     print "<div class='description'>" . $nodeDescription->stripTagsAndTrim(20) . "</div>";
     print $this->getTabs() . "\t";
     print "</div>";
 }