/[drupal]/contributions/modules/skeleton/skeleton_instance.inc
ViewVC logotype

Diff of /contributions/modules/skeleton/skeleton_instance.inc

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

revision 1.20, Fri May 29 00:49:04 2009 UTC revision 1.21, Thu Jul 16 18:09:19 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  // $Id: skeleton_instance.inc,v 1.19 2009/04/30 00:34:57 deviantintegral Exp $  // $Id: skeleton_instance.inc,v 1.20 2009/05/29 00:49:04 deviantintegral Exp $
4    
5  /**  /**
6   * @file   * @file
# Line 702  function skeleton_create_instance_form_s Line 702  function skeleton_create_instance_form_s
702        $node = array();        $node = array();
703        $node['values'] = unserialize($nodes[0]->node_data);        $node['values'] = unserialize($nodes[0]->node_data);
704    
705          // Pathauto provides a 'bookpathalias' token which is very useful for
706          // generating inline URL's. However, the path isn't generated until the
707          // node is saved. Escape out the token if it exists, and replace it later
708          // after the node is saved for the first time.
709          if (module_exists('pathauto')) {
710            $node['values']['title'] = str_replace('[bookpathalias]', '[\skeleton-bookpathalias\]', $node['values']['title']);
711            $node['values']['body'] = str_replace('[bookpathalias]', '[\skeleton-bookpathalias\]', $node['values']['body']);
712          }
713    
714        // Replace custom tokens in the title and body fields. Replace skeleton        // Replace custom tokens in the title and body fields. Replace skeleton
715        // tokens first so they may be used as node tokens such as [title].        // tokens first so they may be used as node tokens such as [title].
716        if (!empty($form_state['values']['skeleton_tokens'])) {        if (!empty($form_state['values']['skeleton_tokens'])) {
# Line 747  function skeleton_create_instance_form_s Line 756  function skeleton_create_instance_form_s
756      // TODO: This will probably need to be removed if this call is integrated      // TODO: This will probably need to be removed if this call is integrated
757      // into the book module. See http://drupal.org/node/364529 for details.      // into the book module. See http://drupal.org/node/364529 for details.
758      menu_rebuild();      menu_rebuild();
759        $parent_node = node_load($parent_node['nid'], NULL, TRUE);
760    
761        // Only do this if pathauto exists, as it involves another save slowing
762        // things down.
763        if (module_exists('pathauto')) {
764          $parent_node->title = str_replace('[\skeleton-bookpathalias\]', drupal_get_path_alias($parent_node->path), $parent_node->title);
765          $parent_node->teaser = str_replace('[\skeleton-bookpathalias\]', drupal_get_path_alias($parent_node->path), $parent_node->teaser);
766          $parent_node->body = str_replace('[\skeleton-bookpathalias\]', drupal_get_path_alias($parent_node->path), $parent_node->body);
767          $parent_node->skeleton_template->keep_connected = TRUE;
768          $parent_node = node_submit($parent_node);
769          node_save($parent_node);
770        }
771    
772      // get the id we just created      // get the id we just created
773      $form_state['nids'][] = $parent_node['nid'];      $form_state['nids'][] = $parent_node->nid;
774      $book_id = $parent_node['nid'];      $book_id = $parent_node->nid;
775      $goto_id = $book_id;      $goto_id = $book_id;
776      // iterate through the dummy nodes and create the book pages  
777        // Iterate through the dummy nodes and create the book pages.
778      // The Book ID is the NID of the topmost book page.      // The Book ID is the NID of the topmost book page.
779      foreach ($nodes as $data) {      foreach ($nodes as $data) {
780        $node = array();        $node = array();
781        $node['values'] = unserialize($data->node_data);        $node['values'] = unserialize($data->node_data);
782        // if parents are assigned by the skeleton, use them        // if parents are assigned by the skeleton, use them
783        if ($data->parent > 0 && isset($parents[$data->parent])) {        if ($data->parent > 0 && isset($parents[$data->parent])) {
784          $parent_node = node_load($parents[$data->parent]);          $parent_node = node_load($parents[$data->parent], NULL, TRUE);
785        }        }
786        else {        else {
787          $parent_node = node_load($book_id);          $parent_node = node_load($book_id, NULL, TRUE);
788        }        }
789        $node['values']['book'] = array();        $node['values']['book'] = array();
790        $node['values']['book']['bid'] = $book_id;        $node['values']['book']['bid'] = $book_id;
791        $node['values']['book']['plid'] = $parent_node->book['mlid'];        $node['values']['book']['plid'] = $parent_node->book['mlid'];
792    
793        $node['values']['book']['weight'] = $data->weight;        $node['values']['book']['weight'] = $data->weight;
794        $node['values']['book']['options'] = array();        $node['values']['book']['options'] = array();
795    
796          // For subpages, we can simply simulate the [bookpathalias] token here.
797          // Otherwise, it will be replaced with '' during token_replace() as the
798          // node isn't saved yet.
799          if (module_exists('pathauto')) {
800            $book_root = node_load($book_id);
801            $node['values']['title'] = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node['values']['title']);
802            $node['values']['body'] = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node['values']['body']);
803          }
804    
805        // Replace custom tokens in the title and body fields. Replace skeleton        // Replace custom tokens in the title and body fields. Replace skeleton
806        // tokens first so they may be used as node tokens such as [title].        // tokens first so they may be used as node tokens such as [title].
807        if (!empty($form_state['values']['skeleton_tokens'])) {        if (!empty($form_state['values']['skeleton_tokens'])) {

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.2