Changeset 2117


Ignore:
Timestamp:
Oct 2, 2007, 7:38:54 AM (17 years ago)
Author:
rvelices
Message:
  • render_category_description and render_category_literal_description events refactoring
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_cats.inc.php

    r2095 r2117  
    216216  }
    217217
    218   // add default event handler for rendering category literal description
    219   add_event_handler('render_category_literal_description',
    220     create_function('$d',
    221       'return strip_tags($d, \'<a><br><p><b><i><small><strong><font>\');'));
    222 
    223218  trigger_action('loc_begin_index_category_thumbnails', $categories);
    224219  if ($conf['subcatify'])
  • trunk/include/common.inc.php

    r2111 r2117  
    172172
    173173// template instance
    174 if 
     174if
    175175  (
    176       defined('IN_ADMIN') and IN_ADMIN and 
     176      defined('IN_ADMIN') and IN_ADMIN and
    177177      isset($user['admin_template']) and
    178178      isset($user['admin_theme'])
     
    263263
    264264// default event handlers
     265add_event_handler('render_category_literal_description', 'render_category_literal_description');
     266add_event_handler('render_category_description', 'render_category_description');
    265267add_event_handler('render_comment_content', 'htmlspecialchars');
    266268add_event_handler('render_comment_content', 'parse_comment_content');
  • trunk/include/functions_category.inc.php

    r2070 r2117  
    157157    }
    158158  }
    159   global $conf;
    160   if ( !( $conf['allow_html_descriptions'] and
    161           preg_match('/<(div|br|img|script).*>/i', $cat['comment']) ) )
    162   {
    163     $cat['comment'] = nl2br(@$cat['comment']);
    164   }
    165159
    166160  $upper_ids = explode(',', $cat['uppercats']);
     
    449443      $cat_nb_images = 0;
    450444    }
    451    
     445
    452446    //at least one image direct or indirect
    453447    $display_text.= l10n_dec('image_available', 'images_available', $cat_count_images);
  • trunk/include/functions_html.inc.php

    r2070 r2117  
    5959  {
    6060    // Use MySql date in order to standardize all recent "actions/queries"
    61     list($page['get_icon_cache']['unix_timestamp']) = 
     61    list($page['get_icon_cache']['unix_timestamp']) =
    6262      mysql_fetch_array(pwg_query('select UNIX_TIMESTAMP(CURRENT_DATE)'));
    6363  }
     
    456456      $menu.= "\n".'<span class="';
    457457      // at least one image in this category -> class menuInfoCat
    458       $menu.= ($category['nb_images'] > 0 ? "menuInfoCat" 
     458      $menu.= ($category['nb_images'] > 0 ? "menuInfoCat"
    459459                                          : "menuInfoCatByChild").'"';
    460460      $menu.= ' title=" '.$title.'">';
     
    736736function set_span_class($count)
    737737{
    738   if ($count > 1) 
    739   { 
     738  if ($count > 1)
     739  {
    740740    return 'plural';
    741741  }
    742   return ( $count == 0 ) ? 'zero':'one';
     742  return ( $count == 0 ) ? 'zero':'one';
     743}
     744
     745/** returns the category comment for rendering in html.
     746 * this is an event handler. don't call directly
     747 */
     748function render_category_description($desc)
     749{
     750  global $conf;
     751  if ( !( $conf['allow_html_descriptions'] and
     752          preg_match('/<(div|br|img|script).*>/i', $desc) ) )
     753  {
     754    $desc = nl2br($desc);
     755  }
     756  return $desc;
     757}
     758
     759/** returns the category comment for rendering in html textual mode (subcatify)
     760 * this is an event handler. don't call directly
     761 */
     762function render_category_literal_description($desc)
     763{
     764  return strip_tags($desc, '<span><p><a><br><b><i><small><big><strong><em>');
    743765}
    744766?>
  • trunk/include/section_init.inc.php

    r1996 r2117  
    204204      $page,
    205205      array(
    206         'comment'           => $page['category']['comment'],
     206        'comment'           =>
     207            trigger_event(
     208              'render_category_description',
     209              $page['category']['comment']
     210            ),
    207211        'title'             =>
    208212          get_cat_display_name($page['category']['upper_names'], '', false),
     
    331335      $page,
    332336      array(
    333         'title' => $lang['search_result'],
     337        'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
     338                  .$lang['search_result'].'</a>',
    334339        )
    335340      );
     
    385390      $page,
    386391      array(
    387         'title' => '<a href="'.duplicate_index_url().'">'
     392        'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
    388393                  .$lang['recent_pics_cat'].'</a>',
    389394        'items' => array_from_query($query, 'id'),
     
    423428      $page,
    424429      array(
    425         'title' => '<a href="'.duplicate_index_url().'">'
     430        'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
    426431                  .$conf['top_number'].' '.$lang['most_visited_cat'].'</a>',
    427432        'items' => array_from_query($query, 'id'),
     
    449454      $page,
    450455      array(
    451         'title' => '<a href="'.duplicate_index_url().'">'
     456        'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
    452457                  .$conf['top_number'].' '.$lang['best_rated_cat'].'</a>',
    453458        'items' => array_from_query($query, 'id'),
     
    472477      $page,
    473478      array(
    474         'title' => '<a href="'.duplicate_index_url().'">'
     479        'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'
    475480                    .$lang['random_cat'].'</a>',
    476481        'items' => array_from_query($query, 'id'),
  • trunk/index.php

    r2114 r2117  
    297297    'cat_infos.comment',
    298298    array(
    299       'COMMENTS' =>
    300         trigger_event('render_category_description', $page['comment'])
     299      'COMMENTS' => $page['comment']
    301300      )
    302301    );
Note: See TracChangeset for help on using the changeset viewer.