public function onBeforeInitController()
 {
     // Translation hack in order to enable the plugin to translate...
     $translate = $this->owApp->translate;
     $translate->addTranslation($this->_pluginRoot . 'languages', null, array('scan' => Zend_Translate::LOCALE_FILENAME));
     $locale = $this->owApp->getConfig()->languages->locale;
     $translate->setLocale($locale);
     $appMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('application');
     $extrasMenu = $appMenu->getSubMenu('Extras');
     $lanMenuEntry = $translate->_('Select Language', $this->owApp->config->languages->locale);
     $lanMenue = new OntoWiki_Menu();
     $request = new OntoWiki_Request();
     $getRequest = $request->getRequestUri();
     foreach ($this->_supportedLanguages as $key => $value) {
         $getRequest = str_replace("&lang=" . $key, "", $getRequest);
         $getRequest = str_replace("?lang=" . $key, "", $getRequest);
     }
     foreach ($this->_supportedLanguages as $key => $value) {
         $url = $getRequest . (strpos($getRequest, "?") ? "&" : "?") . "lang=" . $key;
         $lanMenue->appendEntry($translate->_($value, $this->owApp->config->languages->locale), $url);
     }
     $extrasMenu->setEntry($lanMenuEntry, $lanMenue);
 }
示例#2
0
 /**
  * Create the (context) menu for classes and fill it with its default entries
  */
 private function _getClassMenu($resource = null)
 {
     $owApp = OntoWiki::getInstance();
     $classMenu = new OntoWiki_Menu();
     $query = Erfurt_Sparql_SimpleQuery::initWithString('SELECT *
          FROM <' . (string) $owApp->selectedModel . '>
          WHERE {
             <' . $resource . '> a ?type  .
          }');
     $results[] = $owApp->erfurt->getStore()->sparqlQuery($query);
     $query = Erfurt_Sparql_SimpleQuery::initWithString('SELECT *
          FROM <' . (string) $owApp->selectedModel . '>
          WHERE {
             ?inst a <' . $resource . '> .
          } LIMIT 2');
     if (count($owApp->erfurt->getStore()->sparqlQuery($query)) > 0) {
         $hasInstances = true;
     } else {
         $hasInstances = false;
     }
     $typeArray = array();
     foreach ($results[0] as $row) {
         $typeArray[] = $row['type'];
     }
     if (in_array(EF_RDFS_CLASS, $typeArray) || in_array(EF_OWL_CLASS, $typeArray) || $hasInstances) {
         $url = new OntoWiki_Url(array('action' => 'list'), array());
         $url->setParam('class', $resource, false);
         $url->setParam('init', "true", true);
         $classMenu->appendEntry('List Instances', (string) $url);
         // add class menu entries
         if ($owApp->erfurt->getAc()->isModelAllowed('edit', $owApp->selectedModel)) {
             $classMenu->appendEntry('Create Instance', "javascript:createInstanceFromClassURI('{$resource}');");
         }
     }
     return $classMenu;
 }