Revision [693]

This is an old revision of GmBowen made by GmBowen on 2004-07-01 04:17:50.

 

I'm a university prof who is modifying parts of wikka so that it can be used by high school kids to collaborate on school project work and writing. I chose wakka/wikka because it seemed to be the wiki with the most flexibility for doing the sorts of things I was interested in. I'm not a programmer myself, although I do understand lots about programming, and so I've hired a recent grad from my university to implement some features for me that I think my target audience for using the wiki will need. The wiki is only one of the central tools they'll be using, and has to coordinate with numerous other tools (such as a graph drawing and an on-line drawing tool).

My programming guy (Mark Kasper) has completed a modification of the pageindex.php code that should make it more useable for high-use wakka/wikka sites (such as can now be seen at the original wakka site). It can either be used as usual, {{pageindex}}, or using a parameter indicating which letter you would like to see a listing for (for example, {{pageindex start="a"}}...or whatever letter you wish to show a listing for). If you enter a letter that there is not yet a listing for, then it defaults to "all".

<?php /*dotmg modifications : contact m.randimbisoa@dotmg.net*/ ?>
<?php
$a = array(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z);
$start = strtoupper($start);

if ($pages = $this->LoadAllPages())
{	
	 $link = $this->config["base_url"].$this->MiniHref($method, $tag);
	 print("<strong><a href='$link&var=ALL'>ALL</a> &nbsp;</strong> \n"); 
	  
	 foreach ($pages as $page){
		 if (!preg_match("/^Comment[0-9]+$/", $page["tag"])) {
			$firstChar = strtoupper($page["tag"][0]);
			if (!preg_match("/[A-Z,a-z]/", $firstChar)) {
				$firstChar = "#";
			}

			if ($firstChar != $curChar) {
				if ($curChar) print("\n");
				   	print("<strong><a href='$link&var=$firstChar'>$firstChar</a>&nbsp;</strong> \n");
				$curChar = $firstChar;
			}
		}
	}
	print("<br><br>");
	$curChar = "";
	
	foreach ($pages as $page)
	{
	  
		//#dotmg [1 line modified]: added [0-9]+$ to regular expression
		if (!preg_match("/^Comment[0-9]+$/", $page["tag"])) {
			$firstChar = strtoupper($page["tag"][0]);
			
					$st = htmlspecialchars(urldecode($_GET['var']));
			
		  if($st == ''){	
			if($start == 'ALL')
			{$st='';}
			elseif($start != '')
			{
			   for($i=0; $i<27; $i++)
			   {
				 if($start == $a[$i])
				 { 
				   $st = $a[$i];
				 }
			   }			
			}
		  }
						
		 if($firstChar == $st)
		 {	
			if (!preg_match("/[A-Z,a-z]/", $firstChar)) {
				$firstChar = "#";
			}

			if ($firstChar != $curChar) {
				if ($curChar) print("<br />\n");
				print("<strong>$firstChar</strong><br />\n");
				$curChar = $firstChar;
			}

			if ($this->HasAccess("read", $page["tag"])) {
				print($this->Link($page["tag"]));
	 			}
			else {
				print($page["tag"]);
			}
			if ($page['owner'] != '')
	 			{					   
	   			if ($this->UserName() == $page['owner']) 
	  				print(" . . . . one of your pages.");
	 				else {
					if ($this->HasAccess("read", $page["owner"])) {
			 				print(" . . . . Owner: ".$this->Format($page['owner']));
			 			}
					else {
   						print(" . . . . Owner: ".$page['owner']);
					}
				}
	 			}

	 			print("<br />\n");	
				
		}
		elseif ('' == $st || $st == 'ALL')
		{ 
			if ($firstChar != $curChar) {
				if ($curChar) print("<br />\n");
				print("<strong>$firstChar</strong><br />\n");
				$curChar = $firstChar;
			}

			if ($this->HasAccess("read", $page["tag"])) {
				print($this->Link($page["tag"]));
	 			}
			else {
				print($page["tag"]);
			}
			if ($page['owner'] != '')
	 			{					   
	   			if ($this->UserName() == $page['owner']) 
	  				print(" . . . . one of your pages.");
	 				else {
					if ($this->HasAccess("read", $page["owner"])) {
			 				print(" . . . . Owner: ".$this->Format($page['owner']));
			 			}
					else {
   						print(" . . . . Owner: ".$page['owner']);
					}
				}
	 			}

	 			print("<br />\n");		   
		} 
	  }
	}

}
else
{
	print("<em>No pages found.</em>");
}

