Example #1
2
 /**
  * @inheritdoc
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     }
     if ($this->type == static::TYPE_TEXT) {
         if ($this->hasModel()) {
             echo \CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
         } else {
             echo \CHtml::textField($name, $this->value, $this->htmlOptions);
         }
     } elseif ($this->type == static::TYPE_SELECT) {
         if ($this->hasModel()) {
             echo \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
         } else {
             echo \CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
         }
     } else {
         throw new \CException("Invalid field type '{$this->type}'");
     }
     $options = !empty($this->options) ? \CJavaScript::encode($this->options) : '';
     $script = "jQuery('#{$id}').select2({$options})";
     foreach ($this->events as $event => $handler) {
         $script .= ".on('{$event}'," . \CJavaScript::encode($handler) . ")";
     }
     $script .= ';';
     \Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $this->getId(), $script);
     $this->registerAssets();
 }
Example #2
1
 /**
  * (non-PHPdoc)
  * @see CPortlet::renderContent()
  */
 protected function renderContent()
 {
     $themesList = array_combine(Yii::app()->themeManager->themeNames, Yii::app()->themeManager->themeNames);
     echo CHtml::form('', 'post', array());
     echo CHtml::dropDownList('themeSelector', Yii::app()->theme->name, $themesList, $this->dropDownOptions);
     echo CHtml::endForm();
 }
Example #3
0
    public function stoppage()
    {
        //needs to have!
        $months = array();
        for ($i = 1; $i <= 12; $i++) {
            $tmp = sprintf("%02d", $i);
            $months[$tmp] = $tmp;
        }
        $years = array();
        for ($i = 0; $i < 8; $i++) {
            $tmp = sprintf("%02d", date("y") + $i);
            $years[$tmp] = $tmp;
        }
        $monthSelect = CHtml::dropDownList('bill[mm]', 0, $months);
        $yearSelect = CHtml::dropDownList('bill[yy]', 0, $years);
        return '
	<form id="billForm" method="post" action="' . Yii::app()->createUrl('/payment/bill') . '">
                <input type="hidden" id="Payment_id" name="Payment[id]" value="' . $this->type . '">
                <label>Card Number:</label>
                <input id="billcreditCard" name="bill[creditCard]" />
                <label>Expiration Date:</label>
                ' . $monthSelect . '/' . $yearSelect . '<br />
                <label>CVV:</label>
                <input id="billCvv2" name="bill[cvv2]" />
                <label>ID:</label>
                <input id="billId" name="bill[id]" />
                <label>Sum:</label>
                <input id="billTotal" name="bill[total]" readonly value="' . $this->sum . '">
                
                <a href="javascript:sendBill();" class="btn btn-primary">Bill</a>
                
                <div id=""></div>
	</form>';
    }
 public function run()
 {
     if (!isset($this->htmlOptions['id'])) {
         $this->htmlOptions['id'] = $this->id;
     }
     echo CHtml::dropDownList($this->name, $this->select, $this->data, $this->htmlOptions);
 }
Example #5
0
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     } else {
         $this->htmlOptions['name'] = $name;
     }
     $l = Language::loadConfig();
     $data = array();
     foreach ($l['languages'] as $k => $v) {
         $data[$k] = Yii::t('languages', $v);
     }
     if ($this->empty) {
         $data = array_merge(array('' => Yii::t('cms', $this->empty)), $data);
     }
     if ($this->hasModel()) {
         echo CHtml::activeDropDownList($this->model, $this->attribute, $data, $this->htmlOptions);
     } else {
         echo CHtml::dropDownList($name, $this->value, $data, $this->htmlOptions);
     }
 }
