Update of /cvsroot/phpmp/phpMP/includes
In directory sc8-pr-cvs1:/tmp/cvs-serv16149/includes
Modified Files:
mpcode.php mpcode_arrays.php
Log Message:
Did more work on the MPCode system. Hopefully I will finish this by the end of next week.
Index: mpcode.php
===================================================================
RCS file: /cvsroot/phpmp/phpMP/includes/mpcode.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** mpcode.php 1 May 2003 21:59:30 -0000 1.4
--- mpcode.php 2 May 2003 23:17:41 -0000 1.5
***************
*** 4,9 ****
// 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 {
--- 4,7 ----
***************
*** 15,34 ****
$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;
! }
! }
}
--- 13,35 ----
$split = explode(" ", $string);
! foreach ($split as $key => $code) {
! if ($key == count($split) - 1)
! $final .= $this->_replace($code);
! else
! $final .= $this->_replace($code) . " ";
! }
!
! return $final;
}
// This may not be the best way, but it works
function _replace($string) {
! include ("phpmp/includes/mpcode_arrays.php");
!
! foreach ($mpcode as $key => $code) {
! $string = str_replace($code, $html[$key], $string);
! }
!
! return $string;
}
Index: mpcode_arrays.php
===================================================================
RCS file: /cvsroot/phpmp/phpMP/includes/mpcode_arrays.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** mpcode_arrays.php 1 May 2003 21:59:31 -0000 1.1
--- mpcode_arrays.php 2 May 2003 23:17:41 -0000 1.2
***************
*** 4,15 ****
$mpcode = array(
! 1 => "[b]",
! 2 => "[/b]"
! );
$html = array(
! 1 => "<b>",
! 2 => "</b>"
! );
! ?>
\ No newline at end of file
--- 4,19 ----
$mpcode = array(
! "[b]",
! "[/b]",
! "[i]",
! "[/i]"
! );
$html = array(
! "<b>",
! "</b>",
! "<i>",
! "</i>"
! );
! ?>
|