view compos.inc.php @ 160:0980e705dea0

Add some copyright headers.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 27 Oct 2013 03:05:49 +0200
parents 5bc8bd5c7ecc
children 1e4f530c8310
line wrap: on
line source

<?
//
// FAPWeb Simple Demoparty System
// Competitions page
// (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
//
echo stGetSetting("compoDescription");

function stConvSwitchMode(&$str, &$mode, $newMode)
{
  if ($newMode != $mode)
  {
    if ($mode != "")
      $str .= "\n</".$mode.">\n";

    $mode = $newMode;

    if ($mode != "")
      $str .= "<".$mode.">\n";
  }
}


function stConvertCompoDesc($desc)
{
  global $stDescConversion;
  $str = "";
  $mode = "";

  foreach (explode("\n", $desc) as $line)
  {
    if (preg_match("/^\s*\s*\*(.+)$/", $line, $m))
    {
      stConvSwitchMode($str, $mode, "ol");
      $str .= "<li>".$m[1]."</li>\n";
    }
    else
    if (preg_match("/^\s*-\s*(.+)$/", $line, $m))
    {
      stConvSwitchMode($str, $mode, "ul");
      $str .= "<li>".$m[1]."</li>\n";
    }
    else
    {
      stConvSwitchMode($str, $mode, "p");
      $str .= $line;
    }
  }

  stConvSwitchMode($str, $mode, "");

  return $str;
}

$sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY id ASC";

if (($res = stExecSQL($sql)) !== FALSE)
{
  foreach ($res as $item)
  {
    echo
    "<div id=\"compo".$item["id"]."\">\n".
    "<h2>".chentities($item["name"])."</h2>\n".
    stConvertCompoDesc($item["description"]).
    "</div>\n";
  }
}
?>