OpenTable() And CloseTable() Functions? Help Someone?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   OpenTable() And CloseTable() Functions? Help Someone?
Pheonix
CZ Newbie
Pheonix has been a member for over 20 year's 20 Year Member
Gender: Male
Status: Offline
Joined: Apr 13, 2004
0.00 posts per day
Posts: 24
Points: 1,643
   
ok heres my code and i need help with something... cause basically right now I have it so that the theme open and close functions wrap around the whole thing, hence the border in my theme.php now i would also like that border to wrap around each individual area of the content module for users: Page Text, Footer Text, Header Text, Title, Subtitle you get the point heh. Ive tried putting the open and close functions in but i always get an error. if you could please paste solutions or at least one example of how to do it id greatly appreciate it. also if you have time a simple question about adding <font class=\"...\">$pagetitle</font> tags around the data to spice stuff up a bit... can i simply parse properly and put the tags around? or do i have to do it another way?

heres the code:

<?php
// ----------------------------------------------------------------------
// CROSSNUKE - ENHANCED PHPNUKE
// ----------------------------------------------------------------------
//
// Copyright (c) 2002 by Jata (lophas@yahoo.com)
// http://www.crossnuke.com
//
// MODULE NAME: Content
// CROSSNUKE VERSION: 5.53
// PHPNUKE VERSION: 5.5
//
// New feature:
//  - Unlimited subcategory depth
//

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi (fbc@mandrakesoft.com)         */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (!eregi("modules.php", $PHP_SELF)) {
    die ("You can't access this file directly...");
}

require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
if(!isset($pntable[pages])) $pntable[pages]=$prefix."_pages";
if(!function_exists("evaldef")) include("modules/$module_name/includes/evaldef.php");
$index = 1; //or 1 if you like
function showpage($pid, $page=0) {
    global $pntable, $dbi, $sitename, $admin, $module_name;
    include("header.php");
    OpenTable();
    $result = sql_query("SELECT * from $pntable[pages] where pid='$pid'", $dbi);
    $mypage = sql_fetch_array($result, $dbi);
    if (($mypage[active] == 0) AND (!is_admin($admin))) {
   echo "Sorry... This page doesn't exist.";
    } else {
   sql_query("update $pntable[pages] set counter=counter+1 where pid='$pid'", $dbi);
   $date = explode(" ", $mypage[date]);
   echo "<font class=\"title\">$mypage[title]</font><br>"
       ."<font class=\"content\">$mypage[subtitle]<br><br><br><br>";
$mypage[text]=testdoc($mypage[text]);
   $contentpages = explode( "<!--pagebreak-->", $mypage[text] );
   $pageno = count($contentpages);
   if ( $page=="" || $page < 1 )
       $page = 1;
   if ( $page > $pageno )
       $page = $pageno;
   $arrayelement = (int)$page;
   $arrayelement --;
   if ($pageno > 1) {
       echo ""._PAGE.": $page/$pageno<br>";
   }
   if ($page == 1) {
       echo "<p align=\"justify\">".nl2br($mypage[page_header])."</p><br>";
   }
   echo "<p align=\"justify\">$contentpages[$arrayelement]</p>";
   if($page >= $pageno) {
       $next_page = "";
   } else {
       $next_pagenumber = $page + 1;
       if ($page != 1) {
      $next_page .= "- ";
       }
       $next_page .= "<a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$next_pagenumber\"><img src=\"images/download/right.gif\" border=\"0\" alt=\""._NEXT."\"></a>";
   }
   if ($page == $pageno) {
       echo "<br><p align=\"justify\">".nl2br($mypage[page_footer])."</p><br><br>";
   }
   if($page <= 1) {
       $previous_page = "";
   } else {
       $previous_pagenumber = $page - 1;
       $previous_page = "<a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$previous_pagenumber\"><img src=\"images/download/left.gif\" border=\"0\" alt=\""._PREVIOUS."\"></a> <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
   }
   echo "<br><br><br><center>$previous_page $next_page</center><br><br>";
   if ($page == $pageno) {
       echo "<p align=\"right\">".nl2br($mypage[signature])."</p>"
      ."<p align=\"right\">"._COPYRIGHT."</p><br><br></font>"
      ."<p align=\"right\"><font class=\"tiny\">"._PUBLISHEDON.": $date[0] ($mypage[counter] "._READS.")</font></p>"
      ."<center>"._GOBACK."</center>";
   }
    }
    CloseTable();
    include("footer.php");
}

