/[drupal]/contributions/modules/node_factory/node_factory.module
ViewVC logotype

Diff of /contributions/modules/node_factory/node_factory.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.17, Mon Aug 18 14:50:19 2008 UTC revision 1.1.2.18, Thu Aug 28 08:59:30 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: node_factory.module,v 1.1.2.16 2008/08/18 11:18:36 clemenstolboom Exp $  // $Id: node_factory.module,v 1.1.2.17 2008/08/18 14:50:19 clemenstolboom Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 72  function node_factory_create_node( $node Line 72  function node_factory_create_node( $node
72    
73    // get the node type defaults    // get the node type defaults
74    $node_type_default = variable_get('node_options_'. $edit['type'], array('status', 'published'));    $node_type_default = variable_get('node_options_'. $edit['type'], array('status', 'published'));
   
75    // default settings    // default settings
76    $edit['uid'] = $user->uid;    $edit['uid'] = $user->uid;
77    $edit['name'] = $user->name;    $edit['name'] = $user->name;
# Line 252  function node_factory_nodeapi( &$node, $ Line 251  function node_factory_nodeapi( &$node, $
251      dsm( $_POST);      dsm( $_POST);
252    }    }
253  }  }
 */  
254    */
255    
256    /**
257     * Implementation of hook_drush_command().
258     */
259    function node_factory_drush_command() {
260      $item = array();
261    
262      $items['nf create_json'] = array(
263        'callback' => '_node_factory_create_node_json',
264        'description' => 'Create a node from the commandline'
265      );
266    
267      $items['nf create_php'] = array(
268        'callback' => '_node_factory_create_node_php',
269        'description' => 'Not implemented yet. Create a node from based on a var_export structure'
270      );
271    
272      return $items;
273    }
274    
275    function _node_factory_create_node_php() {
276    
277      return;
278    }
279    
280    function _node_factory_create_node_json() {
281      $nodes = func_get_args();
282      $node =  json_decode($nodes[0], TRUE);
283    
284      $type = $node['type'];
285      $edit = node_factory_create_node( $type);
286      foreach( $node as $field => $value) {
287        node_factory_set_value($edit, $field, $value);
288      }
289    
290      $nid = node_factory_save_node($edit);
291      if( $nid) {
292        if( DRUSH_VERBOSE) {
293          drush_verbose( t('Node !n of type !t created', array( '!n' => $nid, '!t' => $type)));
294        }
295      }
296      else {
297        print_r( 'ERROR');
298      }
299    }

Legend:
Removed from v.1.1.2.17  
changed lines
  Added in v.1.1.2.18

  ViewVC Help
Powered by ViewVC 1.1.2