Coding standards

This commit is contained in:
Romain Neutron
2012-02-02 15:43:12 +01:00
parent 879166bbe1
commit a9c7ed23cb
19 changed files with 67 additions and 56 deletions

View File

@@ -339,7 +339,7 @@ return call_user_func(function()
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$Serializer = $app['Core']['Serializer']; $Serializer = $app['Core']['Serializer'];
@@ -374,7 +374,7 @@ return call_user_func(function()
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$Serializer = $app['Core']['Serializer']; $Serializer = $app['Core']['Serializer'];
@@ -400,7 +400,7 @@ return call_user_func(function()
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$Serializer = $app['Core']['Serializer']; $Serializer = $app['Core']['Serializer'];
@@ -424,7 +424,7 @@ return call_user_func(function()
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
$Serializer = $app['Core']['Serializer']; $Serializer = $app['Core']['Serializer'];

View File

@@ -92,7 +92,7 @@ class Language implements ControllerProviderInterface
$out['FeedBackName'] = _('Name'); $out['FeedBackName'] = _('Name');
$out['FeedBackMessage'] = _('Message'); $out['FeedBackMessage'] = _('Message');
$out['FeedBackNoUsersSelected'] = _('No users selected'); $out['FeedBackNoUsersSelected'] = _('No users selected');
$Serializer = $app['Core']['Serializer']; $Serializer = $app['Core']['Serializer'];
return new Response( return new Response(

View File

@@ -334,7 +334,7 @@ class Push implements ControllerProviderInterface
} }
catch (\Exception_NotFound $e) catch (\Exception_NotFound $e)
{ {
} }
$Participant = new \Entities\ValidationParticipant(); $Participant = new \Entities\ValidationParticipant();
@@ -507,7 +507,7 @@ class Push implements ControllerProviderInterface
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
if (!$user instanceof \User_Adapter) if (!$user instanceof \User_Adapter)
@@ -638,10 +638,10 @@ class Push implements ControllerProviderInterface
{ {
$query->havePositions($request->get('Position')); $query->havePositions($request->get('Position'));
} }
$sort = $request->get('srt', 'usr_creationdate'); $sort = $request->get('srt', 'usr_creationdate');
$ord = $request->get('ord', 'desc'); $ord = $request->get('ord', 'desc');
$query->sort_by($sort, $ord); $query->sort_by($sort, $ord);
$results = $query->include_phantoms() $results = $query->include_phantoms()

View File

@@ -113,7 +113,7 @@ class UsrLists implements ControllerProviderInterface
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
if ($request->getRequestFormat() == 'json') if ($request->getRequestFormat() == 'json')
@@ -183,7 +183,7 @@ class UsrLists implements ControllerProviderInterface
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
$Json = $app['Core']['Serializer']->serialize($datas, 'json'); $Json = $app['Core']['Serializer']->serialize($datas, 'json');
@@ -298,7 +298,7 @@ class UsrLists implements ControllerProviderInterface
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
$Json = $app['Core']['Serializer']->serialize($datas, 'json'); $Json = $app['Core']['Serializer']->serialize($datas, 'json');

View File

@@ -52,7 +52,7 @@ class ConnectionTest implements ControllerProviderInterface
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
if ($dbname && $connection_ok === true) if ($dbname && $connection_ok === true)
@@ -85,7 +85,7 @@ class ConnectionTest implements ControllerProviderInterface
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
} }

View File

@@ -411,17 +411,17 @@ class API_OAuth2_Adapter extends OAuth2
$scope = $request->get('scope', false); $scope = $request->get('scope', false);
$state = $request->get('state', false); $state = $request->get('state', false);
if($state) if($state)
{ {
$datas["state"] = $state; $datas["state"] = $state;
} }
if($scope) if($scope)
{ {
$datas["scope"] = $scope; $datas["scope"] = $scope;
} }
$filters = array( $filters = array(
"client_id" => array( "client_id" => array(
"filter" => FILTER_VALIDATE_REGEXP "filter" => FILTER_VALIDATE_REGEXP

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();
@@ -1379,7 +1381,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $this; return $this;
@@ -1485,6 +1487,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;
@@ -1522,6 +1525,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();
@@ -1580,7 +1584,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }
} }
@@ -1644,7 +1648,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return false; return false;
@@ -1730,7 +1734,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
return $locale; return $locale;
@@ -1796,6 +1800,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

@@ -542,6 +542,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();
@@ -702,6 +703,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;
@@ -726,6 +728,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

@@ -43,7 +43,7 @@ class cache_databox
} }
catch (\Exception $e) catch (\Exception $e)
{ {
} }
if ($last_update) if ($last_update)

View File

@@ -192,6 +192,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

@@ -159,13 +159,13 @@ class databox_status
$statuses = array(); $statuses = array();
$sbas_ids = $user->ACL()->get_granted_sbas(); $sbas_ids = $user->ACL()->get_granted_sbas();
$see_all = array(); $see_all = array();
foreach ($sbas_ids as $databox) foreach ($sbas_ids as $databox)
{ {
$see_all[$databox->get_sbas_id()] = false; $see_all[$databox->get_sbas_id()] = false;
foreach($databox->get_collections() as $collection) foreach($databox->get_collections() as $collection)
{ {
if($user->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus')) if($user->ACL()->has_right_on_base($collection->get_base_id(), 'chgstatus'))
@@ -193,7 +193,7 @@ class databox_status
if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct')) if ($user->ACL()->has_right_on_sbas($sbas_id, 'bas_modify_struct'))
$see_this = true; $see_this = true;
foreach ($status as $bit => $props) foreach ($status as $bit => $props)
{ {

View File

@@ -1935,16 +1935,16 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_data_from_cache($option = null) public function get_data_from_cache($option = null)
{ {
\cache_databox::refresh($this->get_sbas_id()); \cache_databox::refresh($this->get_sbas_id());
$databox = $this->get_databox(); $databox = $this->get_databox();
return $databox->get_data_from_cache($this->get_cache_key($option)); return $databox->get_data_from_cache($this->get_cache_key($option));
} }
public function set_data_to_cache($value, $option = null, $duration = 0) public function set_data_to_cache($value, $option = null, $duration = 0)
{ {
$databox = $this->get_databox(); $databox = $this->get_databox();
return $databox->set_data_to_cache($value, $this->get_cache_key($option), $duration); return $databox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
} }
@@ -1962,7 +1962,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
break; break;
} }
$databox = $this->get_databox(); $databox = $this->get_databox();
\cache_databox::update($this->get_sbas_id(), 'record', $this->get_record_id()); \cache_databox::update($this->get_sbas_id(), 'record', $this->get_record_id());
return $databox->delete_data_from_cache($this->get_cache_key($option)); return $databox->delete_data_from_cache($this->get_cache_key($option));

View File

@@ -829,12 +829,14 @@ class task_period_archive extends task_abstract
{ {
$magicmethod = strtoupper($sxDotPhrasea->magicfile['method']); $magicmethod = strtoupper($sxDotPhrasea->magicfile['method']);
if($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile)) if($magicmethod == 'LOCK' && file_exists($path . '/' . $magicfile))
return; return;
elseif($magicmethod == 'UNLOCK' && !file_exists($path . '/' . $magicfile)) elseif($magicmethod == 'UNLOCK' && !file_exists($path . '/' . $magicfile))
return; return;
} }
} }
while(($file = $listFolder->read()) !== NULL) while(($file = $listFolder->read()) !== NULL)
{ {
if ($this->isIgnoredFile($file)) if ($this->isIgnoredFile($file))

View File

@@ -53,7 +53,7 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('UTF-8', $response->getCharset()); $this->assertEquals('UTF-8', $response->getCharset());
} }
public function testRoutePOSTValidateSlash() public function testRoutePOSTValidateSlash()
{ {
$route = '/push/validateform/'; $route = '/push/validateform/';

View File

@@ -38,11 +38,11 @@
<p> <p>
{% trans 'Push::une validation est une demande d\'appreciation a d\'autres personnes' %} {% trans 'Push::une validation est une demande d\'appreciation a d\'autres personnes' %}
</p> </p>
<input class="search" name="users-search" placeholder="{% trans 'Users' %}" type="text" /> <input class="search" name="users-search" placeholder="{% trans 'Users' %}" type="text" />
<a href="/prod/push/add-user/" class="user_adder">{% trans 'Add user' %}</a> <a href="/prod/push/add-user/" class="user_adder">{% trans 'Add user' %}</a>
<button class="FeedbackSend">{% trans "Send" %}</button> <button class="FeedbackSend">{% trans "Send" %}</button>
</div> </div>
@@ -110,8 +110,8 @@
</div> </div>
<div id="FeedbackSendForm"> <div id="FeedbackSendForm">
<form method="post"> <form method="post">
</form> </form>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">

View File

@@ -83,10 +83,10 @@
</tbody> </tbody>
</table> </table>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
var $editor = $('#list-editor-search-results'); var $editor = $('#list-editor-search-results');
$('th.sortable', $editor).bind('click', function(){ $('th.sortable', $editor).bind('click', function(){
var $this = $(this); var $this = $(this);
@@ -95,7 +95,7 @@
var $form = $this.closest('.editor').find('form[name="list-editor-search"]'); var $form = $this.closest('.editor').find('form[name="list-editor-search"]');
if((sort == $('input[name="srt"]', $form).val()) if((sort == $('input[name="srt"]', $form).val())
&& ($('input[name="ord"]', $form).val() == 'asc')) && ($('input[name="ord"]', $form).val() == 'asc'))
{ {
var ord = 'desc'; var ord = 'desc';
@@ -112,19 +112,19 @@
}) })
.bind('mouseover', function(){$(this).addClass('hover');}) .bind('mouseover', function(){$(this).addClass('hover');})
.bind('mouseout', function(){$(this).removeClass('hover');}); .bind('mouseout', function(){$(this).removeClass('hover');});
$('tbody tr', $editor).bind('click', function(){ $('tbody tr', $editor).bind('click', function(){
var $this = $(this); var $this = $(this);
var usr_id = $('input[name="usr_id"]', $this).val(); var usr_id = $('input[name="usr_id"]', $this).val();
var counters = $('#ListManager .counter.current, #ListManager .lists .list.selected .counter'); var counters = $('#ListManager .counter.current, #ListManager .lists .list.selected .counter');
if($this.hasClass('selected')) if($this.hasClass('selected'))
{ {
$this.removeClass('selected'); $this.removeClass('selected');
p4.ListManager.getList().removeUser(usr_id); p4.ListManager.getList().removeUser(usr_id);
counters.each(function(i,el){ counters.each(function(i,el){
var n = parseInt($(el).text()); var n = parseInt($(el).text());
$(el).text(n - 1); $(el).text(n - 1);
@@ -134,15 +134,15 @@
{ {
$this.addClass('selected'); $this.addClass('selected');
p4.ListManager.getList().addUser(usr_id); p4.ListManager.getList().addUser(usr_id);
counters.each(function(i,el){ counters.each(function(i,el){
var n = parseInt($(el).text()); var n = parseInt($(el).text());
$(el).text(n + 1); $(el).text(n + 1);
}); });
} }
}); });
}); });
</script> </script>
{% endmacro %} {% endmacro %}

View File

@@ -1,3 +1,3 @@
{% import 'prod/actions/Feedback/ListsMacros.html.twig' as ListsMacros %} {% import 'prod/actions/Feedback/ListsMacros.html.twig' as ListsMacros %}
{{ ListsMacros.ResultTable(results, list, sort, ord) }} {{ ListsMacros.ResultTable(results, list, sort, ord) }}

View File

@@ -21,7 +21,7 @@
</div> </div>
<form name="list-editor-search" method="POST" action="/prod/push/edit-list/{{ list.getId() }}/"> <form name="list-editor-search" method="POST" action="/prod/push/edit-list/{{ list.getId() }}/">
<div class="PNB" style="top:40px;height:40px;bottom:auto;"> <div class="PNB" style="top:40px;height:40px;bottom:auto;">
<select name="like_field"> <select name="like_field">
<option value="usr_login"> <option value="usr_login">
{% trans 'Push::filter on login' %} {% trans 'Push::filter on login' %}
@@ -48,9 +48,9 @@
<button type="submit"> <button type="submit">
{% trans 'boutton::chercher' %} {% trans 'boutton::chercher' %}
</button> </button>
</div> </div>
<div class="PNB" style="top:80px;height:120px;bottom:auto;"> <div class="PNB" style="top:80px;height:120px;bottom:auto;">
<table style="table-layout:fixed;"> <table style="table-layout:fixed;">
@@ -113,7 +113,7 @@
</tr> </tr>
</table> </table>
</div> </div>
<input type="hidden" name="page" value="" /> <input type="hidden" name="page" value="" />
<input type="hidden" name="srt" value="{{ sort }}" /> <input type="hidden" name="srt" value="{{ sort }}" />
<input type="hidden" name="ord" value="{{ ord }}" /> <input type="hidden" name="ord" value="{{ ord }}" />

View File

@@ -26,11 +26,11 @@
<p> <p>
{% trans 'Push::unpush permet d\'envoyer un lot d\'image a des destinataires' %} {% trans 'Push::unpush permet d\'envoyer un lot d\'image a des destinataires' %}
</p> </p>
<input class="search" name="users-search" placeholder="{% trans 'Users' %}" type="text" /> <input class="search" name="users-search" placeholder="{% trans 'Users' %}" type="text" />
<a href="/prod/push/add-user/" class="user_adder">{% trans 'Add user' %}</a> <a href="/prod/push/add-user/" class="user_adder">{% trans 'Add user' %}</a>
<button class="FeedbackSend">{% trans "Send" %}</button> <button class="FeedbackSend">{% trans "Send" %}</button>
</div> </div>
@@ -98,8 +98,8 @@
</div> </div>
<div id="FeedbackSendForm"> <div id="FeedbackSendForm">
<form method="post"> <form method="post">
</form> </form>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">