Example #6
0
 /**
  * Retrieves all cards in a particular category
  * @param  string $id The category id
  */
 public function actionGetCardsByCategory($id = NULL)
 {
     if ($id === NULL) {
         throw new CHttpException(400, Yii::t('Dashboard.main', 'Missing category id'));
     }
     $categories = Yii::app()->cache->get('cards_in_category');
     if ($categories === false) {
         $this->getCards();
         $categories = Yii::app()->cache->get('cards_in_category');
     }
     $cards = $categories[$id];
     $elements = $elementOptions = array();
     // TODO: Fix multiple select
     //$elementOptions['multiple'] = 'multiple';
     foreach ($cards as $k => $card) {
         $asset = Yii::app()->assetManager->publish(YiiBase::getPathOfAlias($card['path']), true, -1, YII_DEBUG);
         $elements[] = $k;
         $elementOptions['options'][] = array('value' => $k, 'data-img-src' => Yii::app()->getBaseUrl(true) . $asset . '/default.png');
     }
     $form = $this->beginWidget('ext.cii.widgets.CiiActiveForm', array('htmlOptions' => array('class' => 'pure-form pure-form-aligned item-selection-form')));
     echo CHtml::openTag('div', array('class' => 'pure-form-group', 'style' => 'padding-bottom: 20px'));
     echo CHtml::link(Yii::t('Dashboard.main', 'Add to Dashboard'), '#', array('id' => 'add-cards-button', 'class' => 'pure-button pure-button-link pure-button-primary pull-right pure-button-small', 'style' => 'position: absolute; top: 15px; right: 3%;'));
     echo CHtml::tag('legend', array(), $id);
     echo CHtml::dropDownList('card', NULL, $elements, $elementOptions);
     echo CHtml::closeTag('div');
     $this->endWidget();
 }
Example #7
0
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     if (isset($this->htmlOptions['id'])) {
         $id = $this->htmlOptions['id'];
     } else {
         $this->htmlOptions['id'] = $id;
     }
     if (isset($this->htmlOptions['name'])) {
         $name = $this->htmlOptions['name'];
     }
     if (isset($this->settings['ajax'])) {
         if (isset($this->model)) {
             echo CHtml::textField($name, $this->model->{$this->attribute}, $this->htmlOptions);
         } else {
             echo CHtml::textField($name, $this->value, $this->htmlOptions);
         }
     } else {
         if (isset($this->model)) {
             echo CHtml::dropDownList($name, $this->model->{$this->attribute}, $this->data, $this->htmlOptions);
         } else {
             echo CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
         }
     }
     $this->registerScripts($id);
 }
Example #8
0
 /**
  * @param $attribute
  * @param null $value
  * @param null $name
  * @param array $htmlOptions
  * @return mixed|null|string
  */
 public static function renderField($attribute, $value = null, $name = null, $htmlOptions = [])
 {
     $name = $name ?: 'Attribute[' . $attribute->id . ']';
     switch ($attribute->type) {
         case Attribute::TYPE_SHORT_TEXT:
             return CHtml::textField($name, $value, $htmlOptions);
             break;
         case Attribute::TYPE_TEXT:
             return Yii::app()->getController()->widget(Yii::app()->getModule('store')->getVisualEditor(), ['name' => $name, 'value' => $value], true);
             break;
         case Attribute::TYPE_DROPDOWN:
             $data = CHtml::listData($attribute->options, 'id', 'value');
             return CHtml::dropDownList($name, $value, $data, array_merge($htmlOptions, ['empty' => '---']));
             break;
         case Attribute::TYPE_CHECKBOX_LIST:
             $data = CHtml::listData($attribute->options, 'id', 'value');
             return CHtml::checkBoxList($name . '[]', $value, $data, $htmlOptions);
             break;
         case Attribute::TYPE_CHECKBOX:
             return CHtml::checkBox($name, $value, CMap::mergeArray(['uncheckValue' => 0], $htmlOptions));
             break;
         case Attribute::TYPE_NUMBER:
             return CHtml::numberField($name, $value, $htmlOptions);
             break;
         case Attribute::TYPE_FILE:
             return CHtml::fileField($name . '[name]', null, $htmlOptions);
             break;
     }
     return null;
 }
 public function run()
 {
     list($this->name, $this->id) = $this->resolveNameId();
     if (isset($this->htmlOptions['placeholder'])) {
         $this->options['placeholder'] = $this->htmlOptions['placeholder'];
     }
     $data = array();
     if (isset($this->options['placeholder'])) {
         $data[''] = '';
     }
     $this->data = $data + $this->data;
     if ($this->hasModel()) {
         echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
     } else {
         $this->htmlOptions['id'] = $this->id;
         echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
     }
     $bu = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets/');
     $cs = Yii::app()->clientScript;
     $cs->registerCssFile($bu . '/select2.css');
     if ($this->scriptPosition === null) {
         $this->scriptPosition = $cs->coreScriptPosition;
     }
     $cs->registerScriptFile($bu . '/select2.js', $this->scriptPosition);
     $options = $this->options ? CJavaScript::encode($this->options) : '';
     $cs->registerScript(__CLASS__ . '#' . $this->id, "\$('#{$this->id}').select2({$options});");
 }
Example #10
0
 private function procesarListaPartidos($postJugadorApi, $postJugadorLocal, $postTorneo, &$listaPartidos)
 {
     $selectTorneos = Torneo::model()->selectTorneos();
     $peticionPartidos = ApiChallonge::getPartidoTorneo($postTorneo['idTorneo']);
     $lengthJugadores = count($postJugadorApi);
     for ($i = 0; $i < $lengthJugadores; $i++) {
         $jugadorApi = $postJugadorApi[$i];
         $jugadorLocal = $postJugadorLocal['jugadorId'][$i];
         $idTorneoLocal = $postJugadorLocal['idTorneoVzla'];
         $posicionJugadorLocal = $postJugadorLocal['posicionJugador'][$i];
         $peticionPartidos = str_replace($jugadorApi, $jugadorLocal, $peticionPartidos);
         $posicionJugador = new JugadorPosicionTorneo();
         $posicionJugador->id_jugador = $jugadorLocal;
         $posicionJugador->id_torneo = $idTorneoLocal;
         $posicionJugador->posicion = $posicionJugadorLocal;
         $posicionJugador->save();
     }
     $jsonPartidos = json_decode($peticionPartidos, true);
     $i = 0;
     foreach ($jsonPartidos as $key => $value) {
         $match = $value['match'];
         $player1Id = $match['player1_id'];
         $player2Id = $match['player2_id'];
         $winnerId = $match['winner_id'];
         $ronda = $match['identifier'];
         $numeroRonda = $match['round'];
         $jugadorVzla1 = Jugador::model()->findByPk($player1Id);
         $jugadorVzla2 = Jugador::model()->findByPk($player2Id);
         $ganadorVzla = Jugador::model()->findByPk($winnerId);
         $listaPartidos .= $this->renderPartial('_listaPartidos', array('jsonPartidos' => $jsonPartidos, 'player1Id' => $player1Id, 'player2Id' => $player2Id, 'winnerId' => $winnerId, 'ronda' => $ronda, 'numeroRonda' => $numeroRonda, 'jugadorVzla1' => $jugadorVzla1, 'jugadorVzla2' => $jugadorVzla2, 'ganadorVzla' => $ganadorVzla, 'i' => $i), true, false);
         $i++;
     }
     $listaPartidos .= Chtml::label('ID Torneo SSBMVZLA', 'ResultadoPvP_idTorneoVzla') . '<br/>' . CHtml::dropDownList('ResultadoPvP[idTorneoVzla]', '', $selectTorneos, array('empty' => '')) . '<br/>';
 }
