Commit 7f1f4ebb93caaae4612965d0cc4559bf6e2b5e42
1 parent
1dcdbceb
initial presentation files for dashboard news
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1782 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
242 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/administration/news/editNewsBL.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../../../config/dmsDefaults.php"); | |
| 4 | +require_once("$default->fileSystemRoot/lib/dashboard/DashboardNews.inc"); | |
| 5 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); | |
| 6 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 7 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | |
| 8 | +require_once("$default->uiDirectory/administration/news/newsUI.inc"); | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * $Id$ | |
| 12 | + * | |
| 13 | + * Business logic for editing a news item | |
| 14 | + * | |
| 15 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | |
| 16 | + * | |
| 17 | + * @version $Revision$ | |
| 18 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 19 | + * @package presentation.lookAndFeel.knowledgeTree.administration.news | |
| 20 | + */ | |
| 21 | + | |
| 22 | +if (checkSession()) { | |
| 23 | + global $default; | |
| 24 | + | |
| 25 | + // instantiate my content pattern | |
| 26 | + $oContent = new PatternCustom(); | |
| 27 | + | |
| 28 | + if (isset($fNewsID)) { | |
| 29 | + // we have an id, so instantiate the news object | |
| 30 | + $oDashboardNews = DashboardNews::get($fNewsID); | |
| 31 | + if ($fUpdate) { | |
| 32 | + // overwrite the news attributes and save | |
| 33 | + | |
| 34 | + // only overwrite synopsis, body and rank if they've different | |
| 35 | + if ($oDashboardNews->getSynopsis() <> $fSynopsis) { | |
| 36 | + $oDashboardNews->setSynopsis($fSynopsis); | |
| 37 | + } | |
| 38 | + if ($oDashboardNews->getBody() <> $fBody) { | |
| 39 | + $oDashboardNews->setBody($fBody); | |
| 40 | + } | |
| 41 | + if ($oDashboardNews->getRank() <> $fRank) { | |
| 42 | + $oDashboardNews->setRank($fRank); | |
| 43 | + } | |
| 44 | + // if we have a new image | |
| 45 | + // TODO: check that it is an image | |
| 46 | + if (strlen($_FILES['fImage']['name']) > 0) { | |
| 47 | + $oDashboardNews->setImageFile($_FILES['fImage']['tmp_name']); | |
| 48 | + } | |
| 49 | + | |
| 50 | + if ($oDashboardNews->update()) { | |
| 51 | + $default->log->info("editNewsBL.php successfully updated dashboard news id=$fNewsID"); | |
| 52 | + // redirect to view page | |
| 53 | + redirect("$default->rootUrl/control.php?action=viewNews"); | |
| 54 | + } else { | |
| 55 | + // update failed | |
| 56 | + $default->log->error("editNewsBL.php DB error updating dashboard news id=$fNewsID; ($fSynopsis, $fBody, $fRank)"); | |
| 57 | + $oContent->setHtml(renderErrorMessage("An error occurred while updating this news item.")); | |
| 58 | + } | |
| 59 | + } else { | |
| 60 | + // display the edit form | |
| 61 | + $oContent->setHtml(renderEditNewsPage($oDashboardNews)); | |
| 62 | + } | |
| 63 | + } else { | |
| 64 | + // no news id, so display an error message | |
| 65 | + $oContent->setHtml(renderErrorMessage("No news item was selected for editing")); | |
| 66 | + } | |
| 67 | + | |
| 68 | + // build the page | |
| 69 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 70 | + $main->setCentralPayload($oContent); | |
| 71 | + $main->setFormEncType("multipart/form-data"); | |
| 72 | + $main->setFormAction($_SERVER['PHP_SELF']); | |
| 73 | + $main->setHasRequiredFields(true); | |
| 74 | + $main->render(); | |
| 75 | +} | |
| 76 | +?> | |
| 0 | 77 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/news/manageNewsBL.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../../../config/dmsDefaults.php"); | |
| 4 | +require_once("$default->fileSystemRoot/lib/dashboard/DashboardNews.inc"); | |
| 5 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMainPage.inc"); | |
| 6 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | |
| 7 | +require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | |
| 8 | +require_once("$default->uiDirectory/administration/news/newsUI.inc"); | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * $Id$ | |
| 12 | + * | |
| 13 | + * This page handles the administration of dashboard news items | |
| 14 | + * | |
| 15 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | |
| 16 | + * | |
| 17 | + * @version $Revision$ | |
| 18 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 19 | + * @package presentation.lookAndFeel.knowledgeTree.administration.news | |
| 20 | + */ | |
| 21 | + | |
| 22 | +if (checkSession()) { | |
| 23 | + | |
| 24 | + // instantiate my content pattern | |
| 25 | + $oContent = new PatternCustom(); | |
| 26 | + | |
| 27 | + if (isset($fNewsID)) { | |
| 28 | + // we have an id, so we're either deleting, editing or previewing a current item | |
| 29 | + } else { | |
| 30 | + // no news id, so list the current news items | |
| 31 | + $oContent->setHtml(renderViewNewsPage()); | |
| 32 | + } | |
| 33 | + | |
| 34 | + //$main->setFormAction("$default->rootUrl/presentation/lookAndFeel/knowledgeTree/create.php?fRedirectURL=".urlencode("$default->rootUrl/control.php?action=addLinkSuccess&fLinkID=")); | |
| 35 | + //$main->setHasRequiredFields(true); | |
| 36 | + | |
| 37 | + // build the page | |
| 38 | + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | |
| 39 | + $main->setCentralPayload($oContent); | |
| 40 | + $main->render(); | |
| 41 | +} | |
| 42 | +?> | |
| 0 | 43 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/news/newsUI.inc
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("../../../../../config/dmsDefaults.php"); | |
| 4 | +require_once("$default->uiDirectory/administration/adminUI.inc"); | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * $Id$ | |
| 8 | + * | |
| 9 | + * This page controls browsing for documents- this can be done either by | |
| 10 | + * folder, category or document type. | |
| 11 | + * The relevant permission checking is performed, calls to the business logic | |
| 12 | + * layer to retrieve the details of the documents to view are made and the user | |
| 13 | + * interface is contructed. | |
| 14 | + * | |
| 15 | + * Licensed under the GNU GPL. For full terms see the file DOCS/COPYING. | |
| 16 | + * | |
| 17 | + * @version $Revision$ | |
| 18 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 19 | + * @package presentation.lookAndFeel.knowledgeTree.documentmanagement | |
| 20 | + */ | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * Displays an error message | |
| 24 | + */ | |
| 25 | +function renderErrorMessage($sErrorMessage) { | |
| 26 | + $sToRender = "<table>"; | |
| 27 | + $sToRender .= "<tr><td><p><font color=\"red\">$sErrorMessage</font></p></td></tr>"; | |
| 28 | + $sToRender .= "</table>"; | |
| 29 | + return $sToRender; | |
| 30 | +} | |
| 31 | + | |
| 32 | +function renderNewsPopupJavascript() { | |
| 33 | + global $default; | |
| 34 | + return "\n\n<SCRIPT LANGUAGE=\"javascript\">\n " . | |
| 35 | + "<!--\n" . | |
| 36 | + "function popupNews() {\n" . | |
| 37 | + "window.open ('" . generateControllerUrl("displayNews", "fNewsID=" ) . "', 'newwindow', config='height=400,width=600,left=400,top=300, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no');\n" . | |
| 38 | + "return false;\n" . | |
| 39 | + "}\n" . | |
| 40 | + "//-->\n" . | |
| 41 | + "</SCRIPT>\n\n"; | |
| 42 | +} | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * Displays the current news items | |
| 46 | + */ | |
| 47 | +function renderNewsTable() { | |
| 48 | + global $default; | |
| 49 | + $sQuery = "SELECT id, synopsis, body, rank, if((length(image)>0),'yes','no') as image, 'Edit' AS edit, 'Preview' AS preview, 'Delete' AS del " . | |
| 50 | + "FROM $default->owl_news_table ORDER BY rank ASC"; | |
| 51 | + $aColumns = array("synopsis", "body", "rank", "image", "edit", "preview", "del"); | |
| 52 | + $aColumnHeaders = array("Synopsis", "Body", "Rank", "Image"); | |
| 53 | + $aColumnTypes = array(1,1,1,1,3,3,3); | |
| 54 | + $aDBColumnArray = array("id"); | |
| 55 | + $aQueryStringVariableNames = array("fNewsID"); | |
| 56 | + $aLinkURLs = array(4=> "$default->rootUrl/control.php?action=editNews", | |
| 57 | + 5=> "$default->rootUrl/control.php?action=previewNews", | |
| 58 | + 6=> "$default->rootUrl/control.php?action=removeNews"); | |
| 59 | + | |
| 60 | + $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "10%", $aLinkURLs,$aDBColumnArray,$aQueryStringVariableNames); | |
| 61 | + $oPatternTableSqlQuery->setTableHeading("Dashboard News"); | |
| 62 | + $oPatternTableSqlQuery->setDisplayColumnHeadings(true); | |
| 63 | + return $oPatternTableSqlQuery->render(); | |
| 64 | +} | |
| 65 | + | |
| 66 | +/** | |
| 67 | + * Displays the edit/add news item form | |
| 68 | + * | |
| 69 | + * @param DashboardNews the news item to modify | |
| 70 | + */ | |
| 71 | +function renderModifyAddNewsForm($oDashboardNews = null) { | |
| 72 | + global $default; | |
| 73 | + | |
| 74 | + $sToRender = "<table>"; | |
| 75 | + $sToRender .= "<tr><td>Synopsis</td><td><input type=\"text\" name=\"fSynopsis\" value=\"" . ($oDashboardNews ? $oDashboardNews->getSynopsis() : "") . "\"></td></tr>"; | |
| 76 | + $sToRender .= "<tr><td>Body</td><td><input type=\"textarea\" name=\"fBody\" value=\"" . ($oDashboardNews ? $oDashboardNews->getBody() : "") . "\"></td></tr>"; | |
| 77 | + $sToRender .= "<tr><td>Rank</td><td><input type=\"text\" name=\"fRank\" value=\"" . ($oDashboardNews ? $oDashboardNews->getRank() : "") . "\"></td></tr>"; | |
| 78 | + $sToRender .= "<tr><td>Image</td><td><input type=\"file\" name=\"fImage\"></td></tr>"; | |
| 79 | + $sToRender .= (isset($oDashboardNews) ? "<input type=\"hidden\" name=\"fNewsID\" value=\"" . $oDashboardNews->getID() . "\">" : ""); | |
| 80 | + $sToRender .= "<input type=\"hidden\" name=\"fUpdate\" value=\"1\">"; | |
| 81 | + $sToRender .= "<tr><td><input type=\"image\" src=\"$default->graphicsUrl/widgets/submit.gif\" border=\"0\">\n"; | |
| 82 | + $sToRender .= "<a href=\"$default->rootUrl/control.php?action=viewNews\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a></td></tr>\n"; | |
| 83 | + $sToRender .= "</table>"; | |
| 84 | + return $sToRender; | |
| 85 | +} | |
| 86 | + | |
| 87 | +/** | |
| 88 | + * Displays the edit news page | |
| 89 | + */ | |
| 90 | +function renderEditNewsPage($oDashboardNews) { | |
| 91 | + global $default; | |
| 92 | + | |
| 93 | + $sToRender .= "<table width=\"600\">" . renderHeading("Edit Dashboard News") . "</table>"; | |
| 94 | + $sToRender .= "<table>\n"; | |
| 95 | + $sToRender .= renderModifyAddNewsForm($oDashboardNews); | |
| 96 | + $sToRender .= "</table>\n"; | |
| 97 | + return $sToRender; | |
| 98 | +} | |
| 99 | + | |
| 100 | +/** | |
| 101 | + * Displays the add new new item page | |
| 102 | + */ | |
| 103 | +function renderNewNewsPage() { | |
| 104 | + global $default; | |
| 105 | + | |
| 106 | + $sToRender .= "<table width=\"600\">" . renderHeading("View Dashboard News") . "</table>"; | |
| 107 | + $sToRender .= "<table>\n"; | |
| 108 | + $sToRender .= renderModifyAddNewsForm(); | |
| 109 | + $sToRender .= "</table>\n"; | |
| 110 | + return $sToRender; | |
| 111 | +} | |
| 112 | +/** | |
| 113 | + * Displays a list of news items | |
| 114 | + */ | |
| 115 | +function renderViewNewsPage() { | |
| 116 | + global $default; | |
| 117 | + | |
| 118 | + $sToRender .= "<table width=\"600\">" . renderHeading("View Dashboard News") . "</table>"; | |
| 119 | + $sToRender .= "<table>\n"; | |
| 120 | + $sToRender .= renderNewsTable(); | |
| 121 | + $sToRender .= "</table>\n"; | |
| 122 | + return $sToRender; | |
| 123 | +} | |
| 124 | +?> | |
| 0 | 125 | \ No newline at end of file | ... | ... |