objectManager: add preview support, use it for notes
This commit is contained in:
committed by
Chris Morgan
parent
4b453e1e5a
commit
d7fc82c72f
@@ -136,6 +136,10 @@ class Note {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function objectShowPreview()
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
function SendNotificationMail($sAction="add",$sMsg=null)
|
function SendNotificationMail($sAction="add",$sMsg=null)
|
||||||
{
|
{
|
||||||
@@ -183,7 +187,7 @@ class Note {
|
|||||||
/* Show note */
|
/* Show note */
|
||||||
/* $bDisplayOnly means we should not display any editing controls, even if */
|
/* $bDisplayOnly means we should not display any editing controls, even if */
|
||||||
/* the user has the ability to edit this note */
|
/* the user has the ability to edit this note */
|
||||||
function display($bDisplayOnly = false)
|
function display($aVars = null)
|
||||||
{
|
{
|
||||||
switch($this->sTitle)
|
switch($this->sTitle)
|
||||||
{
|
{
|
||||||
@@ -216,15 +220,12 @@ class Note {
|
|||||||
$shOutput .= $this->shDescription;
|
$shOutput .= $this->shDescription;
|
||||||
$shOutput .= "</td></tr>\n";
|
$shOutput .= "</td></tr>\n";
|
||||||
|
|
||||||
if(!$bDisplayOnly)
|
if((!$aVars || $aVars['bEditing'] != "true") && $this->canEdit())
|
||||||
{
|
{
|
||||||
if ($this->canEdit())
|
$shOutput .= "<tr class=\"color1\" align=\"center\" valign=\"top\"><td>";
|
||||||
{
|
$shOutput .= "<form method=\"post\" name=\"message\" action=\"objectManager.php?sClass=note&sAction=edit&iId=".$this->iNoteId."&sReturnTo=".urlencode($oVersion->objectMakeUrl())."\">";
|
||||||
$shOutput .= "<tr class=\"color1\" align=\"center\" valign=\"top\"><td>";
|
$shOutput .= '<input type="submit" value="Edit Note" class="button">';
|
||||||
$shOutput .= "<form method=\"post\" name=\"message\" action=\"objectManager.php?sClass=note&sAction=edit&iId=".$this->iNoteId."&sReturnTo=".urlencode($oVersion->objectMakeUrl())."\">";
|
$shOutput .= '</form></td></tr>';
|
||||||
$shOutput .= '<input type="submit" value="Edit Note" class="button">';
|
|
||||||
$shOutput .= '</form></td></tr>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$shOutput .= "</table>\n";
|
$shOutput .= "</table>\n";
|
||||||
@@ -237,6 +238,9 @@ class Note {
|
|||||||
{
|
{
|
||||||
switch($sAction)
|
switch($sAction)
|
||||||
{
|
{
|
||||||
|
case "preview":
|
||||||
|
return array("bEditing");
|
||||||
|
|
||||||
case "add":
|
case "add":
|
||||||
return array("iVersionId","sNoteTitle");
|
return array("iVersionId","sNoteTitle");
|
||||||
|
|
||||||
@@ -261,6 +265,7 @@ class Note {
|
|||||||
echo html_frame_start("Edit Application Note {$aClean['noteId']}", "90%","",0);
|
echo html_frame_start("Edit Application Note {$aClean['noteId']}", "90%","",0);
|
||||||
echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
|
echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
|
||||||
|
|
||||||
|
echo '<input type="hidden" name="bEditing" value="true" />';
|
||||||
echo '<input type="hidden" name="iNoteId" value="'.$this->iNoteId.'" />';
|
echo '<input type="hidden" name="iNoteId" value="'.$this->iNoteId.'" />';
|
||||||
echo '<input type="hidden" name="iVersionId" value="'.$this->iVersionId.'" />';
|
echo '<input type="hidden" name="iVersionId" value="'.$this->iVersionId.'" />';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
define("PREVIEW_ENTRY", 2);
|
||||||
|
|
||||||
/* class for managing objects */
|
/* class for managing objects */
|
||||||
/* - handles processing of queued objects */
|
/* - handles processing of queued objects */
|
||||||
/* - handles the display and editing of unqueued objects */
|
/* - handles the display and editing of unqueued objects */
|
||||||
@@ -236,6 +238,9 @@ class ObjectManager
|
|||||||
{
|
{
|
||||||
global $aClean;
|
global $aClean;
|
||||||
$oObject->getOutputEditorValues($aClean);
|
$oObject->getOutputEditorValues($aClean);
|
||||||
|
|
||||||
|
if($sErrors == PREVIEW_ENTRY)
|
||||||
|
$this->show_preview($oObject, $aClean);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<form name="sQform" action="'.$this->makeUrl("edit", $this->iId).
|
echo '<form name="sQform" action="'.$this->makeUrl("edit", $this->iId).
|
||||||
@@ -312,6 +317,7 @@ class ObjectManager
|
|||||||
echo '<input name="sSubmit" type="submit" value="Submit" class="button">'.
|
echo '<input name="sSubmit" type="submit" value="Submit" class="button">'.
|
||||||
' ',"\n";
|
' ',"\n";
|
||||||
echo '<input name="sSubmit" type="submit" value="Delete" class="button" />'."\n";
|
echo '<input name="sSubmit" type="submit" value="Delete" class="button" />'."\n";
|
||||||
|
$this->handle_preview_button();
|
||||||
echo "</td></tr>\n";
|
echo "</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -632,6 +638,20 @@ class ObjectManager
|
|||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function show_preview($oObject, $aClean)
|
||||||
|
{
|
||||||
|
echo html_frame_start("Preview", "75%");
|
||||||
|
|
||||||
|
$aVars = $this->get_custom_vars($aClean, "preview");
|
||||||
|
|
||||||
|
if($aVars)
|
||||||
|
$oObject->display($aVars);
|
||||||
|
else
|
||||||
|
$oObject->display();
|
||||||
|
|
||||||
|
echo html_frame_end();
|
||||||
|
}
|
||||||
|
|
||||||
/* Display screen for submitting a new entry of given type */
|
/* Display screen for submitting a new entry of given type */
|
||||||
function add_entry($aClean, $sErrors = "")
|
function add_entry($aClean, $sErrors = "")
|
||||||
{
|
{
|
||||||
@@ -648,6 +668,9 @@ class ObjectManager
|
|||||||
{
|
{
|
||||||
global $aClean;
|
global $aClean;
|
||||||
$oObject->getOutputEditorValues($aClean);
|
$oObject->getOutputEditorValues($aClean);
|
||||||
|
|
||||||
|
if($sErrors == PREVIEW_ENTRY)
|
||||||
|
$this->show_preview($oObject, $aClean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display help if it is exists */
|
/* Display help if it is exists */
|
||||||
@@ -673,13 +696,26 @@ class ObjectManager
|
|||||||
echo "<div align=\"center\">";
|
echo "<div align=\"center\">";
|
||||||
echo "<input type=\"submit\" class=\"button\" value=\"Submit\" ".
|
echo "<input type=\"submit\" class=\"button\" value=\"Submit\" ".
|
||||||
"name=\"sSubmit\" />\n";
|
"name=\"sSubmit\" />\n";
|
||||||
|
$this->handle_preview_button();
|
||||||
echo "</div></form>\n";
|
echo "</div></form>\n";
|
||||||
|
|
||||||
echo html_back_link(1, $sBackLink);
|
echo html_back_link(1, $sBackLink);
|
||||||
|
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handle_preview_button()
|
||||||
|
{
|
||||||
|
$oObject = new $this->sClass($this->iId);
|
||||||
|
|
||||||
|
if(!method_exists($oObject, "objectShowPreview"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!$oObject->objectShowPreview())
|
||||||
|
return;
|
||||||
|
|
||||||
|
echo '<input type="submit" name="sSubmit" class="button" value="Preview" />';
|
||||||
|
}
|
||||||
|
|
||||||
function handle_anonymous_submission()
|
function handle_anonymous_submission()
|
||||||
{
|
{
|
||||||
$oObject = new $this->sClass();
|
$oObject = new $this->sClass();
|
||||||
@@ -822,6 +858,9 @@ class ObjectManager
|
|||||||
// have to correct
|
// have to correct
|
||||||
switch($aClean['sSubmit'])
|
switch($aClean['sSubmit'])
|
||||||
{
|
{
|
||||||
|
case "Preview":
|
||||||
|
return PREVIEW_ENTRY;
|
||||||
|
|
||||||
case "Submit":
|
case "Submit":
|
||||||
// if we have errors, return them
|
// if we have errors, return them
|
||||||
if($sErrors)
|
if($sErrors)
|
||||||
@@ -1070,6 +1109,10 @@ class ObjectManager
|
|||||||
if($sErrors === TRUE)
|
if($sErrors === TRUE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
if($sErrors == PREVIEW_ENTRY)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
echo "<font color=\"red\">\n";
|
echo "<font color=\"red\">\n";
|
||||||
echo "The following errors were found<br />\n";
|
echo "The following errors were found<br />\n";
|
||||||
echo "<ul>$sErrors</ul>\n";
|
echo "<ul>$sErrors</ul>\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user