diff --git a/.gitignore b/.gitignore index cf074ca..b1816fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.idea/ /app/config/config.ini -vendor \ No newline at end of file +public/content +vendor diff --git a/app/controllers/Admin/BannersController.php b/app/controllers/Admin/BannersController.php index 91ddabf..7956e1d 100644 --- a/app/controllers/Admin/BannersController.php +++ b/app/controllers/Admin/BannersController.php @@ -12,6 +12,9 @@ use App\Models\Views; use App\Models\Zones; +if(phpversion() < 5.5) + require '../vendor/ramsey/array_column/src/array_column.php'; + class BannersController extends ControllerBase { public function indexAction() { if($this->request->getQuery('zone')) { @@ -30,7 +33,8 @@ public function addAction() { $this->assets->collection('bottom-js') ->addJs('js/moment/moment.min.js') ->addJs('js/moment/ru.js') - ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js'); + ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js') + ->addJs('js/banners_edit_sizes.js'); $this->assets->collection('css') ->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css'); $banner = new Banners(); @@ -126,7 +130,8 @@ public function editAction() { $this->assets->collection('bottom-js') ->addJs('js/moment/moment.min.js') ->addJs('js/moment/ru.js') - ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js'); + ->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js') + ->addJs('js/banners_edit_sizes.js'); $this->assets->collection('css') ->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css'); $id = $this->dispatcher->getParam('id'); @@ -213,7 +218,7 @@ public function editAction() { } } - $this->view->checked_zones = $this->request->getPost('zones') ? $this->request->getPost('zones') : array_column($banner->getZones(array('columns'=>array('id')))->toArray(), 'id'); + $this->view->checked_zones = $this->request->getPost('zones') ? $this->request->getPost('zones') : \array_column($banner->getZones(array('columns'=>array('id')))->toArray(), 'id'); $this->view->banner = $banner; $this->view->pick("banners/edit"); $this->view->title = "Редактирование баннера"; diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..dd94045 --- /dev/null +++ b/composer.lock @@ -0,0 +1,63 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "2e8c4faeebdfb72ac301be93b2b9314b", + "packages": [ + { + "name": "ramsey/array_column", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/ramsey/array_column.git", + "reference": "f8e52eb28e67eb50e613b451dd916abcf783c1db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ramsey/array_column/zipball/f8e52eb28e67eb50e613b451dd916abcf783c1db", + "reference": "f8e52eb28e67eb50e613b451dd916abcf783c1db", + "shasum": "" + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "0.8.*", + "phpunit/phpunit": "~4.5", + "satooshi/php-coveralls": "0.6.*", + "squizlabs/php_codesniffer": "~2.2" + }, + "type": "library", + "autoload": { + "files": [ + "src/array_column.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ben Ramsey", + "homepage": "http://benramsey.com" + } + ], + "description": "Provides functionality for array_column() to projects using PHP earlier than version 5.5.", + "homepage": "https://github.com/ramsey/array_column", + "keywords": [ + "array", + "array_column", + "column" + ], + "time": "2015-03-20 22:07:39" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100644 index 0000000..3d98456 --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,10 @@ + 2135, + 'first_name' => 'John', + 'last_name' => 'Doe' + ), + array( + 'id' => 3245, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), + array( + 'id' => 5342, + 'first_name' => 'Jane', + 'last_name' => 'Jones' + ), + array( + 'id' => 5623, + 'first_name' => 'Peter', + 'last_name' => 'Doe' + ) +); + +$lastNames = array_column($records, 'last_name', 'id'); +``` + +If we call `print_r()` on `$lastNames`, you'll see a resulting array that looks +a bit like this: + +``` text +Array +( + [2135] => Doe + [3245] => Smith + [5342] => Jones + [5623] => Doe +) +``` + + +## Installation + +The easiest way to install this library is to use [Composer](https://getcomposer.org/): + +``` +php composer.phar require ramsey/array_column +``` + +Then, when you run `composer install`, everything will fall magically into place, +and the `array_column()` function will be available to your project, as long as +you are including Composer's autoloader. + +_However, you do not need Composer to use this library._ + +This library has no dependencies and should work on older versions of PHP. +Download the code and include `src/array_column.php` in your project, and all +should work fine. + +When you are ready to run your project on PHP 5.5, everything should +continue to run well without conflicts, even if this library remains included +in your project. diff --git a/vendor/ramsey/array_column/composer.json b/vendor/ramsey/array_column/composer.json new file mode 100644 index 0000000..2316b22 --- /dev/null +++ b/vendor/ramsey/array_column/composer.json @@ -0,0 +1,27 @@ +{ + "name": "ramsey/array_column", + "description": "Provides functionality for array_column() to projects using PHP earlier than version 5.5.", + "type": "library", + "keywords": ["array", "column", "array_column"], + "homepage": "https://github.com/ramsey/array_column", + "license": "MIT", + "authors": [ + { + "name": "Ben Ramsey", + "homepage": "http://benramsey.com" + } + ], + "support": { + "issues": "https://github.com/ramsey/array_column/issues", + "source": "https://github.com/ramsey/array_column" + }, + "require-dev": { + "phpunit/phpunit": "~4.5", + "squizlabs/php_codesniffer": "~2.2", + "jakub-onderka/php-parallel-lint": "0.8.*", + "satooshi/php-coveralls": "0.6.*" + }, + "autoload": { + "files": ["src/array_column.php"] + } +} diff --git a/vendor/ramsey/array_column/phpunit.xml.dist b/vendor/ramsey/array_column/phpunit.xml.dist new file mode 100644 index 0000000..61da3c1 --- /dev/null +++ b/vendor/ramsey/array_column/phpunit.xml.dist @@ -0,0 +1,21 @@ + + + + + ./tests + + + + + ./src + + + + + + + + diff --git a/vendor/ramsey/array_column/src/array_column.php b/vendor/ramsey/array_column/src/array_column.php new file mode 100644 index 0000000..1e7fa99 --- /dev/null +++ b/vendor/ramsey/array_column/src/array_column.php @@ -0,0 +1,115 @@ +recordSet = array( + array( + 'id' => 1, + 'first_name' => 'John', + 'last_name' => 'Doe' + ), + array( + 'id' => 2, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), + array( + 'id' => 3, + 'first_name' => 'Jane', + 'last_name' => 'Jones' + ), + ); + + $fh = fopen(__FILE__, 'r', true); + + $this->multiDataTypes = array( + array( + 'id' => 1, + 'value' => new stdClass + ), + array( + 'id' => 2, + 'value' => 34.2345 + ), + array( + 'id' => 3, + 'value' => true + ), + array( + 'id' => 4, + 'value' => false + ), + array( + 'id' => 5, + 'value' => null + ), + array( + 'id' => 6, + 'value' => 1234 + ), + array( + 'id' => 7, + 'value' => 'Foo' + ), + array( + 'id' => 8, + 'value' => $fh + ), + ); + + $this->numericColumns = array( + array('aaa', '111'), + array('bbb', '222'), + array('ccc', '333', -1 => 'ddd'), + ); + + $this->mismatchedColumns = array( + array('a' => 'foo', 'b' => 'bar', 'e' => 'bbb'), + array('a' => 'baz', 'c' => 'qux', 'd' => 'aaa'), + array('a' => 'eee', 'b' => 'fff', 'e' => 'ggg'), + ); + } + + public function testFirstNameColumnFromRecordset() + { + $expected = array('John', 'Sally', 'Jane'); + $this->assertEquals($expected, array_column($this->recordSet, 'first_name')); + } + + public function testIdColumnFromRecordset() + { + $expected = array(1, 2, 3); + $this->assertEquals($expected, array_column($this->recordSet, 'id')); + } + + public function testLastNameColumnKeyedByIdColumnFromRecordset() + { + $expected = array(1 => 'Doe', 2 => 'Smith', 3 => 'Jones'); + $this->assertEquals($expected, array_column($this->recordSet, 'last_name', 'id')); + } + + public function testLastNameColumnKeyedByFirstNameColumnFromRecordset() + { + $expected = array('John' => 'Doe', 'Sally' => 'Smith', 'Jane' => 'Jones'); + $this->assertEquals($expected, array_column($this->recordSet, 'last_name', 'first_name')); + } + + public function testValueColumnWithMultipleDataTypes() + { + $expected = array(); + foreach ($this->multiDataTypes as $row) { + $expected[] = $row['value']; + } + $this->assertEquals($expected, array_column($this->multiDataTypes, 'value')); + } + + public function testValueColumnKeyedByIdWithMultipleDataTypes() + { + $expected = array(); + foreach ($this->multiDataTypes as $row) { + $expected[$row['id']] = $row['value']; + } + $this->assertEquals($expected, array_column($this->multiDataTypes, 'value', 'id')); + } + + public function testNumericColumnKeys1() + { + $expected = array('111', '222', '333'); + $this->assertEquals($expected, array_column($this->numericColumns, 1)); + } + + public function testNumericColumnKeys2() + { + $expected = array('aaa' => '111', 'bbb' => '222', 'ccc' => '333'); + $this->assertEquals($expected, array_column($this->numericColumns, 1, 0)); + } + + public function testNumericColumnKeys3() + { + $expected = array('aaa' => '111', 'bbb' => '222', 'ccc' => '333'); + $this->assertEquals($expected, array_column($this->numericColumns, 1, 0.123)); + } + + public function testNumericColumnKeys4() + { + $expected = array(0 => '111', 1 => '222', 'ddd' => '333'); + $this->assertEquals($expected, array_column($this->numericColumns, 1, -1)); + } + + public function testFailureToFindColumn1() + { + $this->assertEquals(array(), array_column($this->numericColumns, 2)); + } + + public function testFailureToFindColumn2() + { + $this->assertEquals(array(), array_column($this->numericColumns, 'foo')); + } + + public function testFailureToFindColumn3() + { + $expected = array('aaa', 'bbb', 'ccc'); + $this->assertEquals($expected, array_column($this->numericColumns, 0, 'foo')); + } + + public function testFailureToFindColumn4() + { + $this->assertEquals(array(), array_column($this->numericColumns, 3.14)); + } + + public function testSingleDimensionalArray() + { + $singleDimension = array('foo', 'bar', 'baz'); + $this->assertEquals(array(), array_column($singleDimension, 1)); + } + + public function testMismatchedColumns1() + { + $expected = array('qux'); + $this->assertEquals($expected, array_column($this->mismatchedColumns, 'c')); + } + + public function testMismatchedColumns2() + { + $expected = array('baz' => 'qux'); + $this->assertEquals($expected, array_column($this->mismatchedColumns, 'c', 'a')); + } + + public function testMismatchedColumns3() + { + $expected = array('foo', 'aaa' => 'baz', 'eee'); + $this->assertEquals($expected, array_column($this->mismatchedColumns, 'a', 'd')); + } + + public function testMismatchedColumns4() + { + $expected = array('bbb' => 'foo', 'baz', 'ggg' => 'eee'); + $this->assertEquals($expected, array_column($this->mismatchedColumns, 'a', 'e')); + } + + public function testMismatchedColumns5() + { + $expected = array('bar', 'fff'); + $this->assertEquals($expected, array_column($this->mismatchedColumns, 'b')); + } + + public function testMismatchedColumns6() + { + $expected = array('foo' => 'bar', 'eee' => 'fff'); + $this->assertEquals($expected, array_column($this->mismatchedColumns, 'b', 'a')); + } + + public function testObjectConvertedToString() + { + $f = new Foo(); + $b = new Bar(); + $this->assertEquals(array('Doe', 'Smith', 'Jones'), array_column($this->recordSet, $f)); + $this->assertEquals(array('John' => 'Doe', 'Sally' => 'Smith', 'Jane' => 'Jones'), array_column($this->recordSet, $f, $b)); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column() expects at least 2 parameters, 0 given + */ + public function testFunctionWithZeroArgs() + { + $foo = array_column(); + } + + public function testFunctionWithZeroArgsReturnValue() + { + $foo = @array_column(); + $this->assertNull($foo); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column() expects at least 2 parameters, 1 given + */ + public function testFunctionWithOneArg() + { + $foo = array_column(array()); + } + + public function testFunctionWithOneArgReturnValue() + { + $foo = @array_column(array()); + $this->assertNull($foo); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column() expects parameter 1 to be array, string given + */ + public function testFunctionWithStringAsFirstArg() + { + $foo = array_column('foo', 0); + } + + public function testFunctionWithStringAsFirstArgReturnValue() + { + $foo = @array_column('foo', 0); + $this->assertNull($foo); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column() expects parameter 1 to be array, integer given + */ + public function testFunctionWithIntAsFirstArg() + { + $foo = array_column(1, 'foo'); + } + + public function testFunctionWithIntAsFirstArgReturnValue() + { + $foo = @array_column(1, 'foo'); + $this->assertNull($foo); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column(): The column key should be either a string or an integer + */ + public function testFunctionWithColumnKeyAsBool() + { + $foo = array_column(array(), true); + } + + public function testFunctionWithColumnKeyAsBoolReturnValue() + { + $foo = @array_column(array(), true); + $this->assertFalse($foo); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column(): The column key should be either a string or an integer + */ + public function testFunctionWithColumnKeyAsArray() + { + $foo = array_column(array(), array()); + } + + public function testFunctionWithColumnKeyAsArrayReturnValue() + { + $foo = @array_column(array(), array()); + $this->assertFalse($foo); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column(): The index key should be either a string or an integer + */ + public function testFunctionWithIndexKeyAsBool() + { + $foo = array_column(array(), 'foo', true); + } + + public function testFunctionWithIndexKeyAsBoolReturnValue() + { + $foo = @array_column(array(), 'foo', true); + $this->assertFalse($foo); + } + + /** + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage array_column(): The index key should be either a string or an integer + */ + public function testFunctionWithIndexKeyAsArray() + { + $foo = array_column(array(), 'foo', array()); + } + + public function testFunctionWithIndexKeyAsArrayReturnValue() + { + $foo = @array_column(array(), 'foo', array()); + $this->assertFalse($foo); + } + + /** + * @link https://bugs.php.net/bug.php?id=64493 + */ + public function testBugRequest64493() + { + // Array from Bug Request #64493 test script + $rows = array( + 456 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'), + 457 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'), + ); + + // pass null as second parameter to get back all columns indexed by third parameter + $expected1 = array( + 3 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'), + 5 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'), + ); + $this->assertEquals($expected1, array_column($rows, null, 'id')); + + // pass null as second parameter and bogus third param to get back zero-indexed array of all columns + $expected2 = array( + array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'), + array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'), + ); + $this->assertEquals($expected2, array_column($rows, null, 'foo')); + + // pass null as second parameter and no third param to get back array_values(input) (same as $expected2) + $this->assertEquals($expected2, array_column($rows, null)); + } + + public function testObjectCast() + { + $columnKey = new ColumnKeyClass(); + $indexKey = new IndexKeyClass(); + $value = new ValueClass(); + + $records = array( + array( + 'id' => $value, + 'first_name' => 'John', + 'last_name' => 'XXX' + ), + array( + 'id' => 3245, + 'first_name' => 'Sally', + 'last_name' => 'Smith' + ), + ); + + $expected = array( + 2135 => 'John', + 3245 => 'Sally', + ); + + $this->assertEquals($expected, array_column($records, $columnKey, $indexKey)); + } +} + +class Foo +{ + public function __toString() + { + return 'last_name'; + } +} + +class Bar +{ + public function __toString() + { + return 'first_name'; + } +} + +class ColumnKeyClass +{ + function __toString() { return 'first_name'; } +} + +class IndexKeyClass +{ + function __toString() { return 'id'; } +} + +class ValueClass +{ + function __toString() { return '2135'; } +} diff --git a/vendor/ramsey/array_column/tests/bootstrap.php b/vendor/ramsey/array_column/tests/bootstrap.php new file mode 100644 index 0000000..97eabba --- /dev/null +++ b/vendor/ramsey/array_column/tests/bootstrap.php @@ -0,0 +1,5 @@ +