Jump to content

integrate jcart to a theme script


erdem

Recommended Posts

Hi Im using a php theme script and I want to use jcart with this script. The thing is my theme scrip dosen't use echo.

 

When I need to display something I have to use something like this $_PAGE = "<div id='jcart'>..."

 

and if i use echo i recieve header error. i changed couple of thing and now i cant see cart but when i click add to cart button it says Item added but all cart is disappearing. you can see here

 

 

 

could you help me please thanks.

 

<THEME Name={ShopNavDivEnd}>
         </ul>
      </div>  
      
<br /><br /><br /><br />
<VAR>_JCART</VAR>
</div>
            
</THEME>

 

this is shop.php

$_JCART .= "<div id='jcart'>".$jcart->display_cart()."</div>";

 

i changed the jcart.php class to like this. I mean all echo to $_PAGE .= "..."

// Return specified number of tabs to improve readability of HTML output
      function tab($n) {
         $tabs = null;
         while ($n > 0) {
            $tabs .= "\t";
            --$n;
         }
         return $tabs;
      }

      // If there's an error message wrap it in some HTML
      if ($errorMessage)   {
         $errorMessage = "<p id='jcart-error'>$errorMessage</p>";
      }

      // Display the cart header
      $_JCART .= tab(1) . "$errorMessage\n";
      $_JCART .= tab(1) . "<form method='post' action='$checkout'>\n";
      $_JCART .= tab(2) . "<fieldset>\n";
      $_JCART .= tab(3) . "<input type='hidden' name='jcartToken' value='{$_SESSION['jcartToken']}' />\n";
      $_JCART .= tab(3) . "<table border='1'>\n";
      $_JCART .= tab(4) . "<thead>\n";
      $_JCART .= tab(5) . "<tr>\n";
      $_JCART .= tab(6) . "<th colspan='3'>\n";
      $_JCART .= tab(7) . "<strong id='jcart-title'>{$config['text']['cartTitle']}</strong> ($this->itemCount $itemsText)\n";
      $_JCART .= tab(6) . "</th>\n";
      $_JCART .= tab(5) . "</tr>". "\n";
      $_JCART .= tab(4) . "</thead>\n";
      
      // Display the cart footer
      $_JCART .= tab(4) . "<tfoot>\n";
      $_JCART .= tab(5) . "<tr>\n";
      $_JCART .= tab(6) . "<th colspan='3'>\n";

      // If this is the checkout hide the cart checkout button
      if ($isCheckout !== true) {
         if ($config['button']['checkout']) {
            $inputType = "image";
            $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkout']}' title='' ";
         }
         $_JCART .= tab(7) . "<input type='$inputType' $src id='jcart-checkout' name='jcartCheckout' class='jcart-button' value='{$config['text']['checkout']}' />\n";
      }

      $_JCART .= tab(7) . "<span id='jcart-subtotal'>{$config['text']['subtotal']}: <strong>$currencySymbol" . number_format($this->subtotal, $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</strong></span>\n";
      $_JCART .= tab(6) . "</th>\n";
      $_JCART .= tab(5) . "</tr>\n";
      $_JCART .=  tab(4) . "</tfoot>\n";         
      $_JCART .= tab(4) . "<tbody>\n";

      // If any items in the cart
      if($this->itemCount > 0) {

         // Display line items
         foreach($this->get_contents() as $item)   {
            $_JCART .= tab(5) . "<tr>\n";
            $_JCART .= tab(6) . "<td class='jcart-item-qty'>\n";
            $_JCART .= tab(7) . "<input name='jcartItemId[]' type='hidden' value='{$item['id']}' />\n";
            $_JCART .= tab(7) . "<input id='jcartItemQty-{$item['id']}' name='jcartItemQty[]' size='2' type='text' value='{$item['qty']}' />\n";
            $_JCART .= tab(6) . "</td>\n";
            $_JCART .= tab(6) . "<td class='jcart-item-name'>\n";

            if ($item['url']) {
               $_PAGE .= tab(7) . "<a href='{$item['url']}'>{$item['name']}</a>\n";
            }
            else {
               $_PAGE .= tab(7) . $item['name'] . "\n";
            }
            $_JCART .= tab(7) . "<input name='jcartItemName[]' type='hidden' value='{$item['name']}' />\n";
            $_JCART .= tab(6) . "</td>\n";
            $_JCART .= tab(6) . "<td class='jcart-item-price'>\n";
            $_JCART .= tab(7) . "<span>$currencySymbol" . number_format($item['subtotal'], $priceFormat['decimals'], $priceFormat['dec_point'], $priceFormat['thousands_sep']) . "</span><input name='jcartItemPrice[]' type='hidden' value='{$item['price']}' />\n";
            $_JCART .= tab(7) . "<a class='jcart-remove' href='?jcartRemove={$item['id']}'>{$config['text']['removeLink']}</a>\n";
            $_JCART .= tab(6) . "</td>\n";
            $_JCART .= tab(5) . "</tr>\n";
         }
      }

      // The cart is empty
      else {
         $_PAGE = tab(5) . "<tr><td id='jcart-empty' colspan='3'>{$config['text']['emptyMessage']}</td></tr>\n";
      }
      $_JCART .= tab(4) . "</tbody>\n";
      $_JCART .= tab(3) . "</table>\n\n";

      $_JCART .= tab(3) . "<div id='jcart-buttons'>\n";

      if ($config['button']['update']) {
         $inputType = "image";
         $src = " src='{$config['button']['update']}' alt='{$config['text']['update']}' title='' ";
      }

      $_JCART .= tab(4) . "<input type='$inputType' $src name='jcartUpdateCart' value='{$config['text']['update']}' class='jcart-button' />\n";

      if ($config['button']['empty']) {
         $inputType = "image";
         $src = " src='{$config['button']['empty']}' alt='{$config['text']['emptyButton']}' title='' ";
      }

      $_JCART .= tab(4) . "<input type='$inputType' $src name='jcartEmpty' value='{$config['text']['emptyButton']}' class='jcart-button' />\n";
      $_JCART .= tab(3) . "</div>\n";

      // If this is the checkout display the PayPal checkout button
      if ($isCheckout === true) {
         // Hidden input allows us to determine if we're on the checkout page
         // We normally check against request uri but ajax update sets value to relay.php
         $_JCART .= tab(3) . "<input type='hidden' id='jcart-is-checkout' name='jcartIsCheckout' value='true' />\n";

         // PayPal checkout button
         if ($config['button']['checkout'])   {
            $inputType = "image";
            $src = " src='{$config['button']['checkout']}' alt='{$config['text']['checkoutPaypal']}' title='' ";
         }

         if($this->itemCount <= 0) {
            $disablePaypalCheckout = " disabled='disabled'";
         }

         $_JCART .= tab(3) . "<input type='$inputType' $src id='jcart-paypal-checkout' name='jcartPaypalCheckout' value='{$config['text']['checkoutPaypal']}' $disablePaypalCheckout />\n";
      }

      $_JCART .= tab(2) . "</fieldset>\n";
      $_JCART .= tab(1) . "</form>\n\n";
      
      $_JCART .= tab(1) . "<div id='jcart-tooltip'></div>\n";
      
      return $_JCART;
   }
}

 

 

and this is my theme script

<?php

class Theme
{
   var $META = array();
   var $JS = array();
   var $BodyOn = array();
   var $CSS = array();
   var $TITLE = "";
   var $Charset = "UTF-8";

   var $Headers = '';
   var $Body = array();

   var $Vars = array();

   var $ThemeList = array();

   var $ThemeDir = '';
   var $CacheDir = '';
   var $ThemeName = '';

   var $FirstTAG = '';
   var $FirstPosition = 999999;
   var $ClassUpdated = 0;
   var $CompressOutput = true;

   var $MatchTAG = array( // Find And Replace
      'FE' => array( 'Find' => '<FE Array={([^}]+)}>', 'Replace' => "if ( count( \$\\1 ) )\r\n<!TabCount!>{\r\n<!TabCount!>\tforeach ( \$\\1 as \$_KEY => \$_VALUE )\r\n<!TabCount!>\t{\r\n" ), '/FE' => array( 'Find' => '<\/FE>', 'Replace' => "\t}\r\n<!TabCount!>}\r\n" ),
      'FF' => array( 'Find' => '<FF Array={([^}]+)}>', 'Replace' => "if ( count( \$\\1 ) )\r\n<!TabCount!>{\r\n<!TabCount!>\tforeach ( \$\\1 as \$_KFY => \$_VALUF )\r\n<!TabCount!>\t{\r\n" ), '/FF' => array( 'Find' => '<\/FF>', 'Replace' => "\t}\r\n<!TabCount!>}\r\n" ),
      'IF' => array( 'Find' => '<IF State={([^}]+)}>', 'Replace' => "if ( \\1 )\r\n<!TabCount!>{\r\n" ), '/IF' => array( 'Find' => '<\/IF>', 'Replace' => "}\r\n" ),
      'ELIF' => array( 'Find' => '<ELIF State={([^}]+)}>', 'Replace' => "else if ( \\1 )\r\n<!TabCount!>{\r\n" ), '/ELIF' => array( 'Find' => '<\/ELIF>', 'Replace' => "}\r\n" ),
      'ELSE' => array( 'Find' => '<ELSE>', 'Replace' => "else\r\n<!TabCount!>{\r\n" ), '/ELSE' => array( 'Find' => '<\/ELSE>', 'Replace' => "}\r\n" ),
      'VAR' => array( 'Find' => '<VAR>([^<]+)<\/VAR>', 'Replace' => "\$\\1" ),
      'BIT' => array( 'Find' => '<BIT>([a-z0-9_]+)(\(([^<]*)\)|)<\/BIT>', 'Replace' => "t_\\1(\\3)" ),
      'DEF' => array( 'Find' => '<DEF>([^<]+)<\/DEF>', 'Replace' => "\\1" ),
      'PHP' => array( 'Find' => '<PHP>([^<]+);?<\/PHP>', 'Replace' => "\\1" ),
      'THEME' => array( 'Find' => '<THEME Name={([^}]+)}\s*?(Vars?={([^}]+)})?>(.+)<\/THEME>' ),
      );
   var $PredefinedGlobals = array( '_HTML', '_KEY', '_KFY', '_VALUE', '_VALUF', '_GET', '_POST', '_SESSION', '_COOKIE' );

   /*
   * Base Functions
   *
   * <FE Array={Dizi}> ... </FE>
   * <IF State={$a == '4'}> ... </IF>
   * <ELIF State={$a == '4'}> ... </ELIF>
   * <ELSE> ... </ELSE>
   * <VAR> ... </VAR>
   * <BIT> ... </BIT>
   *
   * @param String $ThemeName
   * @return void
   */
   function Theme()
   {
      global $CFG;

      $this->Charset = $CFG['Theme']['Charset'];
      $this->META = $CFG['Theme']['Meta'];
      $this->TITLE = $CFG['Title'];

      $this->ClassUpdated = filemtime( CLS_DIR . "theme.class.php" );
   }

   /**
    *
    * @access public
    * @return void
    */
   function setTHEME( $ThemeName )
   {
      if ( !is_dir( THM_DIR . $ThemeName ) )
         return false;

      $this->ThemeName = $ThemeName;
      $this->ThemeDir = THM_DIR . $ThemeName . '/Html/';
      $this->CacheDir = CCH_DIR . 'Themes/' . $ThemeName . '/';
      $this->initTHEME();
   }

   /**
    *
    * @access public
    * @return void
    */
   function initTHEME()
   {
      define( 'IMG_DIR', "http://" . SITE . "/Themes/" . $this->ThemeName . "/Image/" );
      $this->loadTheme( "index" );
   }

   function loadTheme( $FileName )
   {
      $FileName = ucfirst( strtolower( $FileName ) );
      // Theme HTML Exists ?
      if ( !file_exists( $this->ThemeDir . $FileName . ".tpl" ) )
      {
         global $CFG;
         if ( $this->ThemeName != $CFG['Theme']['DefaultTheme'] )
         {
            $_SESSION['ThemeName'] = $CFG['Theme']['DefaultTheme'];
            header( "Location: ?" );
            die( 'falan filan' );
         }
         else
            die( "Theme File Not Found: " . $FileName . ".tpl" );
      }

      $this->ThemeList = array();
      // Theme Cache Exists ? And Newer than the Theme HTML ?
      if ( file_exists( $this->CacheDir . $FileName . ".tpl.php" ) AND ( filemtime( $this->CacheDir . $FileName . ".tpl.php" ) > max( $this->ClassUpdated, filemtime( $this->ThemeDir . $FileName . ".tpl" ) ) ) )
         $this->createFunctions( $FileName );
      else
         $this->cacheTheme( $FileName );
   }

   /**
    *
    * @access public
    * @return void
    */
   function loadCSS( $CssFile )
   {
      if ( eregi( 'http', $CssFile ) )
         $this->CSS[] = $CssFile;
      else
      {
         global $_RWBASE;

         $FileName = THM_DIR . $this->ThemeName . '/Style/' . $CssFile;
         if ( file_exists( $FileName ) AND is_readable( $FileName ) )
            $this->CSS[$CssFile] = $_RWBASE . $FileName;
      }
   }

   /**
    *
    * @access public
    * @return void
    */
   function loadJS( $JsFile, $Code = false )
   {
      if ( !$Code )
      {
         if ( eregi( 'http', $JsFile ) )
            $this->JS[] = '<script type="text/javascript" src="' . $JsFile . '"></script>';
         else
         {
            global $_RWBASE;
            $FileName = BASE_DIR . 'Sources/JavaScript/' . $JsFile;
            if ( file_exists( $FileName ) AND is_readable( $FileName ) )
               $this->JS[$JsFile] = '<script type="text/javascript" src="' . $_RWBASE . $FileName . '"></script>';
         }
      }
      else
         $this->JS[$Code] = '<script type="text/javascript">' . $JsFile . '</script>';
   }

   function addJS( $JsFile, $Code = false )
   {
      $this->loadJS( $JsFile, $Code );
   }

   /**
    *
    * @access public
    * @return void
    */
   function bodyOn( $Type, $Code )
   {
      $this->BodyOn[strtolower( $Type )][] = $Code;
   }

   /**
    *
    * @access public
    * @return void
    */
   function writePage( $FinalFunction = "t_Page" )
   {
      foreach ( $this->BodyOn as $key => $value )
      {
         $this->loadJS( 'function bodyOn' . $key . '() {' . implode( $value ) . '}; onAttacher("' . $key . '",bodyOn' . $key . ');', 'on' . $key );
      }

      $header = array( "<title>" . $this->TITLE . "</title>" );
      foreach ( $this->META as $value ) $header[] = $value;
      foreach ( $this->JS as $value ) $header[] = $value;
      foreach ( $this->CSS as $value ) $header[] = '<style type="text/css" media="all">@import url(' . $value . ');</style>';

      $this->Headers = implode( $header );

      header( 'Content-Type: text/html; charset=' . $this->Charset );
      echo $FinalFunction();
   }

   function createFunctions( $FileName = '' )
   {
      include_once( $this->CacheDir . $FileName . ".tpl.php" );
   }

   function cacheTheme( $FileName )
   {
      $FileContent = rFile( $this->ThemeDir . $FileName . ".tpl" );
      if ( $this->CompressOutput )
         $FileContent = $this->compressHTML( $FileContent );

      $this->parseThemes( $FileContent );

      wFile( $this->CacheDir . $FileName . ".tpl.php", "<" . "? \r\n" . $this->createThemeFunctions() . "\r\n?" . ">", 0777 );
      $this->createFunctions( $FileName );
   }

   function compressHTML( $Content )
   {
      $Content = preg_replace( "/[\s]{2,}/", " ", $Content );
      $Content = preg_replace( "/> </", "><", $Content );
      return $Content;
   }

   function parseThemes( $Content )
   {
      $Results = $this->findExactTAGs( $Content, "THEME" );
      foreach ( $Results as $Value )
      {
         preg_match( "/^" . $this->MatchTAG['THEME']['Find'] . "$/is", trim( $Value ), $Match );

         $Vars = array();
         if ( trim( $Match[3] ) != '' )
         {
            $tVars = explode( ',', $Match[3] );
            foreach ( $tVars as $vValue )
            {
               if ( preg_match( '/^\$?([a-z0-9_]+)=?(.*)$/i', trim( $vValue ), $vMatch ) )
                  $Vars[$vMatch[1]] = "$" . $vMatch[1] . ( trim( $vMatch[2] ) != "" ? "=" . $vMatch[2] : "" );
            }
         }
         $this->ThemeList[$Match[1]] = array( 'Code' => $Match[4], 'Vars' => $Vars );
      }
      return true;
   }

