/** * 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; }
/** * 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 appropriate site visitor for this action * * @return object SiteVisitor * @access public * @since 9/24/07 */ function getSiteVisitor() { if (!isset($this->visitor)) { $requestedNode = SiteDispatcher::getCurrentNode(); $this->visitor = new EditHeaderFooterSiteVisitor(); } return $this->visitor; }
/** * Answer the items with given tag for a given item * * @return object TagIterator * @access public * @since 11/8/06 */ function getItems() { $tag = $this->getTag(); $SiteComponent = SiteDispatcher::getCurrentNode(); $visitor = new TaggableItemVisitor(); $items = $SiteComponent->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 tags for given item by everyone * * @return object TagIterator * @access public * @since 11/8/06 */ function getTags() { $harmoni = Harmoni::instance(); $tagManager = Services::getService("Tagging"); $SiteComponent = SiteDispatcher::getCurrentNode(); $visitor = new TaggableItemVisitor(); $items = $SiteComponent->acceptVisitor($visitor); SiteDispatcher::passthroughContext(); $tags = $tagManager->getTagsForItems($items, TAG_SORT_ALFA, $this->getNumTags()); return $tags; }
/** * Answer the items with given tag for a given user * * @return object TagIterator * @access public * @since 11/8/06 */ function getItems() { $harmoni = Harmoni::instance(); $tag = $this->getTag(); $SiteComponent = SiteDispatcher::getCurrentNode(); $tagManager = Services::getService("Tagging"); $agentId = $tagManager->getCurrentUserId(); $visitor = new TaggableItemVisitor(); $items = $SiteComponent->acceptVisitor($visitor); $tagIds = $tag->getItemsInList($items); return $tag->getItemsForAgentInListinSystem($tagIds, $agentId, "segue"); }
/** * Answer the appropriate site visitor for this action * * @return object SiteVisitor * @access public * @since 1/7/08 */ public function getSiteVisitor() { if (!isset($this->visitor)) { $requestedNode = SiteDispatcher::getCurrentNode(); if ($requestedNode->acceptVisitor(new IsBlockVisitor())) { $this->visitor = new HistorySiteVisitor($requestedNode); } else { $this->visitor = new ViewModeSiteVisitor(); } } return $this->visitor; }
/** * builds an RSS feed * * @return void * @access public * @since 3/10/08 */ public function buildFeed() { $harmoni = Harmoni::instance(); $siteComponent = SiteDispatcher::getCurrentNode(); // set feed channel title and url $this->setTitle($siteComponent->getDisplayName() . " - " . $this->getTitleLabel()); $this->setLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId()))); if (method_exists($siteComponent, 'getDescription')) { $this->setDescription(strip_tags($siteComponent->getDescription())); } // add items to the feed $siteComponent->acceptVisitor($this); }
/** * Answer the tags for a given items for a given user * * @return object TagIterator * @access public * @since 11/8/06 */ function getTags() { $harmoni = Harmoni::instance(); $tag = $this->getTag(); $siteComponent = SiteDispatcher::getCurrentNode(); $agentManager = Services::getService("Agent"); $tagManager = Services::getService("Tagging"); $agentId = $tagManager->getCurrentUserId(); $visitor = new TaggableItemVisitor(); $items = $siteComponent->acceptVisitor($visitor); SiteDispatcher::passthroughContext(); $tags = $tagManager->getTagsForItemsByAgent($items, $agentId); return $tags; }
/** * Execute this action for generating an XML response with participation summary information * * @return mixed * @access public * @since 4/25/05 */ public function execute() { if (!$this->isAuthorizedToExecute()) { $this->error("Permission Denied"); } $node = SiteDispatcher::getCurrentNode(); $id = RequestContext::value('participant'); $view = new Participation_View($node); $idMgr = Services::getService('Id'); $participantView = new Participation_Participant($view, $idMgr->getId($id)); $this->start(); print "\n\t<role id='comments' number='" . $participantView->getNumActionsByCategory('commenter') . "'/>"; print "\n\t<role id='author' number='" . $participantView->getNumActionsByCategory('author') . "'/>"; print "\n\t<role id='editor' number='" . $participantView->getNumActionsByCategory('editor') . "'/>"; $this->end(); }
/** * 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; }
/** * Return the markup that represents the plugin. * Plugin writers should override this method with their own functionality * as needed. * * @return string * @access public * @since 1/12/06 */ public function getMarkup() { $harmoni = Harmoni::instance(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); // check if user is editor and thus can see link to participant information panel if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), SiteDispatcher::getCurrentNode()->getQualifierId())) { $this->_showTrackLink = true; } else { $this->_showTrackLink = false; } $this->addHeadJavascript('ParticipantPanel.js'); $this->addHeadCss('Participation.css'); ob_start(); // get site admins $siteAdmins = $this->getSiteAdmins(); // get all site members $group = $this->getNode()->getMembersGroup(); //printpre ($group); // get all sub-groups in site members group $subgroups = $group->getGroups(false); // get member hidden groups $hiddenGroups = $this->getMembersHiddenGroups(); if ($this->getFieldValue('edit') && $this->canModify()) { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace(null); $membersUrl = SiteDispatcher::quickURL('agent', 'modify_members', array('returnModule' => $this->getLocalModule(), 'returnAction' => $this->getLocalAction())); $rolesUrl = SiteDispatcher::quickURL('roles', 'modify', array('agent' => $group->getId()->getIdString(), 'returnModule' => $this->getLocalModule(), 'returnAction' => $this->getLocalAction())); $harmoni->request->endNamespace(); print "\n<div class='participation_ext_link'><a href='" . $membersUrl . "'>" . _("Add/Edit Site-Members »") . "</a></div>"; print "\n<div class='participation_ext_link'><a href='" . $rolesUrl . "'>" . _("View/Edit Roles of Site-Members »") . "</a></div>"; print "<p>(" . Help::link('Site-Members') . ")</p>"; print "\n" . $this->formStartTagWithAction(); // print out sub group checkboxes if ($subgroups->hasNext()) { print "\n<div class='participant_group_header'>" . _("Show members of following groups:") . "</div>"; while ($subgroups->hasNext()) { $subgroup = $subgroups->next(); print "\n<div class='participant_list'>"; print "\n\t<input name='" . $this->getFieldName($subgroup->getId()->getIdString()) . "' value='true' type='checkbox' "; if (!in_array($subgroup->getId()->getIdString(), $hiddenGroups)) { print " checked"; } print ">" . $subgroup->getDisplayName(); print "\n</div>"; } } // print out Other Participants checkbox print "\n<div class='participant_list'>"; print "\n\t<input name='" . $this->getFieldName('other_participants') . "' value='true' type='checkbox' "; if ($this->getOtherParticipantsDisplay() == "true") { print " checked"; } print ">" . _("Show Other Participants"); print "<br/>(" . _("i.e. those who are NOT site members") . ")"; print "\n</div>"; print "\n<div class='participation_buttons'>\n\t<input type='submit' value='Update' name='" . $this->getFieldName('submit') . "'>\n"; print "\n\t<input type='button' value='" . _('Cancel') . "' onclick=" . $this->locationSendString() . "/></div>"; print "</form>"; } else { if ($this->canView()) { // Site Admins print "<div class='participant_header'>" . _("Site Administrators") . "</div>"; print $this->printSiteAdminsIterator($siteAdmins); // Direct members of the group print "<div class='participant_header'>" . _("Site Members") . "</div>"; print $this->printMemberIterator($group->getMembers(false)); // Members of subgroups while ($subgroups->hasNext()) { $subgroup = $subgroups->next(); print "<div class='participant_group_header'>" . $subgroup->getDisplayName() . "</div>"; if (!in_array($subgroup->getId()->getIdString(), $hiddenGroups)) { print $this->printMemberIterator($subgroup->getMembers(false)); } } // Other Participants if ($this->getOtherParticipantsDisplay() == "true") { $notPrintedParticipants = array(); foreach ($this->getView()->getParticipants() as $participant) { if (!in_array($participant->getId()->getIdString(), $this->_printedParticipants)) { $notPrintedParticipants[] = $participant; } } print "<br/><div class='participant_header'>" . _("Other Participants") . "</div>"; print $this->printParticipants($notPrintedParticipants); } if ($this->shouldShowControls()) { print "\n<div style='text-align: right; white-space: nowrap;'>"; print "\n\t<a " . $this->href(array('edit' => 'true')) . ">" . _('edit') . "</a>"; print "\n</div>"; } } } return ob_get_clean(); }
/** * Return the markup that represents the plugin. * Plugin writers should override this method with their own functionality * as needed. * * @return string * @access public * @since 1/12/06 */ public function getMarkup() { ob_start(); $RssLinks = RssLinkPrinter::getLinkBlock(SiteDispatcher::getCurrentNode()); print "<div class='breadcrumbs'>" . $RssLinks . "</div>"; return ob_get_clean(); }
/** * Return the markup that represents the plugin. * Plugin writers should override this method with their own functionality * as needed. * * @return string * @access public * @since 1/12/06 */ public function getMarkup() { ob_start(); $node = SiteDispatcher::getCurrentNode(); $breadcrumbs = $node->acceptVisitor(new BreadCrumbsVisitor($node)); $breadcrumbs = "<div class='breadcrumbs'>" . $breadcrumbs . "</div>"; print $breadcrumbs; return ob_get_clean(); }
/** * 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 component that we are editing. If this is a creation wizard * then null will be returned. * * @return mixed object SiteComponent or null * @access protected * @since 5/8/07 */ protected function getSiteComponent() { return SiteDispatcher::getCurrentNode(); }
/** * 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; }
/** * Display a list of participants with summary of their contributions * * @param string $id * @return string XHTML markup * @access private * @since 1/28/09 */ private function getActionsList() { $node = SiteDispatcher::getCurrentNode(); $view = new Participation_View($node); $participants = $view->getParticipants(); // create an array of reorder urls $sortValues = array('timestamp', 'contributor', 'contribution', 'role'); $reorderUrl = array(); foreach ($sortValues as $sortValue) { $reorderUrl[$sortValue] = SiteDispatcher::quickURL('participation', 'actions', array('node' => $node->getId(), 'sort' => $sortValue, 'direction' => $this->_reorder, 'participant' => $this->_participant, 'role' => $this->_role)); } // header row for list of actions ob_start(); print "\n\t<thead>"; print "\n\t\t<tr>"; // time print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['timestamp']; print "'>" . _("Time") . " " . ($this->_sort == 'timestamp' ? $this->_reorderFlag : "") . "</a></th>"; // contributor print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['contributor']; print "'>" . _("Contributor") . " " . ($this->_sort == 'contributor' ? $this->_reorderFlag : "") . "</a></th>"; // role print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['role']; print "'>" . _("Role") . " " . ($this->_sort == 'role' ? $this->_reorderFlag : "") . "</a>"; print "</th>"; // contribution print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['contribution']; print "'>" . _("Contribution") . " " . ($this->_sort == 'contribution' ? $this->_reorderFlag : "") . "</a></th>"; // pushdown link print "\n\t\t\t<th style='border-bottom: 1px dotted'></th>"; print "\n\t</thead>"; $headRow = ob_get_clean(); // if participant specified get their actions if (isset($this->_participant) && $this->_participant != 'all') { $idMgr = Services::getService('Id'); $participantId = $idMgr->getId($this->_participant); $participantView = new Participation_Participant($view, $participantId); $actions = $participantView->getActions(); //get list of all actions in site } else { $actions = $view->getActions(); } // sort actions by sort key $sortKeys = array(); if ($this->_sort == 'timestamp') { foreach ($actions as $action) { $sortKeys[] = $action->getTimeStamp()->asString(); } } else { if ($this->_sort == 'contributor') { foreach ($actions as $action) { $sortKeys[] = $action->getParticipant()->getDisplayName(); } } else { if ($this->_sort == 'contribution') { foreach ($actions as $action) { $sortKeys[] = $action->getTargetDisplayName(); } } else { if ($this->_sort == 'role') { foreach ($actions as $action) { $sortKeys[] = $action->getCategoryDisplayName(); } } else { throw new InvalidArguementException("Unknown sort field {$sort}"); } } } } array_multisort($sortKeys, $this->_direction, array_keys($actions), SORT_ASC, $actions); // if role action specified then filter actions $selectedActions = array(); if ($this->_role != 'all') { foreach ($actions as $action) { if ($action->getCategoryId() == $this->_role) { $selectedActions[] = $action; } } } else { $selectedActions = $actions; } $this->_node = $node; $this->_sortValue = $sortValue; $printer = new ParticipationResultPrinter($selectedActions, $headRow, $this->_display, array($this, 'printAction')); print $printer->getMarkup(); return ob_get_clean(); }
/** * Display a list of participants with summary of their contributions * * @param string $id * @return string XHTML markup * @access private * @since 1/28/09 */ private function getParticipantsList($action = 'all') { ob_start(); //$site = SiteDispatcher::getCurrentRootNode(); $node = SiteDispatcher::getCurrentNode(); $view = new Participation_View($node); if (RequestContext::value('sort')) { $sort = RequestContext::value('sort'); } else { $sort = 'name'; } if (RequestContext::value('direction')) { if (RequestContext::value('direction') == 'DESC') { $direction = SORT_DESC; $reorder = 'ASC'; $reorderFlag = '^'; } else { $direction = SORT_ASC; $reorder = 'DESC'; $reorderFlag = 'v'; } } else { $direction = SORT_ASC; $reorder = 'ASC'; $reorderFlag = '^'; } // create an array of reorder urls $sortValues = array('name', 'commenter', 'author', 'editor'); $reorderUrl = array(); foreach ($sortValues as $sortValue) { $reorderUrl[$sortValue] = SiteDispatcher::quickURL('participation', 'summary', array('node' => $node->getId(), 'sort' => $sortValue, 'direction' => $reorder)); } // print out header row for list of participants ob_start(); print "\n\t<thead>"; print "\n\t\t<tr>"; print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['name']; print "'>" . _("Participants") . " " . ($sort == 'name' ? $reorderFlag : "") . "</a></th>"; print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['commenter']; print "'>" . _("Commenter") . " " . ($sort == 'commenter' ? $reorderFlag : "") . "</a></th>"; print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['author']; print "'>" . _("Author") . " " . ($sort == 'author' ? $reorderFlag : "") . "</a></th>"; print "\n\t\t\t<th style='border-bottom: 1px dotted'><a href='"; print $reorderUrl['editor']; print "'>" . _("Editor") . " " . ($sort == 'editor' ? $reorderFlag : "") . "</a></th>"; print "\n\t</thead>"; $headRow = ob_get_clean(); //get list of participants in site $participants = $view->getParticipants(); // sort actions by sort key $sortKeys = array(); if ($sort == 'name') { foreach ($participants as $participant) { $sortKeys[] = $participant->getDisplayName(); } } else { if ($sort == 'commenter') { foreach ($participants as $participant) { $participantView = new Participation_Participant($view, $participant->getId()); $sortKeys[] = $participantView->getNumActionsByCategory('commenter'); } } else { if ($sort == 'author') { foreach ($participants as $participant) { $participantView = new Participation_Participant($view, $participant->getId()); $sortKeys[] = $participantView->getNumActionsByCategory('author'); } } else { if ($sort == 'editor') { foreach ($participants as $participant) { $participantView = new Participation_Participant($view, $participant->getId()); $sortKeys[] = $participantView->getNumActionsByCategory('editor'); } } else { throw new InvalidArguementException("Unknown sort field {$sort}"); } } } } array_multisort($sortKeys, $direction, array_keys($participants), SORT_ASC, $participants); $this->_view = $view; $this->_node = $node; $this->_sortValue = $sortValue; $this->_reorder = $reorder; $printer = new ParticipationResultPrinter($participants, $headRow, 30, array($this, 'printAction')); print $printer->getMarkup(); return ob_get_clean(); }