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

  • AccountsGridViewProfileWidget
  • ActionMenu
  • ActionsGridViewProfileWidget
  • ActionsQuickCreateRelationshipBehavior
  • ActiveDateRangeInput
  • ApplicationConfigBehavior
  • Attachments
  • ChatBox
  • CommonControllerBehavior
  • ContactMapInlineTags
  • ContactsGridViewProfileWidget
  • CronForm
  • CSaveRelationsBehavior
  • DateRangeInputsWidget
  • DocsGridViewProfileWidget
  • DocViewer
  • DocViewerProfileWidget
  • EButtonColumnWithClearFilters
  • EmailDeliveryBehavior
  • EmailProgressControl
  • EncryptedFieldsBehavior
  • EventsChartProfileWidget
  • FileUploader
  • FontPickerInput
  • Formatter
  • FormView
  • GridViewWidget
  • History
  • IframeWidget
  • ImportExportBehavior
  • InlineActionForm
  • InlineEmailAction
  • InlineEmailForm
  • InlineEmailModelBehavior
  • InlineQuotes
  • JSONEmbeddedModelFieldsBehavior
  • JSONFieldsDefaultValuesBehavior
  • LeadRoutingBehavior
  • LeftWidget
  • LoginThemeHelper
  • LoginThemeHelperBase
  • MarketingGridViewProfileWidget
  • MediaBox
  • MessageBox
  • MobileFormatter
  • MobileFormLayoutRenderer
  • MobileLayoutRenderer
  • MobileLoginThemeHelper
  • MobileViewLayoutRenderer
  • ModelFileUploader
  • NewWebLeadsGridViewProfileWidget
  • NormalizedJSONFieldsBehavior
  • NoteBox
  • OnlineUsers
  • OpportunitiesGridViewProfileWidget
  • Panel
  • ProfileDashboardManager
  • ProfileGridViewWidget
  • ProfileLayoutEditor
  • ProfilesGridViewProfileWidget
  • Publisher
  • PublisherActionTab
  • PublisherCalendarEventTab
  • PublisherCallTab
  • PublisherCommentTab
  • PublisherEventTab
  • PublisherSmallCalendarEventTab
  • PublisherTab
  • PublisherTimeTab
  • QuickContact
  • QuickCreateRelationshipBehavior
  • QuotesGridViewProfileWidget
  • RecordAliasesWidget
  • RecordViewLayoutManager
  • RecordViewWidgetManager
  • RememberPagination
  • Reminders
  • ResponseBehavior
  • ResponsiveHtml
  • SearchIndexBehavior
  • ServicesGridViewProfileWidget
  • SmallCalendar
  • SmartActiveDataProvider
  • SmartDataProviderBehavior
  • SmartSort
  • SocialForm
  • SortableWidgetManager
  • SortableWidgets
  • TagBehavior
  • TagCloud
  • TemplatesGridViewProfileWidget
  • TimeZone
  • TopContacts
  • TopSites
  • TransformedFieldStorageBehavior
  • TranslationLogger
  • TwitterFeed
  • TwoColumnSortableWidgetManager
  • UpdaterBehavior
  • UpdatesForm
  • UserIdentity
  • UsersChartProfileWidget
  • WorkflowBehavior
  • X2ActiveGridView
  • X2ActiveGridViewForSortableWidgets
  • X2AssetManager
  • X2AuthManager
  • X2ChangeLogBehavior
  • X2ClientScript
  • X2Color
  • X2DateUtil
  • X2FixtureManager
  • X2FlowFormatter
  • X2GridView
  • X2GridViewBase
  • X2GridViewForSortableWidgets
  • X2GridViewSortableWidgetsBehavior
  • X2LeadsGridViewProfileWidget
  • X2LinkableBehavior
  • X2ListView
  • X2PillBox
  • X2ProgressBar
  • X2SmartSearchModelBehavior
  • X2TimestampBehavior
  • X2TranslationBehavior
  • X2UrlRule
  • X2WebModule
  • X2Widget
  • X2WidgetList
  • 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: class RecordViewLayoutManager extends X2Widget {
 38: 
 39:     public $miscLayoutSettingsKey = 'recordViewColumnWidth';
 40: 
 41:     public $namespace = 'recordView'; 
 42: 
 43:     public $mainColumnSelector = '#main-column';
 44: 
 45:     /**
 46:      * @var bool $staticLayout
 47:      */
 48:     public $staticLayout = true; 
 49: 
 50:     public $JSClass = 'RecordViewLayoutEditor'; 
 51: 
 52:     private static $editLayoutButtonId = 'edit-record-view-layout';
 53: 
 54:     public $columnWidthPercentage = 65;
 55: 
 56:     private $responsiveCssId = 'main-column-responsive-css';
 57: 
 58:     public static function getEditLayoutActionMenuListItem () {
 59:         return array(
 60:             'name'=>'editLayout',
 61:             'linkOptions' => array (
 62:                 'id' => self::$editLayoutButtonId,
 63:             ),
 64:             'label'=>Yii::t('app', 'Edit Layout'),
 65:             'url'=>array('#')
 66:         );
 67:     }
 68: 
 69:     public static function getViewActionMenuListItem ($modelId) {
 70:         if (Yii::app()->controller->action->getId () === 'view') {
 71:             return array(
 72:                 'name'=>'view',
 73:                 'label' => 
 74:                     Yii::t('app', 'View').X2Html::minimizeButton (array (
 75:                         'class' => 'record-view-type-menu-toggle',
 76:                     ), '#record-view-type-menu', true, 
 77:                     Yii::app()->params->profile->miscLayoutSettings['viewModeActionSubmenuOpen']), 
 78:                 'encodeLabel' => false,
 79:                 'url' => array('view', 'id' => $modelId),
 80:                 'linkOptions' => array (
 81:                     // click minimize button
 82:                     'onClick' => '$(this).find ("i:visible").click ();', 
 83:                 ),
 84:                 'itemOptions' => array (
 85:                     'id' => 'view-record-action-menu-item',
 86:                 ),
 87:                 'submenuOptions' => array (
 88:                     'id' => 'record-view-type-menu',
 89:                     'style' => 
 90:                         Yii::app()->params->profile->miscLayoutSettings
 91:                             ['viewModeActionSubmenuOpen'] ? '' : 'display: none;',
 92:                 ),
 93:                 'items' => array (
 94:                     array (
 95:                         'encodeLabel' => false,
 96:                         'name'=>'journalView',
 97:                         'label' => CHtml::checkBox (
 98:                             'journalView', 
 99:                             Yii::app()->params->profile->miscLayoutSettings
100:                                 ['enableJournalView'], 
101:                             array (
102:                                 'class' => 'journal-view-checkbox',
103:                             )).CHtml::label (Yii::t('app', 'Journal View'), 'journalView'),
104:                     ),
105:                     array (
106:                         'encodeLabel' => false,
107:                         'name'=>'transactionalView',
108:                         'label' => CHtml::checkBox (
109:                             'transactionalView', 
110:                             Yii::app()->params->profile->miscLayoutSettings[
111:                                 'enableTransactionalView'], 
112:                             array (
113:                                 'class' => 'transactional-view-checkbox',
114:                             )).CHtml::label (
115:                                 Yii::t('app', 'List View'), 'transactionalView'),
116:                     ),
117:                 ),
118:             );
119:         } else {
120:             return array(
121:                 'name'=>'view',
122:                 'label' => Yii::t('app', 'View'),
123:                 'encodeLabel' => true,
124:                 'url' => array('view', 'id' => $modelId),
125:             );
126:         }
127:     }
128: 
129:     public function getPackages () {
130:         if (!isset ($this->_packages)) {
131:             $baseUrl = Yii::app()->getBaseUrl ();
132:             $this->_packages = array_merge (parent::getPackages (), array (
133:                 'layoutEditorJS' => array(
134:                     'baseUrl' => $baseUrl.'/js/',
135:                     'js' => array(
136:                         'LayoutEditor.js',
137:                         'RecordViewLayoutEditor.js',
138:                     ),
139:                     'depends' => array ('auxlib'),
140:                 ),
141:                 'layoutEditorCss' => array(
142:                     'baseUrl' => Yii::app()->theme->getBaseUrl (),
143:                     'css' => array(
144:                         '/css/components/views/layoutEditor.css',
145:                     )
146:                 ),
147:             ));
148:         }
149:         return $this->_packages;
150:     }
151: 
152:     public function getJSClassParams () {
153:         if (!isset ($this->_JSClassParams)) {
154:             $this->_JSClassParams = array_merge (parent::getJSClassParams (), array (
155:                 'defaultWidth' => '65',
156:                 'columnWidth' => $this->columnWidthPercentage,
157:                 'editLayoutButton' => '#'.self::$editLayoutButtonId,
158:                 'container' => '#'.$this->namespace.'-layout-editor',
159:                 'draggable' => '#'.$this->namespace.'-section-1',
160:                 'mainColumnSelector' => $this->mainColumnSelector,
161:                 'responsiveCssSelector' => '#'.$this->responsiveCssId,
162:                 'minWidths' => array (50, 35),
163:                 'column1' => array (
164:                     '#RecordViewWidgetManagerwidgets-container-2',
165:                     '#main-column',
166:                     '#'.$this->namespace.'-section-1',
167:                 ),
168:                 'column2' => array (
169:                     '#RecordViewWidgetManagerwidgets-container',
170:                 ),
171:                 'miscSettingsUrl' => 
172:                     Yii::app()->controller->createUrl('/profile/saveMiscLayoutSetting'),
173:                 'settingName' => $this->miscLayoutSettingsKey,
174:                 'dimensions' => array (
175:                     'singleColumnThresholdNoWidgets' => $this->singleColumnThresholdNoWidgets, 
176:                     'singleColumnThreshold' => $this->singleColumnThreshold, 
177:                     'extraContentWidth' => $this->extraContentWidth, 
178:                     'rightWidgetWidth' => $this->rightWidgetWidth, 
179:                     'formLayoutWidthThreshold' => $this->formLayoutWidthThreshold ,
180:                 ),
181:             ));
182:         }
183:         return $this->_JSClassParams;
184:     }
185: 
186:     public function init() {
187:         $miscLayoutSettings = Yii::app()->params->profile->miscLayoutSettings;
188:         if (!$this->staticLayout &&
189:             isset($miscLayoutSettings[$this->miscLayoutSettingsKey])) {
190: 
191:             $this->columnWidthPercentage = $miscLayoutSettings[$this->miscLayoutSettingsKey];
192:         }
193:         if (!$this->staticLayout) {
194:             $this->registerPackages ();
195:             $this->instantiateJSClass ();
196:         }
197: 
198:         parent::init ();
199:     }
200: 
201:     public function columnWidthStyleAttr ($columnNumber) {
202:         $columnWidth = $this->getColumnWidth (1);
203:         return "style='width: {$columnWidth};'";
204:     }
205: 
206:     public function getColumnWidth ($columnNumber) {
207:         $columnWidths = $this->getColumnWidths ($columnNumber); 
208:         return $columnWidths[$columnNumber - 1];
209:     }
210: 
211:     public function responsiveCss ($parentSelector) {
212:         return "
213:             $parentSelector .formSectionRow td {
214:                 // display: block;
215:                 // width: 100% !important;
216:             }
217:             $parentSelector .formSectionRow td > div{
218:                 // width: 100% !important;
219:             }
220:             $parentSelector .formItem.leftLabel > .formInputBox {
221:                 // width: 200px !important;
222:             }";
223:     }
224: 
225:     private $singleColumnThresholdNoWidgets = 1130; 
226:     private $singleColumnThreshold = 1407; 
227:     private $extraContentWidth = 160; 
228:     private $rightWidgetWidth = 280; 
229:     private $formLayoutWidthThreshold = 630; 
230: 
231:     public function registerResponsiveCss () {
232:         
233:         $columnWidthPercentage = $this->columnWidthPercentage / 100;
234: 
235:         // dynamic media queries which get removed if user edits layout
236:         Yii::app()->clientScript->registerCss('RecordViewLayoutManager::registerResponsiveCss',
237:             array (
238:             'text' => "
239:             @media (min-width:{$this->singleColumnThreshold}px) and (max-width: {$this->getFormLayoutResponsiveThreshold (true)}px) {
240:                 {$this->responsiveCss ('body.show-widgets')}
241:             }
242:             @media (min-width:{$this->singleColumnThresholdNoWidgets}px) and (max-width: {$this->getFormLayoutResponsiveThreshold (false)}px) {
243:                 {$this->responsiveCss ('body.no-widgets')}
244:             }",
245:             'htmlOptions' => array (
246:                 'id' => $this->responsiveCssId,
247:             ),
248:         ));
249:         // class-based responsive css which gets applied after user edits layout until page refresh
250:         Yii::app()->clientScript->registerCss('RecordViewLayoutManager::registerResponsiveCss2',
251:             $this->responsiveCss ($this->mainColumnSelector . '.force-single-column'));
252:     }
253: 
254:     public function run () {
255:         $layoutEditor = $this->render ('layoutEditor', array (
256:             'namespace' => $this->namespace,
257:         ), true);
258:         $this->registerResponsiveCss ();
259:         Yii::app()->clientScript->registerScript('RecordViewLayoutManager::run',"
260:             $('#main-column').before (".CJSON::encode ($layoutEditor).");
261:         ", CClientScript::POS_END);
262:     }
263: 
264:     private $_columnWidths;
265:     public function getColumnWidths () {
266:         if ($this->staticLayout) return array ('100%', '100%'); 
267:         if (!isset ($this->_columnWidths)) {
268:             if(!$this->columnWidthPercentage) {
269:                 $this->_columnWidths = array('', '');
270:             } else {
271:                 $column1 = $this->columnWidthPercentage;
272:                 $column2 = 100 - $column1;
273: 
274:                 $column1 = $column1.'%';
275:                 $column2 = $column2.'%';
276: 
277:                 $this->_columnWidths = array(
278:                     $column1,
279:                     $column2
280:                 );
281:             }
282:         }
283:         return $this->_columnWidths;
284:     }
285: 
286:     private function getFormLayoutResponsiveThreshold ($rightWidgets=true) {
287:         $columnWidthRatio = $this->columnWidthPercentage / 100;
288:         $extraContentWidth = $this->extraContentWidth;
289:         if ($rightWidgets) {
290:             $extraContentWidth += $this->rightWidgetWidth;
291:         }
292:         return $extraContentWidth + $this->formLayoutWidthThreshold + 
293:             ($this->formLayoutWidthThreshold * ( 1 - $columnWidthRatio)) / $columnWidthRatio;
294:     }
295: 
296: }
297: 
298: ?>
299: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0