function wysiwyg_template_load_all in Wysiwyg API template plugin 7.2
Wysiwyg load all templates from the database
3 calls to wysiwyg_template_load_all()
- wysiwyg_template_features_export_options in ./
wysiwyg_template.features.inc - Implements hook_features_export_options().
- wysiwyg_template_form_node_type_form_alter in ./
wysiwyg_template.module - Implements hook_form_FORM_ID_alter().
- wysiwyg_template_list_js in ./
wysiwyg_template.module - Generate javascript for template loading
File
- ./
wysiwyg_template.module, line 363 - Makes TinyMCE Templates available as plugin for client-side editors integrated via Wysiwyg API.
Code
function wysiwyg_template_load_all($contentType = '_', $forSelect = FALSE, $includeNone = FALSE) {
global $base_url;
$templateResults = db_query("SELECT * FROM {wysiwyg_templates} order by weight");
$templates = array();
foreach ($templateResults as $dbTemplate) {
// Check, if the template is limited to a content type.
if ($contentType != '_') {
$types = db_select('wysiwyg_templates_content_types', 'wc')
->fields('wc', array(
'type',
))
->condition('wc.name', $dbTemplate->name)
->execute()
->fetchCol();
if (!empty($types)) {
// The template is limited and we now check it.
if (!in_array($contentType, $types)) {
// Do not include this template.
continue;
}
}
}
//get the image
$image = file_load($dbTemplate->fid);
if ($image) {
$image_uri = str_replace($base_url, "", image_style_url('wysiwyg_template_thumbnail', $image->uri));
}
else {
$image_uri = "";
}
$template = array(
'title' => $dbTemplate->title,
'description' => $dbTemplate->description,
'weight' => $dbTemplate->weight,
'image' => $image_uri,
'body' => token_replace($dbTemplate->body),
'format' => $dbTemplate->format,
'name' => $dbTemplate->name,
);
$templates[] = $template;
}
// provide a hook to prepare the templates
drupal_alter('wysiwyg_templates_load', $templates);
if (!$forSelect) {
return $templates;
}
$template_select = $includeNone ? array(
'' => '-' . t('none') . '-',
) : array();
foreach ($templates as $template) {
$template_select[$template['name']] = $template['title'];
}
return $template_select;
}