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: /**
 38:  * Child Class of Record View to display a form with inline
 39:  * editing. 
 40:  * @author Alex Rowe <alex@x2engine.com>
 41:  */
 42: class DetailView extends RecordView {
 43: 
 44:     public $JSClass = 'DetailView';
 45: 
 46:     /**
 47:      * Wether to make link fields link
 48:      * @var boolean
 49:      */
 50:     public $nameLink = false;
 51: 
 52:     /**
 53:      * Whether to restrict this view to half width
 54:      * @var boolean
 55:      */
 56:     public $halfWidth = false;
 57: 
 58:     /**
 59:      * @var array $disableInlineEditingFor Names of fields for which inline editing should be 
 60:      *  disabled
 61:      */
 62:     public $disableInlineEditingFor = array (); 
 63: 
 64:     public function getPackages () {
 65:         return array_merge (parent::getPackages(), array(
 66:             'DetailViewJS' => array(
 67:                 'baseUrl' => Yii::app()->baseUrl.'/js/recordView/',
 68:                 'js' => array(
 69:                     'inlineEditor.js',
 70:                     'DetailView.js'
 71:                 ),
 72:                 'depends' => array('RecordViewJS')
 73:             )
 74:         ));
 75:     }
 76: 
 77:     public function getJSClassParams () {
 78:         return array_merge (parent::getJSClassParams(), array(
 79:             'inlineEdit' => Yii::app()->controller->checkPermissions($this->model,'edit'),
 80:         ));
 81:     }
 82: 
 83:     public function getTranslations () {
 84:         return array (
 85:             'unsavedChanges' => Yii::t('app', 'There are unsaved changes on this page')
 86:         );
 87:     }
 88: 
 89:     /**
 90:      * Modified to add half-width tag and extra classes
 91:      */
 92:     public function getMainOptions () {
 93:         $width = $this->halfWidth ? 'half-width' : '';
 94: 
 95:         return X2Html::mergeHtmlOptions (array (
 96:             'class' => "x2-layout detail-view $width",
 97:             'id' => $this->namespace . 'detail-view',
 98:         ), $this->htmlOptions);
 99:     }
100: 
101:     /**
102:      * Modified to add inline-edit class if necessary
103:      */
104:     public function getItemOptions($item, Fields $field) {
105:         $inlineEdit = $this->canEdit($field) ? ' inline-edit' : '';
106: 
107:         $parent = parent::getItemOptions($item, $field);
108:         $parent['class'] .= $inlineEdit;
109: 
110:         return $parent;
111:     }
112: 
113:     /**
114:      * Renders the attribute and invisible inline edit field
115:      * if user can inline-edit
116:      */
117:     public function renderAttribute ($item, Fields $field) {
118:         $class = '';
119:         $style = '';
120:         if ($field->type == 'text') {
121:             $class = 'textBox';
122:             $style .= 'min-height:' . $item['height'] . 'px';
123:         }
124: 
125:         $html = X2Html::openTag('div', array(
126:             'class' => "formInputBox $class",
127:             'style' => $style,
128:         ));
129: 
130:         if($this->canEdit($field)) {
131:             $html .= $this->renderInput ($item, $field);
132:         }
133: 
134:         $html .= X2Html::tag('span', array(
135:             'class' => 'model-attribute',
136:             'id' => $field->modelName.'_'.$field->fieldName.'_field-field'
137:         ));
138: 
139:         if (isset($this->specialFields[$field->fieldName])) {
140:             $html .= $this->specialFields[$field->fieldName];
141:         } else if ($field->fieldName == 'name' && $this->nameLink &&
142:             $this->model->asa('X2LinkableBehavior')) {
143:                 $html .= $this->model->link;
144:         } else {
145:             $rendered = $this->model->renderAttribute ($field->fieldName, true, false);
146:             if (!$rendered) $rendered = '&nbsp;';
147:             $html .= $rendered;
148:         }
149: 
150:         $html .= '</span>';
151:         $html .= '</div>';
152: 
153:         if ($this->canEdit($field)) {
154:             $html .= $this->renderInlineButtons();
155:         }
156: 
157:         return $html;
158:     }
159: 
160:     /**
161:      * renders the hidden input for an attribute
162:      * @param  [type] $item  [description]
163:      * @param  [type] $field [description]
164:      * @return [type]        [description]
165:      */
166:     public function renderInput ($item, $field){
167:         $html = X2Html::openTag('span', array(
168:             'class' => 'model-input',
169:             'id' => $field->modelName.'_'.$field->fieldName.'_field-input',
170:             'style' => 'display:none',
171:         ));
172:         
173:         $html .= $this->model->renderInput($field->fieldName, array(
174:             'tabindex' => $item['tabindex'],
175:             'disabled' => $item['readOnly'] ? 'disabled' : '',
176:         ));
177: 
178:         $html .= '</span>';
179:         return $html;
180:     }
181: 
182: 
183:     /**
184:      * renders inline edit buttons in the extra column
185:      */
186:     public function renderInlineButtons () {
187:         $html = '<div class="inline-edit-icons">';
188: 
189:         $html .= CHtml::link (X2Html::fa('fa-edit'), '#', array(
190:             'class' => 'edit-icon active',
191:             'title' => Yii::t('app','Edit field'),
192:         ));
193: 
194:         $html .= CHtml::link (X2Html::fa('fa-times-circle'), '#', array(
195:             'class' => 'cancel-icon',
196:             'title' => Yii::t('app', 'Cancel changes'),
197:         ));
198: 
199:         $html .= CHtml::link (X2Html::fa('fa-check-circle'), '#', array(
200:             'class' => 'confirm-icon',
201:             'title' => Yii::t('app', 'Confirm changes'),
202:         ));
203: 
204:         $html .= '</div>';
205:         return $html;
206:     }
207: 
208: 
209: 
210:     public function getLayoutData() {
211:         $layoutData = Yii::app()->cache->get('form_' . $this->modelName . '_' . $this->scenario);
212:         if ($layoutData) {
213:             return $layoutData;
214:         }
215: 
216:         $layout = FormLayout::model()->findByAttributes(
217:             array(
218:                 'model' => ucfirst($this->modelName),
219:                 'defaultView' => 1,
220:                 'scenario' => $this->scenario
221:             ));
222: 
223:         if(!$layout && $this->scenario === 'Inline') {
224:             $layout = FormLayout::model()->findByAttributes(
225:                 array(
226:                     'model' => ucfirst($this->modelName),
227:                     'defaultView' => 1,
228:                     'scenario' => 'Default'
229:                 ));
230:         }
231: 
232:         if(isset($layout)) {
233:             $layoutData = json_decode($layout->layout, true);
234:             Yii::app()->cache->set('form_' . $this->modelName . '_' . $this->scenario, $this->layoutData, 0);    // cache the data
235:         }
236: 
237:         return $layoutData;
238:     }
239: 
240:     /**
241:      * Added condition that scenario is not Inline. be aware
242:      * 'Inline' does not refer to inline-edit, but rather Inline view,
243:      * turned on in a quickView for example.
244:      */
245:     public function canEdit(Fields $field) {
246:         return !in_array ($field->fieldName, $this->disableInlineEditingFor) &&
247:             parent::canEdit ($field) && $this->scenario !== 'Inline';
248:     }
249: }
250: 
251: ?>
252: 
X2CRM Documentation API documentation generated by ApiGen 2.8.0