Changeset 26424


Ignore:
Timestamp:
Jan 4, 2014, 11:53:28 AM (7 years ago)
Author:
mistic100
Message:

reorganize code, clean EOL, remove [img] (deprecated since 08/2012)

Location:
extensions/ExtendedDescription
Files:
4 added
2 deleted
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/ExtendedDescription/include/admin.inc.php

    r25201 r26424  
    11<?php
     2defined('EXTENDED_DESC_PATH') or die('Hacking attempt!');
    23
    3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 
    5 add_event_handler('get_popup_help_content', 'extended_desc_popup', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    6 add_event_handler('loc_begin_admin_page', 'add_ed_help');
    7 
     4/**
     5 * Add link to help popup
     6 */
    87function add_ed_help()
    98{
    109  global $page, $template;
    11  
     10
    1211  $target = null;
    1312  switch ($page['page'])
     
    3029      break;
    3130  }
    32  
     31
    3332  if (!empty($target))
    3433  {
     
    4241  global $template;
    4342  $themeconf = $template->get_template_vars('themeconf');
    44  
     43
    4544  $search = '</textarea>';
    4645  $add = '
    4746{combine_script id=\'core.scripts\' load=\'async\' path=\'themes/default/js/scripts.js\'}
    4847<a href="./admin/popuphelp.php?page=extended_desc" onclick="popuphelp(this.href); return false;" title="'.l10n('ExtendedDesc_help').'" style="vertical-align: middle; border: 0; margin: 0.5em;"><img src="'.$themeconf['admin_icon_dir'].'/help.png" class="button" alt="'.l10n('ExtendedDesc_help').'"></a>';
    49  
     48
    5049  return str_replace($search, $search.$add, $content);
    5150}
    5251
     52
     53/**
     54 * Display popup content
     55 */
    5356function  extended_desc_popup($help_content, $get)
    5457{
     
    5962  return $help_content;
    6063}
    61 
    62 
    63 ?>
  • extensions/ExtendedDescription/main.inc.php

    r26127 r26424  
    88*/
    99
    10 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     10defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
     11
    1112define('EXTENDED_DESC_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    12 load_language('plugin.lang', EXTENDED_DESC_PATH);
     13
    1314
    1415global $conf;
     
    2728
    2829
    29 // Traite les balises [lang=xx]
    30 function get_user_language_desc($desc, $user_lang=null)
    31 {
    32   global $user;
    33  
    34   if (is_null($user_lang))
    35   {
    36     $user_lang = $user['language'];
    37   }
    38 
    39   $small_user_lang = substr($user_lang, 0, 2);
    40 
    41   if (!preg_match('#\[lang=('.$user_lang.'|'.$small_user_lang.')\]#i', $desc))
    42   {
    43     $user_lang = 'default';
    44     $small_user_lang = 'default';
    45   }
    46 
    47   if (preg_match('#\[lang=('.$user_lang.'|'.$small_user_lang.')\]#i', $desc))
    48   {
    49     // la balise avec la langue de l'utilisateur a été trouvée
    50     $patterns[] = '#(^|\[/lang\])(.*?)(\[lang=(' . $user_lang . '|' . $small_user_lang . '|all)\]|$)#is';
    51     $replacements[] = '';
    52     $patterns[] = '#\[lang=(' . $user_lang . '|' . $small_user_lang . '|all)\](.*?)\[/lang\]#is';
    53     $replacements[] = '\\1';
    54   }
    55   else
    56   {
    57     // la balise avec la langue de l'utilisateur n'a pas été trouvée
    58     // On prend tout ce qui est hors balise
    59     $patterns[] = '#\[lang=all\](.*?)\[/lang\]#is';
    60     $replacements[] = '\\1';
    61     $patterns[] = '#\[lang=.*\].*\[/lang\]#is';
    62     $replacements[] = '';
    63   }
    64   return preg_replace($patterns, $replacements, $desc);
    65 }
    66 
    67 function get_user_language_tag_url($tag)
    68 {
    69   return get_user_language_desc($tag, get_default_language());
    70 }
    71 
    72 function ed_get_all_alt_names($arr, $name)
    73 {
    74   if (preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $name, $matches, PREG_SET_ORDER))
    75   {
    76     foreach ($matches as $match)
    77     {
    78       @$arr[$match[1]] .= $match[2];
    79     }
    80   }
    81   return $arr;
    82 }
    83 
    84 // Traite les autres balises
    85 function get_extended_desc($desc, $param='')
    86 {
    87   global $conf, $page;
    88  
    89   if (
    90     $param != 'subcatify_category_description'
    91     and $param != 'main_page_element_description'
    92     and ( script_basename() != 'picture' or $param != 'main_page_category_description' )
    93     and preg_match('#\[redirect (.*?)\]#i', $desc, $m1)
    94   )
    95   {
    96     if (preg_match('#^(img|cat|search)=(\d*)\.?(\d*|)$#i', $m1[1], $m2))
    97     {
    98       switch ($m2[1])
    99       {
    100         case 'img':
    101         $url_params = array('image_id' => $m2[2]);
    102         if (!empty($m2[3]))
    103         {
    104           $url_params['category'] = array('id' => $m2[3], 'name' => '', 'permalink' => '');
    105         }
    106         $url = rtrim(make_picture_url($url_params), '-');
    107         break;
    108 
    109         case 'cat':
    110         $url_params = array('category' => array('id' => $m2[2], 'name' => '', 'permalink' => ''));
    111         $url = rtrim(make_index_url($url_params), '-');
    112         break;
    113 
    114         case 'search':
    115         $url = make_index_url(array('section' => 'search', 'search' => $m2[2]));
    116       }
    117     }
    118     else
    119     {
    120       $url = $m1[1];
    121     }
    122     if (is_admin())
    123     {
    124       global $header_notes;
    125       $header_notes[] = sprintf(l10n('This category is redirected to %s'), '<a href="'.$url.'">'.$url.'</a>');
    126     }
    127     else
    128     {
    129       redirect($url);
    130     }
    131   }
    132 
    133   $desc = get_user_language_desc($desc);
    134 
    135   // Remove redirect tags for subcatify_category_description
    136   $patterns[] = '#\[redirect .*?\]#i';
    137   $replacements[] = '';
    138 
    139   // Balises [cat=xx]
    140   $patterns[] = '#\[cat=(\d*)\]#ie';
    141   $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_cat_thumb("$1")';
    142 
    143   // Balises [img=xx.yy,xx.yy,xx.yy;left|right|;name|titleName|]
    144   $patterns[] = '#\[img=([\d\s\.,]*);?(left|right|);?(name|titleName|)\]#ie';
    145   $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_img_thumb("$1", "$2", "$3")';
    146  
    147   // Balises [photo id=xx album=yy size=SQ|TH|XXS|XS|S|M|L|XL|XXL html=yes|no link=yes|no]
    148   $patterns[] = '#\[photo ([^\]]+)\]#ie';
    149   $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_photo_sized("$1")';
    150 
    151   // Balises [random album=xx size=SQ|TH|XXS|XS|S|M|L|XL|XXL html=yes|no link=yes|no]
    152   $patterns[] = '#\[random([^\]]*)\]#ie';
    153   $replacements[] = ($param == 'subcatify_category_description') ? '' : 'extdesc_get_random_photo("$1")';
    154  
    155   // Balises [slider album=xx nb_images=yy random=yes|no list=aa,bb,cc size=SQ|TH|XXS|XS|S|M|L|XL|XXL speed=z title=yes|no effect=... arrows=yes|no control=yes|no|thumb elastic=yes|no thumbs_size=xx]
    156   $patterns[] = '#\[slider ([^\]]+)\]#ie';
    157   $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_slider("$1")';
    158 
    159   // Balises <!--complete-->, <!--more--> et <!--up-down-->
    160   switch ($param)
    161   {
    162     case 'subcatify_category_description' :
    163       $patterns[] = '#^(.*?)('. preg_quote($conf['ExtendedDescription']['complete']) . '|' . preg_quote($conf['ExtendedDescription']['more']) . '|' . preg_quote($conf['ExtendedDescription']['up-down']) . ').*$#is';
    164       $replacements[] = '$1';
    165       $desc = preg_replace($patterns, $replacements, $desc);
    166       break;
    167 
    168     case 'main_page_category_description' :
    169       $patterns[] = '#^.*' . preg_quote($conf['ExtendedDescription']['complete']) . '|' . preg_quote($conf['ExtendedDescription']['more']) . '#is';
    170       $replacements[] = '';
    171       $desc = preg_replace($patterns, $replacements, $desc);
    172       if (substr_count($desc, $conf['ExtendedDescription']['up-down']))
    173       {
    174         list($desc, $conf['ExtendedDescription']['bottom_comment']) = explode($conf['ExtendedDescription']['up-down'], $desc);
    175         add_event_handler('loc_end_index', 'add_bottom_description');
    176       }
    177       break;
    178 
    179     default:
    180       $desc = preg_replace($patterns, $replacements, $desc);
    181   }
    182 
    183   return $desc;
    184 }
    185 
    186 function extended_desc_mail_group_assign_vars($assign_vars)
    187 {
    188   if (isset($assign_vars['CPL_CONTENT']))
    189   {
    190     $assign_vars['CPL_CONTENT'] = get_extended_desc($assign_vars['CPL_CONTENT']);
    191   }
    192   return $assign_vars;
    193 }
    194 
    195 // Add bottom description
    196 function add_bottom_description()
    197 {
    198   global $template, $conf;
    199   $template->concat('PLUGIN_INDEX_CONTENT_END', '
    200     <div class="additional_info">
    201     ' . $conf['ExtendedDescription']['bottom_comment'] . '
    202     </div>');
    203 }
    204 
    205 // Remove a category
    206 function ext_remove_cat($tpl_var)
    207 {
    208   global $conf;
    209 
    210   $i=0;
    211   while($i<count($tpl_var))
    212   {
    213     if (substr_count($tpl_var[$i]['NAME'], $conf['ExtendedDescription']['not_visible']))
    214     {
    215       array_splice($tpl_var, $i, 1);
    216     }
    217     else
    218     {
    219       $i++;
    220     }
    221   }
    222 
    223   return $tpl_var;
    224 }
    225 
    226 // Remove a category from menubar
    227 function ext_remove_menubar_cats($where)
    228 {
    229   global $conf;
    230 
    231   $query = 'SELECT id, uppercats
    232     FROM '.CATEGORIES_TABLE.'
    233     WHERE name LIKE "%'.$conf['ExtendedDescription']['mb_not_visible'].'%"';
    234 
    235   $result = pwg_query($query);
    236   while ($row = pwg_db_fetch_assoc($result))
    237   {
    238     $ids[] = $row['id'];
    239     $where .= '
    240       AND uppercats NOT LIKE "'.$row['uppercats'].',%"';
    241   }
    242   if (!empty($ids))
    243   {
    244     $where .= '
    245       AND id NOT IN ('.implode(',', $ids).')';
    246   }
    247   return $where;
    248 }
    249 
    250 // Remove an image
    251 function ext_remove_image($tpl_var, $pictures)
    252 {
    253   global $conf;
    254 
    255   $i=0;
    256   while($i<count($tpl_var))
    257   {
    258     if (substr_count($pictures[$i]['name'], $conf['ExtendedDescription']['not_visible']))
    259     {
    260       array_splice($tpl_var, $i, 1);
    261       array_splice($pictures, $i, 1);
    262     }
    263     else
    264     {
    265       $i++;
    266     }
    267   }
    268 
    269   return $tpl_var;
    270 }
    271 
    272 // Return html code for  caterogy thumb
    273 function get_cat_thumb($elem_id)
    274 {
    275   global $template, $user;
    276 
    277   $query = '
    278 SELECT
    279   cat.id,
    280   cat.name,
    281   cat.comment,
    282   cat.representative_picture_id,
    283   cat.permalink,
    284   uc.nb_images,
    285   uc.count_images,
    286   uc.count_categories,
    287   img.path
    288 FROM ' . CATEGORIES_TABLE . ' AS cat
    289   INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' as uc
    290     ON cat.id = uc.cat_id AND uc.user_id = '.$user['id'].'
    291   INNER JOIN ' . IMAGES_TABLE . ' AS img
    292     ON img.id = uc.user_representative_picture_id
    293 WHERE cat.id = ' . $elem_id . ';';
    294   $result = pwg_query($query);
    295 
    296   if($result and $category = pwg_db_fetch_assoc($result))
    297   {
    298     $template->set_filename('extended_description_content', dirname(__FILE__) . '/template/cat.tpl');
    299 
    300     $template->assign(
    301       array(
    302         'ID'    => $category['id'],
    303         'TN_SRC'   => DerivativeImage::thumb_url(array(
    304                                   'id' => $category['representative_picture_id'],
    305                                   'path' => $category['path'],
    306                                 )),
    307         'TN_ALT'   => strip_tags($category['name']),
    308         'URL'   => make_index_url(array('category' => $category)),
    309         'CAPTION_NB_IMAGES' => get_display_images_count
    310                                 (
    311                                   $category['nb_images'],
    312                                   $category['count_images'],
    313                                   $category['count_categories'],
    314                                   true,
    315                                   '<br />'
    316                                 ),
    317         'DESCRIPTION' =>
    318           trigger_event('render_category_literal_description',
    319             trigger_event('render_category_description',
    320               @$category['comment'],
    321               'subcatify_category_description')),
    322         'NAME'  => trigger_event(
    323                      'render_category_name',
    324                      $category['name'],
    325                      'subcatify_category_name'
    326                    ),
    327       )
    328     );
    329 
    330     return $template->parse('extended_description_content', true);
    331   }
    332   return '';
    333 }
    334 
    335 // Return html code for img thumb
    336 //function get_img_thumb($elem_id, $cat_id='', $align='', $name='')
    337 function get_img_thumb($elem_ids, $align='', $name='')
    338 {
    339   global $template;
    340 
    341   $ids=explode(" ",$elem_ids);
    342   $assoc = array();
    343   foreach($ids as $key=>$val)
    344   {
    345     list($a,$b)=array_pad(explode(".",$val),2,"");
    346     $assoc[$a] = $b;
    347   }
    348 
    349   $query = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id in (' . implode(',', array_keys($assoc)) . ');';
    350   $result = pwg_query($query);
    351 
    352   if($result)
    353   {
    354     $template->set_filename('extended_description_content', dirname(__FILE__) . '/template/img.tpl');
    355 
    356     $imglist=array();
    357     while ($picture = pwg_db_fetch_assoc($result))
    358     {
    359       $imglist[$picture["id"]]=$picture;
    360     }
    361 
    362     $img=array();
    363     foreach ($imglist as $id => $picture)
    364     {
    365       if (!empty($assoc[$id]))
    366       {
    367         $url = make_picture_url(array(
    368           'image_id' => $picture['id'],
    369           'category' => array(
    370             'id' => $assoc[$id],
    371             'name' => '',
    372             'permalink' => '')));
    373       }
    374       else
    375       {
    376         $url = make_picture_url(array('image_id' => $picture['id']));
    377       }
    378      
    379       $img[]=array(
    380           'ID'          => $picture['id'],
    381           'IMAGE'       => DerivativeImage::thumb_url($picture),
    382           'IMAGE_ALT'   => $picture['file'],
    383           'IMG_TITLE'   => ($name=="titleName")?htmlspecialchars($picture['name'], ENT_QUOTES):get_thumbnail_title($picture, $picture['name'], null),
    384           'U_IMG_LINK'  => $url,
    385           'LEGEND'      => ($name=="name")?$picture['name']:"",
    386           'COMMENT'     => $picture['file'],
    387           );
    388     }
    389    
    390     $template->assign('img', $img);
    391     $template->assign('FLOAT', !empty($align) ? 'float: ' . $align . ';' : '');
    392     return $template->parse('extended_description_content', true);
    393   }
    394   return '';
    395 }
    396 
    397 /**
    398  * Return html code for a photo
    399  *
    400  * @int    id:    picture id
    401  * @int    album: album to display picture in    (default: null)
    402  * @string size:  picture size                   (default: M)
    403  * @string html:  return complete html structure (default: yes)
    404  * @string link:  add a link to the picture      (default: yes)
    405  */
    406 function get_photo_sized($param)
    407 {
    408   global $template;
    409  
    410   $default_params = array(
    411     'id' =>    array('\d+', null),
    412     'album' => array('\d+', null),
    413     'size' =>  array('SQ|TH|XXS|XS|S|M|L|XL|XXL', 'M'),
    414     'html' =>  array('yes|no', 'yes'),
    415     'link' =>  array('yes|no', 'yes'),
    416     );
    417    
    418   $params = parse_parameters($param, $default_params);
    419  
    420   // check picture id
    421   if (empty($params['id'])) return 'missing picture id';
    422  
    423   // parameters
    424   $params['link'] = $params['link']=='no' ? false : true;
    425   $params['html'] = $params['html']=='no' ? false : true;
    426   $deriv_type = get_deriv_type($params['size']);
    427 
    428   // get picture
    429   $query = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = '.$params['id'].';';
    430   $result = pwg_query($query);
    431 
    432   if (pwg_db_num_rows($result))
    433   {
    434     $picture = pwg_db_fetch_assoc($result);
    435    
    436     // url
    437     if ($params['link'])
    438     {
    439       if (!empty($params['album']))
    440       {
    441         $query = '
    442 SELECT id, name, permalink
    443   FROM '.CATEGORIES_TABLE.'
    444   WHERE id = '.$params['album'].'
    445 ;';
    446         $category = pwg_db_fetch_assoc(pwg_query($query));
    447        
    448         $url = make_picture_url(array(
    449           'image_id' => $picture['id'],
    450           'category' => array(
    451             'id' => $category['id'],
    452             'name' => $category['name'],
    453             'permalink' => $category['permalink'],
    454             )));
    455       }
    456       else
    457       {
    458         $url = make_picture_url(array('image_id' => $picture['id']));
    459       }
    460     }
    461    
    462     // image
    463     $src_image = new SrcImage($picture);
    464     $derivatives = DerivativeImage::get_all($src_image);
    465     $selected_derivative = $derivatives[$deriv_type];
    466 
    467     $template->assign(array(
    468       'ed_image' => array(
    469         'selected_derivative' => $selected_derivative,
    470         'ALT_IMG' => $picture['file'],
    471       )));
    472 
    473     // output
    474     if ($params['html'])
    475     {
    476       $template->set_filename('extended_description_content', dirname(__FILE__).'/template/picture_content.tpl');
    477       $content = $template->parse('extended_description_content', true);
    478       if ($params['link']) return '<a href="'.$url.'">'.$content.'</a>';
    479       else                 return $content;
    480     }
    481     else
    482     {
    483       return $selected_derivative->get_url();
    484     }
    485   }
    486  
    487   return 'invalid picture id';
    488 }
    489 
    490 /**
    491  * Return html code for a random photo
    492  *
    493  * @int    album: select picture from this album (default: all)
    494  * @string size:  picture size                   (default: M)
    495  * @string html:  return complete html structure (default: yes)
    496  * @string link:  add a link to the picture      (default: no)
    497  */
    498 function extdesc_get_random_photo($param)
    499 {
    500   $default_params = array(
    501     'album' => array('\d+', null),
    502     'cat' =>   array('\d+', null), // historical
    503     'size' =>  array('SQ|TH|XXS|XS|S|M|L|XL|XXL', 'M'),
    504     'html' =>  array('yes|no', 'yes'),
    505     'link' =>  array('yes|no', 'no'),
    506     );
    507    
    508   $params = parse_parameters($param, $default_params);
    509  
    510   // check album id
    511   if ( empty($params['album']) and !empty($params['cat']) )
    512   {
    513     $params['album'] = $params['cat'];
    514   }
    515  
    516   // get picture id
    517   $query = '
    518 SELECT id, category_id
    519   FROM '.IMAGES_TABLE.'
    520     JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id';
    521   if (empty($params['album']))
    522   {
    523     $query = '
    524   WHERE 1=1 '
    525       .get_sql_condition_FandF(array(
    526         'forbidden_categories' => 'category_id',
    527         'visible_categories' => 'category_id',
    528         'visible_images' => 'id'
    529         ),
    530       'AND'
    531       );
    532   }
    533   else
    534   {
    535     $query.= '
    536   WHERE category_id = '.$params['album'];
    537   }
    538  
    539   $query.= '
    540   ORDER BY '.DB_RANDOM_FUNCTION.'()
    541   LIMIT 1
    542 ;';
    543   $result = pwg_query($query);
    544  
    545   if (pwg_db_num_rows($result))
    546   {
    547     list($params['id'], $params['album']) = pwg_db_fetch_row($result);
    548     return get_photo_sized($params);
    549   }
    550 
    551   return '';
    552 }
    553 
    554 /**
    555  * Return html code for a nivo slider (album or list is mandatory)
    556  *
    557  * @int    album:     select pictures from this album
    558  * @int    nb_images: display only x pictures           (default: 10)
    559  * @string random:    random sort order                 (default: no)
    560  *
    561  * @string list:      pictures id separated by a comma
    562  *
    563  * @string size:      picture size                      (default: M)
    564  * @int    speed:     slideshow duration                (default: 3)
    565  * @string title:     display picture name              (default: no)
    566  * @string effect:    transition effect                 (default: fade)
    567  * @string arrows:    display navigation arrows         (default: yes)
    568  * @string control:   display navigation bar            (default: yes)
    569  * @string elastic:   adapt slider size to each picture (default: yes)
    570  * @int thumbs_size:  size of thumbnails if control=thumb (default: 80)
    571  */
    572 function get_slider($param)
    573 {
    574   global $template, $conf;
    575  
    576   $default_params = array(
    577     'album' =>     array('\d+', null),
    578     'nb_images' => array('\d+', 10),
    579     'random' =>    array('yes|no', 'no'),
    580     'list' =>      array('[\d,]+', null),
    581     'size' =>      array('SQ|TH|XXS|XS|S|M|L|XL|XXL', 'M'),
    582     'speed' =>     array('\d+', 3),
    583     'title' =>     array('yes|no', 'no'),
    584     'effect' =>    array('[a-zA-Z]+', 'fade'),
    585     'arrows' =>    array('yes|no', 'yes'),
    586     'control' =>   array('yes|no|thumb', 'yes'),
    587     'elastic' =>   array('yes|no', 'yes'),
    588     'thumbs_size' => array('\d+', 80),
    589     );
    590    
    591   $params = parse_parameters($param, $default_params);
    592  
    593   // check size
    594   $deriv_type = get_deriv_type($params['size']);
    595   $enabled = ImageStdParams::get_defined_type_map();
    596   if (empty($enabled[ $deriv_type ]))
    597   {
    598     return '(nivoSlider) size disabled';
    599   }
    600  
    601   // parameters
    602   if ($params['control'] === 'thumb')
    603   {
    604     $params['control'] = 'yes';
    605     $params['control_thumbs'] = true;
    606   }
    607   else
    608   {
    609     $params['control_thumbs'] = false;
    610   }
    611   $params['arrows'] = $params['arrows']==='yes';
    612   $params['control'] = $params['control']==='yes';
    613   $params['elastic'] = $params['elastic']==='yes';
    614   $params['title'] = $params['title']==='yes';
    615   $params['random'] = $params['random']==='yes';
    616  
    617   $tpl_vars = $params;
    618  
    619   // pictures from album...
    620   if (!empty($params['album']))
    621   {
    622     // get image order inside category
    623     if ($params['random'])
    624     {
    625       $order_by = DB_RANDOM_FUNCTION.'()';
    626     }
    627     else
    628     {
    629       $query = '
    630 SELECT image_order
    631   FROM '.CATEGORIES_TABLE.'
    632   WHERE id = '.$params['album'].'
    633 ;';
    634       list($order_by) = pwg_db_fetch_row(pwg_query($query));
    635       if (empty($order_by))
    636       {
    637         $order_by = str_replace('ORDER BY ', null, $conf['order_by_inside_category']);
    638       }
    639     }
    640    
    641     // get pictures ids
    642     $query = '
    643 SELECT image_id
    644   FROM '.IMAGE_CATEGORY_TABLE.' as ic
    645     INNER JOIN '.IMAGES_TABLE.' as i
    646     ON i.id = ic.image_id
    647   WHERE category_id = '.$params['album'].'
    648   ORDER BY '.$order_by.'
    649   LIMIT '.$params['nb_images'].'
    650 ;';
    651     $ids = array_from_query($query, 'image_id');
    652     if (empty($ids))
    653     {
    654       return '(nivoSlider) no photos in album #'.$params['album'];
    655     }
    656     $ids = implode(',', $ids);
    657   }
    658   // ...or pictures list
    659   else if (empty($params['list']))
    660   {
    661     return '(nivoSlider) missing album id or photos list';
    662   }
    663   else
    664   {
    665     $ids = $params['list'];
    666   }
    667  
    668   // get pictures
    669   $query = '
    670 SELECT *
    671   FROM '.IMAGES_TABLE.'
    672   WHERE id IN ('.$ids.')
    673   ORDER BY FIND_IN_SET(id, "'.$ids.'")
    674 ;';
    675   $pictures = hash_from_query($query, 'id');
    676  
    677   foreach ($pictures as $row)
    678   {
    679     // url
    680     if (!empty($params['album']))
    681     {
    682       $url = make_picture_url(array(
    683         'image_id' => $row['id'],
    684         'category' => array(
    685           'id' => $params['album'],
    686           'name' => '',
    687           'permalink' => '',
    688           )));
    689     }
    690     else
    691     {
    692       $url = make_picture_url(array('image_id' => $row['id']));
    693     }
    694 
    695     $name = render_element_name($row);
    696    
    697     $tpl_vars['elements'][] = array(
    698       'ID' => $row['id'],
    699       'TN_ALT' => htmlspecialchars(strip_tags($name)),
    700       'NAME' => $name,
    701       'URL' => $url,
    702       'src_image' => new SrcImage($row),
    703       );
    704   }
    705  
    706   list($tpl_vars['img_size']['w'], $tpl_vars['img_size']['h']) =
    707     $enabled[ $deriv_type ]->sizing->ideal_size;
    708  
    709   $tpl_vars['id'] = crc32(uniqid($ids)); // need a unique id if we have multiple sliders
    710   $tpl_vars['derivative_params'] = ImageStdParams::get_by_type($deriv_type);
    711    
    712   if ($params['control_thumbs'])
    713   {
    714     $tpl_vars['derivative_params_thumb'] = ImageStdParams::get_custom(
    715       $params['thumbs_size'], $params['thumbs_size'], 1,
    716       $params['thumbs_size'], $params['thumbs_size']
    717       );
    718   }
    719  
    720   $template->assign(array(
    721     'EXTENDED_DESC_PATH' => EXTENDED_DESC_PATH,
    722     'SLIDER'=> $tpl_vars,
    723     ));
    724  
    725   $template->set_filename('extended_description_content', dirname(__FILE__).'/template/slider.tpl');
    726   return $template->parse('extended_description_content', true);
    727 }
    728 
    729 
    730 function parse_parameters($param, $default_params)
    731 {
    732   if (is_array($param))
    733   {
    734     return $param;
    735   }
    736  
    737   $params = array();
    738  
    739   foreach ($default_params as $name => $value)
    740   {
    741     if (preg_match('#'.$name.'=('.$value[0].')#', $param, $matches))
    742     {
    743       $params[$name] = $matches[1];
    744     }
    745     else
    746     {
    747       $params[$name] = $value[1];
    748     }
    749   }
    750  
    751   return $params;
    752 }
    753 
    754 function get_deriv_type($size)
    755 {
    756   $size = strtoupper($size);
    757  
    758   $size_map = array(
    759     'SQ' => IMG_SQUARE,
    760     'TH' => IMG_THUMB,
    761     'XXS' => IMG_XXSMALL,
    762     'XS' => IMG_XSMALL,
    763     'S' => IMG_SMALL,
    764     'M' => IMG_MEDIUM,
    765     'L' => IMG_LARGE,
    766     'XL' => IMG_XLARGE,
    767     'XXL' => IMG_XXLARGE,
    768     );
    769    
    770   if (!array_key_exists($size, $size_map)) $size = 'M';
    771  
    772   return $size_map[$size];
    773 }
    774 
     30include_once(EXTENDED_DESC_PATH . 'include/events.inc.php');
     31include_once(EXTENDED_DESC_PATH . 'include/functions.inc.php');
    77532
    77633if (script_basename() == 'admin' or script_basename() == 'popuphelp')
    77734{
    778   include(EXTENDED_DESC_PATH . 'admin.inc.php');
     35  include_once(EXTENDED_DESC_PATH . 'include/admin.inc.php');
     36
     37  add_event_handler('get_popup_help_content', 'extended_desc_popup', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     38  add_event_handler('loc_begin_admin_page', 'add_ed_help');
    77939}
     40
    78041
    78142// main
     
    79960add_event_handler ('loc_end_index_thumbnails',          'ext_remove_image', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    80061add_event_handler ('get_categories_menu_sql_where',     'ext_remove_menubar_cats');
    801 
    802 ?>
  • extensions/ExtendedDescription/template/cat.tpl

    r7138 r26424  
    11<ul class="thumbnailCategories">
    2         <li style="width: 99.5%;">
    3                 <div class="thumbnailCategory">
    4                         <div class="illustration">
    5                         <a href="{$URL}">
    6                                 <img src="{$TN_SRC}" alt="{$TN_ALT}" title="{'shows images at the root of this category'|@translate}">
    7                         </a>
    8                         </div>
    9                         <div class="description">
    10                                 <h3>
    11                                         <a href="{$URL}">{$NAME}</a>
    12                                 </h3>
     2  <li style="width: 99.5%;">
     3    <div class="thumbnailCategory">
     4      <div class="illustration">
     5      <a href="{$URL}">
     6        <img src="{$TN_SRC}" alt="{$TN_ALT}" title="{'shows images at the root of this category'|@translate}">
     7      </a>
     8      </div>
     9      <div class="description">
     10        <h3>
     11          <a href="{$URL}">{$NAME}</a>
     12        </h3>
    1313        <div class="text" style="text-align: left;">
    14                                 {if isset($INFO_DATES) }
    15                                 <p class="dates">{$INFO_DATES}</p>
    16                                 {/if}
    17                                 <p class="Nb_images">{$CAPTION_NB_IMAGES}</p>
    18                                 {if not empty($DESCRIPTION)}
    19                                 <p>{$DESCRIPTION}</p>
    20                                 {/if}
     14          {if isset($INFO_DATES) }
     15          <p class="dates">{$INFO_DATES}</p>
     16          {/if}
     17          <p class="Nb_images">{$CAPTION_NB_IMAGES}</p>
     18          {if not empty($DESCRIPTION)}
     19          <p>{$DESCRIPTION}</p>
     20          {/if}
    2121        </div>
    22                         </div>
    23                 </div>
    24         </li>
     22      </div>
     23    </div>
     24  </li>
    2525</ul>
  • extensions/ExtendedDescription/template/slider.tpl

    r26188 r26424  
    2727      {combine_script id='thumbnails.loader' path='themes/default/js/thumbnails.loader.js' require='jquery.ajaxmanager' load='footer'}
    2828    {/if}
    29    
     29
    3030    <img {if $derivative->is_cached()}src="{$derivative->get_url()}"{else}src="" data-src="{$derivative->get_url()}"{/if} alt="{$thumbnail.TN_ALT}" {$derivative->get_size_htm()} {if $show_title}title="<a href='{$thumbnail.URL}'>{$thumbnail.NAME|replace:'"':"'"}</a>"{/if} {if $SLIDER.control_thumbs}data-thumb="{$derivative_thumb}"{/if}>
    31    
     31
    3232    {assign var=derivative_size value=$derivative->get_size()}
    3333    {math assign=slider_full_width equation="max(x,y)" x=$slider_full_width y=$derivative_size[0]}
     
    4949(function($){ldelim}
    5050  var $slider = $("#slider{$SLIDER.id} .nivoSlider");
    51  
     51
    5252  $slider.nivoSlider({ldelim}
    5353    pauseTime: {$SLIDER.speed}*1000,
Note: See TracChangeset for help on using the changeset viewer.