I modified the Article Admin page code to allow for the
entry of the "up" field (or in my case I labeled in "Prev.
Page".).

Only problem is that it seems you can't modify the "up"
field for articles. 
And lastly, the "list reply articles" function is kinda
wierd. I recall that this was a known bug and will be fixed
in the new version. It only shows during the creation of an
article, and has the following error message: "Warning:
Object article not found in content on line 229".

(Oh yeah, and I turned of the ability to modify the Type
field.)

Anyway, here are the code changes for your review:

/Admin Root/topic/article

Page Element - code-init:

<?
if ($create || $modify) {
  $calstart = ($sday && $smonth && $syear) ?
"$sday.$smonth.$syear" : '';
  if ($calstart && $eday && $emonth && $eyear) 
    $caldays = 
ceil((mktime(0,0,0,$emonth,$eday,$eyear)-mktime(0,0,0,$smonth,$sday,$syear))
/ (60*60*24));
  else
    $caldays = 0;
}

if ($argc == 1) $id = $argv[0];
if ($create) $id = mgd_create_article($up, $topic, $name,
$title, $abstract, $content, $author, $url, $calstart,
$caldays, $icon, $view, $print, $extra1, $extra2, $extra3,
$type);
if ($modify && $id) mgd_update_article($id, $up, $topic,
$name, $title, $abstract, $content, $author, $url,
$calstart, $caldays, $icon, $view, $print, $extra1, $extra2,
$extra3);
if ($id && isset($score)) mgd_update_article_score($id,
$score);
if ($id && isset($lock)) mgd_toggle_article_lock($id);
if ($id && isset($approve)) mgd_approve_article($id);

if ($id) $article = mgd_get_article($id);
if ($article) $topic = $article->topic;
?>




Content:

<? if ($article || $action == 'create') {
     if ($action == 'modify') {
        $up          = $article->up;
        $topic       = $article->topic;
        $name        = $article->name;
        $title       = $article->title;
        $abstract    = $article->abstract;
        $content     = $article->content;
        $author      = $article->author;
        $url         = $article->url;
        $startdate   = $article->startdate;
        $caldays     = $article->caldays;
        $icon        = $article->icon;
        $view        = $article->view;
        $print       = $article->print;
        $extra1      = $article->extra1;
        $extra2      = $article->extra2;
        $extra3      = $article->extra3;
     } elseif ($action == 'create') {
        $author      = $midgard->user;
        $startdate   = 0;
        $caldays     = 0;
        $type = 0;
        $icon = $view = $print = 0;
     } ?>

<? /* ARTICLE HEADER */ ?>
<? if ($action == 'create') { ?>
<h1>New article</h2>
<? } else { ?>
<h2><a href="/topic/article/&(article.id);.html"
class="navi">&(article.title);</a>
    (article #&(article.id);)</h2>
<? } ?>

<? if ($action == 'delete') { ?>
<?   if ($confirm && mgd_delete_article($article->id)) { ?>
<p>Article record deleted.</p>
<p><a href="/topic/&(article.topic);.html"
class="navi">&(mgdleft:h); Return to topic</a>.</p>
<?   } else { ?>
<p>Do you really want to delete this article record?</p>
<p><a href="/topic/article/&(article.id);.html?action=delete&confirm=1"
class="navi">&(mgdok:h); Yes, delete</a>.
   <a href="/topic/article/&(article.id);.html"
class="navi">&(mgdcancel:h); No, do not delete</a>.</p>
<?   } ?>
<? } else { ?>

<? if ($action == 'create') { ?>
<form method="post" action="/topic/article/">
<? } elseif ($action) { ?>
<form method="post" action="/topic/article/&(article.id);.html">
<? } ?>

<? /* ARTICLE METADATA */ ?>
<table border="0" bgcolor="f0f0f0" cellspacing="0"
cellpadding="4">
  <tr><td><p>Location:</p></td>
      <td><p>
<? if ($topic) {
     function twalk($id) {
       if (!$id || !($t = mgd_get_topic($id))) return;
       twalk($t->up);
       printf('/ <a href="/topic/%d.html">%s</a> ', $t->id,
htmlentities($t->name));
     }
     twalk($topic);
   } else { ?>
unknown
<? } ?>
<? if ($action) { ?><input type="hidden" name="topic"
value="&(topic);"><? } ?>
          </p></td></tr>
<? if ($action) { ?>
  <tr><td><p>Title:</p></td>
      <td><input type="text" name="title" value="&(title);"
size="40"></td></tr>
<? } ?>
  <tr><td><p>Name:</p></td>
      <td><? if ($action) { ?><input type="text" name="name"
value="&(name);" size="40"><? } elseif ($article->name) {
?><p>&(article.name);</p><? } else { ?>&nbsp;<? }
?></td></tr>
  <tr><td><p>Author:</p></td>
      <td>
<? if ($action) { ?>
<select name="author">
<? if ($p = mgd_list_persons()) while ($p->fetch()) { ?>
  <option value="&(p.id);"<? if ($author == $p->id) echo '
selected'; ?>>&(p.rname);</option>
<? } ?>
</select>
<? } else {?>
<p><? if ($p = mgd_get_person($article->author))
        printf('<a href="/group/person/%d.html">%s</a>',
$p->id,
               htmlentities($p->name));
      else
        echo 'unknown'; ?></p>
<? } ?>
          </td></tr>
<? if (!$action) { ?>
  <tr><td><p>Score:</p></td>
      <td><p><? if (!$action && $article->score)
                  printf('<a href="/topic/article/%d.html?score=%d"
class="navi">%s</a>',
                         $article->id, $article->score - 1,
$mgdleft);
                printf(' %d ', $article->score);
                if (!$action)
                  printf('<a href="/topic/article/%d.html?score=%d"
class="navi">%s</a>',
                         $article->id, $article->score + 1,
$mgdright); ?></p></td></tr>
  <tr><td><p>Created:</p></td>
      <td><p><? echo strftime('%c', $article->created);
                if ($p = mgd_get_person($article->creator))
                  printf(' by <a
href="/group/person/%d.html">%s</a>',
                         $p->id, htmlentities($p->name));
?></p></td></tr>
  <tr><td><p>Modified:</p></td>
      <td><p><? if ($article->revised > $article->created) {
                  echo strftime('%c', $article->revised);
                  if ($p = mgd_get_person($article->revisor))
                    printf(' by <a
href="/group/person/%d.html">%s</a>',
                           $p->id, htmlentities($p->name));
                  printf(' revision %d',
$article->revision);
                } else
                  echo 'never'; ?></p></td></tr>
  <tr><td><p>Approved:</p></td>
      <td><p><? if ($article->approved) {
                  echo strftime('%c', $article->approved);
                  if ($p = mgd_get_person($article->approver))
                    printf(' by <a
href="/group/person/%d.html">%s</a>',
                           $p->id, htmlentities($p->name));
                  if ($article->revised >
$article->approved)
                    echo ' modified recently';
                } else
                  echo 'never'; ?></p></td></tr>
  <tr><td><p>Locked:</p></td>
      <td><p><? if ($article->locker) {
                  echo strftime('%c', $article->locked);
                  if ($p = mgd_get_person($article->locker))
                    printf(' by <a
href="/group/person/%d.html">%s</a>',
                           $p->id, htmlentities($p->name));
                  else
                    printf(' by person #%d',
$article->locker);
                } else
                  echo 'not locked'; ?></p></td></tr>
<? } ?>

<? if ($action) {
     if ($startdate) {
       $sdate = getdate($startdate);
       $sday   = $sdate['mday'];
       $smonth = $sdate['mon'];
       $syear  = $sdate['year'];
       $edate = getdate($startdate + $caldays*60*60*24);
       $eday   = $edate['mday'];
       $emonth = $edate['mon'];
       $eyear  = $edate['year'];
     } else
       $sday = $smonth = $syear = $eday = $emonth = $eyear =
0;
     $mon = array(0 => 'NA', 1 => 'January', 2 =>
'February', 3 => 'March',
                  4 => 'April', 5 => 'May', 6 => 'June', 7
=> 'July',
                  8 => 'August', 9 => 'September', 10 =>
'October',
                  11 => 'November', 12 => 'December'); ?>
  <tr><td><p>Start date:</p></td>
      <td><select name="sday"><? for ($i = 0; $i < 32; $i++)
echo '<option value="', $i, (($sday == $i) ? '" selected>' :
'">'), $i ? $i : 'NA', '</option>'; ?></select>
          <select name="smonth"><? reset($mon); while
(list($i,$n) = each($mon)) { echo '<option value="', $i,
(($smonth == $i) ? '" selected>' : '">'), $n, '</option>'; }
?></select>
          <select name="syear"><option value="0"<? if
(!$syear) echo ' selected'; ?>>NA</option><? for ($i = 1997;
$i < 2020; $i++) { echo '<option value="', $i, (($syear ==
$i) ? '" selected>' : '">'), $i, '</option>'; }
?></select></td></tr>
  <tr><td><p>End date:</p></td>
      <td><select name="eday"><? for ($i = 0; $i < 32; $i++)
echo '<option value="', $i, (($eday == $i) ? '" selected>' :
'">'), $i ? $i : 'NA', '</option>'; ?></select>
          <select name="emonth"><? reset($mon); while
(list($i,$n) = each($mon)) { echo '<option value="', $i,
(($emonth == $i) ? '" selected>' : '">'), $n, '</option>'; }
?></select>
          <select name="eyear"><option value="0"<? if
(!$eyear) echo ' selected'; ?>>NA</option><? for ($i = 1997;
$i < 2020; $i++) { echo '<option value="', $i, (($eyear ==
$i) ? '" selected>' : '">'), $i, '</option>'; }
?></select></td></tr>
<? } else { ?>
  <tr><td><p>Calendar:</p></td>
      <td><p><? if ($article->startdate) {
                  echo strftime('%d %b %Y',
$article->startdate);
                  if ($article->caldays)
                    echo ' - ', strftime('%d %b %Y',
$article->startdate + $article->caldays*60*60*24);
                } else
                  echo 'not set'; ?></p></td></tr>
<? } ?>

  <tr><td><p>Url:</p></td>
      <td><? if ($action) { ?><input type="text" name="url"
value="&(url);" size="40"><? } elseif ($article->url) {
?><p><a href="&(article.url);">&(article.url);</a></p><? }
else { ?>&nbsp;<? } ?></td></tr>

 <tr><td><p>Prev. Page:</p></td>
      <td><? if ($action) { ?><input type="text" name="up"
value="&(up);" size="10"><? } else {
?><p>&(article.up);</p><? } ?></td></tr>

</table>

<? /* ADMINISTRATION LINKS */ ?>
<p>
<? if ($action) { ?>
<input type="submit" name="&(action);" value="Submit">
<input type="reset" value="Reset">
<? } else { ?>
<?php   if ($article->up): ?>
<a href="/topic/article/&(article.up);.html"
class="navi">&(mgdleft:h);&nbsp;Parent&nbsp;article</a>
<?php   else: ?>
<a href="/topic/&(article.topic);.html"
class="navi">&(mgdleft:h);&nbsp;Go&nbsp;to&nbsp;topic</a>
<?php   endif; ?>
<a href="/topic/article/&(article.id);.html?action=modify"
class="navi">&(mgdedit:h);&nbsp;Modify</a>
<a href="/topic/article/&(article.id);.html?action=delete"
class="navi">&(mgddel:h);&nbsp;Delete</a>
<a href="/topic/article/&(article.id);.html?approve=1"
class="navi">&(mgdok:h);&nbsp;Approve</a>
<a href="/topic/article/&(article.id);.html?lock=1"
class="navi"><? echo $article->locker ? "$mgdon&nbsp;Unlock"
: "$mgdoff&nbsp;Lock"; ?></a>
<? } ?>
</p>

<? /* ARTICLE CONTENT */ ?>
<h3>Abstract:</h3>
<? if ($action) { ?>
<textarea name="abstract" rows="5" cols="60"
wrap="soft">&(abstract);</textarea>
<? } else { ?>
<p class="abstract">
&(article.abstract);
</p>
<? } ?>

<h3>Content:</h3>
<? if ($action) { ?>
<textarea name="content" rows="10" cols="60"
wrap="soft">&(content);</textarea>
<? } else { ?>
&(article.content:f);
<? } ?>

<h3>Extra information:</h3>
<table border="0" cellspacing="5">
  <tr><td><p>Type:</p></td><td><? if ($action) { ?><input
type="text" name="type" value="&(type);" size="5"><? } else
{ ?><p>&(article.type);</p><? } ?></td></tr>
  <tr><td><p>IDs:</p></td><td>
<? if ($action) { ?>
<input type="text" name="icon" value="&(icon);" size="5">
<input type="text" name="view" value="&(view);" size="5">
<input type="text" name="print" value="&(print);" size="5">
<? } else { ?>
<p>icon: &(article.icon);, view: &(article.view);, print:
&(article.print);</p>
<? } ?>
     </td></tr>
  <tr><td><p>Byline:</p></td><td><? if ($action) { ?><input
type="text" name="extra1" value="&(extra1);" size="40"><? }
else { ?><p>&(article.extra1);</p><? } ?></td></tr>
  <tr><td><p>Extra 2:</p></td><td><? if ($action) { ?><input
type="text" name="extra2" value="&(extra2);" size="40"><? }
else { ?><p>&(article.extra2);</p><? } ?></td></tr>
  <tr><td><p>Extra 3:</p></td><td><? if ($action) { ?><input
type="text" name="extra3" value="&(extra3);" size="40"><? }
else { ?><p>&(article.extra3);</p><? } ?></td></tr>
</table>

<?php if ($r = mgd_list_reply_articles($article->id)): ?>
<h3>Replies</h3>
<ul>
<?php   while ($r->fetch()): ?>
  <li><a href="/topic/article/&(r.id);.html">&(r.title);</a></li>
<?php   endwhile; ?>
</ul>
<?php endif; ?>

<? if ($action) { ?>
</form>
<? } ?>

<? } ?>

<? } ?>



Todd Daniel Woodward
Technical Consultant
RadioDigest.com Inc.

http://radiodigest.com

512/583-5448 Office
512/415-6840 Cell

     "Radio you can READ!"

--
This is The Midgard Project's mailing list. For more information,
please visit the project's web site at http://www.midgard-project.org

To unsubscribe the list, send an empty email message to address
[EMAIL PROTECTED]

Reply via email to