Since: 1.0
Author: Kartik Visweswaran (kartikv2@gmail.com)
Inheritance: extends yii\helpers\Inflector
Example #1
0
 public function data() {
     $userField = $this->userField;
     $output = '';
     $models = Chat::records();
     if ($models)
         foreach ($models as $model) {
             if (isset($model->user->$userField)) {
                 $avatar = $model->user->$userField;
             } else{
                 $avatar = Yii::$app->assetManager->getPublishedUrl("@vendor/sintret/yii2-chat-adminlte/assets/img/avatar.png");
             }
                 
             $output .= '<div class="item">
             <img class="online" alt="user image" src="' . $avatar . '">
             <p class="message">
                 <a class="name" href="#">
                     <small class="text-muted pull-right" style="color:green"><i class="fa fa-clock-o"></i> ' . \kartik\helpers\Enum::timeElapsed($model->updateDate) . '</small>
                     ' . $model->user->user_name . '
                 </a>
                ' . $model->message . '
             </p>
         </div>';
         }
     return $output;
 }
 public function getTimeago()
 {
     if ($this->createDate) {
         return Enum::timeElapsed($this->createDate);
     }
 }
Example #3
0
 /**
  * Generates an address block.
  *
  * @param string $name the addressee name
  * @param array $lines the lines of address information
  * @param array $phone the list of phone numbers - passed as $key => $value, where:
  *    - $key is the phone type could be 'Res', 'Off', 'Cell', 'Fax'
  *    - $value is the phone number
  * @param array $email the list of email addresses - passed as $key => $value, where:
  *    - $key is the email type could be 'Res', 'Off'
  *    - $value is the email address
  * @param array $options html options for the address
  * @param string $phoneLabel the prefix label for each phone - defaults to '(P)'
  * @param string $emailLabel the prefix label for each email - defaults to '(E)'
  *
  * Example(s):
  * ~~~
  * echo Html::address(
  *      'Twitter, Inc.',
  *      ['795 Folsom Ave, Suite 600', 'San Francisco, CA 94107'],
  *      ['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'],
  *      ['Res' => '*****@*****.**', 'Off' => '*****@*****.**']
  * );
  * $address = Html::address(
  *      'Twitter, Inc.',
  *      ['795 Folsom Ave, Suite 600', 'San Francisco, CA 94107'],
  *      ['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'],
  *      ['Res' => '*****@*****.**', 'Off' => '*****@*****.**'],
  *      Html::icon('phone'),
  *      Html::icon('envelope')
  * );
  * echo Html::well($address, Html::SIZE_TINY);
  * ~~~
  *
  * @see http://getbootstrap.com/css/#type-addresses
  */
 public static function address($name, $lines = [], $phone = [], $email = [], $options = [], $phoneLabel = '(P)', $emailLabel = '(E)')
 {
     Enum::initI18N();
     $addresses = '';
     if (!empty($lines)) {
         $addresses = implode('<br>', $lines) . "<br>\n";
     }
     $phones = '';
     foreach ($phone as $type => $number) {
         if (is_numeric($type)) {
             // no keys were passed to the phone array
             $type = static::tag('abbr', $phoneLabel, ['title' => Yii::t('kvenum', 'Phone')]) . ': ';
         } else {
             $type = static::tag('abbr', $phoneLabel . ' ' . $type, ['title' => Yii::t('kvenum', 'Phone')]) . ': ';
         }
         $phones .= "{$type}{$number}<br>\n";
     }
     $emails = '';
     foreach ($email as $type => $addr) {
         if (is_numeric($type)) {
             // no keys were passed to the email array
             $type = Html::tag('abbr', $emailLabel, ['title' => Yii::t('kvenum', 'Email')]) . ': ';
         } else {
             $type = Html::tag('abbr', $emailLabel . ' ' . $type, ['title' => Yii::t('kvenum', 'Email')]) . ': ';
         }
         $emails .= $type . static::mailto($addr, $addr) . "<br>\n";
     }
     return static::tag('address', "<strong>{$name}</strong><br>\n" . $addresses . $phones . $emails, $options);
 }
Example #4
0
 /**
  * Generates panel title for heading and footer.
  *
  * @param array $content the panel content settings.
  * @param string $type whether `heading` or `footer`
  *
  * @return string
  */
 protected static function getPanelTitle($content, $type)
 {
     $title = ArrayHelper::getValue($content, $type, '');
     if (!Enum::isEmpty($title)) {
         if (ArrayHelper::getValue($content, "{$type}Title", true) === true) {
             $title = static::tag("h3", $title, ["class" => "panel-title"]);
         }
         return static::tag("div", $title, ["class" => "panel-{$type}"]) . "\n";
     } else {
         return '';
     }
 }
