Ignore:
Timestamp:
Jan 24, 2012, 8:24:47 PM (12 years ago)
Author:
rvelices
Message:

feature 2548 multisize

  • added define_derivative template functiion for themes and plugins
  • code cleanup, new events ...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r12922 r12954  
    2929include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    3030
     31
     32// get_complete_dir returns the concatenation of get_site_url and
     33// get_local_dir
     34// Example : "pets > rex > 1_year_old" is on the the same site as the
     35// Piwigo files and this category has 22 for identifier
     36// get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/"
     37function get_complete_dir( $category_id )
     38{
     39  return get_site_url($category_id).get_local_dir($category_id);
     40}
     41
     42// get_local_dir returns an array with complete path without the site url
     43// Example : "pets > rex > 1_year_old" is on the the same site as the
     44// Piwigo files and this category has 22 for identifier
     45// get_local_dir(22) returns "pets/rex/1_year_old/"
     46function get_local_dir( $category_id )
     47{
     48  global $page;
     49
     50  $uppercats = '';
     51  $local_dir = '';
     52
     53  if ( isset( $page['plain_structure'][$category_id]['uppercats'] ) )
     54  {
     55    $uppercats = $page['plain_structure'][$category_id]['uppercats'];
     56  }
     57  else
     58  {
     59    $query = 'SELECT uppercats';
     60    $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id;
     61    $query.= ';';
     62    $row = pwg_db_fetch_assoc( pwg_query( $query ) );
     63    $uppercats = $row['uppercats'];
     64  }
     65
     66  $upper_array = explode( ',', $uppercats );
     67
     68  $database_dirs = array();
     69  $query = 'SELECT id,dir';
     70  $query.= ' FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$uppercats.')';
     71  $query.= ';';
     72  $result = pwg_query( $query );
     73  while( $row = pwg_db_fetch_assoc( $result ) )
     74  {
     75    $database_dirs[$row['id']] = $row['dir'];
     76  }
     77  foreach ($upper_array as $id)
     78  {
     79    $local_dir.= $database_dirs[$id].'/';
     80  }
     81
     82  return $local_dir;
     83}
     84
     85// retrieving the site url : "http://domain.com/gallery/" or
     86// simply "./galleries/"
     87function get_site_url($category_id)
     88{
     89  global $page;
     90
     91  $query = '
     92SELECT galleries_url
     93  FROM '.SITES_TABLE.' AS s,'.CATEGORIES_TABLE.' AS c
     94  WHERE s.id = c.site_id
     95    AND c.id = '.$category_id.'
     96;';
     97  $row = pwg_db_fetch_assoc(pwg_query($query));
     98  return $row['galleries_url'];
     99}
     100
    31101// +-----------------------------------------------------------------------+
    32102// | Check Access and exit when user status is not ok                      |
Note: See TracChangeset for help on using the changeset viewer.