Commit 74585b57 authored by merlinofchaos's avatar merlinofchaos
Browse files

Patch to sync with HEAD; only did a cursory scan but seems to be working.

parent 53b755c5
......@@ -377,7 +377,7 @@ function views_handler_field_nodelink_with_mark($fieldinfo, $fielddata, $value,
* Format a field as a node type.
*/
function views_handler_nodetype($fieldinfo, $fielddata, $value, $data) {
return node_get_name($value);
return node_get_types('name', $value);
}
/*
......@@ -385,7 +385,7 @@ function views_handler_nodetype($fieldinfo, $fielddata, $value, $data) {
*/
function views_handler_comments_with_new($fieldinfo, $fielddata, $value, $data) {
$comments = intval($value);
if (module_exist('comment') && $comments && $new = comment_num_new($data->nid)) {
if (module_exists('comment') && $comments && $new = comment_num_new($data->nid)) {
$comments .= '<br />';
$comments .= l(t('%num new', array('%num' => $new)), "node/$data->nid", NULL, NULL, 'new');
}
......@@ -447,9 +447,9 @@ function views_handler_arg_nodetype($op, &$query, $argtype, $arg = '') {
$query->add_where("node.type = '%s'", $where);
break;
case 'link':
return l(node_get_name($query->type), "$arg/$query->type");
return l(node_get_types('name', $query->type), "$arg/$query->type");
case 'title':
$title = node_get_name($query);
$title = node_get_types('name', $query);
return $title ? $title : check_plain($query);
}
}
......@@ -634,7 +634,7 @@ function views_handler_filter_isnew($op, $filter, $filterinfo, &$query) {
$limit = NODE_NEW_LIMIT;
$query->ensure_table('history');
if (module_exist('comment')) {
if (module_exists('comment')) {
$query->ensure_table('node_comment_statistics');
$clause = "OR node_comment_statistics.last_comment_timestamp > $limit";
$clause2 = "OR history.timestamp < node_comment_statistics.last_comment_timestamp";
......
......@@ -6,7 +6,7 @@
*/
function taxonomy_views_tables() {
if (module_exist('taxonomy')) {
if (module_exists('taxonomy')) {
$table = views_new_table('term_node', 'internal', 'node', 'nid', 'nid');
views_table_add_field($table, 'name', 'Taxonomy: All Terms', 'This will display all taxonomy terms associated with the node. Note that this causes one extra query per row displayed, and might have a minor performance impact.', array(
'sortable' => false,
......
......@@ -338,7 +338,7 @@ function views_handler_filter_usercurrent_custom($op, $filter, $filterinfo, &$qu
* Add special info to see if a user either authored OR commented on a post
*/
function views_handler_filter_uid_touched($op, $filter, $filterinfo, &$query) {
if (!module_exist('comment')) { // not much to do in this case
if (!module_exists('comment')) { // not much to do in this case
$query->add_where("node.uid = '%s'", $filter['value']);
return;
}
......
......@@ -14,7 +14,7 @@ function views_init() {
foreach($files as $file) {
// The filename format is very specific. It must be views_MODULENAME.inc
$module = substr_replace($file->name, '', 0, 6);
if (module_exist($module)) {
if (module_exists($module)) {
require_once("./$file->filename");
}
}
......@@ -33,7 +33,7 @@ function _views_get_arguments($titles = false) {
global $locale;
if (!$views_arguments) {
$data = cache_get("views_arguments:$locale");
$data = cache_get("views_arguments:$locale", 'cache');
$cache = unserialize($data->data);
if (is_array($cache)) {
$views_arguments = $cache;
......@@ -53,7 +53,7 @@ function _views_get_arguments($titles = false) {
$views_arguments['title'][$name] = $arg;
}
$cache = $views_arguments;
cache_set("views_arguments:$locale", serialize($cache));
cache_set("views_arguments:$locale", 'cache', serialize($cache));
}
}
return ($titles ? $views_arguments['base'] : $views_arguments['title']);
......@@ -68,7 +68,7 @@ function _views_get_tables($full = false) {
global $locale;
if (!$views_tables) {
$data = cache_get("views_tables:$locale");
$data = cache_get("views_tables:$locale", 'cache');
$cache = unserialize($data->data);
if (is_array($cache)) {
......@@ -135,7 +135,7 @@ function _views_get_tables($full = false) {
}
}
}
cache_set("views_tables:$locale", serialize($views_tables));
cache_set("views_tables:$locale", 'cache', serialize($views_tables));
}
}
return ($full ? $views_tables : $views_tables['tables']);
......@@ -172,7 +172,7 @@ function _views_get_sorts($titles = false) {
* Invalidate the views cache, forcing a rebuild on the next grab of table data.
*/
function views_invalidate_cache() {
cache_clear_all('views_', true);
cache_clear_all('views_', 'cache', true);
}
/**
......@@ -222,7 +222,7 @@ function _views_get_default_views() {
global $locale;
if (!$views_default_views) {
$data = cache_get("views_default_views:$locale");
$data = cache_get("views_default_views:$locale", 'cache');
$cache = unserialize($data->data);
if (is_array($cache)) {
......@@ -240,7 +240,7 @@ function _views_get_default_views() {
$views_default_views[$i] = $view;
}
}
cache_set("views_default_views:$locale", serialize($views_default_views));
cache_set("views_default_views:$locale", 'cache', serialize($views_default_views));
}
}
return $views_default_views;
......@@ -256,7 +256,7 @@ function _views_get_style_plugins($titles = false) {
global $locale;
if (!$views_style_plugins) {
$data = cache_get("views_style_plugins:$locale");
$data = cache_get("views_style_plugins:$locale", 'cache');
$cache = unserialize($data->data);
if (is_array($cache)) {
$views_style_plugins = $cache;
......@@ -271,7 +271,7 @@ function _views_get_style_plugins($titles = false) {
$views_style_plugins['base'][$name] = $arg;
}
$cache = $views_style_plugins;
cache_set("views_style_plugins:$locale", serialize($cache));
cache_set("views_style_plugins:$locale", 'cache', serialize($cache));
}
}
return ($titles ? $views_style_plugins['title'] : $views_style_plugins['base']);
......@@ -286,7 +286,6 @@ function _views_get_style_plugins($titles = false) {
function views_help($section) {
switch ($section) {
case 'admin/help#views':
case 'admin/modules#description':
return t('The views module creates customized views of node lists.');
}
}
......@@ -340,10 +339,10 @@ function views_menu($may_cache) {
_views_create_menu_item($items, $view, $view->url);
}
}
cache_set("views_with_inline_args:$locale", serialize($views_with_inline_args));
cache_set("views_with_inline_args:$locale", 'cache', serialize($views_with_inline_args));
}
else {
$data = cache_get("views_with_inline_args:$locale");
$data = cache_get("views_with_inline_args:$locale", 'cache');
$views = unserialize($data->data);
if (is_array($views)) {
foreach ($views as $view) {
......@@ -1401,14 +1400,14 @@ function theme_views_filters($form) {
$view = $form['view']['#value'];
foreach ($view->exposed_filter as $count => $expose) {
$row[] = form_render($form["op$count"]) . form_render($form["filter$count"]);
$row[] = drupal_render($form["op$count"]) . drupal_render($form["filter$count"]);
$label[] = $expose['label'];
}
$row[] = form_render($form['submit']);
$row[] = drupal_render($form['submit']);
$label[] = ''; // so the column count is the same.
// make the 'q' come first
return form_render($form['q']) . theme('table', $label, array($row)) . form_render($form);
return drupal_render($form['q']) . theme('table', $label, array($row)) . drupal_render($form);
}
/**
......
<?php
// $Id$
function views_rss_help($section = 'admin/help#views_rss') {
$output = '';
switch ($section) {
case 'admin/modules#description':
return t('RSS plugin for the views feed selector argument.');
}
}
/**
* Provide views plugins for the feed types we support.
*/
......
<?php
// $Id$
function views_theme_wizard_help($section = 'admin/help#views_theme_wizard') {
$output = '';
switch ($section) {
case 'admin/modules#description':
return t('The views theme wizard helps create stub theming for views.');
}
}
function views_theme_wizard_menu($may_cache) {
if ($may_cache) {
$items[] = array(
'path' => 'admin/views/wizard',
'path' => 'admin/build/views/wizard',
'access' => user_access('administer views'),
'title' => t('theme wizard'),
'callback' => 'views_theme_wizard_page',
......@@ -37,7 +29,10 @@ function views_theme_wizard_page() {
$views[$view->name] = check_plain($view->name . ': ' . $view->description);
}
}
return drupal_get_form('views_theme_wizard_form', $views);
}
function views_theme_wizard_form($views) {
$form['markup'] = array(
'#value' => t('<p>The views theming wizard generates code that you can use in your phptemplate theme to help you customize the output of a view. Simply select a theme and it will generate code for your template.php as well as template files for the individual views.</p><p>At this time this code assumes your view is a <b>list type view</b>! It may not generate effective code for other types of views. Future versions of this program will be smarter, and give more options, but this wizard is still a huge start.</p>'),
'#weight' => 0,
......@@ -75,7 +70,7 @@ function views_theme_wizard_page() {
$form['#after_build'] = array(
'views_theme_wizard_generate',
);
return drupal_get_form('views_theme_wizard_form', $form);
return $form;
}
function views_theme_wizard_generate($form, $form_values) {
......
......@@ -11,18 +11,16 @@ function views_ui_help($section) {
switch ($section) {
case 'admin/help#views_ui':
return _views_ui_help_add();
case 'admin/modules#description':
return t('The views module creates customized views of node lists.');
case 'admin/views/import':
case 'admin/build/views/import':
return t('You may import a view by cut-and-pasting the results of an export view. If the import is successful you will be taken to the Add View page with all of the settings of the imported view..');
case 'admin/views':
case 'admin/build/views':
return t('This screen shows all of the views that are currently defined in your system. The default views are provided by Views and other modules and are automatically available. If a customized view of the same name exists, it will be used in place of a default view.');
}
if (!strncmp($section, 'admin/views', 11)) {
if (!strncmp($section, 'admin/build/views', 11)) {
switch (arg(2)) {
case 'add':
case 'edit':
return t('Please see %s or the views documentation on drupal.org for help here.', array('%s' => l(t('the views help page'), 'admin/help/views_ui')));
return t('Please see !s or the views documentation on drupal.org for help here.', array('!s' => l(t('the views help page'), 'admin/help/views_ui')));
case 'export':
return t('You may cut & paste this view into an import function on another system. The view will only work if all modules required by the view are installed on the target location.');
}
......@@ -93,52 +91,55 @@ function views_ui_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'admin/views',
$items[] = array('path' => 'admin/build/views',
'title' => t('views'),
'callback' => 'views_ui_admin_page',
'access' => user_access('administer views'),
'description' => t('Views are customized lists of content on your system; they are highly configurable and give you control over how lists of content are presented.'),
'type' => MENU_NORMAL_ITEM);
$items[] = array('path' => 'admin/views/list',
$items[] = array('path' => 'admin/build/views/list',
'title' => t('list'),
'callback' => 'views_ui_admin_page',
'access' => user_access('administer views'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => '-1');
$items[] = array('path' => 'admin/views/add',
$items[] = array('path' => 'admin/build/views/add',
'title' => t('add'),
'callback' => 'views_ui_admin_add_page',
'access' => user_access('administer views'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/views/clone',
$items[] = array('path' => 'admin/build/views/clone',
'title' => t('clone'),
'callback' => 'views_ui_admin_clone_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/edit',
$items[] = array('path' => 'admin/build/views/edit',
'title' => t('edit view'),
'callback' => 'views_ui_admin_edit_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/import',
$items[] = array('path' => 'admin/build/views/import',
'title' => t('import'),
'callback' => 'views_ui_admin_import_page',
'access' => user_access('administer views'),
'type' => MENU_LOCAL_TASK);
$items[] = array('path' => 'admin/views/export',
$items[] = array('path' => 'admin/build/views/export',
'title' => t('export view'),
'callback' => 'views_ui_admin_export_page',
'callback' => 'drupal_get_form',
'callback arguments' => 'views_ui_admin_export_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/delete',
$items[] = array('path' => 'admin/build/views/delete',
'title' => t('edit view'),
'callback' => 'views_ui_admin_delete_page',
'callback' => 'drupal_get_form',
'callback arguments' => 'views_ui_admin_delete_confirm',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/enable',
$items[] = array('path' => 'admin/build/views/enable',
'callback' => 'views_ui_admin_enable_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
$items[] = array('path' => 'admin/views/disable',
$items[] = array('path' => 'admin/build/views/disable',
'callback' => 'views_ui_admin_disable_page',
'access' => user_access('administer views'),
'type' => MENU_CALLBACK);
......@@ -208,10 +209,10 @@ function views_ui_admin_page() {
implode(', ', $provides),
$url,
theme('links', array(
l(t('edit'), "admin/views/edit/$view->vid"),
l(t('export'), "admin/views/export/$view->vid"),
l(t('delete'), "admin/views/delete/$view->vid"),
l(t('clone'), "admin/views/clone/$view->vid"),
array('title' => t('edit'), 'href' => "admin/build/views/edit/$view->vid"),
array('title' => t('export'), 'href' => "admin/build/views/export/$view->vid"),
array('title' => t('delete'), 'href' => "admin/build/views/delete/$view->vid"),
array('title' => t('clone'), 'href' => "admin/build/views/clone/$view->vid"),
))
);
}
......@@ -267,12 +268,13 @@ function views_ui_admin_page() {
$provides[] = t('Menu');
}
$links = array(l(t('add'), "admin/views/add/$view->name"));
$links = array();
$links[] = array('title' => t('add'), 'href' => "admin/build/views/add/$view->name");
if ($status == t('Enabled')) {
$links[] = l(t('disable'), "admin/views/disable/$view->name");
$links[] = array('title' => t('disable'), 'href' => "admin/build/views/disable/$view->name");
}
else if ($status == t('Disabled')) {
$links[] = l(t('enable'), "admin/views/enable/$view->name");
$links[] = array('title' => t('enable'), 'href' => "admin/build/views/enable/$view->name");
}
$items[] = array($view->name, views_get_title($view, 'menu'), $view->description, implode(', ', $provides), $url, $status, theme('links', $links));
......@@ -298,7 +300,7 @@ function views_ui_admin_enable_page($view = '') {
variable_set('views_defaults', $views_status);
menu_rebuild();
}
drupal_goto('admin/views');
drupal_goto('admin/build/views');
}
/*
......@@ -311,7 +313,7 @@ function views_ui_admin_disable_page($view = '') {
variable_set('views_defaults', $views_status);
menu_rebuild();
}
drupal_goto('admin/views');
drupal_goto('admin/build/views');
}
/*
......@@ -324,6 +326,11 @@ function views_ui_admin_import_page() {
return views_ui_admin_add_page();
}
drupal_set_title("Import a View");
return drupal_get_form('views_ui_admin_import', $form);
}
function views_ui_admin_import() {
$form['view'] = array(
'#type' => 'textarea',
'#title' => t('Import View Code'),
......@@ -337,13 +344,13 @@ function views_ui_admin_import_page() {
'#value' => t("Submit"),
);
return drupal_get_form('views_import_view', $form);
return $form;
}
/*
* Handle the submit button on importing a view.
*/
function views_import_view_submit($formid, $form) {
function views_ui_admin_import_submit($formid, $form) {
ob_start();
eval($form['view']);
ob_end_clean();
......@@ -353,9 +360,7 @@ function views_import_view_submit($formid, $form) {
if (!is_array($view->requires) || !array_diff($view->requires, $tables)) {
views_sanitize_view($view);
drupal_set_title(t('Add a View'));
$output = _views_view_form($view, NULL);
print theme('page', $output);
exit;
return drupal_get_form('views_edit_view', $view, NULL);
}
else {
drupal_set_message(t("You don't seem to have the following requirements: ") . implode(', ', array_diff($view->requires, $tables)));
......@@ -377,7 +382,7 @@ function views_ui_admin_export_page($vid = '') {
'#title' => $view->name,
'#default_value' => $code,
'#rows' => $lines);
return drupal_get_form('views_export', $form);
return $form;
}
/*
......@@ -386,14 +391,14 @@ function views_ui_admin_export_page($vid = '') {
function views_ui_admin_add_page($template = NULL) {
$op = $_POST['op'];
if ($op == t('Cancel')) {
return 'admin/views';
return 'admin/build/views';
}
$view = _views_get_default_view($template);
drupal_set_title(t('Add a View'));
return _views_view_form($view, $op);
return drupal_get_form('views_edit_view', $view, $op);
}
/*
......@@ -402,7 +407,7 @@ function views_ui_admin_add_page($template = NULL) {
function views_ui_admin_clone_page($viewname) {
$op = $_POST['op'];
if ($op == t('Cancel')) {
return 'admin/views';
return 'admin/build/views';
}
$view = views_load_view($viewname);
......@@ -413,7 +418,7 @@ function views_ui_admin_clone_page($viewname) {
unset($view->vid);
drupal_set_title(t('Add a View'));
return _views_view_form($view, $op);
return drupal_get_form('views_edit_view', $view, $op);
}
/*
......@@ -422,49 +427,49 @@ function views_ui_admin_clone_page($viewname) {
function views_ui_admin_edit_page($vid = '') {
$op = $_POST['op'];
if ($op == t('Cancel')) {
drupal_goto('admin/views');
drupal_goto('admin/build/views');
}
if ($op == t('Delete')) {
drupal_goto("admin/views/delete/$vid");
drupal_goto("admin/build/views/delete/$vid");
}
if (!($view = _views_load_view($vid))) {
drupal_goto('admin/views');
drupal_goto('admin/build/views');
}
drupal_set_title(t('Edit view %n', array('%n' => $view->name)));
return _views_view_form($view, $op);
return drupal_get_form('views_edit_view', $view, $op);
}
/*
* Provide a form to confirm deletion of a view.
*/
function views_ui_admin_delete_page($vid = '') {
function views_ui_admin_delete_confirm($vid = '') {
$view = _views_load_view($vid);
if (!$view) {
return 'admin/views';
return drupal_goto('admin/build/views');
}
$form['vid'] = array('#type' => 'value', '#value' => $view->vid);
return confirm_form('views_delete_confirm', $form,
// bdragon note: Did you mean to drop the above line on the floor with this?
$form = confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $view->name)),
$_GET['destination'] ? $_GET['destination'] : 'admin/views',
$_GET['destination'] ? $_GET['destination'] : 'admin/build/views',
t('This action cannot be undone.'),
t('Delete'), t('Cancel')
);
return $form;
}
/*
* Handle the submit button to delete a view.
*/
function views_delete_confirm_submit($formid, $form) {
if ($form['confirm']) {
_views_delete_view((object) $form);
menu_rebuild();
return 'admin/views';
}
function views_ui_admin_delete_confirm_submit($form_id, $form) {
_views_delete_view((object) $form);
menu_rebuild();
drupal_goto('admin/build/views');
}
/*
......@@ -675,10 +680,11 @@ function views_ui_setup_widget($widget, $default_value, $argument = NULL) {
/**
* Display all the guts of a view in a form for editing.
*/
function _views_view_form($view, $op = '') {
function views_edit_view($view, $op = '') {
_views_check_arrays($view); // make sure arrays that might be empty get set
// Put in all our add buttons, then process them to see if they've been hit.
$form = array();
views_ui_add_add_button($form, 'field', _views_get_fields(true), t('Add Field'));
views_ui_add_add_button($form, 'argument', _views_get_arguments(true), t('Add Argument'));
views_ui_add_add_button($form, 'filter', _views_get_filters(true), t('Add Filter'));
......@@ -1073,13 +1079,16 @@ function _views_view_form($view, $op = '') {
'#value' => t('Cancel'),
);
return drupal_get_form('views_edit_view', $form);
return $form;
}
/**
* separately build a piece of the form
*/
function views_ui_build_form(&$form) {
// NOT REALLY SURE WHY THIS SORT OF WORKS. IT'S MAGIC THAT CHX POINTED ME TO
// IN THE POLL MODULE.
$form['#post'] = $_POST;
$form = form_builder('views_edit_view', $form);
}
......@@ -1485,13 +1494,13 @@ function views_ui_add_button($image, $name, $text) {
*/
function theme_views_edit_view($form) {
$output .= form_render($form['basic-info'], false);
$output .= form_render($form['page-info'], false);
$output .= form_render($form['block-info'], false);
$output .= drupal_render($form['basic-info'], false);
$output .= drupal_render($form['page-info'], false);
$output .= drupal_render($form['block-info'], false);
$allbut = $form['allbut']['#value'];
// form_render wants a reference so use full array notation.
// drupal_render wants a reference so use full array notation.
// fields
$collapsed = $allbut && $allbut != 'field';
......@@ -1509,7 +1518,7 @@ function theme_views_edit_view($form) {
$group .= views_ui_render_section_add($form['argument']['add'], array('id', 'button'), t('Add Argument'));
$group .= form_render($form['view_args_php_fieldset']);
$group .= drupal_render($form['view_args_php_fieldset']);
$group .= '<p>'. t('Arguments are parsed directly from the URL. They are not necessary to any given view, but allow flexibility.') .'</p>';
$output .= theme('fieldset', array('#title' => t('Arguments'), '#children' => $group,
......@@ -1546,7 +1555,7 @@ function theme_views_edit_view($form) {
$output .= theme('fieldset', array('#title' => t('Sort Criteria'), '#children' => $group,
'#collapsible' => true, '#collapsed' => $collapsed,));
$output .= form_render($form, false);
$output .= drupal_render($form, false);
return $output;
}
......@@ -1572,12 +1581,12 @@ function views_ui_render_section(&$form, $items, $header, $section, &$collapsed)
$row[] = '&nbsp;'; // array('data' => '&nbsp;', 'width' => 16);
}
else {
$row[] = form_render($form[$i][$item], false);
$row[] = drupal_render($form[$i][$item], false);
}
}
$rows[] = $row;
if (isset($form[$i]['help'])) {
$rows[] = array(array('data' => form_render($form[$i]['help']), 'colspan' => $num_items));
$rows[] = array(array('data' => drupal_render($form[$i]['help']), 'colspan' => $num_items));
}
}
if (!$rows) {
......@@ -1594,7 +1603,7 @@ function views_ui_render_section(&$form, $items, $header, $section, &$collapsed)
*/
function views_ui_render_section_add(&$form, $items, $label) {
foreach ($items as $item) {
$row[] = form_render($form[$item], false);
$row[] = drupal_render($form[$item], false);
}
$rows[] = $row;
......@@ -1709,7 +1718,7 @@ function views_edit_view_submit($form_id, $form) {
drupal_set_message(t('View successfully added.'));
}
return 'admin/views';
return 'admin/build/views';
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment