Beispiel #1
0
 /**
  * Добавляем обрамление div
  * @param ClientInterface $client
  * @param null $text
  * @param array $htmlOptions
  * @throws InvalidConfigException
  */
 public function clientLink($client, $text = null, array $htmlOptions = [])
 {
     echo Html::beginTag('div', ['class' => $this->clientCssClass, 'style' => 'float: left; padding-right: 20px;']);
     $text = Html::tag('span', $text, ['class' => 'auth-icon ' . $client->getName()]);
     if (!array_key_exists('class', $htmlOptions)) {
         $htmlOptions['class'] = 'auth-link ' . $client->getName();
     }
     $viewOptions = $client->getViewOptions();
     if (empty($viewOptions['widget'])) {
         if ($this->popupMode) {
             if (isset($viewOptions['popupWidth'])) {
                 $htmlOptions['data-popup-width'] = $viewOptions['popupWidth'];
             }
             if (isset($viewOptions['popupHeight'])) {
                 $htmlOptions['data-popup-height'] = $viewOptions['popupHeight'];
             }
         }
         echo Html::a($text, $this->createClientUrl($client), $htmlOptions) . '<br>';
     } else {
         $widgetConfig = $viewOptions['widget'];
         if (!isset($widgetConfig['class'])) {
             throw new InvalidConfigException('Widget config "class" parameter is missing');
         }
         /* @var $widgetClass Widget */
         $widgetClass = $widgetConfig['class'];
         if (!is_subclass_of($widgetClass, AuthChoiceItem::className())) {
             throw new InvalidConfigException('Item widget class must be subclass of "' . AuthChoiceItem::className() . '"');
         }
         unset($widgetConfig['class']);
         $widgetConfig['client'] = $client;
         $widgetConfig['authChoice'] = $this;
         echo $widgetClass::widget($widgetConfig);
     }
     echo Html::endTag('div');
 }
Beispiel #2
0
 public function clientLink($client, $text = null, array $htmlOptions = [])
 {
     if (!array_key_exists('class', $htmlOptions)) {
         $htmlOptions['class'] = $client->getName();
         $htmlOptions['data-original-title'] = $client->getName();
     }
     $viewOptions = $client->getViewOptions();
     if (empty($viewOptions['widget'])) {
         if ($this->popupMode) {
             if (isset($viewOptions['popupWidth'])) {
                 $htmlOptions['data-popup-width'] = $viewOptions['popupWidth'];
             }
             if (isset($viewOptions['popupHeight'])) {
                 $htmlOptions['data-popup-height'] = $viewOptions['popupHeight'];
             }
         }
         echo Html::a('', $this->createClientUrl($client), $htmlOptions);
     } else {
         $widgetConfig = $viewOptions['widget'];
         if (!isset($widgetConfig['class'])) {
             throw new InvalidConfigException('Widget config "class" parameter is missing');
         }
         /* @var $widgetClass Widget */
         $widgetClass = $widgetConfig['class'];
         if (!is_subclass_of($widgetClass, AuthChoiceItem::className())) {
             throw new InvalidConfigException('Item widget class must be subclass of "' . AuthChoiceItem::className() . '"');
         }
         unset($widgetConfig['class']);
         $widgetConfig['client'] = $client;
         $widgetConfig['authChoice'] = $this;
         echo $widgetClass::widget($widgetConfig);
     }
 }
Beispiel #3
0
 /**
  * Outputs client auth link.
  * @param ClientInterface $client external auth client instance.
  * @param string $text link text, if not set - default value will be generated.
  * @param array $htmlOptions link HTML options.
  * @return string generated HTML.
  * @throws InvalidConfigException on wrong configuration.
  */
 public function clientLink($client, $text = null, array $htmlOptions = [])
 {
     $viewOptions = $client->getViewOptions();
     if (empty($viewOptions['widget'])) {
         if ($text === null) {
             $text = Html::tag('span', '', ['class' => 'auth-icon ' . $client->getName()]);
         }
         if (!isset($htmlOptions['class'])) {
             $htmlOptions['class'] = $client->getName();
         }
         if (!isset($htmlOptions['title'])) {
             $htmlOptions['title'] = $client->getTitle();
         }
         Html::addCssClass($htmlOptions, ['widget' => 'auth-link']);
         if ($this->popupMode) {
             if (isset($viewOptions['popupWidth'])) {
                 $htmlOptions['data-popup-width'] = $viewOptions['popupWidth'];
             }
             if (isset($viewOptions['popupHeight'])) {
                 $htmlOptions['data-popup-height'] = $viewOptions['popupHeight'];
             }
         }
         return Html::a($text, $this->createClientUrl($client), $htmlOptions);
     }
     $widgetConfig = $viewOptions['widget'];
     if (!isset($widgetConfig['class'])) {
         throw new InvalidConfigException('Widget config "class" parameter is missing');
     }
     /* @var $widgetClass Widget */
     $widgetClass = $widgetConfig['class'];
     if (!is_subclass_of($widgetClass, AuthChoiceItem::className())) {
         throw new InvalidConfigException('Item widget class must be subclass of "' . AuthChoiceItem::className() . '"');
     }
     unset($widgetConfig['class']);
     $widgetConfig['client'] = $client;
     $widgetConfig['authChoice'] = $this;
     return $widgetClass::widget($widgetConfig);
 }