Example #11
0
 public function renderPagerList()
 {
     if (!$this->enablePagination) {
         return;
     }
     if (isset($this->pagerlist['all'])) {
         $t = $this->pagerlist;
         $this->pagerlist = array();
         foreach ($t as $k => $v) {
             if ($k == 'all') {
                 $this->pagerlist[$this->dataProvider->getTotalItemCount()] = Yii::t('zii', $v);
             } else {
                 $this->pagerlist[$k] = $v;
             }
         }
     }
     $controller = $this->getController();
     $route = $controller->route;
     $parameters = $_GET;
     unset($parameters['pageSize']);
     $parameters['page'] = $this->dataProvider->getPagination()->getCurrentPage() + 1;
     $parameters['pageSize'] = '';
     $url = $controller->createUrl($route, $parameters);
     $id = parent::getId();
     echo '<div class="' . $this->pagerlistCssClass . '">';
     echo CHtml::dropDownList($id . '_pagerlist', $this->dataProvider->pagination->pageSize, $this->pagerlist, array('onchange' => $id . "_changePageSize(\"{$id}\",\"{$url}\")"));
     echo '<span>' . Yii::t('zii', $this->textItemsPerPage) . '</span>';
     echo '</div>';
 }
    public function run()
    {
        if (Yii::app()->user->isGuest) {
            return;
        }
        $powerAdmin = array('sagittaros', 'yiseng', 'yugene');
        $username = Yii::app()->user->id;
        if (in_array($username, $powerAdmin)) {
            $solr = new Solr('search-engine');
            $res = $solr->query('id:"' . $this->dealUrl . '"');
            $docs = $res->response->docs;
            if (array_key_exists(0, $docs)) {
                $options = array('Eateries' => 'Eateries', 'Fun & Activities' => 'Fun & Activities', 'Beauty & Wellness' => 'Beauty & Wellness', 'Goods' => 'Goods', 'Services & Others' => 'Services & Others', 'Travel' => 'Travel');
                $ajaxScript = <<<EOD
jQuery.get('/admin/dealCrud/updateCategory',
    {'id':'{$this->dealUrl}','category':jQuery(this).val()},
    postUpdateCategoryAction
); 

function postUpdateCategoryAction(data) {
    if(data == 'SUCCESS'){
        console.log("success");
        alert('success');
    } else {
        console.log(data);
        alert("update failed");
    }
}

EOD;
                $htmlOptions = array('onchange' => $ajaxScript);
                echo CHtml::dropDownList('category', $res->response->docs[0]->category_raw, $options, $htmlOptions);
            }
        }
    }
 /**
  * (non-PHPdoc)
  * @see CPortlet::renderContent()
  */
 protected function renderContent()
 {
     $translations = self::getLanguagesList();
     echo CHtml::form('', 'post', array());
     echo CHtml::dropDownList('languageSelector', Yii::app()->getLanguage(), $translations, $this->dropDownOptions);
     echo CHtml::endForm();
 }
Example #14
0
 public function run()
 {
     Yii::app()->user->setState('pageSize', $this->mPageSize);
     $this->mPageSize = null == $this->mPageSize ? $this->mDefPageSize : $this->mPageSize;
     echo '# rows per page: ';
     echo CHtml::dropDownList('pageSize', $this->mPageSize, $this->mPageSizeOptions, array('onchange' => "\$.fn.yiiGridView.update('{$this->mGridId}',{ data:{pageSize: \$(this).val() }})"));
 }
Example #15
0
function renderVariation($variation, $i)
{
    if (!ProductSpecification::model()->findByPk(1)) {
        return false;
    }
    if (!$variation) {
        $variation = new ProductVariation();
        $variation->specification_id = 1;
    }
    $str = '<tr> <td>';
    $str .= CHtml::dropDownList("Variations[{$i}][specification_id]", $variation->specification_id, CHtml::listData(ProductSpecification::model()->findall(), "id", "title"), array('empty' => '-'));
    $str .= '</td> <td>';
    $str .= CHtml::textField("Variations[{$i}][title]", $variation->title);
    $str .= '</td> <td>';
    // Price adjustion
    $str .= CHtml::dropDownList("Variations[{$i}][sign_price]", $variation->price_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-'));
    $str .= '</td> <td>';
    $str .= CHtml::textField("Variations[{$i}][price_adjustion]", abs($variation->price_adjustion), array('size' => 5));
    // Weight adjustion
    $str .= '</td> <td>';
    $str .= CHtml::dropDownList("Variations[{$i}][sign_weight]", $variation->weight_adjustion >= 0 ? '+' : '-', array('+' => '+', '-' => '-'));
    $str .= '</td> <td>';
    $str .= CHtml::textField("Variations[{$i}][weight_adjustion]", abs($variation->weight_adjustion), array('size' => 5));
    $str .= '</td> <td>';
    for ($j = -10; $j <= 10; $j++) {
        $positions[$j] = $j;
    }
    $str .= CHtml::dropDownList("Variations[{$i}][position]", $variation->position, $positions);
    $str .= '</td></tr>';
    return $str;
}
Example #16
0
 /**
  * Renders the multiselect field
  */
 public function renderField()
 {
     if ($this->hasModel()) {
         echo \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->options);
     } else {
         echo \CHtml::dropDownList($this->name, $this->value, $this->data, $this->options);
     }
 }
