public function __construct() { if (Erfurt_App::getInstance()->getAc()->isActionAllowed('ExtensionConfiguration')) { $owApp = OntoWiki::getInstance(); $translate = $owApp->translate; $url = new OntoWiki_Url(array('controller' => 'exconf', 'action' => 'list'), array()); $extrasMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('application')->getSubMenu('Extras'); $extrasMenu->setEntry($translate->_('Configure Extensions'), (string) $url); } }
public function init() { // TODO: register menu entry $menuRegistry = ''; //Adding MenuEntries on the basis of the private plugin configuration $appMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('application'); $extrasMenu = $appMenu->getSubMenu('Extras'); #$extrasMenu->appendEntry( # $this->_owApp->translate->_('Import CSV Data', $this->_owApp->config->languages->locale), # new OntoWiki_Url(array('controller' => 'csvimport'), array() ) #); }
/** * */ public function __construct() { $owApp = OntoWiki::getInstance(); $translate = $owApp->translate; $extrasMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('application')->getSubMenu('Extras'); // If a model is selected, add entry to analyze action if (true === isset(OntoWiki::getInstance()->selectedModel)) { $extrasMenu->setEntry($translate->_('ApplicationExtrasMenu_Label'), (string) new OntoWiki_Url(array('controller' => 'cubeviz', 'action' => 'analyze'), array())); } // add entry to comparing action $extrasMenu->setEntry($translate->_('ApplicationExtrasMenu_ComparingLabel'), (string) new OntoWiki_Url(array('controller' => 'cubeviz', 'action' => 'compare'), array())); }
public function __construct() { $owApp = OntoWiki::getInstance(); // if a model has been selected if ($owApp->selectedModel) { // register with extras menu $translate = $owApp->translate; $url = new OntoWiki_Url(array('controller' => 'queries', 'action' => 'editor')); $extrasMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('application')->getSubMenu('Extras'); $extrasMenu->setEntry($translate->_('Queries'), (string) $url); //$extrasMenu->setEntry('Query Builder', (string) $url); } }
public function init() { $this->view->headScript()->appendFile($this->view->moduleUrl . 'modellist.js'); $menuRegistry = OntoWiki_Menu_Registry::getInstance(); $menuRegistry->getMenu('application')->getSubMenu('View')->setEntry('Hide Knowledge Bases Box', '#'); $this->session = new Zend_Session_Namespace(_OWSESSION); $this->allGraphUris = $this->_store->getAvailableModels(true); $this->visibleGraphUris = $this->_store->getAvailableModels(false); if (isset($this->session->showHiddenGraphs) && $this->session->showHiddenGraphs == true) { $this->graphUris = $this->allGraphUris; } else { $this->graphUris = $this->visibleGraphUris; } }
public function createConfigurationView($urlBase) { $ontowiki = OntoWiki::getInstance(); $model = $ontowiki->selectedModel; $this->view->scovo = true; $this->view->placeholder('main.window.title')->append('Import CSV Data'); $this->view->actionUrl = $urlBase . 'csvimport/mapping'; $this->view->salt = hash("md5", serialize($this->parsedFile)); OntoWiki_Navigation::disableNavigation(); if ($model->isEditable()) { $toolbar = $ontowiki->toolbar; $toolbar->appendButton(OntoWiki_Toolbar::ADD, array('name' => 'Add Dimension', 'id' => 'btn-add-dimension'))->appendButton(OntoWiki_Toolbar::ADD, array('name' => 'Add Attribute', 'id' => 'btn-attribute', 'class' => ''))->appendButton(OntoWiki_Toolbar::EDIT, array('name' => 'Select Data Range', 'id' => 'btn-datarange', 'class' => ''))->appendButton(OntoWiki_Toolbar::SEPARATOR)->appendButton(OntoWiki_Toolbar::SUBMIT, array('name' => 'Extract Triples', 'id' => 'extract'))->appendButton(OntoWiki_Toolbar::RESET, array('name' => 'Cancel')); $this->view->placeholder('main.window.toolbar')->set($toolbar); $configurationMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('Configurations'); $i = 0; $pattern = '/\'/i'; $replacement = "\\'"; $this->view->configs = array(); if (isset($this->storedConfigurations)) { foreach ($this->storedConfigurations as $configNum => $config) { $this->view->configs[$i] = preg_replace($pattern, $replacement, $config['config']); $configurationMenu->prependEntry('Select ' . $config['label'], 'javascript:useCSVConfiguration(csvConfigs[' . $i . '])'); $i++; } } $menu = new OntoWiki_Menu(); $menu->setEntry('Configurations', $configurationMenu); $event = new Erfurt_Event('onCreateMenu'); $event->menu = $configurationMenu; $this->view->placeholder('main.window.menu')->set($menu->toArray(false, true)); } else { $ontowiki->appendMessage(); } $this->view->table = $this->view->partial('partials/table.phtml', array('data' => $this->parsedFile, 'tableClass' => 'csvimport')); # $this->viewElements = array( # 'table' => array( # 'template' => 'partials/table.phtml', # 'data' => array( # 'data' => $this->parsedFile, # 'tableClass' => 'csvimport' # ) # ) # ); }
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); }
/** * Displays all preoperties and values for a resource, denoted by parameter */ public function propertiesAction() { $this->_addLastModifiedHeader(); $store = $this->_owApp->erfurt->getStore(); $graph = $this->_owApp->selectedModel; $resource = $this->_owApp->selectedResource; $navigation = $this->_owApp->navigation; $translate = $this->_owApp->translate; // add export formats to resource menu $resourceMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('resource'); $menu = new OntoWiki_Menu(); $menu->setEntry('Resource', $resourceMenu); $event = new Erfurt_Event('onCreateMenu'); $event->menu = $resourceMenu; $event->resource = $this->_owApp->selectedResource; $event->model = $this->_owApp->selectedModel; $event->trigger(); $event = new Erfurt_Event('onPropertiesAction'); $event->uri = (string) $resource; $event->graph = $this->_owApp->selectedModel->getModelUri(); $event->trigger(); // Give plugins a chance to add entries to the menu $this->view->placeholder('main.window.menu')->set($menu->toArray(false, true)); $title = $resource->getTitle($this->_config->languages->locale) ? $resource->getTitle($this->_config->languages->locale) : OntoWiki_Utils::contractNamespace((string) $resource); $windowTitle = sprintf($translate->_('Properties of %1$s'), $title); $this->view->placeholder('main.window.title')->set($windowTitle); if (!empty($resource)) { $event = new Erfurt_Event('onPreTabsContentAction'); $event->uri = (string) $resource; $result = $event->trigger(); if ($result) { $this->view->preTabsContent = $result; } $event = new Erfurt_Event('onPrePropertiesContentAction'); $event->uri = (string) $resource; $result = $event->trigger(); if ($result) { $this->view->prePropertiesContent = $result; } $model = new OntoWiki_Model_Resource($store, $graph, (string) $resource); $values = $model->getValues(); $predicates = $model->getPredicates(); // new trigger onPropertiesActionData to work with data (reorder with plugin) $event = new Erfurt_Event('onPropertiesActionData'); $event->uri = (string) $resource; $event->predicates = $predicates; $event->values = $values; $result = $event->trigger(); if ($result) { $predicates = $event->predicates; $values = $event->values; } $titleHelper = new OntoWiki_Model_TitleHelper($graph); // add graphs $graphs = array_keys($predicates); $titleHelper->addResources($graphs); // set RDFa widgets update info for editable graphs and other graph info $graphInfo = array(); $editableFlags = array(); foreach ($graphs as $g) { $graphInfo[$g] = $titleHelper->getTitle($g, $this->_config->languages->locale); if ($this->_erfurt->getAc()->isModelAllowed('edit', $g)) { $editableFlags[$g] = true; $this->view->placeholder('update')->append(array('sourceGraph' => $g, 'queryEndpoint' => $this->_config->urlBase . 'sparql/', 'updateEndpoint' => $this->_config->urlBase . 'update/')); } else { $editableFlags[$g] = false; } } $this->view->graphs = $graphInfo; $this->view->editableFlags = $editableFlags; $this->view->values = $values; $this->view->predicates = $predicates; $this->view->resourceUri = (string) $resource; $this->view->graphUri = $graph->getModelIri(); $this->view->graphBaseUri = $graph->getBaseIri(); $this->view->editable = false; // use $this->editableFlags[$graph] now // prepare namespaces $namespacePrefixes = $graph->getNamespacePrefixes(); $graphBase = $graph->getBaseUri(); if (!array_key_exists(OntoWiki_Utils::DEFAULT_BASE, $namespacePrefixes)) { $namespacePrefixes[OntoWiki_Utils::DEFAULT_BASE] = $graphBase; } $this->view->namespacePrefixes = $namespacePrefixes; } $toolbar = $this->_owApp->toolbar; // show only if not forwarded and if model is writeable // TODO: why is isEditable not false here? if ($this->_request->getParam('action') == 'properties' && $graph->isEditable() && $this->_owApp->erfurt->getAc()->isModelAllowed('edit', $this->_owApp->selectedModel)) { // TODO: check acl $toolbar->appendButton(OntoWiki_Toolbar::EDIT, array('name' => 'Edit Properties', 'title' => 'SHIFT + ALT + e')); $toolbar->appendButton(OntoWiki_Toolbar::EDITADD, array('name' => 'Clone', 'class' => 'clone-resource', 'title' => 'SHIFT + ALT + l')); // ->appendButton(OntoWiki_Toolbar::EDITADD, array('name' => 'Add Property', 'class' => 'property-add')); $params = array('name' => 'Delete', 'url' => $this->_config->urlBase . 'resource/delete/?r=' . urlencode((string) $resource)); $toolbar->appendButton(OntoWiki_Toolbar::SEPARATOR); $toolbar->appendButton(OntoWiki_Toolbar::DELETE, $params); $toolbar->prependButton(OntoWiki_Toolbar::SEPARATOR); $toolbar->prependButton(OntoWiki_Toolbar::ADD, array('name' => 'Add Property', '+class' => 'property-add', 'title' => 'SHIFT + ALT + a')); $toolbar->prependButton(OntoWiki_Toolbar::SEPARATOR); $toolbar->prependButton(OntoWiki_Toolbar::CANCEL, array('+class' => 'hidden', 'title' => 'SHIFT + ALT + c')); $toolbar->prependButton(OntoWiki_Toolbar::SAVE, array('+class' => 'hidden', 'title' => 'SHIFT + ALT + s')); } // let plug-ins add buttons $toolbarEvent = new Erfurt_Event('onCreateToolbar'); $toolbarEvent->resource = (string) $resource; $toolbarEvent->graph = (string) $graph; $toolbarEvent->toolbar = $toolbar; $eventResult = $toolbarEvent->trigger(); if ($eventResult instanceof OntoWiki_Toolbar) { $toolbar = $eventResult; } // add toolbar $this->view->placeholder('main.window.toolbar')->set($toolbar); //show modules $this->addModuleContext('main.window.properties'); }
/** * Event handler method, which is called whenever the property view of * a resource will be displayed. Adds the location bar to the menu and * adds a message if a resource is configured for sync. * * @param Erfurt_Event $event * * @return bool */ public function onPropertiesAction($event) { $translate = OntoWiki::getInstance()->translate; $session = new Zend_Session_Namespace(_OWSESSION); // Add the location bar menu entry. $menu = OntoWiki_Menu_Registry::getInstance()->getMenu('resource'); $menu->prependEntry(OntoWiki_Menu::SEPARATOR); if ($session->showLocationBar === false) { $entry = $translate->_('Show/Hide Location Bar'); $menu->prependEntry($entry, array('class' => 'location_bar show')); } else { $entry = $translate->_('Show/Hide Location Bar'); $menu->prependEntry($entry, array('class' => 'location_bar')); } $uri = $event->uri; $modelUri = $event->graph; if ((bool) $this->_privateConfig->sync->enabled) { $syncConfig = $this->_getSyncConfig($uri, 'linkeddata', $modelUri); } else { $syncConfig = false; } if ($syncConfig === false || $syncConfig['checkHasChanged'] === false) { return false; } // Thre resource is configured for sync, so show a message box. $message = '<span id="dg_check_update" > <span id="dg_configured_text">' . $translate->_('This Resource is configured for Sync') . '.' . '</span>' . '<span id="dg_updated_text" style="display: none">' . $translate->_('This Resource has changed since last sync') . '.' . '</span> <br />'; $message .= '<span style="font-size:0.8em; font-weight: bold">'; if (isset($syncConfig['lastSyncDateTime'])) { $message .= $translate->_('Last Sync') . ': ' . date('r', strtotime($syncConfig['lastSyncDateTime'])); $message .= '<br />'; } $message .= '<span id="dg_lastmod_text" style="display: none">' . $translate->_('Last Modified') . ': ' . '<span id="dg_lastmod_date"> </span> </span>'; $message .= '</span>'; $message .= '<a id="dg_sync_button" class="minibutton"' . ' style="display: none; float: right; min-height: 20px; padding-top: 8px">'; $message .= $translate->_('Sync') . '</a>'; $message .= '</span>'; OntoWiki::getInstance()->appendMessage(new OntoWiki_Message($message, OntoWiki_Message::INFO, array('escape' => false))); return true; }
/** * Returns the menu of the module * * @return string */ public function getMenu() { return OntoWiki_Menu_Registry::getInstance()->getMenu('application'); }
/** * Menu Action to generate JSON serializations of OntoWiki_Menu for context-, module-, component-menus */ public function menuAction() { $module = $this->_request->getParam('module'); $resource = $this->_request->getParam('resource'); $model = $this->_request->getParam('model'); $translate = $this->_owApp->translate; // create empty menu first $menuRegistry = OntoWiki_Menu_Registry::getInstance(); if (!empty($resource)) { $menu = $menuRegistry->getMenu('resource', $resource); } else { if (!empty($model)) { $menu = $menuRegistry->getMenu('model', $model); } } if (!empty($module)) { $moduleRegistry = OntoWiki_Module_Registry::getInstance(); $menu = $moduleRegistry->getModule($module)->getContextMenu(); } // Fire a event; $event = new Erfurt_Event('onCreateMenu'); $event->menu = $menu; $event->resource = $resource; if (!empty($model)) { $event->isModel = true; $event->model = $model; } else { $event->model = $this->_owApp->selectedModel; } $event->trigger(); echo $menu->toJson(); }