Changeset 12154


Ignore:
Timestamp:
09/13/11 22:51:56 (8 years ago)
Author:
plg
Message:

add pattern [random album=xx]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ExtendedDescription/main.inc.php

    r10754 r12154  
    118118  $replacements[] = ($param == 'subcatify_category_description') ? '' : 'get_img_thumb("$1", "$2", "$3")'; 
    119119 
     120    // [random album=xx] 
     121    $patterns[] = '#\[random\s+(?:album|cat)=\s*?(\d+)\s*?\]#ie'; 
     122    $replacements[] = 'extdesc_get_random_photo("$1")'; 
    120123 
    121124  // Balises <!--complete-->, <!--more--> et <!--up-down--> 
     
    347350 
    348351 
     352function extdesc_get_random_photo($category_id) 
     353{ 
     354  $query = ' 
     355SELECT 
     356    path 
     357  FROM '.IMAGES_TABLE.' 
     358    JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id 
     359  WHERE category_id = '.$category_id.' 
     360  ORDER BY '.DB_RANDOM_FUNCTION.'() 
     361  LIMIT 1 
     362;'; 
     363  $result = pwg_query($query); 
     364  while ($row = pwg_db_fetch_assoc($result)) 
     365  { 
     366    return '<img src="'.$row['path'].'">'; 
     367  } 
     368 
     369  return ''; 
     370} 
     371 
    349372if (script_basename() == 'admin' or script_basename() == 'popuphelp') 
    350373{ 
Note: See TracChangeset for help on using the changeset viewer.