| @@ -54,7 +54,7 @@ | ||
| 54 | 54 |          if (!$user) { | 
| 55 | 55 | return $response->withStatus(302)->withHeader( | 
| 56 | 56 | 'Location', | 
| 57 | -                $this->router->generateUri('auth', ['action' => 'login']) | |
| 57 | +                $this->router->generateUri('auth', [ 'action' => 'login' ]) | |
| 58 | 58 | ); | 
| 59 | 59 | } | 
| 60 | 60 | |
| @@ -9,8 +9,6 @@ | ||
| 9 | 9 | use Core\Mapper\AdminUsersMapper; | 
| 10 | 10 | use Core\Filter\AdminUserFilter; | 
| 11 | 11 | use Core\Exception\FilterException; | 
| 12 | -use Zend\Db\TableGateway\TableGateway; | |
| 13 | -use Zend\Db\Sql\Predicate\Expression; | |
| 14 | 12 | use Zend\Paginator\Adapter\DbSelect; | 
| 15 | 13 | use Zend\Paginator\Paginator; | 
| 16 | 14 | use Zend\Crypt\Password\Bcrypt; | 
| @@ -1,5 +1,5 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | -declare(strict_types=1); | |
| 2 | +declare(strict_types = 1); | |
| 3 | 3 | |
| 4 | 4 | namespace Core\Service; | 
| 5 | 5 | |
| @@ -61,17 +61,17 @@ discard block | ||
| 61 | 61 | */ | 
| 62 | 62 | public function loginUser($email, $password) | 
| 63 | 63 |      { | 
| 64 | -        if(!$email || !$password) { | |
| 64 | +        if (!$email || !$password) { | |
| 65 | 65 |              throw new \Exception('Both email and password are required.', 400); | 
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | $user = $this->adminUsersMapper->getByEmail($email); | 
| 69 | 69 | |
| 70 | -        if(!$user) { | |
| 70 | +        if (!$user) { | |
| 71 | 71 |              throw new \Exception('User does not exist.'); | 
| 72 | 72 | } | 
| 73 | 73 | |
| 74 | -        if(!$this->crypt->verify($password, $user->password)) { | |
| 74 | +        if (!$this->crypt->verify($password, $user->password)) { | |
| 75 | 75 |              throw new \Exception('Password does not match.'); | 
| 76 | 76 | } | 
| 77 | 77 | |
| @@ -117,7 +117,7 @@ discard block | ||
| 117 | 117 |      { | 
| 118 | 118 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); | 
| 119 | 119 | |
| 120 | -        if(!$filter->isValid()) { | |
| 120 | +        if (!$filter->isValid()) { | |
| 121 | 121 | throw new FilterException($filter->getMessages()); | 
| 122 | 122 | } | 
| 123 | 123 | |
| @@ -126,10 +126,10 @@ discard block | ||
| 126 | 126 | 'profile_img' => $this->upload->uploadImage($data, 'profile_img') | 
| 127 | 127 | ]; | 
| 128 | 128 | |
| 129 | - unset($data['confirm_password']); | |
| 130 | - $data['password'] = $this->crypt->create($data['password']); | |
| 131 | - $data['admin_user_id'] = Uuid::uuid1()->toString(); | |
| 132 | - $data['admin_user_uuid'] = (new MysqlUuid($data['admin_user_id']))->toFormat(new Binary); | |
| 129 | + unset($data[ 'confirm_password' ]); | |
| 130 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); | |
| 131 | + $data[ 'admin_user_id' ] = Uuid::uuid1()->toString(); | |
| 132 | + $data[ 'admin_user_uuid' ] = (new MysqlUuid($data[ 'admin_user_id' ]))->toFormat(new Binary); | |
| 133 | 133 | |
| 134 | 134 | return $this->adminUsersMapper->insert($data); | 
| 135 | 135 | } | 
| @@ -143,17 +143,17 @@ discard block | ||
| 143 | 143 | $filter = $this->adminUserFilter->getInputFilter()->setData($data); | 
| 144 | 144 | |
| 145 | 145 | // we dont want to force user to enter the password again | 
| 146 | -        if($data['password'] == '') { | |
| 146 | +        if ($data[ 'password' ] == '') { | |
| 147 | 147 |              $filter->remove('password'); | 
| 148 | 148 |              $filter->remove('confirm_password'); | 
| 149 | 149 | } | 
| 150 | 150 | |
| 151 | 151 | // if we want to keep same email | 
| 152 | -        if($user->email == $data['email']) { | |
| 152 | +        if ($user->email == $data[ 'email' ]) { | |
| 153 | 153 |              $filter->remove('email'); | 
| 154 | 154 | } | 
| 155 | 155 | |
| 156 | -        if(!$filter->isValid()) { | |
| 156 | +        if (!$filter->isValid()) { | |
| 157 | 157 | throw new FilterException($filter->getMessages()); | 
| 158 | 158 | } | 
| 159 | 159 | |
| @@ -163,20 +163,20 @@ discard block | ||
| 163 | 163 | ]; | 
| 164 | 164 | |
| 165 | 165 | // We dont want to force user to re-upload image on edit | 
| 166 | -        if(!$data['face_img']) { | |
| 167 | - unset($data['face_img']); | |
| 166 | +        if (!$data[ 'face_img' ]) { | |
| 167 | + unset($data[ 'face_img' ]); | |
| 168 | 168 | } | 
| 169 | 169 | |
| 170 | -        if(!$data['profile_img']) { | |
| 171 | - unset($data['profile_img']); | |
| 170 | +        if (!$data[ 'profile_img' ]) { | |
| 171 | + unset($data[ 'profile_img' ]); | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | -        if(isset($data['password'])) { | |
| 175 | - unset($data['confirm_password']); | |
| 176 | - $data['password'] = $this->crypt->create($data['password']); | |
| 174 | +        if (isset($data[ 'password' ])) { | |
| 175 | + unset($data[ 'confirm_password' ]); | |
| 176 | + $data[ 'password' ] = $this->crypt->create($data[ 'password' ]); | |
| 177 | 177 | } | 
| 178 | 178 | |
| 179 | - return $this->adminUsersMapper->update($data, ['admin_user_id' => $userId]); | |
| 179 | + return $this->adminUsersMapper->update($data, [ 'admin_user_id' => $userId ]); | |
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | 182 | /** | 
| @@ -187,7 +187,7 @@ discard block | ||
| 187 | 187 | */ | 
| 188 | 188 | public function delete($userId) | 
| 189 | 189 |      { | 
| 190 | - return (bool)$this->adminUsersMapper->delete(['admin_user_id' => $userId]); | |
| 190 | + return (bool) $this->adminUsersMapper->delete([ 'admin_user_id' => $userId ]); | |
| 191 | 191 | } | 
| 192 | 192 | |
| 193 | 193 | /** | 
| @@ -4,7 +4,6 @@ | ||
| 4 | 4 | use MysqlUuid\Formats\Binary; | 
| 5 | 5 | use MysqlUuid\Uuid; | 
| 6 | 6 | use Core\Entity\ArticleType; | 
| 7 | -use MysqlUuid\Formats\PlainString; | |
| 8 | 7 | |
| 9 | 8 | class Discussions extends AbstractMigration | 
| 10 | 9 |  { | 
| @@ -10,11 +10,11 @@ discard block | ||
| 10 | 10 |  { | 
| 11 | 11 | public function up() | 
| 12 | 12 |      { | 
| 13 | -        $this->table('article_discussions', ['id' => false]) | |
| 14 | -            ->addColumn('article_uuid', 'binary', ['limit' => 16]) | |
| 13 | +        $this->table('article_discussions', [ 'id' => false ]) | |
| 14 | +            ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) | |
| 15 | 15 |              ->addColumn('title', 'text') | 
| 16 | 16 |              ->addColumn('body', 'text') | 
| 17 | -            ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) | |
| 17 | +            ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) | |
| 18 | 18 | ->create(); | 
| 19 | 19 | |
| 20 | 20 | // $this->insertDummyData(); | 
| @@ -27,15 +27,15 @@ discard block | ||
| 27 | 27 | |
| 28 | 28 | private function insertDummyData() | 
| 29 | 29 |      { | 
| 30 | - $ids = []; | |
| 30 | + $ids = [ ]; | |
| 31 | 31 |          $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); | 
| 32 | -        foreach($rows as $r){ | |
| 33 | - $ids[] = $r['admin_user_uuid']; | |
| 32 | +        foreach ($rows as $r) { | |
| 33 | + $ids[ ] = $r[ 'admin_user_uuid' ]; | |
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | 36 | $faker = Faker\Factory::create(); | 
| 37 | 37 | $count = rand(250, 300); | 
| 38 | -        for($i = 0; $i < $count; $i++){ | |
| 38 | +        for ($i = 0; $i < $count; $i++) { | |
| 39 | 39 | $id = $faker->uuid; | 
| 40 | 40 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); | 
| 41 | 41 | $title = $faker->sentence(5, 15); | 
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | 'article_id' => $id, | 
| 46 | 46 |                  'slug'            => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), | 
| 47 | 47 | 'status' => 1, | 
| 48 | - 'admin_user_uuid' => $ids[array_rand($ids)], | |
| 48 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], | |
| 49 | 49 | 'type' => ArticleType::DISCUSSION | 
| 50 | 50 | ]; | 
| 51 | 51 | |
| @@ -10,19 +10,19 @@ discard block | ||
| 10 | 10 |  { | 
| 11 | 11 | public function up() | 
| 12 | 12 |      { | 
| 13 | -        $this->table('article_events', ['id' => false]) | |
| 14 | -            ->addColumn('article_uuid', 'binary', ['limit' => 16]) | |
| 13 | +        $this->table('article_events', [ 'id' => false ]) | |
| 14 | +            ->addColumn('article_uuid', 'binary', [ 'limit' => 16 ]) | |
| 15 | 15 |              ->addColumn('title', 'text') | 
| 16 | -            ->addColumn('sub_title', 'text', ['null' => true]) | |
| 16 | +            ->addColumn('sub_title', 'text', [ 'null' => true ]) | |
| 17 | 17 |              ->addColumn('place_name', 'text') | 
| 18 | 18 |              ->addColumn('body', 'text') | 
| 19 | 19 |              ->addColumn('longitude', 'text') | 
| 20 | 20 |              ->addColumn('latitude', 'text') | 
| 21 | -            ->addColumn('featured_img', 'text', ['null' => true]) | |
| 22 | -            ->addColumn('main_img', 'text', ['null' => true]) | |
| 21 | +            ->addColumn('featured_img', 'text', [ 'null' => true ]) | |
| 22 | +            ->addColumn('main_img', 'text', [ 'null' => true ]) | |
| 23 | 23 |              ->addColumn('start_at', 'datetime') | 
| 24 | 24 |              ->addColumn('end_at', 'datetime') | 
| 25 | -            ->addForeignKey('article_uuid', 'articles', 'article_uuid', ['delete' => 'NO_ACTION', 'update' => 'NO_ACTION']) | |
| 25 | +            ->addForeignKey('article_uuid', 'articles', 'article_uuid', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION' ]) | |
| 26 | 26 | ->create(); | 
| 27 | 27 | |
| 28 | 28 | // $this->insertDummyData(); | 
| @@ -35,10 +35,10 @@ discard block | ||
| 35 | 35 | |
| 36 | 36 | private function insertDummyData() | 
| 37 | 37 |      { | 
| 38 | - $ids = []; | |
| 38 | + $ids = [ ]; | |
| 39 | 39 |          $rows = $this->fetchAll('select admin_user_uuid from admin_users;'); | 
| 40 | -        foreach($rows as $r){ | |
| 41 | - $ids[] = $r['admin_user_uuid']; | |
| 40 | +        foreach ($rows as $r) { | |
| 41 | + $ids[ ] = $r[ 'admin_user_uuid' ]; | |
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | 44 | $faker = Faker\Factory::create(); | 
| @@ -46,19 +46,19 @@ discard block | ||
| 46 | 46 | $count = rand(25, 300); | 
| 47 | 47 | |
| 48 | 48 | // Download N images and set it randomly to the events | 
| 49 | -        for($i = 0; $i < 5; $i++){ | |
| 49 | +        for ($i = 0; $i < 5; $i++) { | |
| 50 | 50 | $image = $faker->image(); | 
| 51 | 51 | $destination = $upload->getPath(basename($image)); | 
| 52 | 52 | rename($image, $destination); | 
| 53 | -            $mainImg[] = substr($destination, strlen('/var/www/unfinished/public')); | |
| 53 | +            $mainImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); | |
| 54 | 54 | |
| 55 | 55 | $image = $faker->image(); | 
| 56 | 56 | $destination = $upload->getPath(basename($image)); | 
| 57 | 57 | rename($image, $destination); | 
| 58 | -            $featuredImg[] = substr($destination, strlen('/var/www/unfinished/public')); | |
| 58 | +            $featuredImg[ ] = substr($destination, strlen('/var/www/unfinished/public')); | |
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | -        for($i = 0; $i < $count; $i++){ | |
| 61 | +        for ($i = 0; $i < $count; $i++) { | |
| 62 | 62 | $start = rand(1, 20); | 
| 63 | 63 | $id = $faker->uuid; | 
| 64 | 64 | $mysqluuid = (new Uuid($id))->toFormat(new Binary()); | 
| @@ -69,7 +69,7 @@ discard block | ||
| 69 | 69 | 'article_id' => $id, | 
| 70 | 70 |                  'slug'            => strtolower(trim(preg_replace('~[^\pL\d]+~u', '-', $title), '-')), | 
| 71 | 71 | 'status' => 1, | 
| 72 | - 'admin_user_uuid' => $ids[array_rand($ids)], | |
| 72 | + 'admin_user_uuid' => $ids[ array_rand($ids) ], | |
| 73 | 73 | 'type' => ArticleType::EVENT | 
| 74 | 74 | ]; | 
| 75 | 75 | |
| @@ -80,8 +80,8 @@ discard block | ||
| 80 | 80 | 'longitude' => $faker->longitude, | 
| 81 | 81 | 'latitude' => $faker->latitude, | 
| 82 | 82 | 'place_name' => $faker->sentence(1), | 
| 83 | - 'main_img' => $mainImg[array_rand($mainImg)], | |
| 84 | - 'featured_img' => $featuredImg[array_rand($featuredImg)], | |
| 83 | + 'main_img' => $mainImg[ array_rand($mainImg) ], | |
| 84 | + 'featured_img' => $featuredImg[ array_rand($featuredImg) ], | |
| 85 | 85 |                  'start_at'     => date("Y-m-d H:i:s", strtotime("+$start  day +$start hours")), | 
| 86 | 86 |                  'end_at'       => date("Y-m-d H:i:s", strtotime("+$start  day +" . ($start + rand(1, 5)) . " hours")) | 
| 87 | 87 | ]; | 
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | |
| 3 | - header ( 'Content-type: text/plain'); | |
| 3 | +	header('Content-type: text/plain'); | |
| 4 | 4 | echo " | 
| 5 | 5 | Now see here, you will see the output of the param most | 
| 6 | 6 | interesting to PHP. \$_POST. | 
| @@ -155,7 +155,7 @@ | ||
| 155 | 155 | <table align="center" border="0" cellpadding="0" cellspacing="0"> | 
| 156 | 156 | <tr><td> | 
| 157 | 157 | <? | 
| 158 | -   if(isset($_REQUEST['issubmit'])){
 | |
| 158 | +   if (isset($_REQUEST[ 'issubmit' ])) {
 | |
| 159 | 159 | echo "<strong>form is sumbitted</strong>"; | 
| 160 | 160 | } | 
| 161 | 161 | |
| @@ -1,6 +1,6 @@ discard block | ||
| 1 | 1 | <? | 
| 2 | - $action = $_REQUEST["action"]; | |
| 3 | -  switch($action){
 | |
| 2 | + $action = $_REQUEST[ "action" ]; | |
| 3 | +  switch ($action) {
 | |
| 4 | 4 | case "1": | 
| 5 | 5 | getContent(); | 
| 6 | 6 | break; | 
| @@ -8,19 +8,19 @@ discard block | ||
| 8 | 8 | break; | 
| 9 | 9 | } | 
| 10 | 10 | |
| 11 | - function getContent(){
 | |
| 11 | + function getContent() {
 | |
| 12 | 12 | //sleep(1); | 
| 13 | - $step_number = $_REQUEST["step_number"]; | |
| 14 | - $html = '<h2 class="StepTitle">Step '.$step_number.' Content</h2>'; | |
| 15 | -   if($step_number == 1){
 | |
| 16 | - $html .='<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 13 | + $step_number = $_REQUEST[ "step_number" ]; | |
| 14 | + $html = '<h2 class="StepTitle">Step ' . $step_number . ' Content</h2>'; | |
| 15 | +   if ($step_number == 1) {
 | |
| 16 | + $html .= '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 17 | 17 | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | 
| 18 | 18 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | 
| 19 | 19 | Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | 
| 20 | 20 | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | 
| 21 | 21 | </p>'; | 
| 22 | -   }elseif($step_number == 2){
 | |
| 23 | - $html .='<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 22 | +   }elseif ($step_number == 2) {
 | |
| 23 | + $html .= '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 24 | 24 | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | 
| 25 | 25 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | 
| 26 | 26 | Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | 
| @@ -32,8 +32,8 @@ discard block | ||
| 32 | 32 | Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | 
| 33 | 33 | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | 
| 34 | 34 | </p>'; | 
| 35 | -   }elseif($step_number == 3){
 | |
| 36 | - $html .='<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 35 | +   }elseif ($step_number == 3) {
 | |
| 36 | + $html .= '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 37 | 37 | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | 
| 38 | 38 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | 
| 39 | 39 | Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | 
| @@ -51,8 +51,8 @@ discard block | ||
| 51 | 51 | Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | 
| 52 | 52 | Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | 
| 53 | 53 | </p>'; | 
| 54 | -   }else{
 | |
| 55 | - $html .='<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 54 | +   } else {
 | |
| 55 | + $html .= '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, | |
| 56 | 56 | sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, | 
| 57 | 57 | quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. | 
| 58 | 58 | Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. | 
| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | use Zend\ServiceManager\Config; | 
| 4 | 4 | use Zend\ServiceManager\ServiceManager; | 
| 5 | 5 | |
| 6 | -$config = require __DIR__ . '/config.php'; // Load configuration | |
| 7 | -$container = new ServiceManager(); // Build container | |
| 8 | -(new Config($config['dependencies']))->configureServiceManager($container); | |
| 9 | -$container->setService('config', $config);                        // Inject config | |
| 6 | +$config = require __DIR__ . '/config.php'; // Load configuration | |
| 7 | +$container = new ServiceManager(); // Build container | |
| 8 | +(new Config($config[ 'dependencies' ]))->configureServiceManager($container); | |
| 9 | +$container->setService('config', $config); // Inject config | |
| 10 | 10 | |
| 11 | 11 | return $container; | 
| 12 | 12 | \ No newline at end of file | 
| @@ -9,8 +9,8 @@ | ||
| 9 | 9 | 'error/404' => 'templates/error/404.phtml', | 
| 10 | 10 | ], | 
| 11 | 11 | 'paths' => [ | 
| 12 | - 'layout' => ['templates/layout'], | |
| 13 | - 'error' => ['templates/error'], | |
| 12 | + 'layout' => [ 'templates/layout' ], | |
| 13 | + 'error' => [ 'templates/error' ], | |
| 14 | 14 | ], | 
| 15 | 15 | ], | 
| 16 | 16 | ]; | 
| 17 | 17 | \ No newline at end of file |