/**
  * Visit a Site Navigation Block
  * 
  * @param object SiteNavBlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitSiteNavBlock(SiteNavBlockSiteComponent $siteComponent)
 {
     if (!$this->isAuthorizedToExport($siteComponent)) {
         throw new PermissionDeniedException();
     }
     $this->channel->insertBefore($this->getElement('title', $siteComponent->getDisplayName()), $this->endMeta);
     $this->channel->insertBefore($this->getElement('link', SiteDispatcher::getSitesUrlForSiteId($siteComponent->getId())), $this->endMeta);
     $this->channel->insertBefore($this->getElement('description', $siteComponent->getDescription()), $this->endMeta);
     $this->channel->insertBefore($this->getElement('pubDate', date('r')), $this->endMeta);
     $this->channel->insertBefore($this->getElement('language', 'en'), $this->endMeta);
     $this->channel->insertBefore($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:wxr_version', '1.1'), $this->endMeta);
     $this->channel->insertBefore($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:base_site_url', MYURL), $this->endMeta);
     $this->channel->insertBefore($this->getElementNS("http://wordpress.org/export/1.1/", 'wp:base_blog_url', SiteDispatcher::getSitesUrlForSiteId($siteComponent->getId())), $this->endMeta);
     $siteComponent->getOrganizer()->acceptVisitor($this);
 }
示例#2
0
 /**
  * 
  * 
  * @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(' &raquo; ', $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;
 }
 /**
  * Execute this action.
  * 
  * @return void
  * @access public
  * @since 08/11/08
  */
 public function execute()
 {
     $this->start();
     try {
         if (!$this->isAuthorizedToExecute()) {
             throw new PermissionDeniedException("You are not authorized to load course listing.");
         }
         $semester = RequestContext::value('semester');
         $year = strval(RequestContext::value('year'));
         $courseMgr = SegueCourseManager::instance();
         if (!isset($GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS']) || !is_array($GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS']) || !count($GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS'])) {
             throw new ConfigurationErrorException("\$GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS'] must be an array to enable couse-listing.");
         }
         $semesters = $GLOBALS['SEGUE_COURSE_SITE_LISTING_SEMESTERS'];
         if (!in_array($semester, $semesters)) {
             throw new InvalidArgumentException("'semester' must be one of " . implode(", ", $semesters) . ".");
         }
         if (!preg_match('/^(19|20)[0-9]{2,}$/', $year)) {
             throw new InvalidArgumentException("Year '{$year}' must be four digits.");
         }
         if (!defined('SEGUE_COURSE_SITE_LISTING_MATCH_CALLBACK')) {
             throw new ConfigurationErrorException("SEGUE_COURSE_SITE_LISTING_MATCH_CALLBACK must be defined to enable couse-listing.");
         }
         $func = SEGUE_COURSE_SITE_LISTING_MATCH_CALLBACK;
         $slotMgr = SlotManager::instance();
         $agentMgr = Services::getService('Agent');
         $slots = $slotMgr->getAllSlots();
         while ($slots->hasNext()) {
             $slot = $slots->next();
             if ($slot->siteExists() && $func($slot->getShortname(), $semester, $year)) {
                 print "\n\t<site id=\"" . $slot->getSiteId()->getIdString() . "\">";
                 print "\n\t\t<shortname>" . $slot->getShortname() . "</shortname>";
                 $siteAsset = $slot->getSiteAsset();
                 print "\n\t\t<displayName>" . strip_tags($siteAsset->getDisplayName()) . "</displayName>";
                 print "\n\t\t<description>" . strip_tags($siteAsset->getDescription()) . "</description>";
                 print "\n\t\t<url>" . SiteDispatcher::getSitesUrlForSiteId($slot->getSiteId()->getIdString()) . "</url>";
                 foreach ($slot->getOwners() as $ownerId) {
                     $owner = $agentMgr->getAgent($ownerId);
                     print "\n\t\t<owner id=\"" . $ownerId->getIdString() . "\">";
                     print "\n\t\t<displayName>" . $owner->getDisplayName() . "</displayName>";
                     $propertiesIterator = $owner->getProperties();
                     while ($propertiesIterator->hasNext()) {
                         $properties = $propertiesIterator->next();
                         $keys = $properties->getKeys();
                         while ($keys->hasNext()) {
                             $key = $keys->next();
                             print "\n\t\t<property key=\"" . $key . "\">";
                             print "<![CDATA[" . $properties->getProperty($key) . "]]>";
                             print "</property>";
                         }
                     }
                     print "\n\t\t</owner>";
                 }
                 print "\n\t</site>";
             }
         }
     } catch (Exception $e) {
         $this->error($e->getMessage(), get_class($e));
     }
     $this->end();
 }