   function findExactTAGs( $Content, $TAGName )
   {
      $Results = array();
      $CurrPos = 0;
      $Found = false;
      $Level = 0;
      // ---------------------
      $StartTAG = "<" . $TAGName;
      $EndTAG = "</" . $TAGName . ">";
      $Repeat = substr_count( $Content, $StartTAG );
      if ( substr_count( $Content, $EndTAG ) != $Repeat )
         die( "Template ERROR: <$TAGName> sayısı ile </$TAGName> sayısı eşit değil!" );
      // -----------------------------------
      for( $i = 0; $i < $Repeat; $i++ )
      {
         $Found = false;
         $Level = 0;
         $ContentStart = strpos( $Content, $StartTAG, $CurrPos );
         $CurrPos = $ContentStart + strlen( $StartTAG );
         while ( $Found == false )
         {
            if ( $Level == 0 )
            {
               $PosS = strpos( $Content, $StartTAG, $CurrPos );
               $PosE = strpos( $Content, $EndTAG, $CurrPos );
               if ( $PosS < $PosE AND $PosS !== false )
                  $Level++;
               else
                  $Found = true;
               if ( $Found )
                  $ContentEnd = $PosE;
               $CurrPos = min( ( $PosS === false ? 999999 : $PosS ), ( $PosE === false ? 999999 : $PosE ) ) + 1;
            }
            else if ( $Level > 0 )
            {
               $PosS = strpos( $Content, $StartTAG, $CurrPos );
               $PosE = strpos( $Content, $EndTAG, $CurrPos );
               if ( $PosS < $PosE AND $PosS !== false )
                  $Level++;
               else
                  $Level--;
               $CurrPos = min( ( $PosS === false ? 999999 : $PosS ), ( $PosE === false ? 999999 : $PosE ) ) + 1;
            }
         }
         $Results[] = trim( substr( $Content, $ContentStart, $ContentEnd - $ContentStart + strlen( $EndTAG ) ) );
      } // for
      return $Results;
   }

