kenken999/php
0
1<?php2 3class WhereTabs4{5 protected static function &getGridTabs($table)6 {7 global $strTableName;8 9 if(!$table)10 $tableName = $strTableName;11 else12 $tableName = $table;13 14 if (GetEntityType($tableName) === "")15 return false;16 17 $pSet = new ProjectSettings($tableName);18 19 if(!$pSet->isExistsTableKey(".arrGridTabs"))20 $pSet->_tableData[".arrGridTabs"] = $pSet->getDefaultValueByKey("arrGridTabs");21 return $pSet->_tableData[".arrGridTabs"];22 }23 24 protected static function &getGridTab($table, $id)25 {26 $gridTabs = &WhereTabs::getGridTabs($table);27 if ($gridTabs === false)28 return false;29 30 foreach ($gridTabs as &$tab) {31 if ($tab["tabId"] == $id)32 return $tab;33 }34 return false;35 }36 37 public static function addTab($table, $where, $title, $id)38 {39 $gridTabs = &WhereTabs::getGridTabs($table);40 if ($gridTabs === false)41 return false;42 43 foreach ($gridTabs as $tab) {44 if ($tab["tabId"] == $id)45 return false;46 }47 48 $gridTabs[] = array(49 'tabId' => $id,50 'name' => $title,51 'nameType' => "Text",52 'where' => $where,53 'showRowCount' => false,54 'hideEmpty' => false,55 );56 57 return true;58 }59 60 public static function deleteTab($table, $id)61 {62 $gridTabs = &WhereTabs::getGridTabs($table);63 if ($gridTabs === false)64 return false;65 66 foreach ($gridTabs as $key => $tab) {67 if ($tab["tabId"] == $id) {68 unset($gridTabs[$key]);69 break;70 }71 }72 return true;73 }74 75 public static function setTabTitle($table, $id, $title)76 {77 $tab = &WhereTabs::getGridTab($table, $id);78 79 if ($tab) {80 $tab['name'] = $title;81 $tab['nameType'] = "Text";82 return true;83 }84 return false;85 }86 87 public static function setTabWhere($table, $id, $where)88 {89 $tab = &WhereTabs::getGridTab($table, $id);90 91 if ($tab) {92 $tab['where'] = $where;93 return true;94 }95 return false;96 }97 98 /**99 * @param String table100 * @param String id101 * @param Boolean showIdCount102 */103 public static function setTabShowCount($table, $id, $showCount)104 {105 $tab = &WhereTabs::getGridTab($table, $id);106 107 if ($tab) {108 $tab['showRowCount'] = $showCount ? 1 : 0;109 return true;110 }111 return false;112 }113 114 /**115 * @param String table116 * @param String id117 * @param Boolean hideEmpty118 */119 public static function setTabHideEmpty($table, $id, $hideEmpty)120 {121 $tab = &WhereTabs::getGridTab($table, $id);122 123 if ($tab) {124 $tab['hideEmpty'] = $hideEmpty ? 1 : 0;125 return true;126 }127 return false;128 }129 130}131 