Ejemplo n.º 1
0
 public function getPackages()
 {
     if (!isset($this->_packages)) {
         $this->_packages = array_merge(parent::getPackages(), array('X2ModelConversionWidgetJS' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/X2ModelConversionWidget.js'), 'depends' => array('X2Widget'))));
     }
     return $this->_packages;
 }
Ejemplo n.º 2
0
 /**
  * Magic getter. Returns this widget's packages. 
  */
 public function getPackages()
 {
     if (!isset($this->_packages)) {
         $this->_packages = array_merge(parent::getPackages(), array('SortableWidgetManagerJS' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/sortableWidgets/SortableWidgetManager.js'), 'depends' => array('auxlib'))));
     }
     return $this->_packages;
 }
Ejemplo n.º 3
0
 public function getJSClassParams()
 {
     if (!isset($this->_JSClassParams)) {
         $this->_JSClassParams = array_merge(parent::getJSClassParams(), array('startDateAttribute' => $this->startDateAttribute, 'endDateAttribute' => $this->endDateAttribute, 'element' => '#' . $this->resolveId($this->id)), $this->options);
     }
     return $this->_JSClassParams;
 }
Ejemplo n.º 4
0
 public function init()
 {
     Yii::app()->clientScript->registerScript('hideActionForm', "\$(document).ready(hideActionForm);\n\t\t\tfunction hideActionForm() {\n\t\t\t\t\$('#action-form').hide();\n\t\t\t}\n\t\t\t", CClientScript::POS_HEAD);
     if (!$this->startHidden) {
         Yii::app()->clientScript->registerScript('gotoActionForm', "\$('#action-form').ready(gotoActionForm);\n\t\t\t\tfunction gotoActionForm() {\n\t\t\t\t\t\$('#action-form').show();\n\t\t\t\t}\n\t\t\t\t", CClientScript::POS_HEAD);
     }
     parent::init();
 }
Ejemplo n.º 5
0
 public function beforeExecute()
 {
     if ($this->getFormModel() && !$this->getFormModel()->validate()) {
         $that = $this;
         self::$responseForm = X2Widget::ajaxRender(function () use($that) {
             $that->renderForm(false);
         }, true);
         return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 public function init()
 {
     $this->drive = Yii::app()->params->profile->mediaWidgetDrive && Yii::app()->settings->googleIntegration;
     if (Yii::app()->settings->googleIntegration) {
         $auth = new GoogleAuthenticator();
         if (!isset($_SESSION['driveFiles']) && $auth->getAccessToken()) {
             Yii::import('application.modules.media.controllers.MediaController');
             $mediaController = new MediaController('MediaController');
             $_SESSION['driveFiles'] = $mediaController->printFolder('root', $auth);
         }
     }
     parent::init();
 }
Ejemplo n.º 7
0
 public function init()
 {
     $quotesAssetsUrl = $this->module->assetsUrl;
     if (isset($_POST)) {
         $startHidden = false;
     }
     if ($this->startHidden) {
         if ($this->startHidden) {
             Yii::app()->clientScript->registerScript('startQuotesHidden', "\$('#quotes-form').hide();", CClientScript::POS_READY);
         }
         // Set up the new create form:
         Yii::app()->clientScript->registerScriptFile($quotesAssetsUrl . '/js/inlineQuotes.js', CClientScript::POS_HEAD);
         Yii::app()->clientScript->registerScriptFile($quotesAssetsUrl . '/js/LineItems.js', CClientScript::POS_HEAD);
         Yii::app()->clientScript->registerCssFiles('InlineQuotesCss', array($quotesAssetsUrl . '/css/inlineQuotes.css', $quotesAssetsUrl . '/css/lineItemsMain.css', $quotesAssetsUrl . '/css/lineItemsWrite.css'), false);
         Yii::app()->clientScript->registerCoreScript('jquery.ui');
         $this->contact = X2Model::model('Contacts')->findByPk($this->contactId);
         //$this->contact = Contacts::model()->findByPk($this->contactId);
         $iqConfig = array('contact' => $this->contact instanceof Contacts ? CHtml::encode($this->contact->name) : '', 'account' => $this->account, 'sendingQuote' => false, 'lockedMessage' => Yii::t('quotes', 'This quote is locked. Are you sure you want to update this quote?'), 'deniedMessage' => Yii::t('quotes', 'This quote is locked.'), 'lockedDialogTitle' => Yii::t('quotes', 'Locked'), 'failMessage' => Yii::t('quotes', 'Could not save quote.'), 'reloadAction' => CHtml::normalizeUrl(array('/quotes/quotes/viewInline', 'recordId' => $this->recordId, 'recordType' => CHtml::encode($this->modelName))), 'createAction' => CHtml::normalizeUrl(array('/quotes/quotes/create', 'quick' => 1, 'recordId' => $this->recordId, 'recordType' => $this->modelName)), 'updateAction' => CHtml::normalizeUrl(array('/quotes/quotes/update', 'quick' => 1)));
         Yii::app()->clientScript->registerScript('quickquote-vars', '
         ;(function () {
             if(typeof x2 == "undefined"){
                 x2 = {};
             }
             var iqConfig = ' . CJSON::encode($iqConfig) . ';
             if(typeof x2.inlineQuotes=="undefined") {
                 x2.inlineQuotes = iqConfig;
             } else {
                 $.extend(x2.inlineQuotes,iqConfig);
             }
         }) ();', CClientScript::POS_HEAD);
     }
     parent::init();
 }
Ejemplo n.º 8
0
 public function getPackages()
 {
     return array_merge(parent::getPackages(), array('RecordAliasesWidget' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/RecordAliasesWidget.js'), 'depends' => array('auxlib'))));
 }
Ejemplo n.º 9
0
 public function init()
 {
     parent::init();
     $this->cs = Yii::app()->clientScript;
 }
Ejemplo n.º 10
0
 public function init()
 {
     $this->disableTemplates = $this->disableTemplates || in_array($this->associationType, array_keys(Docs::modelsWhichSupportEmailTemplates()));
     // Prepare the model for initially displayed input:
     $this->model = new InlineEmail();
     if (isset($this->targetModel)) {
         $this->model->targetModel = $this->targetModel;
     }
     if (!$this->associationType) {
         $this->associationType = X2Model::getModelName(Yii::app()->controller->module->name);
     }
     // Bring in attributes set in the configuration:
     $this->model->attributes = $this->attributes;
     if (empty($this->template)) {
         // check for a default template
         $defaultTemplateId = Yii::app()->params->profile->getDefaultEmailTemplate(Yii::app()->controller->module->name);
         // if there's a default set for this module
         if ($defaultTemplateId !== null) {
             $defaultTemplateDoc = Docs::model()->findByPk($defaultTemplateId);
             // ensure that template is still a valid default
             if ($defaultTemplateDoc && ($defaultTemplateDoc->associationType === $this->associationType || $defaultTemplateDoc->type === 'quote' && $this->model->targetModel instanceof Quote)) {
                 $this->template = $defaultTemplateId;
             }
         }
     }
     if (empty($this->template)) {
         if (empty($this->model->message)) {
             $this->model->message = InlineEmail::emptyBody();
         }
         $this->model->insertSignature();
     } else {
         // Fill in the body with a template:
         $this->model->scenario = 'template';
         if (!empty($this->template)) {
             $this->model->template = $this->template;
         }
         $this->model->prepareBody();
     }
     // If insertable attributes aren't set, use the inline email model's
     // getInsertableAttributes() method to generate them.
     if ((bool) $this->model->targetModel && !isset($this->insertableAttributes)) {
         $this->insertableAttributes = $this->model->insertableAttributes;
     }
     $this->registerJSClassInstantiation();
     // Load resources:
     Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/ckeditor/ckeditor.js');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/ckeditor/adapters/jquery.js');
     Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/emailEditor.js');
     if (!empty($this->insertableAttributes)) {
         Yii::app()->clientScript->registerScript('setInsertableAttributes', 'x2.insertableAttributes = ' . CJSON::encode($this->insertableAttributes) . ';', CClientScript::POS_HEAD);
     }
     Yii::app()->clientScript->registerScript('storeOriginalInlineEmailMessage', 'x2.inlineEmailOriginalBody = $("#email-message").val();', CClientScript::POS_READY);
     //'.CJSON::encode($this->model->message).';',CClientScript::POS_READY);
     Yii::app()->clientScript->registerScript('toggleEmailForm', $this->startHidden ? "window.hideInlineEmail = true;\n" : "window.hideInlineEmail = false;\n", CClientScript::POS_HEAD);
     $this->registerPackages();
     parent::init();
 }
Ejemplo n.º 11
0
 public function init()
 {
     $miscLayoutSettings = Yii::app()->params->profile->miscLayoutSettings;
     if (!$this->staticLayout && isset($miscLayoutSettings[$this->miscLayoutSettingsKey])) {
         $this->columnWidthPercentage = $miscLayoutSettings[$this->miscLayoutSettingsKey];
     }
     if (!$this->staticLayout) {
         $this->registerPackages();
         $this->instantiateJSClass();
     }
     parent::init();
 }
Ejemplo n.º 12
0
 public function getJSClassParams()
 {
     $totalEmails = count($this->listItems) + $this->sentCount;
     if (!isset($this->_JSClassParams)) {
         $this->_JSClassParams = array_merge(parent::getJSClassParams(), array('sentCount' => $this->sentCount, 'totalEmails' => $totalEmails, 'listItems' => $this->listItems, 'sendUrl' => Yii::app()->controller->createUrl('/marketing/marketing/mailIndividual'), 'campaignId' => $this->campaign->id, 'paused' => !(isset($_GET['launch']) && $_GET['launch'])));
     }
     return $this->_JSClassParams;
 }
Ejemplo n.º 13
0
 public function init()
 {
     if (!isset($this->namespace)) {
         $this->namespace = $this->getWidgetKey();
     }
     parent::init();
 }
 /**
  * Renders an inline record create/update form
  * @param object $model 
  * @param bool $hasErrors
  */
 public function renderInlineForm($model, array $viewParams = array())
 {
     //@FORMVIEW
     $that = $this;
     echo CJSON::encode(array('status' => $model->hasErrors() ? 'userError' : 'success', 'page' => X2Widget::ajaxRender(function () use($model, $that, $viewParams) {
         echo $that->owner->widget('FormView', array_merge(array('model' => $model, 'suppressQuickCreate' => true, 'formSettings' => array()), $viewParams), true, true);
     }, true)));
 }
Ejemplo n.º 15
0
 public function init()
 {
     parent::init();
 }
Ejemplo n.º 16
0
 public function getJSClassParams()
 {
     return array_merge(parent::getJSClassParams(), array('modelId' => $this->model->id, 'modelName' => $this->modelName));
 }
Ejemplo n.º 17
0
 public function run()
 {
     $ret = parent::run();
     echo $this->renderLayout();
     return $ret;
 }
Ejemplo n.º 18
0
 public function init()
 {
     unset($this->htmlOptions['id']);
     unset($this->htmlOptions['name']);
     parent::init();
 }
Ejemplo n.º 19
0
 /**
  * @param CModel $model 
  * @param string $attribute 
  * @param array (optional) $htmlOptions 
  * @return string
  */
 public static function activeDatePicker(CModel $model, $attribute, array $htmlOptions = array(), $mode = 'date', array $options = array())
 {
     $options = array_merge(array('dateFormat' => Formatter::formatDatePicker(), 'changeMonth' => true, 'changeYear' => true), $options);
     ob_start();
     ob_implicit_flush(false);
     Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
     $model->{$attribute} = Formatter::formatDateTime($model->{$attribute});
     $renderWidget = function () use($model, $attribute, $htmlOptions, $mode, $options) {
         Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $attribute, 'mode' => $mode, 'options' => $options, 'htmlOptions' => $htmlOptions, 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()));
     };
     if (Yii::app()->controller->isAjaxRequest()) {
         // process output if this is an ajax request
         X2Widget::ajaxRender($renderWidget);
     } else {
         $renderWidget();
     }
     return ob_get_clean();
 }
Ejemplo n.º 20
0
 public function getTranslations()
 {
     if (!isset($this->_translations)) {
         $this->_translations = array_merge(parent::getTranslations(), array('View History Item' => Yii::t('app', 'View History Item')));
     }
     return $this->_translations;
 }
Ejemplo n.º 21
0
 /**
  * Magic getter. Returns this widget's packages. 
  */
 public function getPackages()
 {
     if (!isset($this->_packages)) {
         $this->_packages = array_merge(parent::getPackages(), array('PublisherTabJS' => array('baseUrl' => Yii::app()->request->baseUrl, 'js' => array('js/publisher/PublisherTab.js'), 'depends' => array('auxlib'))));
     }
     return $this->_packages;
 }
Ejemplo n.º 22
0
 public function getJSClassParams()
 {
     if (!isset($this->_JSClassParams)) {
         $this->_JSClassParams = array_merge(parent::getJSClassParams(), array('url' => $this->url, 'id' => $this->id, 'mediaParams' => $this->mediaParams, 'viewParams' => $this->viewParams, 'acceptedFiles' => $this->acceptedFiles, 'maxFileSize' => floor(AppFileUtil::sizeToMb(ini_get('upload_max_filesize')))));
     }
     return $this->_JSClassParams;
 }
Ejemplo n.º 23
0
 public function __construct($owner = null)
 {
     $this->execute = true;
     parent::__construct($owner);
     try {
         // Initialize command utility and load the cron table:
         $this->cmdU = new CommandUtil();
         $this->crontab = $this->cmdU->loadCrontab();
         $this->j = CrontabUtil::crontabToArray($this->crontab);
     } catch (Exception $e) {
         $this->execute = false;
     }
 }
Ejemplo n.º 24
0
 public function getJSClassParams()
 {
     $this->_JSClassParams = array_merge(parent::getJSClassParams(), array('iframeSrc' => Yii::app()->createExternalUrl($this->url), 'externalAbsoluteBaseUrl' => Yii::app()->getExternalAbsoluteBaseUrl(), 'saveUrl' => Yii::app()->createAbsoluteUrl($this->saveUrl), 'savedForms' => $this->formAttrs, 'deleteFormUrl' => Yii::app()->createAbsoluteUrl('/marketing/marketing/deleteWebForm'), 'fields' => array('fg', 'bgc', 'font', 'bs', 'bc'), 'colorfields' => array('fg', 'bgc', 'bc')));
     return $this->_JSClassParams;
 }
Ejemplo n.º 25
0
 public function getJSClassParams()
 {
     if (!isset($this->_JSClassParams)) {
         $this->_JSClassParams = array_merge(parent::getJSClassParams(), array('url' => $this->url, 'id' => $this->id, 'mediaParams' => $this->mediaParams, 'viewParams' => $this->viewParams, 'acceptedFiles' => $this->acceptedFiles));
     }
     return $this->_JSClassParams;
 }
Ejemplo n.º 26
0
 public function renderFilterCellContent()
 {
     switch ($this->fieldType) {
         case 'boolean':
             echo CHtml::activeDropdownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', '1' => Yii::t('app', 'Yes'), 'false' => Yii::t('app', "No")), array('class' => 'x2-minimal-select-filtercol'));
             break;
         case 'dropdown':
             $dropdown = Dropdowns::model()->findByPk($this->fieldModel['linkType']);
             if ($dropdown instanceof Dropdowns) {
                 $options = json_decode($dropdown->options, 1);
                 if (!$dropdown->multi) {
                     $defaultOption = array('' => '- ' . Yii::t('app', 'Select') . ' -');
                     $options = is_array($options) ? array_merge($defaultOption, $options) : $defaultOption;
                 }
                 //$selected = isset($options[$this->grid->filter->{$this->name}]) ?
                 //$this->grid->filter->{$this->name} : '';
                 echo CHtml::activeDropdownList($this->grid->filter, $this->name, $options, array('class' => 'x2-minimal-select-filtercol' . ($dropdown->multi ? ' x2-multiselect-dropdown x2-datacolumn-multiselect' : ''), 'multiple' => $dropdown->multi ? 'multiple' : '', 'data-selected-text' => $dropdown->multi ? 'option(s)' : ''));
             } else {
                 parent::renderFilterCellContent();
             }
             break;
         case 'visibility':
             echo CHtml::activeDropDownList($this->grid->filter, $this->name, array('' => '- ' . Yii::t('app', 'Select') . ' -', 1 => Yii::t('app', 'Public'), 0 => Yii::t('app', 'Private'), 2 => Yii::t('app', 'User\'s Groups')), array('class' => 'x2-minimal-select-filtercol'));
             break;
         case 'dateTime':
         case 'date':
             Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
             $that = $this;
             $renderWidget = function () use($that) {
                 echo Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $that->grid->filter, 'attribute' => $that->name, 'mode' => 'date', 'options' => array('dateFormat' => Formatter::formatDatePicker('medium')), 'htmlOptions' => array('id' => 'datePicker' . $that->name, 'class' => 'datePicker x2-gridview-filter-datepicker'), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
             };
             if ($this->grid->ajax) {
                 X2Widget::ajaxRender($renderWidget);
             } else {
                 $renderWidget();
             }
             break;
         default:
             parent::renderFilterCellContent();
     }
 }
Ejemplo n.º 27
0
 public function actionQuickView($id)
 {
     $model = $this->loadModel($id);
     if (!FormLayout::model()->findByAttributes(array('model' => get_class($model)))) {
         echo Yii::t('app', 'Quick view not supported');
     }
     if ($this->checkPermissions($model, 'view')) {
         $that = $this;
         X2Widget::ajaxRender(function () use($model, $that) {
             $that->widget('DetailView', array_merge(array('model' => $model, 'scenario' => 'Inline', 'nameLink' => true)));
         });
         return;
     }
     throw new CHttpException(403);
 }
Ejemplo n.º 28
0
 public function getJSClassParams()
 {
     return array_merge(parent::getJSClassParams(), array('translations' => array('defaultTemplateDialogTitle' => Yii::t('app', 'Set a Default Email Template'), 'Cancel' => Yii::t('app', 'Cancel'), 'Save' => Yii::t('app', 'Save'), 'New Message' => Yii::t('app', 'New Message')), 'disableTemplates' => $this->disableTemplates, 'saveDefaultTemplateUrl' => Yii::app()->controller->createUrl('/profile/profile/ajaxSaveDefaultEmailTemplate'), 'tmpUploadUrl' => Yii::app()->createUrl('/site/tmpUpload'), 'rmTmpUploadUrl' => Yii::app()->createUrl('/site/removeTmpUpload'), 'type' => $this->type, 'enableResizability' => $this->enableResizability));
 }
Ejemplo n.º 29
0
 /**
  * @param string $modelClass the model class for which the autocomplete should be rendered
  * @param bool $ajax if true, registered scripts are processed with ajaxRender
  */
 public static function renderModelAutocomplete($modelClass, $ajax = false, $htmlOptions = array(), $value = null)
 {
     $modelClass = self::getModelName($modelClass);
     if (!class_exists($modelClass) || !$modelClass::model()->asa('X2LinkableBehavior')) {
         if ($ajax) {
             echo 'failure';
             return;
         } else {
             return 'failure';
         }
         /* throw new CException (
            Yii::t('app',
            'Error: renderModelAutocomplete: {modelClass} does not have '.
            'X2LinkableBehavior', array ('{modelClass}' => $modelClass))); */
     }
     if ($ajax) {
         Yii::app()->clientScript->scriptMap['*.css'] = false;
     }
     $renderWidget = function () use($modelClass, $htmlOptions, $value) {
         Yii::app()->controller->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => isset($htmlOptions['name']) ? $htmlOptions['name'] : 'recordName', 'source' => Yii::app()->controller->createUrl(X2Model::model($modelClass)->autoCompleteSource), 'value' => $value ? $value : Yii::t('app', 'Start typing to suggest...'), 'options' => array('minLength' => '1', 'create' => 'js:function (event, ui) {
                     // check for callback in parent form
                     if ($(this).closest ("form").data ("afterAutocompleteCreated")) {
                         $(this).closest ("form").data ("afterAutocompleteCreated") ();
                     }
                 }', 'select' => 'js:function (event, ui) {
                     $(this).val(ui.item.value);
                     // expects next input to be a hidden input which will contain the
                     // record id
                     $(this).nextAll ("input").val(ui.item.id);
                     return false;
                 }'), 'htmlOptions' => array_merge(array('class' => 'record-name-autocomplete x2-default-field', 'data-default-text' => Yii::t('app', 'Start typing to suggest...'), 'style' => $value ? '' : 'color:#aaa'), $htmlOptions)));
         Yii::app()->clientScript->registerScript('renderModelAutocomplete', "\n                x2.forms.enableDefaultText (\$('.record-name-autocomplete'));\n            ", CClientScript::POS_READY);
     };
     if ($ajax) {
         X2Widget::ajaxRender($renderWidget);
     } else {
         $renderWidget();
     }
 }
Ejemplo n.º 30
0
 public function run()
 {
     parent::run();
     $this->registerPackages();
     $this->render('application.modules.mobile.views.mobile._panel');
 }