예제 #1
1
 /**
  * Static function for create list page
  * Read params from setting 
  * Create object of class in accordance with mode displaying page 
  */
 function &createListPage($table, $options)
 {
     global $bSubqueriesSupported, $strTableName, $conn, $locale_info, $isGroupSecurity;
     $gQuery = GetTableData($table, ".sqlquery", null);
     $params = array();
     $params = $options;
     $params['origTName'] = GetTableData($table, ".OriginalTable", '');
     $params['sessionPrefix'] = $strTableName;
     $params['tName'] = $table;
     $params['conn'] =& $conn;
     $params['gPageSize'] = GetTableData($table, ".pageSize", 0);
     $params['gOrderIndexes'] = GetTableData($table, ".orderindexes", array());
     $params['gstrOrderBy'] = GetTableData($table, ".strOrderBy", '');
     $params['gsqlHead'] = GetTableData($table, ".sqlHead", '');
     $params['gsqlFrom'] = GetTableData($table, ".sqlFrom", '');
     $params['gsqlWhereExpr'] = GetTableData($table, ".sqlWhereExpr", '');
     $params['gsqlGroupBy'] = $gQuery->GroupByToSql();
     $oHaving = $gQuery->Having();
     $params['gsqlHaving'] = $oHaving->toSql($gQuery);
     $params['locale_info'] =& $locale_info;
     $params["subQueriesSupp"] = $bSubqueriesSupported;
     $params['nSecOptions'] = GetTableData($table, ".nSecOptions", 0);
     $params['nLoginMethod'] = GetGlobalData("nLoginMethod", 0);
     $params['recsPerRowList'] = GetTableData($table, ".recsPerRowList", 0);
     $params['tableGroupBy'] = GetTableData($table, ".tableGroupBy", '');
     $params['dbType'] = GetGlobalData("dbType", 0);
     $params['mainTableOwnerID'] = GetTableData($table, ".mainTableOwnerID", '');
     $params['moveNext'] = GetTableData($table, ".moveNext", 0);
     $params['exportTo'] = GetTableData($table, ".exportTo", false);
     $params['printFriendly'] = GetTableData($table, ".printFriendly", false);
     $params['deleteRecs'] = GetTableData($table, ".delete", false);
     $params['rowHighlite'] = GetTableData($table, ".rowHighlite", false);
     $params["delFile"] = GetGlobalData("delFile", false);
     $params["isGroupSecurity"] = $isGroupSecurity;
     $params['arrKeyFields'] = GetTableData($table, ".arrKeyFields", array());
     $params["useIbox"] = GetTableData($table, ".useIbox", false);
     $params["isUseInlineAdd"] = GetTableData($table, ".isUseInlineAdd", false);
     $params["isUseInlineEdit"] = GetTableData($table, ".isUseInlineEdit", false);
     $params["isUseInlineJs"] = $params["isUseInlineAdd"] || $params["isUseInlineEdit"];
     $params["globSearchFields"] = GetTableData($table, ".globSearchFields", array());
     $params["panelSearchFields"] = GetTableData($table, ".panelSearchFields", array());
     $params['isVerLayout'] = GetTableData($table, ".isVerLayout", false);
     $params['isDisplayLoading'] = GetTableData($table, ".isDisplayLoading", false);
     $params['createLoginPage'] = GetGlobalData("createLoginPage", false);
     $params['subQueriesSupAccess'] = GetTableData($table, ".subQueriesSupAccess", false);
     $params['noRecordsFirstPage'] = GetTableData($table, ".noRecordsFirstPage", false);
     $params['totalsFields'] = GetTableData($table, ".totalsFields", array());
     $params['listIcons'] = GetTableData($table, ".listIcons", false);
     $params['edit'] = GetTableData($table, ".edit", false);
     $params['inlineEdit'] = GetTableData($table, ".inlineEdit", false);
     $params['iCopy'] = GetTableData($table, ".copy", false);
     $params['iView'] = GetTableData($table, ".view", false);
     $params['listAjax'] = GetTableData($table, ".listAjax", false);
     $params['arrRecsPerPage'] = GetTableData($table, ".arrRecsPerPage", array());
     $params['audit'] = GetAuditObject($table);
     $params['listFields'] = array();
     $allfields = GetFieldsList($table);
     foreach ($allfields as $f) {
         if (!AppearOnListPage($f, $table)) {
             continue;
         }
         $params['listFields'][] = array("fName" => $f, "goodFieldName" => GoodFieldName($f), "valueFieldName" => GoodFieldName($f) . "_value", "viewFormat" => GetFieldData($table, $f, "ViewFormat", ""), "editFormat" => GetFieldData($table, $f, "EditFormat", ""));
     }
     // choose class by mode
     if ($params["mode"] == LIST_SIMPLE) {
         $pageObject = new ListPage_Simple($params);
     } else {
         if ($params["mode"] == LIST_AJAX) {
             $pageObject = new ListPage_Ajax($params);
         } else {
             if ($params["mode"] == LIST_LOOKUP) {
                 $pageObject = new ListPage_Lookup($params);
             } else {
                 if ($params["mode"] == LIST_DETAILS) {
                     $pageObject = new ListPage_DPInline($params);
                 } else {
                     if ($params["mode"] == RIGHTS_PAGE) {
                         $pageObject = new RightsPage($params);
                     } else {
                         if ($params["mode"] == MEMBERS_PAGE) {
                             $pageObject = new MembersPage($params);
                         }
                     }
                 }
             }
         }
     }
     return $pageObject;
 }
