/** * form_edits_tab * * * * * * */ function form_edits_tab($article_data) { $edits = get_article_edits($article_data['id']); $html = ' <div id="tab_edits"> <h2>Edits</h2>'; if (empty($edits)) { $html .= ' <p>There are no previous edits for this article.</p>'; } else { $html .= ' <ul class="article_listing">'; foreach ($edits as $edit) { $html .= ' <li> <div class="article_title">' . from_mysql_date($edit['date_edited'], 'd M Y H:i') . '</div> <div class="article_author"> by ' . $edit['name'] . '</div> <span> <a class="preview_edit" href="' . WW_WEB_ROOT . '/ww_edit/_content/preview_edit.php?edit_id=' . $edit['id'] . '&author_id=' . (int) $_SESSION[WW_SESS]['user_id'] . '&sess=' . htmlspecialchars(session_id()) . '">view</a> </span> </li>'; } $html .= ' </ul>'; } $html .= ' </div>'; return $html; }
/** * build_write_form * * * * * * */ function build_write_form($article_data, $config) { // construct link if (!empty($article_data['id'])) { $article_data['link'] = $config['layout']['url_style'] == 'blog' ? WW_REAL_WEB_ROOT . '/' . date('Y/m/d', strtotime($article_data['date_uploaded'])) . '/' . $article_data['url'] . '/' : WW_REAL_WEB_ROOT . '/' . $article_data['category_url'] . '/' . $article_data['url'] . '/'; } // get edits data $edits = get_article_edits($article_data['id']); $edits_count = count($edits); // start tabs $attachments_total = count($article_data['attachments']); $form = ' <div id="article_tabs"> <ul> <li><a href="#tab_article">Article</a></li> <li><a href="#tab_attachments">Attachments (' . $attachments_total . ')</a></li> <li><a href="#tab_seo">SEO</a></li> <li><a href="#tab_comments">Comments</a></li> <li><a href="#tab_edits">Edits (' . $edits_count . ')</a></li> </ul>'; // start form $form .= ' <form method="post" enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '?' . $_SERVER["QUERY_STRING"] . '" id="write_article">'; // message window - for errors and autosave status $form .= ' <div id="messages"> <span id="last_autosave"></span>'; // errors if (!empty($article_data['error'])) { $form .= ' <ul id="errors"> <li>The following errors prevented your article from being saved:</li> <li>' . implode('</li><li>', $article_data['error']) . '</li> </ul> '; } $form .= ' </div>'; // output form $form .= form_article_tab($article_data); $form .= form_attachments_tab($article_data, $config); $form .= form_seo_tab($article_data); $form .= form_comments_tab($article_data, $config); $form .= form_edits_tab($edits); // submit buttons $form .= ' <p> <input name="current_author_sess" type="hidden" value="' . htmlspecialchars(session_id()) . '"/> <input name="current_author_id" type="hidden" value="' . (int) $_SESSION[WW_SESS]['user_id'] . '"/> <span class="note"> <input type="button" name="preview" value="Preview" /> '; // only show draft option if article hasn't been published if (isset($_GET['article_id'])) { $form .= ' <input type="hidden" name="article_id" value="' . $_GET['article_id'] . '"/>'; } if ($article_data['status'] == 'D') { $form .= ' <input type="submit" name="draft" value="Save As Draft" /> <input type="submit" name="publish" value="Publish Article" />'; } else { $form .= ' <input type="submit" name="publish" value="Update Article" />'; } $form .= ' </span> </p> </form> </div>'; return $form; }