I thought I did, but here is pretty much the entire process from input to output:
The user submits data into a form. The data is then processes for errorchecking. If there error stack is empty, then continue to insert into database:
if (count ($error)) {
return $this->template->getError ('The following errors have been detected:', 'JAVASCRIPT: history.back(-1)', 10, $error);
} else {
$data = array(
'uid' => $this->user['id'],
'sig' => addslashes ($message),
);
$this->adapter->update_profile ($data, 'sig');
return $this->template->getError ('Your signature has been updated successfully, returning you to where you were.', './index.php?a=ucp&CODE=01');
}
$this->adapter->update_profile($data, 'sig'); calls the adapter pattern which interacts between the application and dao ( creating a standard API for plugins and modifications ). The functions looks like this:
function update_profile ($data, $type)
{
extract ($data);
switch ($type)
{
//extra conditionals cutout....
case 'sig':
return $this->dao->query ("UPDATE profiles SET sig = '{$sig}' WHERE id = '{$uid}'");
break;
}
}
The data is now stored in a blob field. Now, when the user wishes to edit or view thier sig, the data is pulled in the same manner:
function display_edit_sig ()
{
return $this->template->add_edit_sig_form ($this->user);
}
Where $this->user is the current user's cached profile and $this->template is a widget-based call to a specific template section.
Here is the 'widget' for the form:
function add_edit_sig_form ($info)
{
extract ($info);
extract ($this->user);
$data = array(
'TEXT' => $sig
);
$psig = $this->parse->parse_text ($data);
$versaCode = $this->add_versa_code ();
$code = $this->fetchPiece ('ucp_edit_sig');
return stripslashes (eval ($code));
}
$psig = $this->parse->parse_text ($data); ( $psig = preview sig ) parses the text and formats bb-type code.
parse_text executes the various parsing functions:
function parse_text ($data = array( 'TEXT' => '', 'SMILIES' => 0, 'MAX_SMILIES' => 8, 'CODE' => 0, 'SIG' => 0, 'HTML' => 0))
{
extract ($data);
$TEXT = $this->parse_simple ($TEXT);
$TEXT = $this->parse_links ($TEXT);
$TEXT = nl2br ($TEXT);
$TEXT = $this->parse_blocks ($TEXT);
return $TEXT;
}
within $this->parse_blocks $this->parse_php is called:
function parse_php($text)
{
if (empty ($text)) {
return;
}
if (!strpos ($text, '<' . '?')) {
$text = '<' . "?php\n\n" . $text;
}
if (!strpos ($text, '?' . '>')) {
$text .= "\n\n?" . ">";
}
$text = str_replace ('<br />', '', $text);
ob_start ();
highlight_string ($text);
$code = ob_get_contents ();
ob_end_clean ();
$keyword = ini_get ('highlight.keyword');
$code=preg_replace ('{([\w_]+)(\s*</font>)(\s*<font\s+color="' . $keyword . '">\s*\()}m', '<a href="http://www.php.net/manual-lookup.php?pattern=$1">$1</a>$2$3', $code);
return $code;
}
This formats and colors the PHP code. I left a few functions out, namely the one that preg_replaces the code and another that formats it into a table with gutter, etc...
Well, thats pretty much it.
If you would be interested in testing this live, go here:
http://www.cyberxtreme.org/dev/vBase/
Thanks for your time!