/** * Constructor * * @param object BlockSiteComponent $block * @return null * @access public * @since 4/3/06 */ function __construct(BlockSiteComponent $block) { $pluginManager = Services::getService('PluginManager'); $this->plugin = $pluginManager->getPlugin($block->getAsset()); $this->agentManager = Services::getService("Agent"); $this->block = $block; }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitBlock(BlockSiteComponent $siteComponent) { // check to see if user is authorized to view block $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_comments"), $idManager->getId($siteComponent->getId()))) { return; } $harmoni = Harmoni::instance(); //get all comments for site component $commentsManager = CommentManager::instance(); $comments = $commentsManager->getAllComments($siteComponent->getAsset()); while ($comments->hasNext()) { $comment = $comments->next(); $item = $this->addItem(new RSSItem()); $item->setTitle($comment->getSubject()); $item->setLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())) . "#comment_" . $comment->getIdString(), true); $item->setPubDate($comment->getModificationDate()); $agentMgr = Services::getService("Agent"); $agent = $comment->getAuthor(); $item->setAuthor($agent->getDisplayName()); $item->setCommentsLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId()))); $pluginMgr = Services::getService("PluginManager"); $plugin = $pluginMgr->getPlugin($comment->getAsset()); $item->setDescription($plugin->executeAndGetMarkup()); // MediaFile eclosures. try { foreach ($plugin->getRelatedMediaFiles() as $file) { $item->addEnclosure($file->getUrl(), $file->getSize()->value(), $file->getMimeType()); } } catch (UnimplementedException $e) { } } }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 1/26/09 */ public function visitBlock(BlockSiteComponent $siteComponent) { $view = new Participation_View($siteComponent); $idMgr = Services::getService('Id'); $azMgr = Services::getService('AuthZ'); // get create actions if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $siteComponent->getQualifierId()) == TRUE) { $this->_actions[] = new Participation_CreateAction($view, $siteComponent); } // get comment actions $commentsManager = CommentManager::instance(); $comments = $commentsManager->getAllComments($siteComponent->getAsset(), DESC); while ($comments->hasNext()) { $comment = $comments->next(); if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.comment'), $siteComponent->getQualifierId()) == TRUE) { $this->_actions[] = new Participation_CommentAction($view, $comment); } } // get history actions $pluginManager = Services::getService('PluginManager'); $plugin = $pluginManager->getPlugin($siteComponent->getAsset()); if ($plugin->supportsVersioning()) { $versions = $plugin->getVersions(); $firstVersion = 0; foreach ($versions as $version) { if ($version->getNumber() != 1) { if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $siteComponent->getQualifierId()) == TRUE) { $this->_actions[] = new Participation_HistoryAction($view, $siteComponent, $version); } } } } }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitBlockInMenu(BlockSiteComponent $siteComponent) { $parent = $siteComponent->getParentComponent(); if (!$parent) { throw new OperationFailedException("No parent for " . $siteComponent->getId()); } return $parent->acceptVisitor($this); }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitBlock(BlockSiteComponent $siteComponent) { $cm = CommentManager::instance(); if ($cm->getNumComments($siteComponent->getAsset())) { return 1; } else { return 0; } }
/** * Visit a block and return the resulting GUI component. * * @param object BlockSiteComponent $block * @return object Component * @access public * @since 4/3/06 */ function visitBlock(BlockSiteComponent $block) { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $idManager->getId($block->getId()))) { print "\n<div>" . $block->getDisplayName() . "</div>"; // $item->setDescription($this->getPluginContent($block)); // $item->setLink($this->getDetailUrl($block->getId())); return; } else { return; } }
/** * Visit a block and return the resulting GUI component. * * @param object BlockSiteComponent $block * @return object Component * @access public * @since 4/3/06 */ function visitBlock(BlockSiteComponent $block) { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $idManager->getId($block->getId()))) { $item = $this->rssFeed->addItem(new RSSItem()); $item->setTitle($block->getDisplayName()); $item->setDescription($this->getPluginContent($block)); $item->setLink($this->getDetailUrl($block->getId())); return; } else { return; } }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 6/11/08 */ public function visitBlock(BlockSiteComponent $siteComponent) { $orig = $siteComponent->getDisplayName(); $new = $this->replacePlaceholders($orig); if ($orig != $new) { $siteComponent->updateDisplayName($new); } // $orig = $siteComponent->getDescription(); // $new = $this->replacePlaceholders($orig); // if ($orig != $new) // $siteComponent->updateDescription($new); $asset = $siteComponent->getAsset(); $orig = $asset->getContent()->asString(); $new = $this->replacePlaceholders($orig); if ($orig != $new) { $asset->updateContent(Blob::withValue($new)); } }
/** * Add controls to the block * * @param object BlockSiteComponent $block * @param object Container $guiContainer * @return object Container The guiContainer * @access public * @since 5/24/07 */ function addBlockControls(BlockSiteComponent $block, Container $guiContainer) { // Add controls bar and border $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $block->getQualifierId())) { $controlsHTML = $this->getBarPreHTML('#090', $block) . $this->getControlsHTML($block, "<em>" . $this->_classNames['Block'] . "</em>", $block->acceptVisitor($this->_controlsVisitor), '#090', '#9F9', '#6C6', 0, '0px', Segue_Selection::instance()->getAddLink($block)); $guiContainer->setPreHTML($controlsHTML . $guiContainer->getPreHTML($null = null)); $guiContainer->setPostHTML($this->getBarPostHTML()); } return $guiContainer; }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 4/13/08 */ public function visitBlockInMenu(BlockSiteComponent $siteComponent) { return $siteComponent->acceptVisitor($this->isHeaderFooterVisitor); }
/** * Answer the files attached to a site component. * * @param object BlockSiteComponent $siteComponent * @access protected */ protected function addAttachedMedia(BlockSiteComponent $siteComponent) { $mediaAssetType = new Type('segue', 'edu.middlebury', 'media_file', 'A file that is uploaded to Segue.'); $children = $siteComponent->getAsset()->getAssets(); while ($children->hasNext()) { $child = $children->next(); if ($mediaAssetType->isEqual($child->getAssetType())) { try { $this->addMediaAsset($child); } catch (PermissionDeniedException $e) { } catch (OperationFailedException $e) { } } } }
/** * Visit a block and return the resulting GUI component. (A menu item) * * @param object BlockSiteComponent $block * @return object MenuItem * @access public * @since 4/3/06 */ public function visitBlockInMenu(BlockSiteComponent $block) { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $idManager->getId($block->getId()))) { $false = false; return $false; } }
/** * Answer controls for adding to the selection. * * @param object BlockSiteComponent $siteComponent * @return string * @access public * @since 8/5/08 */ public function getSelectionAdd(BlockSiteComponent $siteComponent) { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $harmoni = Harmoni::instance(); if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $siteComponent->getQualifierId())) { return false; } return Segue_Selection::instance()->getAddLink($siteComponent); }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 8/5/08 */ public function visitBlock(BlockSiteComponent $siteComponent) { if (!$this->firstSeen) { $this->firstSeen = true; } else { $this->blocks++; } // Discussions $cm = CommentManager::instance(); $this->posts += $cm->getNumComments($siteComponent->getAsset()); // Media $mediaAssets = $this->getAllMediaAssets($siteComponent->getAsset()); $this->media += $mediaAssets->count(); }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitBlock(BlockSiteComponent $siteComponent) { if (in_array($siteComponent->getId(), $this->visited)) { return null; } $this->visited[] = $siteComponent->getId(); $name = html_entity_decode($siteComponent->getDisplayName()); $name = mb_convert_encoding($name, 'UTF-8', mb_detect_encoding($name, "ASCII,UTF-8,ISO-8859-1,JIS,EUC-JP,SJIS")); $name = mb_strtolower($name, 'UTF-8'); $name = trim($name); if ($name == $this->title) { return $siteComponent->getId(); } return null; }
/** * Add the block display type and heading display type to a block * * @param object BlockSiteComponent $siteComponent * @param object DOMElement $element * @return void * @access protected * @since 6/9/08 */ protected function applyBlockDisplayTypes(BlockSiteComponent $siteComponent, DOMElement $element) { if ($element->hasAttribute('blockDisplayType')) { $siteComponent->setDisplayType($element->getAttribute('blockDisplayType')); } if ($element->hasAttribute('headingDisplayType')) { $siteComponent->setHeadingDisplayType($element->getAttribute('headingDisplayType')); } }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 6/6/08 */ public function visitBlockInMenu(BlockSiteComponent $siteComponent) { return $siteComponent->getParentComponent()->acceptVisitor($this); }
/** * Add a subcomponent * * @param object SiteComponent $siteComponent * @return void * @access public * @since 3/31/06 */ public function addSubcomponent(BlockSiteComponent $siteComponent) { $cell = $this->_element->ownerDocument->createElement('cell'); $snippet = $this->_element->ownerDocument->createElement($siteComponent->getComponentClass()); $snippet->setAttribute('id', $siteComponent->getId()); $cell->appendChild($snippet); $this->_element->appendChild($cell); // this is only for single page load deletes (testing) $this->_getChildComponents(true); $this->_saveXml(); if (!$this->isOrganizer($siteComponent->_asset->getAssetType())) { $this->_asset->addAsset($siteComponent->_asset->getId()); } }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitBlockInMenu(BlockSiteComponent $siteComponent) { $harmoni = Harmoni::instance(); // check to see if user is authorized to view block $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $idManager->getId($siteComponent->getId()))) { return; } $this->printNodeStart($siteComponent); print $this->getTabs() . "\t"; print "<div class='expandSpacer'>"; print " "; print "</div>"; $this->printNodeInfo($siteComponent, true); $this->printNodeEnd($siteComponent); }
/** * Rewrite file urls that weren't properly localized. * * @param object BlockSiteComponent $siteComponent * @return void */ protected function rewriteNonlocalFileUrls(BlockSiteComponent $siteComponent) { static $baseUrls; if (empty($baseUrls)) { $baseUrls = array('http://segue.middlebury.edu', 'https://segue.middlebury.edu', 'http://seguecommunity.middlebury.edu', 'https://seguecommunity.middlebury.edu'); foreach (SlotAbstract::getLocationCategories() as $locationCategory) { $baseUrls[] = rtrim(SiteDispatcher::getBaseUrlForLocationCategory($locationCategory), '/'); } $baseUrls = array_unique($baseUrls); } $content = $siteComponent->getAsset()->getContent(); foreach ($baseUrls as $baseUrl) { if (preg_match_all('#[\'"]' . $baseUrl . '/repository/(viewfile|viewfile_flash|viewthumbnail|viewthumbnail_flash)/polyphony-repository___repository_id/edu.middlebury.segue.sites_repository/polyphony-repository___asset_id/([0-9]+)/polyphony-repository___record_id/([0-9]+)(?:polyphony-repository___file_name/(.+))?[\'"]#', $content->asString(), $matches, PREG_SET_ORDER)) { foreach ($matches as $m) { $urlParts = array('module' => 'repository', 'action' => $m[1], 'polyphony-repository___repository_id' => 'edu.middlebury.segue.sites_repository', 'polyphony-repository___asset_id' => $m[2], 'polyphony-repository___record_id' => $m[3]); if (!empty($m[4])) { $urlParts['polyphony-repository___file_name'] = $m[4]; } else { if ($m[1] == 'viewfile') { try { $file = MediaFile::withIdStrings('edu.middlebury.segue.sites_repository', $m[2], $m[3]); $urlParts['polyphony-repository___file_name'] = $file->getFilename(); } catch (UnknownIdException $e) { } } } $url = http_build_query($urlParts, '', '&'); $content->_setValue(str_replace($m[0], '"' . '[[localurl:' . $url . ']]' . '"', $content->value())); } } } }
/** * Visit a Block and add to * * @param object BlockSiteComponent $siteComponent * @return object * @access public * @since 8/31/07 */ public function visitBlock(BlockSiteComponent $block) { $this->taggableItems[] = HarmoniNodeTaggedItem::forId($block->getId(), 'segue'); return $this->taggableItems; //return visitTaggableComponents($block); }
/** * Visit a block and return the resulting GUI component. (A menu item) * * @param object BlockSiteComponent $block * @return object MenuItem * @access public * @since 4/3/06 */ public function visitBlockInMenu(BlockSiteComponent $block) { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $idManager->getId($block->getId()))) { $false = false; return $false; } $pluginManager = Services::getService('PluginManager'); // Create and return the component ob_start(); if ($this->showBlockTitle($block)) { $desc = strip_tags($block->getDescription()); print "<div class='heading' title=\"" . $desc . "\">" . $this->getBlockTitle($block) . "</div>"; } print "<div>" . $this->getPluginContent($block, true) . "</div>"; $menuItem = new MenuItem(ob_get_clean(), 1); return $menuItem; }