@@ -13,8 +13,8 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | site\assets\AppAsset::register($this); |
| 15 | 15 | |
| 16 | -if($hash = Utility::getRevHash()) { |
|
| 17 | - $rev_link = '<a href="'.Utility::getGithubRevUrl().'">'.Utility::getRevHash().'</a>'; |
|
| 16 | +if ($hash = Utility::getRevHash()) { |
|
| 17 | + $rev_link = '<a href="' . Utility::getGithubRevUrl() . '">' . Utility::getRevHash() . '</a>'; |
|
| 18 | 18 | } else $rev_link = 'DEVELOPMENT'; |
| 19 | 19 | |
| 20 | 20 | ?> |
@@ -15,7 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | if($hash = Utility::getRevHash()) { |
| 17 | 17 | $rev_link = '<a href="'.Utility::getGithubRevUrl().'">'.Utility::getRevHash().'</a>'; |
| 18 | -} else $rev_link = 'DEVELOPMENT'; |
|
| 18 | +} else { |
|
| 19 | + $rev_link = 'DEVELOPMENT'; |
|
| 20 | +} |
|
| 19 | 21 | |
| 20 | 22 | ?> |
| 21 | 23 | <?php $this->beginPage() ?> |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | print $form |
| 41 | 41 | ->field($model, "behaviors{$category['id']}") |
| 42 | 42 | ->checkboxList($behaviors, |
| 43 | - ['data-toggle' => 'buttons', 'item' => "checkboxItemTemplate"]); |
|
| 43 | + ['data-toggle' => 'buttons', 'item' => "checkboxItemTemplate"]); |
|
| 44 | 44 | } |
| 45 | 45 | print Html::submitButton('Submit', ['class' => 'btn btn-success']); |
| 46 | 46 | ActiveForm::end(); |
@@ -10,8 +10,7 @@ discard block |
||
| 10 | 10 | $this->title = "The Faster Scale App | Check-in"; |
| 11 | 11 | |
| 12 | 12 | function checkboxItemTemplate($index, $label, $name, $checked, $value) { |
| 13 | - return Html::checkbox |
|
| 14 | - ( |
|
| 13 | + return Html::checkbox( |
|
| 15 | 14 | $name, |
| 16 | 15 | $checked, |
| 17 | 16 | [ |
@@ -35,7 +34,7 @@ discard block |
||
| 35 | 34 | 'options' => ['class' => 'form-horizontal'], |
| 36 | 35 | ]); |
| 37 | 36 | |
| 38 | -foreach($categories as $category) { |
|
| 37 | +foreach ($categories as $category) { |
|
| 39 | 38 | $behaviors = AH::map($behaviorsList[$category['id']], 'id', 'name'); |
| 40 | 39 | print $form |
| 41 | 40 | ->field($model, "behaviors{$category['id']}") |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | print $form |
| 93 | 93 | ->field($model, "behaviors{$category['id']}") |
| 94 | 94 | ->checkboxList($behaviors, |
| 95 | - ['item' => "checkboxItemTemplate"]); |
|
| 95 | + ['item' => "checkboxItemTemplate"]); |
|
| 96 | 96 | } |
| 97 | 97 | ActiveForm::end(); |
| 98 | 98 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $plus_week = $time->alterLocalDate($actual_date, "+1 week"); |
| 28 | 28 | |
| 29 | 29 | $pie_data = []; |
| 30 | -if($answer_pie) { |
|
| 30 | +if ($answer_pie) { |
|
| 31 | 31 | $values = array_map('intval', array_column($answer_pie, "count")); |
| 32 | 32 | $labels = array_column($answer_pie, "name"); |
| 33 | 33 | $colors = array_column($answer_pie, "color"); |
@@ -68,15 +68,15 @@ discard block |
||
| 68 | 68 | </div> |
| 69 | 69 | </div> |
| 70 | 70 | |
| 71 | - <?php if($questions) { |
|
| 72 | - foreach($questions as $behavior_id => $behavior_questions) { |
|
| 71 | + <?php if ($questions) { |
|
| 72 | + foreach ($questions as $behavior_id => $behavior_questions) { |
|
| 73 | 73 | print "<div class='well well-sm'>"; |
| 74 | 74 | print "<button type='button' class='btn btn-primary' disabled='disabled'>{$behavior_questions['question']['title']}</button>"; |
| 75 | 75 | print "<div class='row'>"; |
| 76 | - foreach($behavior_questions['answers'] as $question) { |
|
| 76 | + foreach ($behavior_questions['answers'] as $question) { |
|
| 77 | 77 | print "<div class='col-md-4'>"; |
| 78 | 78 | print "<p><strong>{$question['title']}</strong></p>"; |
| 79 | - print "<p>".Html::encode($question['answer'])."</p>"; |
|
| 79 | + print "<p>" . Html::encode($question['answer']) . "</p>"; |
|
| 80 | 80 | print "</div>"; |
| 81 | 81 | } |
| 82 | 82 | print "</div></div>"; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'options' => ['class' => 'form-horizontal'], |
| 89 | 89 | ]); |
| 90 | 90 | |
| 91 | - foreach($categories as $category) { |
|
| 91 | + foreach ($categories as $category) { |
|
| 92 | 92 | $behaviors = AH::map($behaviorsList[$category['id']], 'id', 'name'); |
| 93 | 93 | print $form |
| 94 | 94 | ->field($model, "behaviors{$category['id']}") |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | $name, |
| 13 | 13 | $checked, |
| 14 | 14 | ['value' => $value, |
| 15 | - 'label' => $label, |
|
| 16 | - 'container' => false, |
|
| 17 | - 'labelOptions' => [ 'class' => $checked |
|
| 15 | + 'label' => $label, |
|
| 16 | + 'container' => false, |
|
| 17 | + 'labelOptions' => [ 'class' => $checked |
|
| 18 | 18 | ? 'btn btn-info active' |
| 19 | 19 | : 'btn btn-info'], |
| 20 | 20 | ]); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | ['value' => $value, |
| 15 | 15 | 'label' => $label, |
| 16 | 16 | 'container' => false, |
| 17 | - 'labelOptions' => [ 'class' => $checked |
|
| 17 | + 'labelOptions' => ['class' => $checked |
|
| 18 | 18 | ? 'btn btn-info active' |
| 19 | 19 | : 'btn btn-info'], |
| 20 | 20 | ]); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | 'id' => 'checkin-form', |
| 33 | 33 | ]); |
| 34 | 34 | |
| 35 | -foreach($categories as $category_id => $category_name) { |
|
| 35 | +foreach ($categories as $category_id => $category_name) { |
|
| 36 | 36 | print $form->field($model, "user_behavior_id{$category_id}")->radioList($behaviors[$category_id], ['class' => "btn-group", 'data-toggle' => 'buttons', 'item'=>"radioItemTemplate"]); |
| 37 | 37 | print $form->field($model, "answer_{$category_id}a")->textarea()->label("How does it affect me? How do I act and feel?"); |
| 38 | 38 | print $form->field($model, "answer_{$category_id}b")->textarea()->label("How does it affect the important people in my life?"); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | public function setBehaviors($behaviors) { |
| 67 | 67 | foreach($behaviors as $category_id => $category_data) { |
| 68 | 68 | $attribute = "behaviors$category_id"; |
| 69 | - $this->$attribute = []; |
|
| 69 | + $this->$attribute = []; |
|
| 70 | 70 | foreach($category_data['behaviors'] as $behavior) { |
| 71 | 71 | $this->{$attribute}[] = $behavior['id']; |
| 72 | 72 | } |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public function compileBehaviors() { |
| 87 | 87 | $behaviors = array_merge((array)$this->behaviors1, |
| 88 | - (array)$this->behaviors2, |
|
| 89 | - (array)$this->behaviors3, |
|
| 90 | - (array)$this->behaviors4, |
|
| 91 | - (array)$this->behaviors5, |
|
| 92 | - (array)$this->behaviors6, |
|
| 93 | - (array)$this->behaviors7); |
|
| 88 | + (array)$this->behaviors2, |
|
| 89 | + (array)$this->behaviors3, |
|
| 90 | + (array)$this->behaviors4, |
|
| 91 | + (array)$this->behaviors5, |
|
| 92 | + (array)$this->behaviors6, |
|
| 93 | + (array)$this->behaviors7); |
|
| 94 | 94 | |
| 95 | 95 | return array_filter($behaviors); // strip out false values |
| 96 | 96 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function setBehaviors($behaviors) { |
| 56 | - foreach($behaviors as $category_id => $category_data) { |
|
| 56 | + foreach ($behaviors as $category_id => $category_data) { |
|
| 57 | 57 | $attribute = "behaviors$category_id"; |
| 58 | 58 | $this->$attribute = []; |
| 59 | - foreach($category_data['behaviors'] as $behavior) { |
|
| 59 | + foreach ($category_data['behaviors'] as $behavior) { |
|
| 60 | 60 | $this->{$attribute}[] = $behavior['id']; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | public function validateBehaviors($attribute, $params) { |
| 66 | 66 | if (!$this->hasErrors()) { |
| 67 | - foreach($this->$attribute as $behavior) { |
|
| 68 | - if(!is_numeric($behavior)) { |
|
| 67 | + foreach ($this->$attribute as $behavior) { |
|
| 68 | + if (!is_numeric($behavior)) { |
|
| 69 | 69 | $this->addError($attribute, 'One of your behaviors is not an integer!'); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -103,20 +103,20 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // delete cached behaviors |
| 105 | 105 | array_map(function($period) use ($time) { |
| 106 | - $key = "checkins_".Yii::$app->user->id."_{$period}_".$time->getLocalDate(); |
|
| 106 | + $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $time->getLocalDate(); |
|
| 107 | 107 | Yii::$app->cache->delete($key); |
| 108 | 108 | }, [30, 90, 180]); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | public function save() { |
| 112 | - if(empty($this->compiled_behaviors)) { |
|
| 112 | + if (empty($this->compiled_behaviors)) { |
|
| 113 | 113 | $this->commpiled_behaviors = $this->compileBehaviors(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
| 117 | 117 | |
| 118 | 118 | $rows = []; |
| 119 | - foreach($this->compiled_behaviors as $behavior_id) { |
|
| 119 | + foreach ($this->compiled_behaviors as $behavior_id) { |
|
| 120 | 120 | $temp = [ |
| 121 | 121 | Yii::$app->user->id, |
| 122 | 122 | (int)$behavior_id, |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | )->execute(); |
| 136 | 136 | |
| 137 | 137 | // if the user has publicised their check-in graph, create the image |
| 138 | - if(Yii::$app->user->identity->expose_graph) { |
|
| 138 | + if (Yii::$app->user->identity->expose_graph) { |
|
| 139 | 139 | $checkins_last_month = $user_behavior->getCheckInBreakdown(); |
| 140 | 140 | |
| 141 | - if($checkins_last_month) { |
|
| 141 | + if ($checkins_last_month) { |
|
| 142 | 142 | Yii::$container |
| 143 | 143 | ->get(\common\components\Graph::class, [Yii::$app->user->identity]) |
| 144 | 144 | ->create($checkins_last_month, true); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | return Yii::$app->mailer->compose() |
| 57 | 57 | ->setTo($email) |
| 58 | 58 | ->setFrom([$this->email => $this->name]) |
| 59 | - ->setSubject("[FSA Contact] ".$this->subject) |
|
| 59 | + ->setSubject("[FSA Contact] " . $this->subject) |
|
| 60 | 60 | ->setTextBody($this->body) |
| 61 | 61 | ->send(); |
| 62 | 62 | } |
@@ -157,11 +157,11 @@ |
||
| 157 | 157 | foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { |
| 158 | 158 | $question_id = \common\models\Question::$TYPES[$answer_letter]; |
| 159 | 159 | array_push($answers, [ |
| 160 | - 'behavior_id' => $user_bhvr->behavior_id, |
|
| 161 | - 'user_bhvr_id' => $user_bhvr->id, |
|
| 162 | - 'question_id' => $question_id, |
|
| 163 | - 'answer' => $answer, |
|
| 164 | - ]); |
|
| 160 | + 'behavior_id' => $user_bhvr->behavior_id, |
|
| 161 | + 'user_bhvr_id' => $user_bhvr->id, |
|
| 162 | + 'question_id' => $question_id, |
|
| 163 | + 'answer' => $answer, |
|
| 164 | + ]); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | return $answers; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | 'whenClient' => "function(attribute, value) { return false; }", // lame, but acceptable |
| 84 | 84 | "message" => "You must select a behavior your responses apply to."], |
| 85 | 85 | |
| 86 | - [['answer_1a','answer_1b','answer_1c','answer_2a','answer_2b','answer_2c','answer_3a','answer_3b','answer_3c','answer_4a','answer_4b','answer_4c','answer_5a', 'answer_5b','answer_5c','answer_6a', 'answer_6b','answer_6c','answer_7a','answer_7b','answer_7c'], 'safe'] |
|
| 86 | + [['answer_1a', 'answer_1b', 'answer_1c', 'answer_2a', 'answer_2b', 'answer_2c', 'answer_3a', 'answer_3b', 'answer_3c', 'answer_4a', 'answer_4b', 'answer_4c', 'answer_5a', 'answer_5b', 'answer_5c', 'answer_6a', 'answer_6b', 'answer_6c', 'answer_7a', 'answer_7b', 'answer_7c'], 'safe'] |
|
| 87 | 87 | ]; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -101,10 +101,10 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public function getBhvrValidator() { |
| 103 | 103 | return function($model, $attr) { |
| 104 | - $attrNum = $attr[strlen($attr)-1]; |
|
| 105 | - foreach(['a', 'b', 'c'] as $l) { |
|
| 104 | + $attrNum = $attr[strlen($attr) - 1]; |
|
| 105 | + foreach (['a', 'b', 'c'] as $l) { |
|
| 106 | 106 | $attr = "answer_{$attrNum}{$l}"; |
| 107 | - if($model->$attr) return true; |
|
| 107 | + if ($model->$attr) return true; |
|
| 108 | 108 | } |
| 109 | 109 | return false; |
| 110 | 110 | }; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | public function getPrefixProps($prefix) { |
| 136 | 136 | return array_filter(get_object_vars($this), function($v, $k) use($prefix) { |
| 137 | - if(strpos($k, $prefix) === 0 && strlen($v)) { |
|
| 137 | + if (strpos($k, $prefix) === 0 && strlen($v)) { |
|
| 138 | 138 | return true; |
| 139 | 139 | } |
| 140 | 140 | }, ARRAY_FILTER_USE_BOTH); |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | public function getAnswers($bhvrs) { |
| 153 | 153 | $answers = []; |
| 154 | 154 | $user_bhvrs = array_combine($this->getUserBehaviorProps(), $bhvrs); |
| 155 | - foreach($user_bhvrs as $property => $user_bhvr) { |
|
| 155 | + foreach ($user_bhvrs as $property => $user_bhvr) { |
|
| 156 | 156 | $behavior_id = intval(substr($property, -1, 1)); |
| 157 | - foreach($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { |
|
| 157 | + foreach ($this->behaviorToAnswers($behavior_id) as $answer_letter => $answer) { |
|
| 158 | 158 | $question_id = \common\models\Question::$TYPES[$answer_letter]; |
| 159 | 159 | array_push($answers, [ |
| 160 | 160 | 'behavior_id' => $user_bhvr->behavior_id, |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | public function saveAnswers($bhvrs) { |
| 171 | 171 | $result = true; |
| 172 | - foreach($this->getAnswers($bhvrs) as $answer) { |
|
| 172 | + foreach ($this->getAnswers($bhvrs) as $answer) { |
|
| 173 | 173 | $model = new \common\models\Question; |
| 174 | 174 | $model->user_id = Yii::$app->user->id; |
| 175 | 175 | $model->behavior_id = $answer['behavior_id']; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $model->date = new Expression("now()::timestamp"); |
| 178 | 178 | $model->question = $answer['question_id']; |
| 179 | 179 | $model->answer = $answer['answer']; |
| 180 | - if(!$model->save()) { |
|
| 180 | + if (!$model->save()) { |
|
| 181 | 181 | $result = false; |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -104,7 +104,9 @@ |
||
| 104 | 104 | $attrNum = $attr[strlen($attr)-1]; |
| 105 | 105 | foreach(['a', 'b', 'c'] as $l) { |
| 106 | 106 | $attr = "answer_{$attrNum}{$l}"; |
| 107 | - if($model->$attr) return true; |
|
| 107 | + if($model->$attr) { |
|
| 108 | + return true; |
|
| 109 | + } |
|
| 108 | 110 | } |
| 109 | 111 | return false; |
| 110 | 112 | }; |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | set_include_path(get_include_path().':'.__DIR__); |
| 8 | 8 | if(file_exists($root.$path)) |
| 9 | 9 | { |
| 10 | - if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') |
|
| 11 | - $path = rtrim($path,'/').'/index.php'; |
|
| 12 | - if(strpos($path,'.php') === false) return false; |
|
| 13 | - else { |
|
| 14 | - chdir(dirname($root.$path)); |
|
| 15 | - require_once $root.$path; |
|
| 16 | - } |
|
| 10 | + if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') |
|
| 11 | + $path = rtrim($path,'/').'/index.php'; |
|
| 12 | + if(strpos($path,'.php') === false) return false; |
|
| 13 | + else { |
|
| 14 | + chdir(dirname($root.$path)); |
|
| 15 | + require_once $root.$path; |
|
| 16 | + } |
|
| 17 | 17 | }else include_once 'index.php'; |
| 18 | 18 | ?> |
@@ -3,16 +3,16 @@ |
||
| 3 | 3 | header("Access-Control-Allow-Origin: *"); |
| 4 | 4 | $root = $_SERVER['DOCUMENT_ROOT']; |
| 5 | 5 | chdir($root); |
| 6 | -$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/'); |
|
| 7 | -set_include_path(get_include_path().':'.__DIR__); |
|
| 8 | -if(file_exists($root.$path)) |
|
| 6 | +$path = '/' . ltrim(parse_url($_SERVER['REQUEST_URI'])['path'], '/'); |
|
| 7 | +set_include_path(get_include_path() . ':' . __DIR__); |
|
| 8 | +if (file_exists($root . $path)) |
|
| 9 | 9 | { |
| 10 | - if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') |
|
| 11 | - $path = rtrim($path,'/').'/index.php'; |
|
| 12 | - if(strpos($path,'.php') === false) return false; |
|
| 10 | + if (is_dir($root . $path) && substr($path, strlen($path) - 1, 1) !== '/') |
|
| 11 | + $path = rtrim($path, '/') . '/index.php'; |
|
| 12 | + if (strpos($path, '.php') === false) return false; |
|
| 13 | 13 | else { |
| 14 | - chdir(dirname($root.$path)); |
|
| 15 | - require_once $root.$path; |
|
| 14 | + chdir(dirname($root . $path)); |
|
| 15 | + require_once $root . $path; |
|
| 16 | 16 | } |
| 17 | -}else include_once 'index.php'; |
|
| 17 | +} else include_once 'index.php'; |
|
| 18 | 18 | ?> |
@@ -7,12 +7,16 @@ |
||
| 7 | 7 | set_include_path(get_include_path().':'.__DIR__); |
| 8 | 8 | if(file_exists($root.$path)) |
| 9 | 9 | { |
| 10 | - if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') |
|
| 11 | - $path = rtrim($path,'/').'/index.php'; |
|
| 12 | - if(strpos($path,'.php') === false) return false; |
|
| 13 | - else { |
|
| 10 | + if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/') { |
|
| 11 | + $path = rtrim($path,'/').'/index.php'; |
|
| 12 | + } |
|
| 13 | + if(strpos($path,'.php') === false) { |
|
| 14 | + return false; |
|
| 15 | + } else { |
|
| 14 | 16 | chdir(dirname($root.$path)); |
| 15 | 17 | require_once $root.$path; |
| 16 | 18 | } |
| 17 | -}else include_once 'index.php'; |
|
| 19 | +} else { |
|
| 20 | + include_once 'index.php'; |
|
| 21 | +} |
|
| 18 | 22 | ?> |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | { |
| 21 | 21 | use _generated\UnitTesterActions; |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Define custom actions here |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * Define custom actions here |
|
| 25 | + */ |
|
| 26 | 26 | } |