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.modules.mobile.components.*');
38:
39: /**
40: * All CSS for the mobile module should be specified in this file. Corresponding sass files
41: * are automatically merged into combined.css. When new CSS assets are added, the console
42: * command combinemobilecss must be run in order to regenerate the combined.scss file.
43: */
44:
45: /**
46: * @package application.modules.mobile
47: */
48: class MobileModule extends X2WebModule {
49:
50: public static $useMergedCss = true;
51:
52: /**
53: * @var string the path of the assets folder for this module. Defaults to 'assets'.
54: */
55: public $packages = array();
56:
57: public static function registerDefaultCss () {
58: $packages = self::getPackages (Yii::app()->controller->assetsUrl);
59: }
60:
61: public static function registerDefaultJs () {
62: $packages = self::getPackages (Yii::app()->controller->assetsUrl);
63: }
64:
65: public static function supportedModules (CDbCriteria $criteria = null) {
66: $basicModules = array (
67: 'x2Activity',
68: 'topics',
69: 'contacts',
70: 'charts',
71: 'accounts',
72: 'opportunities',
73: 'x2Leads',
74: 'quotes',
75: 'products',
76: 'services',
77: 'bugReports',
78: 'users',
79: //'groups',
80: );
81:
82: $qpg = new QueryParamGenerator;
83: $newCriteria = new CDbCriteria;
84: $newCriteria->condition =
85: '(name in '.$qpg->bindArray ($basicModules, true).' or custom) and visible and
86: moduleType in ("module", "pseudoModule") and name != "document"';
87: $newCriteria->params = $qpg->getParams ();
88: $newCriteria->order = 'menuPosition ASC';
89: if ($criteria) {
90: $newCriteria->mergeWith ($criteria);
91: $criteria = $newCriteria;
92: } else {
93: $criteria = $newCriteria;
94: }
95:
96: $modules = Modules::model ()->findAll (
97: $criteria
98: );
99: return $modules;
100: }
101:
102: public static function getPackages ($assetsUrl) {
103: return array(
104: 'jquery-migrate' => array(
105: 'baseUrl' => Yii::app()->baseUrl,
106: 'js' => array(
107: 'js/lib/jquery-migrate-1.2.1.js',
108: ),
109: 'depends' => array('jquery')
110: ),
111: 'jqueryMobileCss' => array(
112: 'baseUrl' => $assetsUrl,
113: 'css' => array(
114: 'css/jquery.mobile.structure-1.4.5.css',
115: ),
116: 'depends' => array('jquery', 'jquery-migrate'),
117: ),
118: 'jqueryMobileJs' => array(
119: 'baseUrl' => $assetsUrl,
120: 'js' => array(
121: 'js/x2mobile-init.js',
122: 'js/lib/jquery.mobile-1.4.5.js',
123: ),
124: 'depends' => array('jquery', 'jquery-migrate'),
125: ),
126: 'x2TouchCss' => array (
127: 'baseUrl' => $assetsUrl,
128: 'css' => array_merge (
129: array_merge (array (
130: 'js/lib/jqueryui/jquery-ui.structure.css',
131: 'js/lib/datepicker/jquery.mobile.datepicker.css',
132: ), Yii::app()->params->isPhoneGap ? array () : array ('css/shared.css')),
133: YII_DEBUG && !self::$useMergedCss ? array(
134: 'css/main.css',
135: 'css/forms.css',
136: 'css/jqueryMobileCssOverrides.css',
137: 'css/login.css',
138: 'css/passwordReset.css',
139: 'css/recordIndex.css',
140: 'css/topicsIndex.css',
141: 'css/recordView.css',
142: 'css/recordCreate.css',
143: 'css/topicsCreate.css',
144: 'css/topicsView.css',
145: 'css/activityFeed.css',
146: 'css/settings.css',
147: 'css/about.css',
148: 'css/license.css',
149: 'css/recentItems.css',
150:
151: ) : array (
152: 'css/combined.css'
153: )),
154: 'depends' => array('jqueryMobileCss'),
155: ),
156: 'x2TouchJs' => array (
157: 'baseUrl' => $assetsUrl,
158: 'js' => array(
159: 'js/jQueryOverrides.js',
160: 'js/x2touchJQueryOverrides.js',
161: 'js/MobileForm.js',
162: 'js/Controller.js',
163: 'js/CameraButton.js',
164: 'js/Main.js',
165: 'js/MobileAutocomplete.js',
166: 'js/lib/jqueryui/jquery-ui.js',
167: 'js/lib/datepicker/jquery.mobile.datepicker.js',
168: ),
169: 'depends' => array('jqueryMobileJs', 'auxlib', 'bbq', 'X2Widget'),
170: ),
171:
172: 'x2TouchSupplementalCss' => array (
173: 'baseUrl' => Yii::app()->baseUrl,
174: 'css' => array_merge (
175: array (
176: 'themes/x2engine/css/fontAwesome/css/font-awesome.css',
177: 'themes/x2engine/css/css-loaders/load8.css',
178: //'themes/x2engine/css/x2IconsStandalone.css',
179: 'themes/x2engine/css/x2touchIcons.css',
180:
181: ),
182: YII_DEBUG && !self::$useMergedCss ? array(
183: ) : array ()),
184: ),
185: 'x2TouchSupplementalJs' => array (
186: 'baseUrl' => Yii::app()->baseUrl,
187: 'js' => array(
188: 'js/jQueryOverrides.js',
189: 'js/webtoolkit.sha256.js',
190: 'js/auxlib.js',
191: 'js/jstorage.min.js',
192: 'js/notifications.js',
193: 'js/Attachments.js',
194: ),
195: ),
196: 'yiiactiveform' => array(
197: 'js' => array('jquery.yiiactiveform.js'),
198: 'depends' => array('jqueryMobileJs'),
199: )
200: );
201: }
202:
203: public function init() {
204: // this method is called when the module is being created
205: // you may place code here to customize the module or the application
206: // import the module-level models and components
207: $this->setImport(array(
208: 'mobile.models.*',
209: 'mobile.components.*',
210: ));
211:
212: Yii::app()->clientScript->packages = self::getPackages ($this->assetsUrl);
213:
214: // set module layout
215: $this->layout = 'main';
216: }
217:
218: public function beforeControllerAction($controller, $action) {
219: if (parent::beforeControllerAction($controller, $action)) {
220: // this method is called before any module controller action is performed
221: // you may place customized code here
222: return true;
223: }
224: else
225: return false;
226: }
227:
228: }
229: