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 X2ActiveGridView extends X2GridViewBase {
 38: 
 39:     public $modelName;
 40:     public $fieldFormatter = 'X2ActiveRecordFieldFormatter';
 41:     public $specialColumns = array ();
 42:     public $columnOverrides = array ();
 43:     public $includedFields = array ();
 44:     public $excludedFields = array ();
 45:     public $isAdmin = false;
 46:     protected $specialColumnNames = array();
 47: 
 48:     protected $_model;
 49:     public function getModel ($row=null, $data=null) {
 50:         if (!isset ($this->_model)) {
 51:             $modelName = $this->modelName;
 52:             $this->_model = $modelName::model ();
 53:         }
 54:         return $this->_model;
 55:     }
 56: 
 57:     public function setFormatter ($data) {
 58:         if (isset ($this->fieldFormatter) && 
 59:             method_exists ($data, 'setFormatter')) {
 60: 
 61:             $data->formatter = $this->fieldFormatter;
 62:         }
 63:         return $data;
 64:     }
 65: 
 66:     public function setSummaryText () {
 67:         if ($this instanceof X2GridViewForSortableWidgets ||
 68:             $this instanceof X2ActiveGridViewForSortableWidgets) {
 69:             $this->setSummaryTextForSortableWidgets ();
 70:             return;
 71:         }
 72:         $this->asa ('X2BaseListViewBehavior')->setSummaryText ();
 73:     }
 74: 
 75:     protected function addSpecialFieldNames () {
 76:         // load names from $specialColumns into $specialColumnNames
 77:         foreach($this->specialColumns as $columnName => &$columnData) {
 78:             if(isset($columnData['header'])) {
 79:                 $this->specialColumnNames[$columnName] = $columnData['header'];
 80:             } else {
 81:                 $this->specialColumnNames[$columnName] = 
 82:                     $this->getModel ()->getAttributeLabel ($columnName);
 83:             }
 84:         }
 85: 
 86:         if(!empty($this->specialColumnNames))
 87:             $this->allFieldNames = array_merge ($this->allFieldNames, $this->specialColumnNames);
 88: 
 89:     }
 90: 
 91: 
 92:     protected function addFieldNames () {
 93:         $this->addSpecialFieldNames ();
 94: 
 95:         foreach($this->includedFields ? 
 96:             $this->includedFields :
 97:             array_diff ($this->getModel ()->attributeNames (), $this->excludedFields) as 
 98:             $fieldName) {
 99: 
100:             $this->allFieldNames[$fieldName] = $this->getModel ()->getAttributeLabel ($fieldName);
101:         }
102:     }
103: 
104:     protected function createSpecialColumn ($columnName, $width) {
105:         $newColumn = $this->specialColumns[$columnName];
106:         $newColumn['id'] = $this->namespacePrefix.'C_'.$columnName;
107:         $newColumn['headerHtmlOptions'] = array('style'=>'width:'.$this->formatWidth ($width).';');
108:         if (!isset ($newColumn['name']) && !isset ($newColumn['value'])) {
109:             $newColumn['name'] = $columnName;
110:         }
111:         return $newColumn;
112:     }
113: 
114: 
115:     protected function generateColumns () {
116:         $columns = array ();
117: 
118:         foreach($this->gvSettings as $columnName => $width) {
119:             if($columnName == 'gvControls' && !$this->enableControls){
120:                 continue;
121:             }
122: 
123:             $col = $this->addNewColumn ($columnName, $this->formatWidth ($width));
124:             if (sizeof ($col))
125:                 $columns[] = $col;
126:         }
127: 
128:         $this->columns = $columns;
129:     }
130: 
131:     /**
132:      * @param int $width 
133:      * @param string $columnName 
134:      * @return array the new column
135:      */
136:     protected function addNewColumn ($columnName, $width) {
137:         $newColumn = array ();
138:         if(array_key_exists($columnName,$this->specialColumnNames)) {
139:             $newColumn = $this->createSpecialColumn ($columnName, $width);
140:         } else if($columnName == 'gvControls') {
141:             $newColumn = $this->getGvControlsColumn ($width);
142:             if(!$this->isAdmin)
143:                 $newColumn['template'] = '{view}{update}';
144:         } else if ($columnName == 'gvCheckbox') {
145:             $newColumn = $this->getGvCheckboxColumn ($width);
146:         } else {
147:             $newColumn = $this->createDefaultStyleColumn ($columnName, $width);
148:         }
149:         if ($newColumn === array ()) return $newColumn;
150:         $newColumn['htmlOptions'] = X2Html::mergeHtmlOptions (
151:             isset ($newColumn['htmlOptions']) ? 
152:                 $newColumn['htmlOptions'] : array (), array ('width' => $width));
153: 
154:         if (isset ($this->columnOverrides[$columnName])) {
155:             $newColumn = array_merge ($newColumn, $this->columnOverrides[$columnName]);
156:         }
157: 
158:         return $newColumn;
159:     }
160: 
161:     protected function createDefaultStyleColumn ($columnName, $width) {
162:         $isCurrency = in_array($columnName,array('annualRevenue','quoteAmount'));
163:         $newColumn = array();
164: 
165:         if (in_array ($columnName, array_keys ($this->allFieldNames))) { 
166: 
167:             $newColumn['name'] = $columnName;
168:             $newColumn['id'] = $this->namespacePrefix.'C_'.$columnName;
169:             $newColumn['header'] = $this->getModel ()->getAttributeLabel($columnName);
170:             $newColumn['headerHtmlOptions'] = array(
171:                 'style'=>'width:'.$this->formatWidth ($width).';');
172: 
173:             $newColumn['value'] = 
174:                  '$this->grid->setFormatter ($data)
175:                      ->renderAttribute ("'.$columnName.'", false);';
176:         } 
177:         return $newColumn;
178:     }
179: 
180: }
181: 
182: ?>
183: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0