Coding standards

This commit is contained in:
Romain Neutron
2012-01-31 18:35:27 +01:00
parent dcb4933438
commit 99a344774f
110 changed files with 668 additions and 536 deletions

View File

@@ -14,12 +14,10 @@
* *
*/ */
require_once __DIR__ . '/lib/Alchemy/Phrasea/Core.php'; require_once __DIR__ . '/lib/bootstrap.php';
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
\Alchemy\Phrasea\Core::initAutoloads();
$fix = isset($argv[1]) && 'fix' == $argv[1]; $fix = isset($argv[1]) && 'fix' == $argv[1];
$finder = new Finder(); $finder = new Finder();

View File

@@ -121,6 +121,7 @@ class ACL implements cache_cacheableInterface
$key = $record->get_serialize_key(); $key = $record->get_serialize_key();
if (array_key_exists($key, $this->_rights_records_document)) if (array_key_exists($key, $this->_rights_records_document))
return true; return true;
return false; return false;
@@ -188,6 +189,7 @@ class ACL implements cache_cacheableInterface
$key = $record->get_serialize_key(); $key = $record->get_serialize_key();
if (array_key_exists($key, $this->_rights_records_preview)) if (array_key_exists($key, $this->_rights_records_preview))
return true; return true;
return false; return false;
@@ -241,6 +243,7 @@ class ACL implements cache_cacheableInterface
public function apply_model(User_Interface $template_user, Array $base_ids) public function apply_model(User_Interface $template_user, Array $base_ids)
{ {
if (count($base_ids) == 0) if (count($base_ids) == 0)
return $this; return $this;
$sbas_ids = array(); $sbas_ids = array();
@@ -382,6 +385,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
if ($this->is_limited($base_id)) if ($this->is_limited($base_id))
@@ -469,6 +473,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return $this->_rights_bas[$base_id]['restrict_dwnld']; return $this->_rights_bas[$base_id]['restrict_dwnld'];
@@ -485,6 +490,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return (int) $this->_rights_bas[$base_id]['remain_dwnld']; return (int) $this->_rights_bas[$base_id]['remain_dwnld'];
@@ -502,6 +508,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
$this->_rights_bas[$base_id]['remain_dwnld'] = $this->_rights_bas[$base_id]['remain_dwnld'] =
@@ -541,12 +548,14 @@ class ACL implements cache_cacheableInterface
$this->load_rights_sbas(); $this->load_rights_sbas();
if (!isset($this->_rights_sbas[$sbas_id])) if (!isset($this->_rights_sbas[$sbas_id]))
return false; return false;
if (!isset($this->_rights_sbas[$sbas_id][$right])) if (!isset($this->_rights_sbas[$sbas_id][$right]))
throw new Exception('This right does not exists'); throw new Exception('This right does not exists');
if ($this->_rights_sbas[$sbas_id][$right] === true) if ($this->_rights_sbas[$sbas_id][$right] === true)
return true; return true;
return false; return false;
@@ -562,6 +571,7 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return $this->_rights_bas[$base_id]['mask_and']; return $this->_rights_bas[$base_id]['mask_and'];
@@ -577,6 +587,7 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
if (!$this->has_access_to_base($base_id)) if (!$this->has_access_to_base($base_id))
return false; return false;
return $this->_rights_bas[$base_id]['mask_xor']; return $this->_rights_bas[$base_id]['mask_xor'];
@@ -718,6 +729,7 @@ class ACL implements cache_cacheableInterface
{ {
if ($this->_rights_records_preview) if ($this->_rights_records_preview)
return $this; return $this;
try try
@@ -771,6 +783,7 @@ class ACL implements cache_cacheableInterface
{ {
if ($this->_rights_sbas && $this->_global_rights) if ($this->_rights_sbas && $this->_global_rights)
return $this; return $this;
try try
@@ -832,6 +845,7 @@ class ACL implements cache_cacheableInterface
protected function load_rights_bas() protected function load_rights_bas()
{ {
if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited)) if ($this->_rights_bas && $this->_global_rights && is_array($this->_limited))
return $this; return $this;
try try
@@ -1335,6 +1349,7 @@ class ACL implements cache_cacheableInterface
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
return $this; return $this;
$this->give_access_to_base(array($base_id_dest)); $this->give_access_to_base(array($base_id_dest));
@@ -1501,6 +1516,7 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
if (!isset($this->_limited[$base_id])) if (!isset($this->_limited[$base_id]))
return null; return null;
return ($this->_limited[$base_id]); return ($this->_limited[$base_id]);
} }

View File

@@ -93,6 +93,7 @@ class Controller_Admin_Publications implements ControllerProviderInterface
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
if (!$feed->is_owner($user)) if (!$feed->is_owner($user))
return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it')); return $app->redirect('/admin/publications/feed/' . $id . '/?error=' . _('You are not the owner of this feed, you can not edit it'));
$request = $app['request']; $request = $app['request'];
@@ -121,23 +122,29 @@ class Controller_Admin_Publications implements ControllerProviderInterface
$user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox); $user = User_Adapter::getInstance($appbox->get_session()->get_usr_id(), $appbox);
if (!$feed->is_owner($user)) if (!$feed->is_owner($user))
return new Response('ERROR:you are not allowed'); return new Response('ERROR:you are not allowed');
if ($_FILES['Filedata']['error'] !== 0) if ($_FILES['Filedata']['error'] !== 0)
return new Response('ERROR:error while upload'); return new Response('ERROR:error while upload');
$file = new system_file($_FILES['Filedata']['tmp_name']); $file = new system_file($_FILES['Filedata']['tmp_name']);
if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif'))) if (!in_array($file->get_mime(), array('image/jpeg', 'image/jpg', 'image/gif')))
return new Response('ERROR:bad filetype'); return new Response('ERROR:bad filetype');
if ($file->getSize() > 200000) if ($file->getSize() > 200000)
return new Response('ERROR:file too large'); return new Response('ERROR:file too large');
$datas = $file->get_technical_datas(); $datas = $file->get_technical_datas();
if (!isset($datas[system_file::TC_DATAS_WIDTH]) || !isset($datas[system_file::TC_DATAS_HEIGHT])) if (!isset($datas[system_file::TC_DATAS_WIDTH]) || !isset($datas[system_file::TC_DATAS_HEIGHT]))
return new Response('ERROR:file is not square'); return new Response('ERROR:file is not square');
if ($datas[system_file::TC_DATAS_WIDTH] != $datas[system_file::TC_DATAS_HEIGHT]) if ($datas[system_file::TC_DATAS_WIDTH] != $datas[system_file::TC_DATAS_HEIGHT])
return new Response('ERROR:file is not square'); return new Response('ERROR:file is not square');
$feed->set_icon($file); $feed->set_icon($file);

View File

@@ -100,6 +100,7 @@ class DailymotionWithoutOauth2 extends Dailymotion
$this->timeout = null; $this->timeout = null;
$result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true); $result = json_decode($this->httpRequest($result['upload_url'], array('file' => '@' . $filePath)), true);
$this->timeout = $timeout; $this->timeout = $timeout;
return $result['url']; return $result['url'];
} }
} }

View File

@@ -370,9 +370,11 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
$medium = strtolower($content->get_record()->get_type()); $medium = strtolower($content->get_record()->get_type());
if (!in_array($medium, array('image', 'audio', 'video'))) if (!in_array($medium, array('image', 'audio', 'video')))
return $this; return $this;
if (!$preview_permalink || !$thumbnail_permalink) if (!$preview_permalink || !$thumbnail_permalink)
return $this; return $this;
//add item node to channel node //add item node to channel node

View File

@@ -907,6 +907,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public static function get_usr_id_from_email($email) public static function get_usr_id_from_email($email)
{ {
if (is_null($email)) if (is_null($email))
return false; return false;
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection();
@@ -1277,6 +1278,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
protected function load_preferences() protected function load_preferences()
{ {
if ($this->_prefs) if ($this->_prefs)
return $this; return $this;
$registry = \registry::get_instance(); $registry = \registry::get_instance();
@@ -1573,6 +1575,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
{ {
$this->load_preferences(); $this->load_preferences();
if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value) if (isset($this->_prefs[$prop]) && $this->_prefs[$prop] === $value)
return $value; return $value;
$ok = true; $ok = true;
@@ -1610,6 +1613,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
if (!$session->is_authenticated()) if (!$session->is_authenticated())
return; return;
$ses_id = $session->get_ses_id(); $ses_id = $session->get_ses_id();
@@ -1884,6 +1888,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
public function get_nonce() public function get_nonce()
{ {
if ($this->nonce) if ($this->nonce)
return $this->nonce; return $this->nonce;
$nonce = false; $nonce = false;

View File

@@ -489,6 +489,7 @@ class User_Query implements User_QueryInterface
public function get_total() public function get_total()
{ {
if ($this->total) if ($this->total)
return $this->total; return $this->total;
$conn = $this->appbox->get_connection(); $conn = $this->appbox->get_connection();
@@ -637,6 +638,7 @@ class User_Query implements User_QueryInterface
public function on_base_ids(Array $base_ids = null) public function on_base_ids(Array $base_ids = null)
{ {
if (!$base_ids) if (!$base_ids)
return $this; return $this;
$this->bases_restrictions = true; $this->bases_restrictions = true;
@@ -661,6 +663,7 @@ class User_Query implements User_QueryInterface
public function on_sbas_ids(Array $sbas_ids = null) public function on_sbas_ids(Array $sbas_ids = null)
{ {
if (!$sbas_ids) if (!$sbas_ids)
return $this; return $this;
$this->sbas_restrictions = true; $this->sbas_restrictions = true;

View File

@@ -327,6 +327,7 @@ class basket_adapter implements cache_cacheableInterface
public function get_first_element() public function get_first_element()
{ {
foreach ($this->get_elements() as $basket_element) foreach ($this->get_elements() as $basket_element)
return $basket_element; return $basket_element;
return null; return null;
} }
@@ -338,6 +339,7 @@ class basket_adapter implements cache_cacheableInterface
public function get_validation_end_date() public function get_validation_end_date()
{ {
if (!$this->valid || !$this->validation_end_date) if (!$this->valid || !$this->validation_end_date)
return null; return null;
return $this->validation_end_date; return $this->validation_end_date;
} }
@@ -349,6 +351,7 @@ class basket_adapter implements cache_cacheableInterface
public function is_validation_finished() public function is_validation_finished()
{ {
if (!$this->valid || !$this->validation_end_date) if (!$this->valid || !$this->validation_end_date)
return null; return null;
$now = new DateTime(); $now = new DateTime();
@@ -362,6 +365,7 @@ class basket_adapter implements cache_cacheableInterface
public function is_confirmed() public function is_confirmed()
{ {
if (!$this->valid) if (!$this->valid)
return null; return null;
return $this->validation_is_confirmed; return $this->validation_is_confirmed;
@@ -370,14 +374,17 @@ class basket_adapter implements cache_cacheableInterface
public function is_releasable() public function is_releasable()
{ {
if (!$this->valid) if (!$this->valid)
return false; return false;
if ($this->is_confirmed()) if ($this->is_confirmed())
return false; return false;
foreach ($this->get_elements() as $element) foreach ($this->get_elements() as $element)
{ {
if ($element->get_my_agreement() == '0') if ($element->get_my_agreement() == '0')
return false; return false;
} }
@@ -585,6 +592,7 @@ class basket_adapter implements cache_cacheableInterface
public function sort($order) public function sort($order)
{ {
if (!$this->valid || !in_array($order, array('asc', 'desc'))) if (!$this->valid || !in_array($order, array('asc', 'desc')))
return; return;
$this->load_elements(); $this->load_elements();
@@ -1016,6 +1024,7 @@ class basket_adapter implements cache_cacheableInterface
public function set_read() public function set_read()
{ {
if (!$this->noview) if (!$this->noview)
return true; return true;
$session = $this->appbox->get_session(); $session = $this->appbox->get_session();
@@ -1131,15 +1140,19 @@ class basket_adapter implements cache_cacheableInterface
if ($this->is_mine) if ($this->is_mine)
{ {
if ($this->is_validation_finished()) if ($this->is_validation_finished())
return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); return sprintf(_('Vous aviez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1));
else else
return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1)); return sprintf(_('Vous avez envoye cette demande a %d utilisateurs'), (count($this->validating_users) - 1));
} }
else else
{ {
if ($this->validation_see_others) if ($this->validation_see_others)
return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1)); return sprintf(_('Processus de validation recu de %s et concernant %d utilisateurs'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name(), (count($this->validating_users) - 1));
else else
return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name()); return sprintf(_('Processus de validation recu de %s'), User_Adapter::getInstance($this->usr_id, $this->appbox)->get_display_name());
} }
} }
@@ -1248,6 +1261,7 @@ class basket_adapter implements cache_cacheableInterface
protected function load_elements() protected function load_elements()
{ {
if (!is_null($this->elements)) if (!is_null($this->elements))
return; return;
$this->elements = array(); $this->elements = array();
@@ -1525,11 +1539,14 @@ class basket_adapter implements cache_cacheableInterface
public function remove_from_ssel($sselcont_id) public function remove_from_ssel($sselcont_id)
{ {
if (!$this->is_mine) if (!$this->is_mine)
return array('error' => 'error', 'status' => 0); return array('error' => 'error', 'status' => 0);
if ($this->is_grouping) if ($this->is_grouping)
return $this->remove_grouping_elements($sselcont_id); return $this->remove_grouping_elements($sselcont_id);
else else
return $this->remove_basket_elements($sselcont_id); return $this->remove_basket_elements($sselcont_id);
} }

View File

@@ -60,6 +60,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
protected function retrieve_fields() protected function retrieve_fields()
{ {
if (is_array($this->fields)) if (is_array($this->fields))
return $this->fields; return $this->fields;
$fields = array(); $fields = array();
@@ -133,6 +134,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
{ {
$fields = $this->retrieve_fields(); $fields = $this->retrieve_fields();
if (isset($this->dces_elements[$label])) if (isset($this->dces_elements[$label]))
return $fields[$this->dces_elements[$label]]; return $fields[$this->dces_elements[$label]];
return null; return null;
} }

View File

@@ -175,6 +175,7 @@ class connection
self::$_PDO_instance[$name] = null; self::$_PDO_instance[$name] = null;
unset(self::$_PDO_instance[$name]); unset(self::$_PDO_instance[$name]);
} }
return; return;
} }

View File

@@ -451,6 +451,7 @@ class databox extends base
$stmt->closeCursor(); $stmt->closeCursor();
if ($row) if ($row)
return self::get_instance((int) $row['sbas_id']); return self::get_instance((int) $row['sbas_id']);
try try
@@ -575,6 +576,7 @@ class databox extends base
public function get_meta_structure() public function get_meta_structure()
{ {
if ($this->meta_struct) if ($this->meta_struct)
return $this->meta_struct; return $this->meta_struct;
try try
@@ -697,6 +699,7 @@ class databox extends base
} }
} }
if ($n > $limit) if ($n > $limit)
return true; return true;
return false; return false;
@@ -1220,6 +1223,7 @@ class databox extends base
public function get_structure() public function get_structure()
{ {
if ($this->structure) if ($this->structure)
return $this->structure; return $this->structure;
$this->structure = $this->retrieve_structure(); $this->structure = $this->retrieve_structure();
@@ -1260,6 +1264,7 @@ class databox extends base
public function get_cterms() public function get_cterms()
{ {
if ($this->cterms) if ($this->cterms)
return $this->cterms; return $this->cterms;
$sql = "SELECT value FROM pref WHERE prop='cterms'"; $sql = "SELECT value FROM pref WHERE prop='cterms'";
@@ -1426,6 +1431,7 @@ class databox extends base
public function get_cgus() public function get_cgus()
{ {
if ($this->cgus) if ($this->cgus)
return $this->cgus; return $this->cgus;
$this->load_cgus(); $this->load_cgus();

View File

@@ -76,6 +76,7 @@ class gatekeeper
$session = $appbox->get_session(); $session = $appbox->get_session();
if (http_request::is_command_line()) if (http_request::is_command_line())
return; return;
if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF'])) if (isset($_SERVER['PHP_SELF']) && trim($_SERVER['PHP_SELF']))
@@ -121,6 +122,7 @@ class gatekeeper
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php' if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php' || $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php') || $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
return; return;
phrasea::redirect('/login/?redirect=/thesaurus2'); phrasea::redirect('/login/?redirect=/thesaurus2');
break; break;
@@ -129,6 +131,7 @@ class gatekeeper
break; break;
case 'admin': case 'admin':
if ($this->_script_name === 'runscheduler.php') if ($this->_script_name === 'runscheduler.php')
return; return;
phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']); phrasea::redirect('/login/?redirect=' . $_SERVER['REQUEST_URI']);
break; break;
@@ -148,6 +151,7 @@ class gatekeeper
return; return;
case 'setup': case 'setup':
if ($appbox->upgradeavailable()) if ($appbox->upgradeavailable())
return; return;
else else
phrasea::redirect('/login/'); phrasea::redirect('/login/');
@@ -264,6 +268,7 @@ class gatekeeper
$parm = $request->get_parms('LOG'); $parm = $request->get_parms('LOG');
if (is_null($parm["LOG"])) if (is_null($parm["LOG"]))
return $this; return $this;
try try
@@ -281,6 +286,7 @@ class gatekeeper
try try
{ {
$datas = random::helloToken($parm['LOG']); $datas = random::helloToken($parm['LOG']);
return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/"); return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
} }
catch (Exception_NotFound $e) catch (Exception_NotFound $e)

View File

@@ -94,6 +94,7 @@ class geonames
$cityName = self::clean_input($cityName); $cityName = self::clean_input($cityName);
if (strlen($cityName) === 0) if (strlen($cityName) === 0)
return $output; return $output;
$registry = registry::get_instance(); $registry = registry::get_instance();
@@ -134,6 +135,7 @@ class geonames
public function find_geoname_from_ip($ip) public function find_geoname_from_ip($ip)
{ {
if (array_key_exists($ip, $this->cache_ips)) if (array_key_exists($ip, $this->cache_ips))
return $this->cache_ips[$ip]; return $this->cache_ips[$ip];
$output = array( $output = array(

View File

@@ -58,6 +58,7 @@ return call_user_func(
{ {
$browser = Browser::getInstance(); $browser = Browser::getInstance();
if (!$browser->isMobile()) if (!$browser->isMobile())
return new Response(''); return new Response('');
$twig = new supertwig(); $twig = new supertwig();

View File

@@ -70,6 +70,7 @@ return call_user_func(function()
return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200); return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200);
} }
return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200); return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200);
} }
}); });

View File

@@ -34,10 +34,13 @@ return call_user_func(function()
{ {
$browser = Browser::getInstance(); $browser = Browser::getInstance();
if ($browser->isMobile()) if ($browser->isMobile())
return $app->redirect("/login/?redirect=/lightbox"); return $app->redirect("/login/?redirect=/lightbox");
elseif ($browser->isNewGeneration()) elseif ($browser->isNewGeneration())
return $app->redirect("/login/?redirect=/prod"); return $app->redirect("/login/?redirect=/prod");
else else
return $app->redirect("/login/?redirect=/client"); return $app->redirect("/login/?redirect=/client");
}); });
@@ -70,6 +73,7 @@ return call_user_func(function()
/** /**
* Mount all aps * Mount all aps
*/ */
return $app; return $app;
} }
); );

View File

@@ -49,8 +49,10 @@ return call_user_func(function()
$app->get('/', function() use ($app) $app->get('/', function() use ($app)
{ {
if ($app['install'] === true) if ($app['install'] === true)
return $app->redirect('/setup/installer/'); return $app->redirect('/setup/installer/');
if ($app['upgrade'] === true) if ($app['upgrade'] === true)
return $app->redirect('/setup/upgrader/'); return $app->redirect('/setup/upgrader/');
}); });
@@ -63,6 +65,7 @@ return call_user_func(function()
$app->error(function($e) use ($app) $app->error(function($e) use ($app)
{ {
if ($e instanceof Exception_Setup_PhraseaAlreadyInstalled) if ($e instanceof Exception_Setup_PhraseaAlreadyInstalled)
return $app->redirect('/login'); return $app->redirect('/login');
return new Response( return new Response(

View File

@@ -77,6 +77,7 @@ class module_admin
); );
$twig = new supertwig(); $twig = new supertwig();
return $twig->render('admin/tree.html.twig', $params); return $twig->render('admin/tree.html.twig', $params);
} }

View File

@@ -121,6 +121,7 @@ $parseRoute = function ($route, Response $response)
} }
} }
} }
return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action); return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
}; };
@@ -139,6 +140,7 @@ $app->before(function($request) use ($app)
$app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken()); $app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
if ($session->is_authenticated()) if ($session->is_authenticated())
return; return;
if ($oauth2_adapter->has_ses_id()) if ($oauth2_adapter->has_ses_id())
{ {

View File

@@ -455,6 +455,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
} }
if (!is_array($request->get('mds'))) if (!is_array($request->get('mds')))
return $this; return $this;
$sbas_id = (int) $request->get('sbid'); $sbas_id = (int) $request->get('sbid');

View File

@@ -500,6 +500,7 @@ class module_report
public function getOrder($k = false) public function getOrder($k = false)
{ {
if ($k === false) if ($k === false)
return $this->tab_order; return $this->tab_order;
return $this->tab_order[$k]; return $this->tab_order[$k];
} }
@@ -819,6 +820,7 @@ class module_report
public function buildReport($tab = false, $groupby = false, $on = false) public function buildReport($tab = false, $groupby = false, $on = false)
{ {
if (sizeof($this->report) > 0) if (sizeof($this->report) > 0)
return $this->report; return $this->report;
$conn = connection::getPDOConnection($this->sbas_id); $conn = connection::getPDOConnection($this->sbas_id);

View File

@@ -1112,6 +1112,7 @@ class module_report_activity extends module_report
$date = new DateTime($row['ddate']); $date = new DateTime($row['ddate']);
$result[$date->format(DATE_ATOM)] = $row['activity']; $result[$date->format(DATE_ATOM)] = $row['activity'];
} }
return $result; return $result;
} }

View File

@@ -157,8 +157,10 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
public function isValid() public function isValid()
{ {
if (isset($this->dashboard) && sizeof($this->dashboard) > 0) if (isset($this->dashboard) && sizeof($this->dashboard) > 0)
return true; return true;
else else
return false; return false;
} }

View File

@@ -252,6 +252,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
{ {
} }
return; return;
} }

View File

@@ -149,8 +149,10 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function isValid() public function isValid()
{ {
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0) if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0)
return true; return true;
else else
return false; return false;
} }
@@ -162,6 +164,7 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function getTop($nbtop) public function getTop($nbtop)
{ {
if (!is_int($nbtop)) if (!is_int($nbtop))
return array(); return array();
$tmp = array(); $tmp = array();
@@ -182,6 +185,7 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
} }
} }
} }
return $tmp; return $tmp;
} }

