Skip to content

Commit

Permalink
Merge branch 'develop' into feature/semantic-extensions
Browse files Browse the repository at this point in the history
Conflicts:
	application/Bootstrap.php
  • Loading branch information
jbrekle committed May 13, 2012
2 parents 54a826f + 87e3dab commit 8d8c8f3
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 121 deletions.
127 changes: 42 additions & 85 deletions application/Bootstrap.php
Expand Up @@ -76,6 +76,7 @@ public function _initExtensionManager()
. $config->extensions->base;

OntoWiki_Navigation::reset();

$extensionManager = new OntoWiki_Extension_Manager($extensionPath);
$extensionManager->setTranslate($translate)
->setComponentUrlBase($extensionPathBase);
Expand Down Expand Up @@ -104,58 +105,22 @@ public function _initExtensionManager()
*/
public function _initConfig()
{
if (!is_dir(CACHE_PATH) || !is_writable(CACHE_PATH)) {
$message = '<p>OntoWiki needs a writeable cache directory ('.CACHE_PATH.').</p>' . PHP_EOL ;
throw new Exception($message);
}
//load cached config
$cachedConfigPath = CACHE_PATH . 'config.json';
$configPath = ONTOWIKI_ROOT . 'config.ini'; // 'doap.n3';
$defaultConfigPath = APPLICATION_PATH . 'config/default.ini'; //'config/default.n3';
$updateCache = false;

$statCache = @stat($cachedConfigPath);
if ($statCache !== false) { //file exists
$statOrig = @stat($configPath);
$statDefault = @stat($defaultConfigPath);

if (
$statOrig && $statDefault && //files exist
$statCache['mtime'] >= $statOrig['mtime'] &&
$statCache['mtime'] >= $statDefault['mtime']
) {
//cache is still valid
$config = new Zend_Config(json_decode(file_get_contents($cachedConfigPath), true), true);
} else {
$updateCache = true;
}
} else {
$updateCache = true;
// load default application configuration file
try {
$config = new Zend_Config_Ini(APPLICATION_PATH . 'config/default.ini', 'default', true);
} catch (Zend_Config_Exception $e) {
exit($e->getMessage());
}
if ($updateCache) {
// load default application configuration file
// $config = Ontowiki_Extension_Manager::loadDoapN3($defaultConfigPath, $name);

try {
$config = new Zend_Config_Ini(APPLICATION_PATH . 'config/default.ini', 'default', true);
} catch (Zend_Config_Exception $e) {
throw new Exception($e->getMessage());
}

// load user application configuration files
try {
$privateConfig = new Zend_Config_Ini(ONTOWIKI_ROOT . 'config.ini', 'private', true);
$config->merge($privateConfig);
} catch (Zend_Config_Exception $e) {
$message = '<p>OntoWiki can not find a proper configuration.</p>' . PHP_EOL .
'<p>Maybe you have to copy and modify the distributed '.
'<code>config.ini-dist</code> file?</p>' . PHP_EOL .
'<details><summary>Error Details</summary>' . $e->getMessage() . '</details>';
throw new Exception($message);
}

//write to cache
file_put_contents($cachedConfigPath, json_encode($config->toArray()));

// load user application configuration files
try {
$privateConfig = new Zend_Config_Ini(ONTOWIKI_ROOT . 'config.ini', 'private', true);
$config->merge($privateConfig);
} catch (Zend_Config_Exception $e) {
$message = '<p>OntoWiki can not find a proper configuration.</p>' . PHP_EOL .
'<p>Maybe you have to copy and modify the distributed <code>config.ini-dist</code> file?</p>' . PHP_EOL .
'<details><summary>Error Details</summary>' . $e->getMessage() . '</details>';
exit($message);
}

// normalize path names
Expand All @@ -166,7 +131,6 @@ public function _initConfig()
if (!defined('EXTENSION_PATH')) {
define('EXTENSION_PATH', $config->extensions->base);
}

$config->extensions->legacy = EXTENSION_PATH . rtrim($config->extensions->legacy, '/\\') . '/';
$config->languages->path = EXTENSION_PATH . rtrim($config->languages->path, '/\\') . '/';

Expand All @@ -183,17 +147,15 @@ public function _initConfig()
// set path variables
$rewriteBase = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], BOOTSTRAP_FILE));
$protocol = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https' : 'http';
$port = (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80')
? (':' . $_SERVER['SERVER_PORT'])
$port = (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80' && $_SERVER['SERVER_PORT'] != '443')
? (':' . $_SERVER['SERVER_PORT'])
: '';
$urlBase = sprintf(
'%s://%s%s%s',
$protocol,
isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost',
$port,
$rewriteBase
);

$urlBase = sprintf('%s://%s%s%s',
$protocol,
isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost',
$port,
$rewriteBase);

// construct URL variables
$config->host = parse_url($urlBase, PHP_URL_HOST);
$config->urlBase = rtrim($urlBase . (ONTOWIKI_REWRITE ? '' : BOOTSTRAP_FILE), '/\\') . '/';
Expand Down Expand Up @@ -264,9 +226,9 @@ public function _initErfurt()
try {
$erfurt = Erfurt_App::getInstance(false)->start($config);
} catch (Erfurt_Exception $ee) {
throw new Exception('Error loading Erfurt framework: ' . $ee->getMessage());
exit('Error loading Erfurt framework: ' . $ee->getMessage());
} catch (Exception $e) {
throw new Exception('Unexpected error: ' . $e->getMessage());
exit('Unexpected error: ' . $e->getMessage());
}

// make available
Expand Down Expand Up @@ -298,7 +260,7 @@ public function _initLogger()
// require config
$this->bootstrap('Config');
$config = $this->getResource('Config');

// support absolute path
if (!(preg_match('/^(\w:[\/|\\\\]|\/)/', $config->log->path) === 1)) {
// prepend OntoWiki root for relative paths
Expand Down Expand Up @@ -362,16 +324,13 @@ public function _initNavigation()
extract($config->routes->{$route}->defaults->toArray());

// and add last routed component
OntoWiki_Navigation::register(
'index',
array(
'route' => $route,
'controller' => $controller,
'action' => $action,
'name' => ucfirst($route),
'priority' => 0
)
);
OntoWiki_Navigation::register('index', array(
'route' => $route,
'controller' => $controller,
'action' => $action,
'name' => ucfirst($route),
'priority' => 0
));
}
}

Expand Down Expand Up @@ -400,11 +359,9 @@ public function _initPlugins()
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');

// Needs to be done first!
$frontController->registerPlugin(new OntoWiki_Controller_Plugin_HttpAuth(), 1);
$frontController->registerPlugin(new OntoWiki_Controller_Plugin_HttpAuth(), 1); // Needs to be done first!
$frontController->registerPlugin(new OntoWiki_Controller_Plugin_SetupHelper(), 2);
//needs to be done after SetupHelper, handles instance lists
$frontController->registerPlugin(new OntoWiki_Controller_Plugin_ListSetupHelper(), 3);
$frontController->registerPlugin(new OntoWiki_Controller_Plugin_ListSetupHelper(), 3); //needs to be done after SetupHelper
}

