Coding standards

This commit is contained in:
Romain Neutron
2012-03-09 12:49:13 +01:00
parent 20a771ae37
commit 82d9eeef7b
64 changed files with 217 additions and 175 deletions

View File

@@ -67,8 +67,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/');
}); });

View File

@@ -40,6 +40,7 @@ class ArrayCache extends DoctrineArray implements Cache
{ {
throw new Exception(sprintf('Unable to find key %s', $id)); throw new Exception(sprintf('Unable to find key %s', $id));
} }
return $this->fetch($id); return $this->fetch($id);
} }

View File

@@ -49,6 +49,7 @@ class Configuration
{ {
$specifications = new Configuration\ApplicationSpecification(); $specifications = new Configuration\ApplicationSpecification();
} }
return new self($specifications, $environment); return new self($specifications, $environment);
} }

View File

@@ -134,12 +134,14 @@ class ApplicationSpecification implements Specification
$this->getConfigurationsFile(); $this->getConfigurationsFile();
$this->getConnexionsFile(); $this->getConnexionsFile();
$this->getServicesFile(); $this->getServicesFile();
return true; return true;
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
return false; return false;
} }

View File

@@ -56,6 +56,7 @@ class StoryWZRepository extends EntityRepository
{ {
return 0; return 0;
} }
return ($a < $b) ? -1 : 1; return ($a < $b) ? -1 : 1;
}); });

View File

@@ -152,6 +152,7 @@ class API_OAuth2_Form_DevAppDesktop
$metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank)); $metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank));
$metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank($blank)); $metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank($blank));
$metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url)); $metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url));
return; return;
} }

View File

@@ -159,6 +159,7 @@ class API_OAuth2_Form_DevAppInternet
$metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url)); $metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url));
$metadata->addPropertyConstraint('urlcallback', new Constraints\NotBlank($blank)); $metadata->addPropertyConstraint('urlcallback', new Constraints\NotBlank($blank));
$metadata->addPropertyConstraint('urlcallback', new Constraints\Url($url)); $metadata->addPropertyConstraint('urlcallback', new Constraints\Url($url));
return; return;
} }

View File

@@ -220,6 +220,7 @@ class API_V1_adapter extends API_V1_Abstract
); );
} }
$result->set_datas($ret); $result->set_datas($ret);
return $result; return $result;
} }

View File