View File

@@ -617,6 +617,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
throw new Exception_Media_SubdefNotFound (); throw new Exception_Media_SubdefNotFound ();
if (isset($this->subdefs[$name])) if (isset($this->subdefs[$name]))
return $this->subdefs[$name]; return $this->subdefs[$name];
if (!$this->subdefs) if (!$this->subdefs)
@@ -756,8 +757,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if ($data) if ($data)
{ {
if (isset($this->technical_datas[$data])) if (isset($this->technical_datas[$data]))
return $this->technical_datas[$data]; return $this->technical_datas[$data];
else else
return false; return false;
} }
@@ -1355,6 +1358,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_reg_name() public function get_reg_name()
{ {
if (!$this->is_grouping()) if (!$this->is_grouping())
return false; return false;
$balisename = ''; $balisename = '';
@@ -1551,6 +1555,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
$hd = $this->get_subdef('document'); $hd = $this->get_subdef('document');
if ($hd->is_physically_present()) if ($hd->is_physically_present())
return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file()); return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file());
return null; return null;
} }
@@ -1891,6 +1896,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_container_baskets() public function get_container_baskets()
{ {
if ($this->container_basket) if ($this->container_basket)
return $this->container_basket; return $this->container_basket;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();

View File

@@ -205,6 +205,7 @@ class record_preview extends record_adapter
public function get_train($pos = 0, $query='', searchEngine_adapter $search_engine=null) public function get_train($pos = 0, $query='', searchEngine_adapter $search_engine=null)
{ {
if ($this->train) if ($this->train)
return $this->train; return $this->train;
switch ($this->env) switch ($this->env)
@@ -267,6 +268,7 @@ class record_preview extends record_adapter
public function get_title($highlight = '', searchEngine_adapter $search_engine=null) public function get_title($highlight = '', searchEngine_adapter $search_engine=null)
{ {
if ($this->title) if ($this->title)
return $this->title; return $this->title;
$this->title = collection::getLogo($this->get_base_id()) . ' '; $this->title = collection::getLogo($this->get_base_id()) . ' ';
@@ -323,6 +325,7 @@ class record_preview extends record_adapter
public function get_short_history() public function get_short_history()
{ {
if (!is_null($this->short_history)) if (!is_null($this->short_history))
return $this->short_history; return $this->short_history;
$tab = array(); $tab = array();
@@ -415,6 +418,7 @@ class record_preview extends record_adapter
public function get_view_popularity() public function get_view_popularity()
{ {
if (!is_null($this->view_popularity)) if (!is_null($this->view_popularity))
return $this->view_popularity; return $this->view_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
@@ -512,6 +516,7 @@ class record_preview extends record_adapter
public function get_refferer_popularity() public function get_refferer_popularity()
{ {
if (!is_null($this->refferer_popularity)) if (!is_null($this->refferer_popularity))
return $this->refferer_popularity; return $this->refferer_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
@@ -598,6 +603,7 @@ class record_preview extends record_adapter
{ {
if (!is_null($this->download_popularity)) if (!is_null($this->download_popularity))
return $this->download_popularity; return $this->download_popularity;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();

View File

@@ -131,8 +131,10 @@ class registry implements registryInterface
$this->load(); $this->load();
if(!$this->cache->is_set($key) && !is_null($defaultvalue)) if(!$this->cache->is_set($key) && !is_null($defaultvalue))
return $defaultvalue; return $defaultvalue;
else else
return $this->cache->get($key); return $this->cache->get($key);
} }

View File

@@ -758,6 +758,7 @@ class set_export extends set_abstract
return false; return false;
} }
if (isset($list['complete']) && $list['complete'] === true) if (isset($list['complete']) && $list['complete'] === true)
return; return;
@@ -1007,6 +1008,7 @@ class set_export extends set_abstract
$response->headers->set('Content-Disposition', $disposition . "; filename=" . $exportname . ";"); $response->headers->set('Content-Disposition', $disposition . "; filename=" . $exportname . ";");
$response->headers->set('Content-Length', filesize($file)); $response->headers->set('Content-Length', filesize($file));
$response->setContent(file_get_contents($file)); $response->setContent(file_get_contents($file));
return $response; return $response;
} }
} }

View File

@@ -150,6 +150,7 @@ class task_manager
closedir($hdir); closedir($hdir);
} }
} }
return $tasks; return $tasks;
} }
} }

View File

@@ -162,6 +162,7 @@ class task_period_outofdate extends task_abstract
parent.calcSQL(); parent.calcSQL();
</script> </script>
<?php <?php
return(""); return("");
} }
else // ... so we NEVER come here else // ... so we NEVER come here
@@ -218,6 +219,7 @@ class task_period_outofdate extends task_abstract
jQuery.map($(this).serializeArray(), function(n, i){ jQuery.map($(this).serializeArray(), function(n, i){
json[n['name']] = n['value']; json[n['name']] = n['value'];
}); });
return json; return json;
}; };
})( jQuery ); })( jQuery );
@@ -309,6 +311,7 @@ class task_period_outofdate extends task_abstract
$("#status"+fld).html(html); $("#status"+fld).html(html);
} }
}); });
return; return;
} }
@@ -682,6 +685,7 @@ class task_period_outofdate extends task_abstract
} }
$ret = ($nchanged > 0 ? $nchanged : 'NORECSTODO'); $ret = ($nchanged > 0 ? $nchanged : 'NORECSTODO');
return($ret); return($ret);
} }

View File

@@ -68,6 +68,7 @@ class task_period_upgradetov32 extends task_abstract
{ {
printf("sbas_id '" . $this->sbas_id . "' invalide\n"); printf("sbas_id '" . $this->sbas_id . "' invalide\n");
$this->return_value = self::RETURNSTATUS_STOPPED; $this->return_value = self::RETURNSTATUS_STOPPED;
return; return;
} }
@@ -369,11 +370,13 @@ class task_period_upgradetov32 extends task_abstract
if ($n_done >= 5000) if ($n_done >= 5000)
{ {
$this->return_value = task_abstract::RETURNSTATUS_TORESTART; $this->return_value = task_abstract::RETURNSTATUS_TORESTART;
return; return;
} }
if ($memory > 100) if ($memory > 100)
{ {
$this->return_value = task_abstract::RETURNSTATUS_TORESTART; $this->return_value = task_abstract::RETURNSTATUS_TORESTART;
return; return;
} }
} }

View File

@@ -366,6 +366,7 @@ class task_period_writemeta extends task_databoxAbstract
$this->log("\t" . $s); $this->log("\t" . $s);
} }
return $this; return $this;
} }

View File

@@ -305,6 +305,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$element = new Bridge_Api_Apitest_Element(); $element = new Bridge_Api_Apitest_Element();
$element->id = $element_id; $element->id = $element_id;
$element->type = $object; $element->type = $object;
return $element; return $element;
} }
@@ -313,6 +314,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$container = new Bridge_Api_Apitest_Containers(); $container = new Bridge_Api_Apitest_Containers();
$container->id = $element_id; $container->id = $element_id;
$container->type = $object; $container->type = $object;
return $container; return $container;
} }
@@ -340,6 +342,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$element_collection->add_element(new Bridge_Api_Apitest_Element()); $element_collection->add_element(new Bridge_Api_Apitest_Element());
$i++; $i++;
} }
return $element_collection; return $element_collection;
} }
@@ -352,6 +355,7 @@ class Bridge_Api_Apitest extends Bridge_Api_Abstract implements Bridge_Api_Inter
$container_collection->add_element(new Bridge_Api_Apitest_Containers()); $container_collection->add_element(new Bridge_Api_Apitest_Containers());
$i++; $i++;
} }
return $container_collection; return $container_collection;
} }

