Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • ActionFormModel
  • ArrayUtil
  • ArrayValidator
  • AssociatedMediaBehavior
  • AuxLib
  • Changelog
  • DetailView
  • EncryptUtilTmp
  • EventsWidgetFieldFormatter
  • FailedLogins
  • FieldFormatter
  • FieldFormatterBase
  • FieldInputRenderer
  • FileFieldBehavior
  • FiltersForm
  • FilterUtil
  • FineDiff
  • FineDiffCopyOp
  • FineDiffDeleteOp
  • FineDiffInsertOp
  • FineDiffOp
  • FineDiffOps
  • FineDiffReplaceOp
  • GlobalCSSFormModel
  • GlobalImportFormModel
  • GoogleAuthenticator
  • JSONFieldsBehavior
  • JSONResponse
  • MediaFieldFormatter
  • MediaSelector
  • MobileActiveRecordFieldFormatter
  • MobileActivityFeed
  • MobileChartDashboard
  • MobileFieldFormatter
  • MobileFieldInputRenderer
  • ModuleModelNameValidator
  • MultiChildNode
  • MultiTypeAutocomplete
  • PasswordUtil
  • ProductFeature
  • ProfileWidgetLayout
  • QueryParamGenerator
  • RecordLimitBehavior
  • RecordView
  • RecordViewWidgetLayout
  • RelationshipsGridModel
  • RelationshipsJoin
  • RepairUserDataCommand
  • RequestUtil
  • RequiredIfNotSetValidator
  • ResponseUtil
  • RunMigrationScriptCommand
  • ServiceWebFormDesigner
  • Settings
  • StringUtil
  • TestEmailAction
  • TestEmailActionForm
  • ThemeGenerator
  • TimerUtil
  • TopicsFieldFormatter
  • TopicsWidgetLayout
  • TransactionalViewFieldFormatter
  • UrlUtil
  • ValidLinkValidator
  • WebFormDesigner
  • WebLeadFormDesigner
  • X2ActiveRecordBehavior
  • X2ActiveRecordFieldFormatter
  • X2ButtonColumn
  • X2ConditionList
  • X2ConsoleCommand
  • X2ControllerBehavior
  • X2DataColumn
  • X2DuplicateBehavior
  • X2Flashes
  • X2GridViewFieldFormatter
  • X2IPAddress
  • X2LeadsDataColumn
  • X2MergeableBehavior
  • X2MessageSource
  • X2MobileControllerBehavior
  • X2MobileProfileControllerBehavior
  • X2MobileQuotesControllerBehavior
  • X2MobileSiteControllerBehavior
  • X2MobileTopicsControllerBehavior
  • X2ModelConversionBehavior
  • X2ModelConversionWidget
  • X2ModelForeignKeyValidator
  • X2ModelUniqueIndexValidator
  • X2NonWebUser
  • X2StaticDropdown
  • X2StaticField
  • X2StaticFieldsBehavior
  • X2UrlManager
  • X2Validator
  • X2WidgetBehavior

Interfaces

  • AdminOwnedCredentials

Exceptions

  • CampaignMailingException
  • CodeExchangeException
  • GetCredentialsException
  • NoRefreshTokenException
  • NoUserIdException
  • StringUtilException