function list_pages($parent_id=0) {
    global $pntable, $dbi, $sitename, $admin, $multilingual, $module_name;
    include("header.php");
    title("$sitename: "._PAGESLIST."");
    OpenTable();
    echo "<center><font class=\"content\">"._LISTOFCONTENT." $sitename:</center><br><br>";
#    $result = sql_query("select * from $pntable[pages]_categories where parent_id='$parent_id'", $dbi);
#    if (sql_num_rows($result, $dbi) > 0 AND sql_num_rows(sql_query("select * from $pntable[pages] WHERE cid!='0'", $dbi),$dbi) > 0) {
#   echo "<center>"._CONTENTCATEGORIES."</center><br><br>"
#           ."<table border=\"1\" align=\"center\" width=\"95%\">";
#   while(list($cid, $title, $description) = sql_fetch_row($result, $dbi)) {
#       if (sql_num_rows(sql_query("select * from $pntable[pages] WHERE cid='$cid'", $dbi),$dbi) > 0) {
#      echo "<tr><td valign=\"top\">&nbsp;<a href=\"modules.php?name=$module_name&amp;pa=list_pages_categories&amp;cid=$cid\">$title</a>&nbsp;</td><td align=\"left\">$description</td></tr>";
#       }
#   }
#   echo "</td></tr></table><br><br>"
list_pages_subcats(0);
echo ""
       ."<center>"._NONCLASSCONT."</center><br><br>";
#    }
    $result = sql_query("SELECT pid, title, subtitle, clanguage from $pntable[pages] WHERE active='1' AND cid='0' order by date", $dbi);
    echo "<blockquote>";
    while(list($pid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
   if ($multilingual == 1) {
       $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
   } else {
       $the_lang = "";
   }
        if ($subtitle != "") {
       $subtitle = " ($subtitle)";
   } else {
           $subtitle = "";
   }
   if (is_admin($admin)) {
       echo "<strong><big>&middot;</big></strong> $the_lang <a href=\"modules.php?name=$module_name&amp;pa=showpage&amp;pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=1\">"._DEACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
   } else {
       echo "<strong><big>&middot;</big></strong> $the_lang <a href=\"modules.php?name=$module_name&amp;pa=showpage&amp;pid=$pid\">$title</a> $subtitle<br>";
   }
    }
    echo "</blockquote>";
    if (is_admin($admin)) {
#   $result = sql_query("SELECT pid, cid, title, subtitle, clanguage from $pntable[pages] WHERE active='0' order by date", $dbi);
#   echo "<br><br><center><b>"._YOURADMINLIST."</b></center><br><br>";
#   echo "<blockquote>";
#   while(list($pid, $cid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
#       if ($multilingual == 1) {
#      $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
#       } else {
#      $the_lang = "";
#       }
#           if ($subtitle != "") {
#           $subtitle = " ($subtitle) ";
#       } else {
#               $subtitle = " ";
#       }
#       echo "<strong><big>&middot;</big></strong> $the_lang <a href=\"modules.php?name=$module_name&amp;pa=showpage&amp;pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=0\">"._ACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
#   }
#   echo "</blockquote>";
list_pages_inactive();
    }
    CloseTable();
    include("footer.php");
}

function list_pages_categories($cid) {
    global $pntable, $dbi, $sitename, $admin, $multilingual, $module_name;
    include("header.php");
    title("$sitename: "._PAGESLIST."");
    OpenTable();

list_pages_subcats($cid);

    echo "<center><font class=\"content\">"._LISTOFCONTENT." $sitename:</center><br><br>";
    $result = sql_query("SELECT pid, title, subtitle, clanguage from $pntable[pages] WHERE active='1' AND cid='$cid' order by date", $dbi);
    echo "<blockquote>";
    while(list($pid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
   if ($multilingual == 1) {
       $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
   } else {
       $the_lang = "";
   }
        if ($subtitle != "") {
       $subtitle = " ($subtitle)";
   } else {
           $subtitle = "";
   }
   if (is_admin($admin)) {
       echo "<strong><big>&middot;</big></strong> $the_lang <a href=\"modules.php?name=$module_name&amp;pa=showpage&amp;pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=1\">"._DEACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
   } else {
       echo "<strong><big>&middot;</big></strong> $the_lang <a href=\"modules.php?name=$module_name&amp;pa=showpage&amp;pid=$pid\">$title</a> $subtitle<br>";
   }
    }
    echo "</blockquote>";
    if (is_admin($admin)) {
#   $result = sql_query("SELECT pid, title, subtitle, clanguage from $pntable[pages] WHERE active='0' and cid='$cid' order by date", $dbi);
#   echo "<br><br><center><b>"._YOURADMINLIST."</b></center><br><br>";
#   echo "<blockquote>";
#   while(list($pid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
#       if ($multilingual == 1) {
#      $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
#       } else {
#      $the_lang = "";
#       }
#           if ($subtitle != "") {
#           $subtitle = " ($subtitle) ";
#       } else {
#               $subtitle = " ";
#       }
#       echo "<strong><big>&middot;</big></strong> $the_lang <a href=\"modules.php?name=$module_name&amp;pa=showpage&amp;pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=0\">"._ACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
#   }
#   echo "</blockquote>";
list_pages_inactive($cid);
    }
    echo "<center>"._GOBACK."</center>";
    CloseTable();
    include("footer.php");
}
##############################################
function get_content_cattitle($cid) {
    global $pntable, $dbi, $module_name;
   if($cattitle!="") $cattitle="/".$cattitle;
   $res = sql_query("select title, parent_id from $pntable[pages]_categories where cid='$cid'", $dbi);
   list($cat_title, $parent_id) = sql_fetch_row($res, $dbi);
   if($parent_id) $cat_title=get_content_cattitle($parent_id)."/<a href=\"modules.php?name=$module_name&amp;pa=list_pages_categories&amp;cid=$cid\">$cat_title</a>";
   else $cat_title="<a href=\"modules.php?name=$module_name&amp;pa=list_pages_categories&amp;cid=$cid\">$cat_title</a>";
   return $cat_title;
}

function list_pages_inactive($cid=0)
{
    global $pntable, $dbi, $sitename, $admin, $multilingual, $module_name;
   $result = sql_query("SELECT pid, cid, title, subtitle, clanguage from $pntable[pages] WHERE active='0' and cid='$cid' order by date", $dbi);
if(sql_num_rows($result))
   {
   echo "<br><br><center><b>"._YOURADMINLIST."</b></center><br><br>";
   echo "<blockquote>";
   while(list($pid, $cid, $title, $subtitle, $clanguage) = sql_fetch_row($result, $dbi)) {
       if ($multilingual == 1) {
      $the_lang = "<img src=\"images/language/flag-$clanguage.png\" hspace=\"3\" border=\"0\" height=\"10\" width=\"20\">";
       } else {
      $the_lang = "";
       }
           if ($subtitle != "") {
           $subtitle = " ($subtitle) ";
       } else {
               $subtitle = " ";
       }
       echo "<strong><big>&middot;</big></strong> $the_lang <a href=\"modules.php?name=$module_name&amp;pa=showpage&amp;pid=$pid\">$title</a> $subtitle [ <a href=\"admin.php?op=content_edit&pid=$pid\">"._EDIT."</a> | <a href=\"admin.php?op=content_change_status&pid=$pid&active=0\">"._ACTIVATE."</a> | <a href=\"admin.php?op=content_delete&pid=$pid\">"._DELETE."</a> ]<br>";
   }
   echo "</blockquote>";
   }
}

function list_pages_subcats($parent_id=0)
{
    global $pntable, $dbi, $module_name;
$result = sql_query("select cid, title, description from $pntable[pages]_categories where parent_id='$parent_id'", $dbi);
    if (sql_num_rows($result, $dbi) > 0)
    {
#    list($cat_title) = sql_fetch_row(sql_query("select title from $pntable[pages]_categories where cid='$parent_id'", $dbi), $dbi);
   echo "<center>"._CONTENTCATEGORIES;
#   echo "&nbsp;&nbsp;<a href=\"modules.php?name=$module_name&amp;pa=list_pages_categories&amp;cid=$parent_id\">$cat_title</a>";
   echo "</center><br><br>"
           ."<table border=\"1\" align=\"center\" width=\"95%\">";
   while(list($cid, $title, $description) = sql_fetch_row($result, $dbi))
   {
     if(sql_num_rows(sql_query("select * from $pntable[pages] WHERE cid='$cid'", $dbi),$dbi) > 0
        or sql_num_rows(sql_query("select * from $pntable[pages]_categories where parent_id='$cid'", $dbi),$dbi) > 0)
        {
$title=get_content_cattitle($cid);
      echo "<tr><td valign=\"top\">&nbsp;$title&nbsp;</td><td align=\"left\">$description</td></tr>";
       }
   }
   echo "</td></tr></table><br><br>";
     }
}

function doc2html($filnam)
{
$arrTr = array(
"\xC3\xA1" => "á",
"\xC3\xA9" => "é",
"\xC3\xAD" => "í",
"\xC3\xB3" => "ó",
"\xC3\xB6" => "ö",
"\xC5\x91" => "õ",
"\xC3\xBA" => "ú",
"\xC3\xBC" => "ü",
"\xC5\xB1" => "û",
"\xC3\x81" => "Á",
"\xC3\x89" => "É",
"\xC3\x8D" => "Í",
"\xC3\x93" => "Ó",
"\xC3\x96" => "Ö",
"\xC5\x90" => "Õ",
"\xC3\x9A" => "Ú",
"\xC3\x9C" => "Ü",
"\xC5\xB0" => "Û"
);

if($str=`wvHtml $filnam /dev/stdout`) return (strtr($str,$arrTr));
else return $filnam;
}

function testdoc($content)
{
if(@file_exists("doc/$content")) $content=doc2html("doc/$content");
elseif(substr(strtolower($content),0,7)=="http://") $content=`wget -o/dev/null -O'-' -v -UMozilla/4.73 --timeout=20 "$content"`;
return evaldef($content);
}

##############################################
switch($pa) {

    case "showpage":
    showpage($pid, $page);
    break;
   
    case "list_pages_categories":
    list_pages_categories($cid);
    break;
   
    default:
    list_pages();
    break;

}

?>



Back to top Reply with quote
#2   re: OpenTable() And CloseTable() Functions? Help Someone?
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
Opentable();
echo "Hello world";
Closetable();



Opentable2();
scho "Hello world";
Closetable2();


What errors do you get?

<font class=\"title\">$title</font>



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   re: OpenTable() And CloseTable() Functions? Help Someone?
Pheonix
CZ Newbie
Pheonix has been a member for over 20 year's 20 Year Member
Gender: Male
Status: Offline
Joined: Apr 13, 2004
0.00 posts per day
Posts: 24
Points: 1,643
   
so your saying i have to do OpenTable2() CloseTable2() and then OpenTable3() CloseTable3() and OpenTable4() CloseTable4() etc etc?

i will bold the table functions in the following code that i have added. please correct the syntax icon_smile.gif oh and as far as I know i only have "OpenTable() and CloseTable()" defined in my theme.php does that mean i have to add a #2, #3 etc when all i want is the same border but repeated around different sections? thx in advance.




function showpage($pid, $page=0) {
global $pntable, $dbi, $sitename, $admin, $module_name;
include("header.php");
OpenTable();
$result = sql_query("SELECT * from $pntable[pages] where pid='$pid'", $dbi);
$mypage = sql_fetch_array($result, $dbi);
if (($mypage[active] == 0) AND (!is_admin($admin))) {
echo "Sorry... This page doesn't exist.";
} else {
sql_query("update $pntable[pages] set counter=counter+1 where pid='$pid'", $dbi);
$date = explode(" ", $mypage[date]);
echo "<font class=\"title\">OpenTable()$mypage[title]CloseTable()</font><br>"
."<font class=\"content\">OpenTable()$mypage[subtitle]CloseTable()<br><br><br><br>";
$mypage[text]=testdoc($mypage[text]);
$contentpages = explode( "<!--pagebreak-->", $mypage[text] );
$pageno = count($contentpages);
if ( $page=="" || $page < 1 )
$page = 1;
if ( $page > $pageno )
$page = $pageno;
$arrayelement = (int)$page;
$arrayelement --;
if ($pageno > 1) {
echo ""._PAGE.": $page/$pageno<br>";
}
if ($page == 1) {
echo "OpenTable()<p align=\"justify\">".nl2br($mypage[page_header])."</p>CloseTable()<br>";
}
echo "OpenTable()<p align=\"justify\">$contentpages[$arrayelement]</p>CloseTable()";
if($page >= $pageno) {
$next_page = "";
} else {
$next_pagenumber = $page + 1;
if ($page != 1) {
$next_page .= "- ";
}
$next_page .= "<a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$next_pagenumber\"><img src=\"images/download/right.gif\" border=\"0\" alt=\""._NEXT."\"></a>";
}
if ($page == $pageno) {
echo "<br>OpenTable()<p align=\"justify\">".nl2br($mypage[page_footer])."</p>CloseTable()<br><br>";
}
if($page <= 1) {
$previous_page = "";
} else {
$previous_pagenumber = $page - 1;
$previous_page = "<a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$previous_pagenumber\"><img src=\"images/download/left.gif\" border=\"0\" alt=\""._PREVIOUS."\"></a> <a href=\"modules.php?name=$module_name&pa=showpage&pid=$pid&page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
}
echo "<br><br><br><center>$previous_page $next_page</center><br><br>";
if ($page == $pageno) {
echo "OpenTable()<p align=\"right\">".nl2br($mypage[signature])."</p>CloseTable()"
."<p align=\"right\">"._COPYRIGHT."</p><br><br></font>"
."<p align=\"right\"><font class=\"tiny\">"._PUBLISHEDON.": $date[0] ($mypage[counter] "._READS.")</font></p>"
."<center>"._GOBACK."</center>";
}
}
CloseTable();
include("footer.php");
}





Back to top Reply with quote
#4   re: OpenTable() And CloseTable() Functions? Help Someone?
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
No i was showing you the functions most themes come with two open tables opentable(); and opentable2(); open table2 is usually used inside of opentable(); because it doesnt set the width. The reason your getting errors is because your PHP is inside your html. Try setting it up like this:

This is a chunk of your code from above
sql_query("update $pntable[pages] set counter=counter+1 where pid='$pid'", $dbi);
$date = explode(" ", $mypage[date]);
Opentable();
echo "<font class=\"title\">$mypage[title]</font><br>";
Closetable();
Opentable();
echo "<font class=\"content\">$mypage[subtitle]<br><br><br><br>";
Closetable();
$mypage[text]=testdoc($mypage[text]);
$contentpages = explode( "<!--pagebreak-->", $mypage[text] );




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum