コード例 #1
0
ファイル: Registry.php プロジェクト: FTeichmann/Erfurt
 /**
  * Destroys the current instance. Next time getInstance is called a new
  * instance will be created.
  */
 public static function reset()
 {
     if (self::$_instance != null) {
         self::$_instance->_wrapperRegistry = array();
     }
     self::$_instance = null;
 }
コード例 #2
0
ファイル: Bootstrap.php プロジェクト: cfrancois7/aksw.org
 /**
  * Initializes the the extension manager which in turn scans
  * for components, modules, plugins and wrapper and registers them.
  *
  * @since 0.9.5
  */
 public function _initExtensionManager()
 {
     // require Front controller
     $this->bootstrap('frontController');
     $frontController = $this->getResource('frontController');
     // require Config
     $this->bootstrap('Config');
     $config = $this->getResource('Config');
     //NOTICE: i swtiched loading of erfurt and session
     //because serialized erfurt objects in the session need constants defined in erfurt
     //is this ok?
     Erfurt_Wrapper_Registry::reset();
     // require Erfurt
     $this->bootstrap('Erfurt');
     // apply session configuration settings
     if (isset($config->session)) {
         $this->applySessionConfig($config->session);
     }
     // require Session
     $this->bootstrap('Session');
     // require Dispatcher
     $this->bootstrap('Dispatcher');
     $dispatcher = $this->getResource('Dispatcher');
     // require OntoWiki
     $this->bootstrap('OntoWiki');
     $ontoWiki = $this->getResource('OntoWiki');
     // require Translate
     $this->bootstrap('Translate');
     $translate = $this->getResource('Translate');
     // require View
     $this->bootstrap('View');
     $view = $this->getResource('View');
     // make sure router is bootstrapped
     $this->bootstrap('Router');
     // set view
     $ontoWiki->view = $view;
     $extensionPath = ONTOWIKI_ROOT . $config->extensions->base;
     $extensionPathBase = $config->staticUrlBase . $config->extensions->base;
     $extensionManager = new OntoWiki_Extension_Manager($extensionPath);
     $extensionManager->setTranslate($translate)->setComponentUrlBase($extensionPathBase);
     // register component controller directories
     foreach ($extensionManager->getComponents() as $extensionName => $extensionConfig) {
         $frontController->addControllerDirectory($extensionConfig->path, '_component_' . $extensionName);
     }
     // make extension manager available to dispatcher
     $dispatcher = $frontController->getDispatcher();
     $dispatcher->setExtensionManager($extensionManager);
     // keep extension manager in OntoWiki
     $ontoWiki->extensionManager = $extensionManager;
     // actionhelper
     Zend_Controller_Action_HelperBroker::addPrefix('OntoWiki_Controller_ActionHelper_');
     Zend_Controller_Action_HelperBroker::addHelper(new OntoWiki_Controller_ActionHelper_List());
     return $extensionManager;
 }
コード例 #3
0
ファイル: ManagerTest.php プロジェクト: FTeichmann/Erfurt
 public function testWrapperInstantiation()
 {
     $this->markTestNeedsTestConfig();
     $this->_manager->addWrapperPath($this->_resourcesPath);
     $registry = Erfurt_Wrapper_Registry::getInstance();
     $ldw = $registry->getWrapperInstance('linkeddata');
     $this->assertInstanceOf('Erfurt_Wrapper_LinkeddataWrapper', $ldw);
     $rdfaw = $registry->getWrapperInstance('rdfa');
     $this->assertInstanceOf('Erfurt_Wrapper_RdfaWrapper', $rdfaw);
     $ew = $registry->getWrapperInstance('enabled');
     $this->assertInstanceOf('EnabledWrapper', $ew);
 }
コード例 #4
0
ファイル: App.php プロジェクト: FTeichmann/Erfurt
 /**
  * Returns the instance of the Erfurt wrapper registry.
  *
  * @param Erfurt_Wrapper_Registry
  */
 public function getWrapperRegistry()
 {
     require_once 'Erfurt/Wrapper/Registry.php';
     return Erfurt_Wrapper_Registry::getInstance();
 }
コード例 #5
0
ファイル: Manager.php プロジェクト: FTeichmann/Erfurt
 public function addWrapperExternally($wrapperName, $wrapperPath, $privateConfig)
 {
     //        if($privateConfig instanceof Zend_Config){
     //            $privateConfig = $privateConfig->toArray();
     //        }
     $wrapperSpec = array('class_name' => ucfirst($wrapperName) . 'Wrapper', 'include_path' => $wrapperPath, 'config' => $privateConfig, 'instance' => null);
     // Finally register the wrapper.
     $registry = Erfurt_Wrapper_Registry::getInstance();
     $registry->register($wrapperName, $wrapperSpec);
 }
コード例 #6
0
ファイル: Manager.php プロジェクト: dmj/uni-helmstedt.hab.de
 /**
  * Constructor
  */
 public function __construct($extensionPath)
 {
     if (!(substr($extensionPath, -1) == DIRECTORY_SEPARATOR)) {
         $extensionPath .= DIRECTORY_SEPARATOR;
     }
     $this->_extensionPath = $extensionPath;
     OntoWiki_Module_Registry::reset();
     //OntoWiki_Module_Registry::getInstance()->resetInstance();
     $this->_moduleRegistry = OntoWiki_Module_Registry::getInstance();
     $this->_moduleRegistry->setExtensionPath($extensionPath);
     //TODO nessesary?
     Erfurt_Wrapper_Registry::reset();
     $this->_eventDispatcher = Erfurt_Event_Dispatcher::getInstance();
     // scan for extensions
     $this->_scanExtensionPath();
     // scan for translations
     $this->_scanTranslations();
     // register for event
     $dispatcher = Erfurt_Event_Dispatcher::getInstance();
     $dispatcher->register('onRouteShutdown', $this);
 }
コード例 #7
0
ファイル: RegistryTest.php プロジェクト: FTeichmann/Erfurt
 public function testGetInstance()
 {
     $instance = Erfurt_Wrapper_Registry::getInstance();
     $this->assertTrue($instance instanceof Erfurt_Wrapper_Registry);
 }
コード例 #8
0
 /**
  * Event handler method, which is called on menu creation. Adds some
  * datagathering relevant menu entries.
  *
  * @param Erfurt_Event $event
  *
  * @return bool
  */
 public function onCreateMenu($event)
 {
     $menu = $event->menu;
     $resource = $event->resource;
     $model = $event->model;
     $owApp = OntoWiki::getInstance();
     // We only add entries to the menu, if all params are given and the
     // model is editable.
     if (null === $resource || null === $model || !$model->isEditable() || !$owApp->erfurt->getAc()->isModelAllowed('edit', $owApp->selectedModel)) {
         return;
     }
     $owApp = OntoWiki::getInstance();
     $translate = $owApp->translate;
     $wrapperRegistry = Erfurt_Wrapper_Registry::getInstance();
     $activeWrapperList = $wrapperRegistry->listActiveWrapper();
     if ((bool) $this->_privateConfig->sync->enabled) {
         $syncConfigList = $this->_listSyncConfigs();
     } else {
         $syncConfigList = array();
     }
     $uri = (string) $resource;
     $modelUri = (string) $model;
     $menuArray = array();
     // Check all active wrapper extensions, whether URI is handled. Also
     // check, whether a sync config exists.
     foreach ($activeWrapperList as $wrapperName) {
         $hash = $this->_getHash($uri, $wrapperName, $modelUri);
         $r = new Erfurt_Rdf_Resource($uri);
         $r->setLocator($this->_getProxyUri($uri));
         $wrapperInstance = $wrapperRegistry->getWrapperInstance($wrapperName);
         if ($wrapperInstance->isHandled($r, $modelUri)) {
             $menuArray[$wrapperName] = array('instance' => $wrapperInstance);
             if (isset($syncConfigList[$hash])) {
                 $menuArray[$wrapperName]['sync'] = true;
             }
         }
     }
     // Only add a separator, if at least one active wrapper exists.
     if (count($menuArray) > 0) {
         $menu->appendEntry(OntoWiki_Menu::SEPARATOR);
     }
     foreach ($menuArray as $wrapperName => $wrapperArray) {
         $wrapperInstance = $wrapperArray['instance'];
         if (isset($wrapperArray['sync']) && $wrapperArray['sync'] === true) {
             $message = $translate->_('Sync Data with %1$s');
             $menu->appendEntry(sprintf($message, $wrapperInstance->getName()), array('about' => $uri, 'class' => 'sync_data_button wrapper_' . $wrapperName));
         } else {
             $message = $translate->_('Import Data with %1$s');
             $menu->appendEntry(sprintf($message, $wrapperInstance->getName()), array('about' => $uri, 'class' => 'fetch_data_button wrapper_' . $wrapperName));
         }
         // Configure for sync entry.
         if ((bool) $this->_privateConfig->sync->enabled) {
             $configUrl = $owApp->config->urlBase . 'datagathering/config?uri=' . urlencode($uri) . '&wrapper=' . urlencode($wrapperName);
             if ($event->isModel) {
                 $configUrl .= '&m=' . urlencode($uri);
             }
             $message = $translate->_('Configure Sync with %1$s');
             $menu->appendEntry(sprintf($message, $wrapperInstance->getName()), $configUrl);
         }
     }
     return true;
 }
コード例 #9
0
 /**
  * Fetches the data from the wrapper.
  *
  * @param string $uri
  * @param string $wrapperName
  * @param string $modelUri
  *
  * @return array
  */
 private function _getData($uri, $wrapperName, $modelUri)
 {
     try {
         $wrapper = $this->_wrapperRegistry->getWrapperInstance($wrapperName);
         $wrapperResult = $wrapper->run($uri, $modelUri);
         if (is_array($wrapperResult) && isset($wrapperResult['add'])) {
             $wrapperResult = $wrapperResult;
         } else {
             $wrapperResult = array();
         }
     } catch (Exception $e) {
         $wrapperResult = array();
     }
     return $wrapperResult;
 }
コード例 #10
0
ファイル: Ping.php プロジェクト: FTeichmann/Erfurt
 private function _getWrapper($wrapperName)
 {
     if ($this->_wrapperRegistry === null) {
         Erfurt_Wrapper_Registry::reset();
         $this->_wrapperRegistry = Erfurt_Wrapper_Registry::getInstance();
     }
     $wrapper = $this->_wrapperRegistry->getWrapperInstance($wrapperName);
     if ($this->_httpAdapter !== null) {
         $wrapper->setHttpAdapter($this->_httpAdapter);
     }
     return $wrapper;
 }