/** Check is appear field on page by page type
 * param $fName - field name
 * param $pageType - type of current page
 *	return boolean/string - true or false/'break' - if need to break the cycle	
 */
function AppearOnCurrentPage($fName, $pageType, $pageLikeInline = false)
{
    if ($pageType == PAGE_LIST) {
        if (AppearOnListPage($fName)) {
            return true;
        } else {
            return AppearOnRegisterOrSearchPage($fName, PAGE_SEARCH);
        }
    } elseif ($pageType == PAGE_ADD) {
        if ($pageLikeInline) {
            if (AppearOnInlineAdd($fName) && AppearOnListPage($fName)) {
                return true;
            }
        } else {
            if (AppearOnAddPage($fName)) {
                return true;
            }
        }
    } elseif ($pageType == PAGE_EDIT) {
        if ($pageLikeInline) {
            if (AppearOnInlineEdit($fName) && AppearOnListPage($fName)) {
                return true;
            }
        } else {
            if (AppearOnEditPage($fName)) {
                return true;
            }
        }
    } elseif ($pageType == PAGE_SEARCH || $pageType == PAGE_REPORT || $pageType == PAGE_CHART) {
        return AppearOnRegisterOrSearchPage($fName, PAGE_SEARCH);
    } elseif ($pageType == PAGE_REGISTER) {
        return AppearOnRegisterOrSearchPage($fName, PAGE_REGISTER);
    } else {
        return 'break';
    }
    return false;
}
 function initLookupParams()
 {
     $this->parId = postvalue("parId");
     $this->firstTime = postvalue("firsttime");
     $this->mainField = postvalue("field");
     $this->lookupControl = postvalue("control");
     $this->lookupCategory = postvalue("category");
     $this->mainTable = postvalue("table");
     global $tables_data;
     include_once getabspath('include/' . GetTableURL($this->mainTable) . '_settings.php');
     $this->lookupParams = "mode=lookup&id=" . $this->id . "&parId=" . $this->parId . "&field=" . rawurlencode($this->mainField) . "&control=" . rawurlencode($this->lookupControl) . "&category=" . rawurlencode($this->lookupCategory) . "&table=" . rawurlencode($this->mainTable) . "&editMode=" . postvalue('editMode');
     $this->sessionPrefix = $this->tName . "_lookup_" . $this->mainTable . '_' . $this->mainField;
     $this->linkField = GetLWLinkField($this->mainField, $this->mainTable, false);
     $this->dispField = GetLWDisplayField($this->mainField, $this->mainTable, false);
     if (GetFieldData($this->mainTable, $this->mainField, 'CustomDisplay', false)) {
         $this->customField = $this->linkField;
         $this->dispFieldAlias = 'dispField1';
     }
     $this->outputFieldValue($this->linkField, 2);
     $this->outputFieldValue($this->dispField, 2);
     if (UseCategory($this->mainField, $this->mainTable)) {
         $this->categoryField = GetFieldData($this->mainTable, $this->mainField, 'CategoryFilter', '');
     }
     $this->strLookupWhere = LookupWhere($this->mainField, $this->mainTable);
     if ($this->dispFieldAlias && AppearOnListPage($this->dispField)) {
         $this->lookupSelectField = $this->linkField;
     } elseif (AppearOnListPage($this->dispField)) {
         $this->lookupSelectField = $this->dispField;
     } else {
         $this->lookupSelectField = $this->listFields[0]['fName'];
     }
     if ($this->categoryField) {
         if (!strlen(GetFullFieldName($this->categoryField))) {
             $this->categoryField = "";
         }
     }
     if (!$this->categoryField) {
         $this->lookupCategory = "";
     }
 }