   function createThemeFunctions()
   {
      $FunctionList = array();
      foreach ( $this->ThemeList as $Name => $ThemeData )
      {
         $FunctionVars = $ThemeData['Vars'];
         $Content = $ThemeData['Code'];

         $FunctionCode = '';
         $FunctionGlobals = array();
         $this->TabCount = 1;
         $HtmlOpen = true;

         while ( ( $StartPoint = $this->getFirstTAG( $Content ) ) !== false )
         {
            if ( $StartPoint == 0 )
            {
               if ( !preg_match( '/^' . $this->MatchTAG[$this->FirstTAG]['Find'] . '/i', $Content, $Match ) )
                  die( 'Template Tag Error: ' . $this->FirstTAG );

               if ( $this->FirstTAG == "THEME" )
               {
                  $SubThemes = $this->findExactTAGs( $Match[0], "THEME" );
                  foreach ( $SubThemes as $SubValue )
                  {
                     preg_match( "/^" . $this->MatchTAG['THEME']['Find'] . "$/i", $SubValue, $SubMatch );
                     $SubVars = array();
                     if ( trim( $SubMatch[3] ) != '' )
                     {
                        $tVars = explode( ',', $SubMatch[3] );
                        foreach ( $tVars as $vValue )
                        {
                           if ( preg_match( '/^\$?([a-z0-9_]+)=?(.*)$/i', trim( $vValue ), $vMatch ) )
                              $SubVars[$vMatch[1]] = "$" . $vMatch[1] . ( trim( $vMatch[2] ) != "" ? "=" . $vMatch[2] : "" );
                        }
                     }
                     $this->ThemeList[$SubMatch[1]] = array( 'Code' => $SubMatch[4], 'Vars' => $SubVars );

                     $Content = str_replace( $SubMatch[0], '<BIT>' . $SubMatch[1] . ( count( $SubVars ) ? "(" . implode( ',', $SubVars ) . ")" : "" ) . '</BIT>', $Content );
                  }
               }
               else
               {
                  if ( in_array( $this->FirstTAG, array( '/FE', '/FF', '/IF', '/ELIF', '/ELSE' ) ) )
                     $this->TabCount--;

                  if ( in_array( $this->FirstTAG, array( '/FE', '/FF' ) ) )
                     $this->TabCount--;

                  $Content = substr( $Content, strlen( $Match[0] ), strlen( $Content ) - strlen( $Match[0] ) );
                  if ( in_array( $this->FirstTAG, array( 'VAR', 'BIT', 'DEF', 'PHP' ) ) )
                  {
                     if ( $HtmlOpen )
                        $FunctionCode .= " . ";
                     else
                        $FunctionCode .= $this->addTab() . "\$_HTML .= ";
                     $HtmlOpen = true;
                  }
                  else
                  {
                     if ( $HtmlOpen )
                        $FunctionCode .= ";\r\n";

                     $FunctionCode .= $this->addTab();
                     $HtmlOpen = false;
                  }
                  $FunctionCode .= preg_replace( '/^' . $this->MatchTAG[$this->FirstTAG]['Find'] . '$/i', str_replace( '<!TabCount!>', $this->addTab(), $this->MatchTAG[$this->FirstTAG]['Replace'] ), $Match[0] );

                  if ( in_array( $this->FirstTAG, array( 'FE', 'FF', 'IF', 'ELIF', 'ELSE' ) ) )
                     $this->TabCount++;

                  if ( in_array( $this->FirstTAG, array( 'FE', 'FF' ) ) )
                     $this->TabCount++;

                  if ( in_array( $this->FirstTAG, array( 'IF', 'ELIF', 'PHP' ) ) )
                     $FunctionGlobals[] = $Match[1];

                  if ( in_array( $this->FirstTAG, array( 'FE', 'FF', 'VAR' ) ) )
                     $FunctionGlobals[] = "$" . $Match[1];
               }
            }
            else
            {
               if ( trim( $HtmlCode = substr( $Content, 0, $StartPoint ) ) != "" )
               {
                  if ( $HtmlOpen )
                     $FunctionCode .= " . ";
                  else
                     $FunctionCode .= $this->addTab() . "\$_HTML .= ";

                  $HtmlOpen = true;
                  $FunctionCode .= "'" . str_replace( "'", "\'", $HtmlCode ) . "'";
                  $Content = substr( $Content, strlen( $HtmlCode ), strlen( $Content ) - strlen( $HtmlCode ) );
               }
               else
                  $Content = ltrim( $Content );
            }
         }
         if ( trim( $Content ) != '' )
         {
            if ( $HtmlOpen )
               $FunctionCode .= " . ";
            else
               $FunctionCode .= $this->addTab() . "\$_HTML .= ";

            $HtmlOpen = true;
            $FunctionCode .= "'" . str_replace( "'", "\'", $Content ) . "'";
         }

         if ( $HtmlOpen )
            $FunctionCode .= ";\r\n";

         $Function = "function t_" . $Name . "(" . implode( ',', $FunctionVars ) . ")\r\n{\r\n";
         $Function .= $this->setGlobals( $FunctionGlobals, $FunctionVars );
         if ( substr( $FunctionCode, 0, 3 ) == " . " )
         {
            $Function .= "\t\$_HTML = ";
            $Function .= substr( $FunctionCode, 3, strlen( $FunctionCode )-3 ) ;
         }
         else
         {
            $Function .= "\t\$_HTML = ''";
            $Function .= $FunctionCode ;
         }
         $Function .= "\treturn \$_HTML;\r\n";
         $Function .= "}\r\n";

         $FunctionList[] = $Function;
      }
      return implode( "\r\n", $FunctionList );
   }

   function getFirstTAG( $Content, $Offset = 0 )
   {
      $FirstPosition = 999999;
      foreach ( $this->MatchTAG as $TagName => $TagArray )
      {
         if ( ( $Position = strpos( $Content, "<" . $TagName, $Offset ) ) !== false )
         {
            if ( $Position < $FirstPosition )
            {
               $FirstPosition = $Position;
               $this->FirstTAG = $TagName;
            }
         }
      }

      if ( $FirstPosition < 999999 )
         return $FirstPosition;
      else
         return false;
   }

   function addTab()
   {
      return str_repeat( "\t", $this->TabCount );
   }

   function setGlobals( $GlobalArray, $VarsArray = array() )
   {
      $Globals = array();
      foreach ( $GlobalArray as $Global )
      {
         preg_match( '/\$([a-z0-9_]+)/i', $Global, $Match );
         if ( !isset( $Globals[$Match[1]] ) AND !in_array( $Match[1], $this->PredefinedGlobals ) AND !isset( $VarsArray[$Match[1]] ) )
            $Globals[$Match[1]] = '$' . $Match[1];
      }
      if ( count( $Globals ) )
         return "\tglobal " . implode( ', ', $Globals ) . ";\r\n";
      else
         return "";
   }
}

?>

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.