/** * Returns the title of the module * * @return string */ public function getTitle() { $title = 'OntoWiki'; if (!$this->_owApp->user instanceof Erfurt_Auth_Identity) { return $title; } if ($this->_owApp->user->isOpenId() || $this->_owApp->user->isWebId()) { if ($this->_owApp->user->getLabel() !== '') { $userName = $this->_owApp->user->getLabel(); $userName = OntoWiki_Utils::shorten($userName, 25); } else { $userName = OntoWiki_Utils::getUriLocalPart($this->_owApp->user->getUri()); $userName = OntoWiki_Utils::shorten($userName, 25); } } else { if ($this->_owApp->user->getUsername() !== '') { $userName = $this->_owApp->user->getUsername(); $userName = OntoWiki_Utils::shorten($userName, 25); } else { $userName = OntoWiki_Utils::getUriLocalPart($this->_owApp->user->getUri()); $userName = OntoWiki_Utils::shorten($userName, 25); } } if (isset($userName) && $userName !== 'Anonymous') { $title .= ' (' . $userName . ')'; } return $title; }
public function getContents() { $url = new OntoWiki_Url(array('route' => 'properties'), array('r')); $changes = array(); if ($this->results) { foreach ($this->results as $change) { if ($this->getContext() == "main.window.dashmodelinfo") { //id, resource, tstamp, action_type $change['useruri'] = $this->user; $this->model = null; } if (Erfurt_Uri::check($change['resource'])) { $change['aresource'] = new OntoWiki_Resource((string) $change['useruri'], $this->systemModel); $change['author'] = $change['aresource']->getTitle() ? $change['aresource']->getTitle() : OntoWiki_Utils::getUriLocalPart($change['aresource']); $url->setParam('r', (string) $change['aresource'], true); $change['ahref'] = (string) $url; //$change['date'] = OntoWiki_Utils::dateDifference($change['tstamp'], null, 3); $url->setParam('r', (string) $change['resource'], true); $change['rhref'] = (string) $url; $change['resource'] = new OntoWiki_Resource((string) $change['resource'], $this->model); $change['rname'] = $change['resource']->getTitle() ? $change['resource']->getTitle() : OntoWiki_Utils::contractNamespace($change['resource']->getIri()); $changes[] = $change; } } } if (empty($changes)) { $this->view->infomessage = 'There are no changes yet.'; } else { $this->view->changes = $changes; } return $this->render('templates/lastchanges'); }
public function onDisplayLiteralPropertyValue($event) { $parameter = $event->getParams(); if (!empty($parameter['datatype'])) { $url = new OntoWiki_Url(array('route' => 'properties'), array('r')); $url->setParam('r', $parameter['datatype'], true); $datatypeLink = "<a class=\"hasMenu\" about=\"" . $parameter['datatype'] . "\" href=\"" . (string) $url . "\">" . OntoWiki_Utils::getUriLocalPart($parameter['datatype']) . "</a>"; $ret = "<span>" . $parameter['value'] . "</span>"; $ret .= "<span style = 'float:right;margin-left:2em'>[" . $datatypeLink . "]</span>"; return $ret; } if (!empty($parameter['language'])) { $ret = "<span>" . $parameter['value'] . "</span>"; $ret .= "<span style = 'float:right;margin-left:2em'>[" . $parameter['language'] . "]</span>"; return $ret; } }
/** * extract the localname from given resourceUri * * @param string resourceUri * @return string title */ private function _extractTitleFromLocalName($resourceUri) { $title = OntoWiki_Utils::contractNamespace($resourceUri); // not even namespace found? if ($title == $resourceUri && $this->_alwaysUseLocalNames) { $title = OntoWiki_Utils::getUriLocalPart($resourceUri); } return $title; }
/** * Returns the title property for the resource URI in the requested language. * If no title property is found for that language a list of fallback languages * is used. If no title property is found for any language, the local part * of the resource URI is returned. * * @param string $resourceUri * @param string $language The preferred language for the title * * @return string */ public function getTitle($resourceUri, $language = null) { if (!Erfurt_Uri::check($resourceUri)) { return $resourceUri; } $cacheValue = $this->_cache($resourceUri, (string) $this->_model); if ($cacheValue === false) { // * means any language if (trim($language) == '*') { $language = null; } // add if we don't have this URI (but logg) if (!array_key_exists($resourceUri, (array) $this->_resources)) { if (defined('_OWDEBUG')) { $logger = OntoWiki::getInstance()->logger; $logger->info('TitleHelper: getTitle called for unknown resource. Adding resource before fetch.'); } $this->addResource($resourceUri); } // if this is the first getTitle request, fetch titles if (!array_key_exists($resourceUri, $this->_resourceTitles)) { $this->_fetchResourceTitlesFromQueryResult(); } // 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)); $title = null; // has anything been found for the resource? if (array_key_exists($resourceUri, $this->_resourceTitles)) { $titleProperties = (array) $this->_resourceTitles[$resourceUri]; $currentBestLanguage = PHP_INT_MAX; foreach ($this->_titleProperties as $currentTitleProperty) { // has the property been found for the resource? if (array_key_exists($currentTitleProperty, $titleProperties)) { for ($i = 0, $max = count($languages); $i < $max; ++$i) { $currentLanguage = $languages[$i]; if ($i < $currentBestLanguage && isset($titleProperties[$currentTitleProperty][$currentLanguage])) { $title = $titleProperties[$currentTitleProperty][$currentLanguage]; $currentBestLanguage = $i; if (!$this->_alwaysSearchAllProperties || $currentBestLanguage === 0) { // it won't get better :) break 2; } } } } } } // still not found? if (null === $title) { $title = OntoWiki_Utils::contractNamespace($resourceUri); // not even namespace found? if ($title == $resourceUri && $this->_alwaysUseLocalNames) { $title = OntoWiki_Utils::getUriLocalPart($resourceUri); // now we have to add this localName to the ResourceTitles array to prevent // querying of resources without titles all the time $this->_resourceTitles[$resourceUri]["localname"]["localname"] = $title; } } $this->_cache($resourceUri, (string) $this->_model, $title); } else { // cached title $title = $cacheValue; } return $title; }