Changeset 2643


Ignore:
Timestamp:
Oct 3, 2008, 11:55:14 AM (16 years ago)
Author:
patdenice
Message:
  • Add set_extents function in template class.
  • 752: add trigger (for flipflip).
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r2634 r2643  
    134134    return;
    135135  }
     136  trigger_action('begin_delete_elements', $ids);
    136137
    137138  // destruction of the comments on the image
  • trunk/include/template.class.php

    r2636 r2643  
    4444  var $files = array();
    4545
     46  // Template extents filenames for each template handle.
     47  var $extents = array();
     48
    4649  // used by html_head smarty block to add content before </head>
    4750  var $html_head_elements = array();
     
    7982
    8083    $this->set_template_dir($root);
     84
     85    if (isset($conf['extents_for_templates']))
     86    {
     87      $tpl_extents = unserialize($conf['extents_for_templates']);
     88      $this->set_extents($tpl_extents, './template-extension/', true);
     89    }
    8190  }
    8291
     
    133142  function set_filenames($filename_array)
    134143  {
    135     global $conf;
    136144    if (!is_array($filename_array))
    137145    {
     
    139147    }
    140148    reset($filename_array);
    141     $tpl_extension = isset($conf['extents_for_templates']) ?
    142       unserialize($conf['extents_for_templates']) : array();
    143149    while(list($handle, $filename) = each($filename_array))
    144150    {
    145151      if (is_null($filename))
    146         unset( $this->files[$handle] );
     152      {
     153        unset($this->files[$handle]);
     154      }
     155      elseif (isset($this->extents[$handle]))
     156      {
     157        $this->files[$handle] = $this->extents[$handle];
     158      }
    147159      else
    148160      {
    149161        $this->files[$handle] = $filename;
    150         foreach ($tpl_extension as $file => $conditions)
    151         {
    152           $localtpl = './template-extension/' . $file;
    153           if ($handle == $conditions[0] and
    154              (stripos(implode('/',array_flip($_GET)),$conditions[1])>0
    155               or $conditions[1] == 'N/A')
    156               and file_exists($localtpl))
    157           { /* examples: Are best_rated, created-monthly-calendar, list, ... set? */
    158               $this->files[$handle] = '../.' . $localtpl;
    159               /* assign their tpl-extension */
    160           }
    161         }
     162      }
     163    }
     164    return true;
     165  }
     166
     167  /**
     168   * Sets template extention filename for handles.
     169   */
     170  function set_extent($filename, $param, $dir='', $overwrite=true)
     171  {
     172    return $this->set_extents(array($filename => $param), $dir, $overwrite);
     173  }
     174
     175  /**
     176   * Sets template extentions filenames for handles.
     177   * $filename_array should be an hash of filename => array( handle, param) or filename => handle
     178   */
     179  function set_extents($filename_array, $dir='', $overwrite=true)
     180  {
     181    if (!is_array($filename_array))
     182    {
     183      return false;
     184    }
     185    foreach ($filename_array as $filename => $value)
     186    {
     187      if (is_array($value))
     188      {
     189        $handle = $value[0];
     190        $param = $value[1];
     191      }
     192      elseif (is_string($value))
     193      {
     194        $handle = $value;
     195        $param = 'N/A';
     196      }
     197      else
     198      {
     199        return false;
     200      }
     201
     202      if ((stripos(implode('/',array_flip($_GET)), $param) > 0 or $param == 'N/A')
     203        and (!isset($this->extents[$handle]) or $overwrite)
     204        and file_exists($dir . $filename))
     205      {
     206        $this->extents[$handle] = realpath($dir . $filename);
    162207      }
    163208    }
Note: See TracChangeset for help on using the changeset viewer.