Exemplo n.º 1
0
 public function renderInput(CModel $model, $attribute, array $htmlOptions = array())
 {
     $action = new Actions();
     $action->setAttributes($model->getAttributes(), false);
     $defaultOptions = array('id' => $this->resolveId($attribute));
     $htmlOptions = X2Html::mergeHtmlOptions($defaultOptions, $htmlOptions);
     return preg_replace('/Actions(\\[[^\\]]*\\])/', get_class($this->formModel) . '$1', $action->renderInput($attribute, $htmlOptions));
 }
Exemplo n.º 2
0
 public function photoAttachmentsContainer(CModel $model, $attr, $uploadAttr, array $htmlOptions = array())
 {
     $htmlOptions = X2Html::mergeHtmlOptions(array('class' => 'photo-attachments-container'), $htmlOptions);
     $attachmentTags = array();
     foreach ($model->{$attr} as $attachment) {
         $attachmentTags[] = $this->photoAttachment($model, $uploadAttr, $attachment);
     }
     return CHtml::tag('div', $htmlOptions, implode("\n", $attachmentTags));
 }
Exemplo n.º 3
0
 public function run()
 {
     $this->htmlOptions = X2Html::mergeHtmlOptions($this->htmlOptions, array('id' => $this->namespace . "-multi-type-autocomplete-container"));
     if (isset($this->model)) {
         $selectAttr = $this->selectName;
         $this->selectValue = $this->model->{$selectAttr};
     }
     $this->render('_multiTypeAutocomplete');
 }
 /**
  * @return array the config array passed to widget ()
  */
 public function getGridViewConfig()
 {
     if (!isset($this->_gridViewConfig)) {
         $this->_gridViewConfig = array_merge(parent::getGridViewConfig(), array('possibleResultsPerPage' => array(5, 10, 20, 30, 40, 50, 75, 100), 'defaultGvSettings' => array('isActive' => 65, 'fullName' => 125, 'lastLogin' => 80, 'emailAddress' => 100), 'template' => CHtml::openTag('div', X2Html::mergeHtmlOptions(array('class' => 'page-title'), array('style' => !CPropertyValue::ensureBoolean($this->getWidgetProperty('showHeader')) && !CPropertyValue::ensureBoolean($this->getWidgetProperty('hideFullHeader')) ? 'display: none;' : ''))) . '<h2 class="grid-widget-title-bar-dummy-element">' . '</h2>{buttons}{filterHint}' . '{summary}{topPager}</div>{items}{pager}', 'includedFields' => array('tagLine', 'username', 'officePhone', 'cellPhone', 'emailAddress', 'googleId', 'isActive', 'leadRoutingAvailability'), 'specialColumns' => array('fullName' => array('name' => 'fullName', 'header' => Yii::t('profile', 'Full Name'), 'value' => 'CHtml::link(CHtml::encode($data->fullName),array("view","id"=>$data->id))', 'type' => 'raw'), 'lastLogin' => array('name' => 'lastLogin', 'header' => Yii::t('profile', 'Last Login'), 'value' => '$data->user ? ($data->user->lastLogin == 0 ? "" : ' . 'Formatter::formatDateDynamic ($data->user->lastLogin)) : ""', 'type' => 'raw'), 'isActive' => array('name' => 'isActive', 'header' => Yii::t('profile', 'Active'), 'value' => '"<span title=\'' . '".(Session::isOnline ($data->username) ? ' . '"' . Yii::t('profile', 'Active User') . '" : "' . Yii::t('profile', 'Inactive User') . '")."\'' . ' class=\'".(Session::isOnline ($data->username) ? ' . '"active-indicator" : "inactive-indicator")."\'></span>"', 'type' => 'raw'), 'username' => array('name' => 'username', 'header' => Yii::t('profile', 'Username'), 'value' => '$data->user ? CHtml::encode($data->user->alias) : ""', 'type' => 'raw'), 'leadRoutingAvailability' => array('name' => 'leadRoutingAvailability', 'header' => Yii::t('profile', 'Lead Routing Availability'), 'value' => 'CHtml::encode($data->leadRoutingAvailability ? 
                             Yii::t("profile", "Available") :
                             Yii::t("profile", "Unavailable"))', 'type' => 'raw')), 'enableControls' => false));
     }
     return $this->_gridViewConfig;
 }
Exemplo n.º 5
0
 protected function generateColumns()
 {
     $unsortedColumns = array();
     foreach ($this->columns as &$column) {
         $name = isset($column['name']) ? $column['name'] : '';
         if (!isset($column['id'])) {
             if (isset($column['class']) && is_subclass_of($column['class'], 'CCheckboxColumn')) {
                 $column['id'] = $this->namespacePrefix . 'C_gvCheckbox' . $name;
             } else {
                 $column['id'] = $this->namespacePrefix . 'C_' . $name;
             }
         } else {
             $column['id'] = $this->namespacePrefix . $column['id'];
         }
         if (!isset($this->gvSettings[$name])) {
             if ($name === 'gvCheckbox') {
                 $column = $this->getGvCheckboxColumn(null, $column);
             }
             $unsortedColumns[] = $column;
             continue;
         }
         $width = $this->gvSettings[$name];
         $width = $this->formatWidth($width);
         if ($width) {
             $column['headerHtmlOptions'] = array_merge(isset($column['headerHtmlOptions']) ? $column['headerHtmlOptions'] : array(), array('style' => 'width:' . $width . ';'));
             $column['htmlOptions'] = X2Html::mergeHtmlOptions(isset($column['htmlOptions']) ? $column['htmlOptions'] : array(), array('width' => $width));
         }
     }
     unset($column);
     // unset lingering reference
     if (isset($this->gvSettings['gvControls']) && $this->enableControls) {
         $width = $this->gvSettings['gvControls'];
         $width = !empty($width) && is_numeric($width) ? $width : null;
         $this->columns[] = $this->getGvControlsColumn($width);
     }
     if (isset($this->gvSettings['gvCheckBox'])) {
         $width = $this->gvSettings['gvCheckBox'];
         $width = !empty($width) && is_numeric($width) ? $width : null;
         $this->columns[] = $this->getGvCheckboxColumn($width);
     }
     if ($this->rememberColumnSort) {
         $sortedColumns = array();
         foreach ($this->gvSettings as $columnName => $width) {
             foreach ($this->columns as $column) {
                 $name = isset($column['name']) ? $column['name'] : '';
                 if ($name === $columnName) {
                     $sortedColumns[] = $column;
                     break;
                 }
             }
         }
         $this->columns = array_merge($sortedColumns, $unsortedColumns);
     }
 }
Exemplo n.º 6
0
 public function render()
 {
     if ($this->isSelected) {
         $this->htmlOptions = X2Html::mergeHtmlOptions($this->htmlOptions, array('class' => 'selected'));
     }
     $html = CHtml::openTag('li', $this->htmlOptions);
     $html .= CHtml::openTag('a', X2Html::mergeHtmlOptions(array('href' => $this->getHref()), $this->linkHtmlOptions));
     $html .= "<i class='icon " . lcfirst($this->getId()) . "'></i>";
     $html .= CHtml::encode($this->getTitle());
     $html .= '</a>';
     $html .= '</li>';
     return $html;
 }
Exemplo n.º 7
0
 /**
  * Like renderFilter, but with html attribute options
  * This method is Copyright (c) 2008-2014 by Yii Software LLC
  * http://www.yiiframework.com/license/ 
  */
 public function renderFilterWithOptions(array $htmlOptions = array())
 {
     if ($this->filter !== null) {
         /* x2modstart */
         echo CHtml::openTag('tr', X2Html::mergeHtmlOptions(array('class' => $this->filterCssClass), $htmlOptions)) . "\n";
         /* x2modend */
         foreach ($this->columns as $column) {
             $column->renderFilterCell();
         }
         echo "</tr>\n";
     }
 }
Exemplo n.º 8
0
 /**
  * Modified to add half-width tag and extra classes
  */
 public function getMainOptions()
 {
     $width = $this->halfWidth ? 'half-width' : '';
     return X2Html::mergeHtmlOptions(array('class' => "x2-layout detail-view {$width}", 'id' => $this->namespace . 'detail-view'), $this->htmlOptions);
 }
Exemplo n.º 9
0
 /**
  * Renders the content of a menu item.
  * Note that the container and the sub-menus are not rendered here.
  * @param array $item the menu item to be rendered. Please see {@link items} on what data might be in the item.
  * @since 0.6
  */
 protected function renderMenuItem($item)
 {
     if (isset($item['url'])) {
         $url = $item['url'];
         $params = array();
         if (!is_string($url)) {
             $route = $url[0];
             $params = array_splice($url, 1);
         }
         // absolute url needed for phonegap app
         $route = $this->getController()->createAbsoluteUrl($route, $params);
         //Yii::trace('url|route='.(is_string ($url) ? $url : 'Array').'|'.$route);
         $label = $this->linkLabelWrapper === null ? $item['label'] : '<' . $this->linkLabelWrapper . '>' . $item['label'] . '</' . $this->linkLabelWrapper . '>';
         $options = X2Html::mergeHtmlOptions(isset($item['left']) ? $this->leftOptions : $this->rightOptions, isset($item['linkOptions']) ? $item['linkOptions'] : array());
         return CHtml::link($label, $route, $options);
     }
 }
Exemplo n.º 10
0
    public static function renderModelInput(CModel $model, $field, $htmlOptions = array())
    {
        if (!$field->asa('CommonFieldsBehavior')) {
            throw new Exception('$field must have CommonFieldsBehavior');
        }
        if ($field->required) {
            if (isset($htmlOptions['class'])) {
                $htmlOptions['class'] .= ' x2-required';
            } else {
                $htmlOptions = array_merge(array('class' => 'x2-required'), $htmlOptions);
            }
        }
        $fieldName = $field->fieldName;
        if (!isset($field)) {
            return null;
        }
        switch ($field->type) {
            case 'text':
                return CHtml::activeTextArea($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), array_merge(array('encode' => false), $htmlOptions)));
            case 'date':
                $oldDateVal = $model->{$fieldName};
                $model->{$fieldName} = Formatter::formatDate($model->{$fieldName}, 'medium');
                Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $pickerOptions = array('dateFormat' => Formatter::formatDatePicker(), 'changeMonth' => false, 'changeYear' => true);
                if (Yii::app()->getLanguage() === 'fr') {
                    $pickerOptions['monthNamesShort'] = Formatter::getPlainAbbrMonthNames();
                }
                $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'date', 'options' => $pickerOptions, 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
                $model->{$fieldName} = $oldDateVal;
                return $input;
            case 'dateTime':
                $oldDateTimeVal = $model->{$fieldName};
                $pickerOptions = array('dateFormat' => Formatter::formatDatePicker('medium'), 'timeFormat' => Formatter::formatTimePicker(), 'ampm' => Formatter::formatAMPM(), 'changeMonth' => true, 'changeYear' => true);
                if (Yii::app()->getLanguage() === 'fr') {
                    $pickerOptions['monthNamesShort'] = Formatter::getPlainAbbrMonthNames();
                }
                $model->{$fieldName} = Formatter::formatDateTime($model->{$fieldName});
                Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'datetime', 'options' => $pickerOptions, 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
                $model->{$fieldName} = $oldDateTimeVal;
                return $input;
            case 'dropdown':
                // Note: if desired to translate dropdown options, change the seecond argument to
                // $model->module
                $om = $field->getDropdownOptions();
                $multi = (bool) $om['multi'];
                $dropdowns = $om['options'];
                $curVal = $multi ? CJSON::decode($model->{$field->fieldName}) : $model->{$field->fieldName};
                $ajaxArray = array();
                if ($field instanceof Fields) {
                    $dependencyCount = X2Model::model('Dropdowns')->countByAttributes(array('parent' => $field->linkType));
                    $fieldDependencyCount = X2Model::model('Fields')->countByAttributes(array('modelName' => $field->modelName, 'type' => 'dependentDropdown', 'linkType' => $field->linkType));
                    if ($dependencyCount > 0 && $fieldDependencyCount > 0) {
                        $ajaxArray = array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{
                                "val":$(this).val(),
                                "dropdownId":"' . $field->linkType . '",
                                "field":true, "module":"' . $field->modelName . '"
                            }', 'success' => '
                                function(data){
                                    if(data){
                                        data=JSON.parse(data);
                                        if(data[0] && data[1]){
                                            $("#' . $field->modelName . '_"+data[0]).html(data[1]);
                                        }
                                    }
                                }'));
                    }
                }
                $htmlOptions = array_merge($htmlOptions, $ajaxArray, array('title' => $field->attributeLabel));
                if ($multi) {
                    $multiSelectOptions = array();
                    if (!is_array($curVal)) {
                        $curVal = array();
                    }
                    foreach ($curVal as $option) {
                        $multiSelectOptions[$option] = array('selected' => 'selected');
                    }
                    $htmlOptions = array_merge($htmlOptions, array('options' => $multiSelectOptions, 'multiple' => 'multiple'));
                } elseif ($field->includeEmpty) {
                    $htmlOptions = array_merge($htmlOptions, array('empty' => Yii::t('app', "Select an option")));
                }
                return CHtml::activeDropDownList($model, $field->fieldName, $dropdowns, $htmlOptions);
            case 'dependentDropdown':
                return CHtml::activeDropDownList($model, $field->fieldName, array('' => '-'), array_merge(array('title' => $field->attributeLabel), $htmlOptions));
            case 'link':
                $linkSource = null;
                $linkId = '';
                $name = '';
                if (class_exists($field->linkType)) {
                    // Create a model for autocompletion:
                    if (!empty($model->{$fieldName})) {
                        list($name, $linkId) = Fields::nameAndId($model->{$fieldName});
                        $linkModel = X2Model::getLinkedModelMock($field->linkType, $name, $linkId, true);
                    } else {
                        $linkModel = X2Model::model($field->linkType);
                    }
                    if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) {
                        $linkSource = Yii::app()->controller->createUrl($linkModel->autoCompleteSource);
                        $linkId = $linkModel->id;
                        $oldLinkFieldVal = $model->{$fieldName};
                        $model->{$fieldName} = $name;
                    }
                }
                static $linkInputCounter = 0;
                $hiddenInputId = $field->modelName . '_' . $fieldName . "_id" . $linkInputCounter++;
                $input = CHtml::hiddenField($field->modelName . '[' . $fieldName . '_id]', $linkId, array('id' => $hiddenInputId)) . Yii::app()->controller->widget('zii.widgets.jui.CJuiAutoComplete', array('model' => $model, 'attribute' => $fieldName, 'source' => $linkSource, 'value' => $name, 'options' => array('minLength' => '1', 'select' => 'js:function( event, ui ) {
                                    $("#' . $hiddenInputId . '").
                                        val(ui.item.id);
                                    $(this).val(ui.item.value);
                                    return false;
                            }', 'create' => $field->linkType == 'Contacts' ? 'js:function(event, ui) {
                                    $(this).data( "uiAutocomplete" )._renderItem = 
                                        function(ul,item) {
                                            return $("<li>").data("item.autocomplete",item).
                                                append(x2.forms.renderContactLookup(item)).
                                                appendTo(ul);
                                        };
                            }' : ($field->linkType == 'BugReports' ? 'js:function(event, ui) {
                                $(this).data( "uiAutocomplete" )._renderItem = 
                                    function( ul, item ) {

                                    var label = "<a style=\\"line-height: 1;\\">" + item.label;

                                    label += "<span style=\\"font-size: 0.6em;\\">";

                                    // add email if defined
                                    if(item.subject) {
                                        label += "<br>";
                                        label += item.subject;
                                    }

                                    label += "</span>";
                                    label += "</a>";

                                    return $( "<li>" )
                                        .data( "item.autocomplete", item )
                                        .append( label )
                                        .appendTo( ul );
                                };
                            }' : '')), 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions)), true);
                if (isset($oldLinkFieldVal)) {
                    $model->{$fieldName} = $oldLinkFieldVal;
                }
                return $input;
            case 'rating':
                return Yii::app()->controller->widget('X2StarRating', array('model' => $model, 'attribute' => $field->fieldName, 'readOnly' => isset($htmlOptions['disabled']) && $htmlOptions['disabled'], 'minRating' => Fields::RATING_MIN, 'maxRating' => Fields::RATING_MAX, 'starCount' => Fields::RATING_MAX - Fields::RATING_MIN + 1, 'cssFile' => Yii::app()->theme->getBaseUrl() . '/css/rating/jquery.rating.css', 'htmlOptions' => $htmlOptions, 'callback' => 'function(value, link){
                        if (typeof x2 !== "undefined" &&
                            typeof x2.InlineEditor !== "undefined" &&
                            typeof x2.InlineEditor.ratingFields !== "undefined") {

                            x2.InlineEditor.ratingFields["' . $field->modelName . '[' . $field->fieldName . ']"] = value;
                        }
                    }'), true);
            case 'boolean':
                $checkbox = CHtml::openTag('div', X2Html::mergeHtmlOptions($htmlOptions, array('class' => 'checkboxWrapper')));
                $checkbox .= CHtml::activeCheckBox($model, $field->fieldName, array_merge(array('unchecked' => 0, 'title' => $field->attributeLabel), $htmlOptions));
                $checkbox .= CHtml::closeTag('div');
                return $checkbox;
            case 'assignment':
                $oldAssignmentVal = $model->{$fieldName};
                $model->{$fieldName} = !empty($model->{$fieldName}) ? $field->linkType == 'multiple' && !is_array($model->{$fieldName}) ? explode(', ', $model->{$fieldName}) : $model->{$fieldName} : X2Model::getDefaultAssignment();
                $dropdownList = CHtml::activeDropDownList($model, $fieldName, X2Model::getAssignmentOptions(true, true), array_merge(array('title' => $field->attributeLabel, 'id' => $field->modelName . '_' . $fieldName . '_assignedToDropdown', 'multiple' => $field->linkType == 'multiple' ? 'multiple' : null), $htmlOptions));
                $model->{$fieldName} = $oldAssignmentVal;
                return $dropdownList;
            case 'optionalAssignment':
                // optional assignment for users (can be left blank)
                $users = User::getNames();
                unset($users['Anyone']);
                return CHtml::activeDropDownList($model, $fieldName, $users, array_merge(array('title' => $field->attributeLabel, 'empty' => ''), $htmlOptions));
            case 'visibility':
                $permissionsBehavior = Yii::app()->params->modelPermissions;
                return CHtml::activeDropDownList($model, $field->fieldName, $permissionsBehavior::getVisibilityOptions(), array_merge(array('title' => $field->attributeLabel, 'id' => $field->modelName . "_visibility"), $htmlOptions));
                // 'varchar', 'email', 'url', 'int', 'float', 'currency', 'phone'
                // case 'int':
                // return CHtml::activeNumberField($model, $field->fieldNamearray_merge(array(
                // 'title' => $field->attributeLabel,
                // ), $htmlOptions));
            // 'varchar', 'email', 'url', 'int', 'float', 'currency', 'phone'
            // case 'int':
            // return CHtml::activeNumberField($model, $field->fieldNamearray_merge(array(
            // 'title' => $field->attributeLabel,
            // ), $htmlOptions));
            case 'percentage':
                $htmlOptions['class'] = empty($htmlOptions['class']) ? 'input-percentage' : $htmlOptions['class'] . ' input-percentage';
                return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
            case 'currency':
                $fieldName = $field->fieldName;
                $elementId = isset($htmlOptions['id']) ? '#' . $htmlOptions['id'] : '#' . $field->modelName . '_' . $field->fieldName;
                Yii::app()->controller->widget('application.extensions.moneymask.MMask', array('element' => $elementId, 'currency' => Yii::app()->params['currency'], 'config' => array('affixStay' => true, 'decimal' => Yii::app()->locale->getNumberSymbol('decimal'), 'thousands' => Yii::app()->locale->getNumberSymbol('group'))));
                return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel, 'class' => 'currency-field'), $htmlOptions));
            case 'credentials':
                $typeAlias = explode(':', $field->linkType);
                $type = $typeAlias[0];
                if (count($typeAlias) > 1) {
                    $uid = Credentials::$sysUseId[$typeAlias[1]];
                } else {
                    $uid = Yii::app()->user->id;
                }
                return Credentials::selectorField($model, $field->fieldName, $type, $uid);
            case 'timerSum':
                // Sorry, no-can-do. This is field derives its value from a sum over timer records.
                return $model->renderAttribute($field->fieldName);
            case 'float':
            case 'int':
                if (isset($model->{$fieldName})) {
                    $oldNumVal = $model->{$fieldName};
                    $model->{$fieldName} = Yii::app()->locale->numberFormatter->formatDecimal($model->{$fieldName});
                }
                $input = CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
                if (isset($oldNumVal)) {
                    $model->{$fieldName} = $oldNumVal;
                }
                return $input;
            default:
                return CHtml::activeTextField($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), $htmlOptions));
                // array(
                // 'tabindex'=>isset($item['tabindex'])? $item['tabindex'] : null,
                // 'disabled'=>$item['readOnly']? 'disabled' : null,
                // 'title'=>$field->attributeLabel,
                // 'style'=>$default?'color:#aaa;':null,
                // ));
        }
    }
Exemplo n.º 11
0
 public static function renderAvatarImage($id, $width, $height, array $htmlOptions = array())
 {
     $model = Profile::model()->findByPk($id);
     $file = Yii::app()->file->set($model->avatar);
     if ($file->exists) {
         return CHtml::tag('img', X2Html::mergeHtmlOptions(array('id' => "avatar-image", 'class' => "avatar-upload", 'width' => $width, 'height' => $height, 'src' => "data:image/x-icon;base64," . base64_encode($file->getContents())), $htmlOptions));
     }
 }
Exemplo n.º 12
0
 public function getImage($link = false, array $htmlOptions = array())
 {
     if (!$this->fileExists() || !$this->isImage()) {
         return '';
     }
     if ($this->drive) {
         return $this->googlePreview;
     }
     $img = CHtml::image($this->getPublicUrl(), '', X2Html::mergeHtmlOptions(array('class' => 'attachment-img'), $htmlOptions));
     if (!$link) {
         return $img;
     }
     return X2Html::link($img, $this->getPublicUrl());
 }
Exemplo n.º 13
0
 public function htmlOptions($name, $options = array())
 {
     return X2Html::mergeHtmlOptions(parent::htmlOptions($name, $options), array('class' => 'google-credential-input'));
 }
Exemplo n.º 14
0
 /**
  * @param int $width 
  * @param string $columnName 
  * @return array the new column
  */
 protected function addNewColumn($columnName, $width)
 {
     $newColumn = array();
     if (array_key_exists($columnName, $this->specialColumnNames)) {
         $newColumn = $this->createSpecialColumn($columnName, $width);
     } else {
         if ($columnName == 'gvControls') {
             $newColumn = $this->getGvControlsColumn($width);
             if (!$this->isAdmin) {
                 $newColumn['template'] = '{view}{update}';
             }
         } else {
             if ($columnName == 'gvCheckbox') {
                 $newColumn = $this->getGvCheckboxColumn($width);
             } else {
                 $newColumn = $this->createDefaultStyleColumn($columnName, $width);
             }
         }
     }
     if ($newColumn === array()) {
         return $newColumn;
     }
     $newColumn['htmlOptions'] = X2Html::mergeHtmlOptions(isset($newColumn['htmlOptions']) ? $newColumn['htmlOptions'] : array(), array('width' => $width));
     if (isset($this->columnOverrides[$columnName])) {
         $newColumn = array_merge($newColumn, $this->columnOverrides[$columnName]);
     }
     return $newColumn;
 }
Exemplo n.º 15
0
 public static function renderThemeColorSelector($label, $key, $value, $htmlOptions = array(), $disabled = false)
 {
     $htmlOptions = X2Html::mergeHtmlOptions(array('class' => 'row theme-color-selector'), $htmlOptions);
     echo X2Html::openTag('div', $htmlOptions);
     echo "\n                <label>\n                    " . CHtml::encode($label) . "\n                </label>\n                <input type='text' name='preferences[{$key}]' id='preferences_{$key}' value='{$value}'\n                 class='color-picker-input theme-attr' " . ($disabled ? 'disabled="disabled"' : '') . "> \n                </input>\n              </div>";
 }
Exemplo n.º 16
0
 public function renderField($field, $inner, array $htmlOptions = array())
 {
     $html = '';
     if ($field->valueIsLink()) {
         $classes = 'ui-link field-container field-link-container';
         if ($field->linkType === 'multiple') {
             $classes .= ' multiple-links';
         }
         $html .= CHtml::tag('div', X2Html::mergeHtmlOptions(array('class' => $classes), $htmlOptions));
         $html .= $inner;
         $html .= CHtml::closeTag('div');
     } else {
         $html .= CHtml::openTag('div', X2Html::mergeHtmlOptions(array('class' => 'field-container'), $htmlOptions));
         $html .= $inner;
         $html .= CHtml::closeTag('div');
     }
     return $html;
 }
Exemplo n.º 17
0
 /**
  * @param type $fieldName
  * @param type $htmlOptions
  */
 public function renderInput($fieldName, $htmlOptions = array())
 {
     switch ($fieldName) {
         case 'color':
             $field = $this->getField($fieldName);
             $options = Dropdowns::getItems($field->linkType, null, false);
             $enableDropdownLegend = Yii::app()->settings->enableColorDropdownLegend;
             if ($enableDropdownLegend) {
                 $htmlOptions['options'] = array();
                 foreach ($options as $value => $label) {
                     $brightness = X2Color::getColorBrightness($value);
                     $fontColor = $brightness > 127.5 ? 'black' : 'white';
                     $htmlOptions['options'][$value] = array('style' => 'background-color: ' . $value . ';
                              color: ' . $fontColor);
                 }
             }
             return CHtml::activeDropDownList($this, $field->fieldName, $options, $htmlOptions);
         case 'priority':
             return CHtml::activeDropdownList($this, 'priority', self::getPriorityLabels());
         case 'associationType':
             return X2Html::activeMultiTypeAutocomplete($this, 'associationType', 'associationId', array('calendar' => Yii::t('app', 'Select an option')) + X2Model::getAssociationTypeOptions());
         case 'reminder':
             $reminderInput = parent::renderInput($fieldName, array('class' => 'reminder-checkbox'));
             $reminderInput .= X2Html::openTag('div', X2Html::mergeHtmlOptions($htmlOptions, array('class' => 'reminder-config'))) . Yii::t('actions', 'Create a notification reminder for {user} {time} before this {action} ' . 'is due', array('{user}' => CHtml::activeDropDownList($this, 'notificationUsers', array('me' => Yii::t('actions', 'me'), 'assigned' => Yii::t('actions', 'the assigned user'), 'both' => Yii::t('actions', 'me and the assigned user'))), '{time}' => CHtml::activeDropDownList($this, 'notificationTime', array(1 => Yii::t('actions', '1 minute'), 5 => Yii::t('actions', '5 minutes'), 10 => Yii::t('actions', '10 minutes'), 15 => Yii::t('actions', '15 minutes'), 30 => Yii::t('actions', '30 minutes'), 60 => Yii::t('actions', '1 hour'), 1440 => Yii::t('actions', '1 day'), 10080 => Yii::t('actions', '1 week'))), '{action}' => lcfirst(Modules::displayName(false, 'Actions')))) . '</div>';
             return $reminderInput;
         default:
             return parent::renderInput($fieldName, $htmlOptions);
     }
 }
Exemplo n.º 18
0
 * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 * California 95067, USA. or at email address contact@x2engine.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * X2Engine" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by X2Engine".
 *****************************************************************************************/
$namespacedId = $this->htmlOptions['id'];
Yii::app()->clientScript->registerScript('multiTypeAutocompleteJS' . $this->namespace, "\n\n\$(function () {\n    var container\$ = \$('#" . $namespacedId . "');\n    var excludeList = " . CJSON::encode($this->staticOptions) . ";\n\n    container\$.find ('select').change (function () {\n        var autocomplete\$ = container\$.find ('.record-name-autocomplete');\n        var modelType = container\$.find ('select').val ();\n        if (\$.inArray (modelType, excludeList) >= 0) {\n            container\$.find ('input').css ('visibility', 'hidden')\n            return;\n        }\n        var throbber\$ = x2.forms.inputLoading (container\$.find ('.record-name-autocomplete'));\n        \$.ajax ({\n            type: 'GET',\n            url: '" . Yii::app()->controller->createUrl('ajaxGetModelAutocomplete') . "',\n            data: {\n                modelType: modelType\n            },\n            success: function (data) {\n                if (data === 'failure') {\n                    autocomplete\$.attr ('disabled', 'disabled');\n                    autocomplete\$.siblings ('label').hide ();\n                } else {\n                    autocomplete\$.siblings ('label').show ();\n                    // remove span element used by jQuery widget\n                    container\$.find ('input').\n                        first ().next ('span').remove ();\n\n                    // replace old autocomplete with the new one\n                    container\$.find ('input').first ().replaceWith (data); \n         \n                }\n                // remove the loading gif\n                throbber\$.remove ();\n            }\n        });\n    });\n});\n\n", CClientScript::POS_END);
echo CHtml::openTag('div', X2Html::mergeHtmlOptions(array('class' => "multi-type-autocomplete-container", 'id' => $namespacedId), $this->htmlOptions));
if (isset($this->model)) {
    echo CHtml::activeDropDownList($this->model, $this->selectName, $this->options, array('class' => ''));
} else {
    echo CHtml::dropDownList($this->selectName, $this->selectValue, $this->options, array('class' => 'x2-select type-select'));
}
$htmlOptions = array();
if (isset($this->model)) {
    echo CHtml::activeLabel($this->model, $this->autocompleteName, array('style' => $this->selectValue === 'calendar' ? 'display: none;' : ''));
}
if (isset($this->autocompleteName)) {
    $htmlOptions['name'] = isset($this->model) ? CHtml::resolveName($this->model, $this->autocompleteName) : $this->autocompleteName;
}
if ($this->selectValue === 'calendar') {
    $htmlOptions['disabled'] = 'disabled';
    $htmlOptions['style'] = 'display: none;';
Exemplo n.º 19
0
 /**
  * @return array the config array passed to widget ()
  */
 public function getGridViewConfig()
 {
     if (!isset($this->_gridViewConfig)) {
         $this->_gridViewConfig = array_merge(parent::getGridViewConfig(), array('sortableWidget' => $this, 'id' => $this->getWidgetKey(), 'enableScrollOnPageChange' => false, 'possibleResultsPerPage' => array(5, 10, 20, 30, 40, 50, 75, 100), 'buttons' => array('advancedSearch', 'clearFilters', 'columnSelector', 'autoResize'), 'template' => CHtml::openTag('div', X2Html::mergeHtmlOptions(array('class' => 'page-title'), array('style' => !CPropertyValue::ensureBoolean($this->getWidgetProperty('showHeader')) && !CPropertyValue::ensureBoolean($this->getWidgetProperty('hideFullHeader')) ? 'display: none;' : ''))) . '<h2 class="grid-widget-title-bar-dummy-element">' . '</h2>{buttons}{filterHint}' . '{summary}{topPager}<div class="clear"></div></div>{items}{pager}', 'fixedHeader' => false, 'dataProvider' => $this->dataProvider, 'filter' => $this->model, 'pager' => array('class' => 'CLinkPager', 'maxButtonCount' => 10), 'modelName' => get_class($this->model), 'viewName' => 'profile', 'gvSettingsName' => get_called_class() . $this->widgetUID, 'enableControls' => true, 'fullscreen' => false, 'enableSelectAllOnAllPages' => false));
     }
     return $this->_gridViewConfig;
 }
Exemplo n.º 20
0
 /**
  * Generate a list of options to send to methods within {@link CHtml} that
  * take HTML element options/properties, so that it includes the proper name
  * of the input.
  * @param type $options
  */
 public function htmlOptions($name, $options = array())
 {
     return X2Html::mergeHtmlOptions($options, array('name' => $this->resolveName($name)));
 }