kenken999/php
0
1<?php2class ProjectSettings3{4 var $_table;5 6 var $_pageMode;7 8 var $_pageType;9 10 var $_page;11 12 var $_viewPage = PAGE_VIEW;13 14 var $_defaultViewPage = PAGE_VIEW;15 16 var $_editPage = PAGE_EDIT;17 18 var $_defaultEditPage = PAGE_EDIT;19 20 var $_tableData = array();21 22 var $_optionsFile = array();23 24 /**25 * _auxTableData is used for all page-related settings such as getDefaultPage, getPageOption etc26 * The only page so far where table != auxTable is Register27 * table is <users> there and auxTable is GLOBAL_PAGES28 */29 var $_auxTable = "";30 var $_auxTableData = array();31 32 var $_pageOptions = array();33 34 var $_mastersTableData = array();35 36 var $_detailsTableData = array();37 38 var $_dashboardElemPSet = array();39 40 /**41 * @param String table - project entity where table and field-level settings are read from42 * @param pageType43 * @param page - specific page id. When empty, the default page of type $pageType is used.44 * IMPORTANT! $page is stronger that $pageType. When page contradicts pageType,45 * e.g. $page.type is 'view', but $pageType is 'list', $pageType is ignored46 * @param $pageTable - project entity where page-level settigns are read from. When empty, $table is used47 */48 function __construct($table = "", $pageType = "", $page = "", $pageTable = "")49 {50 if( !$table )51 $table = GLOBAL_PAGES;52 if( !$pageTable )53 $pageTable = $table;54 $this->setTable($table);55 if( $table == $pageTable) {56 $this->_auxTableData = & $this->_tableData;57 $this->_auxTable = $this->_table;58 } else {59 $this->loadAuxTable( $pageTable );60 }61 if( $page ) {62 // determine the page type to avoid unnecessary permission reading63 // when creating pSetSearch64 $this->_pageType = $this->getOriginalPageType( $page );65 }66 67 68 69 if( $page && array_key_exists($page, $this->getPageIds()) ) {70 $this->setPage($page);71 $this->setPageType( $this->getPageType() );72 } else {73 if( !$pageType ) {74 // pick default page type for the entity75 $pageType = $this->getDefaultPageType();76 }77 if( $pageType ) {78 $this->_pageType = $pageType;79 $page = $this->getDefaultPage( $pageType );80 if( $page )81 {82 $this->setPage( $page );83 }84 }85 }86 if( $page && !$pageType ) {87 $pageType = $this->getPageType();88 }89 if ( $pageType ) {90 $this->setPageType($pageType);91 }92 93 // substitute page if mobile substitution needed94 global $mediaType;95 $mobileSub = $this->getMobileSub();96 if( $mediaType && $mobileSub ) {97 if( array_key_exists( $mobileSub, $this->getPageIds()) ) {98 $this->setPage( $mobileSub );99 }100 }101 }102 103 /**104 * Return default poage type for the current entity105 */106 function getDefaultPageType() {107 $pageTypes = array();108 109 $pageTypes[ titTABLE ] = "list";110 $pageTypes[ titVIEW ] = "list";111 $pageTypes[ titREPORT ] = "report";112 $pageTypes[ titCHART ] = "chart";113 $pageTypes[ titDASHBOARD ] = "dashboard";114 $pageTypes[ titSQL ] = "list";115 $pageTypes[ titREST ] = "list";116 $pageTypes[ titSQL_REPORT ] = "report";117 $pageTypes[ titSQL_CHART ] = "chart";118 $pageTypes[ titREST_REPORT ] = "report";119 $pageTypes[ titREST_CHART ] = "chart";120 return $pageTypes[ $this->getEntityType() ];121 122 }123 124 function table() {125 return $this->_table;126 }127 128 function loadPageOptions( $option = "" ) {129 if( $this->_pageOptions )130 return;131 importPageOptions( $this->_auxTable, $this->_page );132 global $page_options;133 $this->_pageOptions = &$page_options[$this->_auxTable][$this->_page];134 135 136 }137 138 function setPage($page) {139 if( $page != $this->_page ) {140 $dummy = null;141 $this->_pageOptions = &$dummy;142 }143 $this->_page = $page;144 // there is no such page!145 if( array_search( $page, $this->getPageIds() ) === FALSE ) {146 return;147 }148 $this->_optionsFile = getabspath("include/pages/". GetTableURL( $this->_auxTable ) . "_" . $page . ".json");149 }150 151 function setTable($table)152 {153 $this->_table = $table;154 global $tables_data, $field_labels, $fieldToolTips, $placeHolders, $page_titles, $detailsTablesData, $masterTablesData, $bSubqueriesSupported;155 if(GetTableURL($table) != "") {156 importTableSettings( $table );157 }158 159 if(isset($tables_data[$this->_table]))160 $this->_tableData = &$tables_data[$this->_table];161 162 $this->_mastersTableData = &$masterTablesData[$this->_table];163 $this->_detailsTableData = &$detailsTablesData[$this->_table];164 165 $tableType = $this->getTableType();166 167 $this->_editPage = $this->getDefaultEditPageType($tableType);168 $this->_viewPage = $this->getDefaultViewPageType($tableType);169 $this->_defaultEditPage = $this->_editPage;170 $this->_defaultViewPage = $this->_viewPage;171 }172 173 function loadAuxTable($auxTable)174 {175 $this->_auxTable = $auxTable;176 global $tables_data;177 if(GetTableURL($auxTable) != "") {178 importTableSettings( $auxTable );179 }180 181 if(isset($tables_data[$this->_auxTable]))182 $this->_auxTableData = &$tables_data[$this->_auxTable];183 }184 185 186 function pageName() {187 return $this->_page;188 }189 190 function pageType() {191 return $this->_pageType;192 }193 194 195 /**196 * Return table where the page belongs. <global> for Login, Register page desite table==usersTable197 */198 function pageTable() {199 return $this->_auxTable;200 }201 202 function getDefaultViewPageType($tableType)203 {204 if($tableType == PAGE_CHART || $tableType == PAGE_REPORT)205 return $tableType;206 207 return PAGE_VIEW;208 }209 210 function getDefaultEditPageType($tableType)211 {212 if($tableType == PAGE_CHART || $tableType == PAGE_REPORT)213 return PAGE_SEARCH;214 215 return PAGE_EDIT;216 }217 218 function setPageType($page)219 {220 // a deeper checking for table and page types compatibility might be added here221 if($this->isPageTypeForView($page))222 {223 $tableType = $this->getTableType();224 if($tableType != "report" && $tableType != "chart"225 && ($page == PAGE_CHART || $page == PAGE_REPORT))226 $this->_viewPage = PAGE_LIST;227 else228 $this->_viewPage = $page;229 $this->_defaultViewPage = $this->getDefaultViewPageType($tableType);230 }231 if($this->isPageTypeForEdit($page))232 {233 $this->_editPage = $page;234 $this->_defaultEditPage = $this->getDefaultEditPageType($this->getTableType());235 }236 }237 238 function getDefaultPages() {239 $this->updatePages();240 return $this->getAuxTableData(".defaultPages");241 }242 243 function getDefaultPage( $type, $pageTable = "" ) {244 $this->updatePages();245 if( isAdminPage( $this->_auxTable ) )246 return $this->_pageType;247 $defPages =& $this->getAuxTableData(".defaultPages");248 $defPage = $defPages[$type];249 if( $defPage )250 return $defPage;251 return null;252 }253 254 function getPageIds() {255 $this->updatePages();256 $ret = $this->getAuxTableData(".pages");257 if( !is_array( $ret ) )258 return array();259 return $ret;260 }261 262 function getEditPageType()263 {264 return $this->_editPage;265 }266 267 function isPageTypeForView($ptype)268 {269 global $pageTypesForView;270 return in_array(strtolower($ptype), $pageTypesForView);271 }272 273 function isPageTypeForEdit($ptype)274 {275 global $pageTypesForEdit;276 return in_array(strtolower($ptype), $pageTypesForEdit);277 }278 279 /**280 * DEPRECATED281 * Use new ProjectSettings instead282 */283 function getTable($table, $page = "")284 {285 return new ProjectSettings($table, $page);286 }287 288 function getPageTypeByFieldEditFormat($field, $editFormat)289 {290 if(isset($this->_tableData[$field]) && isset($this->_tableData[$field][FORMAT_EDIT]))291 {292 foreach($this->_tableData[$field][FORMAT_EDIT] as $pageType => $editSettings)293 {294 if(isset($editSettings["EditFormat"]) && $editSettings["EditFormat"] == $editFormat)295 return $pageType;296 }297 }298 return "";299 }300 301 function getTableData($key)302 {303 if(!$this->isExistsTableKey($key))304 return $this->getDefaultValueByKey(substr($key,1));305 return $this->_tableData[$key];306 }307 308 function getAuxTableData($key)309 {310 if(!$this->isExistsAuxTableKey($key))311 return $this->getDefaultValueByKey(substr($key,1));312 return $this->_auxTableData[$key];313 }314 315 /**316 * Specify path to arguments in $key1, $key2 etc317 * Returns FALSE if not found318 */319 function getPageOption($key1, $key2 = FALSE, $key3 = FALSE, $key4 = FALSE, $key5 = FALSE )320 {321 $this->loadPageOptions( $key1.$key2 );322 if( !isset( $this->_pageOptions[ $key1 ] ) )323 return FALSE;324 $keys = array( $key1 );325 if( $key2!== FALSE )326 $keys[]= $key2;327 if( $key3!== FALSE )328 $keys[]= $key3;329 if( $key4!== FALSE )330 $keys[]= $key4;331 if( $key5!== FALSE )332 $keys[]= $key5;333 334 $opt = &$this->_pageOptions;335 foreach( $keys as $k ) {336 if( !is_array( $opt ) )337 return FALSE;338 if( !isset( $opt[ $k ] ) )339 return FALSE;340 $opt = &$opt[$k];341 }342 return $opt;343 }344 345 /**346 * Like getPageOption, but always returns an array347 */348 function getPageOptionAsArray($key1, $key2 = FALSE, $key3 = FALSE, $key4 = FALSE, $key5 = FALSE ) {349 $ret =& $this->getPageOption( $key1, $key2, $key3, $key4, $key5);350 if( !$ret || !is_array( $ret ) ) {351 return array();352 }353 return $ret;354 }355 356 /**357 * Specify path to arguments in $key1, $key2 etc358 * Returns FALSE if not found359 */360 function getPageOptionArray( $keys )361 {362 $this->loadPageOptions();363 $opt = &$this->_pageOptions;364 foreach( $keys as $k ) {365 if( !is_array( $opt ) )366 return FALSE;367 if( !isset( $opt[ $k ] ) )368 return FALSE;369 $opt = &$opt[$k];370 }371 return $opt;372 }373 374 375 private function getEffectiveEditPage( $field )376 {377 if( $this->isSeparate($field) )378 {379 return $this->_editPage;380 }381 return $this->_defaultEditPage;382 }383 384 private function getEffectiveViewPage( $field )385 {386 if( $this->isSeparate($field) )387 {388 if( $this->_pageMode == EDIT_INLINE && $this->_viewPage != PAGE_VIEW )389 return PAGE_LIST;390 else if ( $this->_pageMode == LIST_MASTER && $this->_viewPage == PAGE_LIST )391 return PAGE_MASTER_INFO_LIST;392 else if ( $this->_pageMode == LIST_MASTER && $this->_viewPage == PAGE_REPORT )393 return PAGE_MASTER_INFO_REPORT;394 else if ( $this->_pageMode == PRINT_MASTER && $this->_viewPage == PAGE_RPRINT )395 return PAGE_MASTER_INFO_RPRINT;396 else if ( $this->_pageMode == PRINT_MASTER )397 return PAGE_MASTER_INFO_PRINT;398 399 return $this->_viewPage;400 }401 return $this->_defaultViewPage;402 }403 function getFieldData( $field, $key )404 {405 global $g_settingsType;406 if( $this->getEntityType() == titDASHBOARD )407 {408 return $this->getDashFieldData( $field, $key );409 }410 411 if(!isset($this->_tableData[$field]))412 return $this->getDefaultValueByKey($key);413 414 $settingType = $g_settingsType[$key];415 if($settingType == null)416 $settingType = "";417 418 switch($settingType)419 {420 case SETTING_TYPE_VIEW:421 $viewPage = $this->getEffectiveViewPage( $field );422 423 if(isset($this->_tableData[$field][FORMAT_VIEW][$viewPage][$key]))424 return $this->_tableData[$field][FORMAT_VIEW][$viewPage][$key];425 break;426 case SETTING_TYPE_EDIT:427 $editPage = $this->getEffectiveEditPage( $field );428 429 if(isset($this->_tableData[$field][FORMAT_EDIT][$editPage][$key]))430 return $this->_tableData[$field][FORMAT_EDIT][$editPage][$key];431 break;432 default:433 if (isset($this->_tableData[$field][$key]))434 return $this->_tableData[$field][$key];435 break;436 }437 return $this->getDefaultValueByKey($key);438 }439 440 function setFieldData( $field, $key, $value )441 {442 $oldValue = $this->getFieldData( $field, $key );443 global $g_settingsType;444 445 $settingType = $g_settingsType[$key];446 if($settingType == null)447 $settingType = "";448 449 switch($settingType)450 {451 case SETTING_TYPE_VIEW:452 $viewPage = $this->getEffectiveViewPage( $field );453 $this->_tableData[$field][FORMAT_VIEW][$viewPage][$key] = $value;454 break;455 case SETTING_TYPE_EDIT:456 $editPage = $this->getEffectiveEditPage( $field );457 $this->_tableData[$field][FORMAT_EDIT][$editPage][$key] = $value;458 break;459 default:460 $this->_tableData[$field][$key] = $value;461 break;462 }463 return $oldValue;464 }465 466 /**467 * getTableName468 * Returns table name the class is created for469 */470 function getTableName()471 {472 return $this->_table;473 }474 475 /**476 * findField477 * Returns field name in correct case if the field is found. Empty string otherwise.478 * @param {string} field name in arbitrary case, original or GoodFieldName result479 */480 481 function findField( $f )482 {483 global $field_labels, $mlang_defaultlang;484 // check exact match485 $fields = $this->getFieldsList();486 if( array_search( $f, $fields ) !== FALSE )487 return $f;488 489 // check goodfieldname490 $gTable = GoodFieldName( $this->_table );491 if( isset( $field_labels[ $mlang_defaultlang ][ $f ] ) )492 return $this->getFieldByGoodFieldName( $f );493 494 // case-insensitive check495 $f = strtoupper( $f );496 foreach( $fields as $ff )497 {498 if( strtoupper( $ff ) == $f )499 return $ff;500 501 if( strtoupper( GoodFieldName($ff) ) == $f )502 return $ff;503 }504 return "";505 506 }507 508 /**509 * addCustomExpressionIndex510 * Add new index to list, for determination of custom expressions position in SQL query511 * @param {string} table wich contain a lookup field512 * @param {string} name of lookup field513 * @param {int} index514 */515 function addCustomExpressionIndex($mainTable, $mainField, $index)516 {517 if(!$this->isExistsTableKey(".customExpressionIndexes"))518 $this->_tableData[".customExpressionIndexes"] = array();519 if(!isset($this->_tableData[".customExpressionIndexes"][$mainTable]))520 $this->_tableData[".customExpressionIndexes"][$mainTable] = array();521 $this->_tableData[".customExpressionIndexes"][$mainTable][$mainField] = $index;522 }523 524 /**525 * getCustomExpressionIndex526 * Get index of custom expression in SQL field527 * @param {string} table wich contain a lookup field528 * @param {string} name of lookup field529 */530 function getCustomExpressionIndex($mainTable, $mainField)531 {532 if(!$this->isExistsTableKey(".customExpressionIndexes"))533 $this->_tableData[".customExpressionIndexes"] = array();534 if(isset($this->_tableData[".customExpressionIndexes"][$mainTable])535 && isset($this->_tableData[".customExpressionIndexes"][$mainTable][$mainField]))536 return $this->_tableData[".customExpressionIndexes"][$mainTable][$mainField];537 538 return FALSE;539 }540 541 function isExistsTableKey($key)542 {543 if(!isset($this->_tableData[$key]))544 return false;545 return true;546 }547 548 function isExistsAuxTableKey($key)549 {550 if(!isset($this->_auxTableData[$key]))551 return false;552 return true;553 }554 555 function isExistsFieldKey($field, $key)556 {557 if(!$this->isExistsTableKey($field))558 return false;559 if(!isset($this->_tableData[$field][$key]))560 return false;561 return true;562 }563 564 function getDefaultValueByKey($key)565 {566 global $g_defaultOptionValues;567 if(isset($g_defaultOptionValues[$key]))568 return $g_defaultOptionValues[$key];569 return false;570 }571 572 /**573 * Returns array of master tables , which are master for current detail table574 * @return array if success otherwise false575 */576 function getMasterTablesArr()577 {578 return $this->_mastersTableData;579 }580 581 /**582 * Returns array of master keys for passed detailTable583 *584 * @param string $dTableName - it's detail data sourse table name,585 * @return array if success otherwise false586 */587 function getMasterKeysByDetailTable($dTableName, $default = array())588 {589 if(!$dTableName)590 return $default;591 foreach ($this->_detailsTableData as $dTableDataArr)592 {593 if ($dTableDataArr['dDataSourceTable'] == $dTableName)594 return $dTableDataArr['masterKeys'];595 }596 return $default;597 }598 599 /**600 * Returns array of detail tables , which are detail for current master table601 * @param string $tName - it's data source master table name602 * @return array if success otherwise false603 */604 function getDetailTablesArr()605 {606 if( !is_array( $this->_detailsTableData ) )607 return array();608 return $this->_detailsTableData;609 }610 611 /**612 * Returns array of detail keys for passed masterTable613 *614 * @param string $mTableName - it's master table name,615 * @param array $default616 * @return array if success otherwise default value617 */618 function getDetailKeysByMasterTable($mTableName = "", $default = array())619 {620 if(!$mTableName)621 return $default;622 foreach($this->_mastersTableData as $mTableDataArr)623 {624 if ($mTableDataArr['mDataSourceTable'] == $mTableName)625 return $mTableDataArr['detailKeys'];626 }627 return $default;628 }629 630 /**631 * Returns array of detail keys for passed detailTable632 *633 * @param string $dTableName - It's detail data sourse table name634 * @param string $tName - current(master) table name635 * @return array if success otherwise false636 */637 function getDetailKeysByDetailTable($dTableName, $default = array())638 {639 foreach ($this->_detailsTableData as $dTableDataArr)640 {641 if ($dTableDataArr['dDataSourceTable'] == $dTableName)642 return $dTableDataArr['detailKeys'];643 }644 return $default;645 }646 647 /**648 * Returns details preview Type649 *650 * @param string $dTableName - it's detail data sourse table name,651 * @param string $tName - current(master) table name652 * @return array if success otherwise false653 */654 function getDPType($dTableName)655 {656 if(!$dTableName)657 return false;658 foreach ($this->_detailsTableData as $dTableDataArr)659 {660 if ($dTableDataArr['dDataSourceTable'] == $dTableName)661 return $dTableDataArr['previewOnList'];662 }663 return false;664 }665 666 function GetFieldByIndex($index)667 {668 foreach($this->_tableData as $key => $value)669 {670 if(!is_array($value))671 continue;672 elseif(!isset($value["Index"]))673 continue;674 if($value["Index"] == $index && $this->getFieldIndex($key))675 return $key;676 }677 return null;678 }679 680 // Is field has separate type for editing and viewing681 function isSeparate($field)682 {683 return !!$this->_tableData[$field]["isSeparate"];684 }685 686 // return field label687 function label($field)688 {689 $result = GetFieldLabel( GoodFieldName($this->_table), GoodFieldName($field) );690 return $result != "" ? $result : $field;691 }692 693 // return filename field if any694 // viewFormat setting695 function getFilenameField($field)696 {697 return $this->getFieldData($field, "Filename");698 }699 700 // return hyperlink prefix701 // viewFormat setting702 function getLinkPrefix($field)703 {704 return $this->getFieldData($field, "LinkPrefix");705 }706 707 /**708 * Get hyperlink type709 */710 function getLinkType($field)711 {712 return $this->getFieldData($field, "hlType");713 }714 715 /**716 * Get hyperlink display field for title717 * @return string field name718 */719 function getLinkDisplayField($field)720 {721 return $this->getFieldData($field, "hlTitleField");722 }723 724 function openLinkInNewWindow($field)725 {726 return $this->getFieldData($field, "hlNewWindow");727 }728 729 function getLinkWordNameType($field)730 {731 return $this->getFieldData($field, "hlLinkWordNameType");732 }733 734 function getLinkWordText($field)735 {736 return $this->getFieldData($field, "hlLinkWordText");737 }738 739 // return database field type740 // using ADO DataTypeEnum constants741 // the full list available at:742 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdcstdatatypeenum.asp743 function getFieldType($field)744 {745 return $this->getFieldData($field, "FieldType");746 }747 748 function getFieldDateFormat($field)749 {750 return $this->getFieldData($field, "dateFormat");751 }752 753 function isAutoincField($field)754 {755 return $this->getFieldData($field, "AutoInc");756 }757 758 function getDefaultValue($field, $table = "")759 {760 $tableName = $table ? $table : $this->_table;761 $editPage = $this->_editPage;762 if(!$this->isSeparate($field))763 return;764 return GetDefaultValue($field, $editPage, $tableName);765 }766 767 function isAutoUpdatable($field)768 {769 return $this->getFieldData($field, "autoUpdatable");770 }771 772 function getAutoUpdateValue($field)773 {774 $editPage = $this->_editPage;775 if(!$this->isSeparate($field))776 $editPage = $this->getDefaultEditPageType($this->getTableType());;777 return GetAutoUpdateValue($field, $editPage, $this->_table);778 }779 780 // return Edit format781 // editFormats782 function getEditFormat($field)783 {784 return $this->getFieldData($field, "EditFormat");785 }786 787 // return View format788 // viewFormat setting789 function getViewFormat($field)790 {791 return $this->getFieldData($field, "ViewFormat");792 }793 794 // show time in datepicker or not795 function dateEditShowTime($field)796 {797 return $this->getFieldData($field, "ShowTime");798 }799 800 function lookupControlType($field)801 {802 return $this->getFieldData($field, "LCType");803 }804 805 function lookupListPageId($field)806 {807 return $this->getFieldData($field, "listPageId");808 }809 function lookupAddPageId($field)810 {811 return $this->getFieldData($field, "addPageId");812 }813 814 function isDeleteAssociatedFile($field)815 {816 return $this->getFieldData($field, "DeleteAssociatedFile");817 }818 819 // is Lookup wizard dependent or not820 function useCategory($field)821 {822 return $this->getFieldData($field, "UseCategory");823 }824 825 // is Lookup wizard with multiple selection826 function multiSelect($field)827 {828 return $this->getFieldData($field, "Multiselect");829 }830 831 /**832 * Returns list of fields in the table that use cloud storage providers833 * Only OAuth providers are checked here834 * GoogleDrive, OneDrive, Dropbox835 * @return Array of string836 */837 function getOAuthCloudFields() {838 if( !GetGlobalData( "GoogleDriveClientID" )839 && !GetGlobalData( "OneDriveClientID" )840 && !GetGlobalData( "DropboxClientID" )841 ) {842 // nothing to check843 return array();844 }845 $fields = array();846 foreach( $this->getFieldsList() as $field ) {847 $stp = $this->fileStorageProvider( $field );848 if( $stp === stpGOOGLEDRIVE849 || $stp === stpDROPBOX850 || $stp === stpONEDRIVE ) {851 852 $fields[] = $field;853 }854 }855 return $fields;856 }857 858 /**859 * When a field is edited as single-select lookup wizard860 * Use case:861 * if( $pSet->multiSelect() && $pSet->singleSelectLookupEdit() )862 * multiselect on search, single-select on add/edit.863 * In that specific case multiple selected search values864 * should be interpreted as:865 * field=value1 or field=value2 or etc866 *867 */868 function singleSelectLookupEdit( $field )869 {870 $hasLookup = false;871 foreach( $this->_tableData[$field][FORMAT_EDIT] as $pageType => $editFormat ) {872 if( $pageType != "edit" && $pageType != "add" )873 continue;874 if( $editFormat["EditFormat"] != EDIT_FORMAT_LOOKUP_WIZARD )875 continue;876 $hasLookup = true;877 if( $editFormat["Multiselect"] )878 return false;879 }880 return $hasLookup;881 }882 883 /**884 * Check whether the field is a true multiselect lookup.885 * True multiselect has this option on Add or Edit page, not only on Search.886 */887 function multiSelectLookupEdit( $field )888 {889 foreach( $this->_tableData[$field][FORMAT_EDIT] as $pageType => $editFormat ) {890 if( $pageType != "edit" && $pageType != "add" )891 continue;892 if( $editFormat["EditFormat"] != EDIT_FORMAT_LOOKUP_WIZARD )893 continue;894 if( $editFormat["Multiselect"] )895 return true;896 }897 return false;898 }899 900 /**901 * Check whether the field is a lookup wizard with Link Field != Display field.902 */903 function lookupField( $field )904 {905 foreach( $this->_tableData[$field][FORMAT_EDIT] as $pageType => $editFormat ) {906 if( $editFormat["EditFormat"] != EDIT_FORMAT_LOOKUP_WIZARD )907 continue;908 if( $editFormat["LinkField"] != $editFormat["DisplayField"] )909 return true;910 }911 return false;912 }913 914 915 // Lookup wizard select size916 function selectSize($field)917 {918 return $this->getFieldData($field, "SelectSize");919 }920 921 function showThumbnail($field)922 {923 return $this->getFieldData($field, "ShowThumbnail");924 }925 926 function isImageURL($field)927 {928 return $this->getFieldData($field, "fieldIsImageUrl");929 }930 931 function showCustomExpr($field)932 {933 return $this->getFieldData($field, "ShowCustomExpr");934 }935 936 function showFileSize($field)937 {938 return $this->getFieldData($field, "ShowFileSize");939 }940 941 function displayPDF($field)942 {943 return $this->getFieldData($field, "DisplayPDF");944 }945 946 function showIcon($field)947 {948 return $this->getFieldData($field, "ShowIcon");949 }950 951 function getImageWidth($field)952 {953 return $this->getFieldData($field, "ImageWidth");954 }955 956 function getImageHeight($field)957 {958 return $this->getFieldData($field, "ImageHeight");959 }960 961 function getThumbnailWidth($field)962 {963 return $this->getFieldData($field, "ThumbWidth");964 }965 966 function getThumbnailHeight($field)967 {968 return $this->getFieldData($field, "ThumbHeight");969 }970 971 // Get nLookupType for current field972 function getLookupType($field)973 {974 return $this->getFieldData($field, "LookupType");975 }976 977 //Get lookup table name978 function getLookupTable($field)979 {980 return $this->getFieldData($field, "LookupTable");981 }982 983 /**984 * Returns true if Lookup Where clause is specified as PHP code expression985 * @return Boolean986 */987 function isLookupWhereCode($field)988 {989 return $this->getFieldData($field, "LookupWhereCode");990 }991 992 function isLookupWhereSet($field)993 {994 if( $this->isLookupWhereCode( $field ) )995 return true;996 return 0 != strlen( $this->getFieldData($field, "LookupWhere") );997 }998 999 1000 function getLookupWhere($field)1001 {1002 if( $this->isLookupWhereCode( $field )) {1003 $tName = $this->_table;1004 if( $this->getEntityType() == titDASHBOARD )1005 {1006 $dashSearchFields = $this->getDashboardSearchFields();1007 if( isset($dashSearchFields[$field]) ) {1008 $tName = $dashSearchFields[$field][0]["table"];1009 $field = $dashSearchFields[$field][0]["field"];1010 }1011 }1012 1013 return GetLWWhere( $field, $this->getEffectiveEditPage( $field ), $tName );1014 }1015 1016 return $this->getFieldData($field, "LookupWhere");1017 }1018 1019 1020 1021 function getNotProjectLookupTableConnId($field)1022 {1023 return $this->getFieldData($field, "LookupConnId");1024 }1025 1026 function getConnId()1027 {1028 $connId = $this->getTableData( ".connId" );1029 if( $connId == "" ) {1030 return "chats_at_localhost";1031 }1032 return $connId;1033 }1034 1035 function getLinkField($field)1036 {1037 return $this->getFieldData($field, "LinkField");1038 }1039 1040 function getLWLinkFieldType($field)1041 {1042 return $this->getFieldData($field, "LinkFieldType");1043 }1044 1045 function getDisplayField($field)1046 {1047 return $this->getFieldData($field, "DisplayField");1048 }1049 1050 function getCustomDisplay($field)1051 {1052 return $this->getFieldData($field, 'CustomDisplay');1053 }1054 1055 // viewFormats1056 function NeedEncode($field)1057 {1058 return $this->getFieldData($field, "NeedEncode");1059 }1060 1061 /**1062 * Get array of validation for control1063 * return array - of validations1064 */1065 function getValidation($field)1066 {1067 return $this->getFieldData($field, "validateAs");1068 }1069 1070 1071 /**1072 * Returns array of items for a given field1073 */1074 function getFieldItems( $field )1075 {1076 return $this->getPageOption( "fields", "fieldItems", $field );1077 }1078 1079 /**1080 * Returns array of group fields1081 */1082 function getGroupFields()1083 {1084 return $this->getPageOption( "dataGrid", "groupFields");1085 }1086 1087 /**1088 * Check is appear current field on list page1089 * return boolean - true or false1090 */1091 function appearOnListPage($field)1092 {1093 if( array_search( $field, $this->getPageOption("fields", "gridFields") ) !== FALSE )1094 return true;1095 if( isReport( $this->getEntityType() ) ) {1096 return array_search( $field, $this->getReportGroupFields() ) !== FALSE;1097 }1098 return false;1099 }1100 1101 /**1102 * Check is appear current field on add page1103 * return boolean - true or false1104 */1105 function appearOnAddPage($field)1106 {1107 return $this->appearOnPage( $field );1108 }1109 1110 /**1111 * Check is appear current field on inline add1112 * return boolean1113 */1114 function appearOnInlineAdd($field)1115 {1116 $fields =& $this->getInlineAddFields();1117 if( !$fields ) {1118 return false;1119 }1120 return array_search( $field, $fields ) !== FALSE;1121 }1122 1123 /**1124 * Check is appear current field on edit page1125 * return boolean - true or false1126 */1127 function appearOnEditPage($field)1128 {1129 return $this->appearOnPage( $field );1130 }1131 1132 /**1133 * Check is appear current field on edit page1134 * return boolean - true or false1135 */1136 function appearOnInlineEdit($field)1137 {1138 $inlineFields =& $this->getInlineEditFields();1139 if( !$inlineFields ) {1140 return false;1141 }1142 return array_search( $field, $inlineFields ) !== FALSE;1143 //return $this->getFieldData($field, "bInlineEdit");1144 }1145 1146 /**1147 * Check is appear current field on edit page1148 * return boolean - true or false1149 */1150 function appearOnUpdateSelected($field)1151 {1152 $updateOnEditFields = $this->getPageOption("fields", "updateOnEditFields");1153 if( !$updateOnEditFields )1154 return false;1155 1156 return array_search( $field, $this->getPageOption("fields", "updateOnEditFields") ) !== FALSE;1157 //return $this->getFieldData($field, "bUpdateSelected");1158 }1159 1160 function appearOnPage($field)1161 {1162 $gridFields = &$this->getPageOption("fields", "gridFields");1163 if( !$gridFields )1164 $ret = false;1165 else1166 $ret = ( array_search( $field, $gridFields ) !== FALSE );1167 if( !$ret ) {1168 if( $this->getPageType() === 'report' || $this->getPageType() === 'rprint' )1169 return array_search( $field, $this->getReportGroupFields() ) !== false;1170 }1171 return $ret;1172 }1173 1174 function appearOnSearchPanel($field)1175 {1176 $fields = &$this->getPageOption("fields", "searchPanelFields");1177 if( !$fields )1178 return false;1179 1180 return array_search( $field, $fields ) !== FALSE;1181 }1182 1183 1184 function appearAlwaysOnSearchPanel( $field ) {1185 $fields = &$this->getPageOption("listSearch", "alwaysOnPanelFields");1186 if( !$fields )1187 return false;1188 1189 return array_search( $field, $fields ) !== FALSE;1190 1191 }1192 1193 function getPageFields()1194 {1195 $fields = $this->getPageOptionAsArray("fields", "gridFields" );1196 if( isReport( $this->getEntityType() ) ) {1197 return array_merge( $fields, $this->getReportGroupFields() );1198 }1199 return $fields;1200 }