Skip to content
Snippets Groups Projects
Commit 46649188 authored by alangrafu's avatar alangrafu Committed by GIT_AUTHOR_NAME
Browse files

Merge branch 'master' into hotfixes

parents f4ab280d e175c6d7
No related branches found
No related tags found
No related merge requests found
Showing
with 1570 additions and 1503 deletions
......@@ -40,27 +40,17 @@ class SpecialFunction extends AbstractSpecialFunction{
try{
$viewFile = $conf['special']['uri'].".".$f.$conf['view']['extension'].".".$extension;
$modelFile = $conf['special']['uri'].".".$f.$conf['model']['extension'].".".$extension;
if(!(is_dir($conf['model']['directory'].$modelFile) || is_file($conf['model']['directory'].$modelFile)) || !is_file($conf['view']['directory'].$viewFile)){
throw new Exception('Method does not exist!');
if(!(is_dir($conf['model']['directory'].$modelFile) || is_file($conf['model']['directory'].$modelFile))){
$msg = '<h1>Method does not exist!</h1><br/>This means that <tt>'.$conf['model']['directory'].$modelFile."</tt> doesn't exist.<br/>Please refer to this tutorial to create one.<br/>";
throw new Exception($msg);
}
if(!is_file($conf['view']['directory'].$viewFile)){
$msg='<h1>Method does not exist!</h1><br/>This means that <tt>'.$conf['view']['directory'].$viewFile."</tt> doesn't exist.<br/>Please refer to this tutorial to create one.<br/>";
throw new Exception($msg);
}
$endpoints = $context['endpoints'];
array_pop($params);
array_shift($params);
//$query = file_get_contents($conf['model']['directory'].$modelFile);
/*$queryHeader = "";
$prefixHeader = array();
for($i=0;$i<sizeof($params);$i++){
$auxPrefix = Utils::getPrefix($params[$i]);
if($auxPrefix['ns'] != NULL){
$prefixHeader[$auxPrefix['ns']] = $auxPrefix['prefix'];
}
$query = preg_replace("|%".$i."|", $params[$i], $query);
}
foreach($prefixHeader as $n => $p){
$queryHeader .= "PREFIX $p: <$n> \n";
}
$data['query'] =$queryHeader . $query;*/
//$e->query($data['query'], Utils::getResultsType($query));
$prefixHeader = array();
for($i=0;$i<sizeof($params);$i++){
......@@ -81,12 +71,15 @@ class SpecialFunction extends AbstractSpecialFunction{
$data['params'] = $params;
$base = $conf['view']['standard'];
$base['type'] = $modelFile;
$base['root'] = $conf['root'];
$base['home'] = $conf['basedir'];
$base['this']['value'] = $uri;
$base['this']['curie'] = Utils::uri2curie($uri);
$base['this']['contentType'] = $acceptContentType;
$base['model']['directory'] = $conf['model']['directory'];
$base['view']['directory'] = $conf['view']['directory'];
$base['ns'] = $conf['ns']; $base['ns'] = $conf['ns'];
$base['ns'] = $conf['ns'];
$base['endpoint'] = $conf['endpoint'];
$base['type'] = $modelFile;
$base['header'] = $prefixHeader;
$base['args'] = $args;
......@@ -96,8 +89,9 @@ class SpecialFunction extends AbstractSpecialFunction{
$base['view']['directory'] = $conf['home'].$conf['view']['directory'];
$base['model']['directory'] = $conf['home'].$conf['model']['directory'];
chdir($conf['model']['directory']);
Utils::queryFile($modelFile, $endpoints['local'], $data);
chdir("..");
$first = array();
Utils::queryFile($modelFile, $endpoints['local'], $data, $first);
chdir($conf['home']);
$data = Utils::internalize($data);
if(is_array($data)){
......
......@@ -30,13 +30,13 @@ class MetaDb{
global $conf;
try{
$db = new PDO('sqlite:'.$this->dbLocation);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$results = $db->exec($q);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$results = $db->exec($q);
$db = NULL;
}catch(PDOException $e){
print 'Exception exec: '.$e->getMessage()."\n\n";
exit(10);
}catch(Exception $e){
echo "Can't write in SQLite database. Please check you have granted write permissions to <tt>meta/</tt> and <tt>meta/db.sqlite</tt>.";
trigger_error('Exception exec: '.$e->getMessage(), E_USER_ERROR);
exit(1);
}
return $results;
}
......
......@@ -12,7 +12,7 @@ class Utils{
public static function send404($uri){
header("HTTP/1.0 404 Not Found");
echo "I could not find ".$uri." or information about it.\n\n";
echo "LODSPeaKr could not find ".$uri." or information about it.\n\n";
exit(0);
}
......@@ -22,9 +22,12 @@ class Utils{
exit(0);
}
public static function send500($uri){
public static function send500($msg = null){
header("HTTP/1.0 500 Internal Server Error");
echo "An internal error ocurred. Please try later\n\n";
if($msg != null){
echo $msg;
}
exit(0);
}
......@@ -272,7 +275,7 @@ class Utils{
Utils::queryDir($v, $r);
}
}
chdir("..");
chdir($conf['home']);
//return $data;
}
......
......@@ -36,7 +36,7 @@ $conf['special']['uri'] = 'special';
$conf['special']['class'] = 'classes/BasicSpecialFunction.php';
//Frontpage when user goes to http://example.org/
$conf['root'] = 'special/index';
$conf['root'] = 'index.html';
$conf['extension_connector'] = '.';
//Priority for rdfs:Resource (default). Priorities should be >=0
......
......@@ -128,7 +128,7 @@ chdir($conf['model']['directory']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $first);
$results = Utils::internalize($results);
$base['first'] = Utils::getFirsts($results);
chdir("..");
chdir($conf['home']);
if(is_array($results)){
$resultsObj = Convert::array_to_object($results);
}else{
......
......@@ -27,7 +27,7 @@ while [ "$everything_ok" != "y" ]; do
echo
echo "LODSPeaKr needs to know three (3) URIs to minimally configure itself:"
echo
echo "(1/3) At what URL will `pwd` be available? (e.g. http://localhost/$parent/)"
echo "(1/3) At what URL will `pwd |sed -e 's/lodspeakr$//'` be available? (e.g. http://localhost/$parent/)"
echo "**Note** DO NOT include 'lodspeakr/' in the URL"
echo -n "(default '$basedir'): "
read -u 1 aux_basedir
......
Copyright (c) 2010, César D. Rodas <crodas@php.net> and Menéame Comunicacions S.L.
Copyright (c) 2011, César D. Rodas <crodas@php.net> and Menéame Comunicacions S.L.
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
This diff is collapsed.
......@@ -74,7 +74,7 @@
foreach ($this->yy_get_expected_tokens($yymajor) as $token) {
$expect[] = self::$yyTokenName[$token];
}
$this->Error('Unexpected ' . $this->tokenName($yymajor) . '(' . $TOKEN. '), expected one of: ' . implode(',', $expect));
$this->Error('Unexpected ' . $this->tokenName($yymajor) . '(' . $TOKEN. ')');
}
......@@ -379,21 +379,25 @@ expr(A) ::= fvar_or_string(B). { A = B; }
/* Variable name */
varname(A) ::= varpart(B). { A = current($this->compiler->generate_variable_name(B, false)); }
varpart(A) ::= varname(B) T_OBJ|T_DOT T_ALPHA|T_CUSTOM_TAG|T_CUSTOM_BLOCK(C). {
varpart(A) ::= varpart(B) T_OBJ|T_DOT varpart_single(C). {
if (!is_array(B)) { A = array(B); }
else { A = B; } A[]=array('object' => C);
}
varpart(A) ::= varname(B) T_CLASS T_ALPHA|T_CUSTOM_TAG|T_CUSTOM_BLOCK(C). {
varpart(A) ::= varpart(B) T_CLASS varpart_single(C). {
if (!is_array(B)) { A = array(B); }
else { A = B; } A[]=array('class' => '$'.C);
}
varpart(A) ::= varname(B) T_BRACKETS_OPEN var_or_string(C) T_BRACKETS_CLOSE. {
varpart(A) ::= varpart(B) T_BRACKETS_OPEN var_or_string(C) T_BRACKETS_CLOSE. {
if (!is_array(B)) { A = array(B); }
else { A = B; } A[]=C;
}
varpart(A) ::= T_ALPHA(B). { A = B; }
varpart(A) ::= varpart_single(B). { A = B; }
/* T_BLOCK|T_CUSTOM|T_CUSTOM_BLOCK are also T_ALPHA */
varpart(A) ::= T_BLOCK|T_CUSTOM_TAG|T_CUSTOM_BLOCK(B). { A = B; }
varpart_single(A) ::= T_ALPHA|T_BLOCK|T_CUSTOM_TAG|T_CUSTOM_END|T_CUSTOM_BLOCK(B). { A = B; }
range(A) ::= numvar(B) T_DOTDOT numvar(C). { A = array(B, C); }
......
......@@ -560,7 +560,7 @@ class Haanga_Compiler_Tokenizer
/* destroy the parser */
try {
$parser->doParse(0,0);
} catch (Exception $e) {}
} catch (Exception $y) {}
throw $e; /* re-throw exception */
}
......
<?php
class Haanga_Extension_Filter_IsArray
{
public $php_alias = "is_array";
public $is_safe = TRUE; /* boolean if safe */
}
......@@ -7,7 +7,6 @@ class Haanga_Extension_Filter_Length
{
$count = hexec('count', $args[0]);
$strlen = hexec('strlen', $args[0]);
$props = hexec('count', hexec('array_keys', hexec('get_object_vars', $args[0])));
$guess = hexpr_cond(hexec('is_array', $args[0]), hexec('count', $args[0]),
hexec('strlen', $args[0]));
......@@ -19,8 +18,6 @@ class Haanga_Extension_Filter_Length
return $count;
} else if (is_string($value)) {
return $strlen;
} else if (is_object($value)) {
return $props;
} else {
return $guess;
}
......
<?php
class Haanga_Extension_Filter_Null
{
public $php_alias = 'is_null';
}
......@@ -2,7 +2,7 @@
class Haanga_Extension_Filter_Substr
{
public static function generator($compiler, $args)
public static function generator($cmp, $args)
{
if (count($args) != 2) {
$cmp->Error("substr parameter must have one param");
......
<?php
class Haanga_Extension_Filter_Truncatechars
{
static function main($text, $limit)
{
if(strlen($text) <= $limit)
return $text;
$trunctext = substr($text, 0, $limit);
$trunctext[$limit-3] = '.';
$trunctext[$limit-2] = '.';
$trunctext[$limit-1] = '.';
return $trunctext;
}
}
......@@ -37,6 +37,9 @@ class Haanga_Extension_Tag_Exec
$exec->end();
if ($assign) {
$code->decl($assign, $exec);
// make it global
$code->decl(hvar('vars', $assign), hvar($assign));
} else {
$cmp->do_print($code, $exec);
}
......
......@@ -331,7 +331,7 @@ class Haanga_Generator_PHP
{
$op['array'] = $this->php_get_varname($op['array']);
$op['value'] = $this->php_get_varname($op['value']);
$code = "foreach ({$op['array']} as ";
$code = "foreach ((array) {$op['array']} as ";
if (!isset($op['key'])) {
$code .= " {$op['value']}";
} else {
......
5
<?php
$data = array(
'endsomething' => array('endbar' => 5),
);
{{ endsomething.endbar }}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment