本文整理汇总了PHP中Harmoni类的典型用法代码示例。如果您正苦于以下问题:PHP Harmoni类的具体用法?PHP Harmoni怎么用?PHP Harmoni使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Harmoni类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute this action.
*
* @param object Harmoni $harmoni
* @return mixed
* @access public
* @since 4/25/05
*/
function execute()
{
if (!$this->isAuthorizedToExecute()) {
throw new PermissionDeniedException();
}
$harmoni = Harmoni::instance();
$harmoni->request->startNamespace("harmoni-authentication");
$query = RequestContext::value("user");
$harmoni->request->endNamespace();
header('Content-type: text/plain');
if (!strlen($query)) {
exit;
}
$authNMethodManager = Services::getService("AuthNMethods");
$types = $authNMethodManager->getAuthNTypes();
while ($types->hasNext()) {
$type = $types->next();
$method = $authNMethodManager->getAuthNMethodForType($type);
$foundTokens = $method->getTokensBySearch($query);
while ($foundTokens->hasNext()) {
$tokens = $foundTokens->next();
print $method->getDisplayNameForTokens($tokens) . " (" . $type->getKeyword() . ")|type=\"" . $type->asString() . "\" id=\"" . $tokens->getIdentifier() . "\"\n";
}
}
exit;
}
示例2: buildContent
/**
* Build the content for this action
*
* @return boolean
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
$repository = $this->getRepository();
$repositoryId = $this->getRepositoryId();
// function links
ob_start();
print _("Collection") . ": ";
RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository);
$layout = new Block(ob_get_contents(), 3);
ob_end_clean();
$actionRows->add($layout, null, null, CENTER, CENTER);
ob_start();
print "<p>";
print _("Some <em>Collections</em>, <em>Exhibitions</em>, <em>Assets</em>, and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system.");
print "</p>";
$introText = new Block(ob_get_contents(), 3);
ob_end_clean();
$actionRows->add($introText, null, null, CENTER, CENTER);
// Print out the search types
ob_start();
$searchModules = Services::getService("RepositorySearchModules");
$searchTypes = $repository->getSearchTypes();
while ($searchTypes->hasNext()) {
$searchType = $searchTypes->next();
$typeString = $searchType->getDomain() . "::" . $searchType->getAuthority() . "::" . $searchType->getKeyword();
print "\n<h3>" . $typeString . "</h3>";
print "\n" . $searchModules->createSearchForm($repository, $searchType, $harmoni->request->quickURL("collection", "searchresults", array("collection_id" => $repositoryId->getIdString(), "asset_type" => urlencode($typeString))));
}
$searchFields = new Block(ob_get_contents(), 3);
ob_end_clean();
$actionRows->add($searchFields, "100%", null, LEFT, CENTER);
}
示例3: buildContent
/**
* Build the content for this action
*
* @return void
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
// Set our textdomain
$defaultTextDomain = textdomain("polyphony");
ob_start();
$harmoni->request->startNamespace("harmoni-authentication");
$action = $harmoni->history->getReturnURL("polyphony/authentication");
$usernameField = $harmoni->request->getName("username");
$passwordField = $harmoni->request->getName("password");
$usernameText = _("Username/Email");
$passwordText = _("Password");
$submitLabel = _('Log In');
print <<<END
\t\t
\t\t<center><form name='login' action='{$action}' method='post'>
\t\t\t{$usernameText}: <input type='text' name='{$usernameField}' />
\t\t\t<br />{$passwordText}: <input type='password' name='{$passwordField}' />
\t\t\t<br /><input type='submit' value='{$submitLabel}'/>
\t\t</form></center>
\t\t
END;
$actionRows->add(new Block(ob_get_contents(), 2), "100%", null, CENTER, CENTER);
ob_end_clean();
$harmoni->request->endNamespace();
// go back to the default text domain
textdomain($defaultTextDomain);
}
示例4: getVisitorLoginLink
function getVisitorLoginLink()
{
$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('polyphony');
$url = $harmoni->request->mkURL("auth", "login_type");
$url->setValue("type", urlencode($visitorType->asString()));
// 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 Login") . "</a>";
}
return null;
}
示例5: generateMainMenu
/**
* Generates a menu layout based on the current action.
* @param string $actionString A dotted-pair action string of the form
* "module.action" .
* @return object MenuLayout
* @static
*/
static function generateMainMenu()
{
$harmoni = Harmoni::instance();
list($module, $action) = explode(".", $harmoni->request->getRequestedModuleAction());
$mainMenu = new Menu(new YLayout(), 1);
// :: Home ::
$mainMenu_item = new MenuItemLink(_("Home"), $harmoni->request->quickURL("home", "welcome"), $module == "home" && $action == "welcome" ? TRUE : FALSE, 1);
$mainMenu->add($mainMenu_item, "100%", null, LEFT, CENTER);
// $mainMenu_item = new MenuItemLink(
// _("Plugin Tests"),
// $harmoni->request->quickURL("plugin_manager", "test"),
// ($module == "plugin_manager")?TRUE:FALSE,1);
// $mainMenu->add($mainMenu_item, "100%", null, LEFT, CENTER);
$mainMenu_item = new MenuItemLink(_("Portal"), $harmoni->request->quickURL('portal', "list"), $module == "portal" && $action == 'list' ? TRUE : FALSE, 1);
$mainMenu->add($mainMenu_item, "100%", null, LEFT, CENTER);
if (defined('DATAPORT_SEGUE1_URL') && defined('DATAPORT_SEGUE1_SECRET_KEY') && defined('DATAPORT_SEGUE1_SECRET_VALUE')) {
$mainMenu_item = new MenuItemLink(_("Migrate Sites"), $harmoni->request->quickURL('dataport', "choose_site"), $module == "dataport" && $action == 'choose_site' ? TRUE : FALSE, 1);
$mainMenu->add($mainMenu_item, "100%", null, LEFT, CENTER);
}
$mainMenu_item8 = new MenuItemLink(_("User Tools"), $harmoni->request->quickURL("user", "main"), preg_match("/^user\$/", $module) ? TRUE : FALSE, 1);
$mainMenu->add($mainMenu_item8, "100%", null, LEFT, CENTER);
$mainMenu_item7 = new MenuItemLink(_("Admin Tools"), $harmoni->request->quickURL("admin", "main"), preg_match("/^admin\$/", $module) ? TRUE : FALSE, 1);
$mainMenu->add($mainMenu_item7, "100%", null, LEFT, CENTER);
return $mainMenu;
}
示例6: buildContent
/**
* Build the content for this action
*
* @return void
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
$idManager = Services::getService("Id");
$repositoryManager = Services::getService("Repository");
$repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository"));
$asset = $repository->getAsset($idManager->getId(RequestContext::value('slideshow_id')));
// Remove it from its set.
$exhibitionId = $idManager->getId(RequestContext::value('exhibition_id'));
$setManager = Services::getService("Sets");
$exhibitionSet = $setManager->getPersistentSet($exhibitionId);
$exhibitionSet->removeItem($asset->getId());
// Log the action
if (Services::serviceRunning("Logging")) {
$loggingManager = Services::getService("Logging");
$log = $loggingManager->getLogForWriting("Concerto");
$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("Delete Node", "Slideshow deleted:\n<br/> " . $asset->getDisplayName());
$item->addNodeId($asset->getId());
$item->addNodeId($idManager->getId(RequestContext::value('exhibition_id')));
$log->appendLogWithTypes($item, $formatType, $priorityType);
}
$repository->deleteAsset($idManager->getId(RequestContext::value('slideshow_id')));
RequestContext::locationHeader($harmoni->request->quickURL("exhibitions", "browse_exhibition", array("exhibition_id" => RequestContext::value('exhibition_id'))));
}
示例7: buildContent
/**
* Build the content for this action
*
* @return void
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
$idManager = Services::getService("Id");
$repositoryManager = Services::getService("Repository");
$repositoryId = $idManager->getId(RequestContext::value('collection_id'));
$repository = $repositoryManager->getRepository($repositoryId);
$displayName = $repository->getDisplayName();
// Delete all of the tags for the assets in the repository
$itemsToDelete = array();
$assets = $repository->getAssets();
while ($assets->hasNext()) {
$asset = $assets->next();
$itemsToDelete[] = TaggedItem::forId($asset->getId(), 'concerto');
}
$tagManager = Services::getService('Tagging');
$tagManager->deleteItems($itemsToDelete, 'concerto');
$repositoryManager->deleteRepository($idManager->getId(RequestContext::value('collection_id')));
// Log the success or failure
if (Services::serviceRunning("Logging")) {
$loggingManager = Services::getService("Logging");
$log = $loggingManager->getLogForWriting("Concerto");
$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("Delete Node", "Repository deleted:\n<br/> " . $displayName);
$item->addNodeId($repositoryId);
$log->appendLogWithTypes($item, $formatType, $priorityType);
}
RequestContext::locationHeader($harmoni->request->quickURL("collections", "namebrowse"));
}
示例8: execute
/**
* 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;
}
示例9: buildContent
/**
* Build the content for this action
*
* @return boolean
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
ob_start();
CollectionsPrinter::printFunctionLinks();
$layout = new Block(ob_get_contents(), STANDARD_BLOCK);
ob_end_clean();
$actionRows->add($layout, null, null, CENTER, CENTER);
$type = HarmoniType::fromString(urldecode(RequestContext::value('type')));
$repositoryManager = Services::getService("Repository");
// Get the Repositories
$allRepositories = $repositoryManager->getRepositoriesByType($type);
// put the repositories into an array and order them.
// @todo, do authorization checking
$repositoryArray = array();
while ($allRepositories->hasNext()) {
$repository = $allRepositories->next();
$repositoryArray[$repository->getDisplayName()] = $repository;
}
ksort($repositoryArray);
// print the Results
$resultPrinter = new ArrayResultPrinter($repositoryArray, 2, 20, "printrepositoryShort", $harmoni);
$resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
$resultLayout = $resultPrinter->getLayout();
$actionRows->add($resultLayout, null, null, CENTER, CENTER);
}
示例10: execute
/**
* Execute this action. This is a template method that handles setting up
* components of the screen as well as authorization, delegating the various
* parts to descendent classes.
*
* @return mixed
* @access public
* @since 4/25/05
*/
public final function execute()
{
$harmoni = Harmoni::instance();
$pageTitle = $harmoni->config->get('programTitle');
// Our Rows for action content
$actionRows = $this->getActionRows();
// Check authorization
if (!$this->isAuthorizedToExecute()) {
$actionRows->add(new Block($this->getUnauthorizedMessage(), ALERT_BLOCK), "100%", null, CENTER, TOP);
return $actionRows;
}
// Add a heading if specified
if ($headingText = $this->getHeadingText()) {
$actionRows->add(new Heading($headingText, 1), "100%", null, LEFT, CENTER);
}
if ($this->getTitleText()) {
$pageTitle .= ": " . $this->getTitleText();
}
// Set the page title and other new header items
$outputHandler = $harmoni->getOutputHandler();
ob_start();
// Remove any existing title tags from the head text
print preg_replace("/<title>[^<]*<\\/title>/", "", $outputHandler->getHead());
//Add our new title
print "\n\t\t<title>";
print strip_tags(preg_replace("/<(\\/)?(em|i|b|strong)>/", "*", $pageTitle));
print "</title>";
// Add our common Harmoni javascript libraries
require POLYPHONY_DIR . "/main/library/Harmoni.js.inc.php";
$outputHandler->setHead(ob_get_clean());
// Pass content generation off to our child classes
$this->buildContent();
return $actionRows;
}
示例11: addBrowserWarning
/**
* Add a supported-browser warning
*
* @return void
* @access public
* @since 12/20/07
* @static
*/
public static function addBrowserWarning()
{
$harmoni = Harmoni::instance();
$outputHandler = $harmoni->getOutputHandler();
$polyphonyPath = POLYPHONY_PATH;
$msieWarning = _('The \'New Mode\' editing interface does not support old versions of Microsoft Internet Explorer.\\n\\nPlease use the \'Classic Mode\' editing interface or use one of the following browsers:\\n\\tFirefox\\n\\tOpera\\n\\tSafari\\n\\tInternet Explorer (version 7 and later)');
$warning = <<<END
\t\t
\t\t<script src='{$polyphonyPath}/javascript/brwsniff.js' type='text/javascript'></script>
\t\t<script type='text/javascript'>
\t\t// <![CDATA[
\t\t
\t\tvar br = getBrowser();
\t\t
\t\t// Display warning for old MSIE
\t\tif (br[0] == 'msie' && getMajorVersion(br[1]) < 7) {
\t\t\talert("{$msieWarning}");
\t\t}
\t\t
\t\t// ]]>
\t\t</script>
END;
$outputHandler->setHead($outputHandler->getHead() . $warning);
}
示例12: visitBlock
/**
* 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) {
}
}
}
示例13: buildContent
/**
* Build the content for this action
*
* @return boolean
* @access public
* @since 4/26/05
*/
function buildContent()
{
$actionRows = $this->getActionRows();
$harmoni = Harmoni::instance();
$repository = $this->getRepository();
// get the search type.
$searchType = HarmoniType::fromString(urldecode(RequestContext::value('search_type')));
// Get the Search criteria
$searchModules = Services::getService("RepositorySearchModules");
$searchCriteria = $searchModules->getSearchCriteria($repository, $searchType);
// function links
ob_start();
print _("Collection") . ": ";
RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository);
$layout = new Block(ob_get_contents(), 2);
ob_end_clean();
$actionRows->add($layout, null, null, CENTER, CENTER);
ob_start();
print "<p>";
print _("Some <em>Collections</em>, <em>Exhibitions</em>, <em>Assets</em>, and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system.");
print "</p>";
$introText = new Block(ob_get_contents(), 2);
ob_end_clean();
$actionRows->add($introText, null, null, CENTER, CENTER);
//***********************************
// Get the assets to display
//***********************************
$assets = $repository->getAssetsBySearch($searchCriteria, $searchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null')));
//***********************************
// print the results
//***********************************
$resultPrinter = new IteratorResultPrinter($assets, 2, 6, "printAssetShort", $harmoni);
$resultLayout = $resultPrinter->getLayout();
$actionRows->add($resultLayout, "100%", null, LEFT, CENTER);
}
示例14: instance
/**
* This class implements the Singleton pattern. There is only ever
* one instance of the this class and it is accessed only via the
* ClassName::instance() method.
*
* @return object
* @access public
* @since 5/26/05
* @static
*/
public static function instance()
{
if (!isset(self::$instance)) {
self::$instance = new Harmoni();
}
return self::$instance;
}
示例15: getTags
/**
* Answer all the tags in Segue by everyon
*
* @return object TagIterator
* @access public
* @since 11/8/06
*/
function getTags()
{
$harmoni = Harmoni::instance();
$tagManager = Services::getService("Tagging");
$tags = $tagManager->getTags(TAG_SORT_ALFA, $this->getNumTags());
return $tags;
}