NODEQUEUE_BUILDER_PATH_SETTINGS, 'access' => user_access(NODEQUEUE_BUILDER_PERM_ADMINISTER), 'callback' => 'drupal_get_form', 'callback arguments' => array('nodequeue_builder_admin'), 'title' => t('Settings'), 'description' => t('Settings for Node Queue Builder'), 'type' => MENU_LOCAL_TASK ); } else { // Node Queue Builder itself $items[] = array( 'path' => NODEQUEUE_BUILDER_PATH_BUILDER, 'access' => user_access('administer nodequeue'), 'callback' => 'drupal_get_form', 'callback arguments' => array('nodequeue_builder_builder'), 'title' => t('Build'), 'description' => t('Select and add nodes to a node queue'), 'type' => MENU_LOCAL_TASK ); } return $items; } /** * Returns the settoings form. */ function nodequeue_builder_admin() { // Add a selector with possible views that can be used as node list by the builder. $form['nodequeue_builder_view'] = array( '#type' => 'select', '#title' => 'Builder\'s view', '#description' => 'Select the ' . l('view' , 'admin/build/views') . ' that will provide the builder\'s node list.', '#options' => _nodequeue_builder_list_views(), '#default_value' => variable_get('nodequeue_builder_view', NODEQUEUE_BUILDER_DEFAULT_VIEW), '#multiple' => false, '#required' => true ); // Add a selector with possible number of nodes to show on each page $form['nodequeue_builder_limit'] = array( '#type' => 'select', '#title' => 'Nodes per builder page', '#description' => 'The number of nodes to display per page in the builder.', '#options' => array(10 => 10, 20 => 20, 50 => 50, 100 => 100, 0 => 'All nodes'), '#default_value' => variable_get('nodequeue_builder_limit', NODEQUEUE_BUILDER_DEFAULT_LIMIT), '#multiple' => false, '#required' => true ); // Return system settings form. return system_settings_form($form); } /** * Returns the builder form. */ function nodequeue_builder_builder() { // Load the view that will provide the node list. $view_name = variable_get('nodequeue_builder_view', NODEQUEUE_BUILDER_DEFAULT_VIEW); $view = views_get_view($view_name); // Handle the case that the view has been removed. if(!isset($view)) { // Set an error message $message = t('The view "!view" is no longer avaiable.', array('!view' => $view_name)); watchdog('nodequeue_builder', $message, WATCHDOG_ERROR); drupal_set_message($message, 'error'); // Present an explanation $form['message'] = array( '#value' => t( '
Node Queue Builder uses the view "!view" as its source of nodes. But it is no longer avaiable.
Please, add "!view" or select another view.
', array( '!view' => $view_name, '!views-url' => url('http://drupal/admin/build/views/add'), '!settings-url' => url(NODEQUEUE_BUILDER_PATH_SETTINGS)) ) ); // Nothing more to do. return $form; } // Get the number of nodes to be shown on each page. $limit = $view_name = variable_get('nodequeue_builder_limit', NODEQUEUE_BUILDER_DEFAULT_LIMIT); // Let views module make the query. $view = views_build_view('result', $view, array(), $limit > 0, $limit); $result = $view['result']; // Form for selecting nodes to be added. while ($node = db_fetch_object($result)) { $node = node_load($node->nid); $nodes[$node->nid] = ''; $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid) .' '. theme('mark', node_mark($node->nid, $node->changed))); $form['name'][$node->nid] = array('#value' => node_get_types('name', $node)); $form['created'][$node->nid] = array('#value' => format_date($node->created, 'small')); $form['username'][$node->nid] = array('#value' => theme('username', $node)); } $form['nid'] = array('#type' => 'checkboxes', '#options' => $nodes); // Pager $form['pager'] = array('#value' => theme('pager', NULL, $limit, 0)); // Form for selecting a queue to be updated. $form['add'] = array( '#type' => 'fieldset', '#title' => t('Add to node queue'), '#prefix' => 'Settings for the Node Queue Builder. For more information, see the !help.
', array('!help' => l(t('help page'), 'admin/help/nodequeue_builder')) ); } /** * Returns short help text about the builder page. */ function _nodequeue_builder_help_builder() { return t('Add checked nodes to the selected queue. For more information, see the !help.
', array('!help' => l(t('help page'), 'admin/help/nodequeue_builder')) ); } /** * Returns full help text. */ function _nodequeue_builder_help_help() { $version = str_replace(array('$Re'.'vision:', ' $'), array('', ''), '$Revision: 1.4 $'); $year = substr('$Date: 2007/01/09 22:49:49 $', 7, 4); return ' ' . t( 'TODO
TODO
Node Queue Builder revision !version. Copyright © !year Thomas Barregren.
Node Queue Builder is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Node Queue Builder is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
', array('!version' => $version, '!year' => $year) ); }