/includes/qcodo/_core/qform/QDataGridColumn.class.php

https://github.com/quinta/qcodo · PHP · 414 lines · 357 code · 32 blank · 25 comment · 29 complexity · 1007e545898233feb704f78423e6078b MD5 · raw file

  1. <?php
  2. // This defines a specific column <td> for a DataGrid
  3. // All the appearance properties should be self-explanatory.
  4. // The SortByCommand and ReverseSortByCommand are both optional -- and are explained in more
  5. // depth in DataGrid.inc
  6. // "Name" is the name of the column, as displayed in the DataGrid's header row for that column
  7. // "Html" is the contents of the column itself -- the $this->strHtml contents can contain backticks ` to
  8. // deliniate commands that are to be PHP evaled (again, see DataGrid.inc for more info)
  9. class QDataGridColumn extends QBaseClass {
  10. // APPEARANCE
  11. protected $strBackColor = null;
  12. protected $strBorderColor = null;
  13. protected $strBorderStyle = QBorderStyle::NotSet;
  14. protected $strBorderWidth = null;
  15. protected $strCssClass = null;
  16. protected $blnFontBold = false;
  17. protected $blnFontItalic = false;
  18. protected $strFontNames = null;
  19. protected $blnFontOverline = false;
  20. protected $strFontSize = null;
  21. protected $blnFontStrikeout = false;
  22. protected $blnFontUnderline = false;
  23. protected $strForeColor = null;
  24. protected $strHorizontalAlign = QHorizontalAlign::NotSet;
  25. protected $strVerticalAlign = QVerticalAlign::NotSet;
  26. protected $strWidth = null;
  27. protected $blnWrap = true;
  28. // BEHAVIOR
  29. protected $objOrderByClause = null;
  30. protected $objReverseOrderByClause = null;
  31. // MISC
  32. protected $strName;
  33. protected $strHtml;
  34. protected $blnHtmlEntities = true;
  35. public function __construct($strName, $strHtml = null, $objOverrideParameters = null) {
  36. $this->strName = $strName;
  37. $this->strHtml = $strHtml;
  38. $objOverrideArray = func_get_args();
  39. if (count($objOverrideArray) > 2)
  40. try {
  41. unset($objOverrideArray[0]);
  42. unset($objOverrideArray[1]);
  43. $this->OverrideAttributes($objOverrideArray);
  44. } catch (QCallerException $objExc) {
  45. $objExc->IncrementOffset();
  46. throw $objExc;
  47. }
  48. }
  49. public function GetAttributes($blnIncludeCustom = true, $blnIncludeAction = true) {
  50. $strToReturn = "";
  51. $strStyle = "";
  52. if (!$this->blnWrap)
  53. $strToReturn .= 'nowrap="nowrap" ';
  54. switch ($this->strHorizontalAlign) {
  55. case QHorizontalAlign::Left:
  56. $strStyle .= 'text-align:left;';
  57. break;
  58. case QHorizontalAlign::Right:
  59. $strStyle .= 'text-align:right;';
  60. break;
  61. case QHorizontalAlign::Center:
  62. $strStyle .= 'text-align:center;';
  63. break;
  64. case QHorizontalAlign::Justify:
  65. $strStyle .= 'text-align:justify;';
  66. break;
  67. }
  68. switch ($this->strVerticalAlign) {
  69. case QVerticalAlign::Top:
  70. $strStyle .= 'vertical-align:top;';
  71. break;
  72. case QVerticalAlign::Middle:
  73. $strStyle .= 'vertical-align:middle;';
  74. break;
  75. case QVerticalAlign::Bottom:
  76. $strStyle .= 'vertical-align:bottom;';
  77. break;
  78. }
  79. if ($this->strCssClass)
  80. $strToReturn .= sprintf('class="%s" ', $this->strCssClass);
  81. if ($this->strWidth) {
  82. if (is_numeric($this->strWidth))
  83. $strStyle .= sprintf("width:%spx;", $this->strWidth);
  84. else
  85. $strStyle .= sprintf("width:%s;", $this->strWidth);
  86. }
  87. if ($this->strForeColor)
  88. $strStyle .= sprintf("color:%s;", $this->strForeColor);
  89. if ($this->strBackColor)
  90. $strStyle .= sprintf("background-color:%s;", $this->strBackColor);
  91. if ($this->strBorderColor)
  92. $strStyle .= sprintf("border-color:%s;", $this->strBorderColor);
  93. if ($this->strBorderWidth) {
  94. $strStyle .= sprintf("border-width:%s;", $this->strBorderWidth);
  95. if ((!$this->strBorderStyle) || ($this->strBorderStyle == QBorderStyle::NotSet))
  96. // For "No Border Style" -- apply a "solid" style because width is set
  97. $strStyle .= "border-style:solid;";
  98. }
  99. if (($this->strBorderStyle) && ($this->strBorderStyle != QBorderStyle::NotSet))
  100. $strStyle .= sprintf("border-style:%s;", $this->strBorderStyle);
  101. if ($this->strFontNames)
  102. $strStyle .= sprintf("font-family:%s;", $this->strFontNames);
  103. if ($this->strFontSize) {
  104. if (is_numeric($this->strFontSize))
  105. $strStyle .= sprintf("font-size:%spx;", $this->strFontSize);
  106. else
  107. $strStyle .= sprintf("font-size:%s;", $this->strFontSize);
  108. }
  109. if ($this->blnFontBold)
  110. $strStyle .= "font-weight:bold;";
  111. if ($this->blnFontItalic)
  112. $strStyle .= "font-style:italic;";
  113. $strTextDecoration = "";
  114. if ($this->blnFontUnderline)
  115. $strTextDecoration .= "underline ";
  116. if ($this->blnFontOverline)
  117. $strTextDecoration .= "overline ";
  118. if ($this->blnFontStrikeout)
  119. $strTextDecoration .= "line-through ";
  120. if ($strTextDecoration) {
  121. $strTextDecoration = trim($strTextDecoration);
  122. $strStyle .= sprintf("text-decoration:%s;", $strTextDecoration);
  123. }
  124. if ($strStyle)
  125. $strToReturn .= sprintf('style="%s" ', $strStyle);
  126. return $strToReturn;
  127. }
  128. /////////////////////////
  129. // Public Properties: GET
  130. /////////////////////////
  131. public function __get($strName) {
  132. switch ($strName) {
  133. // APPEARANCE
  134. case "BackColor": return $this->strBackColor;
  135. case "BorderColor": return $this->strBorderColor;
  136. case "BorderStyle": return $this->strBorderStyle;
  137. case "BorderWidth": return $this->strBorderWidth;
  138. case "CssClass": return $this->strCssClass;
  139. case "FontBold": return $this->blnFontBold;
  140. case "FontItalic": return $this->blnFontItalic;
  141. case "FontNames": return $this->strFontNames;
  142. case "FontOverline": return $this->blnFontOverline;
  143. case "FontSize": return $this->strFontSize;
  144. case "FontStrikeout": return $this->blnFontStrikeout;
  145. case "FontUnderline": return $this->blnFontUnderline;
  146. case "ForeColor": return $this->strForeColor;
  147. case "HorizontalAlign": return $this->strHorizontalAlign;
  148. case "VerticalAlign": return $this->strVerticalAlign;
  149. case "Width": return $this->strWidth;
  150. case "Wrap": return $this->blnWrap;
  151. // BEHAVIOR
  152. case "OrderByClause": return $this->objOrderByClause;
  153. case "ReverseOrderByClause": return $this->objReverseOrderByClause;
  154. // MANUAL QUERY BEHAVIORS
  155. case "SortByCommand": return $this->objOrderByClause;
  156. case "ReverseSortByCommand": return $this->objReverseOrderByClause;
  157. // MISC
  158. case "Html": return $this->strHtml;
  159. case "Name": return $this->strName;
  160. case "HtmlEntities": return $this->blnHtmlEntities;
  161. default:
  162. try {
  163. return parent::__get($strName);
  164. } catch (QCallerException $objExc) {
  165. $objExc->IncrementOffset();
  166. throw $objExc;
  167. }
  168. }
  169. }
  170. /////////////////////////
  171. // Public Properties: SET
  172. /////////////////////////
  173. public function __set($strName, $mixValue) {
  174. switch ($strName) {
  175. // APPEARANCE
  176. case "BackColor":
  177. try {
  178. $this->strBackColor = QType::Cast($mixValue, QType::String);
  179. break;
  180. } catch (QInvalidCastException $objExc) {
  181. $objExc->IncrementOffset();
  182. throw $objExc;
  183. }
  184. case "BorderColor":
  185. try {
  186. $this->strBorderColor = QType::Cast($mixValue, QType::String);
  187. break;
  188. } catch (QInvalidCastException $objExc) {
  189. $objExc->IncrementOffset();
  190. throw $objExc;
  191. }
  192. case "BorderStyle":
  193. try {
  194. $this->strBorderStyle = QType::Cast($mixValue, QType::String);
  195. break;
  196. } catch (QInvalidCastException $objExc) {
  197. $objExc->IncrementOffset();
  198. throw $objExc;
  199. }
  200. case "BorderWidth":
  201. try {
  202. $this->strBorderWidth = QType::Cast($mixValue, QType::String);
  203. break;
  204. } catch (QInvalidCastException $objExc) {
  205. $objExc->IncrementOffset();
  206. throw $objExc;
  207. }
  208. case "CssClass":
  209. try {
  210. $this->strCssClass = QType::Cast($mixValue, QType::String);
  211. break;
  212. } catch (QInvalidCastException $objExc) {
  213. $objExc->IncrementOffset();
  214. throw $objExc;
  215. }
  216. case "FontBold":
  217. try {
  218. $this->blnFontBold = QType::Cast($mixValue, QType::Boolean);
  219. break;
  220. } catch (QInvalidCastException $objExc) {
  221. $objExc->IncrementOffset();
  222. throw $objExc;
  223. }
  224. case "FontItalic":
  225. try {
  226. $this->blnFontItalic = QType::Cast($mixValue, QType::Boolean);
  227. break;
  228. } catch (QInvalidCastException $objExc) {
  229. $objExc->IncrementOffset();
  230. throw $objExc;
  231. }
  232. case "FontNames":
  233. try {
  234. $this->strFontNames = QType::Cast($mixValue, QType::String);
  235. break;
  236. } catch (QInvalidCastException $objExc) {
  237. $objExc->IncrementOffset();
  238. throw $objExc;
  239. }
  240. case "FontOverline":
  241. try {
  242. $this->blnFontOverline = QType::Cast($mixValue, QType::Boolean);
  243. break;
  244. } catch (QInvalidCastException $objExc) {
  245. $objExc->IncrementOffset();
  246. throw $objExc;
  247. }
  248. case "FontSize":
  249. try {
  250. $this->strFontSize = QType::Cast($mixValue, QType::String);
  251. break;
  252. } catch (QInvalidCastException $objExc) {
  253. $objExc->IncrementOffset();
  254. throw $objExc;
  255. }
  256. case "FontStrikeout":
  257. try {
  258. $this->blnFontStrikeout = QType::Cast($mixValue, QType::Boolean);
  259. break;
  260. } catch (QInvalidCastException $objExc) {
  261. $objExc->IncrementOffset();
  262. throw $objExc;
  263. }
  264. case "FontUnderline":
  265. try {
  266. $this->blnFontUnderline = QType::Cast($mixValue, QType::Boolean);
  267. break;
  268. } catch (QInvalidCastException $objExc) {
  269. $objExc->IncrementOffset();
  270. throw $objExc;
  271. }
  272. case "ForeColor":
  273. try {
  274. $this->strForeColor = QType::Cast($mixValue, QType::String);
  275. break;
  276. } catch (QInvalidCastException $objExc) {
  277. $objExc->IncrementOffset();
  278. throw $objExc;
  279. }
  280. case "HorizontalAlign":
  281. try {
  282. $this->strHorizontalAlign = QType::Cast($mixValue, QType::String);
  283. break;
  284. } catch (QInvalidCastException $objExc) {
  285. $objExc->IncrementOffset();
  286. throw $objExc;
  287. }
  288. case "VerticalAlign":
  289. try {
  290. $this->strVerticalAlign = QType::Cast($mixValue, QType::String);
  291. break;
  292. } catch (QInvalidCastException $objExc) {
  293. $objExc->IncrementOffset();
  294. throw $objExc;
  295. }
  296. case "Width":
  297. try {
  298. $this->strWidth = QType::Cast($mixValue, QType::String);
  299. break;
  300. } catch (QInvalidCastException $objExc) {
  301. $objExc->IncrementOffset();
  302. throw $objExc;
  303. }
  304. case "Wrap":
  305. try {
  306. $this->blnWrap = QType::Cast($mixValue, QType::Boolean);
  307. break;
  308. } catch (QInvalidCastException $objExc) {
  309. $objExc->IncrementOffset();
  310. throw $objExc;
  311. }
  312. // BEHAVIOR
  313. case "OrderByClause":
  314. try {
  315. $this->objOrderByClause = QType::Cast($mixValue, 'QQOrderBy');
  316. break;
  317. } catch (QInvalidCastException $objExc) {
  318. $objExc->IncrementOffset();
  319. throw $objExc;
  320. }
  321. case "ReverseOrderByClause":
  322. try {
  323. $this->objReverseOrderByClause = QType::Cast($mixValue, 'QQOrderBy');
  324. break;
  325. } catch (QInvalidCastException $objExc) {
  326. $objExc->IncrementOffset();
  327. throw $objExc;
  328. }
  329. // MANUAL QUERY BEHAVIOR
  330. case "SortByCommand":
  331. try {
  332. $this->objOrderByClause = QType::Cast($mixValue, QType::String);
  333. break;
  334. } catch (QInvalidCastException $objExc) {
  335. $objExc->IncrementOffset();
  336. throw $objExc;
  337. }
  338. case "ReverseSortByCommand":
  339. try {
  340. $this->objReverseOrderByClause = QType::Cast($mixValue, QType::String);
  341. break;
  342. } catch (QInvalidCastException $objExc) {
  343. $objExc->IncrementOffset();
  344. throw $objExc;
  345. }
  346. // MISC
  347. case "Html":
  348. try {
  349. $this->strHtml = QType::Cast($mixValue, QType::String);
  350. break;
  351. } catch (QInvalidCastException $objExc) {
  352. $objExc->IncrementOffset();
  353. throw $objExc;
  354. }
  355. case "Name":
  356. try {
  357. $this->strName = QType::Cast($mixValue, QType::String);
  358. break;
  359. } catch (QInvalidCastException $objExc) {
  360. $objExc->IncrementOffset();
  361. throw $objExc;
  362. }
  363. case "HtmlEntities":
  364. try {
  365. $this->blnHtmlEntities = QType::Cast($mixValue, QType::Boolean);
  366. break;
  367. } catch (QInvalidCastException $objExc) {
  368. $objExc->IncrementOffset();
  369. throw $objExc;
  370. }
  371. default:
  372. try {
  373. parent::__set($strName, $mixValue);
  374. break;
  375. } catch (QCallerException $objExc) {
  376. $objExc->IncrementOffset();
  377. throw $objExc;
  378. }
  379. }
  380. }
  381. }
  382. ?>