Changeset 10617 for branches/2.2


Ignore:
Timestamp:
Apr 25, 2011, 9:08:43 PM (13 years ago)
Author:
rvelices
Message:

merge -r10516 from trunk combine_script - more checks and warnings...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/include/template.class.php

    r10504 r10617  
    923923  private $did_head;
    924924  private $head_done_scripts;
     925  private $did_footer;
    925926
    926927  private static $known_paths = array(
     
    947948    $this->inline_scripts = array();
    948949    $this->head_done_scripts = array();
    949     $this->did_head = false;
     950    $this->did_head = $this->did_footer = false;
    950951  }
    951952
     
    957958  function add_inline($code, $require)
    958959  {
     960    !$this->did_footer || trigger_error("Attempt to add inline script but the footer has been written", E_USER_WARNING);
    959961    if(!empty($require))
    960962    {
     
    973975  function add($id, $load_mode, $require, $path, $version=0)
    974976  {
    975     if ($this->did_head && $load_mode==0 )
    976     {
    977       trigger_error("Attempt to add a new script $id but the head has been written", E_USER_WARNING);
     977    if ($this->did_head && $load_mode==0)
     978    {
     979      trigger_error("Attempt to add script $id but the head has been written", E_USER_WARNING);
     980    }
     981    elseif ($this->did_footer)
     982    {
     983      trigger_error("Attempt to add script $id but the footer has been written", E_USER_WARNING);
    978984    }
    979985    if (! isset( $this->registered_scripts[$id] ) )
     
    982988      self::fill_well_known($id, $script);
    983989      $this->registered_scripts[$id] = $script;
     990
     991      // Load or modify all UI core files
     992      if ($id == 'jquery.ui' and $script->path == self::$known_paths['jquery.ui'])
     993      {
     994        foreach (self::$ui_core_dependencies as $script_id => $required_ids)
     995          $this->add($script_id, $load_mode, $required_ids, null, $version);
     996      }
     997
     998      // Try to load undefined required script
     999      foreach ($script->precedents as $script_id)
     1000      {
     1001        if (! isset( $this->registered_scripts[$script_id] ) )
     1002          $this->load_known_required_script($script_id, $load_mode);
     1003      }
    9841004    }
    9851005    else
    9861006    {
    987       $script = & $this->registered_scripts[$id];
     1007      $script = $this->registered_scripts[$id];
    9881008      if (count($require))
    9891009      {
     
    9961016        $script->load_mode = $load_mode;
    9971017    }
    998     // Load or modify all UI core files
    999     if ($id == 'jquery.ui' and $script->path == self::$known_paths['jquery.ui'])
    1000     {
    1001       foreach (self::$ui_core_dependencies as $script_id => $required_ids)
    1002         $this->add($script_id, $load_mode, $required_ids, null, $version);
    1003     }
    1004 
    1005     // Try to load undefined required script
    1006     foreach ($script->precedents as $script_id)
    1007     {
    1008       if (! isset( $this->registered_scripts[$script_id] ) )
    1009         $this->load_known_required_script($script_id, $load_mode);
    1010     }
     1018
    10111019  }
    10121020
     
    10411049  function get_footer_scripts()
    10421050  {
     1051    $this->did_head || trigger_error("Footer scripts before header scripts ?", E_USER_WARNING);
     1052    $this->did_footer = true;
    10431053    $todo = array();
    10441054    foreach( $this->registered_scripts as $id => $script)
     
    11021112      {
    11031113        $load = $script->load_mode;
    1104         /*if ($load==0)
    1105           continue;*/
    11061114        foreach( $script->precedents as $precedent)
    11071115        {
     
    11771185    }
    11781186    $recursion_limiter<5 or fatal_error("combined script circular dependency");
    1179     $script = & $this->registered_scripts[$script_id];
     1187    $script = $this->registered_scripts[$script_id];
    11801188    if (isset($script->extra['order']))
    11811189      return $script->extra['order'];
Note: See TracChangeset for help on using the changeset viewer.