@@ -377,6 +377,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
if (!$response->isOk()) if (!$response->isOk())
{ {
if ($response->err_code === 3) //Already exists in photoset if ($response->err_code === 3) //Already exists in photoset
return; return;
throw new Bridge_Exception_ApiConnectorRequestFailed(); throw new Bridge_Exception_ApiConnectorRequestFailed();
} }
@@ -663,12 +664,15 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
{ {
if (!$this->registry->get('GV_flickr_api')) if (!$this->registry->get('GV_flickr_api'))
return false; return false;
if (trim($this->registry->get('GV_flickr_client_id')) === '') if (trim($this->registry->get('GV_flickr_client_id')) === '')
return false; return false;
if (trim($this->registry->get('GV_flickr_client_secret')) === '') if (trim($this->registry->get('GV_flickr_client_secret')) === '')
return false; return false;
return true; return true;

View File

@@ -136,10 +136,12 @@ class appbox extends base
$custom_path.= $collection->get_base_id(); $custom_path.= $collection->get_base_id();
if (is_null($pathfile)) if (is_null($pathfile))
return $this; return $this;
$datas = file_get_contents($pathfile->getPathname()); $datas = file_get_contents($pathfile->getPathname());
if (is_null($datas)) if (is_null($datas))
return $this; return $this;
file_put_contents($file, $datas); file_put_contents($file, $datas);
@@ -191,10 +193,12 @@ class appbox extends base
$custom_path.= $pic_type . '_' . $databox->get_sbas_id(); $custom_path.= $pic_type . '_' . $databox->get_sbas_id();
if (is_null($pathfile)) if (is_null($pathfile))
return $this; return $this;
$datas = file_get_contents($pathfile->getPathname()); $datas = file_get_contents($pathfile->getPathname());
if (is_null($datas)) if (is_null($datas))
return $this; return $this;
file_put_contents($file, $datas); file_put_contents($file, $datas);
@@ -540,6 +544,7 @@ class appbox extends base
public function get_databoxes() public function get_databoxes()
{ {
if ($this->databoxes) if ($this->databoxes)
return $this->databoxes; return $this->databoxes;
$ret = array(); $ret = array();

View File

@@ -79,6 +79,7 @@ abstract class base implements cache_cacheableInterface
public function get_schema() public function get_schema()
{ {
if ($this->schema) if ($this->schema)
return $this->schema; return $this->schema;
$this->load_schema(); $this->load_schema();
@@ -167,6 +168,7 @@ abstract class base implements cache_cacheableInterface
{ {
$this->cache = $this->Core->getCache(); $this->cache = $this->Core->getCache();
} }
return $this->cache; return $this->cache;
} }
@@ -232,6 +234,7 @@ abstract class base implements cache_cacheableInterface
{ {
if ($this->version) if ($this->version)
return $this->version; return $this->version;
$version = '0.0.0'; $version = '0.0.0';
@@ -260,8 +263,10 @@ abstract class base implements cache_cacheableInterface
public function upgradeavailable() public function upgradeavailable()
{ {
if ($this->get_version()) if ($this->get_version())
return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>'); return version_compare(\Alchemy\Phrasea\Core\Version::getNumber(), $this->get_version(), '>');
else else
return true; return true;
} }
@@ -399,6 +404,7 @@ abstract class base implements cache_cacheableInterface
protected function load_schema() protected function load_schema()
{ {
if ($this->schema) if ($this->schema)
return $this; return $this;
$structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml"); $structure = simplexml_load_file(__DIR__ . "/../../lib/conf.d/bases_structure.xml");

View File

@@ -59,6 +59,7 @@ class cache_databox
if ($date <= $last_update) if ($date <= $last_update)
{ {
self::$refreshing = false; self::$refreshing = false;
return; return;
} }

View File

@@ -79,6 +79,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']))
@@ -131,6 +132,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;
@@ -139,6 +141,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;
@@ -158,6 +161,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/');
@@ -274,6 +278,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

View File

@@ -306,6 +306,7 @@ class module_console_fileEnsureDevSetting extends Command
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required))); $output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
$this->errors++; $this->errors++;
} }
return; return;
} }
@@ -447,6 +448,7 @@ class module_console_fileEnsureDevSetting extends Command
{ {
$config = new \Doctrine\DBAL\Configuration(); $config = new \Doctrine\DBAL\Configuration();
$conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config); $conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
return true; return true;
} }
catch (\Exception $e) catch (\Exception $e)

View File

@@ -300,6 +300,7 @@ class module_console_fileEnsureProductionSetting extends Command
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required))); $output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
$this->errors++; $this->errors++;
} }
return; return;
} }
@@ -441,6 +442,7 @@ class module_console_fileEnsureProductionSetting extends Command
{ {
$config = new \Doctrine\DBAL\Configuration(); $config = new \Doctrine\DBAL\Configuration();
$conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config); $conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
return true; return true;
} }
catch (\Exception $e) catch (\Exception $e)
@@ -896,6 +898,7 @@ class module_console_fileEnsureProductionSetting extends Command
{ {
return false; return false;
} }
return $server === $Service->getDriver()->isServer(); return $server === $Service->getDriver()->isServer();
} }

View File

@@ -99,6 +99,7 @@ class sphinxrt
$cl = new SphinxClient(); $cl = new SphinxClient();
if ($cl->Status() === false) if ($cl->Status() === false)
return $this; return $this;
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port')); $cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));

View File

@@ -35,6 +35,7 @@ $extractDateFields = function(\Alchemy\Phrasea\Core $Core) {
$date_sort_fields[$date['fieldname']] = $date['fieldname']; $date_sort_fields[$date['fieldname']] = $date['fieldname'];
} }
} }
return $date_sort_fields; return $date_sort_fields;
}; };

View File

@@ -53,6 +53,7 @@
{ {
var val = $.trim($('#auto_order').val()); var val = $.trim($('#auto_order').val());
if(val == '') if(val == '')
return; return;
var sorter = {}; var sorter = {};

View File

@@ -53,6 +53,7 @@
{ {
var val = $.trim($('#auto_order').val()); var val = $.trim($('#auto_order').val());
if(val == '') if(val == '')
return; return;
var sorter = {}; var sorter = {};

View File

@@ -155,6 +155,7 @@
humane.error(data.message); humane.error(data.message);
} }
$dialog.refresh(); $dialog.refresh();
return; return;
}, },
error: function(){ error: function(){

View File

@@ -292,6 +292,7 @@ phrasea::headers();
}, },
success: function(data){ success: function(data){
alert(data.message); alert(data.message);
return; return;
} }
}); });