Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Commit

Permalink
refactor: Fix code style (refs #147)
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Mar 23, 2018
1 parent fa005e7 commit db1646a
Show file tree
Hide file tree
Showing 23 changed files with 164 additions and 132 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ composer.phar
deployment.*
npm-debug.log
*.map
.php_cs.cache
*.log

# Configuration
inc/config.inc.php
Expand Down
16 changes: 8 additions & 8 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$parameters = $container->getParameters();

define('ROOT_DIR', $parameters['wwwDir']);
define('HTTP_DIR', '//'.$_SERVER['HTTP_HOST'] . '/');
define('HTTP_DIR', '//' . $_SERVER['HTTP_HOST'] . '/');

/**
* Application's definitions
Expand All @@ -56,12 +56,12 @@
define('TPL_DIR', TEMPLATE_DIR);

/* URLs */
define('BLOCK_DIR', PRJ_DIR.'block');
define('PROG_DIR', PRJ_DIR.'program');
define('MEET_DIR', PRJ_DIR.'meeting');
define('VISIT_DIR', PRJ_DIR.'visitor');
define('CAT_DIR', PRJ_DIR.'category');
define('EXP_DIR', PRJ_DIR.'export');
define('SET_DIR', PRJ_DIR.'settings');
define('BLOCK_DIR', PRJ_DIR . 'block');
define('PROG_DIR', PRJ_DIR . 'program');
define('MEET_DIR', PRJ_DIR . 'meeting');
define('VISIT_DIR', PRJ_DIR . 'visitor');
define('CAT_DIR', PRJ_DIR . 'category');
define('EXP_DIR', PRJ_DIR . 'export');
define('SET_DIR', PRJ_DIR . 'settings');

return $container;
2 changes: 1 addition & 1 deletion app/components/Forms/VisitorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function buildProgramSwitcher(Form $form): Form

$form->addRadioList(
'blck_' . $block->id,
$block->day . ', ' . $block->from .' - ' . $block->to .' : ' . $block->name,
$block->day . ', ' . $block->from . ' - ' . $block->to . ' : ' . $block->name,
$programs
)->setDefaultValue(0)
->setDisabled($this->filterFilledCapacity($programs));
Expand Down
2 changes: 1 addition & 1 deletion app/components/NavbarRight/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(User $user)
public function render($backlink)
{
$template = $this->getTemplate();
$template->setFile(__DIR__ . './templates/'.self::TEMPLATE_NAME.'.'.self::TEMPLATE_EXT);
$template->setFile(__DIR__ . './templates/' . self::TEMPLATE_NAME . '.' . self::TEMPLATE_EXT);
$template->user = $this->getUser();
$template->page = $this->getPresenter()->getName();
$template->backlink = $backlink;
Expand Down
4 changes: 2 additions & 2 deletions app/models/ExportModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ public static function getPdfBlocks($vid, $database)
// zbaveni se predsnemovni diskuse
if($progData['id'] == 63) $programs .= "";
else {
$programs .= "<div class='block'>".$progData['day'].", ".$progData['from']." - ".$progData['to']." : ".$progData['name']."</div>\n";
$programs .= "<div class='block'>" . $progData['day'] . ", " . $progData['from'] . " - " . $progData['to'] . " : " . $progData['name'] . "</div>\n";

if($progData['program'] == 1) $programs .= "<div>".ProgramModel::getPdfPrograms($progData['id'], $vid, self::$connection)."</div>";
if($progData['program'] == 1) $programs .= "<div>" . ProgramModel::getPdfPrograms($progData['id'], $vid, self::$connection) . "</div>";
}
}
}
Expand Down
15 changes: 6 additions & 9 deletions app/models/MeetingModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class MeetingModel extends BaseModel

public $eventId;
public $courseId;

private $configuration;

private $program;
private $httpEncoding;
private $dbTable;
Expand All @@ -59,8 +56,8 @@ class MeetingModel extends BaseModel
/** Constructor */
public function __construct(Context $database, ProgramModel $program)
{
$this->weekendDays = array("pátek", "sobota", "neděle");
$this->form_names = array(
$this->weekendDays = ["pátek", "sobota", "neděle"];
$this->form_names = [
"place",
"start_date",
"end_date",
Expand All @@ -74,8 +71,8 @@ public function __construct(Context $database, ProgramModel $program)
"numbering",
'skautis_event_id',
'skautis_course_id',
);
$this->dbColumns = array(
];
$this->dbColumns = [
"place",
"start_date",
"end_date",
Expand All @@ -89,7 +86,7 @@ public function __construct(Context $database, ProgramModel $program)
"numbering",
'skautis_event_id',
'skautis_course_id',
);
];
$this->dbTable = "kk_meetings";
$this->setDatabase($database);
$this->program = $program;
Expand Down Expand Up @@ -175,7 +172,7 @@ public function update($id, array $data)
*/
public function delete($ids)
{
$data = array('deleted' => '1');
$data = ['deleted' => '1'];
$result = $this->getDatabase()->table($this->getTable())->where('id', $ids)->update($data);

return $result;
Expand Down
26 changes: 13 additions & 13 deletions app/models/ProgramModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ProgramModel extends BaseModel
*
* @var array form_names[]
*/
public $formNames = array();
public $formNames = [];

protected $table = 'kk_programs';

Expand All @@ -45,7 +45,7 @@ class ProgramModel extends BaseModel
/** Constructor */
public function __construct(Context $database)
{
$this->formNames = array('guid', "name", "description", "material", "tutor", "email", "capacity", "display_in_reg", "block", "category");
$this->formNames = ['guid', "name", "description", "material", "tutor", "email", "capacity", "display_in_reg", "block", "category"];
$this->setDatabase($database);
self::$connection = $this->getDatabase();
}
Expand Down Expand Up @@ -102,13 +102,13 @@ public function getPrograms($blockId, $vid)
}
// if the capacity is full
if($fullProgramData['visitors'] >= $data['capacity']){
$html_input .= "<input id='".$data['id'].$blockId."' ".$checked." disabled type='radio' name='blck_".$blockId."' value='".$data['id']."' />\n";
$html_input .= "<input id='" . $data['id'] . $blockId . "' " . $checked . " disabled type='radio' name='blck_" . $blockId . "' value='" . $data['id'] . "' />\n";
$fullProgramInfo = " (NELZE ZAPSAT - kapacita programu je již naplněna!)";
} else {
$html_input .= "<input id='".$data['id'].$blockId."' ".$checked." type='radio' name='blck_".$blockId."' value='".$data['id']."' /> \n";
$html_input .= "<input id='" . $data['id'] . $blockId . "' " . $checked . " type='radio' name='blck_" . $blockId . "' value='" . $data['id'] . "' /> \n";
$fullProgramInfo = "";
}
$html_input .= '<label for="'.$data['id'].$blockId.'">'.$data['name'].'</label>';
$html_input .= '<label for="' . $data['id'] . $blockId . '">' . $data['name'] . '</label>';
$html_input .= $fullProgramInfo;
$html_input .= "<br />\n";
}
Expand All @@ -117,7 +117,7 @@ public function getPrograms($blockId, $vid)
if(!$checked_flag) $checked = "checked='checked'";
else $checked = "";

$html .= "<input ".$checked." type='radio' name='blck_".$blockId."' value='0' /> Nebudu přítomen <br />\n";
$html .= "<input " . $checked . " type='radio' name='blck_" . $blockId . "' value='0' /> Nebudu přítomen <br />\n";
$html .= $html_input;

$html .= "</div>\n";
Expand Down Expand Up @@ -151,14 +151,14 @@ public function getExportPrograms($blockId)

if($fullProgramData['visitors'] >= $data['capacity']){
//$html .= "<input disabled type='radio' name='".$id."' value='".$data['id']."' />\n";
$fullProgramInfo = "<span style='font-size:12px; font-weight:bold;'>".$fullProgramData['visitors']."/".$data['capacity']."</span> (kapacita programu je naplněna!)";
$fullProgramInfo = "<span style='font-size:12px; font-weight:bold;'>" . $fullProgramData['visitors'] . "/" . $data['capacity'] . "</span> (kapacita programu je naplněna!)";
}
else {
//$html .= "<input type='radio' name='".$id."' value='".$data['id']."' /> \n";
$fullProgramInfo = "<span style='font-size:12px; font-weight:bold;'>".$fullProgramData['visitors']."/".$data['capacity']."</span>";
$fullProgramInfo = "<span style='font-size:12px; font-weight:bold;'>" . $fullProgramData['visitors'] . "/" . $data['capacity'] . "</span>";
}
$html .= "<td style='min-width:270px;'>";
$html .= "<a rel='programDetail' href='".PRJ_DIR."program/?id=".$data['id']."&cms=edit&page=export' title='".$data['name']."'>".$data['name']."</a>\n";
$html .= "<a rel='programDetail' href='" . PRJ_DIR . "program/?id=" . $data['id'] . "&cms=edit&page=export' title='" . $data['name'] . "'>" . $data['name'] . "</a>\n";
$html .= "</td>";
$html .= "<td>";
$html .= $fullProgramInfo;
Expand Down Expand Up @@ -205,8 +205,8 @@ public function renderExportPrograms()
}
*/
else $notDisplayed = "";
$programs .= "<div ".$notDisplayed.">".$progData['day'].", ".$progData['from']." - ".$progData['to']." : ".$progData['name']."</div>\n";
if($progData['program'] == 1) $programs .= "<div ".$notDisplayed.">".$this->getExportPrograms($progData['id'])."</div>";
$programs .= "<div " . $notDisplayed . ">" . $progData['day'] . ", " . $progData['from'] . " - " . $progData['to'] . " : " . $progData['name'] . "</div>\n";
if($progData['program'] == 1) $programs .= "<div " . $notDisplayed . ">" . $this->getExportPrograms($progData['id']) . "</div>";
$programs .= "<br />";
}
}
Expand Down Expand Up @@ -348,7 +348,7 @@ public function getProgramsLarge($id){
$html = "<table>";
$html .= " <tr>";
foreach($result as $data){
$html .= "<td class='category cat-".$data['style']."' >".$data['name']."</td>\n";
$html .= "<td class='category cat-" . $data['style'] . "' >" . $data['name'] . "</td>\n";
}
$html .= " </tr>\n";
$html .= "</table>\n";
Expand All @@ -370,7 +370,7 @@ public static function getProgramNames($block_id)
if(!$result) $html = "";
else {
foreach($result as $data){
$html .= $data['name'].",\n";
$html .= $data['name'] . ",\n";
}
}
return $html;
Expand Down
62 changes: 32 additions & 30 deletions app/models/VisitorModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class VisitorModel extends BaseModel
*
* @var array dbColumns[]
*/
public $dbColumns = array();
public $dbColumns = [];

/**
* Array of form names
*
* @var array formNames[]
*/
public $formNames = array();
public $formNames = [];

protected $table = 'kk_visitors';

Expand Down Expand Up @@ -93,32 +93,34 @@ public function __construct(
$this->Meals = $Meals;
$this->Programs = $Program;
$this->Blocks = $Blocks;
$this->dbColumns = array(
"guid",
"name",
"surname",
"nick",
"birthday",
"street",
"city",
"postal_code",
"province",
"group_num",
"group_name",
"troop_name",
"bill",
"cost",
"email",
"comment",
"arrival",
"departure",
"question",
"question2",
"checked",
"meeting",
"hash"
);
$this->formNames = array("name", "description", "material", "tutor", "email", "capacity", "display_in_reg", "block", "category");
$this->dbColumns = [
"guid",
"name",
"surname",
"nick",
"birthday",
"street",
"city",
"postal_code",
"province",
"group_num",
"group_name",
"troop_name",
"bill",
"cost",
"email",
"comment",
"arrival",
"departure",
"question",
"question2",
"checked",
"meeting",
"hash",
];
$this->formNames = [
"name", "description", "material", "tutor", "email", "capacity", "display_in_reg", "block", "category"
];
$this->database = $database;
}

Expand Down Expand Up @@ -168,10 +170,10 @@ public function assemble(array $DB_data, $meals_data, $programs_data, $returnGui
$program_blocks = $this->Blocks->getProgramBlocks($DB_data['meeting']);

foreach($program_blocks as $DB_blocks_data) {
$bindingsData = array(
$bindingsData = [
'visitor' => $ID_visitor,
'program' => $programs_data[$DB_blocks_data['id']],
);
];
// insert into binding table
// var programs_data contains requested values in format block-id => program-id
$bindingsData['guid'] = md5(uniqid());
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/BasePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function beforeRender()
* data
* @var array
*/
protected $data = array();
protected $data = [];

/**
* error handler
Expand Down
11 changes: 7 additions & 4 deletions app/presenters/BlockPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ public function actionCreate(ArrayHash $block)

$result = $this->getBlockRepository()->create($block);

$this->logInfo('Creation of block successfull, result: ' . json_encode($result));
$this->logInfo('Creation of block successfull, result: %s', [json_encode($result)]);
$this->flashSuccess('Položka byla úspěšně vytvořena');
} catch(Exception $e) {
$this->logError('Creation of block with data ' . json_encode($block) . ' failed, result: ' . $e->getMessage());
$this->logError('Creation of block with data %s failed, result: %s', [
json_encode($block),
$e->getMessage(),
]);
$this->flashFailure('Creation of block failed, result: ' . $e->getMessage());
$result = false;
}
Expand Down Expand Up @@ -131,7 +134,7 @@ public function actionDelete($id)
$this->logInfo('Destroying of block successfull, result: ' . json_encode($result));
$this->flashSuccess('Položka byla úspěšně smazána.');
} catch(Exception $e) {
$this->logError('Destroying of block failed, result: ' . $e->getMessage());
$this->logError('Destroying of block failed, result: ' . $e->getMessage());
$this->flashFailure('Destroying of block failed, result: ' . $e->getMessage());
}

Expand All @@ -156,7 +159,7 @@ public function actionMail($id)
$this->logInfo('Sending email to block tutor successfull, result: ' . json_encode($recipients) . ', ' . $tutors->guid);
$this->flashSuccess('Email lektorovi byl odeslán..');
} catch(Exception $e) {
$this->logError('Sending email to block tutor failed, result: ' . $e->getMessage());
$this->logError('Sending email to block tutor failed, result: ' . $e->getMessage());
$this->flashFailure('Email lektorovi nebyl odeslán, result: ' . $e->getMessage());
}

Expand Down
23 changes: 16 additions & 7 deletions app/presenters/CategoryPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public function actionDelete($id)
{
try {
$result = $this->getModel()->delete($id);
Debugger::log('Destroying of category successfull, result: ' . json_encode($result), Debugger::INFO);
$this->logInfo('Destroying of category successfull, result: %s', json_encode($result));
$this->flashMessage('Položka byla úspěšně smazána', 'ok');
} catch(Exception $e) {
Debugger::log('Destroying of category failed, result: ' . $e->getMessage(), Debugger::ERROR);
$this->logError('Destroying of category failed, result: %s', $e->getMessage());
$this->flashMessage('Destroying of category failed, result: ' . $e->getMessage(), 'error');
}

Expand All @@ -58,11 +58,14 @@ public function actionCreate()
$data = $this->getHttpRequest()->getPost();
$result = $this->getModel()->create($data);

Debugger::log('Creation of category successfull, result: ' . json_encode($result), Debugger::INFO);
$this->logInfo('Creation of category successfull, result: %s', json_encode($result));

$this->flashMessage('Položka byla úspěšně vytvořena', 'ok');
} catch(Exception $e) {
Debugger::log('Creation of category with data ' . json_encode($data) . ' failed, result: ' . $e->getMessage(), Debugger::ERROR);
$this->logError('Creation of category with data %s failed, result: %s', [
json_encode($data),
$e->getMessage()
]);

$this->flashMessage('Creation of category failed, result: ' . $e->getMessage(), 'error');
}
Expand All @@ -80,11 +83,17 @@ public function actionUpdate($id)
$data = $this->getHttpRequest()->getPost();
$result = $this->getModel()->update($id, $data);

Debugger::log('Modification of category id ' . $id . ' with data ' . json_encode($data) . ' successfull, result: ' . json_encode($result), Debugger::INFO);

$this->logInfo('Modification of category id %s with data %s successfull, result: %s', [
$id,
json_encode($data),
json_encode($result),
]);
$this->flashMessage('Položka byla úspěšně upravena', 'ok');
} catch(Exception $e) {
Debugger::log('Modification of category id ' . $id . ' failed, result: ' . $e->getMessage(), Debugger::ERROR);
$this->logError('Modification of category id %s failed, result: %s', [
$id,
$e->getMessage(),
]);

$this->flashMessage('Modification of category id ' . $id . ' failed, result: ' . $e->getMessage(), 'error');
}
Expand Down
Loading

0 comments on commit db1646a

Please sign in to comment.