/**
  * Test known contributor with avatar
  */
 public function testWithKnownContributorWithAvatar()
 {
     /* @var $contributor User */
     $contributor = $this->getModule('Yii2')->grabFixture('users', 'activeUser1');
     $contributor->avatar = 'test.jpg';
     $contributor->getAvatarUrl();
     $expectedString = '<span class="avatar avatar-test-avatar-size">' . '<img src="' . User::AVATAR_URL . 'test.jpg" alt="">' . '</span>';
     $result = ContributorAvatar::widget(['contributor' => $contributor, 'size' => 'test-avatar-size', 'asBlock' => false]);
     $this->assertEquals($expectedString, $result);
 }
Beispiel #2
0
 /**
  * Render widget without user model
  *
  * @param boolean $withAvatar Render avatar placeholder
  *
  * @return string
  */
 protected function renderSimple($withAvatar = true)
 {
     $ret = '';
     if ($withAvatar) {
         $ret .= ContributorAvatar::widget(['size' => $this->avatarSize]);
     }
     $ret .= Html::encode($this->contributor->getContributorName());
     if ($this->showEmail && ($email = $this->contributor->getContributorEmail()) !== false) {
         $ret .= ' &lt;' . Html::encode($email) . '&gt;';
     }
     return $ret;
 }
Beispiel #3
0
</div>
    <?php 
$form = ActiveForm::begin(['id' => $profileForm->formName(), 'enableAjaxValidation' => true, 'enableClientValidation' => true, 'validateOnBlur' => false, 'options' => ['enctype' => 'multipart/form-data']]);
?>
    <div class="panel-body">
        <?php 
echo $form->field($profileForm, 'email')->staticControl();
?>
        <?php 
echo $form->field($profileForm, 'name')->textInput();
?>
        <?php 
if (($avatarUrl = $profileForm->getAvatarUrl()) !== false) {
    ?>
            <?php 
    $img = ContributorAvatar::widget(['contributor' => $profileForm, 'size' => 'normal', 'asBlock' => true]);
    $deleteField = $form->field($profileForm, 'deleteAvatar')->checkbox();
    $field = $form->field($profileForm, 'uploadedAvatar', ['template' => '{label}{img}{checkbox}{input}{error}'])->fileInput();
    $field->parts['{img}'] = $img;
    $field->parts['{checkbox}'] = $deleteField;
    echo $field;
    ?>
        <?php 
} else {
    ?>
            <?php 
    echo $form->field($profileForm, 'uploadedAvatar')->fileInput();
    ?>
        <?php 
}
?>