Permalink
Browse files

Squashed commit of Matthimatiker branch.

Cherrypicked the minor additions as proposed in pull request #308.
Close #308.

Conflicts:
	application/controllers/ResourceController.php

Original commits:

commit 4a3dd0c
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Sat Mar 22 14:01:44 2014 +0100

    removed usage of undeclared properties that are not accessed afterwards

commit 28b009e
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Sat Mar 22 13:54:17 2014 +0100

    introduced workaround to avoid storing global objects in the session

commit 2be2305
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Mon Mar 17 23:06:37 2014 +0100

    changed handling of translator and view references to avoid storing the whole view graph in the session whenever a message is added

commit db36002
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Tue Jan 28 22:02:58 2014 +0100

    news feed url is now configurable

commit e496127
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Tue Jan 28 21:42:27 2014 +0100

    added stricter timeout to ensure that the Wiki is usable if the AKSW blog is not reachable

commit 5439d73
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Tue Jan 28 21:36:48 2014 +0100

    refactoring: extracted method; reduced duplicated code

commit af17400
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Tue Jan 28 21:24:55 2014 +0100

    fixed typo

commit 333a3aa
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Mon Jan 27 19:07:33 2014 +0100

    use line breaks to improve readability of SPARQL error

commit 3734cc2
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Mon Jan 27 19:06:27 2014 +0100

    escape errors to ensure that they are readable in the browser

commit 319fd03
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Mon Jan 27 18:56:21 2014 +0100

    OntoWiki recommends to disable short open tags, therefore, the templates should not rely on it

commit ebb6e38
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Mon Jan 27 13:37:55 2014 +0100

    fixed query: according to <http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rSelectClause>, a comma is not allowed between variables

commit 03d0a4e
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Sun Jan 26 16:26:23 2014 +0100

    only apply max_execution_time setting if the execution time is increased

commit 49ce0e7
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Thu Jan 23 17:18:37 2014 +0100

    changed parameter retrieval to avoid PHP notices when they do not exist

commit 400300f
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Sun Jan 19 13:43:24 2014 +0100

    escaped error text to ensure that messages with for example SPARQL queries are at least readable in the browser

commit f4156e1
Author: Matthias Molitor <matthias@matthimatiker.de>
Date:   Sun Jan 19 12:53:10 2014 +0100

    introduced optional class loading via Composer
  • Loading branch information...
