function patterns_list in Patterns 5
Same name and namespace in other branches
- 6.2 patterns.module \patterns_list()
- 6 patterns.module \patterns_list()
- 7.2 patterns.module \patterns_list()
- 7 patterns.module \patterns_list()
1 string reference to 'patterns_list'
- patterns_menu in ./
patterns.module - Implementation of hook_menu().
File
- ./
patterns.module, line 283 - Enables extremely simple adding/removing features to your site with minimal to no configuration
Code
function patterns_list() {
drupal_add_css(drupal_get_path('module', 'patterns') . '/patterns.css');
drupal_add_js(drupal_get_path('module', 'patterns') . '/patterns.js');
patterns_load();
$patterns = patterns_get_patterns();
if (empty($patterns)) {
return t('No patterns available.');
}
// $header = array(t('Title'), t('Status'), t('Version'), t('Public'), t('Actions'));
$header = array(
t('Title'),
t('Status'),
t('Version'),
t('Actions'),
);
// List all patterns
$rows = array();
foreach ($patterns as $pid => $pattern) {
$actions = array();
if (!$pattern->status) {
$actions[] = l(t('Run'), 'admin/build/patterns/enable/' . $pid);
}
else {
if ($pattern->enabled >= $pattern->updated) {
$actions[] = l(t('Re-Run'), 'admin/build/patterns/enable/' . $pid);
}
else {
$actions[] = l(t('Run Update'), 'admin/build/patterns/enable/' . $pid);
}
}
$actions[] = l(t('Edit'), 'admin/build/patterns/edit/' . $pid);
$actions = implode(' ', $actions);
$cells = array();
// $title = l($pattern->title, 'admin/build/patterns/info/'. $pid, array('class' => 'pattern-title', 'id' => 'pid-'. $pid));
$title = '<span id="pid-' . $pid . '" class="pattern-title">' . $pattern->title . '</span>';
// $view_more = '<div>'. t('Clik on pattern title to see more details.') .'</div>';
$info = array();
$info[] = t('Author: ') . $pattern->info['author'];
$info[] = t('Email: ') . $pattern->info['author_email'];
$info[] = t('Web: ') . $pattern->info['author_website'];
$author = theme('item_list', $info);
$title .= '<div id="pid-' . $pid . '-info" class="pattern-info">' . $author . $pattern->description . $view_more . '</div>';
$cells[] = $title;
$cells[] = $pattern->status ? t('Enabled') : t('Disabled');
$cells[] = $pattern->info['version'];
// $cells[] = $pattern->public ? t('Yes') : t('No');
$cells[] = $actions;
$category = $pattern->info['category'] ? $pattern->info['category'] : t('Other');
$rows[$category][] = $cells;
}
ksort($rows);
foreach ($rows as $title => $category) {
$fieldset = array(
'#title' => t($title),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#value' => theme('table', $header, $category),
);
$output .= theme('fieldset', $fieldset);
}
return $output;
}