$deftarget = "_self"; $cksectionclass_version = 6.1; // Rev 3 - last modified 7/8/99 // Rev 4 - last modified 8/9/99 // (added header and footer capability to show catalog) // Rev 5 // (changed show tree - significantly) // Rev 5.1 // shut off log_view // Rev 5.2 // added display_catalog success count variables // rev 5.3 // enhanced 404 capabilities // ref 5.4 // added create_href function // 5.5 // given to town of orleans // added def target // 6.1 - added debug arg to display_catalog /* Useful SimpleSection Methods: create_link([$documentnumber], [$UID], [$SID], [$target_attribute], [$javascript_attribute], [$CDATA]) returns A HREF tag dump_params([$in_a_comment_or_not]) returns data dump find_icon([$icon_file], [$image_attributes]) returns its own icon or not, any image or not if sent first argument */ /* Useful SiteSection methods display_catalog([$starting_item], [$table_array], [$order_by_array]) finds the display modules and prints catalog listings to STDOUT display_portfolio($item_number, [$previous_itemID], [$next_itemID], [$debug], [$item_table], [$item_cktype], [$item_order_by_clause]) finds the item, the display module and prints item to STDOUT show_thread(&$array_of_sections, [$docID], [$spanclass = "SHOWTHREAD"], [$separator = " : "], [$target], [$js]) returns horizontal list of current hierarchy */ class SimpleSection { // for Sections that are not the current section. var $CType = "SiteSection"; var $ID; var $Name; var $Parent; var $Siblings = array(); var $Children = array(); var $ChildCount = 0; var $FirstBorn = ""; var $params = array(); var $ImageRoot = ""; var $Thread = array(); var $OrderKey = ""; var $Buggin = ""; var $Bugs = 0; var $Seen = 0; var $SID = ""; var $UID = ""; var $DataLink; var $Item = 0; var $HREF = ""; function SimpleSection($parameters, $cnx, $itemID = 0, $SID = "", $UID = "") { global $user, $session, $deftarget; if (! $SID) { $SID = $session; } if (! $UID) { $UID = $session; } if (is_array($parameters)) { $this->params = $parameters; if ($parameters[ID]) { $this->ID = $parameters[ID]; } if ($parameters[Name]) { $this->Name = $parameters[Name]; } if ($parameters[PriorityIndex]) { $orderkey = $parameters[PriorityIndex] . "_" . $this->ID; } else { $orderkey = $parameters[Name] . "_" . $this->ID; } $this->DataLink = $cnx; $this->Item = $itemID; $this->SID = $SID; $this->UID = $UID; $this->OrderKey = $orderkey; $this->Siblings[$orderkey] = $this->ID; // i am my own sibling... if (! $this->params[Target]) { $this->params[Target] = $deftarget; } } else { $this->find_bug("parameters sent to contructer were not in an array\n"); } } function simple_link($divclass = "VTHERE1") { global $deftarget; $op = ""; if (ereg("[A-Za-z]+", $this->params[IconCode])) { $op .= $this->params[IconCode]; } else { $myIcon = ""; if ($useIcon > 0) { $myIcon = $this->find_icon(); } if ($myIcon) { $op .= $myIcon; } else { if ($this->params[Target]) { $tg = $this->params[Target]; } else { $tg = $deftarget; } $op .= "
$op"; } } function find_icon($icon_file = "", $atts = "") { if ($icon_file == "") { $icon_file = $this->params[IconFile]; } if (! $icon_file) { return ""; } if (! ereg("(jpe*g|gif)$", $icon_file)) { return ""; // not the right type } if (ereg("^https*//", $icon_file)) { // who knows how big it is? return ""; } if (! file_exists($icon_file)) { // it probably won't.... so do this $icon_path = $this->ImageRoot; if ((! ereg("/$", $icon_path)) and (ereg("^/", $icon_file))) { $icon_path .= "/"; } $icon_path .= $icon_file; if (! file_exists($icon_path)) { // O.K., give up. $this->find_bug("couldn't find $icon_path OR $icon_file"); return ""; } } else { $icon_path = $icon_file; } // can we do it now? I think so. $sz = GetImageSize($icon_path); return ""; } } class SiteSection extends SimpleSection { var $CType = "SiteSection"; var $Content = array(); var $DataLink; var $Modules = array(); /* var $SQLStatelets = array( 1 => array( "SECTIONKEY" => "IsInventorySection", "FIELDS" => "*", "TABLES" => "Inventory", // "CONDITIONS" => "SectionID=" . $area, "ORDER" => "Price DESC", "HEADERFILE" => "mods/header_inv.php3", "FOOTERFILE" => "mods/footer_inv.php3" ), 2 => array( "SECTIONKEY" => "IsDocSection", "FIELDS" => "*", "TABLES" => "Docs", "CONDITIONS" => "SectionID=$area AND (Expires > NOW() OR Expires IS NULL)", "ORDER" => "Created DESC", "HEADERFILE" => "mods/header_doc.php3", "FOOTERFILE" => "mods/footer_doc.php3" ), 3 => array( "SECTIONKEY" => "IsLinkSection", "FIELDS" => "*", "TABLES" => "Links", "CONDITIONS" => "SectionID=$area AND (Expires > NOW() OR Expires IS NULL)", "ORDER" => "PriorityIndex", "HEADERFILE" => "mods/header_link.php3", "FOOTERFILE" => "mods/footer_link.php3" ), 4 => array( "SECTIONKEY" => "IsEventSection", "FIELDS" => "*", "TABLES" => "Events", "CONDITIONS" => "SectionID=$area AND ((EndDate <= NOW() AND EndTime <= NOW()) OR (EndDate IS NULL AND EndTime <= NOW()) OR (EndTime IS NULL AND EndDate <= NOW()) OR (Weekly > 0))", "ORDER" => "BeginDate, EndDate", "HEADERFILE" => "mods/header_event.php3", "FOOTERFILE" => "mods/footer_event.php3" ), 5 => array( "SECTIONKEY" => "HasChildren", "FIELDS" => "*", "TABLES" => "Sections", "CONDITIONS" => "ParentID=$area AND Visible='Y'", "ORDER" => "PriorityIndex", "HEADERFILE" => "mods/header_index.php3", "FOOTERFILE" => "mods/footer_index.php3" ) ); */ function SiteSection($parameters, $cnx, $itemID = 0, $SID = "", $UID = "", $prvitem = 0, $nxtitem = 0) { if (is_array($parameters)) { $this->params = $parameters; if ($parameters[ID]) { $this->ID = $parameters[ID]; } if ($parameters[Name]) { $this->Name = $parameters[Name]; } if ($parameters[PriorityIndex]) { $orderkey = $parameters[PriorityIndex] . "_" . $this->ID; } else { $orderkey = $parameters[Name] . "_" . $this->ID; } $this->DataLink = $cnx; $this->Item = $itemID; $this->SID = $SID; $this->UID = $UID; $this->OrderKey = $orderkey; $this->Siblings[$orderkey] = $this->ID; // i am my own sibling... } else { $this->find_bug("parameters sent to contructer were not in an array\n"); } } function display_catalog($SQLArray, $pre_item = 0, $use_debug = 0) { global $here, $area; // lets just shoot straight from the Database this time $paginate = 0; // if itemcount > ItemsPerPage set this to 1 $area = $this->params[ID]; if ((! is_array($SQLArray)) or (count($SQLArray) == 0)) { $SQLArray = $this->SQLStatelets; } // 5.3 - moved this out of loop below $itemcount = 0; // make sure we don't dump more items than ItemsPerPage wants for($i = 1; $i <= count($SQLArray); $i++) { $v = $SQLArray[$i]; $previtem = 0; if ($this->params[$v[SECTIONKEY]] == "Y") { // 5.2: create variable to Count Successes $newvar = $v[SECTIONKEY] . "Count"; $$newvar = 0; // make statement $st = "SELECT " . $v[FIELDS] . " FROM " . $v[TABLES] . "\n\t"; if ($v[CONDITIONS]) { $st .= "WHERE " . $v[CONDITIONS] . "\n\t"; } if ($v[ORDER]) { $st .= "ORDER BY " . $v[ORDER] . "\n"; } if ($use_debug) { echo ""; } $res = mysql_query($st, $this->DataLink); if ($res) { if ($use_debug) { echo ""; } if (mysql_num_rows($res) > 0) { $$newvar = mysql_num_rows($res); if ($use_debug) { echo ""; } if (($v[HEADERFILE] != "") and (file_exists($v[HEADERFILE]))) { include($v[HEADERFILE]); } else { if ($use_debug) { echo ""; } } } else { if ($use_debug) { echo ""; } } while($row = mysql_fetch_array($res)) { $itemcount++; $row[QueryUsed] = $st; $item = new ContentItem($this, $row, $v[ORDER]); if (is_object($previtem)) { $item->BeforeMe = $previtem->params[ID]; $previtem->AfterMe = $item->params[ID]; $previtem->create_link_tags(); $this->display_catalog_item($previtem->params, $v[TABLES]); unset($previtem); } $previtem = $item; // if ($this->params[ItemsPerPage]) { // if ($itemcount > $this->params[ItemsPerPage]) { // $paginate = 1; // if ($use_debug) { // echo ""; // } // break; // } // } } if ((is_object($previtem)) and ($paginate == 0)) { $previtem->create_link_tags(); $this->display_catalog_item($previtem->params, $v[TABLES], $use_debug); unset($previtem); } if ($itemcount > 0) { if (($v[FOOTERFILE] != "") and (file_exists($v[FOOTERFILE]))) { include($v[FOOTERFILE]); } else { if ($use_debug) { echo ""; } } } } else { if ($use_debug) { echo ""; } } } else { if ($use_debug) { echo ""; } } } } function display_catalog_item($c_item, $itstable, $use_debug = 0) { global $itemparams; if ((! is_object($c_item)) and (! is_array($c_item))) { echo ""; return 0; } if (is_object($c_item)) { if (! $c_item->params[PortfolioURL]) { echo ""; } $itemparams = $c_item->params; } else { $itemparams = $c_item; } if ($itemparams[CatalogModuleID]) { $mod = $this->page_module($itemparams[CatalogModuleID]); if ($mod[FileName]) { if ($this->DataLink) { if (! $itemparams[Name]) { $itemparams[Name] = $itemparams[Title]; } } include($mod[FileName]); return 1; } else { if ($use_debug) { echo ""; } } } else { if ($use_debug) { echo ""; } } } function display_portfolio($item_num, $SQLArray, $item_typeID, $pre_item = 0, $nxt_item = 0, $debug = 0) { if (! is_array($SQLArray)) { // is it a statement? if (strtolower(substr($SQLArray, 6)) == "select") { $st = $SQLArray; $sortables = eregi_replace("^.+ORDER BY ", "", $st); } else { $SQLArray = $this->SQLStatelets; } } elseif (count($SQLArray) == 0) { $SQLArray = $this->SQLStatelets; } if (! $st) { $v = $SQLArray[$item_typeID]; echo ""; $sortables = $v[ORDER]; $st = "SELECT " . $v[FIELDS] . " FROM " . $v[TABLES] . "\n\t"; if ($v[CONDITIONS]) { $st .= "WHERE " . $v[CONDITIONS] . "\n\t"; } if ($v[ORDER]) { $st .= "ORDER BY " . $v[ORDER] . "\n"; } } $res = mysql_query($st, $this->DataLink); if (($res) and (mysql_num_rows($res))) { $gotitem = 0; $lastitem = array(); while($row = mysql_fetch_array($res)) { if ($row[ID] == $pre_item) { $p_item = new ContentItem($this, $row, $sortables); $p_item->AfterMe = $item_num; $p_item->BeforeMe = $lastitem[ID]; $gotprv = 1; } elseif ($row[ID] == $nxt_item) { $n_item = new ContentItem($this, $row, $sortables); $n_item->BeforeMe = $item_num; if ($gotitem) { $c_item->AfterMe = $row[ID]; $final = mysql_fetch_array($res); $n_item->AfterMe = $final[ID]; break; } } elseif ($row[ID] == $item_num) { $c_item = new ContentItem($this, $row, $sortables); $c_item->BeforeMe = $lastitem; $gotitem = 1; if (! $pre_item) { $p_item = new ContentItem($this, $lastitem, $sortables); $c_item->BeforeMe = $lastitem[ID]; } if (! $nxt_item) { $final = mysql_fetch_array($res); if ($final) { $n_item = new ContentItem($this, $final, $sortables); $c_item->AfterMe = $final[ID]; } break; } } $lastitem = $row; } mysql_free_result($res); if (($c_item) and ($p_item)) { if ($p_item->params[ID]) { $p_item->create_link_tags("Previous: " . $p_item->params[Name]); $c_item->params[PrvTextLink] = $p_item->params[TextLink]; $c_item->params[PrvThumbnailLink] = $p_item->params[ThumbnailLink]; $c_item->params[PRV] = $p_item->params[ID]; } } if (($c_item) and ($n_item)) { if ($n_item->params[ID]) { $n_item->create_link_tags("Next: " . $n_item->params[Name]); $c_item->params[NxtTextLink] = $n_item->params[TextLink]; $c_item->params[NxtThumbnailLink] = $n_item->params[ThumbnailLink]; $c_item->params[NXT] = $n_item->params[ID]; } } } else { if (file_exists("mods/404.php3")) { include("mods/404.php3"); echo "\n\n"; } else { echo ""; echo "