render_rules

Versions
5
render_rules()

List the rules

Code

contributions/render/render.module, line 145

<?php
function render_rules() {
  $plugins = render_plugins();
  $rules   = render_get_rules();
  $renderdir = drupal_get_path('module', 'render');
  $header  = array(t('Plugin'), t('Rule Name'), t('CSS Selector'), t('Font'), t('Colors'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2));
  $rows    = array();
  $img_edit      = theme('image', $renderdir .'/images/editor.png');
  $img_duplicate = theme('image', $renderdir .'/images/copy.png');
  $img_delete    = theme('image', $renderdir .'/images/delete.png');
  foreach ($rules as $r) {
    $function = $r['plugin'] .'_render_rules';
    if (function_exists($function)) {
      $fontstyle = $function($r);
    }
    $color_names = array(
      'color' => t('Font color'),
      'linkcolor' => t('Link color'),
      'hovervolor' => t('Hover color'),
      'bgcolor' => t('Background color'),
    );
    $colors = '';
    foreach ($fontstyle['colors'] as $key => $color) {
      $colors .= '<div class="render-font-color" style="background-color: '. $color .';" title="'. $color_names[$key] .'"> </div>';
    }
    $operations = array(
      l($img_edit, 'admin/settings/render/edit/'. $r['rid'], array('title' => t('Edit'), 'class' => 'render-rule-op'), NULL, NULL, FALSE, TRUE),
      l($img_duplicate, 'admin/settings/render/duplicate/'. $r['rid'], array('title' => t('Duplicate'), 'class' => 'render-rule-op'), NULL, NULL, FALSE, TRUE),
      l($img_delete, 'admin/settings/render/rules/delete/'. $r['rid'], array('title' => t('Delete'), 'class' => 'render-rule-op'), NULL, NULL, FALSE, TRUE),
    );
    $rows[] = array(
      $plugins[$r['plugin']]['title'],
      $r['name'],
      $r['selector'],
      $fontstyle['font'],
      $colors,
      $r['weight'],
      implode('', $operations),
    );
  }
  $output .= theme_table($header, $rows, array('class' => 'render-rules'));
  $output .= '<p>';
  $output .= l(t('Add another rule'), 'admin/settings/render/addrule');
  $output .= '</p>';
  
  // Display logos of supported plugins.
  $output .= '<h4>'. t('Supported plugins') .'</h4>';
  $plugin_links = array();
  foreach ($plugins as $plugin) {
    $logo = $renderdir .'/plugins/'. $plugin['name'] .'.png';
    if (file_exists($logo)) {
      $plugin_links[] = l(theme('image', $logo, $plugin['title'], $plugin['title'], array()), $plugin['url'], array(), NULL, NULL, FALSE, TRUE);
    }
    else {
      $plugin_links[] = l($plugin['title'], $plugin['url']);
    }
  }
  $output .= implode(' | ', $plugin_links);
  
  drupal_add_css(drupal_get_path('module', 'render') .'/render.css', 'module', 'all', FALSE);
  
  return $output;
}
?>