List Info

Thread: geshi-src/geshi/classes class.geshicontext.php,1.33,1.34




geshi-src/geshi/classes class.geshicontext.php,1.33,1.34
user name
2006-05-14 09:18:05
Update of /cvsroot/geshi/geshi-src/geshi/classes
In directory
sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv20346/geshi/classes

Modified Files:
	class.geshicontext.php 
Log Message:
Bug #73: allow addChild to specify a function that can be
used to initialise the context. Still needs more discussion
before it can be marked as resolved.

Also some very basic handling of bug #74: better error
reporting if language functions don't exist.

Index: class.geshicontext.php
============================================================
=======
RCS file:
/cvsroot/geshi/geshi-src/geshi/classes/class.geshicontext.ph
p,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** class.geshicontext.php	14 May 2006 02:15:59 -0000	1.33
--- class.geshicontext.php	14 May 2006 09:18:03 -0000	1.34
***************
*** 203,210 ****
       * 
       * param string The name of the language this context
represents
!      * param array  The name used for aliasing
       * todo [blocking 1.1.9] Better comment
       */
!     function GeSHiContext ($context_name, $alias_name =
'')
      {
          $this->_contextName = $context_name;
--- 203,210 ----
       * 
       * param string The name of the language this context
represents
!      * param string An initialisation function
       * todo [blocking 1.1.9] Better comment
       */
!     function GeSHiContext ($context_name, $init_function =
'')
      {
          $this->_contextName = $context_name;
***************
*** 217,221 ****
          
          $funcname = 'geshi_' . str_replace('/', '_',
$context_name);
!         $funcname($this);
      }
      
--- 217,250 ----
          
          $funcname = 'geshi_' . str_replace('/', '_',
$context_name);
!         $init_function = ('' != $init_function) ?
'geshi_' . $this->_languageName
!             . '_' . $init_function : '';
!         
!         if (function_exists($funcname)) {
!             $funcname($this);
!             // todo [blocking 1.1.1] Although we added
functionality
!             // for specifying the function to initialise
the context
!             // with, so far the usage has been exclusivly
to name
!             // function as the context name (just without
dialect)
!             // anyway, so perhaps we could save some
hassle and just
!             // try that function (geshi_lang_context_name)
anyway
!         } elseif ('' != $init_function &&
function_exists($init_function)) {
!             $init_function($this);
!         } else {
!             // todo [blocking 1.1.1] bug #74: die nicely
!             if (function_exists('debug_backtrace')) {
!                 $data = debug_backtrace();
!                 $file = $data[2]['file'];
!                 $line = $data[2]['line'];
!             } else {
!                 $data = array(
!                     'file' => 'Unknown',
!                     'line' => 0
!                 );
!             }
!             trigger_error("Can't find function for
context $context_name\n"
!                 . 'looked for ' . $funcname .
(($init_function != '') ? ' and ' . $init_function :
'')
!                 . ' in file ' . $file . ' on line ' .
$line,
!                 E_USER_ERROR);
!         }
      }
      
***************
*** 339,359 ****
       * param string $type An optional type of context for
the child. The class
<kbd>GeSHi[$type]Context</kbd>
       *                     will be used for the context. A
commonn value would be <kbd>'string'</kbd>.
!      * param string $lang If the type of class you want to
use is language specific (and thus is in a directory
!      *                     under
<kbd>GESHI_CLASSES_ROOT</kbd>), specify the name
of the directory here.
       * since 1.1.1
       */
!     function addChild ($name, $type = '', $language =
'')
      {
          // Get the class if needed
!         if ($type && 'string' != $type
&& 'code' != $type) {
              if ($language) {
                  $language .= GESHI_DIR_SEP;
              }
!             /** Get the context class required for this
child */
              require_once GESHI_CLASSES_ROOT . $language .
'class.geshi' . $type . 'context.php';
!         }
  
          $classname = 'geshi' . $type . 'context';
!         $this->_childContexts[] =& new
$classname($this->_makeContextName($name));
      }
      
--- 368,387 ----
       * param string $type An optional type of context for
the child. The class
<kbd>GeSHi[$type]Context</kbd>
       *                     will be used for the context. A
commonn value would be <kbd>'string'</kbd>.
!      * param string $init_function
       * since 1.1.1
       */
!     function addChild ($name, $type = '', $init_function
= '')
      {
          // Get the class if needed
!         /*if ($type && 'string' != $type
&& 'code' != $type) {
              if ($language) {
                  $language .= GESHI_DIR_SEP;
              }
!             /** Get the context class required for this
child *//*
              require_once GESHI_CLASSES_ROOT . $language .
'class.geshi' . $type . 'context.php';
!         }*/
  
          $classname = 'geshi' . $type . 'context';
!         $this->_childContexts[] =& new
$classname($this->_makeContextName($name),
$init_function);
      }
      



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to
make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/
sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
geshi-cvs mailing list
geshi-cvslists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geshi-cvs

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )