Index: content_profile.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_profile/Attic/content_profile.module,v
retrieving revision 1.1.2.41
diff -u -r1.1.2.41 content_profile.module
--- content_profile.module	5 Aug 2009 14:08:34 -0000	1.1.2.41
+++ content_profile.module	7 Oct 2009 11:18:57 -0000
@@ -552,6 +552,9 @@
     'content_profile_display_tab_edit' => array(
       'file' => 'content_profile.theme.inc',
     ),
+    'content_profile_empty' => array(
+      'arguments' => array('type_name' => NULL)
+    ),
   );
 }
 
@@ -602,3 +605,15 @@
   $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test');
   return array_keys($tests);
 }
+
+/**
+ * Implementation of hook_pageroute_infor() for Pageroute integration.
+ */
+function content_profile_pageroute_info() {
+  return array(
+    'content_profile' => array(
+      'viewprofile' => 'content_profile.pageroute',
+      'editprofile' => 'content_profile.pageroute',
+    )
+  );
+}
Index: content_profile.pageroute.inc
===================================================================
RCS file: content_profile.pageroute.inc
diff -N content_profile.pageroute.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ content_profile.pageroute.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,131 @@
+<?php
+// $Id$
+
+/**
+ * @file 
+ * Pageroute intergration classes
+ */
+
+include_once(drupal_get_path('module', 'pageroute') . '/pageroute.page_edit.inc');
+include_once(drupal_get_path('module', 'pageroute') . '/pageroute.page_view.inc');
+
+/**
+ * theme_content_profile_pageroute_empty generates a message, if there is no content profile for the user.
+ */
+function theme_content_profile_pageroute_empty($type_name) {
+  return '<div class="content-profile-empty">'.
+    t('You have not created a @type yet. Go ahead and create one!', array('@type' => $type_name)) .'</div>';
+}
+
+/**
+ * ContentProfilePageEditProfile displays a form that allows users to edit content profiles.
+ */
+class ContentProfilePageEditProfile extends PageroutePageEdit {
+
+  public function getForm(&$form, &$form_state, &$args) {
+      $args['hide_pageroute_buttons'] = FALSE;
+      $args['default_target'] = PAGEROUTE_CURRENT;
+      $page = &$form_state['page'];
+
+      if (isset($form_state['node']) && $form_state['node']['type'] == $this->options['content-type']) {
+        $node = $form_state['node'];
+      }
+      else {
+        if (isset($page)) {
+          $node = node_load(array(
+          	'type' => $this->options['content-type'],
+          	'uid' => pageroute_page_get_uid($page),
+          ));
+        }
+      }
+      if (empty($node)) {
+        PageroutePageAdd::setNodeAddForm($form, $form_state, $page);
+      }
+      else {
+        $this->setNodeEditForm($form, $form_state, $page, $args, $node);
+      }
+      parent::unsetForm($form);
+      return;
+  }
+
+  public function getAdminForm($page, &$form) {
+
+    $form['options']['content-type'] = array(
+      '#type' => 'select',
+      '#title' => t('Profile content type'),
+      '#options' => content_profile_get_types('names'),
+      '#default_value' => $page->options['content-type'],
+      '#weight' => 2,
+      '#description' => t('Select a content profile type.'),
+    );
+
+    PageroutePage::nodeUi($page, $form, TRUE);
+  }
+
+  public static function help() {
+    return t('A page of this type will present a content profile node editing form of a configurable content-profile-type. It will edit the node with the id taken from the first argument of the pageroute. Furthermore this type can be configured to show a node adding form if the content profile is not existing. So you can build a pageroute that manages the creation and editing of content profiles.');
+  }
+
+  public static function info() {
+    return array('name' => t('Content profile editing form'));
+  }
+
+  public function setUp() {}
+
+  public static function getDefaultSubmitHandler($form) {
+    return 'node_form_submit';
+  }
+
+}
+
+/**
+ * ContentProfilePageViewProfile displays a content profile.
+ */
+class ContentProfilePageViewProfile extends PageroutePageView {
+  /*
+   * Returns the page display for the configured node
+   */
+  public function getForm(&$form, &$form_state, &$args) {
+    $page = &$form_state['page'];
+
+    $args['hide_pageroute_buttons'] = FALSE;
+    $args['default_target'] = PAGEROUTE_CURRENT;
+
+    $node = node_load(array(
+      'type' => $page->options['content-type'],
+      'uid' => pageroute_page_get_uid($page),
+    ));
+
+    if ($node->nid && node_access('view', $node)) {
+      if (empty($this->title)) {
+        drupal_set_title(check_plain($node->title));
+      }
+      node_tag_new($node->nid);
+      $form += array('pageroute-view' => array('#value' => node_view($node, FALSE, TRUE, FALSE)));
+    }
+    else {
+      $type_name = node_get_types('name', $page->options['content-type']);
+      $form += array('pageroute-view' => array('#value' => theme('content_profile_pageroute_empty', $type_name)));
+    }
+  }
+
+  public function getAdminForm($page, &$form) {
+    $form['options']['content-type'] = array(
+      '#type' => 'select',
+      '#title' => t('Profile content type'),
+      '#options' => content_profile_get_types('names'),
+      '#required' => TRUE,
+      '#default_value' => $page->options['content-type'],
+      '#weight' => 2,
+      '#description' => t('You can only use content types marked as \'content profile\''),
+    );
+  }
+
+  public static function help() {
+    return t('The lonely node display page can be used to view this lonely node. This might be useful for displaying the lonely node aftercreation or update. There will be a (themeable) message if there is no node that can be displayed.');
+  }
+
+  public static function info() {
+    return array('name' => t('Content profile display'));
+  }
+}
