/** * Execute the action * * @return mixed * @access public */ public function execute() { try { if (!$this->isAuthorizedToExecute()) { throw new PermissionDeniedException(); } ob_start(); $harmoni = Harmoni::instance(); $component = SiteDispatcher::getCurrentNode(); $site = SiteDispatcher::getCurrentRootNode(); $slotMgr = SlotManager::instance(); $slot = $slotMgr->getSlotBySiteId($site->getId()); $exportDirname = $slot->getShortname() . "-html"; $exportDir = DATAPORT_TMP_DIR . "/" . $exportDirname; $archivePath = DATAPORT_TMP_DIR . '/' . $exportDirname . ".zip"; if (!file_exists($exportDir)) { header('HTTP/1.1 404 Not Found'); print "Not Found"; exit; } header("Content-Type: text/html;"); $this->printStatus($exportDir); } catch (PermissionDeniedException $e) { header('HTTP/1.1 403 Forbidden'); header("Content-Type: text/plain;"); print _("You are not authorized to monitor the export this component."); exit; } exit; }
/** * Anser the site * * @return object SiteNavBlockSiteComponent * @access protected * @since 2/5/09 */ protected function getSite() { if (!isset($this->_site)) { $this->_site = SiteDispatcher::getCurrentRootNode(); } return $this->_site; }
/** * Answer the current site id for this source. * * @return string $id * @access private * @since 5/15/08 */ private function getSiteId() { if (isset($this->siteId)) { return $this->siteId; } else { return SiteDispatcher::getCurrentRootNode()->getId(); } }
/** * Answer the items with given tag in a given Segue site by everyone * * @return object TagIterator * @access public * @since 11/8/06 */ function getItems() { $tag = $this->getTag(); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); $visitor = new TaggableItemVisitor(); $items = $rootSiteComponent->acceptVisitor($visitor); $tagIds = $tag->getItemsInList($items); return $tag->getItemsWithIdsInSystem($tagIds, "segue"); }
/** * Execute the action * * @return mixed * @access public */ public function execute() { ob_start(); $harmoni = Harmoni::instance(); $component = SiteDispatcher::getCurrentNode(); $site = SiteDispatcher::getCurrentRootNode(); $slotMgr = SlotManager::instance(); $slot = $slotMgr->getSlotBySiteId($site->getId()); $exportDirname = $slot->getShortname() . "-files"; $exportDir = DATAPORT_TMP_DIR . "/" . $exportDirname; mkdir($exportDir); $archivePath = DATAPORT_TMP_DIR . '/' . $exportDirname . ".zip"; try { // Do the export $visitor = new FileExportSiteVisitor($exportDir); $component->acceptVisitor($visitor); $archive = new ZipArchive(); if ($archive->open($archivePath, ZIPARCHIVE::CREATE) !== TRUE) { throw new Exception("Could not create zip archive."); } foreach (scandir($exportDir) as $file) { if (!is_dir($exportDir . '/' . $file)) { $archive->addFile($exportDir . '/' . $file, $exportDirname . '/' . $file); } } $archive->close(); // Remove the directory $this->deleteRecursive($exportDir); if ($output = ob_get_clean()) { print $output; throw new Exeception("Errors occurred, output wasn't clean."); } header("Content-Type: application/zip;"); header('Content-Disposition: attachment; filename="' . basename($archivePath) . '"'); header('Content-Length: ' . filesize($archivePath)); print file_get_contents($archivePath); // Clean up the archive unlink($archivePath); } catch (PermissionDeniedException $e) { $this->deleteRecursive($exportDir); if (file_exists($archivePath)) { unlink($archivePath); } return new Block(_("You are not authorized to export this component."), ALERT_BLOCK); } catch (Exception $e) { $this->deleteRecursive($exportDir); if (file_exists($archivePath)) { unlink($archivePath); } throw $e; } error_reporting(0); exit; }
/** * Answer the items with given tag in a given Segue site * * @return object TagIterator * @access public * @since 11/8/06 */ function getItems() { $tag = $this->getTag(); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); $tagManager = Services::getService("Tagging"); $agentId = $tagManager->getCurrentUserId(); $visitor = new TaggableItemVisitor(); $items = $rootSiteComponent->acceptVisitor($visitor); $tagIds = $tag->getItemsInList($items); return $tag->getItemsForAgentInListinSystem($tagIds, $agentId, "segue"); }
/** * Answer all the tags on this site by everyone * * @return object TagIterator * @access public * @since 11/8/06 */ function getTags() { $harmoni = Harmoni::instance(); $tagManager = Services::getService("Tagging"); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); $visitor = new TaggableItemVisitor(); $items = $rootSiteComponent->acceptVisitor($visitor); SiteDispatcher::passthroughContext(); $tags = $tagManager->getTagsForItems($items, TAG_SORT_ALFA, $this->getNumTags()); return $tags; }
/** * Answer the items with given tag in a Segue site by a given user * * @return object TagIterator * @access public * @since 11/8/06 */ function getItems() { $harmoni = Harmoni::instance(); $tag = $this->getTag(); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); $tagManager = Services::getService("Tagging"); $agentId = $tagManager->getCurrentUserId(); $visitor = new TaggableItemVisitor(); $items = $rootSiteComponent->acceptVisitor($visitor); $tagIds = $tag->getItemsInList($items); //printpre($tagIds); return $tag->getItemsForAgent($agentId); }
/** * Answer all the tags on this site by given user * * @return object TagIterator * @access public * @since 11/8/06 */ function getTags() { $harmoni = Harmoni::instance(); $tag = $this->getTag(); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); $agentManager = Services::getService("Agent"); $tagManager = Services::getService("Tagging"); $agentId = $tagManager->getCurrentUserId(); $visitor = new TaggableItemVisitor(); $items = $rootSiteComponent->acceptVisitor($visitor); SiteDispatcher::passthroughContext(); $tags = $tagManager->getTagsForItemsByAgent($items, $agentId); return $tags; }
/** * Execute the action * * @return object * @access public * @since 1/18/07 */ function execute() { UI2::addBrowserWarning(); $allwrapper = parent::execute(); $mainScreen = $this->mainScreen; // Add controls bar and border $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), SiteDispatcher::getCurrentRootNode()->getQualifierId())) { $visitor = $this->getSiteVisitor(); $controlsHTML = $visitor->getBarPreHTML('#090', SiteDispatcher::getCurrentRootNode()) . $visitor->getControlsHTML(SiteDispatcher::getCurrentRootNode(), "<em>" . _("Site") . "</em>", SiteDispatcher::getCurrentRootNode()->acceptVisitor($visitor->_controlsVisitor), '#090', '#9F9', '#6C6', 0, '0px'); $mainScreen->setPreHTML($controlsHTML . $mainScreen->getPreHTML($null = null)); $mainScreen->setPostHTML($visitor->getBarPostHTML()); } return $allwrapper; }
/** * Execute the action * * @return mixed * @access public * @since 1/17/08 */ public function execute() { $harmoni = Harmoni::instance(); $component = SiteDispatcher::getCurrentNode(); $site = SiteDispatcher::getCurrentRootNode(); $slotMgr = SlotManager::instance(); $slot = $slotMgr->getSlotBySiteId($site->getId()); $exportDir = DATAPORT_TMP_DIR . "/" . $slot->getShortname() . "-" . str_replace(':', '_', DateAndTime::now()->asString()); mkdir($exportDir); try { // Do the export $visitor = new DomExportSiteVisitor($exportDir); $component->acceptVisitor($visitor); // Validate the result // printpre(htmlentities($visitor->doc->saveXMLWithWhitespace())); // $tmp = new Harmoni_DomDocument; // $tmp->loadXML($visitor->doc->saveXMLWithWhitespace()); // $tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd"); $visitor->doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd"); // Write out the XML $visitor->doc->saveWithWhitespace($exportDir . "/site.xml"); $archive = new Archive_Tar($exportDir . ".tar.gz"); $archive->createModify($exportDir, '', DATAPORT_TMP_DIR); // Remove the directory $this->deleteRecursive($exportDir); header("Content-Type: application/x-gzip;"); header('Content-Disposition: attachment; filename="' . basename($exportDir . ".tar.gz") . '"'); print file_get_contents($exportDir . ".tar.gz"); // Clean up the archive unlink($exportDir . ".tar.gz"); } catch (PermissionDeniedException $e) { $this->deleteRecursive($exportDir); if (file_exists($exportDir . ".tar.gz")) { unlink($exportDir . ".tar.gz"); } return new Block(_("You are not authorized to export this component."), ALERT_BLOCK); } catch (Exception $e) { $this->deleteRecursive($exportDir); if (file_exists($exportDir . ".tar.gz")) { unlink($exportDir . ".tar.gz"); } throw $e; } error_reporting(0); exit; }
/** * Execute the action * * @return mixed * @access public * @since 1/17/08 */ public function execute() { $harmoni = Harmoni::instance(); $component = SiteDispatcher::getCurrentNode(); $site = SiteDispatcher::getCurrentRootNode(); $slotMgr = SlotManager::instance(); $slot = $slotMgr->getSlotBySiteId($site->getId()); $this->setupTextTemplates(); $pluginManager = Services::getService('PluginManager'); $audioType = new Type('SeguePlugins', 'edu.middlebury', 'AudioPlayer'); $pluginManager->_loadPlugins(); // Ensure that the original plugin is loaded. require_once MYDIR . '/plugins-dist/SeguePlugins/edu.middlebury/AudioPlayer/WordpressExportAudioPlayerPlugin.class.php'; $pluginManager->setPluginClass($audioType, 'WordpressExportAudioPlayerPlugin'); $textType = new Type('SeguePlugins', 'edu.middlebury', 'TextBlock'); require_once MYDIR . '/plugins-dist/SeguePlugins/edu.middlebury/TextBlock/WordpressExportTextBlockPlugin.class.php'; $pluginManager->setPluginClass($textType, 'WordpressExportTextBlockPlugin'); try { // Do the export $visitor = new WordpressExportSiteVisitor(); $component->acceptVisitor($visitor); // Validate the result // printpre(htmlentities($visitor->doc->saveXMLWithWhitespace())); // $tmp = new Harmoni_DomDocument; // $tmp->loadXML($visitor->doc->saveXMLWithWhitespace()); // $tmp->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd"); // $visitor->doc->schemaValidateWithException(MYDIR."/doc/raw/dtds/segue2-site.xsd"); header("Content-Type: text/xml"); header('Content-Disposition: attachment; filename="' . basename($slot->getShortname() . ".xml") . '"'); $xml = $visitor->doc->saveXMLWithWhitespace(); header('Content-Length: ' . strlen($xml)); print $xml; } catch (PermissionDeniedException $e) { return new Block(_("You are not authorized to export this component."), ALERT_BLOCK); } catch (Exception $e) { throw $e; } error_reporting(0); exit; }
/** * Execute the action * * @return object * @access public * @since 1/18/07 */ function execute() { $allwrapper = parent::execute(); $mainScreen = $this->mainScreen; // Add permissions button $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $siteId = SiteDispatcher::getCurrentRootNode()->getQualifierId(); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); ob_start(); $harmoni = Harmoni::instance(); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteId)) { $url = SiteDispatcher::quickURL("ui1", "editSite", array("node" => $siteId->getIdString(), "returnNode" => SiteDispatcher::getCurrentNodeId(), "returnAction" => $harmoni->request->getRequestedAction())); print "\n\t<button onclick='window.location = \"{$url}\".urlDecodeAmpersands();'>"; print _("Edit Site Options") . "</button>"; } if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteId)) { $url = SiteDispatcher::quickURL("ui1", "theme_options", array("node" => $siteId->getIdString(), "returnNode" => SiteDispatcher::getCurrentNodeId(), "returnAction" => $harmoni->request->getRequestedAction())); print "\n\t<button onclick='window.location = \"{$url}\".urlDecodeAmpersands();'>"; print _("Theme Options") . "</button>"; } // 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<button onclick='window.location = \"{$url}\".urlDecodeAmpersands();'>"; print _("Roles") . "</button>"; } if (strlen(ob_get_contents())) { $mainScreen->add(new UnstyledBlock("\n<div style='text-align: right;'>" . ob_get_contents() . "\n</div>"), $rootSiteComponent->getWidth(), null, CENTER, BOTTOM); } ob_end_clean(); return $allwrapper; }
/** * Execute the action * * @return void * @access public * @since 7/10/08 */ public function execute() { if (!$this->isAuthorizedToExecute()) { throw new PermissionDeniedException(); } $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $hierarchyManager = Services::getService('Hierarchy'); $site = SiteDispatcher::getCurrentRootNode(); $hierarchy = $hierarchyManager->getHierarchy($idManager->getId("edu.middlebury.authorization.hierarchy")); $infoList = $hierarchy->traverse($idManager->getId($site->getId()), Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_DOWN, Hierarchy::TRAVERSE_LEVELS_ALL); $status = new StatusStars(str_replace('%1', $infoList->count(), _("Rebuilding Implicit AZs on %1 nodes."))); $status->initializeStatistics($infoList->count()); $azCache = $authZ->getAuthorizationCache(); while ($infoList->hasNext()) { $info = $infoList->next(); $node = $hierarchy->getNode($info->getNodeId()); // printpre("Rebuilding implicit AZs for ".$node->getId()." '".$node->getDisplayName()."'. Ancestors:"); // printpre($node->getAncestorIds()); $azCache->createHierarchyImplictAZs($node, $node->getAncestorIds()); $status->updateStatistics(); } printpre("Done."); /********************************************************* * 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", "Error", "Errors that did not halt execution"); $item = new AgentNodeEntryItem("Rebuilt Implict AZs", "Hierarchy-Implicit AZs for site '" . $site->getDisplayName() . "' were rebuilt manually."); $item->addNodeId($site->getQualifierId()); $log->appendLogWithTypes($item, $formatType, $priorityType); } }
/** * Build the content for this action * * @return void * @access public * @since 3/14/08 */ public function buildContent() { $actionRows = $this->getActionRows(); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); // print out related links $actionRows->add(new Block($this->getRelatedLinks($rootSiteComponent), STANDARD_BLOCK)); ob_start(); print "\n<script type='text/javascript'>\n// <![CDATA[\n\n\tfunction toggleSiteMapChildren(node) {\n\t\tfor (var i = 0; i < node.parentNode.childNodes.length; i++) {\n\t\t\tvar child = node.parentNode.childNodes[i];\n\t\t\tif (child.className == 'children') {\n\t\t\t\tif (child.style.display != 'none') {\n\t\t\t\t\tchild.style.display = 'none';\n\t\t\t\t\tnode.innerHTML = '+';\n\t\t\t\t} else {\n\t\t\t\t\tchild.style.display = 'block';\n\t\t\t\t\tnode.innerHTML = '-';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfunction expandAllSiteMapChildren(node) {\n\t\tvar divElements = node.getElementsByTagName('div');\n\t\tfor (var i = 0; i < divElements.length; i++) {\n\t\t\tvar div = divElements[i];\n\t\t\tif (div.className == 'children') {\n\t\t\t\tdiv.style.display = 'block';\n\t\t\t}\n\t\t\t\n\t\t\tif (div.className == 'expand') {\n\t\t\t\tdiv.innerHTML = '-';\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfunction collapseAllSiteMapChildren(node) {\n\t\tvar divElements = node.getElementsByTagName('div');\n\t\tfor (var i = 0; i < divElements.length; i++) {\n\t\t\tvar div = divElements[i];\n\t\t\tif (div.className == 'children') {\n\t\t\t\tdiv.style.display = 'none';\n\t\t\t}\n\t\t\t\n\t\t\tif (div.className == 'expand') {\n\t\t\t\tdiv.innerHTML = '+';\n\t\t\t}\n\t\t}\n\t}\n\n\n// ]]>\n</script>\n\t\t\n\t\t"; print "\n<div class='siteMap'>"; print "\n\t<button onclick='expandAllSiteMapChildren(document.get_element_by_id(\"site_children\"));'>" . _("Expand All") . "</button>"; print "\n\t<button onclick='collapseAllSiteMapChildren(document.get_element_by_id(\"site_children\"));'>" . _("Collapse All") . "</button>"; $this->isHeaderFooterVisitor = new isHeaderFooterSiteVisitor(); // $currentNode = $this->getNodeId(); //printpre ($currentNode); $rootSiteComponent->acceptVisitor($this); print "\n</div>"; $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK)); }
/** * Visit a Fixed Organizer * * @param object FixedOrganizerSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitFixedOrganizer(FixedOrganizerSiteComponent $siteComponent) { $numCells = $siteComponent->getTotalNumberOfCells(); $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); $isHeaderFooterVisitor = new IsHeaderFooterSiteVisitor(); for ($i = 0; $i < $numCells; $i++) { $child = $siteComponent->getSubcomponentForCell($i); if (is_object($child)) { // don't include in feed if header and footer blocks if (!$child->acceptVisitor($isHeaderFooterVisitor)) { $child->acceptVisitor($this); } } } }
/** * Answer the site id. * * @return object Id * @access protected * @since 11/14/07 */ protected function getSite() { return SiteDispatcher::getCurrentRootNode(); }
/** * Print out the site admins in an iterator * * @param object $siteAdmins * @return string * @access protected * @since 2/18/09 */ protected function printSiteAdminsIterator($siteAdmins) { $admins = array(); while ($siteAdmins->hasNext()) { $admin = $siteAdmins->next(); $adminId = $admin->getAgentId(); $participant_view = new Participation_View(SiteDispatcher::getCurrentRootNode()); if (!in_array($adminId, $admins)) { $admins[] = $participant_view->getParticipant($adminId->getIdString()); } } return $this->printParticipants($admins); }
/** * answer an action filter form * * @return string XHTML markup * @access public * @since 2/5/09 */ public function getActionDisplayOptions() { $node = SiteDispatcher::getCurrentNode(); $view = new Participation_View($node); if (RequestContext::value('sort')) { $this->_sort = RequestContext::value('sort'); } else { $this->_sort = 'timestamp'; } if (RequestContext::value('participant')) { $this->_participant = RequestContext::value('participant'); } else { $this->_participant = 'all'; } if (RequestContext::value('role')) { $this->_role = RequestContext::value('role'); } else { $this->_role = 'all'; } if (RequestContext::value('display')) { $this->_display = RequestContext::value('display'); } else { $this->_display = '20'; } if (RequestContext::value('direction')) { if (RequestContext::value('direction') == 'DESC') { $this->_direction = SORT_DESC; $this->_reorder = 'ASC'; $this->_reorderFlag = '^'; } else { $this->_direction = SORT_ASC; $this->_reorder = 'DESC'; $this->_reorderFlag = 'v'; } } else { $this->_direction = SORT_DESC; $this->_reorder = 'ASC'; $this->_reorderFlag = '^'; } $participants = $view->getParticipants(); ob_start(); print "<form action='"; print SiteDispatcher::quickURL('participation', 'actions', array('node' => $node->getId(), 'sort' => 'timestamp', 'direction' => 'DESC')); print "' method='post'>"; $idMgr = Services::getService('Id'); $azMgr = Services::getService('AuthZ'); $rootNode = SiteDispatcher::getCurrentRootNode(); if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $rootNode->getQualifierId()) == TRUE) { print "<a href = '"; print SiteDispatcher::quickURL('participation', 'summary', array('node' => $node->getId(), 'sort' => 'name', 'direction' => 'ASC')); print "'>" . _("Summary") . "</a> | "; } // get a list of all participants print "\n\t<select name='participant'"; print " onchange='this.form.submit();'"; print ">"; print "\n\t\t<option value='all'>" . _("All Participants") . "</option>"; foreach ($participants as $aParticipant) { print "\n\t\t<option value='" . $aParticipant->getId() . "'"; if (RequestContext::value('participant') == $aParticipant->getId()) { print " selected='selected'"; } print ">"; print $aParticipant->getDisplayName(); print "</option>"; } print "\n\t</select> "; // get list of actions print "\n\t<select name='role'"; print " onchange='this.form.submit();'"; print ">"; print "\n\t\t<option value='all'>" . _("All Roles") . "</option>"; $roleValues = array('commenter', 'author', 'editor'); foreach ($roleValues as $roleValue) { print "\n\t\t<option value='" . $roleValue . "'"; if (RequestContext::value('role') == $roleValue) { print " selected='selected'"; } print ">"; print $roleValue; print "</option>"; } print "\n\t</select>"; // print out number of rows to display print "\n\tDisplay: <select name='display'"; print " onchange='this.form.submit();'"; print ">"; $displayValues = array(20, 5, 10, 25, 30); foreach ($displayValues as $displayValue) { print "\n\t\t<option value='" . $displayValue . "'"; if (RequestContext::value('display') == $displayValue) { print " selected='selected'"; } print ">"; print $displayValue; print "</option>"; } print "\n\t</select>"; print "\n\t</form>"; return ob_get_clean(); }
/** * Execute the action * * @return mixed * @access public */ public function execute() { try { if (!$this->isAuthorizedToExecute()) { throw new PermissionDeniedException(); } ob_start(); $harmoni = Harmoni::instance(); $component = SiteDispatcher::getCurrentNode(); $site = SiteDispatcher::getCurrentRootNode(); $slotMgr = SlotManager::instance(); $slot = $slotMgr->getSlotBySiteId($site->getId()); $exportDirname = $slot->getShortname() . "-html"; $exportDir = DATAPORT_TMP_DIR . "/" . $exportDirname; $archivePath = DATAPORT_TMP_DIR . '/' . $exportDirname . ".zip"; if (file_exists($exportDir)) { $changedTime = filemtime($exportDir); // If the export is more than an hour old, trash it. if ($changedTime < time() - 3600) { $this->deleteRecursive($exportDir); } else { throw new AlreadyExportingException("Another export of this site is in progress (data written last on " . date('r', $changedTime) . "). Please wait. <br/><br/>The other export will be force-quit if it does not finish in " . round((3600 - (time() - $changedTime)) / 60) . " minutes."); } } mkdir($exportDir); // Do the export $urlParts = parse_url(MYURL); $urlPrefix = rtrim($urlParts['path'], '/'); $include = array($urlPrefix . '/gui2', $urlPrefix . '/images', $urlPrefix . '/javascript', $urlPrefix . '/polyphony', $urlPrefix . '/repository', $urlPrefix . '/plugin_manager', $urlPrefix . '/rss', $urlPrefix . '/dataport/html/site/' . $slot->getShortname()); if (defined('WGET_PATH')) { $wget = WGET_PATH; } else { $wget = 'wget'; } $command = $wget . " -r --page-requisites --html-extension --convert-links --no-directories -e robots=off " . "--directory-prefix=" . escapeshellarg($exportDir . '/content') . " " . "--include=" . escapeshellarg(implode(',', $include)) . " " . "--header=" . escapeshellarg("Cookie: " . session_name() . "=" . session_id()) . " " . escapeshellarg(SiteDispatcher::quickURL('dataport', 'html', array('site' => $slot->getShortname()))); // throw new Exception($command); // Close the session. If we don't, a lock on the session file will // cause the request initiated via wget to hang. session_write_close(); exec($command, $output, $exitCode); if ($exitCode) { throw new Exception('Wget Failed. ' . implode("\n", $output)); } // Copy the main HTML file to index.html copy($exportDir . '/content/' . $slot->getShortname() . '.html', $exportDir . '/content/index.html'); // Copy the index.html file up a level to make it easy to find file_put_contents($exportDir . '/index.html', preg_replace('/(src|href)=([\'"])([^\'"\\/]+)([\'"])/', '$1=$2content/$3$4', file_get_contents($exportDir . '/content/index.html'))); // Zip up the result $archive = new ZipArchive(); if ($archive->open($archivePath, ZIPARCHIVE::CREATE) !== TRUE) { throw new Exception("Could not create zip archive."); } $this->addDirectoryToZip($archive, $exportDir, $exportDirname); $archive->close(); // Remove the directory $this->deleteRecursive($exportDir); if ($output = ob_get_clean()) { print $output; throw new Exception("Errors occurred, output wasn't clean."); } header("Content-Type: application/zip;"); header('Content-Disposition: attachment; filename="' . basename($archivePath) . '"'); header('Content-Length: ' . filesize($archivePath)); print file_get_contents($archivePath); // Clean up the archive unlink($archivePath); } catch (PermissionDeniedException $e) { $this->deleteRecursive($exportDir); if (file_exists($archivePath)) { unlink($archivePath); } return new Block(_("You are not authorized to export this component."), ALERT_BLOCK); } catch (AlreadyExportingException $e) { return new Block($e->getMessage(), ALERT_BLOCK); } catch (Exception $e) { $this->deleteRecursive($exportDir); if (file_exists($archivePath)) { unlink($archivePath); } throw $e; } error_reporting(0); exit; }
/** * Answer a menu for the tagging system * * @return string * @access public * @since 11/8/06 */ public function getTagsMenu() { $harmoni = Harmoni::instance(); $tagManager = Services::getService("Tagging"); ob_start(); print "<div class='tagging_header'>" . _("Other Tags") . "</div>"; print "<div class='tagging_options'>"; print _("...added by "); // all tags on node by you if (!$this->isAnonymous()) { if ($harmoni->getCurrentAction() != 'tags.usernode') { $url = SiteDispatcher::quickURL('tags', 'usernode', array('agent_id' => $tagManager->getCurrentUserIdString(), 'tag' => RequestContext::value('tag'))); print "<a href='" . $url . "'>" . str_replace('%1', RequestContext::value('tag'), _("you")) . "</a> / "; } else { if ($harmoni->getCurrentAction() == 'tags.usernode') { print "<strong>" . _("you") . "</strong> / "; } else { print _("you / "); } } } // all tags on node by everyone if ($harmoni->getCurrentAction() != 'tags.node') { $url = SiteDispatcher::quickURL('tags', 'node', array('agent_id' => $tagManager->getCurrentUserIdString(), 'tag' => RequestContext::value('tag'))); print "<a href='" . $url . "'>" . str_replace('%1', RequestContext::value('tag'), _("everyone")) . "</a>"; } else { if ($harmoni->getCurrentAction() == 'tags.node') { print "<strong>" . _("everyone") . "</strong>"; } else { print _("everyone"); } } $node = SiteDispatcher::getCurrentNode(); $context = str_replace('%2', $node->acceptVisitor(new BreadCrumbsVisitor($node)), _("%2")); print _(" within: ") . $context; print "</div>"; print "<div class='tagging_options'>"; // all tags in site by you print _("...added by "); // all tags in site by you if (!$this->isAnonymous()) { if ($harmoni->getCurrentAction() != 'tags.usersite') { $url = SiteDispatcher::quickURL('tags', 'usersite', array('agent_id' => $tagManager->getCurrentUserIdString(), 'tag' => RequestContext::value('tag'))); print "<a href='" . $url . "'>" . str_replace('%1', RequestContext::value('tag'), _("you")) . "</a> / "; } else { if ($harmoni->getCurrentAction() == 'tags.usersite') { print "<strong>" . _("you") . "</strong> / "; } else { print _("you / "); } } } // all tags in site by everyone if ($harmoni->getCurrentAction() != 'tags.site') { $url = SiteDispatcher::quickURL('tags', 'site', array('agent_id' => $tagManager->getCurrentUserIdString(), 'tag' => RequestContext::value('tag'))); print "<a href='" . $url . "'>" . str_replace('%1', RequestContext::value('tag'), _("everyone")) . "</a>"; } else { if ($harmoni->getCurrentAction() == 'tags.site') { print "<strong>" . _("everyone") . "</strong>"; } else { print _("everyone"); } } $node = SiteDispatcher::getCurrentRootNode(); $context = str_replace('%2', $node->acceptVisitor(new BreadCrumbsVisitor($node)), _("%2")); print _(" within: ") . $context; print "</div>"; print "<div class='tagging_options'>"; print _("...added by "); // all tags from all segue by you if (!$this->isAnonymous()) { if ($harmoni->getCurrentAction() != 'tags.usersegue') { $url = SiteDispatcher::quickURL('tags', 'usersegue', array('agent_id' => $tagManager->getCurrentUserIdString(), 'tag' => RequestContext::value('tag'))); print "<a href='" . $url . "'>" . str_replace('%1', RequestContext::value('tag'), _("you")) . "</a> / "; } else { if ($harmoni->getCurrentAction() == 'tags.usersegue') { print "<strong>" . _("you") . "</strong> / "; } else { print _("you / "); } } } // all tags from all segue by everyone if ($harmoni->getCurrentAction() != 'tags.segue') { $url = SiteDispatcher::quickURL('tags', 'segue', array('agent_id' => $tagManager->getCurrentUserIdString(), 'tag' => RequestContext::value('tag'))); print "<a href='" . $url . "'>" . str_replace('%1', RequestContext::value('tag'), _("everyone")) . "</a>"; } else { if ($harmoni->getCurrentAction() == 'tags.segue') { print "<strong>" . _("everyone") . "</strong>"; } else { print _("everyone"); } } print _(" within: <br/> all of Segue"); print "</div>"; $tagsMenu = ob_get_clean(); return $tagsMenu; }
/** * Answer the site-wide header customized for this site. * * @return string */ public function getSegueSiteHeader() { if (!defined('SITE_OWNER_MESSAGE') || !$this->isAuthorizedToExecute()) { return str_replace('[[SITE_OWNER_MESSAGE]]', '', SEGUE_SITE_HEADER); } // Build the owner list. $admins = array(); $roleMgr = SegueRoleManager::instance(); $adminIds = $roleMgr->getAgentsWithExplicitRoleAtLeast($roleMgr->getRole('editor'), SiteDispatcher::getCurrentRootNode()->getQualifierId(), true); $adminstratorsGroupId = new HarmoniId('1'); $agentMgr = Services::getService('Agent'); foreach ($adminIds as $adminId) { if (!$adminId->isEqual($adminstratorsGroupId)) { try { $admins[] = $agentMgr->getAgent($adminId)->getDisplayName(); } catch (UnknownIdException $e) { // Ignore missing agents. } } } if (count($admins) <= 2) { $adminString = implode(' and ', $admins); } else { $admins[count($admins) - 1] = 'and ' . $admins[count($admins) - 1]; $adminString = implode(', ', $admins); } return str_replace('[[SITE_OWNER_MESSAGE]]', str_replace('[[SITE_OWNERS]]', $adminString, SITE_OWNER_MESSAGE), SEGUE_SITE_HEADER); }
/** * Check Authorizations * * @return boolean * @access public * @since 11/14/07 */ public function isAuthorizedToExecute() { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); return $authZ->isUserAuthorizedBelow($idManager->getId("edu.middlebury.authorization.view_authorizations"), SiteDispatcher::getCurrentRootNode()->getQualifierId()); }
/** * Add the site content gui components * * @param Component $mainScreen * @return void * @access public */ public function addSiteContent(Component $mainScreen) { $harmoni = Harmoni::instance(); if ($this->isAuthorizedToExecute()) { // :: Site :: $rootSiteComponent = SiteDispatcher::getCurrentRootNode(); $this->siteGuiComponent = $rootSiteComponent->acceptVisitor($this->getSiteVisitor()); $mainScreen->add($this->siteGuiComponent); } else { // Replace the title $outputHandler = $harmoni->getOutputHandler(); $title = "\n\t\t<title>" . _("Unauthorized") . "</title>"; $outputHandler->setHead(preg_replace("/<title>[^<]*<\\/title>/", $title, $outputHandler->getHead())); $mainScreen->add(new Block($this->getUnauthorizedMessage(), ALERT_BLOCK), "100%", null, CENTER, TOP); } }