当前位置: 首页>>代码示例>>PHP>>正文


PHP Services::serviceRunning方法代码示例

本文整理汇总了PHP中Services::serviceRunning方法的典型用法代码示例。如果您正苦于以下问题:PHP Services::serviceRunning方法的具体用法?PHP Services::serviceRunning怎么用?PHP Services::serviceRunning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Services的用法示例。


在下文中一共展示了Services::serviceRunning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 10/9/08
  */
 public function execute()
 {
     header('Content-Type: text/plain;');
     try {
         if (!$this->isAuthorizedToExecute()) {
             throw new PermissionDeniedException("You must be logged in.");
         }
         $mgr = SlotManager::instance();
         $slot = $mgr->getSlotByShortname(RequestContext::value('slot'));
         $slot->makeAlias($mgr->getSlotByShortname(RequestContext::value('target_slot')));
         print _("Success");
         /*********************************************************
          * Log the success
          *********************************************************/
         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", "Event_Notice", "Normal events.");
             $item = new AgentNodeEntryItem("Alias Made", "'" . $slot->getShortname() . "' has been made an alias of '" . RequestContext::value('target_slot') . "'.");
             $item->addNodeId($slot->getSiteId());
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     } catch (OperationFailedException $e) {
         print $e->getMessage();
     } catch (UnknownIdException $e) {
         print $e->getMessage();
     }
     exit;
 }
开发者ID:adamfranco,项目名称:segue,代码行数:37,代码来源:make_alias.act.php

示例2: 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");
     $recordStructureId = $this->getRecordStructureId();
     $recordStructure = $this->getRecordStructure();
     $recordStructureIdString = $recordStructureId->getIdString();
     $repositoryId = $this->getRepositoryId();
     $repository = $this->getRepository();
     // 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 RecordStructure", "RecordStructure deleted:\n<br/>&nbsp; &nbsp; &nbsp;" . $recordStructure->getDisplayName());
         $item->addNodeId($recordStructureId);
         $item->addNodeId($repositoryId);
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $setManager = Services::getService("Sets");
     $set = $setManager->getPersistentSet($repositoryId);
     if ($set->isInSet($recordStructureId)) {
         $set->removeItem($recordStructureId);
     }
     $repository->deleteRecordStructure($recordStructureId, new StatusStars(_("Deleting Schema and associated Records")));
     RequestContext::sendTo($harmoni->history->getReturnUrl("concerto/schema/delete-return/" . $recordStructureIdString));
 }
开发者ID:adamfranco,项目名称:concerto,代码行数:36,代码来源:delete.act.php

示例3: 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);
         }
     }
 }
开发者ID:adamfranco,项目名称:polyphony,代码行数:39,代码来源:TabAssetIterator.class.php

示例4: 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/>&nbsp; &nbsp; &nbsp;" . $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'))));
 }
开发者ID:adamfranco,项目名称:concerto,代码行数:34,代码来源:delete_slideshow.act.php

