Commit fb3d5e0b authored by Franco Fichtner's avatar Franco Fichtner

mvc: apply new style rule

parent 50e9ebb6
...@@ -92,7 +92,7 @@ class ControllerBase extends ControllerRoot ...@@ -92,7 +92,7 @@ class ControllerBase extends ControllerRoot
} else { } else {
$tab[] = $this->parseFormNode($node); $tab[] = $this->parseFormNode($node);
} }
$result['tabs'][] = $tab ; $result['tabs'][] = $tab;
break; break;
case "subtab": case "subtab":
$subtab = array(); $subtab = array();
...@@ -135,13 +135,13 @@ class ControllerBase extends ControllerRoot ...@@ -135,13 +135,13 @@ class ControllerBase extends ControllerRoot
public function getForm($formname) public function getForm($formname)
{ {
$class_info = new \ReflectionClass($this); $class_info = new \ReflectionClass($this);
$filename = dirname($class_info->getFileName()) . "/forms/".$formname.".xml" ; $filename = dirname($class_info->getFileName()) . "/forms/".$formname.".xml";
if (!file_exists($filename)) { if (!file_exists($filename)) {
throw new \Exception('form xml '.$filename.' missing') ; throw new \Exception('form xml '.$filename.' missing');
} }
$formXml = simplexml_load_file($filename); $formXml = simplexml_load_file($filename);
if ($formXml === false) { if ($formXml === false) {
throw new \Exception('form xml '.$filename.' not valid') ; throw new \Exception('form xml '.$filename.' not valid');
} }
return $this->parseFormNode($formXml); return $this->parseFormNode($formXml);
......
...@@ -91,7 +91,7 @@ class SettingsController extends ApiControllerBase ...@@ -91,7 +91,7 @@ class SettingsController extends ApiControllerBase
} }
} else { } else {
// generate new node, but don't save to disc // generate new node, but don't save to disc
$node = $mdlCP->zones->zone->add() ; $node = $mdlCP->zones->zone->add();
return array("zone" => $node->getNodes()); return array("zone" => $node->getNodes());
} }
return array(); return array();
......
...@@ -44,10 +44,10 @@ class InterfaceController extends ApiControllerBase ...@@ -44,10 +44,10 @@ class InterfaceController extends ApiControllerBase
{ {
// collect interface names // collect interface names
$intfmap = array(); $intfmap = array();
$config = Config::getInstance()->object() ; $config = Config::getInstance()->object();
if ($config->interfaces != null) { if ($config->interfaces != null) {
foreach ($config->interfaces->children() as $key => $node) { foreach ($config->interfaces->children() as $key => $node) {
$intfmap[(string)$node->if] = !empty((string)$node->descr) ? (string)$node->descr : $key ; $intfmap[(string)$node->if] = !empty((string)$node->descr) ? (string)$node->descr : $key;
} }
} }
return $intfmap; return $intfmap;
......
...@@ -155,7 +155,7 @@ class NetworkinsightController extends ApiControllerBase ...@@ -155,7 +155,7 @@ class NetworkinsightController extends ApiControllerBase
$data_filter .= ','; $data_filter .= ',';
} }
if (isset($filter_values[$field_indx])) { if (isset($filter_values[$field_indx])) {
$data_filter .= $filter_field.'='.$filter_values[$field_indx] ; $data_filter .= $filter_field.'='.$filter_values[$field_indx];
} }
} }
$data_filter = "'{$data_filter}'"; $data_filter = "'{$data_filter}'";
...@@ -266,7 +266,7 @@ class NetworkinsightController extends ApiControllerBase ...@@ -266,7 +266,7 @@ class NetworkinsightController extends ApiControllerBase
); );
if ($this->request->isGet()) { if ($this->request->isGet()) {
$backend = new Backend(); $backend = new Backend();
$configd_cmd = "netflow aggregate export {$provider} {$from_date} {$to_date} {$resolution}" ; $configd_cmd = "netflow aggregate export {$provider} {$from_date} {$to_date} {$resolution}";
$response = $backend->configdRun($configd_cmd); $response = $backend->configdRun($configd_cmd);
return $response; return $response;
} else { } else {
......
...@@ -595,10 +595,10 @@ class SystemhealthController extends ApiControllerBase ...@@ -595,10 +595,10 @@ class SystemhealthController extends ApiControllerBase
{ {
// collect interface names // collect interface names
$intfmap = array(); $intfmap = array();
$config = Config::getInstance()->object() ; $config = Config::getInstance()->object();
if ($config->interfaces != null) { if ($config->interfaces != null) {
foreach ($config->interfaces->children() as $key => $node) { foreach ($config->interfaces->children() as $key => $node) {
$intfmap[(string)$key] = array("descr" => !empty((string)$node->descr) ? (string)$node->descr : $key) ; $intfmap[(string)$key] = array("descr" => !empty((string)$node->descr) ? (string)$node->descr : $key);
} }
} }
return $intfmap; return $intfmap;
......
...@@ -243,7 +243,7 @@ class SettingsController extends ApiMutableModelControllerBase ...@@ -243,7 +243,7 @@ class SettingsController extends ApiMutableModelControllerBase
$item['documentation_url'] = $fileinfo['documentation_url']; $item['documentation_url'] = $fileinfo['documentation_url'];
if (!empty($fileinfo['documentation_url'])) { if (!empty($fileinfo['documentation_url'])) {
$item['documentation'] = "<a href='".$item['documentation_url']."' target='_new'>"; $item['documentation'] = "<a href='".$item['documentation_url']."' target='_new'>";
$item['documentation'] .= $item['documentation_url'] ; $item['documentation'] .= $item['documentation_url'];
$item['documentation'] .= '</a>'; $item['documentation'] .= '</a>';
} else { } else {
$item['documentation'] = null; $item['documentation'] = null;
...@@ -549,7 +549,7 @@ class SettingsController extends ApiMutableModelControllerBase ...@@ -549,7 +549,7 @@ class SettingsController extends ApiMutableModelControllerBase
} }
} else { } else {
// generate new node, but don't save to disc // generate new node, but don't save to disc
$node = $mdlIDS->userDefinedRules->rule->add() ; $node = $mdlIDS->userDefinedRules->rule->add();
return array("rule" => $node->getNodes()); return array("rule" => $node->getNodes());
} }
return array(); return array();
......
...@@ -91,7 +91,7 @@ class SettingsController extends ApiControllerBase ...@@ -91,7 +91,7 @@ class SettingsController extends ApiControllerBase
} }
} else { } else {
// generate new node, but don't save to disc // generate new node, but don't save to disc
$node = $mdlShaper->pipes->pipe->add() ; $node = $mdlShaper->pipes->pipe->add();
return array("pipe" => $node->getNodes()); return array("pipe" => $node->getNodes());
} }
return array(); return array();
...@@ -238,7 +238,7 @@ class SettingsController extends ApiControllerBase ...@@ -238,7 +238,7 @@ class SettingsController extends ApiControllerBase
} }
} else { } else {
// generate new node, but don't save to disc // generate new node, but don't save to disc
$node = $mdlShaper->queues->queue->add() ; $node = $mdlShaper->queues->queue->add();
return array("queue" => $node->getNodes()); return array("queue" => $node->getNodes());
} }
return array(); return array();
...@@ -369,7 +369,7 @@ class SettingsController extends ApiControllerBase ...@@ -369,7 +369,7 @@ class SettingsController extends ApiControllerBase
} }
} else { } else {
// generate new node, but don't save to disc // generate new node, but don't save to disc
$node = $mdlShaper->rules->rule->add() ; $node = $mdlShaper->rules->rule->add();
$node->sequence = $mdlShaper->getMaxRuleSequence() + 10; $node->sequence = $mdlShaper->getMaxRuleSequence() + 10;
return array("rule" => $node->getNodes()); return array("rule" => $node->getNodes());
} }
......
...@@ -38,7 +38,7 @@ class LDAP implements IAuthConnector ...@@ -38,7 +38,7 @@ class LDAP implements IAuthConnector
/** /**
* @var int ldap version to use * @var int ldap version to use
*/ */
private $ldapVersion = 3 ; private $ldapVersion = 3;
/** /**
* @var null base ldap search DN * @var null base ldap search DN
...@@ -63,12 +63,12 @@ class LDAP implements IAuthConnector ...@@ -63,12 +63,12 @@ class LDAP implements IAuthConnector
/** /**
* @var null|string ldap administrative bind dn * @var null|string ldap administrative bind dn
*/ */
private $ldapBindDN = null ; private $ldapBindDN = null;
/** /**
* @var null|string ldap administrative bind passwd * @var null|string ldap administrative bind passwd
*/ */
private $ldapBindPassword = null ; private $ldapBindPassword = null;
/** /**
* @var null|string user attribute * @var null|string user attribute
...@@ -186,7 +186,7 @@ class LDAP implements IAuthConnector ...@@ -186,7 +186,7 @@ class LDAP implements IAuthConnector
"ldap_attr_user" => "ldapAttributeUser", "ldap_attr_user" => "ldapAttributeUser",
"ldap_extended_query" => "ldapExtendedQuery", "ldap_extended_query" => "ldapExtendedQuery",
"local_users" => "userDNmap" "local_users" => "userDNmap"
) ; );
// map properties 1-on-1 // map properties 1-on-1
foreach ($confMap as $confSetting => $objectProperty) { foreach ($confMap as $confSetting => $objectProperty) {
......
...@@ -218,7 +218,7 @@ class LocalTOTP extends Local ...@@ -218,7 +218,7 @@ class LocalTOTP extends Local
$fields["timeWindow"]["type"] = "text"; $fields["timeWindow"]["type"] = "text";
$fields["timeWindow"]["default"] = null; $fields["timeWindow"]["default"] = null;
$fields["timeWindow"]["help"] = gettext("The time period in which the token will be valid,". $fields["timeWindow"]["help"] = gettext("The time period in which the token will be valid,".
" default is 30 seconds (google authenticator)") ; " default is 30 seconds (google authenticator)");
$fields["timeWindow"]["validate"] = function ($value) { $fields["timeWindow"]["validate"] = function ($value) {
if (!empty($value) && filter_var($value, FILTER_SANITIZE_NUMBER_INT) != $value) { if (!empty($value) && filter_var($value, FILTER_SANITIZE_NUMBER_INT) != $value) {
return array(gettext("Please enter a valid time window in seconds")); return array(gettext("Please enter a valid time window in seconds"));
......
...@@ -113,7 +113,7 @@ class Radius implements IAuthConnector ...@@ -113,7 +113,7 @@ class Radius implements IAuthConnector
'radius_acct_port' => 'acctPort', 'radius_acct_port' => 'acctPort',
'radius_protocol' => 'protocol', 'radius_protocol' => 'protocol',
'refid' => 'nasIdentifier' 'refid' => 'nasIdentifier'
) ; );
// map properties 1-on-1 // map properties 1-on-1
foreach ($confMap as $confSetting => $objectProperty) { foreach ($confMap as $confSetting => $objectProperty) {
...@@ -340,7 +340,7 @@ class Radius implements IAuthConnector ...@@ -340,7 +340,7 @@ class Radius implements IAuthConnector
*/ */
public function authenticate($username, $password) public function authenticate($username, $password)
{ {
$this->lastAuthProperties = array() ;// reset auth properties $this->lastAuthProperties = array();// reset auth properties
$radius = radius_auth_open(); $radius = radius_auth_open();
$error = null; $error = null;
......
...@@ -197,7 +197,7 @@ class Voucher implements IAuthConnector ...@@ -197,7 +197,7 @@ class Voucher implements IAuthConnector
($chr_ord >= 109 && $chr_ord <= 110) || // m..n ($chr_ord >= 109 && $chr_ord <= 110) || // m..n
($chr_ord >= 112 && $chr_ord <= 122) // p..z ($chr_ord >= 112 && $chr_ord <= 122) // p..z
) { ) {
$characterMap .= $random_bytes[$i] ; $characterMap .= $random_bytes[$i];
} }
} }
} }
...@@ -212,7 +212,7 @@ class Voucher implements IAuthConnector ...@@ -212,7 +212,7 @@ class Voucher implements IAuthConnector
for ($i = 0; $i < strlen($random_bytes); $i++) { for ($i = 0; $i < strlen($random_bytes); $i++) {
$chr_ord = ord($random_bytes[$i]); $chr_ord = ord($random_bytes[$i]);
if ($chr_ord >= 33 && $chr_ord <= 125 && !in_array($random_bytes[$i], $doNotUseChr)) { if ($chr_ord >= 33 && $chr_ord <= 125 && !in_array($random_bytes[$i], $doNotUseChr)) {
$characterMap .= $random_bytes[$i] ; $characterMap .= $random_bytes[$i];
} }
} }
} }
...@@ -309,7 +309,7 @@ class Voucher implements IAuthConnector ...@@ -309,7 +309,7 @@ class Voucher implements IAuthConnector
$record['username'] = $row['username']; $record['username'] = $row['username'];
$record['validity'] = $row['validity']; $record['validity'] = $row['validity'];
# always calculate a starttime, if not registered yet, use now. # always calculate a starttime, if not registered yet, use now.
$record['starttime'] = empty($row['starttime']) ? time() : $row['starttime'] ; $record['starttime'] = empty($row['starttime']) ? time() : $row['starttime'];
$record['endtime'] = $record['starttime'] + $row['validity']; $record['endtime'] = $record['starttime'] + $row['validity'];
if (empty($row['starttime'])) { if (empty($row['starttime'])) {
...@@ -382,7 +382,7 @@ class Voucher implements IAuthConnector ...@@ -382,7 +382,7 @@ class Voucher implements IAuthConnector
$this->setStartTime($username, $row['starttime']); $this->setStartTime($username, $row['starttime']);
} }
if (time() - $row['starttime'] < $row['validity']) { if (time() - $row['starttime'] < $row['validity']) {
$this->lastAuthProperties['session_timeout'] = $row['validity'] - (time() - $row['starttime']) ; $this->lastAuthProperties['session_timeout'] = $row['validity'] - (time() - $row['starttime']);
return true; return true;
} }
} }
...@@ -400,7 +400,7 @@ class Voucher implements IAuthConnector ...@@ -400,7 +400,7 @@ class Voucher implements IAuthConnector
$fields["simplePasswords"] = array(); $fields["simplePasswords"] = array();
$fields["simplePasswords"]["name"] = gettext("Use simple passwords (less secure)"); $fields["simplePasswords"]["name"] = gettext("Use simple passwords (less secure)");
$fields["simplePasswords"]["type"] = "checkbox"; $fields["simplePasswords"]["type"] = "checkbox";
$fields["simplePasswords"]["help"] = gettext("Use simple (less secure) passwords, which are easier to read") ; $fields["simplePasswords"]["help"] = gettext("Use simple (less secure) passwords, which are easier to read");
$fields["simplePasswords"]["validate"] = function ($value) { $fields["simplePasswords"]["validate"] = function ($value) {
return array(); return array();
}; };
......
...@@ -77,7 +77,7 @@ class Backend ...@@ -77,7 +77,7 @@ class Backend
public function configdRun($event, $detach = false, $timeout = 120, $connect_timeout = 10) public function configdRun($event, $detach = false, $timeout = 120, $connect_timeout = 10)
{ {
$endOfStream = chr(0).chr(0).chr(0); $endOfStream = chr(0).chr(0).chr(0);
$poll_timeout = 2 ; // poll timeout interval $poll_timeout = 2; // poll timeout interval
// wait until socket exist for a maximum of $connect_timeout // wait until socket exist for a maximum of $connect_timeout
$timeout_wait = $connect_timeout; $timeout_wait = $connect_timeout;
...@@ -106,7 +106,7 @@ class Backend ...@@ -106,7 +106,7 @@ class Backend
} }
// read response data // read response data
$starttime = time() ; $starttime = time();
while (true) { while (true) {
$resp = $resp . stream_get_contents($stream); $resp = $resp . stream_get_contents($stream);
......
...@@ -169,7 +169,7 @@ class Config extends Singleton ...@@ -169,7 +169,7 @@ class Config extends Singleton
// root node // root node
if ($node == null) { if ($node == null) {
$this->simplexml = simplexml_load_string('<'.$this->simplexml[0]->getName().'/>'); $this->simplexml = simplexml_load_string('<'.$this->simplexml[0]->getName().'/>');
$node = $this->simplexml ; $node = $this->simplexml;
// invalidate object on warnings/errors (prevent save from happening) // invalidate object on warnings/errors (prevent save from happening)
set_error_handler( set_error_handler(
function () { function () {
...@@ -222,7 +222,7 @@ class Config extends Singleton ...@@ -222,7 +222,7 @@ class Config extends Singleton
private function checkvalid() private function checkvalid()
{ {
if (!$this->statusIsValid) { if (!$this->statusIsValid) {
throw new ConfigException('no valid config loaded') ; throw new ConfigException('no valid config loaded');
} }
} }
...@@ -267,7 +267,7 @@ class Config extends Singleton ...@@ -267,7 +267,7 @@ class Config extends Singleton
try { try {
$this->load(); $this->load();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->simplexml = null ; $this->simplexml = null;
// there was an issue with loading the config, try to restore the last backup // there was an issue with loading the config, try to restore the last backup
$backups = $this->getBackups(); $backups = $this->getBackups();
$logger = new Syslog("config", array('option' => LOG_PID, 'facility' => LOG_LOCAL4)); $logger = new Syslog("config", array('option' => LOG_PID, 'facility' => LOG_LOCAL4));
...@@ -299,17 +299,17 @@ class Config extends Singleton ...@@ -299,17 +299,17 @@ class Config extends Singleton
{ {
// exception handling // exception handling
if (!file_exists($this->config_file)) { if (!file_exists($this->config_file)) {
throw new ConfigException('file not found') ; throw new ConfigException('file not found');
} }
$xml = file_get_contents($this->config_file); $xml = file_get_contents($this->config_file);
if (trim($xml) == '') { if (trim($xml) == '') {
throw new ConfigException('empty file') ; throw new ConfigException('empty file');
} }
set_error_handler( set_error_handler(
function () { function () {
// reset simplexml pointer on parse error. // reset simplexml pointer on parse error.
$this->simplexml = null ; $this->simplexml = null;
} }
); );
...@@ -317,7 +317,7 @@ class Config extends Singleton ...@@ -317,7 +317,7 @@ class Config extends Singleton
if ($this->simplexml == null) { if ($this->simplexml == null) {
restore_error_handler(); restore_error_handler();
throw new ConfigException("invalid config xml") ; throw new ConfigException("invalid config xml");
} }
restore_error_handler(); restore_error_handler();
...@@ -470,7 +470,7 @@ class Config extends Singleton ...@@ -470,7 +470,7 @@ class Config extends Singleton
$simplexml = $this->simplexml; $simplexml = $this->simplexml;
try { try {
// try to restore config // try to restore config
copy($filename, $this->config_file) ; copy($filename, $this->config_file);
$this->load(); $this->load();
return true; return true;
} catch (ConfigException $e) { } catch (ConfigException $e) {
...@@ -482,7 +482,7 @@ class Config extends Singleton ...@@ -482,7 +482,7 @@ class Config extends Singleton
} }
} else { } else {
// we don't have a valid config loaded, just copy and load the requested one // we don't have a valid config loaded, just copy and load the requested one
copy($filename, $this->config_file) ; copy($filename, $this->config_file);
$this->load(); $this->load();
return true; return true;
} }
......
...@@ -75,7 +75,7 @@ abstract class BaseModel ...@@ -75,7 +75,7 @@ abstract class BaseModel
*/ */
protected function init() protected function init()
{ {
return ; return;
} }
/** /**
...@@ -117,7 +117,7 @@ abstract class BaseModel ...@@ -117,7 +117,7 @@ abstract class BaseModel
$tagName = $xmlNode->getName(); $tagName = $xmlNode->getName();
// every item results in a Field type object, the first step is to determine which object to create // every item results in a Field type object, the first step is to determine which object to create
// based on the input model spec // based on the input model spec
$fieldObject = null ; $fieldObject = null;
$classname = "OPNsense\\Base\\FieldTypes\\".$xmlNode->attributes()["type"]; $classname = "OPNsense\\Base\\FieldTypes\\".$xmlNode->attributes()["type"];
if (class_exists($classname)) { if (class_exists($classname)) {
// construct field type object // construct field type object
...@@ -160,7 +160,7 @@ abstract class BaseModel ...@@ -160,7 +160,7 @@ abstract class BaseModel
if ($config_data != null && isset($config_data->$tagName)) { if ($config_data != null && isset($config_data->$tagName)) {
$config_section_data = $config_data->$tagName; $config_section_data = $config_data->$tagName;
} else { } else {
$config_section_data = null ; $config_section_data = null;
} }
if ($fieldObject instanceof ArrayField) { if ($fieldObject instanceof ArrayField) {
...@@ -218,16 +218,16 @@ abstract class BaseModel ...@@ -218,16 +218,16 @@ abstract class BaseModel
// determine our caller's filename and try to find the model definition xml // determine our caller's filename and try to find the model definition xml
// throw error on failure // throw error on failure
$class_info = new \ReflectionClass($this); $class_info = new \ReflectionClass($this);
$model_filename = substr($class_info->getFileName(), 0, strlen($class_info->getFileName())-3) . "xml" ; $model_filename = substr($class_info->getFileName(), 0, strlen($class_info->getFileName())-3) . "xml";
if (!file_exists($model_filename)) { if (!file_exists($model_filename)) {
throw new ModelException('model xml '.$model_filename.' missing') ; throw new ModelException('model xml '.$model_filename.' missing');
} }
$model_xml = simplexml_load_file($model_filename); $model_xml = simplexml_load_file($model_filename);
if ($model_xml === false) { if ($model_xml === false) {
throw new ModelException('model xml '.$model_filename.' not valid') ; throw new ModelException('model xml '.$model_filename.' not valid');
} }
if ($model_xml->getName() != "model") { if ($model_xml->getName() != "model") {
throw new ModelException('model xml '.$model_filename.' seems to be of wrong type') ; throw new ModelException('model xml '.$model_filename.' seems to be of wrong type');
} }
$this->internal_mountpoint = $model_xml->mount; $this->internal_mountpoint = $model_xml->mount;
...@@ -239,13 +239,13 @@ abstract class BaseModel ...@@ -239,13 +239,13 @@ abstract class BaseModel
// if found, convert the data to a simple structure (or create an empty array) // if found, convert the data to a simple structure (or create an empty array)
$tmp_config_data = $internalConfigHandle->xpath($model_xml->mount); $tmp_config_data = $internalConfigHandle->xpath($model_xml->mount);
if ($tmp_config_data->length > 0) { if ($tmp_config_data->length > 0) {
$config_array = simplexml_import_dom($tmp_config_data->item(0)) ; $config_array = simplexml_import_dom($tmp_config_data->item(0));
} else { } else {
$config_array = array(); $config_array = array();
} }
// We've loaded the model template, now let's parse it into this object // We've loaded the model template, now let's parse it into this object
$this->parseXml($model_xml->items, $config_array, $this->internalData) ; $this->parseXml($model_xml->items, $config_array, $this->internalData);
// root may contain a version, store if found // root may contain a version, store if found
if (empty($config_array)) { if (empty($config_array)) {
// new node, reset // new node, reset
...@@ -278,7 +278,7 @@ abstract class BaseModel ...@@ -278,7 +278,7 @@ abstract class BaseModel
*/ */
public function __set($name, $value) public function __set($name, $value)
{ {
$this->internalData->$name = $value ; $this->internalData->$name = $value;
} }
/** /**
...@@ -359,7 +359,7 @@ abstract class BaseModel ...@@ -359,7 +359,7 @@ abstract class BaseModel
$fieldnm = str_replace($sourceref, $targetref, $msg->getField()); $fieldnm = str_replace($sourceref, $targetref, $msg->getField());
$result[$fieldnm] = $msg->getMessage(); $result[$fieldnm] = $msg->getMessage();
} else { } else {
$fieldnm = $targetref . $msg->getField() ; $fieldnm = $targetref . $msg->getField();
$result[$fieldnm] = $msg->getMessage(); $result[$fieldnm] = $msg->getMessage();
} }
} }
......
...@@ -81,7 +81,7 @@ class ArrayField extends BaseField ...@@ -81,7 +81,7 @@ class ArrayField extends BaseField
// validate child nodes, nesting not supported in this version. // validate child nodes, nesting not supported in this version.
throw new \Exception("Unsupported copy, Array doesn't support nesting."); throw new \Exception("Unsupported copy, Array doesn't support nesting.");
} }
$new_record[$key] = clone $node ; $new_record[$key] = clone $node;
} }
$nodeUUID = $this->generateUUID(); $nodeUUID = $this->generateUUID();
...@@ -146,11 +146,11 @@ class ArrayField extends BaseField ...@@ -146,11 +146,11 @@ class ArrayField extends BaseField
$sortKey = ''; $sortKey = '';
foreach ($fieldNames as $fieldName) { foreach ($fieldNames as $fieldName) {
if (array_key_exists($fieldName, $node->internalChildnodes)) { if (array_key_exists($fieldName, $node->internalChildnodes)) {
$sortKey .= sprintf("%".$MAX_KEY_LENGTH."s ,", $node->$fieldName) ; $sortKey .= sprintf("%".$MAX_KEY_LENGTH."s ,", $node->$fieldName);
} }
} }
$sortKey .= $nodeKey; // prevent overwrite of duplicates $sortKey .= $nodeKey; // prevent overwrite of duplicates
$sortedData[$sortKey] = $node ; $sortedData[$sortKey] = $node;
} }
// sort by key on ascending or descending order // sort by key on ascending or descending order
......
...@@ -52,13 +52,13 @@ class AutoNumberField extends BaseField ...@@ -52,13 +52,13 @@ class AutoNumberField extends BaseField
* maximum value for this field * maximum value for this field
* @var integer * @var integer
*/ */
private $maximum_value ; private $maximum_value;
/** /**
* minimum value for this field * minimum value for this field
* @var integer * @var integer
*/ */
private $minimum_value ; private $minimum_value;
/** /**
* constructor, set absolute min and max values * constructor, set absolute min and max values
...@@ -69,7 +69,7 @@ class AutoNumberField extends BaseField ...@@ -69,7 +69,7 @@ class AutoNumberField extends BaseField
{ {
parent:: __construct($ref, $tagname); parent:: __construct($ref, $tagname);
$this->minimum_value = 0; $this->minimum_value = 0;
$this->maximum_value = PHP_INT_MAX-1 ; $this->maximum_value = PHP_INT_MAX-1;
} }
/** /**
......
...@@ -90,7 +90,7 @@ abstract class BaseField ...@@ -90,7 +90,7 @@ abstract class BaseField
/** /**
* @var bool is this a required attribute? * @var bool is this a required attribute?
*/ */
protected $internalIsRequired = false ; protected $internalIsRequired = false;
/** /**
* @var string validation message string * @var string validation message string
...@@ -100,7 +100,7 @@ abstract class BaseField ...@@ -100,7 +100,7 @@ abstract class BaseField
/** /**
* @var bool node (and subnodes) is virtual * @var bool node (and subnodes) is virtual
*/ */
protected $internalIsVirtual = false ; protected $internalIsVirtual = false;
/** /**
* @var array key value store for attributes (will be saved as xml attributes) * @var array key value store for attributes (will be saved as xml attributes)
...@@ -177,7 +177,7 @@ abstract class BaseField ...@@ -177,7 +177,7 @@ abstract class BaseField
*/ */
public function __clone() public function __clone()
{ {
$this->internalIsVirtual = false ; $this->internalIsVirtual = false;
$this->internalValue = ""; $this->internalValue = "";
$this->internalReference = null; $this->internalReference = null;
} }
...@@ -240,7 +240,7 @@ abstract class BaseField ...@@ -240,7 +240,7 @@ abstract class BaseField
$result = array(); $result = array();
foreach ($this->internalChildnodes as $key => $value) { foreach ($this->internalChildnodes as $key => $value) {
if ($value->internalIsVirtual == false) { if ($value->internalIsVirtual == false) {
$result[$key] = $value ; $result[$key] = $value;
} }
} }
return $result; return $result;
...@@ -391,7 +391,7 @@ abstract class BaseField ...@@ -391,7 +391,7 @@ abstract class BaseField
{ {
$validators = $this->getConstraintValidators(); $validators = $this->getConstraintValidators();
if ($this->isEmptyAndRequired()) { if ($this->isEmptyAndRequired()) {
$validators[] = new PresenceOf(array('message' => $this->internalValidationMessage)) ; $validators[] = new PresenceOf(array('message' => $this->internalValidationMessage));
} }
return $validators; return $validators;
} }
...@@ -437,7 +437,7 @@ abstract class BaseField ...@@ -437,7 +437,7 @@ abstract class BaseField
foreach ($this->__items as $node) { foreach ($this->__items as $node) {
foreach ($node->getFlatNodes() as $childNode) { foreach ($node->getFlatNodes() as $childNode) {
$result[$childNode->internalReference] = $childNode ; $result[$childNode->internalReference] = $childNode;
} }
} }
...@@ -520,7 +520,7 @@ abstract class BaseField ...@@ -520,7 +520,7 @@ abstract class BaseField
{ {
if ($this->internalReference == "" || get_class($this) == "OPNsense\\Base\\FieldTypes\\ArrayField") { if ($this->internalReference == "" || get_class($this) == "OPNsense\\Base\\FieldTypes\\ArrayField") {
// ignore tags without internal reference (root) and ArrayTypes // ignore tags without internal reference (root) and ArrayTypes
$subnode = $node ; $subnode = $node;
} else { } else {
if ($this->internalValue != "") { if ($this->internalValue != "") {
$newNodeName = $this->getInternalXMLTagName(); $newNodeName = $this->getInternalXMLTagName();
......
...@@ -62,7 +62,7 @@ class CSVListField extends BaseField ...@@ -62,7 +62,7 @@ class CSVListField extends BaseField
/** /**
* @var string basic regex validation to use for the complete field * @var string basic regex validation to use for the complete field
*/ */
protected $internalMask = null ; protected $internalMask = null;
/** /**
* set validation mask * set validation mask
...@@ -70,7 +70,7 @@ class CSVListField extends BaseField ...@@ -70,7 +70,7 @@ class CSVListField extends BaseField
*/ */
public function setMask($value) public function setMask($value)
{ {
$this->internalMask = $value ; $this->internalMask = $value;
} }
/** /**
......
...@@ -102,7 +102,7 @@ class CertificateField extends BaseField ...@@ -102,7 +102,7 @@ class CertificateField extends BaseField
self::$internalOptionList[$this->certificateType] = array(); self::$internalOptionList[$this->certificateType] = array();
$configObj = Config::getInstance()->object(); $configObj = Config::getInstance()->object();
foreach ($configObj->{$this->certificateType} as $cert) { foreach ($configObj->{$this->certificateType} as $cert) {
self::$internalOptionList[$this->certificateType][(string)$cert->refid] = (string)$cert->descr ; self::$internalOptionList[$this->certificateType][(string)$cert->refid] = (string)$cert->descr;
} }
} }
} }
......
...@@ -51,13 +51,13 @@ class IntegerField extends BaseField ...@@ -51,13 +51,13 @@ class IntegerField extends BaseField
* maximum value for this field * maximum value for this field
* @var integer * @var integer
*/ */
private $maximum_value ; private $maximum_value;
/** /**
* minimum value for this field * minimum value for this field
* @var integer * @var integer
*/ */
private $minimum_value ; private $minimum_value;
/** /**
* constructor, set absolute min and max values * constructor, set absolute min and max values
...@@ -68,7 +68,7 @@ class IntegerField extends BaseField ...@@ -68,7 +68,7 @@ class IntegerField extends BaseField
{ {
parent:: __construct($ref, $tagname); parent:: __construct($ref, $tagname);
$this->minimum_value = PHP_INT_MAX*-1; $this->minimum_value = PHP_INT_MAX*-1;
$this->maximum_value = PHP_INT_MAX ; $this->maximum_value = PHP_INT_MAX;
} }
/** /**
......
...@@ -79,9 +79,9 @@ class OptionField extends BaseField ...@@ -79,9 +79,9 @@ class OptionField extends BaseField
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if (!is_array($value)) { if (!is_array($value)) {
if ($key == "__empty__") { if ($key == "__empty__") {
$this->internalOptionList[""] = $value ; $this->internalOptionList[""] = $value;
} else { } else {
$this->internalOptionList[$key] = $value ; $this->internalOptionList[$key] = $value;
} }
} }
} }
......
...@@ -130,7 +130,7 @@ class PortField extends BaseField ...@@ -130,7 +130,7 @@ class PortField extends BaseField
$validators = parent::getValidators(); $validators = parent::getValidators();
if ($this->internalValidationMessage == null) { if ($this->internalValidationMessage == null) {
$msg = "please specify a valid portnumber (1-65535) or name (" . implode(",", self::$wellknownservices) . $msg = "please specify a valid portnumber (1-65535) or name (" . implode(",", self::$wellknownservices) .
")" ; ")";
} else { } else {
$msg = $this->internalValidationMessage; $msg = $this->internalValidationMessage;
} }
......
...@@ -58,7 +58,7 @@ class TextField extends BaseField ...@@ -58,7 +58,7 @@ class TextField extends BaseField
*/ */
public function setMask($value) public function setMask($value)
{ {
$this->internalMask = $value ; $this->internalMask = $value;
} }
/** /**
......
...@@ -88,7 +88,7 @@ class MenuItem ...@@ -88,7 +88,7 @@ class MenuItem
* parent node, used to mark active nodes * parent node, used to mark active nodes
* @var null|MenuItem * @var null|MenuItem
*/ */
private $parent = null ; private $parent = null;
/** /**
* is this node or any of the child nodes selected * is this node or any of the child nodes selected
...@@ -131,7 +131,7 @@ class MenuItem ...@@ -131,7 +131,7 @@ class MenuItem
*/ */
public function getId() public function getId()
{ {
return $this->id ; return $this->id;
} }
...@@ -186,7 +186,7 @@ class MenuItem ...@@ -186,7 +186,7 @@ class MenuItem
*/ */
public function setCssClass($value) public function setCssClass($value)
{ {
$this->CssClass = $value ; $this->CssClass = $value;
} }
/** /**
...@@ -265,7 +265,7 @@ class MenuItem ...@@ -265,7 +265,7 @@ class MenuItem
$isNew = false; $isNew = false;
foreach ($this->children as $nodeKey => $node) { foreach ($this->children as $nodeKey => $node) {
if ($node->getId() == $id) { if ($node->getId() == $id) {
$newMenuItem = $node ; $newMenuItem = $node;
} }
} }
if ($newMenuItem == null) { if ($newMenuItem == null) {
...@@ -327,7 +327,7 @@ class MenuItem ...@@ -327,7 +327,7 @@ class MenuItem
*/ */
public function select() public function select()
{ {
$this->selected = true ; $this->selected = true;
if ($this->parent != null) { if ($this->parent != null) {
$this->parent->select(); $this->parent->select();
} }
...@@ -339,7 +339,7 @@ class MenuItem ...@@ -339,7 +339,7 @@ class MenuItem
*/ */
public function toggleSelected($url) public function toggleSelected($url)
{ {
$this->selected = false ; $this->selected = false;
foreach ($this->getFilteredChildren() as $nodeId => $node) { foreach ($this->getFilteredChildren() as $nodeId => $node) {
$node->toggleSelected($url); $node->toggleSelected($url);
if ($node->getUrl() != "") { if ($node->getUrl() != "") {
...@@ -405,7 +405,7 @@ class MenuItem ...@@ -405,7 +405,7 @@ class MenuItem
{ {
foreach ($this->getFilteredChildren() as $key => $node) { foreach ($this->getFilteredChildren() as $key => $node) {
if (strtolower($node->getId()) == strtolower($id)) { if (strtolower($node->getId()) == strtolower($id)) {
return $node ; return $node;
} }
} }
return null; return null;
......
...@@ -40,7 +40,7 @@ class MenuSystem ...@@ -40,7 +40,7 @@ class MenuSystem
/** /**
* @var null|MenuItem root node * @var null|MenuItem root node
*/ */
private $root = null ; private $root = null;
/** /**
* add menu structure to root * add menu structure to root
...@@ -51,14 +51,14 @@ class MenuSystem ...@@ -51,14 +51,14 @@ class MenuSystem
{ {
// load and validate menu xml // load and validate menu xml
if (!file_exists($filename)) { if (!file_exists($filename)) {
throw new MenuInitException('Menu xml '.$filename.' missing') ; throw new MenuInitException('Menu xml '.$filename.' missing');
} }
$menuXml = simplexml_load_file($filename); $menuXml = simplexml_load_file($filename);
if ($menuXml === false) { if ($menuXml === false) {
throw new MenuInitException('Menu xml '.$filename.' not valid') ; throw new MenuInitException('Menu xml '.$filename.' not valid');
} }
if ($menuXml->getName() != "menu") { if ($menuXml->getName() != "menu") {
throw new MenuInitException('Menu xml '.$filename.' seems to be of wrong type') ; throw new MenuInitException('Menu xml '.$filename.' seems to be of wrong type');
} }
// traverse items // traverse items
......
...@@ -100,10 +100,10 @@ class ACL ...@@ -100,10 +100,10 @@ class ACL
// load ACL xml file and perform some basic validation // load ACL xml file and perform some basic validation
$ACLxml = simplexml_load_file($acl_cfg_xml); $ACLxml = simplexml_load_file($acl_cfg_xml);
if ($ACLxml === false) { if ($ACLxml === false) {
throw new \Exception('ACL xml '.$acl_cfg_xml.' not valid') ; throw new \Exception('ACL xml '.$acl_cfg_xml.' not valid');
} }
if ($ACLxml->getName() != "acl") { if ($ACLxml->getName() != "acl") {
throw new \Exception('ACL xml '.$acl_cfg_xml.' seems to be of wrong type') ; throw new \Exception('ACL xml '.$acl_cfg_xml.' seems to be of wrong type');
} }
// when acl was correctly loaded, let's parse data into private $this->ACLtags // when acl was correctly loaded, let's parse data into private $this->ACLtags
...@@ -151,11 +151,11 @@ class ACL ...@@ -151,11 +151,11 @@ class ACL
$groupmap = array(); $groupmap = array();
// gather user / group data from config.xml // gather user / group data from config.xml
$config = Config::getInstance()->object() ; $config = Config::getInstance()->object();
if ($config->system != null) { if ($config->system != null) {
foreach ($config->system->children() as $key => $node) { foreach ($config->system->children() as $key => $node) {
if ($key == 'user') { if ($key == 'user') {
$this->legacyUsers[$node->name->__toString()] = array() ; $this->legacyUsers[$node->name->__toString()] = array();
$this->legacyUsers[$node->name->__toString()]['uid'] = $node->uid->__toString(); $this->legacyUsers[$node->name->__toString()]['uid'] = $node->uid->__toString();
$this->legacyUsers[$node->name->__toString()]['groups'] = array(); $this->legacyUsers[$node->name->__toString()]['groups'] = array();
$this->legacyUsers[$node->name->__toString()]['priv'] = array(); $this->legacyUsers[$node->name->__toString()]['priv'] = array();
...@@ -168,7 +168,7 @@ class ACL ...@@ -168,7 +168,7 @@ class ACL
} }
} }
} elseif ($key == 'group') { } elseif ($key == 'group') {
$groupmap[$node->name->__toString()] = $node ; $groupmap[$node->name->__toString()] = $node;
} }
} }
} }
...@@ -278,7 +278,7 @@ class ACL ...@@ -278,7 +278,7 @@ class ACL
// sort by name ( case insensitive ) // sort by name ( case insensitive )
uasort($priv_list, function ($a, $b) { uasort($priv_list, function ($a, $b) {
return strcasecmp($a["name"], $b["name"]) ; return strcasecmp($a["name"], $b["name"]);
}); });
return $priv_list; return $priv_list;
......
...@@ -54,7 +54,7 @@ class Cron extends BaseModel ...@@ -54,7 +54,7 @@ class Cron extends BaseModel
$cron->origin = $origin; $cron->origin = $origin;
$cron->command = $command; $cron->command = $command;
$cron->description = $description; $cron->description = $description;
$cron->weekdays = $weekdays ; $cron->weekdays = $weekdays;
$cron->enabled = $enabled; $cron->enabled = $enabled;
return $uuid; return $uuid;
} }
......
...@@ -161,7 +161,7 @@ class IDS extends BaseModel ...@@ -161,7 +161,7 @@ class IDS extends BaseModel
} }
} elseif (!$response_plain) { } elseif (!$response_plain) {
// generate selection for new field // generate selection for new field
$default_types = $this->action_list ; $default_types = $this->action_list;
if (array_key_exists($default, $default_types)) { if (array_key_exists($default, $default_types)) {
foreach ($default_types as $key => $value) { foreach ($default_types as $key => $value) {
if ($key == $default) { if ($key == $default) {
...@@ -199,6 +199,6 @@ class IDS extends BaseModel ...@@ -199,6 +199,6 @@ class IDS extends BaseModel
$node = $this->files->file->Add(); $node = $this->files->file->Add();
$node->filename = $filename; $node->filename = $filename;
return $node ; return $node;
} }
} }
...@@ -39,7 +39,7 @@ $executed_migration = false; ...@@ -39,7 +39,7 @@ $executed_migration = false;
$model_dir = dirname($class_info->getFileName())."/../../"; $model_dir = dirname($class_info->getFileName())."/../../";
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir)) as $x) { foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir)) as $x) {
if (strtolower(substr($x->getPathname(), -4)) == '.php') { if (strtolower(substr($x->getPathname(), -4)) == '.php') {
$classname = str_replace('/', '\\', explode('.', str_replace($model_dir, '', $x->getPathname()))[0]) ; $classname = str_replace('/', '\\', explode('.', str_replace($model_dir, '', $x->getPathname()))[0]);
try { try {
$mdl_class_info = new \ReflectionClass($classname); $mdl_class_info = new \ReflectionClass($classname);
$parent = $mdl_class_info->getParentClass(); $parent = $mdl_class_info->getParentClass();
...@@ -52,7 +52,7 @@ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir ...@@ -52,7 +52,7 @@ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir
$version_pre = !empty($version_pre) ? $version_pre : ' <unversioned> '; $version_pre = !empty($version_pre) ? $version_pre : ' <unversioned> ';
echo "migrated " . $mdl_class_info->getName() . echo "migrated " . $mdl_class_info->getName() .
" from " . $version_pre . " from " . $version_pre .
" to " . $version_post . "\n" ; " to " . $version_post . "\n";
$executed_migration = true; $executed_migration = true;
} elseif (!empty($version_post)) { } elseif (!empty($version_post)) {
echo "keep version " . $mdl_class_info->getName() . " (".$version_post.")\n"; echo "keep version " . $mdl_class_info->getName() . " (".$version_post.")\n";
......
...@@ -244,7 +244,7 @@ class BaseModelTest extends \PHPUnit_Framework_TestCase ...@@ -244,7 +244,7 @@ class BaseModelTest extends \PHPUnit_Framework_TestCase
{ {
$count = 2; $count = 2;
foreach (BaseModelTest::$model->arraytypes->item->__items as $nodeid => $node) { foreach (BaseModelTest::$model->arraytypes->item->__items as $nodeid => $node) {
$count-- ; $count--;
if ($count >= 0) { if ($count >= 0) {
$node->number = 999; $node->number = 999;
} }
...@@ -259,7 +259,7 @@ class BaseModelTest extends \PHPUnit_Framework_TestCase ...@@ -259,7 +259,7 @@ class BaseModelTest extends \PHPUnit_Framework_TestCase
{ {
$count = 1; $count = 1;
foreach (BaseModelTest::$model->arraytypes->item->__items as $nodeid => $node) { foreach (BaseModelTest::$model->arraytypes->item->__items as $nodeid => $node) {
$count++ ; $count++;
$node->number = $count; $node->number = $count;
} }
BaseModelTest::$model->serializeToConfig(); BaseModelTest::$model->serializeToConfig();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment