Get KoolPHP UI with 30% OFF!

KoolAjax Global Variables

ADavid Wulkan
I've posted this before but, did not get an answer. My environment has many applications that are in directories that are symbolic links off the DOCUMENT_ROOT. So, off the DOCUMENT_ROOT I have the KoolPHPSuite directory. I've set up a file named gvars.php (gloabl variabes) that is based on the /Resources/runexample.php file. But, with full paths so that any symbolically linked directory (application) can find the KoolControls.
[DOCUMENT_ROOT] = "/var/www"
gavrs.php looks like this:
<?php
error_reporting(E_ERROR);
ob_start();
session_start();
   //Global vars - NEVER end a directory variable's value with a slash!
   $rootFolder             = $_SERVER['DOCUMENT_ROOT'];         // /var/www
   $ks                     = "$rootFolder/KoolPHPSuite";   
   //$kc                     = "$rootFolder/KoolControls";   
   $kc                     = "$ks/KoolControls";   
   $KoolControlsFolder     = "$kc";
   $controlsURL            = "$kc";
   $cssURL                 = "$ks/Resources/css";
   $resourcesURL           = "$ks/Resources";
   //$rootURL                = "$kc/index.php";  //maybe not necessary ?
   $rootURL                = "$kc";  //maybe not necessary ?
   $xmlControls            = "$ks/controls.xml";
   $imgURL                 = "$ks/Resources/images";
//------------------------------------------------------------------------------------
// Maybe not necessary stuff?
   //$installURL             = "$ks/Install"; //maybe   //? maybe Not necessary
   //$controlImgUrl          = "$resourcesURL/Images";  //Capitol I only in Examples/control directory
   //$xmlNav                 = "$ks/Examples/navigation.xml";  //Only used in Examples/[controlname] directory
   //$navURL                 = "../.."; //In control directory - KoolSuiteMenu - maybe Not necessary
   //$xmlExample             = "example.xml";  //? maybe Not necessary
   //$example                = array();        //? maybe Not necessary
   
echo "        rootFolder= $rootFolder<br>";  //For interrogation
echo "                ks= $ks<br>";
echo "                kc= $kc<br>";
echo "KoolControlsFolder= $KoolControlsFolder<br>";
echo "           rootURL= $rootURL<br>";
echo "       xmlControls= $xmlControls<br>";
echo "       controlsURL= $controlsURL<br>";
echo "            cssURL= $cssURL<br>";
echo "            imgURL= $imgURL<br>";
echo "        installURL= $installURL<br>";
echo "     controlImgUrl= $controlImgUrl<br>";
   
   //$xmlOverview   = "../../overview.xml";  //In Examples/control directory - maybe Not necessary
   
//Maybe useful - keep
   //Check PHP version
   if(phpversion() < 5)
      header("Location: $resourcesURL/err.html");
      
   //load database infomation
   include($resourcesURL.'/config.php');
?> 

http://localhost/dwulkan/kool/treeview.php Code :
<?php
include "/var/www/KoolPHPSuite/gvars.php";
    require $KoolControlsFolder."/KoolAjax/koolajax.php";
    require $KoolControlsFolder."/KoolTreeGrid/kooltreegrid.php";
    $info = array(
        'id' => 'KoolTreeGrid1',
        'width' => '780px',
        'columns' => array(
            array(
                'field' => 'prop',
                'headerText' => 'Property',
                'width' => '250px',
            ),
            array(
                'field' => 'defaultValue',
                'headerText' => 'Default Value',
                'width' => '120px',
            ),
            array(
                'field' => 'value',
                'headerText' => 'Example Value',
                'width' => '120px',
                'columnEdit' => TRUE,
            ),
            array(
                'field' => 'type',
                'headerText' => 'Type',
                'width' => '50px',
            ),
            array(
                'field' => 'desc',
                'headerText' => 'Description',
            ),
        ),
        'rootIndent' => 20,
        'treeIndent' => 19,
    );
    
    $treeGrid = KoolTreeGrid::newTreeGrid($info);
    
    $rows = KoolTreeGrid::csvToArray('data.csv', ';');
    $metaField = 'meta';
    $rows = KoolTreeGrid::csvToArray('data.csv', ';');
    foreach ($rows as & $row) 
        foreach ($row as $field => & $value)
            if ($field===$metaField) 
                $value = json_decode($value, true);
    
    $treeGrid->addSetting(array(
        'ArrayData' => $rows,
        'idField' => 'id',
        'parentField' => 'parentId',
        'metaField' => $metaField,
    ));
    
    $treeGrid->process();
?>
 
<html><body>
<form id="form1" method="post">
    <?php 
        //Render Ajax functions for KoolTreeView
        echo $koolajax->Render();
    ?>
    <?php 
        echo $treeGrid->render();
    ?>
</form>
</body></html>

When I go to http://localhost/dwulkan/kool/treeview.php, I see this and no page?
rootFolder= /var/www
ks= /var/www/KoolPHPSuite
kc= /var/www/KoolPHPSuite/KoolControls
KoolControlsFolder= /var/www/KoolPHPSuite/KoolControls
rootURL= /var/www/KoolPHPSuite/KoolControls
xmlControls= /var/www/KoolPHPSuite/controls.xml
controlsURL= /var/www/KoolPHPSuite/KoolControls
cssURL= /var/www/KoolPHPSuite/Resources/css
imgURL= /var/www/KoolPHPSuite/Resources/images
installURL=
controlImgUrl= 

And when I view source, for some reason the AJAX src= is incorrect:
        rootFolder= /var/www<br>                ks= /var/www/KoolPHPSuite<br>                kc= /var/www/KoolPHPSuite/KoolControls<br>KoolControlsFolder= /var/www/KoolPHPSuite/KoolControls<br>           rootURL= /var/www/KoolPHPSuite/KoolControls<br>       xmlControls= /var/www/KoolPHPSuite/controls.xml<br>       controlsURL= /var/www/KoolPHPSuite/KoolControls<br>            cssURL= /var/www/KoolPHPSuite/Resources/css<br>            imgURL= /var/www/KoolPHPSuite/Resources/images<br>        installURL= <br>     controlImgUrl= <br>  
<html><body>
<form id="form1" method="post">
    
<!--KoolAjax version 3.0.0.0 - www.koolphp.net -->
<script type='text/javascript' src='oolControls/KoolAjax/koolajax.php?32981a13284db7a021131df49e6cd203'> </script>    

Why is the src= not picking up the full path?
Posted Nov 14, 2015 Kool