View File

@@ -88,6 +88,7 @@ class W3CFeedUrlValidator extends W3CFeedValidator
{ {
throw new W3CFeedValidatorException("Unable to request W3C API"); throw new W3CFeedValidatorException("Unable to request W3C API");
} }
return new W3CFeedValidatorResponse($response); return new W3CFeedValidatorResponse($response);
} }
@@ -151,6 +152,7 @@ class W3CFeedRawValidator extends W3CFeedValidator
{ {
throw new W3CFeedValidatorException("Unable to request W3C API"); throw new W3CFeedValidatorException("Unable to request W3C API");
} }
return new W3CFeedValidatorResponse($response); return new W3CFeedValidatorResponse($response);
} }
@@ -209,6 +211,7 @@ class W3CFeedValidatorResponse
$string .= $name . "=>" . $detail . "\n"; $string .= $name . "=>" . $detail . "\n";
} }
} }
return $string; return $string;
} }
@@ -219,6 +222,7 @@ class W3CFeedValidatorResponse
public function isValid() public function isValid()
{ {
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:validity"; $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:validity";
return $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== "false"; return $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== "false";
} }
@@ -229,6 +233,7 @@ class W3CFeedValidatorResponse
public function hasError() public function hasError()
{ {
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorcount"; $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorcount";
return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0; return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0;
} }
@@ -239,6 +244,7 @@ class W3CFeedValidatorResponse
public function hasWarning() public function hasWarning()
{ {
$xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warningcount"; $xPathQuery = "/env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warningcount";
return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0; return (int) $this->DOMXpath->query($xPathQuery)->item(0)->nodeValue !== 0;
} }
@@ -286,6 +292,7 @@ class W3CFeedValidatorResponse
$warnings[] = $this->domNodeToArray($warning); $warnings[] = $this->domNodeToArray($warning);
} }
} }
return $warnings; return $warnings;
} }
@@ -305,6 +312,7 @@ class W3CFeedValidatorResponse
$errors[] = $this->domNodeToArray($error); $errors[] = $this->domNodeToArray($error);
} }
} }
return $errors; return $errors;
} }