white-gecko committed Apr 4, 2016
1 parent a43feb7 commit fb18b81d5d13e0c5e5eb043bb036435c0fecf2d9
@@ -66,20 +66,6 @@ class OntoWiki_Message
*/
protected $_text = null;
/**
* The current view object
*
* @var OntoWiki_View
*/
protected $_view = null;
/**
* The translation object
*
* @var Zend_Translate
*/
protected $_translate = null;
/**
* Constructor
*
@@ -97,19 +83,6 @@ public function __construct($text, $type = self::INFO, $options = array())
$this->_type = $type;
$this->_text = $text;
// Clone view
if (null === $this->_view) {
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if (null === $viewRenderer->view) {
$viewRenderer->initView();
}
$this->_view = clone $viewRenderer->view;
$this->_view->clearVars();
}
// get translation for current language
$this->_translate = OntoWiki::getInstance()->translate;
}
/**
@@ -133,19 +106,45 @@ public function getText()
if (strlen($text) > 1000) {
$text = substr($text, 0, 1000) . '...';
}
$text = $this->_options['escape'] ? $this->_view->escape($text) : $text;
$text = $this->_options['escape'] ? $this->getView()->escape($text) : $text;
return $text;
}
private function _translate($text)
/**
* Returns the view object.
*
* @return OntoWiki_View
*/
protected function getView()
{
if (($this->_options['translate'] === true) && (null !== $this->_translate)) {
return $this->_translate->translate($text);
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if (null === $viewRenderer->view) {
$viewRenderer->initView();
}
$view = clone $viewRenderer->view;
$view->clearVars();
return $view;
}
/**
* Returns the translator.
*
* @return Zend_Translate
*/
protected function getTranslator()
{
return OntoWiki::getInstance()->translate;
}
private function _translate($text)
{
if (($this->_options['translate'] === true) && ($translator = $this->getTranslator()) !== null) {
return $translator->translate($text);
}
return $text;
}
}
@@ -14,6 +14,9 @@
* @copyright Copyright (c) 2012, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
* @author Norman Heino <norman.heino@gmail.com>
* @property Zend_Log $_logger
* @property Erfurt_Event_Dispatcher $_eventDispatcher
* @property Zend_Config $_config The application configuration.
*/
class OntoWiki_Model
{
@@ -24,27 +27,13 @@ class OntoWiki_Model
*/
protected $_store = null;
/**
* The OntoWiki Application config
*
* @var Zend_Config
*/
protected $_config = null;
/**
* Whether inference features are turned on
*
* @var boolean
*/
protected $_inference = true;
/**
* The Application logger
*
* @var Zend_Log
*/
protected $_logger = null;
/**
* Model instance
*
@@ -59,23 +48,13 @@ class OntoWiki_Model
*/
protected $_graph = null;
/**
* The Erfurt event dispatcher
*
* @var Erfurt_Event_Dispatcher
*/
protected $_eventDispatcher = null;
/**
* Constructor
*/
public function __construct(Erfurt_Store $store, Erfurt_Rdf_Model $graph)
{
// system variables
$this->_store = $store;
$this->_config = OntoWiki::getInstance()->config;
$this->_logger = OntoWiki::getInstance()->logger;
$this->_eventDispatcher = Erfurt_Event_Dispatcher::getInstance();
if (isset($this->_config->system->inference) && !(bool)$this->_config->system->inference) {
$this->_inference = false;
@@ -110,5 +89,29 @@ public function getGraph()
{
return $this->_model;
}
/**
* Simulates properties that reference global objects.
*
* The globals are *not* stored as properties of this objects, otherwise
* these globals (and the whole object graph that is connected to them)
* are serialized when this object is stored in the session.
*
* @param string $name
* @return Erfurt_Event_Dispatcher|Zend_Log|Zend_Config|null
*/
public function __get($name)
{
switch ($name) {
case '_logger':
return OntoWiki::getInstance()->logger;;
case '_eventDispatcher':
return Erfurt_Event_Dispatcher::getInstance();
case '_config':
return OntoWiki::getInstance()->config;
}
return null;
}
}
@@ -164,10 +164,6 @@ public function __construct(Erfurt_Store $store, Erfurt_Rdf_Model $model, $optio
$this->_useCache = $options[Erfurt_Store::USE_CACHE];
}
//TODO still needed?
$this->_defaultUrl['resource'] = new OntoWiki_Url(array('route' => 'properties'), array());
$this->_defaultUrlParam['resource'] = 'r';
$this->_resourceQuery = new Erfurt_Sparql_Query2();
$this->_resourceVar = new Erfurt_Sparql_Query2_Var('resourceUri');
@@ -15,6 +15,12 @@
*/
class IndexController extends OntoWiki_Controller_Base
{
/**
* Timeout for reading the OntoWiki RSS news feed.
*/
const NEWS_FEED_TIMEOUT_IN_SECONDS = 3;
/**
* Displays the OntoWiki news feed short summary (dashboard part)
*/
@@ -23,26 +29,8 @@ public function newsshortAction()
// requires zend Feed module
// number of news
$feedCount = 3;
// create empty var for feed
$owFeed = null;
// get current version
$version = $this->_config->version;
// try reading
try {
$url = 'http://blog.aksw.org/feed/?cat=5&client='
. $version->label
. '&version='
. $version->number
. '&suffix='
. $version->suffix;
$owFeed = $this->getNews();
$owFeed = Zend_Feed::import($url);
} catch (Exception $e) {
$this->_owApp->appendMessage(
new OntoWiki_Message('Error loading feed: ' . $url, OntoWiki_Message::WARNING)
);
$owFeed = array();
}
// create new array for data
$data = array();
// parse feed items into array
@@ -67,7 +55,7 @@ public function newsshortAction()
}
/**
* Displays messages only without any othe content.
* Displays messages only without any other content.
*/
public function messagesAction()
{
@@ -81,32 +69,15 @@ public function messagesAction()
*/
public function newsAction()
{
$owFeed = null;
$version = $this->_config->version;
$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);
$owFeed = Zend_Feed::import($url);
$this->view->feed = $owFeed;
$owFeed = $this->getNews();
$this->view->feed = $owFeed;
if ($owFeed instanceof Zend_Feed_Abstract) {
$this->view->title = $owFeed->title();
$this->view->link = $owFeed->link();
$this->view->description = $owFeed->description();
} catch (Exception $e) {
$this->_owApp->appendMessage(
new OntoWiki_Message('Error loading feed: ' . $url, OntoWiki_Message::WARNING)
);
$this->view->feed = array();
}
OntoWiki::getInstance()->getNavigation()->disableNavigation();
}
@@ -143,4 +114,35 @@ public function emptyAction()
// sorry for this hack, but I dont wanted to modify the the main layout too much ...
$this->view->placeholder('main.window.additionalclasses')->set('hidden');
}
/**
* Reads OntoWiki news from the AKSW RSS feed.
*
* @return array|Zend_Feed_Abstract
*/
public function getNews()
{
// get current version
$version = $this->_config->version;
// try reading
try {
$url = $this->_config->news->feedUrl;
$url = strtr($url, array(
'{{version.label}}' => urlencode($version->label),
'{{version.number}}' => urlencode($version->number),
'{{version.suffix}}' => urlencode($version->suffix)
));
/* @var $client Zend_Http_Client */
$client = Zend_Feed::getHttpClient();
$client->setConfig(array('timeout' => self::NEWS_FEED_TIMEOUT_IN_SECONDS));
$owFeed = Zend_Feed::import($url);
return $owFeed;
} catch (Exception $e) {
$this->_owApp->appendMessage(
new OntoWiki_Message('Error loading feed: ' . $url, OntoWiki_Message::WARNING)
);
return array();
}
}
}
@@ -840,9 +840,8 @@ public function updateAction()
*/
private function _doImportActionRedirect($modelUri)
{
$post = $this->_request->getPost();
$id = $post['importAction'];
$importOptions = $post['importOptions'];
$id = $this->_request->getPost('importAction');
$importOptions = $this->_request->getPost('importOptions');
$actions = $this->_getImportActions();
if (isset($actions[$id])) {
@@ -371,7 +371,7 @@ public function deleteAction()
// query for all triples to delete them
$sparqlQuery = new Erfurt_Sparql_SimpleQuery();
$sparqlQuery->setSelectClause('SELECT ?p, ?o');
$sparqlQuery->setSelectClause('SELECT ?p ?o');
$sparqlQuery->addFrom($modelIri);
$sparqlQuery->setWherePart('{ <' . $resource . '> ?p ?o . }');
@@ -42,7 +42,7 @@ body {
<?php endif; ?>
</h1>
<details>
<summary><?php echo $this->errorText ?></summary>
<summary><?php echo $this->escape($this->errorText) ?></summary>
<?php if (isset($this->exceptionType)): ?>
<p><code><?php echo $this->exceptionType ?></code></p>
<?php endif; ?>
View
@@ -147,6 +147,7 @@ cache.backend.sqlite.cache_db_complete_path = "/tmp/ow_cache.sqlite"
;; Options for Gearman/worker
worker.enable = false
news.feedUrl = "http://blog.aksw.org/feed/?cat=5&client={{version.label}}&version={{version.number}}&suffix={{version.suffix}}"
;;;;
;; uncomment this line if you need more information
@@ -20,12 +20,12 @@ if (isset($this->errorFlag) && $this->errorFlag !== false) {
<input id="editortype" type="hidden" value="queryeditor" />
<div class="configMmodules">
<div class="width49 float margin">
<strong><?= $this->_('Output Format') ?></strong>
<?= $this->render('sparqloptions.phtml') ?>
<strong><?php echo $this->_('Output Format') ?></strong>
<?php echo $this->render('sparqloptions.phtml') ?>
</div>
<div class="width49 float margin">
<strong><?= $this->_('Query Source') ?></strong>
<?= $this->render('queryeditorfromsetter.phtml') ?>
<strong><?php echo $this->_('Query Source') ?></strong>
<?php echo $this->render('queryeditorfromsetter.phtml') ?>
</div>
</div>
<p class="messagebox info"><?php echo $this->_('Predefined namespaces') ?>:
@@ -44,7 +44,7 @@ if (isset($this->errorFlag) && $this->errorFlag !== false) {
</div>
<?php if ($this->has('error')): ?>
<fieldset>
<div class="messagebox error"><?php echo $this->error ?></div>
<div class="messagebox error"><?php echo nl2br($this->escape($this->error)) ?></div>
</fieldset>
<?php endif; ?>
View
@@ -73,7 +73,9 @@ function getEnvVar ($key)
// PHP environment settings
ini_set('max_execution_time', 240);
if ((int)ini_get('max_execution_time') < 240) {
ini_set('max_execution_time', 240);
}
if ((int)substr(ini_get('memory_limit'), 0, -1) < 256) {
ini_set('memory_limit', '256M');

0 comments on commit fb18b81

Please sign in to comment.