Example #5
0
Modal::begin(['header' => '<h3>' . Yii::t('igolf', 'Repeat Event') . '</h3>', 'id' => 'recurrence-modal']);
?>
<div class="recurrence-form">

	<?php 
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 12, 'attributes' => ['frequency' => ['label' => Yii::t('igolf', 'Recurrence'), 'type' => Form::INPUT_DROPDOWN_LIST, 'items' => Recurrence::getLocalizedConstants('FREQUENCY_'), 'columnOptions' => ['colspan' => 4]], 'interval' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => TouchSpin::className(), 'options' => ['pluginOptions' => ['initval' => 1, 'min' => 1, 'max' => 30]], 'columnOptions' => ['colspan' => 4]], 'repeat' => ['label' => Yii::t('igolf', 'every'), 'type' => Form::INPUT_STATIC, 'columnOptions' => ['colspan' => 4]]]]);
echo '<div class="recurrence_byweekday">';
echo $form->field($model, 'byweekday')->checkboxButtonGroup(Enum::dayList())->label(false);
echo '</div>';
echo '<div class="recurrence_bymonth">';
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 12, 'attributes' => ['option' => ['type' => Form::INPUT_RADIO_LIST, 'items' => ['bymonthday' => Yii::t('igolf', 'on day')], 'columnOptions' => ['colspan' => 2], 'label' => false], 'bymonthday' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Enum::dateList(1, 31), 'columnOptions' => ['colspan' => 2], 'label' => false]]]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 12, 'attributes' => ['option' => ['type' => Form::INPUT_RADIO_LIST, 'items' => ['byposday' => Yii::t('igolf', 'on the')], 'columnOptions' => ['colspan' => 2], 'label' => false], 'bypos4month' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Recurrence::getLocalizedConstants('POSITION_'), 'columnOptions' => ['colspan' => 4], 'label' => false], 'weekday4month' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Enum::dayList() + Recurrence::getLocalizedConstants('DAY_'), 'columnOptions' => ['colspan' => 4], 'label' => false]]]);
echo '</div>';
echo '<div class="recurrence_byyear">';
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 12, 'attributes' => ['option' => ['type' => Form::INPUT_RADIO_LIST, 'items' => ['bymonth' => Yii::t('igolf', 'on')], 'columnOptions' => ['colspan' => 2], 'label' => false], 'bymonth' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Enum::monthList(), 'columnOptions' => ['colspan' => 4], 'label' => false], 'monthday4year' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Enum::dateList(1, 31), 'columnOptions' => ['colspan' => 2], 'label' => false]]]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 12, 'attributes' => ['option' => ['type' => Form::INPUT_RADIO_LIST, 'items' => ['byposmonth' => Yii::t('igolf', 'on the')], 'columnOptions' => ['colspan' => 2], 'label' => false], 'bypos4year' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Recurrence::getLocalizedConstants('POSITION_'), 'columnOptions' => ['colspan' => 3], 'label' => false], 'weekday4year' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Enum::dayList() + Recurrence::getLocalizedConstants('DAY_'), 'columnOptions' => ['colspan' => 3], 'label' => false], 'month4year' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Enum::monthList(), 'columnOptions' => ['colspan' => 4], 'label' => false]]]);
echo '</div>';
echo '<div class="recurrence_until">';
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 12, 'attributes' => ['until' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => Recurrence::getLocalizedConstants('UNTIL_'), 'columnOptions' => ['colspan' => 4]], 'count' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => TouchSpin::className(), 'options' => ['pluginOptions' => ['initval' => 1, 'min' => 1, 'max' => 20]], 'columnOptions' => ['colspan' => 4]], 'date_end' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => DatePicker::className(), 'options' => ['pluginOptions' => ['format' => 'yyyy/mm/dd', 'todayHighlight' => true]], 'columnOptions' => ['colspan' => 4], 'label' => Yii::t('igolf', 'End Date')]]]);
echo '</div>';
?>

	<div class="form-group">
	    <?php 
echo Html::button(Yii::t('igolf', 'Cancel'), ['class' => 'btn btn-danger', 'data' => ['dismiss' => 'modal']]);
?>
	    <?php 
echo Html::button(Yii::t('igolf', 'OK'), ['class' => 'btn btn-success action-ok', 'data' => ['dismiss' => 'modal']]);
?>
	</div>
Example #6
0
 public function data($status = 0)
 {
     $output = '';
     $models = $this->records($status);
     $num = 0;
     if ($models) {
         foreach ($models as $model) {
             $checked = $model->status == 1 ? "checked" : "";
             $output .= '<li>
             <!-- drag handle -->
             <span class="handle">
                 <i class="fa fa-ellipsis-v"></i>
                 <i class="fa fa-ellipsis-v"></i>
             </span>
             <!-- checkbox -->
             <input type="checkbox" ' . $checked . ' class="todolistCheck" value="' . $model->id . '" name="list"/>
             <!-- todo text -->
             <span class="text">' . $model->title . '</span>
             <!-- Emphasis label -->
             <small class="label label-' . self::$labels[$num] . '"><i class="fa fa-clock-o"></i>' . \kartik\helpers\Enum::timeElapsed($model->createDate) . '</small>
             <!-- General tools such as edit or delete-->
             <div class="tools">
                 <i class="fa fa-edit"></i>
                 <i class="fa fa-trash-o"></i>
             </div>
         </li>';
             $num++;
         }
     }
     return $output;
 }
Example #7
0
 /**
  * Helper to convert expiry time left from now
  *
  * @param string $type the expiry time type
  * @param int    $seconds the time left in seconds
  *
  * @return string
  */
 public static function timeLeft($type, $seconds)
 {
     if ($seconds > 0) {
         return Yii::t('user', 'The {type} link will expire in {time} from now.', ['type' => $type, 'time' => Enum::timeInterval($seconds, '')]);
     }
     return '';
 }