diff --git a/.gitignore b/.gitignore index 66234bb9b..0b5887796 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ build/ # vagrant stuff Vagrantfile .vagrant + +# export folder +dumps/ diff --git a/.gitmodules b/.gitmodules index aeabfa427..53cb2d72e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,48 @@ [submodule "libraries/RDFauthor"] path = libraries/RDFauthor - url = git://github.com/AKSW/RDFauthor.git + url = https://github.com/amsl-project/RDFauthor.git [submodule "libraries/Erfurt"] path = libraries/Erfurt - url = git://github.com/AKSW/Erfurt.git + url = https://github.com/amsl-project/Erfurt.git +[submodule "extensions/contextinfo"] + path = extensions/contextinfo + url = https://github.com/AKSW/contextinfo.ontowiki.git +[submodule "extensions/imagehelper"] + path = extensions/imagehelper + url = https://github.com/amsl-project/imagehelper.ontowiki.git +[submodule "extensions/issnimporter"] + path = extensions/issnimporter + url = https://github.com/amsl-project/issnimporter.ontowiki.git +[submodule "extensions/fulltextsearch"] + path = extensions/fulltextsearch + url = https://github.com/amsl-project/fulltextsearch.ontowiki.git +[submodule "extensions/listexporter"] + path = extensions/listexporter + url = https://github.com/amsl-project/listexporter.ontowiki.git +[submodule "extensions/counterimporter"] + path = extensions/counterimporter + url = https://github.com/amsl-project/counterimporter.ontowiki.git +[submodule "extensions/jsloader"] + path = extensions/jsloader + url = https://github.com/amsl-project/jsloader.ontowiki.git +[submodule "extensions/statements"] + path = extensions/statements + url = https://github.com/amsl-project/statements.ontowiki.git +[submodule "extensions/files"] + path = extensions/files + url = https://github.com/amsl-project/files.ontowiki.git +[submodule "extensions/linkandcreate"] + path = extensions/linkandcreate + url = https://github.com/amsl-project/linkandcreate.ontowiki.git +[submodule "sample-data"] + path = sample-data + url = https://github.com/amsl-project/sample-data.git +[submodule "extensions/jobcenter"] + path = extensions/jobcenter + url = https://github.com/amsl-project/jobcenter.ontowiki.git +[submodule "extensions/template"] + path = extensions/template + url = https://github.com/amsl-project/template.ontowiki.git +[submodule "extensions/deadlinehelper"] + path = extensions/deadlinehelper + url = https://github.com/amsl-project/deadlinehelper.ontowiki.git diff --git a/.htaccess b/.htaccess index 491d87274..936b76299 100644 --- a/.htaccess +++ b/.htaccess @@ -3,7 +3,12 @@ # WARNING: If you do not use the htaccess at all or your htaccess is # ignored, then your config.ini can be loaded over the web !!! - Deny from all + + Deny from all + + + Require all denied + # OntoWiki does not requires Apache's rewrite engine to work. However, diff --git a/Makefile b/Makefile index 6c5964e5f..b969f2d46 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ help: @echo " pull ....................... 'git pull' for all repos" @echo " fetch ...................... 'git fetch' for all repos" @echo " fetch-all .................. 'git fetch --all', i.e. fetch all repos on all remotes" - @echo " add-upstream ............... Adds standard AKSW git repo as remote/upstream" + @echo " add-upstream ............... Adds standard amsl-project git repo as remote/upstream" @echo " status ..................... 'git status' for all repos" @echo " branch-check ............... 'git rev-parse' for all repos" @echo " clean ...................... Deletes all log and cache files" @@ -108,14 +108,14 @@ libraries: zend submodules-developer submodules: # read-only git submodule init - git config submodule.libraries/Erfurt.url "https://github.com/AKSW/Erfurt.git" - git config submodule.libraries/RDFauthor.url "https://github.com/AKSW/RDFauthor.git" + git config submodule.libraries/Erfurt.url "https://github.com/amsl-project/Erfurt.git" + git config submodule.libraries/RDFauthor.url "https://github.com/amsl-project/RDFauthor.git" git submodule update submodules-developer: # read-write git submodule init - git config submodule.libraries/Erfurt.url "git@github.com:AKSW/Erfurt.git" - git config submodule.libraries/RDFauthor.url "git@github.com:AKSW/RDFauthor.git" + git config submodule.libraries/Erfurt.url "git@github.com:amsl-project/Erfurt.git" + git config submodule.libraries/RDFauthor.url "git@github.com:amsl-project/RDFauthor.git" git submodule update # developer targets @@ -135,7 +135,7 @@ fetch-all: git submodule foreach git fetch --all add-upstream: - git remote add upstream git://github.com/AKSW/OntoWiki.git + git remote add upstream git://github.com/amsl-project/OntoWiki.git info: @git --no-pager log -1 --oneline --decorate @@ -172,7 +172,7 @@ zend2: rdfauthor: rm -rf libraries/RDFauthor @echo 'Cloning RDFauthor into libraries/RDFauthor ...' - git clone git@github.com:AKSW/RDFauthor.git libraries/RDFauthor + git clone git@github.com:amsl-project/RDFauthor.git libraries/RDFauthor # test stuff @@ -229,7 +229,7 @@ install-test-environment: erfurt@: rm -rf libraries/Erfurt @echo 'Cloning Erfurt into libraries/Erfurt ...' - git clone git@github.com:AKSW/Erfurt.git libraries/Erfurt + git clone git@github.com:amsl-project/Erfurt.git libraries/Erfurt odbctest: @application/scripts/odbctest.php @@ -319,3 +319,24 @@ endif list-events: @grep -R "new Erfurt_Event" * 2> /dev/null | sed "s/.*new Erfurt_Event('//;s/');.*//" | sort -u + +make amsl-update: + git fetch --all + git checkout origin/develop + git submodule init + git submodule sync + git submodule update + +data-init: + sh -c "$(PWD)/application/scripts/clean.sh $(PWD)" + sh -c "$(PWD)/application/scripts/init.sh $(PWD)" + sh -c "$(PWD)/application/scripts/vocab.sh $(PWD)" + +clean-virtuoso: + sh -c "$(PWD)/application/scripts/clean.sh $(PWD)" + +amsl-vocab: + sh -c "$(PWD)/application/scripts/vocab.sh $(PWD)" + +export-virtuoso: + sh -c "$(PWD)/application/scripts/export.sh $(PWD)" diff --git a/application/classes/OntoWiki/Controller/ActionHelper/List.php b/application/classes/OntoWiki/Controller/ActionHelper/List.php index 63fa97519..44717d544 100644 --- a/application/classes/OntoWiki/Controller/ActionHelper/List.php +++ b/application/classes/OntoWiki/Controller/ActionHelper/List.php @@ -127,13 +127,20 @@ public function addList( $other = new stdClass(); } + $config = $this->_owApp->config; + $listHeading = ''; + if (($config->lists) && $config->lists->showHeading === "true") { + $listHeading = $list->getTitle(); + } + $renderedList = $view->partial( 'partials/list.phtml', array( 'listName' => $listName, 'instances' => $list, 'mainTemplate' => $mainTemplate, - 'other' => $other + 'other' => $other, + 'heading' => $listHeading ) ); diff --git a/application/classes/OntoWiki/Controller/Base.php b/application/classes/OntoWiki/Controller/Base.php index 6602ab341..918eb3121 100644 --- a/application/classes/OntoWiki/Controller/Base.php +++ b/application/classes/OntoWiki/Controller/Base.php @@ -126,7 +126,10 @@ public function init() var themeUrlBase = "' . $this->_config->themeUrlBase . '"; var _OWSESSION = "' . _OWSESSION . '"; var RDFAUTHOR_BASE = "' . $this->_config->staticUrlBase . 'libraries/RDFauthor/"; - var RDFAUTHOR_VIEW_MODE = "' . $viewMode . '";' . PHP_EOL; + var RDFAUTHOR_LANGUAGE = "' . $this->_config->languages->locale . '"; + var RDFAUTHOR_VIEW_MODE = "' . $viewMode . '"; + var RDFAUTHOR_DATATYPES_FIX = {};' + . PHP_EOL; if (defined('_OWDEBUG')) { $this->view->jsonVars .= ' var RDFAUTHOR_DEBUG = 1;'; diff --git a/application/classes/OntoWiki/Controller/Plugin/ListSetupHelper.php b/application/classes/OntoWiki/Controller/Plugin/ListSetupHelper.php index 3ff48f442..7a20bb9ad 100644 --- a/application/classes/OntoWiki/Controller/Plugin/ListSetupHelper.php +++ b/application/classes/OntoWiki/Controller/Plugin/ListSetupHelper.php @@ -96,7 +96,7 @@ public function routeShutdown(Zend_Controller_Request_Abstract $request) || isset($request->init) ) { // instantiate model, that selects all resources - $list = new OntoWiki_Model_Instances($store, $ontoWiki->selectedModel, array()); + $list = new OntoWiki_Model_Instances($store, $ontoWiki->selectedModel, array(), $request->title); } else { // use the object from the session if (isset($request->list) && $request->list != $listHelper->getLastListName()) { @@ -113,34 +113,18 @@ public function routeShutdown(Zend_Controller_Request_Abstract $request) $list->setStore($store); // store is not serialized in session! reset it } - //local function :) - function _json_decode($string) - { - /* PHP 5.3 DEPRECATED ; REMOVE IN PHP 6.0 */ - if (get_magic_quotes_gpc()) { - // add slashes for unicode chars in json - $string = str_replace('\\u', '\\\\u', $string); - //$string = str_replace('\\u000a','', $string); - $string = stripslashes($string); - } - - /* ---- */ + // load instances config + $config = []; - return json_decode($string, true); + if (isset($request->instancesconfig)) { + $config = json_decode($request->instancesconfig, true); + if ($config === null) { + throw new OntoWiki_Exception('Invalid parameter instancesconfig (json_decode failed)'); + } } //a shortcut for search param if (isset($request->s)) { - if (isset($request->instancesconfig)) { - $config = _json_decode($request->instancesconfig); - if (null === $config) { - throw new OntoWiki_Exception( - 'Invalid parameter instancesconfig (json_decode failed): ' . $this->_request->setup - ); - } - } else { - $config = array(); - } if (!isset($config['filter'])) { $config['filter'] = array(); } @@ -153,16 +137,6 @@ function _json_decode($string) } //a shortcut for class param if (isset($request->class)) { - if (isset($request->instancesconfig)) { - $config = _json_decode($request->instancesconfig); - if (null === $config) { - throw new OntoWiki_Exception( - 'Invalid parameter instancesconfig (json_decode failed): ' . $this->_request->setup - ); - } - } else { - $config = array(); - } if (!isset($config['filter'])) { $config['filter'] = array(); } @@ -174,22 +148,72 @@ function _json_decode($string) $request->setParam('instancesconfig', json_encode($config)); } - //check for change-requests - if (isset($request->instancesconfig)) { - $config = _json_decode($request->instancesconfig); - if (null === $config) { - throw new OntoWiki_Exception('Invalid parameter instancesconfig (json_decode failed)'); + // check if we have the property configuration saved + $modelIri = $ontoWiki->selectedModel->getModelIri(); + $listName = $list->getTitle(); + + $session = new Zend_Session_Namespace('ONTOWIKI_USER_PROFILE'); + + // retrieve session + if (isset($session->config)) { + $persConfig = $session->config; + + // set empty default config, if this list is not configured + if (!array_key_exists($modelIri, $persConfig)) + $persConfig[$modelIri] = [$listName => []]; + + if (!array_key_exists($listName, $persConfig[$modelIri])) + $persConfig[$modelIri][$listName] = []; + } + else { + $persConfig = [$modelIri => [$listName => []]]; + } + + $listConfig = $persConfig[$modelIri][$listName]; + + // init list configuration with saved config + if (array_key_exists('shownProperties', $listConfig) && !empty($listConfig['shownProperties']) && empty($list->getShownPropertiesPlain())) { + $config['shownProperties'] = []; + + // mark following properties to be added + foreach ($listConfig['shownProperties'] as $prop) { + $config['shownProperties'][] = ['uri' => $prop['uri'], 'label' => $prop['name'], 'inverse' => $prop['inverse'], 'action' => 'add']; } -// TODO is this a bug? why access sort->asc when it is null? + } + + if (array_key_exists('sort', $listConfig) && !empty($listConfig['sort']) && empty($list->getShownPropertiesPlain())) { + $config['sort'] = $listConfig['sort']; + } + + // check for change-requests + if (!empty($config)) { if (isset($config['sort'])) { - if ($config['sort'] == null) { - $list->orderByUri($config['sort']['asc']); - } else { - $list->setOrderProperty($config['sort']['uri'], $config['sort']['asc']); + if ($config['sort'] !== null) + $sortParam = $config['sort']['uri']; + $query = new Erfurt_Sparql_SimpleQuery(); + $query->setProloguePart('SELECT DISTINCT ?range') + ->setWherePart('WHERE { <' . $sortParam . '> ?range . }'); + + $result = $store->sparqlQuery($query); + if(array_key_exists("0", $result)) { + if ($result[0]['range'] === "http://www.w3.org/2001/XMLSchema#integer" || $result[0]['range'] === "http://www.w3.org/2001/XMLSchema#decimal") { + $_SESSION['ONTOWIKI']['StringSort'] = false; + } else { + $_SESSION['ONTOWIKI']['StringSort'] = true; + } } + $list->setOrderProperty($config['sort']['uri'], $config['sort']['asc']); + + $listConfig['sort'] = $config['sort']; + } else { + // $listConfig['sort'] = []; + $listConfig['sort'] = array('uri' => 'http://www.w3.org/2000/01/rdf-schema#label' , 'asc' => 'true'); + $list->setOrderProperty($listConfig['sort']['uri'], $listConfig['sort']['asc']); } if (isset($config['shownProperties'])) { + + // add or remove property from list foreach ($config['shownProperties'] as $prop) { if ($prop['action'] == 'add') { $list->addShownProperty($prop['uri'], $prop['label'], $prop['inverse']); @@ -197,6 +221,9 @@ function _json_decode($string) $list->removeShownProperty($prop['uri'], $prop['inverse']); } } + + // get current list property configuration and persist it + $listConfig['shownProperties'] = $list->getShownPropertiesPlain(); } if (isset($config['filter'])) { @@ -210,59 +237,61 @@ function _json_decode($string) } if ($filter['action'] == 'add') { - if ($filter['mode'] == 'box') { - $list->addFilter( - $filter['property'], - isset($filter['isInverse']) ? $filter['isInverse'] : false, - isset($filter['propertyLabel']) ? $filter['propertyLabel'] : 'defaultLabel', - $filter['filter'], - isset($filter['value1']) ? $filter['value1'] : null, - isset($filter['value2']) ? $filter['value2'] : null, - isset($filter['valuetype']) ? $filter['valuetype'] : 'literal', - isset($filter['literaltype']) ? $filter['literaltype'] : null, - isset($filter['hidden']) ? $filter['hidden'] : false, - isset($filter['id']) ? $filter['id'] : null, - isset($filter['negate']) ? $filter['negate'] : false - ); - } else { - if ($filter['mode'] == 'search') { + + switch ($filter['mode']) { + case 'box': + $list->addFilter( + $filter['property'], + isset($filter['isInverse']) ? $filter['isInverse'] : false, + isset($filter['propertyLabel']) ? $filter['propertyLabel'] : 'defaultLabel', + $filter['filter'], + isset($filter['value1']) ? $filter['value1'] : null, + isset($filter['value2']) ? $filter['value2'] : null, + isset($filter['valuetype']) ? $filter['valuetype'] : 'literal', + isset($filter['literaltype']) ? $filter['literaltype'] : null, + isset($filter['hidden']) ? $filter['hidden'] : false, + isset($filter['id']) ? $filter['id'] : null, + isset($filter['negate']) ? $filter['negate'] : false + ); + break; + case 'search': $list->addSearchFilter( $filter['searchText'], isset($filter['id']) ? $filter['id'] : null ); - } else { - if ($filter['mode'] == 'rdfsclass') { - $list->addTypeFilter( - $filter['rdfsclass'], - isset($filter['id']) ? $filter['id'] : null - ); - } else { - if ($filter['mode'] == 'cnav') { + break; + case 'rdfsclass': + $list->addTypeFilter( + $filter['rdfsclass'], + isset($filter['id']) ? $filter['id'] : null + ); + break; + case 'cnav': + $list->addTripleFilter( + NavigationHelper::getInstancesTriples($filter['uri'], $filter['cnav']), + isset($filter['id']) ? $filter['id'] : null + ); + break; + case 'query': + try { + //echo $filter->query." "; + $query = Erfurt_Sparql_Query2::initFromString($filter['query']); + // TODO what the hell is this?! + if (!($query instanceof Exception)) { $list->addTripleFilter( - NavigationHelper::getInstancesTriples($filter['uri'], $filter['cnav']), + $query->getWhere()->getElements(), isset($filter['id']) ? $filter['id'] : null ); - } else { - if ($filter['mode'] == 'query') { - try { - //echo $filter->query." "; - $query = Erfurt_Sparql_Query2::initFromString($filter['query']); -// TODO what the hell is this?! - if (!($query instanceof Exception)) { - $list->addTripleFilter( - $query->getWhere()->getElements(), - isset($filter['id']) ? $filter['id'] : null - ); - } - //echo $query->getSparql(); - } catch (Erfurt_Sparql_ParserException $e) { - $ontoWiki->appendMessage('the query could not be parsed'); - } - } } + //echo $query->getSparql(); + } catch (Erfurt_Sparql_ParserException $e) { + $ontoWiki->appendMessage('the query could not be parsed'); } - } + break; + default: + throw new OntoWiki_Exception('Invalid filter mode for list!'); } + } else { $list->removeFilter($filter['id']); } @@ -282,10 +311,14 @@ function _json_decode($string) } } + // persist config + $persConfig[$modelIri][$listName] = $listConfig; + $session->config = $persConfig; + if (isset($request->limit)) { // how many results per page $list->setLimit($request->limit); } else { - $list->setLimit(10); + $list->setLimit(30); } if (isset($request->p)) { // p is the page number $list->setOffset( diff --git a/application/classes/OntoWiki/Menu/Registry.php b/application/classes/OntoWiki/Menu/Registry.php index 250078b8e..66ac2f911 100644 --- a/application/classes/OntoWiki/Menu/Registry.php +++ b/application/classes/OntoWiki/Menu/Registry.php @@ -293,7 +293,7 @@ private function _getModelMenu($model = null) $modelMenu->appendEntry( 'Delete Knowledge Base', - (string)$url + "javascript:deleteModelDialog('$url')" ); } @@ -419,19 +419,6 @@ private function _getClassMenu($resource = null) ); $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; diff --git a/application/classes/OntoWiki/Model/AbstractHelper.php b/application/classes/OntoWiki/Model/AbstractHelper.php new file mode 100644 index 000000000..205cf3bfb --- /dev/null +++ b/application/classes/OntoWiki/Model/AbstractHelper.php @@ -0,0 +1,245 @@ +_resources[$resourceUri])) { + $this->_resources[$resourceUri] = null; + } + } else { + // throw exeption in debug mode only + if (defined('_OWDEBUG')) { + $logger = OntoWiki::getInstance()->logger; + $logger->info('Supplied resource ' . htmlentities('<' . $resource . '>') . ' is not a valid URI.'); + } + } + return $this; + } + + /** + * Adds a bunch of resources for which to query the requested properties. + * @param array $resources + * @return $this + */ + public function addResources($resources = array(), $variable = null) + { + if (null === $variable) { + foreach ($resources as $resourceUri) { + $this->addResource($resourceUri); + } + } else { + foreach ($resources as $row) { + foreach ((array)$variable as $key) { + if (!empty($row[$key])) { + $object = $row[$key]; + $toBeAdded = null; + if (is_array($object)) { + // probably support extended format + if (isset($object['type']) && ($object['type'] == 'uri')) { + $toBeAdded = $object['value']; + } + } else { + // plain object + $toBeAdded = $object; + } + if ($toBeAdded != null) { + $this->addResource($toBeAdded); + } + } + } + } + } + return $this; + } + + /** + * operate on _resources array and call the method to fetch the requested properties + * if no requested properties found for the respective resource the localname will be extracted + * + * @return void + */ + protected function _receiveRequestetProperties() + { + //first we check if there are resourceUris without the requested property + $toBeReceived = array(); + foreach ($this->_resources as $resourceUri => $resource) { + if ($resource == null) { + $toBeReceived[] = $resourceUri; + } + } + //now we try to receive the requested properties from ResourcePool + $this->_fetchRequestedPropertiesFromResourcePool($toBeReceived); + + // if nothing found fetch fallback properties, if implemented + $this->_fetchFallbackProperties(); + + } + + /** + * Fallback method in case we dont find the requested properties. + */ + abstract protected function _fetchFallbackProperties(); + + /** + * fetches all requested properties according the given array if Uris + * + * @param array resourceUris + */ + protected function _fetchRequestedPropertiesFromResourcePool($resourceUris) + { + $resourcePool = $this->_erfurtApp->getResourcePool(); + if (!empty($this->_model)) { + $modelUri = $this->_model->getModelIri(); + $resources = $resourcePool->getResources($resourceUris, $modelUri); + } else { + $resources = $resourcePool->getResources($resourceUris); + } + + $memoryModel = new Erfurt_Rdf_MemoryModel(); + foreach ($resources as $resourceUri => $resource) { + $resourceDescription = $resource->getDescription(); + $memoryModel->addStatements($resourceDescription); + foreach ($this->_requestedProperties as $requestedProperty) { + $values = $memoryModel->getValues($resourceUri, $requestedProperty); + foreach ($values as $value) { + if (!empty($value['lang'])) { + $language = $value['lang']; + } else { + $language = ''; + } + $this->_resources[$resourceUri][$requestedProperty][$language] = $value['value']; + } + } + } + } + + /** + * Returns the requested property for the resource URI in the requested language. + * + * @param string $resourceUri + * @param string $language The preferred language for the commment + * + * @return string + */ + public function getRequestedProperty($resourceUri, $language = null) + { + if (!Erfurt_Uri::check($resourceUri)) { + return $resourceUri; + } + + // * means any language + if (trim($language) == '*') { + $language = null; + } + + //Have a look if we have an entry for the given resourceUri + if (!array_key_exists($resourceUri, $this->_resources)) { + + if (defined('_OWDEBUG')) { + $logger = OntoWiki::getInstance()->logger; + $logger->info('CommentHelper: getRequestedProperty called for unknown resource. Adding resource before fetch.'); + } + //If we dont have an entry create one + $this->addResource($resourceUri); + } + + // prepend the language that is asked for to the array + // of languages we will look for + $languages = $this->_languages; + if (null !== $language) { + array_unshift($languages, (string)$language); + } + + $languages = array_values(array_unique($languages)); + + //Have a look if we have already a commment for the given resourceUri + if ($this->_resources[$resourceUri] === null) { + $this->_receiveRequestetProperties(); + } + + $foundProperty = null; + $requestedProperties = $this->_resources[$resourceUri]; + foreach ($languages as $language) { + foreach ($this->_requestedProperties as $requestedProperty) { + if (isset($requestedProperties[$requestedProperty][$language]) && !empty($requestedProperties[$requestedProperty][$language])) { + $foundProperty = $requestedProperties[$requestedProperty][$language]; + break(2); + } + } + } + return $foundProperty; + } + + /** + * Resets the helper, emptying all resources, results and queries stored + */ + abstract public function reset(); + +} \ No newline at end of file diff --git a/application/classes/OntoWiki/Model/DescriptionHelper.php b/application/classes/OntoWiki/Model/DescriptionHelper.php new file mode 100644 index 000000000..1415039de --- /dev/null +++ b/application/classes/OntoWiki/Model/DescriptionHelper.php @@ -0,0 +1,112 @@ +_model = $model; + } + + $this->_erfurtApp = Erfurt_App::getInstance(); + + if (null !== $store) { + $this->_store = $store; + } else { + $this->_store = $this->_erfurtApp->getStore(); + } + + if (null == $config) { + $config = OntoWiki::getInstance()->config; + } + if (is_array($config)) { + if (isset($config['descriptionHelper']['properties'])) { // naming properties for resources + $this->_requestedProperties = array_values($config['descriptionHelper']['properties']); + } else { + $this->_requestedProperties = array(); + } + } else { + if ($config instanceof Zend_Config) { + //its possible to define myProperties in config.ini + if (isset($config->descriptionHelper->myProperties)) { + $this->_requestedProperties = array_values($config->descriptionHelper->myProperties->toArray()); + } else if (isset($config->descriptionHelper->properties)) { // naming properties for resources + $this->_requestedProperties = array_values($config->descriptionHelper->properties->toArray()); + } else { + $this->_requestedProperties = array(); + } + + } else { + $this->_requestedProperties = array(); + } + } + + + if (null === $this->_languages) { + $this->_languages = array(); + } + if (isset($config->languages->locale)) { + array_unshift($this->_languages, (string)$config->languages->locale); + $this->_languages = array_unique($this->_languages); + } + + } + + /** + * Singleton instance + * + * @return OntoWiki_Model_Instance + */ + public static function getInstance() + { + if (null === self::$_instance) { + self::$_instance = new self(); + } + + return self::$_instance; + } + + /** + * Resets the helper, emptying all resources, results and queries stored + */ + public function reset() + { + $this->_resources = array(); + } + + /** + * No fallback comments + */ + protected function _fetchFallbackProperties() + { + + } +} diff --git a/application/classes/OntoWiki/Model/Instances.php b/application/classes/OntoWiki/Model/Instances.php index 5f54982c0..055dd3170 100644 --- a/application/classes/OntoWiki/Model/Instances.php +++ b/application/classes/OntoWiki/Model/Instances.php @@ -153,10 +153,16 @@ class OntoWiki_Model_Instances extends OntoWiki_Model */ protected $_titleHelper = null; + + /** + * @var string + */ + protected $_title = null; + /** * Constructor */ - public function __construct(Erfurt_Store $store, Erfurt_Rdf_Model $model, $options = array()) + public function __construct(Erfurt_Store $store, Erfurt_Rdf_Model $model, $options = array(), $title = '') { parent::__construct($store, $model); @@ -217,6 +223,8 @@ public function __construct(Erfurt_Store $store, Erfurt_Rdf_Model $model, $optio $this->_valueQuery->addFrom((string)$model); $this->_resourceQuery->addFrom((string)$model); + $this->_title = $title; + $this->invalidate(); } @@ -319,6 +327,16 @@ public function getTitleHelper() return $this->_titleHelper; } + /** + * get title + * + * @return string + */ + public function getTitle() + { + return $this->_title; + } + /** * add ?resourceUri ?p ?o to the resource query * TODO: support objects as resources? optionally? @@ -643,12 +661,12 @@ public function addFilter( break; case 'equals': if ($valuetype == 'literal') { - $valueVar = new Erfurt_Sparql_Query2_Var($propertyLabel); + $var = new Erfurt_Sparql_Query2_Var($propertyLabel); if (!$isInverse) { $triple = new Erfurt_Sparql_Query2_Triple( $this->_resourceVar, $prop, - $valueVar + $var ); } else { throw new RuntimeException( @@ -665,15 +683,15 @@ public function addFilter( $orExpression = new Erfurt_Sparql_Query2_ConditionalOrExpression(); $orExpression->addElement( new Erfurt_Sparql_Query2_UnaryExpressionNot( - new Erfurt_Sparql_Query2_bound($valueVar) + new Erfurt_Sparql_Query2_bound($var) ) ); - $orExpression->addElement(new Erfurt_Sparql_Query2_NotEquals($valueVar, $valueObj)); + $orExpression->addElement(new Erfurt_Sparql_Query2_NotEquals($var, $valueObj)); $filterObj = $optionalGP->addFilter($orExpression); } else { $filterObj = $optionalGP->addFilter( - new Erfurt_Sparql_Query2_NotEquals($valueVar, $valueObj) + new Erfurt_Sparql_Query2_NotEquals($var, $valueObj) ); } @@ -683,7 +701,7 @@ public function addFilter( $this->_resourceQuery->addElement($triple); $filterObj = $this->_resourceQuery->addFilter( new Erfurt_Sparql_Query2_Regex( - new Erfurt_Sparql_Query2_Str($valueVar), + new Erfurt_Sparql_Query2_Str($var), new Erfurt_Sparql_Query2_RDFLiteral( '^' . str_replace("\\", "\\\\", preg_quote($value)) . '$' ) @@ -692,11 +710,33 @@ public function addFilter( } } else { if (!$isInverse) { - $triple = $this->_resourceQuery->addTriple( - $this->_resourceVar, - $prop, - $valueObj - ); + if ($negate) { + $var = new Erfurt_Sparql_Query2_Var($propertyLabel); + $optionalGP = new Erfurt_Sparql_Query2_OptionalGraphPattern(); + $optionalGP->addTriple( + $this->_resourceVar, + $prop, + $var + ); + + $orExpression = new Erfurt_Sparql_Query2_ConditionalOrExpression(); + $orExpression->addElement( + new Erfurt_Sparql_Query2_UnaryExpressionNot( + new Erfurt_Sparql_Query2_bound($var) + ) + ); + $orExpression->addElement(new Erfurt_Sparql_Query2_NotEquals($var, $valueObj)); + + $this->_resourceQuery->addElement($optionalGP); + $filterObj = $this->_resourceQuery->addFilter($orExpression); + } + else { + $triple = $this->_resourceQuery->addTriple( + $this->_resourceVar, + $prop, + $valueObj + ); + } } else { $triple = $this->_resourceQuery->addTriple( $valueObj, @@ -773,7 +813,6 @@ public function addFilter( break; case 'bound': $var = new Erfurt_Sparql_Query2_Var($propertyLabel); - if (!$isInverse) { $triple = new Erfurt_Sparql_Query2_Triple( $this->_resourceVar, @@ -1212,7 +1251,7 @@ public function getPermalink($listname) } } - return $url; + return $url . "&title=" . urlencode($this->_title); } /** @@ -1556,7 +1595,11 @@ public function getAllPropertiesBySingleQuery($inverse = false) $properties[] = array('uri' => $row['resourceUri']['value']); } - return $this->convertProperties($properties); + $convertedProperties = $this->convertProperties($properties); + usort($convertedProperties, function($a, $b) { + return strnatcasecmp($a['title'], $b['title']); + }); + return $convertedProperties; } @@ -2041,4 +2084,49 @@ public static function getSelectedClass() return -1; } + + public function getClassComment() + { + $classUri = $this->getSelectedClass(); + if ($classUri == -1) { + return false; + } + else { + $owApp = OntoWiki::getInstance(); + $lang = $owApp->config->languages->locale; + if(!isset($owApp->config->lists) + || !isset($owApp->config->lists->showCommentsForHeading) + || ($owApp->config->lists->showCommentsForHeading === "false")) { + return false; + } + else { + $commentPredicates = $owApp->config->lists->headingComment->toArray(); + } + + $property_queries = array(); + foreach ($commentPredicates as $property) { + $property_queries[] = ' { <' . $classUri . '> <' . $property . '> ?comment . }'; + } + + $query = 'SELECT DISTINCT ?comment WHERE {' . PHP_EOL; + $query.= join(PHP_EOL . ' UNION' . PHP_EOL, $property_queries) . PHP_EOL; + $query.= 'FILTER (langMatches(lang(?comment), \'' . $lang . '\'))' . PHP_EOL; + $query.= '}'; + + $result = $this->_store->sparqlQuery($query); + + if (count($result) > 0) { + $resultstrings = array(); + foreach ($result as $res) { + $resultstrings[] = $res['comment']; + } + return join('
', $resultstrings); + } + else { + return false; + } + } + } + + } diff --git a/application/classes/OntoWiki/Model/Resource.php b/application/classes/OntoWiki/Model/Resource.php index 565986d99..aac24e408 100644 --- a/application/classes/OntoWiki/Model/Resource.php +++ b/application/classes/OntoWiki/Model/Resource.php @@ -322,11 +322,10 @@ public function getValues() } // push it only if it doesn't exceed number of items to display - if (count($this->_valueResults[$graph][$predicateUri]) < $this->_limit) { - array_push($this->_valueResults[$graph][$predicateUri], $value); - } else { + if (!count($this->_valueResults[$graph][$predicateUri]) < $this->_limit) { $this->_predicateResults[$graph][$predicateUri]['has_more'] = true; } + array_push($this->_valueResults[$graph][$predicateUri], $value); if (count($this->_valueResults[$graph][$predicateUri]) > 1) { // create the "has more link" (used for area context menu as well) // do it only once per predicate @@ -338,6 +337,7 @@ public function getValues() $allValuesAreLiterals = false; } } + if (!$allValuesAreLiterals) { $hasMoreUrl = new OntoWiki_Url( array('route' => 'instances', 'action' => 'list'), @@ -373,7 +373,7 @@ public function getValues() ); } else { $hasMoreUrl = new OntoWiki_Url( - array('controller' => 'queries', 'action' => 'editor'), + array('controller' => 'listview', 'action' => 'list'), array() ); $hasMoreUrl->setParam( @@ -382,6 +382,12 @@ public function getValues() )->setParam( 'immediate', true + )->setParam( + 'subject', + $this->_uri + )->setParam( + 'property', + $predicateUri ); } diff --git a/application/classes/OntoWiki/Model/TitleHelper.php b/application/classes/OntoWiki/Model/TitleHelper.php index 15e51d1df..afc1ec4cc 100644 --- a/application/classes/OntoWiki/Model/TitleHelper.php +++ b/application/classes/OntoWiki/Model/TitleHelper.php @@ -2,7 +2,7 @@ /** * This file is part of the {@link http://ontowiki.net OntoWiki} project. * - * @copyright Copyright (c) 2012, {@link http://aksw.org AKSW} + * @copyright Copyright (c) 2014, {@link http://aksw.org AKSW} * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) */ @@ -13,7 +13,11 @@ * @category OntoWiki * @package OntoWiki_Classes_Model */ -class OntoWiki_Model_TitleHelper + +require_once 'OntoWiki/Model/AbstractHelper.php'; + + +class OntoWiki_Model_TitleHelper extends OntoWiki_Model_AbstractHelper { /** * Whether to always search all configured title properties @@ -39,65 +43,16 @@ class OntoWiki_Model_TitleHelper */ private static $_instance = null; - /** - * The languages to consider for title properties. - * - * @var array - */ - protected $_languages = array('en','','localname'); - - /** - * The model object to operate on - * - * @var Erfurt_Rdf_Model - */ - protected $_model = null; - - /** - * The resources for whitch to fetch title properties - * - * @var array - */ - protected $_resources = array(); - - /** - * Resource query object - * - * @var Erfurt_Sparql_SimpleQuery - */ - protected $_resourceQuery = null; - - /** - * Erfurt store object - * - * @var Erfurt_Store - */ - protected $_store = null; - - /** - * Erfurt store object - * - * @var Erfurt_App - */ - protected $_erfurtApp = null; - - /** - * titleProperties from configuration - * - * @var array - */ - protected $_titleProperties = null; - - - - // ------------------------------------------------------------------------ - // --- Magic methods ------------------------------------------------------ - // ------------------------------------------------------------------------ /** * Constructs a new title helper instance. * * @param Erfurt_Rdf_Model $model The model instance to operate on + * @param Erfurt_Store $store + * @param null $config + * @throws Erfurt_Exception + * @throws Erfurt_Store_Exception + * @throws Exception */ public function __construct(Erfurt_Rdf_Model $model = null, Erfurt_Store $store = null, $config = null) { @@ -118,9 +73,9 @@ public function __construct(Erfurt_Rdf_Model $model = null, Erfurt_Store $store } if (is_array($config)) { if (isset($config['titleHelper']['properties'])) { // naming properties for resources - $this->_titleProperties = array_values($config['titleHelper']['properties']); + $this->_requestedProperties = array_values($config['titleHelper']['properties']); } else { - $this->_titleProperties = array(); + $this->_requestedProperties = array(); } // fetch mode @@ -131,11 +86,11 @@ public function __construct(Erfurt_Rdf_Model $model = null, Erfurt_Store $store if ($config instanceof Zend_Config) { //its possible to define myProperties in config.ini if (isset($config->titleHelper->myProperties)) { - $this->_titleProperties = array_values($config->titleHelper->myProperties->toArray()); + $this->_requestedProperties = array_values($config->titleHelper->myProperties->toArray()); } else if (isset($config->titleHelper->properties)) { // naming properties for resources - $this->_titleProperties = array_values($config->titleHelper->properties->toArray()); + $this->_requestedProperties = array_values($config->titleHelper->properties->toArray()); } else { - $this->_titleProperties = array(); + $this->_requestedProperties = array(); } // fetch mode @@ -143,7 +98,7 @@ public function __construct(Erfurt_Rdf_Model $model = null, Erfurt_Store $store $this->_alwaysSearchAllProperties = (strtolower($config->titleHelper->searchMode) == 'language'); } } else { - $this->_titleProperties = array(); + $this->_requestedProperties = array(); } } // always use local name for unknown resources? @@ -151,7 +106,7 @@ public function __construct(Erfurt_Rdf_Model $model = null, Erfurt_Store $store $this->_alwaysUseLocalNames = (bool)$config->titleHelper->useLocalNames; } // add localname to titleproperties - $this->_titleProperties[] = 'localname'; + $this->_requestedProperties[] = 'localname'; if (null === $this->_languages) { $this->_languages = array(); @@ -179,66 +134,6 @@ public static function getInstance() return self::$_instance; } - /** - * Adds a resource to list of resources for which to query title properties. - * - * @param Erfurt_Rdf_Resource|string $resource Resource instance or URI - * - * @return OntoWiki_Model_TitleHelper - */ - public function addResource($resource) - { - $resourceUri = (string)$resource; - if (Erfurt_Uri::check($resourceUri)) { - if (empty($this->_resources[$resourceUri])) { - $this->_resources[$resourceUri] = null; - } - } else { - // throw exeption in debug mode only - if (defined('_OWDEBUG')) { - $logger = OntoWiki::getInstance()->logger; - $logger->info('Supplied resource ' . htmlentities('<' . $resource . '>') . ' is not a valid URI.'); - } - } - return $this; - } - - /** - * Adds a bunch of resources for which to query title properties. - * @param array $resources - * @return OntoWiki_Model_TitleHelper - */ - public function addResources($resources = array(), $variable = null) - { - if (null === $variable) { - foreach ($resources as $resourceUri) { - $this->addResource($resourceUri); - } - } else { - foreach ($resources as $row) { - foreach ((array)$variable as $key) { - if (!empty($row[$key])) { - $object = $row[$key]; - $toBeAdded = null; - if (is_array($object)) { - // probably support extended format - if (isset($object['type']) && ($object['type'] == 'uri')) { - $toBeAdded = $object['value']; - } - } else { - // plain object - $toBeAdded = $object; - } - if ($toBeAdded != null) { - $this->addResource($toBeAdded); - } - } - } - } - } - return $this; - } - /** * Returns the title property for the resource URI in the requested language. * If no title property is found for that language the local part @@ -251,50 +146,7 @@ public function addResources($resources = array(), $variable = null) */ public function getTitle($resourceUri, $language = null) { - if (!Erfurt_Uri::check($resourceUri)) { - return $resourceUri; - } - // * means any language - if (trim($language) == '*') { - $language = null; - } - - //Have a look if we have an entry for the given resourceUri - if (!array_key_exists($resourceUri, $this->_resources) ) { - - if (defined('_OWDEBUG')) { - $logger = OntoWiki::getInstance()->logger; - $logger->info('TitleHelper: getTitle called for unknown resource. Adding resource before fetch.'); - } - //If we dont have an entry create one - $this->addResource($resourceUri); - } - - // prepend the language that is asked for to the array - // of languages we will look for - $languages = $this->_languages; - if (null !== $language) { - array_unshift($languages, (string)$language); - } - $languages = array_values(array_unique($languages)); - - //Have a look if we have already a title for the given resourceUri - if ($this->_resources[$resourceUri] === null ) { - $this->_receiveTitles(); - } - //Select the best found title according received titles and order of configured titleproperties - $title = $resourceUri; - - $titles = $this->_resources[$resourceUri]; - foreach ($languages as $language) { - foreach ($this->_titleProperties as $titleProperty) { - if (isset($titles[$titleProperty][$language]) && !empty($titles[$titleProperty][$language])) { - $title = $titles[$titleProperty][$language]; - break(2); - } - } - } - return $title; + return $this->getRequestedProperty($resourceUri, $language); } /** @@ -307,24 +159,24 @@ public function prependTitleProperty($propertyUri) // check if we have a valid URI if (Erfurt_Uri::check($propertyUri)) { // remove the property from the list if it already exist - foreach ($this->_titleProperties as $key => $value) { + foreach ($this->_requestedProperties as $key => $value) { if ($value == $propertyUri) { - unset($this->_titleProperties[$key]); + unset($this->_requestedProperties[$key]); } } // rewrite the array - $this->_titleProperties = array_values($this->_titleProperties); + $this->_requestedProperties = array_values($this->_requestedProperties); // prepend the new URI - array_unshift($this->_titleProperties, $propertyUri); + array_unshift($this->_requestedProperties, $propertyUri); // reset the TitleHelper to fetch resources with new title properties $this->reset(); } } - /** + /** * Resets the title helper, emptying all resources, results and queries stored */ public function reset() @@ -332,75 +184,13 @@ public function reset() $this->_resources = array(); } - /** - * operate on _resources array and call the method to fetch the titles - * if no titles found for the respective resource the localname will be extracted - * - * @return void - */ - private function _receiveTitles() - { - //first we check if there are resourceUris without a title representation - $toBeReceived = array(); - foreach ($this->_resources as $resourceUri => $resource) { - if ($resource == null) { - $toBeReceived[] = $resourceUri; - } - } - //now we try to receive the Titles from ResourcePool - $this->_fetchTitlesFromResourcePool($toBeReceived); - - //If we dont find titles then we extract them from LocalName - foreach ($this->_resources as $resourceUri => $resource) { - if ($resource == null) { - $this->_resources[$resourceUri]['localname']['localname'] - = $this->_extractTitleFromLocalName($resourceUri); - } - } - } - - /** - * fetches all titles according the given array if Uris - * - * @param array resourceUris - */ - private function _fetchTitlesFromResourcePool($resourceUris) - { - $resourcePool = $this->_erfurtApp->getResourcePool(); - $resources = array(); - if (!empty($this->_model)) { - $modelUri = $this->_model->getModelIri(); - $resources = $resourcePool->getResources($resourceUris, $modelUri); - } else { - $resources = $resourcePool->getResources($resourceUris); - } - - $memoryModel = new Erfurt_Rdf_MemoryModel(); - foreach ($resources as $resourceUri => $resource) { - $resourceDescription = $resource->getDescription(); - $memoryModel->addStatements($resourceDescription); - $found = false; - foreach ($this->_titleProperties as $titleProperty) { - $values = $memoryModel->getValues($resourceUri, $titleProperty); - foreach ($values as $value) { - if (!empty($value['lang'])) { - $language = $value['lang']; - } else { - $language = ''; - } - $this->_resources[$resourceUri][$titleProperty][$language] = $value['value']; - } - } - } - } - /** * extract the localname from given resourceUri * * @param string resourceUri * @return string title */ - private function _extractTitleFromLocalName($resourceUri) + protected function _extractTitleFromLocalName($resourceUri) { $title = OntoWiki_Utils::contractNamespace($resourceUri); // not even namespace found? @@ -409,4 +199,17 @@ private function _extractTitleFromLocalName($resourceUri) } return $title; } + + /** + * If we dont find titles then we extract them from LocalName as a fallback solution + */ + protected function _fetchFallbackProperties() + { + foreach ($this->_resources as $resourceUri => $resource) { + if ($resource == null) { + $this->_resources[$resourceUri]['localname']['localname'] + = $this->_extractTitleFromLocalName($resourceUri); + } + } + } } diff --git a/application/config/default.ini b/application/config/default.ini index 6dd0c3b8b..adb6102bb 100644 --- a/application/config/default.ini +++ b/application/config/default.ini @@ -19,7 +19,6 @@ sysont.properties.hiddenImports = "http://ns.ontowiki.net/SysOnt/hiddenImports" sysont.properties.hidden = "http://ns.ontowiki.net/SysOnt/hidden" sysont.properties.isLarge = "http://ns.ontowiki.net/SysOnt/isLarge" - ;; ; Main title prefix (head) ;; @@ -30,7 +29,6 @@ title.prefix = "OntoWiki" ;; title.separator = " — " - ;; ; Title Helper Configuration ; Properties to be searched for values with a human-readable @@ -41,7 +39,6 @@ title.separator = " — " ;; these are more important than rdfs:label titleHelper.properties.skosPlabel = "http://www.w3.org/2004/02/skos/core#prefLabel" -titleHelper.properties.dcTitle = "http://purl.org/dc/elements/1.1/title" titleHelper.properties.dcTitle2 = "http://purl.org/dc/terms/title" titleHelper.properties.swrcTitle = "http://swrc.ontoware.org/ontology#title" titleHelper.properties.foafName = "http://xmlns.com/foaf/0.1/name" @@ -55,6 +52,7 @@ titleHelper.properties.goName = "http://www.geneontology.org/dtds/go.dtd#na titleHelper.properties.rdfsLabel = "http://www.w3.org/2000/01/rdf-schema#label" ;; these are less important than rdfs:label ... +titleHelper.properties.dcTitle = "http://purl.org/dc/elements/1.1/title" titleHelper.properties.accountName = "http://xmlns.com/foaf/0.1/accountName" titleHelper.properties.foafNick = "http://xmlns.com/foaf/0.1/nick" titleHelper.properties.foafSurname = "http://xmlns.com/foaf/0.1/surname" @@ -72,12 +70,21 @@ titleHelper.properties.skosAlabel = "http://www.w3.org/2004/02/skos/core#altLab ;; titleHelper.searchMode = "language" - ;; ; Always fall back to the local part of the URI for unknown resources. ;; titleHelper.useLocalNames = true +;; +; These properties are the ones what will be queried to display a comment +; for the selected class (if available) +;; +lists.showHeading = "false" +lists.showCommentsForHeading = "false" +lists.headingComment[] = "http://www.w3.org/2000/01/rdf-schema#comment" +lists.headingComment[] = "http://rdfs.org/sioc/ns#content" +lists.headingComment[] = "http://www.w3.org/2004/02/skos/core#comment" +lists.headingComment[] = "http://rdfs.org/sioc/ns#about" ;; ; Model Info description properties (maybe later a description helper?) @@ -89,11 +96,12 @@ descriptionHelper.properties.dcDesc2 = "http://purl.org/dc/elements/1.1/descript descriptionHelper.properties.skosNote = "http://www.w3.org/2004/02/skos/core#note" descriptionHelper.properties.skosEditorialNote = "http://www.w3.org/2004/02/skos/core#editorialNote" - ;; ; List settings ;; -lists.showTypeColumnByDefault = "true" +lists.showTypeColumnByDefault = "false" +lists.showHeading = "true" +lists.showCommentsForHeading = "true" ;; ; Version info @@ -105,11 +113,10 @@ version.suffix = "git" ;; ; Help Menu URLs ;; -help.documentation = "https://github.com/AKSW/OntoWiki/wiki" -help.issues = "https://github.com/AKSW/OntoWiki/issues" +help.documentation = "http://amsl.technology/manual/" +help.issues = "mailto:team@amsl.technology" help.versioninfo = "https://raw.github.com/AKSW/OntoWiki/master/debian/changelog" - ;; ; Zend routes for built-in controllers ; Routes are applied in reverse order, so most specific routes should go last. @@ -154,20 +161,17 @@ index.default.action = "news" ;; encoding = "utf-8" - ;; ; Path for external libraries ;; libraries.path = "libraries" - ;; ; Default theme and themes folder ;; -themes.default = "silverblue" +themes.default = "amsl" themes.path = "extensions/themes" - ;; ; Extension directories ;; @@ -177,7 +181,6 @@ extensions.core[] = "application" extensions.core[] = "account" extensions.core[] = "exconf" - ;; ; language options ;; @@ -189,7 +192,7 @@ cache.translation = on ; RDFa widget configuration ;; update.endpoint = "endpoint" - +rdfauthor.usetemplate = off ;; ; Zend_Cache options @@ -197,27 +200,23 @@ update.endpoint = "endpoint" cache.path = "cache" cache.modules = off - ;; ; Set this identifier to a unique value if you want to run multiple OntoWiki ; installations on one server ;; ;session.identifier = "abc123" - ;; ; Disables certain inference features that make OntoWiki slow when used ; with large models (> 100.000 triples) ;; system.inference = true - ;; ; Web service configuration ;; service.auth.allowGet = false - ; Enables logging up to a certain level. The specified logs folder needs to ; be writable. To disable logging at all set this option to false. If the ; debug option is set to true logging is enabled (7) automatically. @@ -241,7 +240,6 @@ log.path = "logs" ;; ; debug = true - ;; ; Database setup. Please adjust these settings in ; config.ini. @@ -256,7 +254,6 @@ log.path = "logs" ; store.zenddb.dbname = ontowiki ;; - ;; ; Some Erfurt Config Options ;; @@ -275,7 +272,6 @@ cache.query.type = database cache.enable = true ; clear the cache if you switch from 0 to 1! cache.type = database ; database, sqllite - ;; Options for cache frontend cache.frontend.enable = true cache.frontend.lifetime = 0 @@ -289,7 +285,7 @@ cache.frontend.cache_id_prefix = 'OW_' ;; Available: file | memcached | database | sqlite | apc ;; Recommended: memcached | file cache.backend.type = "file" - + ;; Options for file cache backend cache.backend.file.cache_dir = "./cache/" cache.backend.file.file_locking = NULL diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 63a17a672..df7a44a17 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -29,7 +29,7 @@ public function newsshortAction() $version = $this->_config->version; // try reading try { - $url = 'http://blog.aksw.org/feed/?cat=5&client=' + $url = 'http://amsl.technology/feed/?lang=en' . $version->label . '&version=' . $version->number @@ -84,15 +84,11 @@ public function newsAction() $owFeed = null; $version = $this->_config->version; + $translate = OntoWiki::getInstance()->translate; $this->view->placeholder('main.window.title')->set('News'); - try { - $url = 'http://blog.aksw.org/feed/?cat=5&client=' - . urlencode($version->label) - . '&version=' - . urlencode($version->number) - . '&suffix=' - . urlencode($version->suffix); + try { + $url = $translate->translate('http://amsl.technology/feed/?lang=en'); $owFeed = Zend_Feed::import($url); diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php index 89455a407..330e0dd00 100644 --- a/application/controllers/ResourceController.php +++ b/application/controllers/ResourceController.php @@ -43,6 +43,7 @@ public function propertiesAction() $store = $this->_owApp->erfurt->getStore(); $graph = $this->_owApp->selectedModel; + $importedGraphs = $this->_owApp->selectedModel->getImports(); $resource = $this->_owApp->selectedResource; $navigation = $this->_owApp->navigation; $translate = $this->_owApp->translate; @@ -106,6 +107,18 @@ public function propertiesAction() $values = $event->values; } + $event = new Erfurt_Event('onPropertiesActionTemplate'); + $event->selectedModel = $this->_owApp->selectedModel; + $event->resource = $resource; + $event->graph = $graph; + $event->predicates = $predicates; + $result = $event->trigger(); + + if ($result) { + $predicates = $event->predicates; + $this->view->templateHtml = $event->templateHtml; + } + $titleHelper = new OntoWiki_Model_TitleHelper($graph); // add graphs $graphs = array_keys($predicates); @@ -117,7 +130,7 @@ public function propertiesAction() foreach ($graphs as $g) { $graphInfo[$g] = $titleHelper->getTitle($g, $this->_config->languages->locale); - if ($this->_erfurt->getAc()->isModelAllowed('edit', $g)) { + if ($this->_erfurt->getAc()->isModelAllowed('edit', $g) && !in_array($g, $importedGraphs)) { $editableFlags[$g] = true; $this->view->placeholder('update')->append( array( @@ -128,6 +141,13 @@ public function propertiesAction() ); } else { $editableFlags[$g] = false; + $this->view->placeholder('update')->append( + array( + 'sourceGraph' => $g, + 'queryEndpoint' => $this->_config->urlBase . 'sparql/', + 'updateEndpoint' => $this->_config->urlBase . 'update/' + ) + ); } } @@ -257,7 +277,11 @@ public function instancesAction() //$list->setOrderProperty('http://ns.ontowiki.net/SysOnt/order'); //begin view building - $this->view->placeholder('main.window.title')->set('Resource List'); + // Set the window title in the appropriate language. + $translate = $this->_owApp->translate; + $windowTitle = $translate->_('Resource List'); + $this->view->placeholder('main.window.title')->set($windowTitle); + // rdfauthor on a list is not possible yet // TODO: check acl @@ -265,32 +289,36 @@ public function instancesAction() /* * toolbar disabled for 0.9.5 (reactived hopefully later :) ) */ - if ($graph->isEditable()) { - $toolbar = $this->_owApp->toolbar; - $toolbar->appendButton( - OntoWiki_Toolbar::EDITADD, array('name' => 'Add Instance', 'class' => 'init-resource') - ); - $toolbar->prependButton(OntoWiki_Toolbar::SEPARATOR); - $toolbar->prependButton( - OntoWiki_Toolbar::CANCEL, - array( - '+class' => 'hidden', - 'title' => 'SHIFT + ALT + c' - ) - ); + if($_SESSION['ONTOWIKI']['archive'] == ''){ + if ($graph->isEditable() ) { + $toolbar = $this->_owApp->toolbar; + $toolbar->appendButton( + OntoWiki_Toolbar::EDITADD, array('name' => 'Add Instance', 'class' => 'init-resource') + ); + $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' - ) - ); - // ->appendButton(OntoWiki_Toolbar::EDIT, array('name' => 'Edit Instances', 'class' => 'edit-enable')) - // ->appendButton(OntoWiki_Toolbar::SEPARATOR) - // ->appendButton(OntoWiki_Toolbar::DELETE, array('name' => 'Delete Selected', 'class' => 'submit')) - $this->view->placeholder('main.window.toolbar')->set($toolbar); + $toolbar->prependButton( + OntoWiki_Toolbar::SAVE, + array( + '+class' => 'hidden', + 'title' => 'SHIFT + ALT + s' + ) + ); + // ->appendButton(OntoWiki_Toolbar::EDIT, array('name' => 'Edit Instances', 'class' => 'edit-enable')) + // ->appendButton(OntoWiki_Toolbar::SEPARATOR) + // ->appendButton(OntoWiki_Toolbar::DELETE, array('name' => 'Delete Selected', 'class' => 'submit')) + $this->view->placeholder('main.window.toolbar')->set($toolbar); + } } + + /* $url = new OntoWiki_Url( @@ -412,6 +440,14 @@ public function deleteAction() $event->modelUri = $modelIri; $event->trigger(); + /** + * Trigger Index + **/ + $indexEvent = new Erfurt_Event('onDeleteResourceAction'); + $indexEvent->resources = $resources; + $indexEvent->model = $modelIri; + $indexEvent->trigger(); + $this->_redirect($redirect, array('code' => 302)); } diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 8e931cd5c..2cb102624 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -515,6 +515,18 @@ public function updateAction() $insert = json_decode($this->_request->getParam('insert', '{}'), true); $delete = json_decode($this->_request->getParam('delete', '{}'), true); + foreach($insert as $subkey => $currentSubject){ + foreach($currentSubject as $prdkey => $currentProperty){ + foreach($currentProperty as $itemkey => $item) { + if ($item["value"] == "") { + unset($insert[$subkey][$prdkey][$itemkey]); + } + } + } + } + + $changeReason = $this->_request->getParam('changeReason', null); + if ($this->_request->has('delete_hashed')) { $hashedObjectStatements = $this->_findStatementsForObjectsWithHashes( $namedGraph, @@ -539,6 +551,18 @@ public function updateAction() $flag = false; + + // action spec for versioning + $versioning = OntoWiki::getInstance()->erfurt->getVersioning(); + $actionSpec = array(); + $actionSpec['type'] = 21; + $actionSpec['modeluri'] = $deleteModel->getModelUri(); + $actionSpec['resourceuri'] = !null == key($delete) ? key($delete) : key($insert); + $actionSpec['changeReason'] = $changeReason; + + // starting action + $versioning->startAction($actionSpec); + /** * @trigger onUpdateServiceAction is triggered when Service-Controller Update Action is executed. * Event contains following attributes: @@ -595,6 +619,9 @@ public function updateAction() } } + // stopping action + $versioning->endAction(); + // nothing done? if (!$flag) { // When no user is given (Anoymous) give the requesting party a chance to authenticate. @@ -607,6 +634,19 @@ public function updateAction() } } + /** + * Trigger Index + **/ + $indexEvent = new Erfurt_Event('onIndexAction'); + $indexEvent->resource = !null == key($delete) ? key($delete) : key($insert); + $indexEvent->model = $deleteModel->getModelUri(); + $indexEvent->trigger(); + + $objectCache = Erfurt_App::getInstance()->getCache(); + if (!($objectCache->getBackend() instanceof Erfurt_Cache_Backend_Null)) { + $objectCache->clean(); + } + if ($changes) { /** * @see {http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2} @@ -668,7 +708,6 @@ public function templateAction() $this->_response->setBody($this->view->render($file)); } - /** * JSON outputs of the transitive closure of resources to a given start * resource and an transitive attribute @@ -827,7 +866,6 @@ public function rdfauthorcacheAction() $response->setBody(json_encode($output)); } - /** * JSON output of the RDFauthor init config, which is a RDF/JSON Model * without objects where the user should be able to add data @@ -876,28 +914,60 @@ public function rdfauthorinitAction() $resourceUri = $parameter; } + $event = new Erfurt_Event('onRDFAuthorInitActionTemplate'); + $event->model = $model; + $event->resource = $resourceUri; + $event->parameter = $parameter; + $event->mode = $workingMode; + $eventResult = $event->trigger(); + + // empty object to hold data + $output = new stdClass(); + $newProperties = new stdClass(); + + //Write rdfAuthor-output to handle 'Add Property'-widget + if ($event->addPropertyValues !== null) { + $output->addPropertyValues = $event->addPropertyValues; + } + + if ($event->addOptionalPropertyValues !== null) { + $output->addOptionalPropertyValues = $event->addOptionalPropertyValues; + } + if ($workingMode == 'class') { - $properties = $model->sparqlQuery( - 'SELECT DISTINCT ?uri ?value { - ?s ?uri ?value. - ?s a <' . $parameter . '>. - } LIMIT 20 ', array('result_format' => 'extended') - ); + if ($eventResult) { + $properties = $event->properties; + } else { + $properties = $model->sparqlQuery( + 'SELECT DISTINCT ?uri ?value { + ?s ?uri ?value. + ?s a <'. $parameter . '>. + } LIMIT 40 ', array('result_format' => 'extended') + ); + } } elseif ($workingMode == 'clone') { // FIXME: more than one values of a property are not supported right now // FIXME: Literals are not supported right now - $properties = $model->sparqlQuery( - 'SELECT ?uri ?value { - <' . $parameter . '> ?uri ?value. - #FILTER (isUri(?value)) - } LIMIT 20 ', array('result_format' => 'extended') - ); + if ($eventResult) { + $properties = $event->properties; + } else { + $properties = $model->sparqlQuery( + 'SELECT ?uri ?value { + <' . $parameter . '> ?uri ?value. + #FILTER (isUri(?value)) + } LIMIT 40 ', array('result_format' => 'extended') + ); + } } elseif ($workingMode == 'edit') { + if ($eventResult) { + $properties = $event->properties; + } else { $properties = $model->sparqlQuery( 'SELECT ?uri ?value { <' . $parameter . '> ?uri ?value. - } LIMIT 20 ', array('result_format' => 'extended') - ); + } LIMIT 40 ', array('result_format' => 'extended') + ); + } } else { // resource $properties = $model->sparqlQuery( 'SELECT DISTINCT ?uri ?value { @@ -906,12 +976,60 @@ public function rdfauthorinitAction() ); } - // empty object to hold data - $output = new stdClass(); - $newProperties = new stdClass(); - $properties = $properties['results']['bindings']; + $displayProperties = array(); + if (!empty($properties)) { + foreach ($properties as $p) { + array_push($displayProperties, $p["uri"]["value"]); + } + } + + if(isset($output->addOptionalPropertyValues)){ + foreach ($output->addOptionalPropertyValues as $key => $value) { + $isIn = false; + foreach ($properties as $item){ + if($item['uri']['value'] == $key){ + $isIn = true; + break; + } + } + if(!$isIn) { + $uriA = array("type" => "uri", + "value" => $key); + if(isset($value["type"])){ + $valueB = array("type" => "typed-literal", + "datatype" => $value["type"]); + array_push($properties, array("uri" => $uriA, "value" => $valueB)); + }else{ + array_push($properties, array("uri" => $uriA)); + } + + } + }} + + if(isset($output->addPropertyValues)){ + foreach ($output->addPropertyValues as $key => $value) { + $isIn = false; + foreach ($properties as $item){ + if($item['uri']['value'] == $key){ + $isIn = true; + break; + } + } + if(!$isIn) { + $uriA = array("type" => "uri", + "value" => $key); + if(isset($value["type"] )){ + $valueB = array("type" => "typed-literal", + "datatype" => $value["type"]); + array_push($properties, array("uri" => $uriA, "value" => $valueB)); + }else{ + array_push($properties, array("uri" => $uriA)); + } + } + }} + // feed title helper w/ URIs $titleHelper = new OntoWiki_Model_TitleHelper($model); $titleHelper->addResources($properties, 'uri'); @@ -920,8 +1038,21 @@ public function rdfauthorinitAction() foreach ($properties as $property) { $currentUri = $property['uri']['value']; - $currentValue = $property['value']['value']; - $currentType = $property['value']['type']; + /* FIXME ad-hoc fix since in rdfauthor template mode + the value will not be set right now (but should probably + be provided in future + */ + if (isset($property['value']) && isset($property['value']['value'])) { + $currentValue = $property['value']['value']; + } else { + $currentValue = ''; + } + + if (isset($property['value']) && isset($property['value']['type'])) { + $currentType = $property['value']['type']; + } else { + $currentType = ''; + } $value = new stdClass(); @@ -965,8 +1096,11 @@ public function rdfauthorinitAction() $value->value = $currentValue; $value->type = $currentType; } - if ($workingMode == 'class') { - $value->value = ''; + if ($workingMode == 'class' && $eventResult) { + $value->value = $currentValue; + $value->type = $currentType; + } elseif ($workingMode == 'class' && !$eventResult) { + $value->value = '' ; $value->type = $currentType; } } @@ -983,7 +1117,7 @@ public function rdfauthorinitAction() $output->$resourceUri = $newProperties; } else { // empty sparql results -> start with a plain resource - if ($workingMode == 'class') { + if ($workingMode == 'class' || $workingMode =='clone') { // for classes, add the rdf:type property $value = new stdClass(); $value->value = $parameter; @@ -1001,6 +1135,103 @@ public function rdfauthorinitAction() $output->$resourceUri = $newProperties; } + // Sort Properties with sortproperties extension + $event = new Erfurt_Event('onSortPropertiesRDFauthorData'); + $event->data = $output; + $result = $event->trigger(); + + if ($result) { + $output = $event->output; + } + + foreach ($output[$resourceUri] as $k => $v) { + if ($k != "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") { + $query = 'SELECT ?type ?range ?owlOneOf ?displayAs WHERE { +<'. $k .'> ?type . +OPTIONAL { +<'. $k .'> ?range +OPTIONAL { ?range ?owlOneOf } } +OPTIONAL { ?range ?displayAs } }'; + $data = $model->sparqlQuery( + $query, array('result_format' => 'plain') + ); + for($itemCount = 0; $itemCount < sizeOf($output[$resourceUri][$k]); $itemCount++) { + if (sizeof($data) > 0) { + $ranges = array(); + $ranges[] = $data[0]["range"]; + $types = array(); + $types[] = $data[0]["type"]; + $output[$resourceUri][$k][$itemCount]["range"] = $ranges; + if ($data[0]["owlOneOf"] === "" || $data[0]["owlOneOf"] === "null" || $data[0]["owlOneOf"] == null) { + $data[0]["owlOneOf"] = ""; + } + $output[$resourceUri][$k][$itemCount]["owlOneOf"] = $data[0]["owlOneOf"]; + $output[$resourceUri][$k][$itemCount]["displayAs"] = $data[0]["displayAs"]; + $output[$resourceUri][$k][$itemCount]["type"] = $types; + + if ($data[0]["owlOneOf"] != "") { + $_owApp = OntoWiki::getInstance(); + $lang = $_owApp->language; + $query = "PREFIX rdf: +SELECT DISTINCT ?elem ?label +WHERE { +<" . $ranges[0] . "> ?list . +?list rdf:rest*/rdf:first ?elem . +OPTIONAL { +?elem ?label . +FILTER(lang(?label) = '" . $lang . "') +}}"; + $dropDownContent = $model->sparqlQuery( + $query, array('result_format' => 'extended') + ); + $output[$resourceUri][$k][$itemCount]["dropDownContent"] = $dropDownContent; + } + } + } + } + } + if(isset($output->addOptionalPropertyValues)){ + foreach ($output["addOptionalPropertyValues"] as $k => $v) { + if ($k != "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") { + $query = 'SELECT ?range WHERE { + +<'. $k .'> ?range +}'; + $data = $model->sparqlQuery( + $query, array('result_format' => 'plain') + ); + if(sizeof($data) > 0) { + $ranges = array(); + $ranges[] = $data[0]["range"]; + $output["addOptionalPropertyValues"][$k]["ranges"] = $ranges; + } + } + }} + + $inititialData = array(); + $additionalData = array(); + + foreach($output[$resourceUri] as $key => $value){ + $isIn = false; + foreach($displayProperties as $propp){ + if($propp == $key){ + $isIn = true; + $inititialData[$key] = $value; + } + } + if(!$isIn){ + $additionalData[$key] = $value; + } + } + + if($workingMode == 'clone'){ + $test = 0; + } + + $output[$resourceUri] = $inititialData; + $output["additionalData"] = $additionalData; + $output["displayProperties"] = $displayProperties; + // send the response $response->setHeader('Content-Type', 'application/json'); $response->setBody(json_encode($output)); diff --git a/application/scripts/clean.sh b/application/scripts/clean.sh new file mode 100755 index 000000000..b5ea403b0 --- /dev/null +++ b/application/scripts/clean.sh @@ -0,0 +1,37 @@ +#!/bin/bash +echo "START CLEAN VIRTUOSO" +SESSION=$(date +%Y-%m-%d-%H:%mi:%S) + +if [ $# == 0 ]; then + echo "OntoWiki root path is missing" + exit 0 +fi + +if [ $# == 1 ]; then + OWPATH=$1 +fi + +if [ ! -d "$OWPATH/dumps" ]; then + mkdir $OWPATH/dumps +fi + +mkdir $OWPATH/dumps/clean_$SESSION >/dev/null 2>&1 +chmod -R 777 $OWPATH/dumps/clean_$SESSION >/dev/null 2>&1 +curl -s -L "http://localhost:8890/sparql" --data-urlencode "default-graph-uri=" --data-urlencode "query=SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?o ?p}}" --data-urlencode "format=text/csv" | sed "s/\"//g" | sed 1D | sort >$OWPATH/dumps/clean_$SESSION/graphs.lst + +while read GRAPH +do + GRAPH=$(echo $GRAPH | sed "s/\s*//g") + + if [ "$GRAPH" == "http://localhost/OntoWiki/Config/" ] || [ "$GRAPH" == "http://www.openlinksw.com/schemas/virtrdf#" ] || [ "$GRAPH" == "http://localhost:8890/DAV/" ] || [ "$GRAPH" == "http://localhost:8890/sparql" ] || [ "$GRAPH" == "http://www.w3.org/2002/07/owl#" ]; then + echo "IGNORE $GRAPH"; + else + echo "DELETE $GRAPH" + DELETE=$DELETE"SPARQL DROP GRAPH <$GRAPH>;" + fi + +done < $OWPATH/dumps/clean_$SESSION/graphs.lst +IFS=' ' read -r ISQL_PROG virt_user virt_pw <<< "`exec $OWPATH/application/scripts/virtuoso.sh $OWPATH`" +eval "$ISQL_PROG -U $virt_user -P $virt_pw exec=\"$DELETE\"" > /dev/null +rm -rf $OWPATH/dumps/clean_$SESSION > /dev/null +echo "FINISHED CLEAN VIRTUOSO" diff --git a/application/scripts/dump_graph.sql b/application/scripts/dump_graph.sql new file mode 100644 index 000000000..30721ed1d --- /dev/null +++ b/application/scripts/dump_graph.sql @@ -0,0 +1,72 @@ +CREATE PROCEDURE dump_one_graph + ( IN srcgraph VARCHAR + , IN out_file VARCHAR + , IN file_length_limit INTEGER := 1000000000 + ) + { + DECLARE file_name VARCHAR + ; DECLARE env + , ses ANY + ; DECLARE ses_len + , max_ses_len + , file_len + , file_idx INTEGER + ; SET ISOLATION = 'uncommitted' + ; max_ses_len := 10000000 + ; file_len := 0 + ; file_idx := 1 + ; file_name := sprintf ('%s%06d.ttl', out_file, file_idx) + ; string_to_file ( file_name || '.graph', + srcgraph, + -2 + ); + string_to_file ( file_name, + sprintf ( '# Dump of graph <%s>, as of %s\n@base <> .\n', + srcgraph, + CAST (NOW() AS VARCHAR) + ), + -2 + ) + ; env := vector (dict_new (16000), 0, '', '', '', 0, 0, 0, 0, 0) + ; ses := string_output () + ; FOR (SELECT * FROM ( SPARQL DEFINE input:storage "" + SELECT ?s ?p ?o { GRAPH `iri(?:srcgraph)` { ?s ?p ?o } } + ) AS sub OPTION (LOOP)) DO + { + http_ttl_triple (env, "s", "p", "o", ses); + ses_len := length (ses); + IF (ses_len > max_ses_len) + { + file_len := file_len + ses_len; + IF (file_len > file_length_limit) + { + http (' .\n', ses); + string_to_file (file_name, ses, -1); + gz_compress_file (file_name, file_name||'.gz'); + file_delete (file_name); + file_len := 0; + file_idx := file_idx + 1; + file_name := sprintf ('%s%06d.ttl', out_file, file_idx); + string_to_file ( file_name, + sprintf ( '# Dump of graph <%s>, as of %s (part %d)\n@base <> .\n', + srcgraph, + CAST (NOW() AS VARCHAR), + file_idx), + -2 + ); + env := VECTOR (dict_new (16000), 0, '', '', '', 0, 0, 0, 0, 0); + } + ELSE + string_to_file (file_name, ses, -1); + ses := string_output (); + } + } + IF (LENGTH (ses)) + { + http (' .\n', ses); + string_to_file (file_name, ses, -1); + gz_compress_file (file_name, file_name||'.gz'); + file_delete (file_name); + } + } +; \ No newline at end of file diff --git a/application/scripts/export.sh b/application/scripts/export.sh new file mode 100755 index 000000000..8bb9ba454 --- /dev/null +++ b/application/scripts/export.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +echo "START VIRTUOSO GRAPH EXPORT" + +a=0 +SESSION=$(date +%Y-%m-%d-%H:%m:%S) + +if [ $# == 0 ]; then + echo "OntoWiki root path is missing" + exit 0 +fi + +if [ $# == 1 ]; then + OWPATH=$1 +fi + +if [ ! -d "$OWPATH/dumps" ]; then + mkdir $OWPATH/dumps >/dev/null 2>&1 +fi + +mkdir -p /tmp/export_$SESSION +mkdir $OWPATH/dumps/export_$SESSION >/dev/null 2>&1 +chmod -R 777 $OWPATH/dumps/export_$SESSION >/dev/null 2>&1 +chmod -R 777 /tmp/export_$SESSION >/dev/null 2>&1 + +IFS=' ' read -r ISQL_PROG virt_user virt_pw <<< "`exec $OWPATH/application/scripts/virtuoso.sh $OWPATH`" + +echo "LOAD ${OWPATH}/application/scripts/dump_graph.sql;" | $ISQL_PROG -U $virt_user -P $virt_pw > /dev/null 2>&1 + +curl -s -L "http://localhost:8890/sparql" --data-urlencode "default-graph-uri=" --data-urlencode "query=SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?o ?p}}" --data-urlencode "format=text/csv" | sed "s/\"//g" | sed 1D | sort >$OWPATH/dumps/export_$SESSION/graphs.lst + +while read GRAPH +do + GRAPH=$(echo $GRAPH | sed "s/\s*//g") + + if [ "$GRAPH" == "http://www.openlinksw.com/schemas/virtrdf#" ] || [ "$GRAPH" == "http://localhost:8890/DAV/" ] || [ "$GRAPH" == "http://localhost:8890/sparql" ] || [ "$GRAPH" == "http://www.w3.org/2002/07/owl#" ]; then + echo "IGNORE $GRAPH"; + else + COUNT=$(curl -s -L "http://localhost:8890/sparql" --data-urlencode "default-graph-uri=" --data-urlencode "query=SELECT (COUNT(*) AS ?no) {GRAPH <$GRAPH> {?s ?p ?o }}" --data-urlencode "should-sponge=" --data-urlencode "format=text/csv" | sed "s/\"//g" | sed 1D | sed 's/[^0-9]*//g') + a=$(($a+1)) + echo "EXPORT $GRAPH (containing $COUNT triples) to dumps/export_$SESSION" + + # now dump graph + echo "dump_one_graph('${GRAPH}', '/tmp/export_$SESSION/${a}_', 1000000000);" | $ISQL_PROG -U $virt_user -P $virt_pw >/dev/null + fi +done < $OWPATH/dumps/export_$SESSION/graphs.lst + +echo "FINISHED VIRTUOSO GRAPH EXPORT" +echo "ALL DATA SAVED IN ./dumps/export_$SESSION/" + +cp -a /tmp/export_$SESSION/* "${OWPATH}/dumps/export_$SESSION" +rm -rf "/tmp/export_$SESSION" \ No newline at end of file diff --git a/application/scripts/init.sh b/application/scripts/init.sh new file mode 100755 index 000000000..b9dc877ce --- /dev/null +++ b/application/scripts/init.sh @@ -0,0 +1,32 @@ +#!/bin/bash +SESSION=$(date +%Y-%m-%d-%H:%m:%S) +echo "START DATA INITIALISATION" + +if [ $# == 0 ]; then + echo "OntoWiki root path is missing" + exit 0 +fi + +if [ $# == 1 ]; then + OWPATH=$1 +fi + +mkdir /tmp/init_$SESSION >/dev/null 2>&1 +chmod -R 777 /tmp/init_$SESSION/* >/dev/null 2>&1 +cp $OWPATH/sample-data/*ttl* /tmp/init_$SESSION >/dev/null 2>&1 +IFS=' ' read -r ISQL_PROG virt_user virt_pw <<< "`exec $OWPATH/application/scripts/virtuoso.sh $OWPATH`" +echo "delete from DB.DBA.load_list;" | $ISQL_PROG -U $virt_user -P $virt_pw >/dev/null 2>&1 +echo "CREATE PROCEDURE create_silent_graphs () { + ld_dir('/tmp/init_$SESSION', '*.ttl*', null); + rdf_loader_run(); + log_message(sprintf('Creating silent graphs: ')); + FOR (SELECT * FROM DB.DBA.load_list AS sub WHERE ll_state=2 OPTION (LOOP)) DO { + log_message (sprintf ( 'Executing: SPARQL CREATE SILENT GRAPH <%s>', ll_graph)) ; + exec (sprintf ( 'SPARQL CREATE SILENT GRAPH <%s>', ll_graph)) ; + } +} ; " > /tmp/init_create_silent_graphs.sql +echo "LOAD /tmp/init_create_silent_graphs.sql ; " | $ISQL_PROG -U $virt_user -P $virt_pw >/dev/null 2>&1 +echo "create_silent_graphs () ;" | $ISQL_PROG -U $virt_user -P $virt_pw >/dev/null 2>&1 +echo "delete from DB.DBA.load_list;" | $ISQL_PROG -U $virt_user -P $virt_pw >/dev/null 2>&1 +rm -rf /tmp/init_* >/dev/null 2>&1 +echo "FINISHED DATA INITIALISATION" diff --git a/application/scripts/virtuoso.sh b/application/scripts/virtuoso.sh new file mode 100755 index 000000000..e88470ac7 --- /dev/null +++ b/application/scripts/virtuoso.sh @@ -0,0 +1,25 @@ +#!/bin/bash +if [ $# == 0 ]; then + echo "OntoWiki root path is missing" + exit 0 +fi +if [ $# == 1 ]; then + OWPATH=$1 +fi +if [ -e "/usr/bin/isql-vt" ] +then + ISQL_PROG="isql-vt" +else + if [ -e "/usr/bin/isql" ] + then + ISQL_PROG="isql" + else + ISQL_PROG=$(which isql) + if [ -z $ISQL_PROG ] + then exit 0 + fi + fi +fi +virt_user=$(sed -r -n 's/.*store.virtuoso.username *= *"*([^"]*)"*/\1/p' < $OWPATH/config.ini) +virt_pw=$(sed -r -n 's/.*store.virtuoso.password *= *"*([^"]*)"*/\1/p' < $OWPATH/config.ini) +echo "$ISQL_PROG $virt_user $virt_pw" diff --git a/application/scripts/vocab.sh b/application/scripts/vocab.sh new file mode 100755 index 000000000..6f5c05ad0 --- /dev/null +++ b/application/scripts/vocab.sh @@ -0,0 +1,47 @@ +#!/bin/bash +echo "START IMPORT AMSL VOCABULARY" + +SESSION=$(date +%Y-%m-%d-%H:%m:%S) + +if [ $# == 0 ]; then + echo "OntoWiki root path is missing" + exit 0 +fi + +if [ $# == 1 ]; then + OWPATH=$1 +fi + +if [ ! -d "$OWPATH/tmp" ]; then + mkdir $OWPATH/tmp >/dev/null 2>&1 +fi + +mkdir /tmp/vocab_$SESSION >/dev/null 2>&1 +chmod -R 777 /tmp/vocab_$SESSION >/dev/null 2>&1 +chmod -R +x /tmp/vocab_$SESSION >/dev/null 2>&1 +wget -q "https://raw.githubusercontent.com/amsl-project/amsl.vocab/master/amsl.ttl" -O /tmp/vocab_$SESSION/amsl.ttl + +if [ ! -e "/tmp/vocab_$SESSION/amsl.ttl" ]; then + echo "Could not find and download the vocabulary. Abort action"; + exit 0; +fi + +echo "http://vocab.ub.uni-leipzig.de/amsl/" > /tmp/vocab_$SESSION/amsl.ttl.graph +IFS=' ' read -r ISQL_PROG virt_user virt_pw <<< "`exec $OWPATH/application/scripts/virtuoso.sh $OWPATH`" +DELETE=$DELETE"SPARQL DROP GRAPH ;" +echo "$DELETE" | $ISQL_PROG -U $virt_user -P $virt_pw > /dev/null 2>&1 +echo "delete from DB.DBA.load_list;" | $ISQL_PROG -U $virt_user -P $virt_pw > /dev/null 2>&1 +echo "CREATE PROCEDURE create_silent_graphs () { + ld_dir('/tmp/vocab_$SESSION', '*.ttl', 'http://example.com/'); + rdf_loader_run(); + log_message(sprintf('Creating silent graphs: ')); + FOR (SELECT * FROM DB.DBA.load_list AS sub WHERE ll_state=2 OPTION (LOOP)) DO { + log_message (sprintf ( 'Executing: SPARQL CREATE SILENT GRAPH <%s>', ll_graph)) ; + exec (sprintf ( 'SPARQL CREATE SILENT GRAPH <%s>', ll_graph)) ; + } +} ; " > /tmp/vocab_create_silent_graphs.sql +echo "LOAD /tmp/vocab_create_silent_graphs.sql ; " | $ISQL_PROG -U $virt_user -P $virt_pw > /dev/null 2>&1 +echo "create_silent_graphs () ;" | $ISQL_PROG -U $virt_user -P $virt_pw > /dev/null 2>&1 +echo "delete from DB.DBA.load_list;" | $ISQL_PROG -U $virt_user -P $virt_pw > /dev/null 2>&1 +rm -rf /tmp/vocab_* >/dev/null 2>&1 +echo "FINISHED IMPORT AMSL VOCABULARY" diff --git a/application/views/templates/layouts/layout.phtml b/application/views/templates/layouts/layout.phtml index bf7f368b4..5adcf0708 100644 --- a/application/views/templates/layouts/layout.phtml +++ b/application/views/templates/layouts/layout.phtml @@ -74,6 +74,7 @@ + @@ -196,5 +197,12 @@ $queryCount = OntoWiki::getInstance()->erfurt->getStore()->getQueryCount(); $time = (microtime(true) - REQUEST_START) * 1000; ?> + +
+
+

_('Do you really want to delete this model?') ?>

+
+
+ diff --git a/application/views/templates/model/create.phtml b/application/views/templates/model/create.phtml index ab087a99f..fb4a4673a 100644 --- a/application/views/templates/model/create.phtml +++ b/application/views/templates/model/create.phtml @@ -50,7 +50,7 @@ type="radio" class="radio importAction" name="importAction" id="import-" value="" - + _($action['description']).'"' : '' ) ?> /> _($action['label']) ?> diff --git a/application/views/templates/partials/list.phtml b/application/views/templates/partials/list.phtml index d18b1437d..3c7eb2537 100644 --- a/application/views/templates/partials/list.phtml +++ b/application/views/templates/partials/list.phtml @@ -133,6 +133,7 @@ echo $this->partial('partials/'.$this->mainTemplate.'.phtml', 'propertyInfo' => $propertyInfo, 'other' => $other, 'listName' => $this->listName, - 'start' => $start + 'start' => $start, + 'heading' => $this->heading ) ); diff --git a/application/views/templates/partials/list_std_element.phtml b/application/views/templates/partials/list_std_element.phtml index f1d813145..74a534ba1 100644 --- a/application/views/templates/partials/list_std_element.phtml +++ b/application/views/templates/partials/list_std_element.phtml @@ -96,6 +96,7 @@ $viewUrl = new OntoWiki_Url(array('controller' => 'resource','action' => 'proper //print the value itself until OW_SHOW_MAX if (isset($value['url']) && $value['url'] !== null && $i
  • + 'resource','action' => 'proper resource=""> + + +
  • OW_SHOW_MAX ?>
  • @@ -157,6 +161,7 @@ $viewUrl = new OntoWiki_Url(array('controller' => 'resource','action' => 'proper $this->instanceData[$this->instanceUri][$property['varName']][0]['uri'] ); ?> + instanceData[$this->instanceUri][$property['varName']][0]['value'], 0, 4 ) !== 'tel:') : ?> 'resource','action' => 'proper resource="instanceData[$this->instanceUri][$property['varName']][0]['uri'] ?>"> instanceData[$this->instanceUri][$property['varName']][0]['value'] ?> + + instanceData[$this->instanceUri][$property['varName']][0]['value'] ?> +
    diff --git a/application/views/templates/partials/list_std_main.phtml b/application/views/templates/partials/list_std_main.phtml index 3f01f0552..6f117875e 100644 --- a/application/views/templates/partials/list_std_main.phtml +++ b/application/views/templates/partials/list_std_main.phtml @@ -7,7 +7,6 @@ $actionMenu->setEntry('Toggle show Resource Query', "javascript:showresQuery()") $actionMenu->setEntry('Toggle show Value Query', "javascript:showvalQuery()"); $actions = new OntoWiki_Menu(); $actions->setEntry('View', $actionMenu); -$this->placeholder('main.window.menu')->set($actions->toArray()); $instances = $this->instances; // get queries @@ -18,6 +17,9 @@ $valueQuery = $instances->getQuery(); $permalink = $instances->getPermalink($this->listName); $config = Erfurt_App::getInstance()->getConfig(); $urlBase = $config->urlBase; +$translate = OntoWiki::getInstance()->translate; + +$this->placeholder('main.window.menu')->set($actions->toArray()); $this->headScript()->prependScript( 'function showPermaLink(){$("#permalink").slideToggle(400);} @@ -43,6 +45,20 @@ $this->headScript()->prependScript( + +heading != '')): ?> +

    heading; ?>

    + instances->getClassComment(); + if ($comment !== false): ?> + + +
    + + + instances->hasData()): ?> @@ -93,3 +109,4 @@ $this->headScript()->prependScript(

    _('No matches.') ?>

    +_('Export list as') ?>: CSV _('or') ?> _('Advanced export options') ?> diff --git a/application/views/templates/resource/properties.phtml b/application/views/templates/resource/properties.phtml index bb0ff3ab6..b905eee59 100644 --- a/application/views/templates/resource/properties.phtml +++ b/application/views/templates/resource/properties.phtml @@ -1,5 +1,8 @@ prePropertiesContent)): ?> -
    prePropertiesContent; ?>
    +
    prePropertiesContent; ?>
    + +templateHtml)): ?> + templateHtml ?> @@ -9,7 +12,7 @@ namespacePrefixes as $prefix => $namespace): ?> > - + predicates as $graph => $predicatesForGraph): ?> predicates[$graph]) > 0): /* has resource predicates from graph at all? */ ?> @@ -20,7 +23,7 @@ - graphUri) ? $this->_('Imported from ') : '' ?> + graphUri) ? $this->_('Imported from') : '' ?> graphs[$graph] ?> @@ -66,15 +69,15 @@
      - values[$graph][$uri] as $entry): ?> - -
    • + values[$graph][$uri] as $entry): $current_value++;?> + +
    • OW_SHOW_MAX) : ?> style="display: none;" >
    • -
    • OW_SHOW_MAX) : ?> style="display: none;" property="" data-object-hash="" content="escape(isset($entry['content']) ? $entry['content'] : $entry['object']); ?>" @@ -87,7 +90,7 @@ ?>
    • - + OW_SHOW_MAX): ?> [_('more') ?>]
    @@ -100,6 +103,9 @@ +templateHtml)): ?> + templateHtml ?> + namespacePrefixes as $prefix => $namespace): ?> diff --git a/config.ini.dist b/config.ini.dist index ebbd0cc34..c9582aa55 100644 --- a/config.ini.dist +++ b/config.ini.dist @@ -65,6 +65,11 @@ store.comparer.ignoredMethods[] = sparqlQuery ;; languages.locale = "en" ; en, de, ru, zh (Chinese) +;;;; +;; Configuration for RDFauthor +;; +rdfauthor.usetemplate = true ; this should be set to false when merging to develop + ;;;; ;; Set this identifier to a unique value if you want to run multiple OntoWiki ;; installations on one server @@ -147,6 +152,13 @@ cache.backend.sqlite.cache_db_complete_path = "/tmp/ow_cache.sqlite" ;; Options for Gearman/worker worker.enable = false +;; TitleHelper Bibiographic URIs +titleHelper.properties.gndPrBody = "http://d-nb.info/standards/elementset/gnd#preferredNameForTheCorporateBody" +titleHelper.properties.gndPrPerson = "http://d-nb.info/standards/elementset/gnd#preferredNameForThePerson" +titleHelper.properties.gndPrSubject= "http://d-nb.info/standards/elementset/gnd#preferredNameForTheSubjectHeading" +titleHelper.properties.gndPrWork = "http://d-nb.info/standards/elementset/gnd#preferredNameForTheWork" +titleHelper.properties.gndPrGeoName= "http://d-nb.info/standards/elementset/gnd#preferredNameForThePlaceOrGeographicName" + ;;;; ;; uncomment this line if you need more information diff --git a/extensions/adaptivecache/AdaptivecacheController.php b/extensions/adaptivecache/AdaptivecacheController.php new file mode 100644 index 000000000..29543c416 --- /dev/null +++ b/extensions/adaptivecache/AdaptivecacheController.php @@ -0,0 +1,377 @@ +_privateConfig->toArray()['mode']; + +// OntoWiki::getInstance()->getNavigation()->disableNavigation(); +// $reducedQuerySet = array(); +// $reducedQuerySet2 = array(); +// +// //get queries and how often they occurred +// $queries = $this->readLog(); +// // if queries are sorted by occurrence evaluation will be faster in erfurt-store +// arsort($queries); +// // count queries and occurrences +// $numberOfQueries = 0; +// $totalAmount = 0; +// foreach ($queries as $query => $amount) { +// $numberOfQueries++; +// $totalAmount = $totalAmount + $amount; +// } +// // calculate expected value +// $expectedValue = $totalAmount / $numberOfQueries; +// // calculate standard deviation +// $sum = 0; +// foreach ($queries as $query => $amount) { +// $sum = $sum + (($amount - $expectedValue) * ($amount - $expectedValue)); +// } +// $standardDeviation = bcsqrt($sum / $numberOfQueries, 4); +// +// // determine which queries should be cached +// $queriesToBeCached = array(); +// $border = $expectedValue - $standardDeviation; +// foreach ($queries as $query => $amount) { +// if ($amount < $standardDeviation + $expectedValue) { +// $reducedQuerySet[$query] = $amount; +// } else { +// $reducedQuerySet2[$query] = $amount; +// } +// if ($amount > ($expectedValue)) { +// $queriesToBeCached[] = $query; +// } +// } +// +// +// $reducedNumberOfQueries = 0; +// $reducedTotalAmount = 0; +// foreach ($reducedQuerySet as $query => $amount) { +// $reducedNumberOfQueries++; +// $reducedTotalAmount = $reducedTotalAmount + $amount; +// } +// $reducedExpectedValue = $reducedTotalAmount / $reducedNumberOfQueries; +// $reducedSum = 0; +// foreach ($reducedQuerySet as $query => $amount) { +// $reducedSum = $reducedSum + (($amount - $reducedExpectedValue) * ($amount - $reducedExpectedValue)); +// } +// $reducedStandardDeviation = bcsqrt($reducedSum / $reducedNumberOfQueries, 4); +// $reducedQueriesToBeCached = array(); +// foreach ($reducedQuerySet as $query => $amount) { +// if ($amount > ($reducedExpectedValue)) { +// $reducedQueriesToBeCached[] = $query; +// } +// } +// foreach ($reducedQuerySet2 as $query => $amount) { +// $reducedQueriesToBeCached[] = $query; +// } + + $path = realpath(null) . '/extensions/adaptivecache/resources/store.txt'; + $this->view->logFileSize = round((filesize($path) / 1048576), 1); + +// $this->view->totalAmountOfQueries = $totalAmount; +// $this->view->numberOfQueries = $numberOfQueries; +// $this->view->cachedQueries = count($queriesToBeCached); +// $this->view->expectedValue = round($expectedValue, 2); +// $this->view->standardDeviation = round($standardDeviation, 2); +// +// $this->view->rnumberOfQueries = $reducedNumberOfQueries; +// $this->view->rcachedQueries = count($reducedQueriesToBeCached); +// $this->view->rexpectedValue = round($reducedExpectedValue, 2); +// $this->view->rstandardDeviation = round($reducedStandardDeviation, 2); + + $response = $this->calculateWithFullDataSet(); + $this->view->totalAmountOfQueries = $response['totalAmountOfQueries']; + $this->view->numberOfQueries = $response['numberOfQueries']; + $this->view->cachedQueries = count($response['cachedQueries']); + $this->view->expectedValue = round($response['expectedValue'], 2); + $this->view->standardDeviation = round($response['standardDeviation'], 2); + + $response = $this->calculateWithoutPeaks(); + $this->view->rnumberOfQueries = $response['numberOfQueries']; + $this->view->rcachedQueries = count($response['cachedQueries']); + $this->view->rexpectedValue = round($response['expectedValue'], 2); + $this->view->rstandardDeviation = round($response['standardDeviation'], 2); + + $response = $this->calculateWithPeaksOnly(); + $this->view->ptotalAmount = $response['totalAmountOfQueries']; + $this->view->pcachedQueries = count($response['cachedQueries']); + $this->view->pexpectedValue = round($response['expectedValue'], 2); + $this->view->pstandardDeviation = round($response['standardDeviation'], 2); + + $this->view->mode = $mode; + } + + public function logAction() + { + $query = $this->_request->getParam('query'); + $this->writeLog($query); + } + + private function calculateWithFullDataSet() + { + $response = array(); + //get queries and how often they occurred + $queries = $this->readLog(); + // if queries are sorted by occurrence evaluation will be faster in erfurt-store + arsort($queries); + // count queries and occurrences + $numberOfQueries = 0; + $totalAmount = 0; + foreach ($queries as $query => $amount) { + $numberOfQueries++; + $totalAmount = $totalAmount + $amount; + } + // calculate expected value + $expectedValue = $totalAmount / $numberOfQueries; + // calculate standard deviation + $sum = 0; + foreach ($queries as $query => $amount) { + $sum = $sum + (($amount - $expectedValue) * ($amount - $expectedValue)); + } + $standardDeviation = bcsqrt($sum / $numberOfQueries, 4); + + // determine which queries should be cached + $queriesToBeCached = array(); + foreach ($queries as $query => $amount) { + if ($amount > ($expectedValue)) { + $queriesToBeCached[] = $query; + } + } + + $response['totalAmountOfQueries'] = $totalAmount; + $response['numberOfQueries'] = $numberOfQueries; + $response['cachedQueries'] = $queriesToBeCached; + $response['expectedValue'] = $expectedValue; + $response['standardDeviation'] = $standardDeviation; + return $response; + } + + private function calculateWithoutPeaks() + { + //get queries and how often they occurred + $queries = $this->readLog(); + $totalAmount = 0; + $numberOfQueries = 0; + foreach ($queries as $query => $amount) { + $numberOfQueries++; + $totalAmount = $totalAmount + $amount; + } + //get pre-calculated data + $response = $this->calculateWithFullDataSet(); + $expectedValue = $response['expectedValue']; + $standardDeviation = $response['standardDeviation']; + + // refine data + foreach ($queries as $query => $amount) { + if ($amount < $standardDeviation + $expectedValue) { + $reducedQuerySet[$query] = $amount; + } else { + $reducedQuerySet2[$query] = $amount; + } + } + + $reducedNumberOfQueries = 0; + $reducedTotalAmount = 0; + foreach ($reducedQuerySet as $query => $amount) { + $reducedNumberOfQueries++; + $reducedTotalAmount = $reducedTotalAmount + $amount; + } + $reducedExpectedValue = $reducedTotalAmount / $reducedNumberOfQueries; + $reducedSum = 0; + foreach ($reducedQuerySet as $query => $amount) { + $reducedSum = $reducedSum + (($amount - $reducedExpectedValue) * ($amount - $reducedExpectedValue)); + } + $reducedStandardDeviation = bcsqrt($reducedSum / $reducedNumberOfQueries, 4); + $reducedQueriesToBeCached = array(); + foreach ($reducedQuerySet as $query => $amount) { + if ($amount > ($reducedExpectedValue)) { + $reducedQueriesToBeCached[] = $query; + } + } + foreach ($reducedQuerySet2 as $query => $amount) { + $reducedQueriesToBeCached[] = $query; + } + + $response['totalAmountOfQueries'] = $reducedTotalAmount; + $response['numberOfQueries'] = $reducedNumberOfQueries; + $response['cachedQueries'] = $reducedQueriesToBeCached; + $response['expectedValue'] = $reducedExpectedValue; + $response['standardDeviation'] = $reducedStandardDeviation; + + return $response; + } + + private function calculateWithPeaksOnly(){ + //get queries and how often they occurred + $queries = $this->readLog(); + $totalAmount = 0; + $numberOfQueries = 0; + foreach ($queries as $query => $amount) { + $numberOfQueries++; + $totalAmount = $totalAmount + $amount; + } + + //get pre-calculated data + $response = $this->calculateWithFullDataSet(); + $expectedValue = $response['expectedValue']; + $standardDeviation = $response['standardDeviation']; + + // refine data + foreach ($queries as $query => $amount) { + if ($amount > $standardDeviation + $expectedValue) { + $reducedQuerySet[$query] = $amount; + } + } + + $reducedNumberOfQueries = 0; + $reducedTotalAmount = 0; + foreach ($reducedQuerySet as $query => $amount) { + $reducedNumberOfQueries++; + $reducedTotalAmount = $reducedTotalAmount + $amount; + } + $reducedExpectedValue = $reducedTotalAmount / $reducedNumberOfQueries; + $reducedSum = 0; + foreach ($reducedQuerySet as $query => $amount) { + $reducedSum = $reducedSum + (($amount - $reducedExpectedValue) * ($amount - $reducedExpectedValue)); + } + $reducedStandardDeviation = bcsqrt($reducedSum / $reducedNumberOfQueries, 4); + $reducedQueriesToBeCached = array(); + foreach ($reducedQuerySet as $query => $amount) { + $reducedQueriesToBeCached[] = $query; + } + + $response['totalAmountOfQueries'] = $reducedTotalAmount; + $response['cachedQueries'] = $reducedQueriesToBeCached; + $response['expectedValue'] = $reducedExpectedValue; + $response['standardDeviation'] = $reducedStandardDeviation; + + return $response; + } + + public function analyzeAction() + { + $mode = $this->_privateConfig->toArray()['mode']; + $ok = false; + if ($mode === '1') { + $data = $this->calculateWithFullDataSet(); + $ok = true; + } + if ($mode === '2') { + $data = $this->calculateWithoutPeaks(); + $ok = true; + } + if ($mode === '3') { + $data = $this->calculateWithPeaksOnly(); + $ok = true; + } + + if ($ok) { + $queriesToBeCached = $data['cachedQueries']; + // write query look-up + $path = realpath(null) . '/extensions/adaptivecache/resources/queries.txt'; + file_put_contents($path, implode('', $queriesToBeCached), LOCK_EX); + // shorten log + $this->shortenLog(); + } + $this->getHelper('Layout')->disableLayout(); + $this->getHelper('ViewRenderer')->setNoRender(); + } + + private function writeLog($query) + { + $path = realpath(null) . '/extensions/adaptivecache/resources/store.txt'; + file_put_contents($path, $query, FILE_APPEND | LOCK_EX); + } + + private function readLog() + { + $alldata = array(); + $path = realpath(null) . '/extensions/adaptivecache/resources/store.txt'; + $linecount = 0; + $handle = fopen($path, "r"); + while (!feof($handle)) { + $line = fgets($handle); + $linecount++; + if (isset($alldata[$line])) { + $alldata[$line] = $alldata[$line] + 1; + } else { + $alldata[$line] = 1; + } + } + fclose($handle); + // if queries are sorted by occurrence evaluation will be faster in erfurt-store + arsort($alldata); + return $alldata; + } + + private function shortenLog() + { + $array = $this->_privateConfig->toArray(); + $numberOfLinesToKeep = $array['evaluationBase']; + + $path = realpath(null) . '/extensions/adaptivecache/resources/store.txt'; + $linecount = 0; + $handle = fopen($path, "r"); + while (!feof($handle)) { + $linecount++; + $line = fgets($handle); + } + fclose($handle); + + $linesToKeep = array(); + + if ($linecount > $numberOfLinesToKeep) { + $borderLine = $linecount - $numberOfLinesToKeep; + $linecount = 0; + $handle = fopen($path, "r"); + while (!feof($handle)) { + $linecount++; + $line = fgets($handle); + if ($linecount > $borderLine) { + if ($line !== PHP_EOL) { + $linesToKeep[] = $line; + } + } + } + fclose($handle); + file_put_contents($path, implode('', $linesToKeep), LOCK_EX); + } + } + + private function readStorage() + { + $alldata = array(); + $path = realpath(null) . '/extensions/adaptivecache/resources/store.txt'; + if (($handle = fopen($path, "r")) !== FALSE) { + while (($data = fgetcsv($handle, 1000, "#")) !== FALSE) { + array_push($alldata, $data); + } + fclose($handle); + } + return $alldata; + } +} \ No newline at end of file diff --git a/extensions/adaptivecache/AdaptivecacheHelper.php b/extensions/adaptivecache/AdaptivecacheHelper.php new file mode 100644 index 000000000..a15e7a17a --- /dev/null +++ b/extensions/adaptivecache/AdaptivecacheHelper.php @@ -0,0 +1,28 @@ +. +@prefix doap: . +@prefix rdfs: . +@prefix owconfig: . +@prefix extension: . +@prefix foaf: . +@prefix event: . +@prefix : . + +<> foaf:primaryTopic :adaptivecache . +:adaptivecache a doap:Project ; + doap:name "adaptivecache" ; + owconfig:privateNamespace ; + owconfig:enabled "true"^^xsd:false ; + owconfig:evaluationBase 1000 ; + owconfig:mode 1 ; + rdfs:label "Adaptive Cache" ; + doap:description "Generates a list of queries that are relevant for caching." ; + owconfig:authorLabel "AMSL" ; + owconfig:templates "templates" ; + owconfig:languages "languages/" ; + doap:maintainer . + +:application :hideForAnonymousOnNoModels "false"^^xsd:boolean ; + doap:release :v1-0 . +:v1-0 a doap:Version ; + doap:revision "1.0" . \ No newline at end of file diff --git a/extensions/adaptivecache/list.phtml b/extensions/adaptivecache/list.phtml new file mode 100644 index 000000000..c419de081 --- /dev/null +++ b/extensions/adaptivecache/list.phtml @@ -0,0 +1,6 @@ +getUrlBase(); +?> +
    + HALLO WELT!! +
    \ No newline at end of file diff --git a/extensions/adaptivecache/resources/queries.txt b/extensions/adaptivecache/resources/queries.txt new file mode 100755 index 000000000..e69de29bb diff --git a/extensions/adaptivecache/resources/store.txt b/extensions/adaptivecache/resources/store.txt new file mode 100755 index 000000000..e69de29bb diff --git a/extensions/adaptivecache/templates/adaptivecache/list.phtml b/extensions/adaptivecache/templates/adaptivecache/list.phtml new file mode 100644 index 000000000..4383ea132 --- /dev/null +++ b/extensions/adaptivecache/templates/adaptivecache/list.phtml @@ -0,0 +1,27 @@ +getUrlBase(); +?> +
    +Meta-data:
    +Size of log-file (MByte): logFileSize ?>
    +Amount of queries used for evaluation: totalAmountOfQueries ?>
    +Number of equal-queries (eq): numberOfQueries ?>* (numberOfQueries / $this->totalAmountOfQueries) * 100), 1)) ?>% of evaluation basis)
    +


    +Using full data set: mode == '1')?'<- this mode is in use':'') ?>
    +Number of eq to be cached: cachedQueries ?> (cachedQueries / $this->numberOfQueries) * 100), 1)) ?>% of *)
    +Average number of calls per eq: expectedValue ?>
    +Standard deviation of calls per eq: standardDeviation ?>
    +Number of eq within standard deviation: rnumberOfQueries ?> (rnumberOfQueries / $this->numberOfQueries) * 100), 2)) ?>% of *)
    +Number of eq above standard deviation: numberOfQueries - $this->rnumberOfQueries) ?> (numberOfQueries - $this->rnumberOfQueries) / $this->numberOfQueries) * 100), 2)) ?>% of *)
    +


    +Cutting off peaks for average: mode == '2')?'<- this mode is in use':'') ?>
    +Adapted number of eq to be cached: rcachedQueries ?> (rcachedQueries / $this->rnumberOfQueries) * 100), 1)) ?>% of *)
    +Adapted average number of calls per eq: rexpectedValue ?>
    +Adapted standard deviation of calls per eq: rstandardDeviation ?>
    +


    +Cache peaks only (with more than expectedValue + $this->standardDeviation)) ?> calls): mode == '3')?'<- this mode is in use':'') ?>
    +Adapted number of eq to be cached: pcachedQueries ?> (pcachedQueries / $this->numberOfQueries) * 100), 1)) ?>% of *)
    +Adapted average number of calls per eq: pexpectedValue ?>
    +Adapted standard deviation of calls per eq: pstandardDeviation ?>
    +Share of peak-queries of evaluation base: ptotalAmount / $this->totalAmountOfQueries) * 100), 1)) ?>% of *
    +
    \ No newline at end of file diff --git a/extensions/archive/ArchivePlugin.php b/extensions/archive/ArchivePlugin.php new file mode 100644 index 000000000..3b70616ac --- /dev/null +++ b/extensions/archive/ArchivePlugin.php @@ -0,0 +1,88 @@ +_config = $this->_privateConfig; + $this->owApp = OntoWiki::getInstance(); + } + + public function onBeforeInitController() + { + $config = $this->_privateConfig->toArray(); + if(filter_var($config['archiveEndpoint'], FILTER_VALIDATE_URL)) { + $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); + + $request = new OntoWiki_Request(); + $getRequest = $request->getRequestUri(); + + $extrasMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('application')->getSubMenu('Extras'); + + if (!array_key_exists('archive', $_SESSION['ONTOWIKI'])) { + $_SESSION['ONTOWIKI']['archive'] = ''; + } + if ($_SESSION['ONTOWIKI']['archive'] == '') { + $lanMenuEntry = $translate->_('Enable Archive Mode'); + if (strpos($getRequest, '/?') != false) { + $getRequest = str_replace("&archive=false", '', $getRequest); + $getRequest = $getRequest . '&archive=true'; + } else { + $getRequest = str_replace("?archive=false", '', $getRequest); + $getRequest = $getRequest . '?archive=true'; + } + } else { + $lanMenuEntry = $translate->_('Disable Archive Mode'); + if (strpos($getRequest, '/?') != false) { + $getRequest = str_replace("&archive=true", '', $getRequest); + $getRequest = $getRequest . '&archive=false'; + } else { + $getRequest = str_replace("?archive=true", '', $getRequest); + $getRequest = $getRequest . '?archive=false'; + } + } + $extrasMenu->setEntry($lanMenuEntry, $getRequest); + } + } + + public function onPostBootstrap($event) + { + $request = new OntoWiki_Request(); + $requestedLanguage = $request->getParam("archive"); + if ($requestedLanguage == 'true') { + + $config = $this->_privateConfig->toArray(); + $_SESSION['ONTOWIKI']['archive'] = $config['archiveEndpoint']; + } elseif ($requestedLanguage == 'false') { + $_SESSION['ONTOWIKI']['archive'] = ''; + } + + $request = new OntoWiki_Request(); + $this->view->requestURI = $request->getRequestUri(); + } +} diff --git a/extensions/archive/default.ini b/extensions/archive/default.ini new file mode 100644 index 000000000..478185ade --- /dev/null +++ b/extensions/archive/default.ini @@ -0,0 +1,16 @@ +enabled = true +name = Select Language +description = "This plugin is used for switching to a specific language" +author = "Michael Martin" + +[events] +;1 = onAfterConfigurationInitialized +1 = onPostBootstrap +2 = onBeforeInitController +[private] +languages.en = "english (en)" +languages.de = "deutsch (de)" +languages.hu = "magyar (hu)" +languages.zh = "汉语 (zh)" +languages.ru = "русский язык (ru)" +;languages.nl = dutch diff --git a/extensions/archive/doap.n3 b/extensions/archive/doap.n3 new file mode 100644 index 000000000..df050f49e --- /dev/null +++ b/extensions/archive/doap.n3 @@ -0,0 +1,24 @@ +@prefix xsd: . +@prefix doap: . +@prefix rdfs: . +@prefix owconfig: . +@prefix extension: . +@prefix foaf: . +@prefix event: . +@prefix : . + +<> foaf:primaryTopic :archive . +:archive a doap:Project ; + doap:name "Archive" ; + owconfig:privateNamespace ; + owconfig:enabled "false"^^xsd:boolean ; + rdfs:label "Archive" ; + doap:description "Archive plugin" ; + owconfig:authorLabel "AMSL" ; + owconfig:pluginEvent event:onPostBootstrap ; + owconfig:pluginEvent event:onBeforeInitController ; + owconfig:archiveEndpoint "enter URL here" + . +:selectlanguage doap:release :v1-0 . +:v1-0 a doap:Version ; + doap:revision "1.0" . diff --git a/extensions/archive/languages/archivemode-de.csv b/extensions/archive/languages/archivemode-de.csv new file mode 100644 index 000000000..4ba880eba --- /dev/null +++ b/extensions/archive/languages/archivemode-de.csv @@ -0,0 +1,2 @@ +Enable Archive Mode; Archivmodus aktivieren +Disable Archive Mode; Archivmodus deaktivieren \ No newline at end of file diff --git a/extensions/basicimporter/BasicimporterController.php b/extensions/basicimporter/BasicimporterController.php index e12dd951d..f7d465964 100644 --- a/extensions/basicimporter/BasicimporterController.php +++ b/extensions/basicimporter/BasicimporterController.php @@ -196,8 +196,29 @@ private function _import($fileOrUrl, $filetype, $locator) { $modelIri = (string)$this->_model; + // action spec for versioning + $versioning = $this->_erfurt->getVersioning(); + $actionSpec = array(); + $actionSpec['type'] = 11; + $actionSpec['modeluri'] = $modelIri; + $actionSpec['resourceuri'] = $modelIri; + try { + // starting versioning action + $versioning->startAction($actionSpec); + $this->_erfurt->getStore()->importRdf($modelIri, $fileOrUrl, $filetype, $locator); + + // stopping versioning action + $versioning->endAction(); + + /** + * Trigger Reindex + **/ + $indexEvent = new Erfurt_Event('onReindexAction'); + $indexEvent->model = $modelIri; + $indexEvent->trigger(); + } catch (Erfurt_Exception $e) { // re-throw throw new OntoWiki_Controller_Exception( diff --git a/extensions/chronjobs/ChronjobsController.php b/extensions/chronjobs/ChronjobsController.php new file mode 100644 index 000000000..cea6af825 --- /dev/null +++ b/extensions/chronjobs/ChronjobsController.php @@ -0,0 +1,183 @@ +_owApp->getNavigation()->disableNavigation(); + } + + public function runAction() + { + $conf = $this->_privateConfig->toArray(); + $jobs = array(); + foreach ($conf as $job) { + if (isset($job['type']) && ($job['type'] == 'script' || $job['type'] == 'query')) { + array_push($jobs, $job); + } + } + + $storageData = $this->readStorage(); + + $newJobs = 0; + $oldJobs = count($storageData); + foreach ($jobs as $job) { + $data = null; + + // merge numbers of already executed (and thus documented) jobs and (possibly new) configured jobs + $hasJobNumber = false; + $jobnumber = 0; + foreach($storageData as $d){ + if($d[0] == $job['name']){ + $data = $d; + $hasJobNumber = true; + break; + } + $jobnumber++; + } + + if($hasJobNumber){ + $finalJobNumber = $jobnumber; + }else{ + $newJobs++; + $finalJobNumber = $oldJobs + $newJobs; + } + +// if ($this->hasToBeExecuted($job['rhythm'], $job['date'], $job['time'], $job['rectify'], $data)) { + if(true){ + if ($job['type'] == 'script') { + $controllerAndmethod = explode('/', $job['value']); + if (count($controllerAndmethod) == 2) { + $storageData[$finalJobNumber][0] = $job['name']; + $storageData[$finalJobNumber][1] = date('d.m.Y'); + $url = new OntoWiki_Url(array('controller' => $controllerAndmethod[0], 'action' => $controllerAndmethod[1])); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, (string)$url); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_exec($ch); + curl_close($ch); + $storageData[$finalJobNumber][2] = 'success'; + } + } elseif ($job['type'] == 'query') { + $storageData[$finalJobNumber][0] = $job['name']; + $storageData[$finalJobNumber][1] = date('d.m.Y'); + $options = $this->_owApp->getConfig()->toArray()['store']['virtuoso']; + $options['is_open_source_version'] = '1'; + $backend = new Erfurt_Store_Adapter_Virtuoso($options); + $backend->init(); + $query_results = $backend->_execSparqlUpdate($job['value']); + $storageData[$finalJobNumber][2] = 'success'; + } + } + } + + $this->writeStorage($storageData); + + $this->getHelper('Layout')->disableLayout(); + $this->getHelper('ViewRenderer')->setNoRender(); + } + + private function readStorage() + { + $alldata = array(); + $path = realpath(null) . '/extensions/chronjobs/resources/store.txt'; + if (($handle = fopen($path, "r")) !== FALSE) { + while (($data = fgetcsv($handle, 1000, "#")) !== FALSE) { + array_push($alldata, $data); + } + fclose($handle); + } + return $alldata; + } + + private function writeStorage($storageData) + { + $path = realpath(null) . '/extensions/chronjobs/resources/store.txt'; + $writing = fopen($path, 'w'); + ftruncate($writing, 0); + $lines = array(); + foreach($storageData as $dataset){ + $lines[] = implode('#', $dataset); + } + $fileContent = implode(PHP_EOL, $lines); + fputs($writing, $fileContent); + fclose($writing); + + } + + private function hasToBeExecuted($rhythm = null, $date = null, $time = null, $rectify = null, $data) + { + + if ($rhythm == null || $time == null) { + return false; + } + switch ($rhythm) { + case 'daily': + break; + case 'weekly': + if ($date == null || jddayofweek(cal_to_jd(CAL_GREGORIAN, date("m"), date("d"), date("Y")), 2) != $date) { + return false; + } + break; + case 'monthly': + $actualDate = date("d"); + if ($date == null || $actualDate != $date) { + return false; + } + break; + case 'yearly': + $actualDate = date("d") . "." . date("m"); + if ($date == null || $actualDate != $date) { + return false; + } + break; + } + + if ($data != null) { + $lastsheduled = $data[1]; + $date = date('d.m.Y'); + if ($lastsheduled == $date) { + return false; + } else { + $actualTime = date('h:i'); + if($time < $actualTime){ + return true; + }else{ + return false; + } + } + + }else{ + return true; + } + } + + public function exampleAction() + { + $this->getHelper('Layout')->disableLayout(); + $this->getHelper('ViewRenderer')->setNoRender(); + return true; + } +} \ No newline at end of file diff --git a/extensions/chronjobs/ChronjobsHelper.php b/extensions/chronjobs/ChronjobsHelper.php new file mode 100644 index 000000000..7a21d0a94 --- /dev/null +++ b/extensions/chronjobs/ChronjobsHelper.php @@ -0,0 +1,41 @@ +_owApp->getUser(); + $allowed_users = $this->_privateConfig->allowed_users; + $allowed_users = $allowed_users && $allowed_users instanceof Zend_Config ? $allowed_users->toArray() : []; + + // don't add menu entry for non-authorized users +// if (!$user->isDbUser() && !in_array($user->getUri(), $allowed_users)) { +// return; +// } + + // register with extras menu + $translate = $this->_owApp->translate; + $url = new OntoWiki_Url(array('controller' => 'chronjobs', 'action' => 'run')); + $extrasMenu = OntoWiki_Menu_Registry::getInstance()->getMenu('application')->getSubMenu('Extras'); + // $extrasMenu->setEntry($translate->_('ChronJobs'), (string)$url); + } +} + diff --git a/extensions/chronjobs/default.ini b/extensions/chronjobs/default.ini new file mode 100644 index 000000000..dbe814fc1 --- /dev/null +++ b/extensions/chronjobs/default.ini @@ -0,0 +1,14 @@ +;; +; Basic component configuration +;; +enabled = true +templates = "templates" +languages = "languages/" + +action = list +name = "Meta Data Service" +description = "Used to provide information about meta data sources and their collection to third party web sites." +author = "AMSL" +authorUrl = "http://amsl.technology" + +[private] diff --git a/extensions/chronjobs/doap.n3 b/extensions/chronjobs/doap.n3 new file mode 100644 index 000000000..1dbbc1056 --- /dev/null +++ b/extensions/chronjobs/doap.n3 @@ -0,0 +1,34 @@ +@prefix xsd: . +@prefix doap: . +@prefix rdfs: . +@prefix owconfig: . +@prefix extension: . +@prefix foaf: . +@prefix event: . +@prefix : . + +<> foaf:primaryTopic :chonjobs . +:chonjobs a doap:Project ; + doap:name "cronjobs" ; + owconfig:privateNamespace ; + owconfig:enabled "true"^^xsd:boolean ; + rdfs:label "CronJobs" ; + doap:description "Used to provide automated, scheduled but also manually triggeralbe processing." ; + owconfig:authorLabel "AMSL" ; + doap:maintainer ; + owconfig:config [ + a owconfig:Config; + owconfig:id "example"; + owconfig:name "Example"; + owconfig:type "script"; + owconfig:value "chronjobs/example"; + owconfig:rhythm "yearly"; + owconfig:date "3"; + owconfig:time "01:00"; + owconfig:rectify "false"; + ] . + +:application :hideForAnonymousOnNoModels "false"^^xsd:boolean ; + doap:release :v1-0 . +:v1-0 a doap:Version ; + doap:revision "1.0" . diff --git a/extensions/chronjobs/list.phtml b/extensions/chronjobs/list.phtml new file mode 100644 index 000000000..c419de081 --- /dev/null +++ b/extensions/chronjobs/list.phtml @@ -0,0 +1,6 @@ +getUrlBase(); +?> +
    + HALLO WELT!! +
    \ No newline at end of file diff --git a/extensions/chronjobs/resources/store.txt b/extensions/chronjobs/resources/store.txt new file mode 100755 index 000000000..e69de29bb diff --git a/extensions/chronjobs/templates/chronjobs/list.phtml b/extensions/chronjobs/templates/chronjobs/list.phtml new file mode 100644 index 000000000..c419de081 --- /dev/null +++ b/extensions/chronjobs/templates/chronjobs/list.phtml @@ -0,0 +1,6 @@ +getUrlBase(); +?> +
    + HALLO WELT!! +
    \ No newline at end of file diff --git a/extensions/community/CommentModule.php b/extensions/community/CommentModule.php index 2c0427a82..9751a29b9 100644 --- a/extensions/community/CommentModule.php +++ b/extensions/community/CommentModule.php @@ -34,7 +34,7 @@ public function getContents() // comment form part if ((isset($this->_owApp->selectedModel)) - && ($this->_owApp->erfurt->getAc()->isModelAllowed('edit', $this->_owApp->selectedModel)) + && ($this->_owApp->erfurt->getAc()->isModelAllowed('edit', $this->_owApp->selectedModel, true)) ) { $limit = $this->_privateConfig->limit; $actionUrl = new OntoWiki_Url(array('controller' => 'community', 'action' => 'comment'), array()); diff --git a/extensions/community/CommunityController.php b/extensions/community/CommunityController.php index 670da06aa..bec2d1ce1 100644 --- a/extensions/community/CommunityController.php +++ b/extensions/community/CommunityController.php @@ -20,13 +20,14 @@ class CommunityController extends OntoWiki_Controller_Component */ public function listAction() { + $resourceString = $this->_request->getParam('base'); + $resource = new OntoWiki_Resource(urldecode($resourceString)); $translate = $this->_owApp->translate; $singleResource = true; if ($this->_request->getParam('mode') === 'multi') { $windowTitle = $translate->_('Discussion about elements of the list'); $singleResource = false; } else { - $resource = $this->_owApp->selectedResource; if ($resource->getTitle()) { $title = $resource->getTitle(); } else { @@ -44,7 +45,7 @@ public function listAction() } $helper = $this->_owApp->extensionManager->getComponentHelper('community'); - $comments = $helper->getList($this->view, $singleResource, $limit); + $comments = $helper->getList($this->view, $singleResource, $limit, $resource); if ($comments === null) { $this->view->infomessage = 'There are no discussions yet.'; } else { @@ -68,7 +69,7 @@ public function commentAction() $date = date('c'); // xsd:datetime // $date = date('Y-m-d\TH:i:s'); // xsd:dateTime - $resource = (string)$this->_owApp->selectedResource; + $resource = $this->getParam('base'); $aboutProperty = $this->_privateConfig->about->property; $creatorProperty = $this->_privateConfig->creator->property; $commentType = $this->_privateConfig->comment->type; @@ -248,4 +249,51 @@ public function rateAction() // stop Action $versioning->endAction(); } + + /* + * View for displaying extended information to last changes of a resource. + */ + public function listlastchangesAction() + { + $this->versioning = $this->_erfurt->getVersioning(); + $this->model = $this->_owApp->selectedModel; + $params = $this->_request->getParams(); + if (isset($params['page'])){ + $page = $params['page']; + } else { + $page = 1; + } + $this->results = $this->versioning->getHistoryForGraph($this->model->getModelIri(), $page); + $titleHelper = new OntoWiki_Model_TitleHelper(); + $translate = $this->_owApp->translate; + + $userArray = $this->_erfurt->getUsers(); + foreach ($this->results as $key => $entry) { + + $this->results[$key]['url'] = $this->_config->urlBase . "view?r=" . urlencode($entry['resource']); + $titleHelper->addResource($entry['resource']); + + if ($entry['useruri'] == $this->_erfurt->getConfig()->ac->user->anonymousUser) { + $userArray[$entry['useruri']] = 'Anonymous'; + } else if ($entry['useruri'] == $this->_erfurt->getConfig()->ac->user->superAdmin) { + $userArray[$entry['useruri']] = 'SuperAdmin'; + } else if (is_array($userArray[$entry['useruri']])) { + if (isset($userArray[$entry['useruri']]['userName'])) { + $userArray[$entry['useruri']] = $userArray[$entry['useruri']]['userName']; + } else { + $titleHelper->addResource($entry['useruri']); + $userArray[$entry['useruri']] = $titleHelper->getTitle($entry['useruri']); + } + } + } + + $this->view->placeholder('main.window.title')->set($translate->_('Last changes')); + $this->view->userArray = $userArray; + $this->view->translate = $translate; + $this->view->results = $this->results; + $this->view->model = $this->model->getTitle(); + $this->view->titleHelper = $titleHelper; + $this->view->page = $page; + $this->_owApp->getNavigation()->disableNavigation(); + } } diff --git a/extensions/community/CommunityHelper.php b/extensions/community/CommunityHelper.php index 50c8adb43..b73b1dff0 100644 --- a/extensions/community/CommunityHelper.php +++ b/extensions/community/CommunityHelper.php @@ -42,11 +42,16 @@ public function init() } } - public function getList($view, $singleResource = true, $limit = null) + public function getList($view, $singleResource = true, $limit = null, $r = null) { $store = $this->_owApp->erfurt->getStore(); $graph = $this->_owApp->selectedModel; - $resource = $this->_owApp->selectedResource; + if($r == null){ + $resource = $this->_owApp->selectedResource; + }else{ + $resource = $r; + } + $aboutProperty = $this->_privateConfig->about->property; $creatorProperty = $this->_privateConfig->creator->property; diff --git a/extensions/community/LastchangesModule.php b/extensions/community/LastchangesModule.php index 72a99a749..0684687aa 100644 --- a/extensions/community/LastchangesModule.php +++ b/extensions/community/LastchangesModule.php @@ -62,6 +62,7 @@ public function shouldShow() public function getContents() { + $url = new OntoWiki_Url(array('route' => 'properties'), array('r')); $changes = array(); if ($this->results) { @@ -86,6 +87,10 @@ public function getContents() $change['resource'] = new OntoWiki_Resource((string)$change['resource'], $this->model); $change['rname'] = $change['resource']->getTitle() ? $change['resource']->getTitle() : OntoWiki_Utils::contractNamespace($change['resource']->getIri()); + if(preg_match('/[a-z0-9]{32}/' , $change['rname']) == 1){ + $change['rname'] = chunk_split($change['rname'],16, ' '); + //$change['rname'] = substr($change['rname'], 0, 17) . '...'; + } $changes[] = $change; } @@ -100,4 +105,4 @@ public function getContents() return $this->render('templates/lastchanges'); } -} +} \ No newline at end of file diff --git a/extensions/community/templates/comment.phtml b/extensions/community/templates/comment.phtml index f940ff23e..65a54c5eb 100644 --- a/extensions/community/templates/comment.phtml +++ b/extensions/community/templates/comment.phtml @@ -1,7 +1,14 @@ +selectedResource; +$uri = $resource->getNameSpace() . $resource->getLocalName(); +$urlBase = OntoWiki::getInstance()->getUrlBase(); +?>

    context == 'main.window.community') : ?> + add comment icon _('Post Comment') ?> @@ -9,6 +16,7 @@ +