You are here

function ckeditor_htmlbutton_load_all in CKEditor HTML Buttons (for WYSIWYG and CKEditor) 7

CKEditor load all buttons from the database.

5 calls to ckeditor_htmlbutton_load_all()
ckeditor_htmlbuttons_ckeditor_plugin in ./ckeditor_htmlbuttons.ckeditor.inc
Implements hook_ckeditor_plugin().
ckeditor_htmlbuttons_overview in ./ckeditor_htmlbuttons.admin.inc
CKEditor HTML Buttons overview page - view buttons and edit them.
ckeditor_htmlbuttons_wysiwyg_editor_settings_alter in ./ckeditor_htmlbuttons.wysiwyg.inc
Implements hook_wysiwyg_editor_settings_alter().
ckeditor_htmlbuttons_wysiwyg_plugin in ./ckeditor_htmlbuttons.wysiwyg.inc
Implements hook_wysiwyg_plugin().
_ckeditor_htmlbuttons_ckeditor_add_buttons_js in ./ckeditor_htmlbuttons.ckeditor.inc
Implements hook_init().

File

./ckeditor_htmlbuttons.module, line 125
Basic module file for CKEditor HTML Buttons.

Code

function ckeditor_htmlbutton_load_all() {
  global $base_url;
  $module_path = drupal_get_path('module', 'ckeditor_htmlbuttons');
  $button_results = db_query('SELECT * FROM {ckeditor_htmlbuttons}');
  $buttons = array();
  foreach ($button_results as $button) {

    // Get the icon.
    $icon = file_load($button->fid);
    if ($icon) {
      $icon_url = file_create_url($icon->uri);
      $icon_url = parse_url($icon_url, PHP_URL_PATH);
    }
    else {
      $icon_url = '';
    }
    $button_new = array(
      'title' => $button->title,
      // Because the original plugin prepends plugin path to icon and our
      // icons are in the files folder, we need to cd back to root.
      'icon' => str_repeat('../', count(explode('/', $module_path))) . '../..' . $icon_url,
      'icon_clean' => $icon_url,
      'html' => $button->html,
      'name' => $button->name,
    );
    $buttons[] = $button_new;
  }
  return $buttons;
}