'drush_auto_nodetitle_drush_update', 'description' => dt('Update automatic node titles.'), 'examples' => array( 'drush ant sometype' => dt('Update all the automatic node titles for content type sometype'), ), ); return $items; } /** * Implementation of hook_drush_help(). */ function auto_nodetitle_drush_help($section) { switch ($section) { case 'drush:ant': return dt('Recreate auto node titles for one or more content types.'); } } /** * Drush callback to perform actual auto_nodetitle preset flush. */ function drush_auto_nodetitle_drush_update() { global $user; $user = user_load(1); $args = func_get_args(); if (empty($args)) { drush_set_error(dt('You must specify a node type name to recreate or specify "all".'. "\n".'Node types are: ').implode(array_keys(node_get_types()),' ')); return FALSE; } else { // Implement 'all' if (count($args) == 1 && $args[0] == 'all') { $args = array_keys(node_get_types()); } foreach ($args as $type) { $count = db_result(db_query("select count(nid) from node where type='%s'",$type)); drush_log(dt('Updating @count auto node titles for type "@type".', array('@type' => $type, '@count' => $count)), 'ok'); $block = 0; $blocksize = 10; $total = 0; while ($result = db_query_range("select nid from node where type='%s'",$type,$block*$blocksize,$blocksize)) { $nids = array(); while ($row = db_fetch_array($result)) { $nids[] = $row['nid']; } if(count($nids) == 0) { break; } auto_nodetitle_operations_update($nids); $total += count($nids); drush_log(dt(' @count done', array('@count' => $total))); $block++; } drush_log(dt('All done for type "@type".', array('@type' => $type)), 'ok'); } return TRUE; } }