[phpMP-CVS] CVS: phpMP/includes mpcode_arrays.php,NONE,1.1 mpcode.php,1.3,1.4 template.php,1.27,1.28
Status: Pre-Alpha
Brought to you by:
heimidal
From: Anthony W. <ant...@us...> - 2003-05-01 21:59:34
|
Update of /cvsroot/phpmp/phpMP/includes In directory sc8-pr-cvs1:/tmp/cvs-serv11175/includes Modified Files: mpcode.php template.php Added Files: mpcode_arrays.php Log Message: Started some work on mpcode, I think I have a good start here --- NEW FILE: mpcode_arrays.php --- <?php // Contains the mpcode and corresponding html arrays $mpcode = array( 1 => "[b]", 2 => "[/b]" ); $html = array( 1 => "<b>", 2 => "</b>" ); ?> Index: mpcode.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/mpcode.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** mpcode.php 8 Feb 2003 09:31:54 -0000 1.3 --- mpcode.php 1 May 2003 21:59:30 -0000 1.4 *************** *** 4,6 **** --- 4,37 ---- // These work similarly to BBCode and the like. + include ("includes/mpcode_arrays.php"); + + // Work here done by anthony. If you dont like it feel free to change it. + class mpcode { + + function parse_string($string) { + if ($string == "") + return; + + $split = explode(" ", $string); + + for ($i = 0; $i < count($split); $i++) { + if (in_array($split[$i], $mpcode)) { + $this->_replace($split[$i]); + } + } + } + + // This may not be the best way, but it works + function _replace($string) { + for ($i = 0; $i < count($mpcode); $i++) { + switch ($string) { + case $mpcode[$i]: + str_replace($string, $html[$i], $string); + break; + } + } + } + + } + ?> Index: template.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/template.php,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** template.php 8 Feb 2003 09:43:29 -0000 1.27 --- template.php 1 May 2003 21:59:30 -0000 1.28 *************** *** 4,66 **** // This will utilize a flat-file template system. ! class Template extends Smarty ! { ! ! // Assigns template constants. ! // This function should somehow be integrated into constants.php. ! // Author: Nrian 'Heimidal' Rose ! // Accepts: none. ! // Returns: none. ! function assignConstants() ! { ! ! $this->assign( array( ! ! "C_SITE_ADDR" => SITE_ADDR, ! "C_SITE_NAME" => SITE_NAME, ! "C_REL_PATH" => REL_PATH, ! "C_TIME_NOW" => TIME_NOW, ! "C_TEMPLATE" => TEMPLATE ! ) ); ! } ! // Assigns template vars through lang files. ! // Author: Brian 'Heimidal' Rose ! // Accepts: none. ! // Returns: none. ! function assignLangVars() { ! global $Local; ! ! $this->assign( $Local->lang ); ! ! } ! ! // Initiates the Template engine. ! // Author: Brian 'Heimidal' Rose ! // Accepts: none. ! // Returns: none. ! function Template() ! { ! ! ( defined( "U_USR_TPL" ) && ( C_OVERRIDE_USR_TPL == 0 ) ) ? define( "C_TEMPLATE", U_TEMPLATE ) : define( "C_TEMPLATE", C_DEFAULT_TPL ); ! ! // Set up the directories for Smarty. ! $this->template_dir = './templates/' . C_TEMPLATE; ! $this->compile_dir = './templates/' . C_TEMPLATE . '/compile'; ! $this->config_dir = './templates/' . C_TEMPLATE . '/configs'; ! $this->cache_dir = ''; ! ! // Turn on compile_check. ! $this->compile_check = 1; ! ! // Switch for caching. ! $this->caching = false; // Caching does not currently work. Maybe later. ! } ! } --- 4,33 ---- // This will utilize a flat-file template system. ! include_once( C_PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); ! $DB = new DB; ! class template ! { ! var $tplname, $tplvars; ! $tplvars = new array(); ! /** ! * template::template() ! * ! * Initializes the template system ! * Default Constructor ! * ! * @param $tplname ! * @return ! **/ ! function template($tplname) { + $query = $DB->query("SELECT * FROM " . DB_TABLE_PREFIX . "template_vars WHERE tpl_name='$tplname'"); ! $this->tplname = $tplname; ! $this->tplvars = $DB->fetchArray($query); } ! } |