Functions

  • checkCurrency
  • checkDNS
  • checkServerVar
  • checkTimezone
  • decodeQuotes
  • echoIcons
  • encodeQuotes
  • exceptionForError
  • getField
  • getLanguageName
  • getModuleTitle
  • handleReqError
  • handleReqException
  • installer_t
  • installer_tr
  • isAllowedDir
  • mediaMigrationRrmdir
  • migrateMediaDir
  • printGraph
  • printR
  • renderFields
  • reqShutdown
  • RIP
  • translateOptions
  • tryGetRemote
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /*****************************************************************************************
  3:  * X2Engine Open Source Edition is a customer relationship management program developed by
  4:  * X2Engine, Inc. Copyright (C) 2011-2016 X2Engine Inc.
  5:  * 
  6:  * This program is free software; you can redistribute it and/or modify it under
  7:  * the terms of the GNU Affero General Public License version 3 as published by the
  8:  * Free Software Foundation with the addition of the following permission added
  9:  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 10:  * IN WHICH THE COPYRIGHT IS OWNED BY X2ENGINE, X2ENGINE DISCLAIMS THE WARRANTY
 11:  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 12:  * 
 13:  * This program is distributed in the hope that it will be useful, but WITHOUT
 14:  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 15:  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 16:  * details.
 17:  * 
 18:  * You should have received a copy of the GNU Affero General Public License along with
 19:  * this program; if not, see http://www.gnu.org/licenses or write to the Free
 20:  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 21:  * 02110-1301 USA.
 22:  * 
 23:  * You can contact X2Engine, Inc. P.O. Box 66752, Scotts Valley,
 24:  * California 95067, USA. or at email address contact@x2engine.com.
 25:  * 
 26:  * The interactive user interfaces in modified source and object code versions
 27:  * of this program must display Appropriate Legal Notices, as required under
 28:  * Section 5 of the GNU Affero General Public License version 3.
 29:  * 
 30:  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 31:  * these Appropriate Legal Notices must retain the display of the "Powered by
 32:  * X2Engine" logo. If the display of the logo is not reasonably feasible for
 33:  * technical reasons, the Appropriate Legal Notices must display the words
 34:  * "Powered by X2Engine".
 35:  *****************************************************************************************/
 36: 
 37: Yii::import ('application.components.behaviors.*');
 38: Yii::import ('application.modules.mobile.components.actions.*');
 39: Yii::import ('application.modules.mobile.*');
 40: Yii::import ('application.modules.mobile.models.*');
 41: 
 42: class X2MobileControllerBehavior extends X2ControllerBehavior {
 43: 
 44:     /**
 45:      * used for jquerymobile layout
 46:      */
 47:     public $dataUrl; 
 48:     public $pageId; 
 49:     public $pageClass; 
 50:     public $headerTitle; 
 51: 
 52:     public $pathAliasBase = 'application.modules.mobile.';
 53: 
 54:     /**
 55:      * @var bool $includeActions
 56:      */
 57:     public $includeActions = true; 
 58: 
 59:     public function hasMobileAction ($action) {
 60:         $actions = $this->owner->actions ();
 61:         return isset ($actions[$action]);
 62:     }
 63: 
 64:     private $_assetsUrl;
 65:     public function getAssetsUrl () {
 66:         if (!isset ($this->_assetsUrl)) {
 67:             if (isset ($this->owner->module)) {
 68:                 $this->_assetsUrl = $this->owner->module->assetsUrl;
 69:             } else {
 70:                 $this->_assetsUrl = Yii::app()->getAssetManager()->publish (
 71:                     Yii::getPathOfAlias($this->pathAliasBase.'assets'), false, -1, true);
 72:             }
 73:         }
 74:         return $this->_assetsUrl;
 75:     }
 76: 
 77:     public function setAssetsUrl ($assetsUrl) {
 78:         $this->_assetsUrl = $assetsUrl;
 79:     }
 80: 
 81:     public function actions () {
 82:         if ($this->owner instanceof MobileController || !$this->includeActions) return array ();
 83:         return array (
 84:             'mobileIndex' => array (
 85:                 'class' => 'MobileIndexAction'
 86:             ),
 87:             'mobileView' => array (
 88:                 'class' => 'MobileViewAction'
 89:             ),
 90:             'mobileCreate' => array (
 91:                 'class' => 'MobileCreateAction'
 92:             ),
 93:             'mobileUpdate' => array (
 94:                 'class' => 'MobileUpdateAction'
 95:             ),
 96:             'mobileDelete' => array (
 97:                 'class' => 'MobileDeleteAction'
 98:             ),
 99:         );
100:     }
101: 
102:     public function beforeAction ($action) {
103:         if (!($this->owner instanceof MobileController) &&
104:             !in_array ($this->owner->action->getId (), array_keys ($this->actions ()))) {
105: 
106:             return true;
107:         }
108:         
109:         Yii::app()->user->loginUrl = array ('/mobile/login');
110: 
111:         Yii::app()->params->isMobileApp = true;
112: 
113:         // fix profile linkable behavior since model was instantiated before action
114:         if (!preg_match (
115:             '/\/mobileView$/',
116:             Yii::app()->params->profile->asa ('X2LinkableBehavior')->viewRoute)) {
117: 
118:             Yii::app()->params->profile->asa ('X2LinkableBehavior')->viewRoute .= '/mobileView';
119:         }
120:         
121:         $this->dataUrl = $this->owner->createAbsoluteUrl ($action->getId ());
122:         $this->pageId = lcfirst (preg_replace ('/Controller$/', '', get_class ($this->owner))).'-'.
123:             $action->getId ();
124: 
125:         $cookie = new CHttpCookie('isMobileApp', 'true'); // create cookie
126:         $cookie->expire = 2147483647; // max expiration time
127:         Yii::app()->request->cookies['isMobileApp'] = $cookie; // save cookie
128: 
129:           
130: 
131: 
132:         if (!($this->owner instanceof MobileController)) {
133:             $this->owner->layout = $this->pathAliasBase.'views.layouts.main';
134:             if ($this->owner->module) {
135: 
136:                 $this->owner->setAssetsUrl (Yii::app()->getAssetManager()->publish (
137:                     Yii::getPathOfAlias($this->pathAliasBase.'assets'), false, -1, true));
138:                 $this->owner->module->assetsUrl = $this->owner->assetsUrl;
139:                 Yii::app()->clientScript->packages = MobileModule::getPackages (
140:                     $this->owner->module->assetsUrl);
141:             } else {
142:                 Yii::app()->clientScript->packages = MobileModule::getPackages (
143:                     $this->owner->assetsUrl);
144:             }
145:         }
146: 
147:         return true;
148:     }
149: 
150:     public function includeDefaultJsAssets () {
151:         return !$this->owner->isAjaxRequest () || isset ($_GET['includeX2TouchJsAssets']);
152:     }
153: 
154:     public function includeDefaultCssAssets () {
155:         return !$this->owner->isAjaxRequest () || isset ($_GET['includeX2TouchCssAssets']);
156:     }
157: 
158:     /**
159:      * Wrap specified JS in the appropriate on load handler 
160:      * @param string $js
161:      */
162:     public function onPageLoad ($js, $scriptName=null) {
163:         static $i=0;
164:         $scriptName  = !isset ($scriptName) ? 
165:             'X2MobileControllerBehavior.onPageLoad.'.$i : $scriptName;
166:         if ($this->owner->isAjaxRequest ()) {
167:             Yii::app()->clientScript->registerScript($scriptName, 
168:             "$(function () { $js });", CClientScript::POS_END);
169:         } else {
170:             Yii::app()->clientScript->registerScript($scriptName, 
171:             "$(document).on ('pagecontainercreate', function () { $js });", CClientScript::POS_END);
172:         }
173:         $i++;
174:     }
175: 
176:     /**
177:      * Guarantees unique suffix across page loads
178:      */
179:     public function getUniquePageIdSuffix () {
180:         if (isset ($_SESSION['X2MobileControllerBehavior.random'])) {
181:             $oldVal = $_SESSION['X2MobileControllerBehavior.random'];
182:             while (($suffix = (mt_rand ().preg_replace ('/\./', '_', microtime (true)))) === 
183:                 $oldVal) {};
184: 
185:             $_SESSION['X2MobileControllerBehavior.random'] = $suffix;
186:         } else {
187:             $suffix = mt_rand ().preg_replace ('/\./', '_', microtime (true));
188:         }
189:         return $suffix;
190:     }
191: }
192: 
193: ?>
194: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0