Example #17
0
 /**
  * Renders the select2 field
  */
 public function renderField()
 {
     if ($this->hasModel()) {
         echo $this->asDropDownList ? \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->options) : \CHtml::activeHiddenField($this->model, $this->attribute);
     } else {
         echo $this->asDropDownList ? \CHtml::dropDownList($this->options['name'], $this->value, $this->data, $this->options) : \CHtml::hiddenField($this->options['name'], $this->value);
     }
 }
Example #18
0
 public function renderScreenNameSelector()
 {
     $options = array();
     foreach ($this->getModelTwitterAliases() as $alias) {
         $options[$alias->alias] = $alias->alias;
     }
     echo CHtml::dropDownList('screenName', null, $options, array('class' => 'x2-minimal-select', 'id' => 'screen-name-selector'));
 }
 /**
  * Called by X2GridView's init () method to set the summaryText property. This method allows
  * the results per page drop down to display/set the results per page for an individual 
  * sortable widget
  */
 public function setSummaryTextForSortableWidgets()
 {
     $widgetClass = get_class($this->owner->sortableWidget);
     $resultsPerPage = $widgetClass::getJSONProperty($this->owner->sortableWidget->profile, 'resultsPerPage', $this->owner->sortableWidget->widgetType, $this->owner->sortableWidget->widgetUID);
     // add a dropdown to the summary text that let's user set how many rows to show on each page
     $this->owner->summaryText = '<span class="grid-summary-container" style="' . ($this->owner->hideSummary ? 'display: none;' : '') . '">' . Yii::t('app', '<b>{start}&ndash;{end}</b> of <b>{count}</b>') . '<div class="form no-border" style="display:inline;">' . CHtml::dropDownList($widgetClass . 'resultsPerPage', $resultsPerPage, $this->owner->getPossibleResultsPerPageFormatted(), array('class' => 'x2-minimal-select', 'onchange' => '$.ajax ({' . 'data: {' . 'key: "resultsPerPage",' . 'value: $(this).val(),' . 'widgetClass: "' . get_class($this->owner->sortableWidget) . '",' . 'widgetType: "' . $this->owner->sortableWidget->widgetType . '",' . 'widgetUID: "' . $this->owner->sortableWidget->widgetUID . '"' . '},' . 'type: "POST",' . 'url: "' . Yii::app()->controller->createUrl('/profile/setWidgetSetting') . '",' . 'complete: function (response) {' . 'x2.DEBUG && console.log ("setResultsPerPage after ajax");' . '$.fn.yiiGridView.update("' . $this->owner->id . '", {' . (isset($this->owner->modelName) ? 'data: {' . $this->owner->modelName . '_page: 1},' : '') . 'complete: function () {' . '}' . '});' . '}' . '});')) . '</div>
         </span>';
 }
 public function renderField()
 {
     $this->htmlOptions['multiple'] = 'multiple';
     if ($this->hasModel()) {
         echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
     } else {
         echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
     }
 }
function groupForm($role)
{
    ob_start();
    ?>
<table class="stdtable">
<tr>
    <td>
        <?php 
    echo CHtml::label(Yii::t('mc', 'Prefix'), 'prefix_' . $role);
    ?>
    </td>
    <td>
        <?php 
    echo CHtml::label(Yii::t('mc', 'Suffix'), 'suffix_' . $role);
    ?>
    </td>
    <td>
        <?php 
    echo CHtml::label(Yii::t('mc', 'Can Build'), 'build_' . $role);
    ?>
    </td>
</tr>
<tr>
    <td>
        <?php 
    echo CHtml::textField('prefix_' . $role, @$_POST['prefix_' . $role]);
    ?>
    </td>
    <td>
        <?php 
    echo CHtml::textField('suffix_' . $role, @$_POST['suffix_' . $role]);
    ?>
    </td>
    <td>
        <?php 
    echo CHtml::dropDownList('build_' . $role, @$_POST['build_' . $role], array(0 => Yii::t('mc', 'Yes'), 1 => Yii::t('mc', 'No')));
    ?>
    </td>
</tr>
<tr>
    <td colspan="3">
        <?php 
    echo CHtml::label(Yii::t('mc', 'Permissions, comma sepparated'), 'perms_' . $role);
    ?>
    </td>
</tr>
<tr>
    <td colspan="3">
        <?php 
    echo CHtml::textField('perms_' . $role, @$_POST['perms_' . $role], array('style' => 'width: 540px'));
    ?>
    </td>
</tr>
</table>
<?php 
    return ob_get_clean();
}
Example #22
0
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     if ($this->hasModel()) {
         echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
     } else {
         echo CHtml::dropDownList($name, $this->value, $this->data, $this->htmlOptions);
     }
 }
