1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Contains template preprocess files for the add content modal themes.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Preprocess the primary entry level theme.
|
10 |
|
|
*/
|
11 |
|
|
function template_preprocess_panels_add_content_modal(&$vars) {
|
12 |
|
|
// Process the list of categories.
|
13 |
|
|
foreach ($vars['categories'] as $key => $category_info) {
|
14 |
|
|
// 'root' category is actually displayed under the categories, so
|
15 |
|
|
// skip it.
|
16 |
|
|
if ($key == 'root') {
|
17 |
|
|
continue;
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
$class = 'panels-modal-add-category';
|
21 |
|
|
if ($key == $vars['category']) {
|
22 |
|
|
$class .= ' active';
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
$url = $vars['renderer']->get_url('select-content', $vars['region'], $key);
|
26 |
|
|
$vars['categories_array'][] = ctools_ajax_text_button($category_info['title'], $url, '', $class);
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
// Now render the top level buttons (aka the root category) if any.
|
30 |
|
|
$vars['root_content'] = '';
|
31 |
|
|
if (!empty($vars['categories']['root'])) {
|
32 |
|
|
foreach ($vars['categories']['root']['content'] as $content_type) {
|
33 |
|
|
$vars['root_content'] .= theme('panels_add_content_link', array('renderer' => $vars['renderer'], 'region' => $vars['region'], 'content_type' => $content_type));
|
34 |
|
|
}
|
35 |
|
|
}
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
/**
|
39 |
|
|
* Process the panels add content modal.
|
40 |
|
|
*
|
41 |
|
|
* This is run here so that preprocess can make changes before links are
|
42 |
|
|
* actually rendered.
|
43 |
|
|
*/
|
44 |
|
|
function template_process_panels_add_content_modal(&$vars) {
|
45 |
|
|
$content = !empty($vars['categories'][$vars['category']]['content']) ? $vars['categories'][$vars['category']]['content'] : array();
|
46 |
|
|
|
47 |
|
|
// If no category is selected or the category is empty or our special empty
|
48 |
|
|
// category render a 'header' that will appear instead of the columns.
|
49 |
|
|
if (empty($vars['category']) || empty($content) || $vars['category'] == 'root') {
|
50 |
|
|
$vars['header'] = t('Content options are divided by category. Please select a category from the left to proceed.');
|
51 |
|
|
}
|
52 |
|
|
else {
|
53 |
|
|
$titles = array_keys($content);
|
54 |
|
|
natcasesort($titles);
|
55 |
|
|
|
56 |
|
|
// This will default to 2 columns in the theme definition but could be
|
57 |
|
|
// changed by a preprocess. Ensure there is at least one column.
|
58 |
|
|
$columns = max(1, $vars['column_count']);
|
59 |
|
|
$vars['columns'] = array_fill(1, $columns, '');
|
60 |
|
|
|
61 |
|
|
$col_size = count($titles) / $columns;
|
62 |
|
|
$count = 0;
|
63 |
|
|
foreach ($titles as $title) {
|
64 |
|
|
$which = floor($count++ / $col_size) + 1;
|
65 |
|
|
$vars['columns'][$which] .= theme('panels_add_content_link', array('renderer' => $vars['renderer'], 'region' => $vars['region'], 'content_type' => $content[$title]));
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
$vars['messages'] = theme('status_messages');
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
/**
|
73 |
|
|
* Preprocess the add content link used in the modal.
|
74 |
|
|
*/
|
75 |
|
|
function template_preprocess_panels_add_content_link(&$vars) {
|
76 |
|
|
$vars['title'] = filter_xss_admin($vars['content_type']['title']);
|
77 |
|
|
$vars['description'] = isset($vars['content_type']['description']) ? $vars['content_type']['description'] : $vars['title'];
|
78 |
|
|
$vars['icon'] = ctools_content_admin_icon($vars['content_type']);
|
79 |
|
|
$vars['url'] = $vars['renderer']->get_url('add-pane', $vars['region'], $vars['content_type']['type_name'], $vars['content_type']['subtype_name']);
|
80 |
e4c061ad
|
Assos Assos
|
$subtype_class = 'add-content-link-' . str_replace('_', '-', $vars['content_type']['subtype_name']);
|
81 |
|
|
$vars['image_button'] = ctools_ajax_image_button($vars['icon'], $vars['url'], $vars['description'], $subtype_class . '-image-button panels-modal-add-config');
|
82 |
|
|
$vars['text_button'] = ctools_ajax_text_button($vars['title'], $vars['url'], $vars['description'], $subtype_class . '-text-button panels-modal-add-config');
|
83 |
|
|
if (function_exists('ctools_ajax_icon_text_button')) {
|
84 |
|
|
$vars['icon_text_button'] = ctools_ajax_icon_text_button($vars['title'], $vars['icon'], $vars['url'], $vars['description'], $subtype_class . '-icon-text-button panels-modal-add-config');
|
85 |
|
|
}
|
86 |
85ad3d82
|
Assos Assos
|
} |