PageRenderTime 50ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/osj-osj2dpostsview.php

http://osjobber.googlecode.com/
PHP | 705 lines | 675 code | 14 blank | 16 comment | 57 complexity | 914c0e2e13c02f754ffeaa0d3f27b075 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "view", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-posts', TRUE);
  4. ?>
  5. <?php
  6. session_start(); // Initialize session data
  7. ob_start(); // Turn on output buffering
  8. ?>
  9. <?php include "osj-ewcfg50.php" ?>
  10. <?php include "osj-ewmysql50.php" ?>
  11. <?php include "osj-phpfn50.php" ?>
  12. <?php include "osj-osj2dpostsinfo.php" ?>
  13. <?php include "osj-userfn50.php" ?>
  14. <?php include "osj-osj2dusersinfo.php" ?>
  15. <?php
  16. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  17. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
  18. header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
  19. header("Cache-Control: post-check=0, pre-check=0", false);
  20. header("Pragma: no-cache"); // HTTP/1.0
  21. ?>
  22. <?php
  23. // Open connection to the database
  24. $conn = ew_Connect();
  25. ?>
  26. <?php
  27. $Security = new cAdvancedSecurity();
  28. ?>
  29. <?php
  30. if (!$Security->IsLoggedIn()) $Security->AutoLogin();
  31. $Security->LoadCurrentUserLevel('osj-posts');
  32. ?>
  33. <?php
  34. // Common page loading event (in userfn*.php)
  35. Page_Loading();
  36. ?>
  37. <?php
  38. // Page load event, used in current page
  39. Page_Load();
  40. ?>
  41. <?php
  42. $osj2Dposts->Export = @$_GET["export"]; // Get export parameter
  43. $sExport = $osj2Dposts->Export; // Get export parameter, used in header
  44. $sExportFile = $osj2Dposts->TableVar; // Get export file, used in header
  45. ?>
  46. <?php
  47. if (@$_GET["post_id"] <> "") {
  48. if ($sExportFile <> "") $sExportFile .= "_";
  49. $sExportFile .= ew_StripSlashes($_GET["post_id"]);
  50. }
  51. if ($osj2Dposts->Export == "html") {
  52. // Printer friendly, no action required
  53. }
  54. if ($osj2Dposts->Export == "xml") {
  55. header('Content-Type: text/xml');
  56. header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml');
  57. }
  58. if ($osj2Dposts->Export == "csv") {
  59. header('Content-Type: application/csv');
  60. header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
  61. }
  62. ?>
  63. <?php
  64. // Paging variables
  65. $nStartRec = 0; // Start record index
  66. $nStopRec = 0; // Stop record index
  67. $nTotalRecs = 0; // Total number of records
  68. $nDisplayRecs = 1;
  69. $nRecRange = 10;
  70. // Load current record
  71. $bLoadCurrentRecord = FALSE;
  72. if (@$_GET["post_id"] <> "") {
  73. $osj2Dposts->post_id->setQueryStringValue($_GET["post_id"]);
  74. } else {
  75. $bLoadCurrentRecord = TRUE;
  76. }
  77. // Get action
  78. if (@$_POST["a_view"] <> "") {
  79. $osj2Dposts->CurrentAction = $_POST["a_view"];
  80. } else {
  81. $osj2Dposts->CurrentAction = "I"; // Display form
  82. }
  83. switch ($osj2Dposts->CurrentAction) {
  84. case "I": // Get a record to display
  85. $nStartRec = 1; // Initialize start position
  86. $rs = LoadRecordset(); // Load records
  87. $nTotalRecs = $rs->RecordCount(); // Get record count
  88. if ($nTotalRecs <= 0) { // No record found
  89. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // Set no record message
  90. Page_Terminate("osj-osj2dpostslist.php"); // Return to list page
  91. } elseif ($bLoadCurrentRecord) { // Load current record position
  92. SetUpStartRec(); // Set up start record position
  93. // Point to current record
  94. if (intval($nStartRec) <= intval($nTotalRecs)) {
  95. $rs->Move($nStartRec-1);
  96. }
  97. } else { // Match key values
  98. $bMatchRecord = FALSE;
  99. while (!$rs->EOF) {
  100. if (strval($osj2Dposts->post_id->CurrentValue) == strval($rs->fields('post_id'))) {
  101. $bMatchRecord = TRUE;
  102. break;
  103. } else {
  104. $nStartRec++;
  105. $rs->MoveNext();
  106. }
  107. }
  108. if (!$bMatchRecord) {
  109. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // Set no record message
  110. Page_Terminate("osj-osj2dpostslist.php"); // Return to list
  111. } else {
  112. $osj2Dposts->setStartRecordNumber($nStartRec); // Save record position
  113. }
  114. }
  115. LoadRowValues($rs); // Load row values
  116. }
  117. // Export data only
  118. if ($osj2Dposts->Export == "xml" || $osj2Dposts->Export == "csv") {
  119. ExportData();
  120. Page_Terminate(); // Terminate response
  121. }
  122. // Set return url
  123. $osj2Dposts->setReturnUrl("osj-osj2dpostsview.php");
  124. // Render row
  125. $osj2Dposts->RowType = EW_ROWTYPE_VIEW;
  126. RenderRow();
  127. ?>
  128. <?php include "osj-header.php" ?>
  129. <script type="text/javascript">
  130. <!--
  131. var EW_PAGE_ID = "view"; // Page id
  132. var EW_SHOW_HIGHLIGHT = "Show highlight";
  133. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  134. //-->
  135. </script>
  136. <script language="JavaScript" type="text/javascript">
  137. <!--
  138. // Write your client script here, no need to add script tags.
  139. // To include another .js script, use:
  140. // ew_ClientScriptInclude("my_javascript.js");
  141. //-->
  142. </script>
  143. <p><span class="phpmaker">View TABLE: Posts
  144. <?php if ($osj2Dposts->Export == "") { ?>
  145. &nbsp;&nbsp;<a href="osj-osj2dpostsview.php?export=html&post_id=<?php echo urlencode($osj2Dposts->post_id->CurrentValue) ?>">Printer Friendly</a>
  146. &nbsp;&nbsp;<a href="osj-osj2dpostsview.php?export=xml&post_id=<?php echo urlencode($osj2Dposts->post_id->CurrentValue) ?>">Export to XML</a>
  147. &nbsp;&nbsp;<a href="osj-osj2dpostsview.php?export=csv&post_id=<?php echo urlencode($osj2Dposts->post_id->CurrentValue) ?>">Export to CSV</a>
  148. <?php } ?>
  149. <br><br>
  150. <?php if ($osj2Dposts->Export == "") { ?>
  151. <a href="osj-osj2dpostslist.php">Back to List</a>&nbsp;
  152. <?php if ($Security->CanAdd()) { ?>
  153. <?php if (ShowOptionLink()) { ?>
  154. <a href="osj-osj2dpostsadd.php">Add</a>&nbsp;
  155. <?php } ?>
  156. <?php } ?>
  157. <?php if ($Security->CanEdit()) { ?>
  158. <?php if (ShowOptionLink()) { ?>
  159. <a href="<?php echo $osj2Dposts->EditUrl() ?>">Edit</a>&nbsp;
  160. <?php } ?>
  161. <?php } ?>
  162. <?php if ($Security->CanDelete()) { ?>
  163. <?php if (ShowOptionLink()) { ?>
  164. <a href="<?php echo $osj2Dposts->DeleteUrl() ?>">Delete</a>&nbsp;
  165. <?php } ?>
  166. <?php } ?>
  167. <?php } ?>
  168. </span>
  169. </p>
  170. <?php
  171. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  172. ?>
  173. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  174. <?php
  175. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  176. }
  177. ?>
  178. <p>
  179. <?php if ($osj2Dposts->Export == "") { ?>
  180. <form action="osj-osj2dpostsview.php" name="ewpagerform" id="ewpagerform">
  181. <table border="0" cellspacing="0" cellpadding="0">
  182. <tr>
  183. <td nowrap>
  184. <span class="phpmaker">
  185. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  186. <?php if ($Pager->RecordCount > 0) { ?>
  187. <?php if ($Pager->FirstButton->Enabled) { ?>
  188. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  189. <?php } ?>
  190. <?php if ($Pager->PrevButton->Enabled) { ?>
  191. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  192. <?php } ?>
  193. <?php foreach ($Pager->Items as $PagerItem) { ?>
  194. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2dpostsview.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  195. <?php } ?>
  196. <?php if ($Pager->NextButton->Enabled) { ?>
  197. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  198. <?php } ?>
  199. <?php if ($Pager->LastButton->Enabled) { ?>
  200. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  201. <?php } ?>
  202. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  203. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  204. <?php } else { ?>
  205. <?php if ($sSrchWhere == "0=101") { ?>
  206. Please enter search criteria
  207. <?php } else { ?>
  208. No records found
  209. <?php } ?>
  210. <?php } ?>
  211. </span>
  212. </td>
  213. </tr>
  214. </table>
  215. </form>
  216. <?php } ?>
  217. <form>
  218. <table class="ewTable">
  219. <tr class="ewTableRow">
  220. <td class="ewTableHeader">Post ID</td>
  221. <td<?php echo $osj2Dposts->post_id->CellAttributes() ?>>
  222. <?php if ($osj2Dposts->post_id->HrefValue <> "") { ?>
  223. <a href="osj-osj2dapplicationsadd.php?post_id=<?php echo $osj2Dposts->post_id->HrefValue ?>"><div<?php echo $osj2Dposts->post_id->ViewAttributes() ?>><?php echo $osj2Dposts->post_id->ViewValue ?></div></a>
  224. <?php } else { ?>
  225. <div<?php echo $osj2Dposts->post_id->ViewAttributes() ?>><?php echo $osj2Dposts->post_id->ViewValue ?></div>
  226. <?php } ?>
  227. </td>
  228. </tr>
  229. <tr class="ewTableAltRow">
  230. <td class="ewTableHeader">Employer ID</td>
  231. <td<?php echo $osj2Dposts->user_id->CellAttributes() ?>>
  232. <div<?php echo $osj2Dposts->user_id->ViewAttributes() ?>><?php echo $osj2Dposts->user_id->ViewValue ?></div>
  233. </td>
  234. </tr>
  235. <tr class="ewTableRow">
  236. <td class="ewTableHeader">Creation Date</td>
  237. <td<?php echo $osj2Dposts->post_creation_date->CellAttributes() ?>>
  238. <div<?php echo $osj2Dposts->post_creation_date->ViewAttributes() ?>><?php echo $osj2Dposts->post_creation_date->ViewValue ?></div>
  239. </td>
  240. </tr>
  241. <tr class="ewTableAltRow">
  242. <td class="ewTableHeader">Title</td>
  243. <td<?php echo $osj2Dposts->post_title->CellAttributes() ?>>
  244. <?php if ($osj2Dposts->post_title->HrefValue <> "") { ?>
  245. <a href="osj-osj2dpostsview.php?post_id=<?php echo $osj2Dposts->post_title->HrefValue ?>"><div<?php echo $osj2Dposts->post_title->ViewAttributes() ?>><?php echo $osj2Dposts->post_title->ViewValue ?></div></a>
  246. <?php } else { ?>
  247. <div<?php echo $osj2Dposts->post_title->ViewAttributes() ?>><?php echo $osj2Dposts->post_title->ViewValue ?></div>
  248. <?php } ?>
  249. </td>
  250. </tr>
  251. <tr class="ewTableRow">
  252. <td class="ewTableHeader">Description</td>
  253. <td<?php echo $osj2Dposts->post_description->CellAttributes() ?>>
  254. <div<?php echo $osj2Dposts->post_description->ViewAttributes() ?>><?php echo $osj2Dposts->post_description->ViewValue ?></div>
  255. </td>
  256. </tr>
  257. <tr class="ewTableAltRow">
  258. <td class="ewTableHeader">Category ID's</td>
  259. <td<?php echo $osj2Dposts->post_categories->CellAttributes() ?>>
  260. <div<?php echo $osj2Dposts->post_categories->ViewAttributes() ?>><?php echo $osj2Dposts->post_categories->ViewValue ?></div>
  261. </td>
  262. </tr>
  263. <tr class="ewTableRow">
  264. <td class="ewTableHeader">Post Edit Date</td>
  265. <td<?php echo $osj2Dposts->post_edit_date->CellAttributes() ?>>
  266. <div<?php echo $osj2Dposts->post_edit_date->ViewAttributes() ?>><?php echo $osj2Dposts->post_edit_date->ViewValue ?></div>
  267. </td>
  268. </tr>
  269. </table>
  270. </form>
  271. <?php if ($osj2Dposts->Export == "") { ?>
  272. <form action="osj-osj2dpostsview.php" name="ewpagerform" id="ewpagerform">
  273. <table border="0" cellspacing="0" cellpadding="0">
  274. <tr>
  275. <td nowrap>
  276. <span class="phpmaker">
  277. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  278. <?php if ($Pager->RecordCount > 0) { ?>
  279. <?php if ($Pager->FirstButton->Enabled) { ?>
  280. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  281. <?php } ?>
  282. <?php if ($Pager->PrevButton->Enabled) { ?>
  283. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  284. <?php } ?>
  285. <?php foreach ($Pager->Items as $PagerItem) { ?>
  286. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2dpostsview.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  287. <?php } ?>
  288. <?php if ($Pager->NextButton->Enabled) { ?>
  289. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  290. <?php } ?>
  291. <?php if ($Pager->LastButton->Enabled) { ?>
  292. <a href="osj-osj2dpostsview.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  293. <?php } ?>
  294. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  295. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  296. <?php } else { ?>
  297. <?php if ($sSrchWhere == "0=101") { ?>
  298. Please enter search criteria
  299. <?php } else { ?>
  300. No records found
  301. <?php } ?>
  302. <?php } ?>
  303. </span>
  304. </td>
  305. </tr>
  306. </table>
  307. </form>
  308. <?php } ?>
  309. <p>
  310. <script language="JavaScript" type="text/javascript">
  311. <!--
  312. // Write your table-specific startup script here
  313. // document.write("page loaded");
  314. //-->
  315. </script>
  316. <?php include "osj-footer.php" ?>
  317. <?php
  318. // If control is passed here, simply terminate the page without redirect
  319. Page_Terminate();
  320. // -----------------------------------------------------------------
  321. // Subroutine Page_Terminate
  322. // - called when exit page
  323. // - clean up connection and objects
  324. // - if url specified, redirect to url, otherwise end response
  325. function Page_Terminate($url = "") {
  326. global $conn;
  327. // Page unload event, used in current page
  328. Page_Unload();
  329. // Global page unloaded event (in userfn*.php)
  330. Page_Unloaded();
  331. // Close Connection
  332. $conn->Close();
  333. // Go to url if specified
  334. if ($url <> "") {
  335. ob_end_clean();
  336. header("Location: $url");
  337. }
  338. exit();
  339. }
  340. ?>
  341. <?php
  342. // Load recordset
  343. function LoadRecordset($offset = -1, $rowcnt = -1) {
  344. global $conn, $osj2Dposts;
  345. // Call Recordset Selecting event
  346. $osj2Dposts->Recordset_Selecting($osj2Dposts->CurrentFilter);
  347. // Load list page sql
  348. $sSql = $osj2Dposts->SelectSQL();
  349. if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";
  350. // Load recordset
  351. $conn->raiseErrorFn = 'ew_ErrorFn';
  352. $rs = $conn->Execute($sSql);
  353. $conn->raiseErrorFn = '';
  354. // Call Recordset Selected event
  355. $osj2Dposts->Recordset_Selected($rs);
  356. return $rs;
  357. }
  358. ?>
  359. <?php
  360. // Load row based on key values
  361. function LoadRow() {
  362. global $conn, $Security, $osj2Dposts;
  363. $sFilter = $osj2Dposts->SqlKeyFilter();
  364. if (!is_numeric($osj2Dposts->post_id->CurrentValue)) {
  365. return FALSE; // Invalid key, exit
  366. }
  367. $sFilter = str_replace("@post_id@", ew_AdjustSql($osj2Dposts->post_id->CurrentValue), $sFilter); // Replace key value
  368. // Call Row Selecting event
  369. $osj2Dposts->Row_Selecting($sFilter);
  370. // Load sql based on filter
  371. $osj2Dposts->CurrentFilter = $sFilter;
  372. $sSql = $osj2Dposts->SQL();
  373. if ($rs = $conn->Execute($sSql)) {
  374. if ($rs->EOF) {
  375. $LoadRow = FALSE;
  376. } else {
  377. $LoadRow = TRUE;
  378. $rs->MoveFirst();
  379. LoadRowValues($rs); // Load row values
  380. // Call Row Selected event
  381. $osj2Dposts->Row_Selected($rs);
  382. }
  383. $rs->Close();
  384. } else {
  385. $LoadRow = FALSE;
  386. }
  387. return $LoadRow;
  388. }
  389. // Load row values from recordset
  390. function LoadRowValues(&$rs) {
  391. global $osj2Dposts;
  392. $osj2Dposts->post_id->setDbValue($rs->fields('post_id'));
  393. $osj2Dposts->user_id->setDbValue($rs->fields('user_id'));
  394. $osj2Dposts->post_creation_date->setDbValue($rs->fields('post_creation_date'));
  395. $osj2Dposts->post_title->setDbValue($rs->fields('post_title'));
  396. $osj2Dposts->post_description->setDbValue($rs->fields('post_description'));
  397. $osj2Dposts->post_email->setDbValue($rs->fields('post_email'));
  398. $osj2Dposts->post_categories->setDbValue($rs->fields('post_categories'));
  399. $osj2Dposts->post_url->setDbValue($rs->fields('post_url'));
  400. $osj2Dposts->post_edit_date->setDbValue($rs->fields('post_edit_date'));
  401. }
  402. ?>
  403. <?php
  404. // Render row values based on field settings
  405. function RenderRow() {
  406. global $conn, $Security, $osj2Dposts;
  407. // Call Row Rendering event
  408. $osj2Dposts->Row_Rendering();
  409. // Common render codes for all row types
  410. // post_id
  411. $osj2Dposts->post_id->CellCssStyle = "";
  412. $osj2Dposts->post_id->CellCssClass = "";
  413. // user_id
  414. $osj2Dposts->user_id->CellCssStyle = "";
  415. $osj2Dposts->user_id->CellCssClass = "";
  416. // post_creation_date
  417. $osj2Dposts->post_creation_date->CellCssStyle = "";
  418. $osj2Dposts->post_creation_date->CellCssClass = "";
  419. // post_title
  420. $osj2Dposts->post_title->CellCssStyle = "";
  421. $osj2Dposts->post_title->CellCssClass = "";
  422. // post_description
  423. $osj2Dposts->post_description->CellCssStyle = "";
  424. $osj2Dposts->post_description->CellCssClass = "";
  425. // post_categories
  426. $osj2Dposts->post_categories->CellCssStyle = "";
  427. $osj2Dposts->post_categories->CellCssClass = "";
  428. // post_edit_date
  429. $osj2Dposts->post_edit_date->CellCssStyle = "";
  430. $osj2Dposts->post_edit_date->CellCssClass = "";
  431. if ($osj2Dposts->RowType == EW_ROWTYPE_VIEW) { // View row
  432. // post_id
  433. $osj2Dposts->post_id->ViewValue = $osj2Dposts->post_id->CurrentValue;
  434. $osj2Dposts->post_id->CssStyle = "";
  435. $osj2Dposts->post_id->CssClass = "";
  436. $osj2Dposts->post_id->ViewCustomAttributes = "";
  437. // user_id
  438. $osj2Dposts->user_id->ViewValue = $osj2Dposts->user_id->CurrentValue;
  439. $osj2Dposts->user_id->CssStyle = "";
  440. $osj2Dposts->user_id->CssClass = "";
  441. $osj2Dposts->user_id->ViewCustomAttributes = "";
  442. // post_creation_date
  443. $osj2Dposts->post_creation_date->ViewValue = $osj2Dposts->post_creation_date->CurrentValue;
  444. $osj2Dposts->post_creation_date->ViewValue = ew_FormatDateTime($osj2Dposts->post_creation_date->ViewValue, 6);
  445. $osj2Dposts->post_creation_date->CssStyle = "";
  446. $osj2Dposts->post_creation_date->CssClass = "";
  447. $osj2Dposts->post_creation_date->ViewCustomAttributes = "";
  448. // post_title
  449. $osj2Dposts->post_title->ViewValue = $osj2Dposts->post_title->CurrentValue;
  450. $osj2Dposts->post_title->CssStyle = "";
  451. $osj2Dposts->post_title->CssClass = "";
  452. $osj2Dposts->post_title->ViewCustomAttributes = "";
  453. // post_description
  454. $osj2Dposts->post_description->ViewValue = $osj2Dposts->post_description->CurrentValue;
  455. if (!is_null($osj2Dposts->post_description->ViewValue)) $osj2Dposts->post_description->ViewValue = str_replace("\n", "<br>", $osj2Dposts->post_description->ViewValue);
  456. $osj2Dposts->post_description->CssStyle = "";
  457. $osj2Dposts->post_description->CssClass = "";
  458. $osj2Dposts->post_description->ViewCustomAttributes = "";
  459. // post_categories
  460. $osj2Dposts->post_categories->ViewValue = $osj2Dposts->post_categories->CurrentValue;
  461. $osj2Dposts->post_categories->CssStyle = "";
  462. $osj2Dposts->post_categories->CssClass = "";
  463. $osj2Dposts->post_categories->ViewCustomAttributes = "";
  464. // post_edit_date
  465. $osj2Dposts->post_edit_date->ViewValue = $osj2Dposts->post_edit_date->CurrentValue;
  466. $osj2Dposts->post_edit_date->ViewValue = ew_FormatDateTime($osj2Dposts->post_edit_date->ViewValue, 6);
  467. $osj2Dposts->post_edit_date->CssStyle = "";
  468. $osj2Dposts->post_edit_date->CssClass = "";
  469. $osj2Dposts->post_edit_date->ViewCustomAttributes = "";
  470. // post_id
  471. if (!is_null($osj2Dposts->post_id->CurrentValue)) {
  472. $osj2Dposts->post_id->HrefValue = ((!empty($osj2Dposts->post_id->ViewValue)) ? $osj2Dposts->post_id->ViewValue : $osj2Dposts->post_id->CurrentValue);
  473. if ($osj2Dposts->Export <> "") $osj2Dposts->post_id->HrefValue = ew_ConvertFullUrl($osj2Dposts->post_id->HrefValue);
  474. } else {
  475. $osj2Dposts->post_id->HrefValue = "";
  476. }
  477. // user_id
  478. $osj2Dposts->user_id->HrefValue = "";
  479. // post_creation_date
  480. $osj2Dposts->post_creation_date->HrefValue = "";
  481. // post_title
  482. if (!is_null($osj2Dposts->post_id->CurrentValue)) {
  483. $osj2Dposts->post_title->HrefValue = ((!empty($osj2Dposts->post_id->ViewValue)) ? $osj2Dposts->post_id->ViewValue : $osj2Dposts->post_id->CurrentValue);
  484. if ($osj2Dposts->Export <> "") $osj2Dposts->post_title->HrefValue = ew_ConvertFullUrl($osj2Dposts->post_title->HrefValue);
  485. } else {
  486. $osj2Dposts->post_title->HrefValue = "";
  487. }
  488. // post_description
  489. $osj2Dposts->post_description->HrefValue = "";
  490. // post_categories
  491. $osj2Dposts->post_categories->HrefValue = "";
  492. // post_edit_date
  493. $osj2Dposts->post_edit_date->HrefValue = "";
  494. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_ADD) { // Add row
  495. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_EDIT) { // Edit row
  496. } elseif ($osj2Dposts->RowType == EW_ROWTYPE_SEARCH) { // Search row
  497. }
  498. // Call Row Rendered event
  499. $osj2Dposts->Row_Rendered();
  500. }
  501. ?>
  502. <?php
  503. // Export data in Xml or Csv format
  504. function ExportData() {
  505. global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $osj2Dposts;
  506. $sCsvStr = "";
  507. $rs = LoadRecordset();
  508. $nTotalRecs = $rs->RecordCount();
  509. $nStartRec = 1;
  510. SetUpStartRec(); // Set Up Start Record Position
  511. // Set the last record to display
  512. if ($nDisplayRecs < 0) {
  513. $nStopRec = $nTotalRecs;
  514. } else {
  515. $nStopRec = $nStartRec + $nDisplayRecs - 1;
  516. }
  517. if ($osj2Dposts->Export == "xml") {
  518. $XmlDoc = new cXMLDocument();
  519. }
  520. if ($osj2Dposts->Export == "csv") {
  521. $sCsvStr .= "post_id" . ",";
  522. $sCsvStr .= "user_id" . ",";
  523. $sCsvStr .= "post_creation_date" . ",";
  524. $sCsvStr .= "post_title" . ",";
  525. $sCsvStr .= "post_description" . ",";
  526. $sCsvStr .= "post_categories" . ",";
  527. $sCsvStr .= "post_edit_date" . ",";
  528. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  529. $sCsvStr .= "\n";
  530. }
  531. // Move to first record directly for performance reason
  532. $nRecCount = $nStartRec - 1;
  533. if (!$rs->EOF) {
  534. $rs->MoveFirst();
  535. $rs->Move($nStartRec - 1);
  536. }
  537. while (!$rs->EOF && $nRecCount < $nStopRec) {
  538. $nRecCount++;
  539. if (intval($nRecCount) >= intval($nStartRec)) {
  540. LoadRowValues($rs);
  541. if ($osj2Dposts->Export == "xml") {
  542. $XmlDoc->BeginRow();
  543. $XmlDoc->AddField('post_id', $osj2Dposts->post_id->CurrentValue);
  544. $XmlDoc->AddField('user_id', $osj2Dposts->user_id->CurrentValue);
  545. $XmlDoc->AddField('post_creation_date', $osj2Dposts->post_creation_date->CurrentValue);
  546. $XmlDoc->AddField('post_title', $osj2Dposts->post_title->CurrentValue);
  547. $XmlDoc->AddField('post_description', $osj2Dposts->post_description->CurrentValue);
  548. $XmlDoc->AddField('post_categories', $osj2Dposts->post_categories->CurrentValue);
  549. $XmlDoc->AddField('post_edit_date', $osj2Dposts->post_edit_date->CurrentValue);
  550. $XmlDoc->EndRow();
  551. }
  552. if ($osj2Dposts->Export == "csv") {
  553. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dposts->post_id->CurrentValue)) . '",';
  554. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dposts->user_id->CurrentValue)) . '",';
  555. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dposts->post_creation_date->CurrentValue)) . '",';
  556. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dposts->post_title->CurrentValue)) . '",';
  557. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dposts->post_description->CurrentValue)) . '",';
  558. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dposts->post_categories->CurrentValue)) . '",';
  559. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Dposts->post_edit_date->CurrentValue)) . '",';
  560. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  561. $sCsvStr .= "\n";
  562. }
  563. }
  564. $rs->MoveNext();
  565. }
  566. // Close recordset
  567. $rs->Close();
  568. if ($osj2Dposts->Export == "xml") {
  569. header("Content-Type: text/xml");
  570. echo $XmlDoc->XML();
  571. }
  572. if ($osj2Dposts->Export == "csv") {
  573. echo $sCsvStr;
  574. }
  575. }
  576. ?>
  577. <?php
  578. // Show link optionally based on User ID
  579. function ShowOptionLink() {
  580. global $Security, $osj2Dposts;
  581. if ($Security->IsLoggedIn()) {
  582. if (!$Security->IsAdmin()) {
  583. return $Security->IsValidUserID($osj2Dposts->user_id->CurrentValue);
  584. }
  585. }
  586. return TRUE;
  587. }
  588. ?>
  589. <?php
  590. // Set up Starting Record parameters based on Pager Navigation
  591. function SetUpStartRec() {
  592. global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $osj2Dposts;
  593. if ($nDisplayRecs == 0) return;
  594. // Check for a START parameter
  595. if (@$_GET[EW_TABLE_START_REC] <> "") {
  596. $nStartRec = $_GET[EW_TABLE_START_REC];
  597. $osj2Dposts->setStartRecordNumber($nStartRec);
  598. } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
  599. $nPageNo = $_GET[EW_TABLE_PAGE_NO];
  600. if (is_numeric($nPageNo)) {
  601. $nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
  602. if ($nStartRec <= 0) {
  603. $nStartRec = 1;
  604. } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
  605. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
  606. }
  607. $osj2Dposts->setStartRecordNumber($nStartRec);
  608. } else {
  609. $nStartRec = $osj2Dposts->getStartRecordNumber();
  610. }
  611. } else {
  612. $nStartRec = $osj2Dposts->getStartRecordNumber();
  613. }
  614. // Check if correct start record counter
  615. if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
  616. $nStartRec = 1; // Reset start record counter
  617. $osj2Dposts->setStartRecordNumber($nStartRec);
  618. } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
  619. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
  620. $osj2Dposts->setStartRecordNumber($nStartRec);
  621. } elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
  622. $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
  623. $osj2Dposts->setStartRecordNumber($nStartRec);
  624. }
  625. }
  626. ?>
  627. <?php
  628. // Page Load event
  629. function Page_Load() {
  630. //echo "Page Load";
  631. }
  632. // Page Unload event
  633. function Page_Unload() {
  634. //echo "Page Unload";
  635. }
  636. ?>