Example #23
0
 /**
  * Renders page size list
  */
 public function renderSizes()
 {
     if ($this->enablePageSizing) {
         echo CHtml::openTag('div', array('class' => 'grid-view-page-size'));
         echo 'Отображать по:';
         echo CHtml::dropDownList($this->id . '-page-size', $this->pageSize, $this->pageSizeList);
         echo CHtml::closeTag('div');
     }
 }
Example #24
0
 public function actionAjaxState()
 {
     $country = country::model()->findByPk($_POST['address']['address_country_ID']);
     if ($country && $country->contain_states == 1) {
         echo CHtml::dropDownList('address[address_state_ID]', '', state::items($country->country_ID), array('id' => 'state'));
     } else {
         echo CHtml::dropDownList('address[address_state_ID]', '', array(0 => '----------------------------------------'), array('id' => 'state'));
     }
 }
Example #25
0
    public function run()
    {
        if ($this->selector == null) {
            list($this->name, $this->id) = $this->resolveNameId();
            $this->selector = '#' . $this->id;
            if (isset($this->htmlOptions['placeholder'])) {
                $this->options['placeholder'] = $this->htmlOptions['placeholder'];
            }
            if (!isset($this->htmlOptions['multiple'])) {
                $data = array();
                if (isset($this->options['placeholder'])) {
                    $data[''] = '';
                }
                $this->data = $data + $this->data;
            }
            if ($this->hasModel()) {
                if (isset($this->options['ajax'])) {
                    echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
                } else {
                    echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions);
                }
            } elseif (!isset($this->options['ajax'])) {
                $this->htmlOptions['id'] = $this->id;
                echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions);
            } else {
                echo CHtml::hiddenField($this->name, $this->value, $this->htmlOptions);
            }
        }
        $bu = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets/');
        $cs = Yii::app()->clientScript;
        //$cs->registerCssFile($bu . '/select2.css');
        if (YII_DEBUG) {
            $cs->registerScriptFile($bu . '/select2.js');
        } else {
            $cs->registerScriptFile($bu . '/select2.min.js');
        }
        if ($this->sortable) {
            $cs->registerCoreScript('jquery.ui');
        }
        $options = CJavaScript::encode(CMap::mergeArray($this->defaultOptions, $this->options));
        ob_start();
        echo "jQuery('{$this->selector}').select2({$options})";
        foreach ($this->events as $event => $handler) {
            echo ".on('{$event}', " . CJavaScript::encode($handler) . ")";
        }
        echo ';';
        if ($this->sortable) {
            echo <<<JavaScript
jQuery('{$this->selector}').select2("container").find("ul.select2-choices").sortable({
\tcontainment: 'parent',
\tstart: function() { jQuery('{$this->selector}').select2("onSortStart"); },
\tupdate: function() { jQuery('{$this->selector}').select2("onSortEnd"); }
});
JavaScript;
        }
        $cs->registerScript(__CLASS__ . '#' . $this->id, ob_get_clean());
    }
 protected function renderDataCellContent($row, $data)
 {
     if (Yii::app()->params['view_role'] == 'admin') {
         return;
     }
     $access = $data->getServerFtpAccess(Yii::app()->params['view_server_id']);
     $options = array('' => Yii::t('mc', 'No Access'), 'ro' => Yii::t('mc', 'Read only'), 'rw' => Yii::t('mc', 'Full access'));
     echo CHtml::dropDownList('ftpAccess_' . $data->id, $access, $options, array('ajax' => array('type' => 'POST', 'data' => array('ajax' => 'ftpAccess', 'user' => $data->id, Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken, 'ftpAccess' => "js:\$('#ftpAccess_" . $data->id . "').val()"), 'success' => 'js:function(e) {if(e)alert(e);}')));
     echo '&nbsp;&nbsp;&nbsp;' . CHtml::encode($data->name) . '.' . Yii::app()->params['view_server_id'];
 }
