i found this class here on phpbuilder that parses custom tags as i need witch is great saves alot of work for me as i scan through the code to figure this thing out i get stuck on a comment sounds wierd i now but i will show but the comment says INPUT
function myTag(){
$this->CONVERT_TO_BR=MYTAG_CONVERT_TO_BR;
}
/**
* definition functions
* INPUT PARAMS ARE NECESSERY !!!
* @param Array $attr=null array of attributes you can use with tag
* @param String $data="" data you want do parse
* @return String
* @version 1.1
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 28.04.2003, 16:37:34
**/
input params are necessery? what input prams?
here is the whole class and i warn it you its big and full of string fucntions
<?php
/**
* My Tag class
* @author Armando Ota <armando.ota@rs-pi.com>
* @version 1.1
* @since 28.04.2003, 08:33:49
* @copyright GPL - jada jada jada
**/
define("MYTAG_PREFIX","<tag="); //prefixes you may use {?}
define("MYTAG_CONVERT_TO_BR","1"); //converts CR to HTML <BR />
define("MYTAG_SEPARATOR","|"); //defines separator
class myTag {
public $tag_stack = null;
public $basic_string = "";
public $CONVERT_TO_BR = 0;
/**
* constructor
* @return
* @version 1.1
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 28.04.2003, 08:43:02
**/
function myTag(){
$this->CONVERT_TO_BR=MYTAG_CONVERT_TO_BR;
}
/**
* definition functions
* INPUT PARAMS ARE NECESSERY !!!
* @param Array $attr=null array of attributes you can use with tag
* @param String $data="" data you want do parse
* @return String
* @version 1.1
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 28.04.2003, 16:37:34
**/
/**
* external link
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function link($attr=null,$data=""){
if($attr['url']){
$output="<a href=\"".$attr['url']."\" target=\"_blank\">".$data."</a>";
} else {
$output=$data;
}
return $output;
}
/**
* internal link
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function int_link($attr=null,$data=""){
return $output;
}
/**
* file into content
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function file($attr=null,$data=""){
return $output;
}
/**
* shows picture in content
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function picture($attr=null,$data=""){
return $output;
}
/**
* creates table in content
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function table($attr=null,$data=""){
$output="
<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
".$data."
</table>
";
return $output;
}
/**
* creates table row in content
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function row($attr=null,$data=""){
$output="
<tr>
".$data."
</tr>
";
return $output;
}
/**
* creates table column in content
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function col($attr=null,$data=""){
$output="
<td>".$data."</td>
";
return $output;
}
/**
* creates list in content
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function list($attr=null,$data=""){
$output="
<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
".$data."
</table>
";
return $output;
}
/**
* creates list item in content
* @param array $attr=null attributes array
* @param string $data="" input data
* @return string
* @version 1.0
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 05.05.2003, 08:09:06
**/
function listItem($attr=null,$data=""){
$output="
<tr>
<td><img src=\"dsg/list_bullet.gif\" border=\"0\" alt=\"\" /></td><td>".$data."</td>
</tr>
";
return $output;
}
/**
* parser for input string
* @param string $str string for parsing
* @return string
* @version 1.1
* @author Armando Ota <armando.ota@rs-pi.com>
* @since 28.04.2003, 08:43:57
**/
function parseText($str=""){
if($str){
$str=" ".$str;
$start_tag_lok=strpos($str,"<".MYTAG_PREFIX.MYTAG_SEPARATOR);
while($start_tag_lok){
$def_tag_len=strlen("<".MYTAG_PREFIX.MYTAG_SEPARATOR); //length of start string tag
$start_tag_lok_end=strpos($str,">",$start_tag_lok+1); // find the closing gap for start tag
//find tag string
$tag_string=substr($str,$start_tag_lok+$def_tag_len,$start_tag_lok_end-($start_tag_lok+$def_tag_len));
// posibility that tag has been written like <tag='something'>
$start_attr_eq=strpos($tag_string,"="); //find occuarance of '=' sign
$start_attr_space=strpos($tag_string," "); //find occuarance of ' '(whitespace) sign
if(!$start_attr_space) $start_attr_space=strlen($tag_string);
if($start_attr_eq<$start_attr_space){
//if tag conatins equal sign
$tag_name=substr($tag_string,0,$start_attr_eq);
$attr_str=trim(substr($tag_string,0,strlen($tag_string)+1));
//puts it into array
$attr_arr=explode(" ",$attr_str);
for($i=0;$i<sizeof($attr_arr);$i++){
$sec_attr_arr=explode("=",$attr_arr[$i]);
//attr_stack now has attribute name as key and its value
$attr_stack[$sec_attr_arr[0]]=trim(substr($sec_attr_arr[1],1,strlen($sec_attr_arr[1])-2));
}
} else {
//defines where tag name ends
if($start_attr_space<$start_attr_eq){
$start_attr_pos=$start_attr_space;
} else {
$start_attr_pos=$start_attr_eq;
}
//pick tagname
$tag_name=substr($tag_string,0,$start_attr_pos);
//gets attributes string
$attr_str=trim(substr($tag_string,$start_attr_pos+1,strlen($tag_string)-$start_attr_pos+1));
//puts it into array
$attr_arr=explode(" ",$attr_str);
for($i=0;$i<sizeof($attr_arr);$i++){
$sec_attr_arr=explode("=",$attr_arr[$i]);
//attr_stack now has attribute name as key and its value stored
$attr_stack[$sec_attr_arr[0]]=trim(substr($sec_attr_arr[1],1,strlen($sec_attr_arr[1])-2));
}
}
//data between start and end tags
$end_tag_lok=strpos($str,"</".MYTAG_PREFIX.MYTAG_SEPARATOR.$tag_name.">");
if($end_tag_lok){
$tag_data=substr($str,$start_tag_lok_end+1,$end_tag_lok-$start_tag_lok_end-1);
$end_tag_len=strlen("</".MYTAG_PREFIX.MYTAG_SEPARATOR.$tag_name.">");
//builds the whole string (start and end tag) for replacement
$whole_tag_string=substr($str,$start_tag_lok,($end_tag_lok+$end_tag_len)-$start_tag_lok);
if(method_exists($this,$tag_name)){ //checks if tag method exists and calls it
$str=str_replace($whole_tag_string,call_user_func(array("myTag",$tag_name),$attr_stack,$this->parseText($tag_data)),$str);
} else {
$str=str_replace($whole_tag_string,$this->parseText($tag_data),$str); //if tag method does not exists then we replace tag with text
}
}
$start_tag_lok=strpos($str,"<".MYTAG_PREFIX.MYTAG_SEPARATOR,$start_tag_lok+1);
}
if($this->CONVERT_TO_BR){
$str=str_replace(chr(10),"<br />",$str);
}
}
return $str;
}
}
?>
also code wasn't written by me was written in 2003 according to your libaray and no updates and no way to get ahold of the creator.
but i need to dissect this code and get it figured out piece by piece.
any help would be greatly appreciated