コード例 #1
0
 public static function DrawArticleList($mode = "htabs")
 {
     $stdout = "";
     self::initiateNewsClass();
     // -----------------------------------------------------------
     // -- Obtain existing code as initial data
     // -----------------------------------------------------------
     // --> $dataArticle[article_id] = article_record
     $dataArticle = $GLOBALS["newsClass"]->getArticle(NEWS_ANYUNPUBLISHED);
     // --> $dataArticleSorted[section_id] = array(int=>article_id)
     $dataArticleSorted = news::sortArticleList($dataArticle);
     // --> $sections[section_id] = section_label
     $sections = array();
     foreach ($GLOBALS["newsClass"]->getLookup("section") as $arr) {
         $sections[$arr["section_id"]] = $arr["section"];
     }
     // -----------------------------------------------------------
     if (empty($dataArticle)) {
         return functions::boxMessage("error", "There are currently no unpublished articles.", 1) . self::drawButtonYoufirstneedto("WRITE NEW ARTICLES", "edit_article/single");
     } else {
         $stdout .= "<p><span style='font-size:1.4em;font-weight:normal;padding-right:0.5em' " . "class='fake-contentheading red'>EITHER:</span> " . "<a href='" . str_replace("/index.php", "", $_SERVER["PHP_SELF"]) . "/single/index.php' " . "class='fakenewsbutton'" . ">WRITE NEW ARTICLES</a></p>\r\n" . PADDED_HR . "<h3 class='bottommargin'><span class='red'>OR:</span> EDIT ARTICLES THAT HAVE NOT YET BEEN PUBLISHED:</h3>\r\n" . "\r\n";
     }
     // -----------------------------------------------------------
     switch ($mode) {
         // -----------------------------------------------------------
         /* ACCORDION LIST -- didn't work very well
         
             $useaccordion = true;
             $brief = false;
         
             $stdout .= "<p>&nbsp;</p>\r\n";
         
             foreach ($dataArticleSorted as $section_id => $data) {
         
               $stdout .=
                 "<div class='newslist xcol left2of3'>\r\n" .
                 "  <h2>" . $sections[$section_id] . "</h2>\r\n" .
                 "  <div class='accordion'>\r\n" .
                 "\r\n";
         
               foreach ($data as $article_id) {
                 $stdout .=
                   //"    <legend>Article #" . $id . "</legend>\r\n" .
                   news::drawArticle($dataArticle[$article_id],$useaccordion,$brief) .
                   //"  </fieldset>\r\n" .
                   "";
               }
         
               $stdout .=
                 "  </div>\r\n" .
                 "</div>\r\n" .
                 "\r\n";
             }
         */
         // -----------------------------------------------------------
         case "htabs":
         case "vtabs":
             // -----------------------------------------------------------
             $useaccordion = false;
             $brief = true;
             $stdout .= "<div id='jtabs' class='" . ($mode == "htabs" ? "htabs" : "vtabs") . "'>\r\n" . "  <ul>\r\n";
             foreach ($dataArticleSorted as $section_id => $data) {
                 if (isset($sections[$section_id])) {
                     $stdout .= "    <li style='font-size:1.2em'><a href='" . $_SERVER["PHP_SELF"] . "#s" . $section_id . "'>" . $sections[$section_id] . "</a></li>\r\n";
                 }
             }
             $stdout .= (!empty($dataArticleSorted[NEWS_NOSECTION]) ? "    <li style='font-size:1.2em'><a href='" . $_SERVER["PHP_SELF"] . "#s0'>[Articles In No Section]</a></li>\r\n" : "") . "  </ul>\r\n" . "\r\n";
             foreach ($dataArticleSorted as $section_id => $data) {
                 $stdout .= "  <div id='s" . $section_id . "'>\r\n" . "\r\n";
                 //if ($mode=="vtabs") $stdout .= "    <h2>".$sections[$section_id]."</h2>\r\n\r\n";
                 $i = 0;
                 $count = ceil(count($data) / 2);
                 if ($mode == "htabs") {
                     $stdout .= "    <div class='col c1of2'>\r\n";
                 }
                 foreach ($data as $article_id) {
                     $stdout .= "      <fieldset style='border:1px solid #ccc'>\r\n" . "        <legend>Article #" . $article_id . " <span style='color:#ccc'>&mdash;</span> " . ($dataArticle[$article_id]["articlestatus_id"] ? " [<span class='green'>Ready to be published</span>]" : " [<span class='red'>Needs further editing</span>]") . "</legend>\r\n" . news::drawArticle($dataArticle[$article_id], $useaccordion, $brief) . "      <p style='text-align:right;margin-bottom:0'>" . "<a href='" . str_replace("/index.php", "", $_SERVER["PHP_SELF"]) . "/single/index.php?aid=" . $article_id . "' " . "class='fakenewsbutton'>EDIT THIS ARTICLE</a></p>\r\n" . "      </fieldset>\r\n" . "\r\n";
                     if ($mode == "htabs") {
                         $i++;
                         $stdout .= $i % 2 ? "    </div> <div class='col c2of2'>\r\n" : "    </div> <div class='col c1of2'>\r\n";
                     }
                 }
                 if ($mode == "htabs") {
                     $stdout .= "    </div><div style='clear:both'><br></div>\r\n";
                 }
                 $stdout .= "  </div>\r\n" . "\r\n";
             }
             $stdout .= "</div>\r\n" . "\r\n";
             break;
             // -----------------------------------------------------------
         // -----------------------------------------------------------
         case "full":
             // -----------------------------------------------------------
             $useaccordion = false;
             $brief = false;
             $stdout .= "<p>&nbsp;</p>\r\n";
             foreach ($dataArticle as $id => $data) {
                 $stdout .= "<div class='newslist col left2of3'>\r\n" . "  <fieldset style='width:105%;border:1px solid #ccc'>\r\n" . "    <legend>Article #" . $id . "</legend>\r\n" . news::drawArticle($data, $useaccordion, $brief) . "  </fieldset>\r\n" . "</div> <div class='col-content-right1third'>\r\n" . "\r\n";
                 $stdout .= "<p><a href='" . str_replace("/index.php", "", $_SERVER["PHP_SELF"]) . "/single/index.php?aid=" . $id . "' " . "class='fakenewsbutton'>EDIT THIS ARTICLE</a></p>\r\n";
                 if (isset($data["section"])) {
                     $stdout .= "<p>Currently assigned to the section ";
                     if (is_array($data["section"])) {
                         $stdout .= " <strong class='nowrap'>&quot;" . implode("&quot;, &quot;", $data["section"]) . "&quot;</strong> ";
                     } else {
                         $stdout .= " " . $data["section"] . " ";
                     }
                     $stdout .= "</p>\r\n";
                 }
                 $stdout .= "\r\n";
                 $stdout .= "</div><div style='clear:both'><br></div>\r\n";
             }
             // end foreach
             //$stdout .= "    </div>\r\n";
             break;
             // -----------------------------------------------------------
     }
     // end swtich
     return $stdout;
 }