示例5: test_start_stop_restart

 function test_start_stop_restart()
 {
     $this->test_register_service();
     //$this->assertFalse(Services::serviceRunning("DBHandler"));
     // start it!
     $this->assertTrue(Services::startService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     // stop it!
     $this->assertTrue(Services::stopService("DBHandler"));
     $this->assertFalse(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     // restart it! (or, first start it, *then* restart it!)
     $this->assertTrue(Services::startService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
     $this->assertTrue(Services::restartService("DBHandler"));
     $this->assertTrue(Services::serviceRunning("DBHandler"));
     $this->assertTrue(Services::serviceAvailable("DBHandler"));
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:20,代码来源:ServicesTestCase.class.php

示例6: processChanges

 /**
  * Process changes to the site components. This is the method that the various
  * actions that modify the site should override.
  * 
  * @param object SiteDirector $director
  * @return void
  * @access public
  * @since 4/14/06
  */
 function processChanges(SiteDirector $director)
 {
     $component = $director->getSiteComponentById(SiteDispatcher::getCurrentNodeId());
     $component->acceptVisitor(new ModifySettingsSiteVisitor());
     /*********************************************************
      * 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", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Component Modified", $component->getComponentClass() . " modified.");
         $item->addNodeId($component->getQualifierId());
         $site = $component->getDirector()->getRootSiteComponent($component->getId());
         if (!$component->getQualifierId()->isEqual($site->getQualifierId())) {
             $item->addNodeId($site->getQualifierId());
         }
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
 }
开发者ID:adamfranco,项目名称:segue,代码行数:30,代码来源:modifyComponent.act.php

示例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");
     $repositoryId = $idManager->getId(RequestContext::value('collection_id'));
     $systemAgentId = $idManager->getId('system:concerto');
     $tagGenerator = StructuredMetaDataTagGenerator::instance();
     $tagGenerator->regenerateTagsForRepository($repositoryId, $systemAgentId, 'concerto');
     // 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("Regenerated Tags", "Auto-generated tags were regenerated");
         $item->addNodeId($repositoryId);
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     RequestContext::sendTo($harmoni->request->quickURL("collection", "browse", array('collection_id' => RequestContext::value('collection_id'))));
 }
开发者ID:adamfranco,项目名称:concerto,代码行数:28,代码来源:regenStructuredTags.act.php

示例8: getSingleAssetRecordList

 /**
  * get parameters for createRecord
  * 
  * @param mixed input
  * @return array or false on fatal error
  * @access public
  * @since 7/20/05
  */
 function getSingleAssetRecordList($input)
 {
     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.");
     }
     $idManager = Services::getService("Id");
     $this->_fileStructureId = $idManager->getId("FILE");
     $fileparts = array("File Name", "Thumbnail Data");
     $this->_fileNamePartIds = $this->matchPartStructures($this->_destinationRepository->getRecordStructure($this->_fileStructureId), $fileparts);
     $recordList = array();
     $recordListElement = array();
     $recordListElement['structureId'] = $this->_fileStructureId;
     $recordListElement['partStructureIds'] = $this->_fileNamePartIds;
     $recordListElement['parts'] = array($input, "");
     $recordList[] = $recordListElement;
     $recordListElement = array();
     //printpre($recordList);
     return $recordList;
 }
开发者ID:adamfranco,项目名称:polyphony,代码行数:30,代码来源:FilesOnlyRepositoryImporter.class.php

示例9: buildContent

 /**
  * Process the changes and build the output
  * 
  * @return void
  * @access public
  * @since 10/25/07
  */
 public function buildContent()
 {
     try {
         ob_start();
         $fileAsset = $this->getFileAsset();
         $fileAssetId = $fileAsset->getId();
         $contentAsset = $this->getContentAsset();
         $repository = $fileAsset->getRepository();
         $repository->deleteAsset($fileAsset->getId());
         // Log the success or failure
         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", "Event_Notice", "Normal events.");
             $message = "File deleted with id '" . $fileAssetId->getIdString() . "'.";
             $item = new AgentNodeEntryItem("Media Library", $message);
             $item->addNodeId($fileAssetId);
             $item->addNodeId($contentAsset->getId());
             $idManager = Services::getService("Id");
             $director = AssetSiteDirector::forAsset($contentAsset);
             $site = $director->getRootSiteComponent($contentAsset->getId()->getIdString());
             $item->addNodeId($idManager->getId($site->getId()));
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         $error = ob_get_clean();
         if ($error) {
             $this->error($error);
         }
     } catch (Exception $e) {
         $this->error($e->getMessage());
     }
     $this->start();
     print $this->getQuota();
     // No content.
     $this->end();
 }
开发者ID:adamfranco,项目名称:segue,代码行数:44,代码来源:delete.act.php

示例10: execute

 /**
  * 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);
     }
 }
开发者ID:adamfranco,项目名称:segue,代码行数:43,代码来源:rebuildImplicit.act.php

示例11: execute

 /**
  * Execute the action
  * 
  * @return void
  * @access public
  * @since 10/9/08
  */
 public function execute()
 {
     if (!$this->isAuthorizedToExecute()) {
         throw new PermissionDeniedException("You must be logged in.");
     }
     $mgr = SlotManager::instance();
     $slot = $mgr->getSlotByShortname(RequestContext::value('slot'));
     $oldTarget = $slot->getAliasTarget();
     $slot->makeNotAlias();
     /*********************************************************
      * Log the success
      *********************************************************/
     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", "Event_Notice", "Normal events.");
         $item = new AgentNodeEntryItem("Alias Removed", "'" . $slot->getShortname() . "' is no longer an alias of '" . $oldTarget->getShortname() . "'.");
         $item->addNodeId($oldTarget->getSiteId());
         $log->appendLogWithTypes($item, $formatType, $priorityType);
     }
     $harmoni = Harmoni::instance();
     RequestContext::sendTo($harmoni->request->quickURL('portal', 'list'));
 }
开发者ID:adamfranco,项目名称:segue,代码行数:31,代码来源:remove_alias.act.php

示例12: createNewSlotIfRequested

 /**
  * Create a new personal slot if our form was submitted.
  * 
  * @return void
  * @access private
  * @since 4/1/08
  */
 private function createNewSlotIfRequested()
 {
     $authN = Services::getService("AuthN");
     $harmoni = Harmoni::instance();
     // Creation of new personal slots.
     $harmoni->request->startNamespace('personal_slot');
     if (RequestContext::value('slot_postfix') && PersonalSlot::hasPersonal()) {
         try {
             $newSlotname = PersonalSlot::getPersonalShortname($authN->getFirstUserId()) . "-" . RequestContext::value('slot_postfix');
             // Replace delimiting marks with an underscore
             $newSlotname = preg_replace('/[\\s\\/=+.,()]+/i', '_', $newSlotname);
             // Remove anything left over (other than letters/numbers/-/_)
             $newSlotname = preg_replace('/[^a-z0-9_-]/i', '', $newSlotname);
             $slot = new PersonalSlot(strtolower($newSlotname));
             $slot->addOwner($authN->getFirstUserId());
         } catch (OperationFailedException $e) {
             $harmoni->request->endNamespace();
             if ($e->getCode() == Slot::OWNER_EXISTS) {
                 throw new OperationFailedException("Placeholder '" . strtolower($newSlotname) . "' already exists.");
             } else {
                 throw $e;
             }
         }
         // Log this change.
         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", "Event_Notice", "Normal events.");
             $item = new AgentNodeEntryItem("Create Placeholder", "New placeholder created:  '" . $slot->getShortname() . "'.");
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
     }
     $harmoni->request->endNamespace();
 }
开发者ID:adamfranco,项目名称:segue,代码行数:42,代码来源:PersonalPortalFolder.class.php

示例13: moreGranulesFromXML

 function moreGranulesFromXML()
 {
     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.");
     }
     $moreXML = $this->_import->documentElement->getElementsByTagName("repositoryfile");
     $granules = 0;
     for ($i = 0; $i < $moreXML->getLength(); $i++) {
         $element = $moreXML->item($i);
         $path = $element->getText();
         if (!preg_match("#^([a-zA-Z]+://|[a-zA-Z]+:\\|/)#", $path)) {
             $path = $element->ownerDocument->xmlPath . $path;
         }
         $import = new DOMIT_Document();
         // attempt to load (parse) the xml file
         if ($import->loadXML($path)) {
             if (!$import->documentElement->hasChildNodes()) {
                 $this->addError("There are no Importables in this file");
                 // log error
                 $item = new AgentNodeEntryItem("XMLImporter Error", "No Importables in the file: " . htmlspecialchars($path) . ".");
                 if (isset($log)) {
                     $log->appendLogWithTypes($item, $formatType, $priorityType);
                 }
             } else {
                 $nodes = $import->documentElement->getElementsByTagName($this->_granule);
                 $granules += $nodes->getLength();
             }
         } else {
             // any errors encountered by DOMIT in parsing handled here
             $this->addError("DOMIT error: " . $import->getErrorCode() . "<br/>\t meaning: " . $import->getErrorString() . "<br/>");
             $item = new AgentNodeEntryItem("XMLImporter DOMIT Error", "Error Code: " . $import->getErrorCode() . ", meaning: " . $import->getErrorString() . ".");
             if (isset($log)) {
                 $log->appendLogWithTypes($item, $formatType, $priorityType);
             }
         }
     }
     return $granules;
 }
开发者ID:adamfranco,项目名称:polyphony,代码行数:41,代码来源:XMLImporter.class.php

示例14: requireService

 /**
  * The Require Service function checks for required service availability.
  * 
  * The function first checks for service availabilty, and then attempts to
  * start the service if it's available. If either action fails, it stops
  * script execution. If $start=false then the function will only check for 
  * availability.
  * @param string $name The name of the service.
  * @param boolean $start If we should attempt to start the service or not.
  * @access public
  * @static
  * @return ref object The started service object. (if start=true)
  * @deprecated 2004/07/28 Use {@link startManagerAsService()} and {@link getService()} instead.
  **/
 static function requireService($service, $start = true)
 {
     $backtrace = debug_backtrace();
     print "\n<br/><strong>Warning: Method call, Services::requireService(), is deprecated. Please use Services::startManagerAsService() and/or Services::getService() instead. ";
     print $backtrace[0]['file'] . " (Line " . $backtrace[0]['line'] . ")";
     print "</strong><br/>\n";
     $error = false;
     if (!Services::serviceAvailable($service)) {
         $error = true;
     } else {
         if ($start && !Services::serviceRunning($service) && !Services::startService($service)) {
             $error = true;
         }
     }
     if ($error) {
         // if we have the error Handler, throw a pretty error with that,
         // otherwise, use the die() function.
         if ($GLOBALS[SERVICES_OBJECT]->available('ErrorHandler')) {
             throwError(new Error("A required Service <b>\"{$service}\"</b> " . ($start ? "could not be started" : "is not available"), "Services", 1));
         } else {
             $debug = debug_backtrace();
             $str = "<B>FATAL ERROR</b><br /><br />";
             $str .= "A required Service <b>\"{$service}\"</b> ";
             $str .= $start ? "could not be started" : "is not available";
             $str .= ".<br /><br />\n";
             $str .= "<b>Debug backtrace:</b>\n";
             $str .= "<pre>\n";
             $str .= print_r($debug, true);
             $str .= "\n</pre>\n";
             die($str);
         }
     }
     if ($start) {
         return Services::getService($service);
     }
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:50,代码来源:Services.abstract.php

示例15: saveWizard

 /**
  * Save our results. Tearing down and unsetting the Wizard is handled by
  * in {@link runWizard()} and does not need to be implemented here.
  * 
  * @param string $cacheName
  * @return boolean TRUE if save was successful and tear-down/cleanup of the
  *		Wizard should ensue.
  * @access public
  * @since 1/28/08
  */
 public function saveWizard($cacheName)
 {
     $wizard = $this->getWizard($cacheName);
     if (!$wizard->validate()) {
         return false;
     }
     $values = $wizard->getAllValues();
     // 		printpre($values);
     // 		return false;
     try {
         if (!defined('DATAPORT_TMP_DIR')) {
             throw new Exception("DATAPORT_TMP_DIR must be defined in the Segue configuration.");
         }
         $archivePath = $values['mode']['backup_file']['tmp_name'];
         $archiveName = basename($archivePath);
         $decompressDir = DATAPORT_TMP_DIR . '/' . $archiveName . '_source';
         if (!$values['mode']['backup_file']['size']) {
             throw new Exception("File upload error - archive was not successfully uploaded and has no size.");
         }
         $this->decompressArchive($archivePath, $decompressDir);
         // Do the import
         $director = SiteDispatcher::getSiteDirector();
         $doc = new Harmoni_DOMDocument();
         $doc->load($decompressDir . "/site.xml");
         // Validate the document contents
         $doc->schemaValidateWithException(MYDIR . "/doc/raw/dtds/segue2-site.xsd");
         $mediaDir = $decompressDir;
         switch ($values['mode']['trust']) {
             case 'all':
                 $class = 'DomImportSiteVisitor';
                 break;
             case 'time_only':
                 $class = 'UntrustedAgentDomImportSiteVisitor';
                 break;
             default:
                 $class = 'UntrustedAgentAndTimeDomImportSiteVisitor';
         }
         $importer = new $class($doc, $mediaDir, $director);
         if ($values['mode']['roles'] == '1') {
             $importer->enableRoleImport();
         }
         if ($values['mode']['comments'] == '0') {
             $importer->disableCommentImport();
         }
         if (isset($values['owners'])) {
             $idMgr = Services::getService('Id');
             foreach ($values['owners']['admins'] as $adminIdString) {
                 $importer->addSiteAdministrator($idMgr->getId($adminIdString));
             }
         }
         $importer->enableStatusOutput();
         $site = $importer->importAtSlot($values['mode']['slotname']);
         // Delete the uploaded file
         unlink($archivePath);
         // Delete the decompressed Archive
         $this->deleteRecursive($decompressDir);
     } catch (Exception $importException) {
         // Delete the uploaded file
         try {
             if (file_exists($archivePath)) {
                 unlink($archivePath);
             }
         } catch (Exception $deleteException) {
             print "\n<div>\n\t";
             print $deleteException->getMessage();
             print "\n</div>";
         }
         // Delete the decompressed Archive
         try {
             if (file_exists($decompressDir)) {
                 $this->deleteRecursive($decompressDir);
             }
         } catch (Exception $deleteException) {
             print "\n<div>\n\t";
             print $deleteException->getMessage();
             print "\n</div>";
         }
         print "\n<div>\n\t";
         print $importException->getMessage();
         // 			print HarmoniErrorHandler::printDebugBacktrace($importException->getTrace());
         print "\n</div>";
         $wizard->backupFile->setValue(array('name' => null, 'size' => null, 'type' => null));
         /*********************************************************
          * Log the failure
          *********************************************************/
         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", "Recoverable errors.");
//.........这里部分代码省略.........
开发者ID:adamfranco,项目名称:segue,代码行数:101,代码来源:import.act.php


注:本文中的Services::serviceRunning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。