?>


If anybody has any suggestions, or sees any security issues, for this script please let me know. Mark is working on some other issues for me right now (other mods for wakka.....a *very* simple spreadsheet-like interactive table tool actually, and a file upload tool so kids can upload pix.....but the pix will go to a central area for approval first after which they'll be sent to each kids personal file area so they can be embedded in wikka pages. I'm going to integrate a modified version of the wikka-based gallery tool into this so that kids can have on-line presentations of their pictures (it'll only come from their personal file areas, not on a per-page basis)) but if there are useful suggestions for the pageindex action then he might be able to look at them before his contract ends. I'll post the other things he's working on here when he's done. -- Mike Bowen

The edit of 17 June was to force the script to accept upper or lower case letters when designating a letter to start with. -- Mike Bowen

+

We've "mostly" finished another action for "pagewatches".....the code and the table info for it is below

<?php

// get current user
$username = $this->GetUserName();
$urldest = $this->config["base_url"];
$thislink = $this->config["base_url"].$this->MiniHref($method, $tag);

$str  = 'SELECT tag, user, time, timesaved  ';
$str .= "FROM ".$this->config["table_prefix"]."pagewatches ";
$str .= "WHERE user='$username'";

$pn = '';

$renew=$_REQUEST['renew']; 
$pn=$_REQUEST['pn']; 
$update=$_REQUEST['update']; 
$deleterow=$_REQUEST['del'];

//DELETE row in database pagewatches
if ($deleterow == "yes")
{
$this->query("DELETE from ".$this->config['table_prefix']."pagewatches WHERE user='$username' AND tag = '$pn' ");
}
// DELETE code is ended

// UPDATE of information on when chosen wikipages were last edited...
if ($update == "yes")
{
  $query = "$str";
  $result = mysql_query($query);
	while ($row = mysql_fetch_array($result))
	{
	extract ($row);
		$query2 = "SELECT time, tag, latest FROM wakka_pages WHERE tag = '$tag' AND latest = 'Y'";
		  $result2 = mysql_query($query2);
			while ($row2 = mysql_fetch_array($result2))
			{
			extract ($row2);
			$this->query("UPDATE ".$this->config['table_prefix']."pagewatches SET timesaved = '$time' WHERE user='$username' AND tag = '$tag' ");
			}
	}
}
// UPDATE code is finished

// DO RENEWAL if in URL line (depends on variables being passed across)...
if ($renew == "yes")
{

// obtain info from _pages table so that can determine time of last edit
$time = '';
$query = "SELECT time, tag, latest FROM wakka_pages WHERE tag = '$pn' AND latest = 'Y'";
  $result = mysql_query($query);
	while ($row = mysql_fetch_array($result))
	{
		extract ($row);
	}
// update timestamp
$timesubmitted = date("Y-m-d H:i:s");
		$this->query("UPDATE ".$this->config['table_prefix']."pagewatches SET time = '$timesubmitted',timesaved = '$time' WHERE user='$username' AND tag = '$pn' ");	

}
// RENEWAL Code is finished here

// Submit Wikipages For Monitoring +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
?>

		 <b><font size='-2'>Enter Wikipage names that you want to monitor for changes</font></b><br />
   		<form action="" method="post">
	   		<input type="text" size="25" name="wikipages" style="padding: 0px; margin: 0px; font-size: 10px; height: 12px; font-style:verdana">
		   	<input type="button" value="Submit" style="padding: 0px; margin: 0px; font-size: 10px; height: 20px; font-style:verdana; ALIGN=center">
			   <input type="hidden" name="save" value="true">
		   </form>	
<?php
	$wikipages = $_POST["wikipages"];
// The stuff below is to figure out if an entry is to update or insert into the pagewatches table.
// This section is to determine if a wiki page has been entered before into wakka_pagewatches

if ($wikipages != '')
{

// this section determines if the wikipagename had been entered in watchedpages before...if not then sets $donotdelete to "1"

// reset donotdelete to null

$donotdelete = '';

	$query = "SELECT tag, user, donotdelete FROM wakka_pagewatches WHERE tag = '$wikipages' AND user = '$username'";
	  $result = mysql_query($query);
	while ($row = mysql_fetch_array($result))
	{
		extract ($row);
// echo $donotdelete;
	}
// THIS SECTION WORKS TO HERE...it produces a score for $donotdelete which indicates if wikiname is in pagewatches table

// NEW SECTION....This section is to extract the time a wiki page was last saved ... it's saved at $time

$time = '';
$query = "SELECT time, tag, latest FROM wakka_pages WHERE tag = '$wikipages' AND latest = 'Y'";
  $result = mysql_query($query);
while ($row = mysql_fetch_array($result))
{
	extract ($row);

}
// THIS SECTION WORKS to HERE.....it extracts the last time that the wikipage was saved to wakka_pages

// Need another "if" statement....logic is....if "exist" in database then UPDATE else INSERT. 
	if ($donotdelete == '1')
	{	
// update timestamp
$timesubmitted = date("Y-m-d H:i:s");
//			GMB This line below updates a "new" time to start watching into an already existing row.

		$this->query("UPDATE ".$this->config['table_prefix']."pagewatches SET time = '$timesubmitted',timesaved = '$time' WHERE user='$username' AND tag = '$wikipages' ");	


	}
	if ($donotdelete == '')
	{
$timesubmitted = date("Y-m-d H:i:s");
// This query will INSERT new information into the table.

		$this->query("INSERT INTO ".$this->config['table_prefix']."pagewatches (user, tag, time, timesaved) VALUES ('$username', '$wikipages', '$timesubmitted', '$time') ");	

	}

}

?>
<?php

// I need to reset $wikipages to null (so it doesn't keep the same variable in if you re-load the page) ... but this doesn't work??

$wikipages = '';

?> 
<?php
  $query = "$str";
  $result = mysql_query($query);

echo "<table cellspacing='0' cellpadding='0'>";
echo "<tr><td bgcolor='gray' valign='bottom' align='center' colspan='9'><font color='white' size='-2'><b>List of Watched WikiPages</b></font></td></tr>\n";
	echo "<tr>
		<td bgcolor='gray' valign='bottom' align='center'><font color='white' size='-2'>&nbsp;Renew?&nbsp;</font><td>
		<td bgcolor='gray' valign='bottom' align='center'><font color='white' size='-2'>Wiki Page</font><td>
		<td bgcolor='gray' valign='bottom' align='center'><font color='white' size='-2'>When Submitted</font><td>
		<td bgcolor='gray' valign='bottom' align='center'><font color='white' size='-2'>Changed?</font><td>
		<td bgcolor='gray' valign='bottom' align='center'><font color='white' size='-2'>&nbsp;Delete?&nbsp;</font><td>
		</tr>";
while ($row = mysql_fetch_array($result))
{
	extract ($row);

// need comparison of dates in here....if one in this database greater then "Not Changed", if less...
// Have last entered date from wakka_pages entered
// when pagename typed in, & then current one compared with that one. So working out that data-out code allows me to do the comparison bit. 

$tagdest = $urldest.$tag;
$renewtime = $thislink.'&renew=yes'.'&pn='.$tag;
$delpglnk = $thislink.'&del=yes'.'&pn='.$tag;
$edtimeupdate = $thislink.'&update=yes';

// "CHANGED" determination 
$timesubnohyphens = str_replace("-", "", $time);
$timesubnohyphens = str_replace(":", "", $timesubnohyphens);
$timesubnohyphens = str_replace(" ", "", $timesubnohyphens);

$timesavnohyphens = str_replace("-", "", $timesaved);
$timesavnohyphens = str_replace(":", "", $timesavnohyphens);
$timesavnohyphens = str_replace(" ", "", $timesavnohyphens);
$timediff = $timesubnohyphens - $timesavnohyphens;
if ($timediff < 0)
{
	$changed = "<b>File Changed!</b>";
}
else
{
	$changed = "File Not Changed";
}

// "CHANGED" determination goes to here
	echo "<tr>
		<td valign='top' align='center'><font color='gray' size='-2'><a href=\"$renewtime\">Renew</a></font><td>
		<td valign='top'><font size='-2' color='gray'><b><a href=\"$tagdest\">$tag</a></b></font><td>
		<td valign='top' align='center'><font color='gray' size='-2'>&nbsp;$time&nbsp;</font><td>
		<td valign='top' align='center'><font color='gray' size='-2'>&nbsp;$changed&nbsp;</font><td>
		<td valign='top' align='center'><font color='gray' size='-2'><a href=\"$delpglnk\">Delete</a></font><td>
		</tr>";
   }
echo "<tr><td bgcolor='gray' valign='bottom' align='center' colspan='9'><font color='white' size='-2'><a href=\"$edtimeupdate\"><b>&nbsp;&nbsp;Update&nbsp;&nbsp;</b></a> Check to see if pages have been edited.</font></td></tr>\n";
echo "</table>";
?>
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki