Ejemplo n.º 1
0
 /**
  * Register plugin assets. Uses `kvIpInfo` jQuery plugin created by Krajee to refresh the IP information.
  */
 protected function registerAssets()
 {
     if (empty($this->noData)) {
         $noData = empty($this->ip) ? Yii::t('kvip', "No data found for the user's IP address.") : Yii::t('kvip', 'No data found for IP address {ip}.', ['ip' => '<kbd>' . $this->ip . '</kbd>']);
     } else {
         $noData = $this->noData;
     }
     $this->pluginOptions = ['flagWrapper' => $this->showFlag ? $this->flagWrapperOptions['id'] : false, 'flagOptions' => $this->flagOptions, 'fields' => empty($this->fields) ? array_keys($this->_defaultFields) : $this->fields, 'defaultFields' => $this->_defaultFields, 'url' => $this->api, 'noData' => self::renderTag($noData, $this->noDataOptions, 'div'), 'errorData' => empty($this->errorData) ? '' : self::renderTag($this->errorData, $this->errorDataOptions)];
     $this->registerPlugin('kvIpInfo');
     IpInfoAsset::register($this->getView());
 }
Ejemplo n.º 2
0
 /**
  * Register plugin assets. Uses `kvIpInfo` jQuery plugin created by Krajee to refresh the IP information.
  *
  * @param array $params
  */
 protected function registerAssets($params = [])
 {
     if (empty($this->noData)) {
         $noData = empty($this->ip) ? Yii::t('kvip', "No data found for the user's IP address.") : Yii::t('kvip', 'No data found for IP address {ip}.', ['ip' => '<kbd>' . $this->ip . '</kbd>']);
     } else {
         $noData = $this->noData;
     }
     $credits = '';
     if ($this->showCredits) {
         $label = ArrayHelper::remove($this->creditsOptions, 'label', Yii::t('kvip', 'Revalidate IP info'));
         $credits = Html::a($label, self::API_HOME, $this->creditsOptions);
     }
     $this->pluginOptions = ['fields' => empty($this->fields) ? array_keys($this->_defaultFields) : $this->fields, 'defaultFields' => $this->_defaultFields, 'url' => self::API_INFO, 'params' => $params, 'credits' => $credits, 'contentOptions' => $this->contentOptions, 'noData' => self::renderTag($noData, $this->noDataOptions, 'div'), 'errorData' => empty($this->errorData) ? '' : self::renderTag($this->errorData, $this->errorDataOptions)];
     $view = $this->getView();
     $this->registerPlugin('kvIpInfo');
     IpInfoAsset::register($view);
 }