QFox2/Fox2.php
changeset 34 0e05a7ed0206
parent 33 fe2836c510cf
child 35 1d100abd8030
     1.1 --- a/QFox2/Fox2.php	Mon Dec 28 17:27:30 2009 +0600
     1.2 +++ b/QFox2/Fox2.php	Wed Dec 30 16:25:48 2009 +0600
     1.3 @@ -35,6 +35,7 @@
     1.4  {
     1.5      var $URL_temps;
     1.6      var $URL_domain = null;
     1.7 +    var $VIS_redefs = Array();
     1.8      var $err_traced = Array();
     1.9  
    1.10      function Fox2()
    1.11 @@ -143,7 +144,7 @@
    1.12          $QF->Events->Set_On_Event('VIS_PreParse',  Array(&$this, 'On_VIS_Prep') );
    1.13          $QF->Events->Set_On_Event('EJS_PreParse',  Array(&$this, 'On_EJS_Prep') );
    1.14          if ($QF->Config->Get('vis_redefined', 'fox2'))
    1.15 -            $QF->Events->Set_On_Event('VIS_module_start',  Array(&$this, '_VISUserMods_Preload') );
    1.16 +            $QF->Events->Set_On_Event('VIS_RawParse',  Array(&$this, '_VISUserMods_Add') );
    1.17  
    1.18          // running any autoruns from packages
    1.19          if ($ar_datas = $QF->DSets->Get_DSet('fox_autoruns'))
    1.20 @@ -705,9 +706,54 @@
    1.21          $indata = preg_replace_callback('#\{(?>(F|R)?URL:((?:\w+|\"[^\"]+\"|\|)+))\}#',Array(&$this, '_VISParse_URL_CB'),$indata);
    1.22      }
    1.23  
    1.24 -    function _VISUserMods_Preload()
    1.25 +    function _VISUserMods_Add(&$indata, $style, $part)
    1.26 +    {
    1.27 +        global $QF;
    1.28 +
    1.29 +        if (!isset($this->VIS_redefs[$style]) && !$this->_VISUserMods_Preload($style))
    1.30 +            return;
    1.31 +
    1.32 +        if (isset($this->VIS_redefs[$style]) && isset($this->VIS_redefs[$style][$part]))
    1.33 +            $indata.= $this->VIS_redefs[$style][$part];
    1.34 +    }
    1.35 +
    1.36 +    /*function _VISUserMods_Preload()
    1.37      {
    1.38         global $QF;
    1.39          $QF->VIS->Load_Templates('user_redefined');
    1.40 +    } */
    1.41 +
    1.42 +    function _VISUserMods_Preload($style)
    1.43 +    {
    1.44         global $QF;
    1.45 +        if (!$QF->Check_Module('VIS'))
    1.46 +            return false;
    1.47 +
    1.48 +        $style = strtolower($style);
    1.49 +        if (isset($this->VIS_redefs[$style]))
    1.50 +            return true;
    1.51 +
    1.52 +        $cachename = QF_KERNEL_VIS_VPREFIX.$style.'_redefs';
    1.53 +        $cfile = QF_STYLES_DIR.$style.'/redefined.vis';
    1.54 +        if ($data = $QF->Cache->Get($cachename))
    1.55 +            $this->VIS_redefs[$style] = $data;
    1.56 +        elseif ($data = qf_file_get_contents($cfile))
    1.57 +        {
    1.58             preg_match_all('#\<\<part \'(\w+)\'\>\>|[^\<]+|\<#', $data, $struct, PREG_SET_ORDER);
    1.59 +            $data = Array();
    1.60 +            $p_name = QF_KERNEL_VIS_COMMON;
    1.61 +            foreach ($struct as $part)
    1.62 +            {
    1.63 +                if ($part[1])
    1.64 +                    $p_name = strtolower($part[1]);
    1.65 +                elseif (isset($data[$p_name]))
    1.66 +                    $data[$p_name].= $part[0];
    1.67 +                else
    1.68 +                    $data[$p_name] = $part[0];
    1.69 +            }
    1.70 +            $QF->Cache->Set($cachename, $data);
    1.71 +            $this->VIS_redefs[$style] = $data;
    1.72 +            return true;
    1.73 +        }
    1.74 +        else
    1.75 +            return false;
    1.76      }
    1.77  
    1.78      function _VISParse_URL_CB($matches)