Skip to content

Commit

Permalink
[PFBC]Use "strict" comparison in in_array() third arg
Browse files Browse the repository at this point in the history
  • Loading branch information
pH-7 committed May 9, 2019
1 parent 2a0382d commit ff7dfbc
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 41 deletions.
2 changes: 1 addition & 1 deletion _protected/framework/Layout/Form/Engine/PFBC/Base.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Many changes have been made in this file.
* By pH7 (Pierre-Henry SORIA).
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function jQueryDocumentReady()
{
/*Unless explicitly prevented, jQueryUI's button widget functionality is applied to
the each Button element.*/
if (!in_array('jQueryUIButtons', $this->form->getPrevent())) {
if (!in_array('jQueryUIButtons', $this->form->getPrevent(), true)) {
echo 'jQuery("#', $this->attributes['id'], '").button(';
/*Any of the jQueryUI framework icons can be added to your buttons via the icon
property. See http://jqueryui.com/themeroller/ for a complete list of available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function render()
foreach ($this->options as $value => $text) {
$value = $this->getOptionValue($value);
echo '<div class="pfbc-checkbox"><table cellpadding="0" cellspacing="0"><tr><td style="vertical-align:top"><input id="', $this->attributes["id"], "-", $count, '"', $this->getAttributes(['id', 'value', 'checked']), ' value="', $this->filter($value), '"';
if (in_array($value, $this->attributes['value'])) {
if (in_array($value, $this->attributes['value'], true)) {
echo ' checked="checked"';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function render()
foreach ($this->options as $value => $text) {
$value = $this->getOptionValue($value);
echo '<div class="pfbc-checkbox"><table cellpadding="0" cellspacing="0"><tr><td style="vertical-align:top"><input id="', $this->attributes['id'], "-", $count, '"', $this->getAttributes(["id", "value", "checked", "name", "onclick"]), ' value="', $this->filter($value), '"';
if (in_array($value, $this->attributes['value'])) {
if (in_array($value, $this->attributes['value'], true)) {
echo ' checked="checked"';
}

echo ' onclick="updateChecksort(this, \'', $this->filter($text), '\');"/></td><td><label for="', $this->attributes['id'], "-", $count, '">', $text, '</label></td></tr></table></div>';

if (in_array($value, $this->attributes['value'])) {
if (in_array($value, $this->attributes['value'], true)) {
$existing .= '<li id="' . $this->attributes['id'] . "-sort-" . $count . '" class="ui-state-default"><input type="hidden" name="' . $this->attributes['name'] . '" value="' . $value . '"/>' . $text . '</li>';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function render()
$value = $this->getOptionValue($value);
echo '<option value="', $this->filter($value), '"';
$selected = false;
if (in_array($value, $this->attributes['value'])) {
if (in_array($value, $this->attributes['value'], true)) {
echo ' selected="selected"';
}
echo '>', $text, '</option>';
Expand Down
3 changes: 2 additions & 1 deletion _protected/framework/Layout/Form/Engine/PFBC/Form.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* This file has been modified by pH7 developers team (Pierre-Henry SORIA).
* Many changes have been made in this file.
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Many changes have been made in this file.
* By Pierre-Henry SORIA.
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
/**
* We made this code.
* By pH7.
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC\View;
Expand All @@ -15,7 +14,7 @@ public function render()
$this->form->getError()->render();

$elements = $this->form->getElements();
$elementSize = sizeof($elements);
$elementSize = count($elements);
$elementCount = 0;

for ($e = 0; $e < $elementSize; ++$e) {
Expand Down
39 changes: 21 additions & 18 deletions _protected/framework/Layout/Form/Engine/PFBC/View/Grid.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
/**
* Changes made in this code from original PFBC's version.
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC\View;

Expand All @@ -11,10 +15,11 @@ class Grid extends \PFBC\View

public function __construct(array $grid, array $properties = null)
{
if (!empty($properties))
$properties["grid"] = $grid;
else
$properties = ["grid" => $grid];
if (!empty($properties)) {
$properties['grid'] = $grid;
} else {
$properties = ['grid' => $grid];
}

parent::__construct($properties);
}
Expand Down Expand Up @@ -66,8 +71,9 @@ public function render()
if (!empty($this->grid[$gridIndex])) {
if ($gridCount == 0)
echo '<div class="pfbc-grid pfbc-grid-' . $this->grid[$gridIndex] . '">';
} else
} else {
echo '<div class="pfbc-grid pfbc-grid-1">';
}

echo '<div id="pfbc-element-', $gridElementCount, '" class="pfbc-element">';
$this->renderLabel($element);
Expand All @@ -83,8 +89,10 @@ public function render()
++$gridIndex;
} else
++$gridCount;
} else
} else {
echo '</div>';
}

echo $element->getPostHTML();
++$gridElementCount;
}
Expand Down Expand Up @@ -126,25 +134,21 @@ public function renderCSS()
$gridRevised = [];
foreach ($this->grid as $grid) {
$gridRemaining = $this->gridIncludedElements - array_sum($gridRevised);
if (!empty($gridRemaining))
if ($gridRemaining >= $grid)
$gridRevised[] = $grid;
else
$gridRevised[] = $gridRemaining;
else
if (!empty($gridRemaining)) {
$gridRevised[] = ($gridRemaining >= $grid) ? $grid : $gridRemaining;
} else {
break;
}
}
$this->grid = $gridRevised;
}

$gridSize = sizeof($this->grid);
$gridSize = count($this->grid);
$elementWidths = [];

for ($g = 0; $g < $gridSize; ++$g) {
$gridSum = array_sum(array_slice($this->grid, 0, $g));
if ($widthSuffix == "px")
$gridRemainingWidth = $width;
else
$gridRemainingWidth = 100;
$gridRemainingWidth = $widthSuffix === 'px' ? $width : 100;
$gridRemainingElements = $this->grid[$g];
for ($e = $gridSum; $e < ($gridSum + $this->grid[$g]); ++$e) {
$elementWidths[$e] = $gridElements[$e]->getWidth();
Expand All @@ -167,5 +171,4 @@ public function renderCSS()
}
}
}

}
15 changes: 11 additions & 4 deletions _protected/framework/Layout/Form/Engine/PFBC/View/Horizontal.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
/**
* Changes made in this code from original PFBC's version.
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC\View;

Expand Down Expand Up @@ -47,12 +51,15 @@ public function renderCSS()
#$id .pfbc-label { float: left; margin-right: .25em; }
CSS;

if (empty($this->labelPaddingTop) && !in_array("style", $this->form->getPrevent()))
$this->labelPaddingTop = ".75em";
if (empty($this->labelPaddingTop) && !in_array('style', $this->form->getPrevent(), true)) {
$this->labelPaddingTop = '.75em';
}

if (!empty($this->labelPaddingTop)) {
if (is_numeric($this->labelPaddingTop))
$this->labelPaddingTop .= "px";
if (is_numeric($this->labelPaddingTop)) {
$this->labelPaddingTop .= 'px';
}

echo '#', $id, ' .pfbc-label { padding-top: ', $this->labelPaddingTop, '; }';
}
}
Expand Down
22 changes: 14 additions & 8 deletions _protected/framework/Layout/Form/Engine/PFBC/View/SideBySide.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
/**
* Changes made in this code from original PFBC's version.
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC\View;

Expand All @@ -12,9 +16,9 @@ class SideBySide extends \PFBC\View
public function __construct($labelWidth, array $properties = null)
{
if (!empty($properties)) {
$properties["labelWidth"] = $labelWidth;
$properties['labelWidth'] = $labelWidth;
} else {
$properties = ["labelWidth" => $labelWidth];
$properties = ['labelWidth' => $labelWidth];
}

parent::__construct($properties);
Expand Down Expand Up @@ -58,10 +62,11 @@ public function renderCSS()
$width = $this->form->getWidth();
$widthSuffix = $this->form->getWidthSuffix();

if ($widthSuffix == "px")
if ($widthSuffix === 'px') {
$elementWidth = $width - $this->labelWidth - $this->labelPaddingRight;
else
} else {
$elementWidth = 100 - $this->labelWidth - $this->labelPaddingRight;
}

\PFBC\View::renderCSS();
echo <<<CSS
Expand All @@ -76,12 +81,13 @@ public function renderCSS()
if (!empty($this->labelRightAlign))
echo '#', $id, ' .pfbc-label { text-align: right; }';

if (empty($this->labelPaddingTop) && !in_array("style", $this->form->getPrevent()))
$this->labelPaddingTop = ".75em";
if (empty($this->labelPaddingTop) && !in_array('style', $this->form->getPrevent(), true)) {
$this->labelPaddingTop = '.75em';
}

if (!empty($this->labelPaddingTop)) {
if (is_numeric($this->labelPaddingTop))
$this->labelPaddingTop .= "px";
$this->labelPaddingTop .= 'px';
echo '#', $id, ' .pfbc-label { padding-top: ', $this->labelPaddingTop, '; }';
}

Expand All @@ -94,7 +100,7 @@ public function renderCSS()
if (!$element instanceof \PFBC\Element\Hidden && !$element instanceof \PFBC\Element\HTMLExternal && !$element instanceof \PFBC\Element\HTMLExternal) {
if (!empty($elementWidth)) {
echo '#', $id, ' #pfbc-element-', $elementCount, ' { width: ', $elementWidth, $widthSuffix, '; }';
if ($widthSuffix == "px") {
if ($widthSuffix === 'px') {
$elementWidth = $elementWidth - $this->labelWidth - $this->labelPaddingRight;
echo '#', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textbox, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-textarea, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-select, #', $id, ' #pfbc-element-', $elementCount, ' .pfbc-right { width: ', $elementWidth, $widthSuffix, '; }';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php
/**
* Changes made in this code from original PFBC's version.
* By Pierre-Henry Soria <https://ph7.me>
*/

namespace PFBC\View;

Expand Down

0 comments on commit ff7dfbc

Please sign in to comment.