View File

@@ -64,6 +64,7 @@ class Module_Prod_Route_RecordFeedApp extends PhraseanetWebTestCaseAuthenticated
public function createApplication() public function createApplication()
{ {
$app = require __DIR__ . '/../../../../../classes/module/Prod.php'; $app = require __DIR__ . '/../../../../../classes/module/Prod.php';
return $app; return $app;
} }

View File

@@ -331,6 +331,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
{ {
$current_attributes[$attribute->name] = $attribute->value; $current_attributes[$attribute->name] = $attribute->value;
} }
return $current_attributes; return $current_attributes;
} }
@@ -516,6 +517,7 @@ class Module_RssFeedTest extends PhraseanetWebTestCaseAbstract
unset($item_entries[$key]); //remove unset($item_entries[$key]); //remove
} }
}; };
return $remove; return $remove;
} }

View File

@@ -351,6 +351,7 @@ foreach ($tasks as $t)
{ {
if(window.console) if(window.console)
console.log('No task like this'); console.log('No task like this');
return(false); return(false);
} }

View File

@@ -72,6 +72,7 @@ $qrySbas = array();
if (is_null($parm['bas'])) if (is_null($parm['bas']))
{ {
echo 'vous devez selectionner des collections dans lesquelles chercher'; echo 'vous devez selectionner des collections dans lesquelles chercher';
return; return;
} }

View File

@@ -220,6 +220,7 @@ if ($request->has_post_datas())
if ($newUsrEmail) if ($newUsrEmail)
{ {
$user->set_mail_locked(true); $user->set_mail_locked(true);
return phrasea::redirect('/login/sendmail-confirm.php?usr_id=' . $newid); return phrasea::redirect('/login/sendmail-confirm.php?usr_id=' . $newid);
} }