/**
Expand Down Expand Up @@ -622,6 +579,8 @@ public function _initView()
->setEncoding($config->encoding)
->setHelperPath(ONTOWIKI_ROOT . 'application/classes/OntoWiki/View/Helper', 'OntoWiki_View_Helper');



// set Zend_View to emit notices in debug mode
$view->strictVars(defined('_OWDEBUG'));

Expand All @@ -643,12 +602,10 @@ public function _initView()
}

// initialize layout
Zend_Layout::startMvc(
array(
// for layouts we use the default path
'layoutPath' => $layoutPath
)
);
Zend_Layout::startMvc(array(
// for layouts we use the default path
'layoutPath' => $layoutPath
));

return $view;
}
Expand Down
23 changes: 20 additions & 3 deletions application/views/templates/partials/list_std_element.phtml
Expand Up @@ -90,7 +90,7 @@ $url = new OntoWiki_Url(array('controller' => 'resource','action' => 'instances'
<?php
}
//print the value itself until OW_SHOW_MAX
if (isset($value['url']) && $value['url'] !== null && $i<OW_SHOW_MAX+1): ?>
if (isset($value['url']) && $value['url'] !== null && $i<OW_SHOW_MAX+1): //show uris until OW_SHOW_MAX ?>
<li>
<a about="<?php echo $this->instanceUri ?>"
class="hasMenu"
Expand All @@ -100,7 +100,7 @@ $url = new OntoWiki_Url(array('controller' => 'resource','action' => 'instances'
<?php echo $value['value']; ?>
</a>
</li>
<?php else: //don't show value, which are > OW_SHOW_MAX ?>
<?php elseif (isset($value['url']) && $value['url'] !== null): //don't show uri value, which are > OW_SHOW_MAX ?>
<li>
<a about="<?php echo $this->instanceUri ?>"
style="display: none;"
Expand All @@ -111,6 +111,23 @@ $url = new OntoWiki_Url(array('controller' => 'resource','action' => 'instances'
<?php echo $value['value']; ?>
</a>
</li>
<?php elseif ($value['url'] == null && $i < OW_SHOW_MAX+1): //show literals until OW_SHOW_MAX ?>
<li>
<span about="<?php echo $this->instanceUri ?>"
property="<?php echo $this->curie($property['uri']) ?>"
content="<?php echo $value['uri'] ?>">
<?php echo $value['value']; ?>
</a>
</li>
<?php elseif ($value['url'] == null): //don't show literal values, which are > OW_SHOW_MAX ?>
<li>
<span about="<?php echo $this->instanceUri ?>"
style="display: none;"
property="<?php echo $this->curie($property['uri']) ?>"
content="<?php echo $value['uri'] ?>">
<?php echo $value['value']; ?>
</span>
</li>
<?php endif; ?>
<?php endforeach;?>
</ul>
Expand All @@ -132,7 +149,7 @@ $url = new OntoWiki_Url(array('controller' => 'resource','action' => 'instances'
class="hasMenu"
rel="<?php echo $this->curie($property['uri']) ?>"
resource="<?php echo $this->instanceData[$this->instanceUri][$property['varName']][0]['uri'] ?>"
href="<?php echo $this->instanceData[$this->instanceUri][$property['varName']][0]['url'] ?>">
content="<?php echo $this->instanceData[$this->instanceUri][$property['varName']][0]['value'] ?>">
<?php echo $this->instanceData[$this->instanceUri][$property['varName']][0]['value'] ?>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion extensions/community/CommentModule.php
Expand Up @@ -6,7 +6,7 @@
* Allows to post a comment about a resource.
*
* @category OntoWiki
* @package OntoWiki_extensions_modules_comment
* @package Extensions_Community
* @author Norman Heino <norman.heino@gmail.com>
* @copyright Copyright (c) 2008, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
Expand Down
10 changes: 3 additions & 7 deletions extensions/community/CommunityController.php
@@ -1,12 +1,8 @@
<?php
/**
* @category OntoWiki
* @package OntoWiki_extensions_components_community
*/
<?php

