You are here

function wysiwyg_template_overview in Wysiwyg API template plugin 7.2

Wysiwyg template overview page - view templates and edit them

1 string reference to 'wysiwyg_template_overview'
wysiwyg_template_menu in ./wysiwyg_template.module
Implementation of hook_menu().

File

./wysiwyg_template.admin.inc, line 11
Administrative page callbacks for the Wysiwyg Template module.

Code

function wysiwyg_template_overview($form, $form_state) {
  $templates = db_select('wysiwyg_templates', 't')
    ->fields('t')
    ->orderBy('t.weight')
    ->execute()
    ->fetchAll();
  $form['wysiwyg_templates'] = array(
    '#tree' => TRUE,
  );
  if (empty($templates)) {
    $form['info_empty'] = array(
      '#markup' => t('No templates available.') . ' ' . l(t('Add you first template.'), 'admin/config/content/wysiwyg-templates/add'),
      '#weight' => 10,
    );
  }
  else {
    $order = 0;
    foreach ($templates as $template) {
      $form['wysiwyg_templates'][$template->name]['#template'] = (object) array(
        'name' => $template->name,
        'title' => $template->title,
        'description' => $template->description,
        'weight' => $order,
        'content_types' => wysiwyg_template_load_template_content_types($template->name),
      );
      $form['wysiwyg_templates'][$template->name]['#weight'] = $order;
      $form['wysiwyg_templates'][$template->name]['weight'] = array(
        '#type' => 'textfield',
        '#title' => t('Weight for @title', array(
          '@title' => $template->title,
        )),
        '#title_display' => 'invisible',
        '#size' => 4,
        '#default_value' => $order,
        '#attributes' => array(
          'class' => array(
            'template-weight',
          ),
        ),
      );
      $order++;
    }
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save order'),
      '#submit' => array(
        'wysiwyg_template_overview_submit',
      ),
    );
  }
  return $form;
}