| @@ -35,20 +35,20 @@ | ||
| 35 | 35 |      { | 
| 36 | 36 | if(isset($this->labeleduri)) | 
| 37 | 37 |          { | 
| 38 | - //Have multiple emails | |
| 39 | - if($propName === 'mail') | |
| 40 | -             { | |
| 41 | -                 return $this->getFieldSingleValue('labeleduri'); | |
| 42 | - } | |
| 43 | - if($propName === 'allMail') | |
| 44 | -             { | |
| 45 | -                 $tmp = $this->getField('mail'); | |
| 46 | - if(isset($tmp['count'])) | |
| 47 | -                 { | |
| 48 | - unset($tmp['count']); | |
| 49 | - } | |
| 50 | - return $tmp; | |
| 51 | - } | |
| 38 | + //Have multiple emails | |
| 39 | + if($propName === 'mail') | |
| 40 | +                { | |
| 41 | +                    return $this->getFieldSingleValue('labeleduri'); | |
| 42 | + } | |
| 43 | + if($propName === 'allMail') | |
| 44 | +                { | |
| 45 | +                    $tmp = $this->getField('mail'); | |
| 46 | + if(isset($tmp['count'])) | |
| 47 | +                    { | |
| 48 | + unset($tmp['count']); | |
| 49 | + } | |
| 50 | + return $tmp; | |
| 51 | + } | |
| 52 | 52 | } | 
| 53 | 53 | $tmp = $this->getValueWithDefault($propName); | 
| 54 | 54 | if($tmp !== false) | 
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | public function getDataSetData($dataSetName) | 
| 73 | 73 |      { | 
| 74 | 74 | if(!isset(\FlipsideSettings::$dataset) || !isset(\FlipsideSettings::$dataset[$dataSetName])) | 
| 75 | -	{ | |
| 75 | +    { | |
| 76 | 76 | return false; | 
| 77 | 77 | } | 
| 78 | 78 | return \FlipsideSettings::$dataset[$dataSetName]; | 
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | public function getDataSetData($dataSetName) | 
| 73 | 73 |      { | 
| 74 | 74 | if(!isset(\FlipsideSettings::$dataset) || !isset(\FlipsideSettings::$dataset[$dataSetName])) | 
| 75 | -	{ | |
| 75 | +        { | |
| 76 | 76 | return false; | 
| 77 | 77 | } | 
| 78 | 78 | return \FlipsideSettings::$dataset[$dataSetName]; | 
| @@ -27,9 +27,11 @@ | ||
| 27 | 27 |      { | 
| 28 | 28 | // build a replacement array with braces around the context keys | 
| 29 | 29 | $replace = array(); | 
| 30 | -        foreach ($context as $key => $val) { | |
| 30 | + foreach ($context as $key => $val) | |
| 31 | +        { | |
| 31 | 32 | // check that the value can be casted to string | 
| 32 | -            if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { | |
| 33 | + if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) | |
| 34 | +            { | |
| 33 | 35 |                  $replace['{' . $key . '}'] = $val; | 
| 34 | 36 | } | 
| 35 | 37 | } | 
| @@ -48,7 +48,7 @@ | ||
| 48 | 48 | $objCount = count($res); | 
| 49 | 49 | for($i = 0; $i < $objCount; $i++) | 
| 50 | 50 |          { | 
| 51 | - $res[$i] = new $this->className($res[$i]); | |
| 51 | + $res[$i] = new $this->className($res[$i]); | |
| 52 | 52 | } | 
| 53 | 53 | return $res; | 
| 54 | 54 | } | 
| @@ -9,33 +9,33 @@ | ||
| 9 | 9 | public function __construct($file) | 
| 10 | 10 |      { | 
| 11 | 11 |          $this->data = array_map('str_getcsv', file($file)); | 
| 12 | - $titles = array_shift($this->data); | |
| 13 | - $count = count($this->data); | |
| 14 | - for($i = 0; $i < $count; $i++) | |
| 15 | -	{ | |
| 12 | + $titles = array_shift($this->data); | |
| 13 | + $count = count($this->data); | |
| 14 | + for($i = 0; $i < $count; $i++) | |
| 15 | +    { | |
| 16 | 16 | $this->data[$i] = array_combine($titles, $this->data[$i]); | 
| 17 | - } | |
| 17 | + } | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 | public function count($filter = false) | 
| 21 | 21 |      { | 
| 22 | 22 | if($filter) | 
| 23 | -	{ | |
| 23 | +    { | |
| 24 | 24 | $res = $this->data; | 
| 25 | - $res = $filter->filter_array($res); | |
| 26 | - return count($res); | |
| 27 | - } | |
| 28 | - return count($this->data); | |
| 25 | + $res = $filter->filter_array($res); | |
| 26 | + return count($res); | |
| 27 | + } | |
| 28 | + return count($this->data); | |
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | 31 | public function read($filter = false, $select = false, $count = false, $skip = false, $sort = false, $params = false) | 
| 32 | 32 |      { | 
| 33 | 33 | $res = $this->data; | 
| 34 | - if($filter !== false) | |
| 35 | -	{ | |
| 34 | + if($filter !== false) | |
| 35 | +    { | |
| 36 | 36 | $res = $filter->filter_array($res); | 
| 37 | - } | |
| 38 | - return $res; | |
| 37 | + } | |
| 38 | + return $res; | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | public function create($data) | 
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | public function count($filter = false) | 
| 21 | 21 |      { | 
| 22 | 22 | if($filter) | 
| 23 | -	{ | |
| 23 | +        { | |
| 24 | 24 | $res = $this->data; | 
| 25 | 25 | $res = $filter->filter_array($res); | 
| 26 | 26 | return count($res); | 
| @@ -248,7 +248,7 @@ | ||
| 248 | 248 | if($stmt === false) | 
| 249 | 249 |          { | 
| 250 | 250 |              if (php_sapi_name() !== "cli") { | 
| 251 | -              error_log('DB query failed. '.print_r($this->pdo->errorInfo(), true)); | |
| 251 | +                error_log('DB query failed. '.print_r($this->pdo->errorInfo(), true)); | |
| 252 | 252 | } | 
| 253 | 253 | return false; | 
| 254 | 254 | } | 
| @@ -247,7 +247,8 @@ discard block | ||
| 247 | 247 | $stmt = $this->pdo->query($sql); | 
| 248 | 248 | if($stmt === false) | 
| 249 | 249 |          { | 
| 250 | -            if (php_sapi_name() !== "cli") { | |
| 250 | + if (php_sapi_name() !== "cli") | |
| 251 | +            { | |
| 251 | 252 |                error_log('DB query failed. '.print_r($this->pdo->errorInfo(), true)); | 
| 252 | 253 | } | 
| 253 | 254 | return false; | 
| @@ -296,7 +297,8 @@ discard block | ||
| 296 | 297 | $sql = "INSERT INTO $tablename ($cols) VALUES ($set);"; | 
| 297 | 298 | if($this->pdo->exec($sql) === false) | 
| 298 | 299 |          { | 
| 299 | -            if (php_sapi_name() !== "cli") { | |
| 300 | + if (php_sapi_name() !== "cli") | |
| 301 | +            { | |
| 300 | 302 |                  error_log('DB query failed. '.print_r($this->pdo->errorInfo(), true)); | 
| 301 | 303 | } | 
| 302 | 304 | return false; | 
| @@ -140,9 +140,9 @@ | ||
| 140 | 140 | $case = true; | 
| 141 | 141 | } | 
| 142 | 142 | if($case) | 
| 143 | -	{ | |
| 143 | +        { | |
| 144 | 144 |              if(class_exists('MongoRegex')) | 
| 145 | -	    { | |
| 145 | +            { | |
| 146 | 146 |                  return array($field=>array('$regex'=>new \MongoRegex('/'.$this->var2.'/i'))); | 
| 147 | 147 | } | 
| 148 | 148 | else | 
| @@ -140,9 +140,9 @@ discard block | ||
| 140 | 140 | $case = true; | 
| 141 | 141 | } | 
| 142 | 142 | if($case) | 
| 143 | -	{ | |
| 143 | +    { | |
| 144 | 144 |              if(class_exists('MongoRegex')) | 
| 145 | -	    { | |
| 145 | +        { | |
| 146 | 146 |                  return array($field=>array('$regex'=>new \MongoRegex('/'.$this->var2.'/i'))); | 
| 147 | 147 | } | 
| 148 | 148 | else | 
| @@ -236,15 +236,15 @@ discard block | ||
| 236 | 236 |          { | 
| 237 | 237 | case '=': | 
| 238 | 238 | return array($this->var1=>$this->var2); | 
| 239 | - case 'substringof': | |
| 240 | -		if(class_exists('MongoRegex')) | |
| 241 | -		{ | |
| 242 | -		    return array($this->var1=>array('$regex'=>new \MongoRegex('/'.$this->var2.'/i'))); | |
| 243 | - } | |
| 244 | - else | |
| 245 | -		{ | |
| 239 | + case 'substringof': | |
| 240 | +        if(class_exists('MongoRegex')) | |
| 241 | +        { | |
| 242 | +            return array($this->var1=>array('$regex'=>new \MongoRegex('/'.$this->var2.'/i'))); | |
| 243 | + } | |
| 244 | + else | |
| 245 | +        { | |
| 246 | 246 |                      return array($this->var1=>array('$regex'=>new \MongoDB\BSON\Regex($this->var2, 'i'))); | 
| 247 | - } | |
| 247 | + } | |
| 248 | 248 | case 'indexof': | 
| 249 | 249 | return $this->getMongoIndexOfOperator(); | 
| 250 | 250 | default: | 
| @@ -141,9 +141,12 @@ | ||
| 141 | 141 |      { | 
| 142 | 142 | $namespace = $this->db_name.'.'.$collectionName; | 
| 143 | 143 | $dbWrite = new \MongoDB\Driver\BulkWrite(); | 
| 144 | -        try { | |
| 144 | + try | |
| 145 | +        { | |
| 145 | 146 | $dbWrite->update($criteria, $new_object, $options); | 
| 146 | -        } catch(\MongoDB\Driver\Exception\InvalidArgumentException $e) { | |
| 147 | + } | |
| 148 | + catch(\MongoDB\Driver\Exception\InvalidArgumentException $e) | |
| 149 | +        { | |
| 147 | 150 | if(isset($new_object['$set'][''])) | 
| 148 | 151 |              { | 
| 149 | 152 | unset($new_object['$set']['']); | 
| @@ -142,47 +142,47 @@ | ||
| 142 | 142 |      { | 
| 143 | 143 | $res = array(); | 
| 144 | 144 | $count = count($this->children); | 
| 145 | - for($i = 0; $i < $count; $i++) | |
| 146 | -	{ | |
| 145 | + for($i = 0; $i < $count; $i++) | |
| 146 | +    { | |
| 147 | 147 | if($this->children[$i] === 'and' || $this->children[$i] === 'or') | 
| 148 | -	    { | |
| 148 | +        { | |
| 149 | 149 | array_push($res, $this->children[$i]); | 
| 150 | - } | |
| 151 | - else | |
| 152 | -	    { | |
| 150 | + } | |
| 151 | + else | |
| 152 | +        { | |
| 153 | 153 | $tmp = $this->children[$i]->php_compare($element); | 
| 154 | - array_push($res, $tmp); | |
| 155 | - } | |
| 156 | - } | |
| 157 | - if($count === 1) | |
| 158 | -	{ | |
| 154 | + array_push($res, $tmp); | |
| 155 | + } | |
| 156 | + } | |
| 157 | + if($count === 1) | |
| 158 | +    { | |
| 159 | 159 | return $res[0]; | 
| 160 | - } | |
| 161 | - while($count >= 3) | |
| 162 | -	{ | |
| 163 | - if($res[1] === 'and') | |
| 160 | + } | |
| 161 | + while($count >= 3) | |
| 162 | +    { | |
| 163 | + if($res[1] === 'and') | |
| 164 | 164 |              { | 
| 165 | 165 | $var1 = array_shift($res); | 
| 166 | 166 | array_shift($res); | 
| 167 | 167 | $var2 = array_shift($res); | 
| 168 | - $res = array_merge(array($var1 && $var2), $res); | |
| 168 | + $res = array_merge(array($var1 && $var2), $res); | |
| 169 | 169 | } | 
| 170 | - else if($res[1] === 'or') | |
| 170 | + else if($res[1] === 'or') | |
| 171 | 171 |              { | 
| 172 | 172 | $var1 = array_shift($res); | 
| 173 | 173 | array_shift($res); | 
| 174 | 174 | $var2 = array_shift($res); | 
| 175 | 175 | $res = array_merge(array($var1 || $var2), $res); | 
| 176 | - } | |
| 177 | - $count = count($res); | |
| 178 | - } | |
| 176 | + } | |
| 177 | + $count = count($res); | |
| 178 | + } | |
| 179 | 179 | return $res[0]; | 
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | 182 | public function filter_array(&$array) | 
| 183 | 183 |      { | 
| 184 | 184 | if(is_array($array)) | 
| 185 | -	{ | |
| 185 | +    { | |
| 186 | 186 | $res = array_filter($array, array($this, 'filterElement')); | 
| 187 | 187 | return array_values($res); | 
| 188 | 188 | } | 
| @@ -145,7 +145,7 @@ discard block | ||
| 145 | 145 | for($i = 0; $i < $count; $i++) | 
| 146 | 146 |  	{ | 
| 147 | 147 | if($this->children[$i] === 'and' || $this->children[$i] === 'or') | 
| 148 | -	    { | |
| 148 | +            { | |
| 149 | 149 | array_push($res, $this->children[$i]); | 
| 150 | 150 | } | 
| 151 | 151 | else | 
| @@ -161,14 +161,14 @@ discard block | ||
| 161 | 161 | while($count >= 3) | 
| 162 | 162 |  	{ | 
| 163 | 163 | if($res[1] === 'and') | 
| 164 | -            { | |
| 164 | +	    { | |
| 165 | 165 | $var1 = array_shift($res); | 
| 166 | 166 | array_shift($res); | 
| 167 | 167 | $var2 = array_shift($res); | 
| 168 | 168 | $res = array_merge(array($var1 && $var2), $res); | 
| 169 | 169 | } | 
| 170 | - else if($res[1] === 'or') | |
| 171 | -            { | |
| 170 | + else if($res[1] === 'or') | |
| 171 | +	    { | |
| 172 | 172 | $var1 = array_shift($res); | 
| 173 | 173 | array_shift($res); | 
| 174 | 174 | $var2 = array_shift($res); | 
| @@ -182,7 +182,7 @@ discard block | ||
| 182 | 182 | public function filter_array(&$array) | 
| 183 | 183 |      { | 
| 184 | 184 | if(is_array($array)) | 
| 185 | -	{ | |
| 185 | +        { | |
| 186 | 186 | $res = array_filter($array, array($this, 'filterElement')); | 
| 187 | 187 | return array_values($res); | 
| 188 | 188 | } |