public function getKeyOptionsByUserId($id)
 {
     $keyOptions = array();
     $keyOptions[""] = "None";
     $allKeyConnections = KeyConnections::find()->where(['owner' => $id])->all();
     foreach ($allKeyConnections as $connection) {
         if ($connection->text != "") {
             $keyOptions[$connection->text] = $connection->name . " - " . $connection->text;
         }
     }
     return $keyOptions;
 }
 /**
  * Finds the KeyConnections model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return KeyConnections the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = KeyConnections::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #3
0
 public function hasKey($key)
 {
     return KeyConnections::find()->where(['owner' => $this->id, 'text' => $key])->exists();
 }
$endMonth = intval(date('m'));
$endYear = intval(date('Y'));
$startMonth = $endMonth;
$startYear = $endYear - 1;
//Draw our graph.
$data = getTweetsForIntervalByUsernameAsArray($user, $startMonth, $startYear, $endMonth, $endYear);
$graph = new GraphWrapper("tweetsOverYear", $data, 'date', ['numTweets'], 'date', ['Tweets']);
echo $graph->getChart();
echo "<br/>";
echo "<p class='lead'>Keys</p>";
echo "<br/>";
$model = new KeyConnections();
echo $this->render('/key-connections/_form', ['model' => $model]);
$userId = User::find()->where(['username' => $user])->one()->id;
//Draw our keys.
$dataProvider = new ActiveDataProvider(['query' => KeyConnections::find()->where(['owner' => $userId])]);
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', 'text', ['class' => 'yii\\grid\\ActionColumn', 'controller' => 'key-connections']]]);
?>
    </div>
</div>







<?php 
class GraphWrapper
{
    private $data;
Beispiel #5
0
?>

<div class="col-md-6 well">
<?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'], 'action' => '@web/tweet/create']);
echo "<div class='row-fluid'>";
echo "<div class='col-md-3'>";
echo Yii::$app->user->identity->username;
echo "<br/>";
$hash = hash("md5", Yii::$app->user->identity->username);
echo "<img src='http://www.gravatar.com/avatar/{$hash}?d=identicon' />";
echo "</div>";
echo "<div class='col-md-9 text-center'>";
echo "<div class='panel panel-default'>";
echo "<div class='panel-body'>";
echo $form->field($model, 'key')->dropDownList(KeyConnections::getKeyOptionsByUserId(Yii::$app->user->identity->id));
echo $form->field($model, 'text')->textarea(['rows' => 6]);
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "<div class='row-fluid'>";
echo "<div class='col-md-12'>";
echo "OPTIONS GO HERE";
echo $form->field($model, 'image[]')->fileInput(['multiple' => true, 'accept' => 'image/*']);
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
echo "</div>";
echo "</div>";
ActiveForm::end();
?>
</div>