本文整理汇总了PHP中Services::getService方法的典型用法代码示例。如果您正苦于以下问题:PHP Services::getService方法的具体用法?PHP Services::getService怎么用?PHP Services::getService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Services
的用法示例。
在下文中一共展示了Services::getService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'))));
}
示例2: 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;
}
示例3: visitBlock
/**
* 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);
}
}
}
}
}
示例4: 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) {
}
}
}
示例5: getMarkup
/**
* Returns a block of XHTML-valid code that contains markup for this specific
* component.
* @param string $fieldName The field name to use when outputting form data or
* similar parameters/information.
* @access public
* @return string
*/
function getMarkup($fieldName)
{
ob_start();
if (is_object($this->_id)) {
$repositoryManager = Services::getService('Repository');
try {
$asset = $repositoryManager->getAsset($this->_id);
print "\n<table border='0'>";
print "\n\t<tr>\n\t\t<td>";
$thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($this->_id);
if ($thumbnailURL !== FALSE) {
// print "\n\t<br /><a href='".$assetViewUrl."'>";
print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' class='thumbnail_image' />";
// print "\n\t</a>";
}
print "\n\t\t</td>\n\t\t</tr>";
print "\n\t<tr>\n\t\t<td>";
print _("Id: ") . $this->_id->getIdString();
print "\n\t\t</td>\n\t\t</tr>";
print "\n\t<tr>\n\t\t<td>";
print _("Name: ") . $asset->getDisplayName();
print "\n\t\t</td>\n\t\t</tr>";
print "\n</table>";
} catch (UnknownIdException $e) {
print "\n<div style='margin: 10px; padding: 10px; border: 1px dotted;'>";
print _("The target Asset has been deleted or is no longer available.");
print "</div>";
}
}
$m = ob_get_contents();
ob_end_clean();
return $m;
}
示例6: isAuthorizedToExecute
/**
* Check Authorizations
*
* @return boolean
* @access public
* @since 4/26/05
*/
function isAuthorizedToExecute()
{
// Check that the user can access this collection
$authZ = Services::getService("AuthZ");
$idManager = Services::getService("Id");
return $authZ->isUserAuthorizedBelow($idManager->getId("edu.middlebury.authorization.view"), $this->getRepositoryId());
}
示例7: 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);
}
示例8: __construct
/**
* 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;
}
示例9: 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;
}
示例10: getGroupsBySearch
/**
* Get all the Groups with the specified search criteria and search Type.
*
* This method is defined in v.2 of the OSIDs.
*
* @param mixed $searchCriteria
* @param object Type $groupSearchType
* @return object AgentIterator
* @access public
* @since 11/10/04
*/
function getGroupsBySearch($searchCriteria)
{
$allGroups = array();
// See if the agent exists as known by harmoni
$authNMethodManager = Services::getService("AuthNMethodManager");
$authenticationManager = Services::getService("AuthenticationManager");
$agentManager = Services::getService("AgentManager");
$idManager = Services::getService("IdManager");
$types = $authNMethodManager->getAuthNTypes();
$idsFound = array();
while ($types->hasNext()) {
$type = $types->next();
$authNMethod = $authNMethodManager->getAuthNMethodForType($type);
if (!method_exists($authNMethod, "getGroupTokensBySearch")) {
continue;
}
$tokensIterator = $authNMethod->getGroupTokensBySearch($searchCriteria);
while ($tokensIterator->hasNextObject()) {
$token = $tokensIterator->nextObject();
if (!in_array($token->getIdentifier(), $idsFound)) {
$allGroups[] = $agentManager->getGroup($idManager->getId($token->getIdentifier()));
$idsFound[] = $token->getIdentifier();
}
}
}
$obj = new HarmoniIterator($allGroups);
return $obj;
}
示例11: authenticate
/**
* Loop through the authentication types and try to authenticate the user.
*
* @return void
* @access public
* @since 8/4/06
*/
function authenticate()
{
$authN = Services::getService("AuthN");
// Reconfigure the AuthNManager to use HTTP Auth rather than forms
// :: Start the AuthenticationManager OSID Impl.
$configuration = $authN->getConfiguration();
$tokenCollectors = array();
$authNTypes = $authN->getAuthenticationTypes();
while ($authNTypes->hasNext()) {
$tokenCollectors[serialize($authNTypes->next())] = new HTTPAuthNamePassTokenCollector($this->getRelm(), $this->getCancelFunction());
}
$configuration->deleteProperty('token_collectors');
$configuration->addProperty('token_collectors', $tokenCollectors);
$authN->assignConfiguration($configuration);
// Authenticate with HTTP Authentication.
$harmoni = Harmoni::instance();
$isAuthenticated = FALSE;
$authTypes = $authN->getAuthenticationTypes();
while ($authTypes->hasNext() && !$isAuthenticated) {
$authType = $authTypes->next();
// Try authenticating with this type
$authN->authenticateUser($authType);
// If they are authenticated, quit
if ($authN->isUserAuthenticated($authType)) {
$isAuthenticated = TRUE;
}
}
}
示例12: getCommandsComponent
/**
* 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;
}
示例13: 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;
}
示例14: TabAssetIterator
/**
* Constructor
*
* @return object
* @access public
* @since 7/20/05
*/
function TabAssetIterator($srcDir, $parentRepositoryImporter)
{
if (Services::serviceRunning("Logging")) {
$loggingManager = Services::getService("Logging");
$log = $loggingManager->getLogForWriting("Harmoni");
$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", "Events involving critical system errors.");
}
if (file_exists($srcDir . "metadata.txt") && ($meta = fopen($srcDir . "metadata.txt", "r"))) {
fgets($meta);
fgets($meta);
while ($line = preg_replace("/[\n\r]*\$/", "", fgets($meta))) {
$metadata = explode("\t", $line);
$this->_assetList[] = $metadata;
}
if (count($this->_assetList) == 0) {
$parentRepositoryImporter->addError("There are no assets to import in: " . $srcDir . "metadata.txt.");
if (isset($log)) {
$item = new AgentNodeEntryItem("TabImporter Error", "There are no assets to import in: {$srcDir}/metadata.txt.");
$log->appendLogWithTypes($item, $formatType, $priorityType);
}
}
fclose($meta);
$this->_current = 0;
} else {
$parentRepositoryImporter->addError("Tab-Delimited parse failed: " . $srcDir . "metadata.txt does not exist or is unreadable.");
if (isset($log)) {
$item = new AgentNodeEntryItem("TabImporter Error", "Tab-Delimited parse failed: {$srcDir}/metadata.txt does not exist or is unreadable.");
$log->appendLogWithTypes($item, $formatType, $priorityType);
}
}
}
示例15: getPluginContent
/**
* Answer the plugin content for a block
*
* @param object BlockSiteComponent $block
* @return string
* @access public
* @since 1/7/08
*/
function getPluginContent($block)
{
if ($block->getId() != $this->_node->getId()) {
return parent::getPluginContent($block);
}
$harmoni = Harmoni::instance();
$pluginManager = Services::getService('PluginManager');
$plugin = $pluginManager->getPlugin($block->getAsset());
ob_start();
print "\n<form action='" . SiteDispatcher::quickURL('versioning', 'compare_versions', array('node' => SiteDispatcher::getCurrentNodeId())) . "' method='post'>";
print "\n\t<div style='float: right;'>";
print "\n\t<input type='submit' value='" . _("Compare Selected Revisions »") . "'";
if (count($plugin->getVersions()) <= 1) {
print " disabled='disabled'";
}
print "/>";
print "\n\t</div>";
print "\n\t<div style='float: left;'>\n\t\t<a href='" . $harmoni->history->getReturnURL('view_history_' . $block->getId()) . "'>";
print "\n\t\t\t<input type='button' value='" . _("« Go Back") . "'/>\n\t\t</a>\n\t</div>";
print "\n\t\t<input type='hidden' name='module' value='versioning'/>";
print "\n\t<input type='hidden' name='action' value='compare_versions'/>";
print "\n\t<input type='hidden' name='node' value='" . SiteDispatcher::getCurrentNodeId() . "'/>";
print $this->getVersionTable($plugin);
print "\n</form>";
print $this->getVersionChoiceJS();
return ob_get_clean();
}