Example #27
0
 /**
  * Renders the select2 field
  */
 public function renderField()
 {
     list($name, $id) = $this->resolveNameID();
     TbArray::defaultValue('id', $id, $this->htmlOptions);
     TbArray::defaultValue('name', $name, $this->htmlOptions);
     if ($this->hasModel()) {
         echo $this->asDropDownList ? CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions) : CHtml::activeHiddenField($this->model, $this->attribute);
     } else {
         echo $this->asDropDownList ? CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions) : CHtml::hiddenField($this->name, $this->value);
     }
 }
 public function run()
 {
     $currencyActvie = Currency::getActiveCurrencyArray(2);
     $currentCharCode = Currency::getCurrentCurrencyModel()->char_code;
     foreach ($currencyActvie as $char_code => $currencyName) {
         echo CHtml::hiddenField($char_code, $this->getOwner()->createLangUrl(Yii::app()->language, array('currency' => $char_code)), array('id' => 'currency_' . $char_code));
     }
     echo CHtml::form();
     $class = Yii::app()->theme->name != 'classic' ? 'currency' : 'currency-drop';
     echo CHtml::dropDownList('currency', $currentCharCode, $currencyActvie, array('onchange' => 'this.form.action=$("#currency_"+this.value).val(); this.form.submit(); return false;', 'class' => $class));
     echo CHtml::endForm();
 }
Example #29
0
	/**
	 * Executes the widget.
	 * This overrides the parent implementation by displaying the generated page buttons.
	 */
	public function run()
	{
		if(($pageCount=$this->getPageCount())<=1)
			return;
		$pages=array();
		for($i=0;$i<$pageCount;++$i)
			$pages[$this->createPageUrl($i)]=$this->generatePageText($i);
		$selection=$this->createPageUrl($this->getCurrentPage());
		echo $this->header;
		echo CHtml::dropDownList($this->getId(),$selection,$pages,$this->htmlOptions);
		echo $this->footer;
	}
Example #30
-1
 public function run()
 {
     // here render procedures
     echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'target' => $this->target));
     // you better create a function but
     // for the sake of the example...
     foreach ($this->attributes as $attr) {
         // here we can actually say i
         // this is very simple but you get the idea
         echo CHtml::label($attr['label'], $attr['name']);
         if ($attr['type'] == 'text') {
             echo CHtml::textField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']);
         } else {
             if ($attr['type'] == 'textarea') {
                 echo CHtml::textArea($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']);
             } else {
                 if ($attr['type'] == 'password') {
                     echo CHtml::passwordField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']);
                 } else {
                     if ($attr['type'] == 'checkbox') {
                         echo CHtml::checkBox($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']);
                     } else {
                         if ($attr['type'] == 'checkboxlist') {
                             echo CHtml::checkBoxList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']);
                         } else {
                             if ($attr['type'] == 'date') {
                                 echo CHtml::dateField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']);
                             } else {
                                 if ($attr['type'] == 'dropdownlist') {
                                     echo CHtml::dropDownList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']);
                                 } else {
                                     if ($attr['type'] == 'file') {
                                         echo CHtml::fileField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']);
                                     } else {
                                         if ($attr['type'] == 'hidden') {
                                             echo CHtml::hiddenField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']);
                                         } else {
                                             if ($attr['type'] == 'radio') {
                                                 echo CHtml::radioButton($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']);
                                             } else {
                                                 if ($attr['type'] == 'radiolist') {
                                                     echo CHtml::radioButtonList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // do more here
     }
     echo "<br/><br/><div class='row-fluid'>";
     echo CHtml::submitButton($this->submit['label'], $this->submit['options']);
     echo "</div>";
     echo CHtml::endForm();
 }