/**
* @category OntoWiki
* @package OntoWiki_extensions_components_community
* @package Extensions_Community
*/
class CommunityController extends OntoWiki_Controller_Component {

Expand All @@ -28,7 +24,7 @@ public function listAction(){
//Loading data for list of saved queries
$listHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('List');
$listName = "community-".$this->_request->getParam('mode');

if($listHelper->listExists($listName)){
$list = $listHelper->getList($listName);
$listHelper->addList($listName, $list, $this->view, 'list_community_main', $this->_privateConfig);
Expand Down
12 changes: 3 additions & 9 deletions extensions/community/CommunityHelper.php
Expand Up @@ -3,20 +3,14 @@
/**
* This file is part of the {@link http://ontowiki.net OntoWiki} project.
*
* @copyright Copyright (c) 2010, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
*/

/**
* Helper class for the Community component.
*
* - register the tab for all navigations except the instances list
* (this should be undone if the community tab can be created from a Query2 too)
*
* @category OntoWiki
* @package Extensions
* @subpackage Community
* @copyright Copyright (c) 2008, {@link http://aksw.org AKSW}
* @category OntoWiki
* @package Extensions_Community
* @copyright Copyright (c) 2010, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
*/
class CommunityHelper extends OntoWiki_Component_Helper
Expand Down
2 changes: 1 addition & 1 deletion extensions/community/LastchangesModule.php
Expand Up @@ -5,7 +5,7 @@
* show last activities in a knowledge base and link to the resources
*
* @category OntoWiki
* @package OntoWiki_extensions_modules_lastchanges
* @package Extensions_Community
* @author Sebastian Dietzold <dietzold@informatik.uni-leipzig.de>
* @copyright Copyright (c) 2009, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
Expand Down
2 changes: 1 addition & 1 deletion extensions/community/LastcommentsModule.php
Expand Up @@ -8,7 +8,7 @@
* show last comments on resources of one knowledge base
*
* @category OntoWiki
* @package OntoWiki_extensions_modules_lastcomments
* @package Extensions_Community
* @author Sebastian Dietzold <dietzold@informatik.uni-leipzig.de>
* @copyright Copyright (c) 2009, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
Expand Down
3 changes: 2 additions & 1 deletion extensions/community/RatingModule.php
Expand Up @@ -7,7 +7,8 @@
*
* Allows to post a comment about a resource.
*
* @package ontowiki
* @category OntoWiki
* @package Extensions_Community
* @author Christian Maier, Niederstätter Michael
* @copyright Copyright (c) 2008, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
Expand Down
2 changes: 1 addition & 1 deletion extensions/resourcemodules/LinkinghereModule.php
Expand Up @@ -6,7 +6,7 @@
* Add instance properties to the list view
*
* @category OntoWiki
* @package OntoWiki_extensions_modules_linkinghere
* @package Extensions_Resourcemodule
* @author Norman Heino <norman.heino@gmail.com>
* @copyright Copyright (c) 2008, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
Expand Down
2 changes: 1 addition & 1 deletion extensions/resourcemodules/SimilarinstancesModule.php
Expand Up @@ -6,7 +6,7 @@
* Add instance properties to the list view
*
* @category OntoWiki
* @package OntoWiki_extensions_modules_similarinstances
* @package Extensions_Resourcemodule
* @author Norman Heino <norman.heino@gmail.com>
* @copyright Copyright (c) 2008, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
Expand Down
12 changes: 1 addition & 11 deletions extensions/resourcemodules/UsageModule.php
Expand Up @@ -3,24 +3,14 @@
/**
* This file is part of the {@link http://ontowiki.net OntoWiki} project.
*
* @category OntoWiki
* @package OntoWiki_extensions_modules_usage
* @copyright Copyright (c) 2010, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
*/


/**
* OntoWiki usage module
*
* Adds the "Usage as Property" box to the properties context
*
* @category OntoWiki
* @package OntoWiki_extensions_modules_usage
* @package Extensions_Resourcemodule
* @copyright Copyright (c) 2010, {@link http://aksw.org AKSW}
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
* @category extensions
* @package modules
* @author Norman Heino <norman.heino@gmail.com>
*/
class UsageModule extends OntoWiki_Module
Expand Down

0 comments on commit 8d8c8f3

Please sign in to comment.