b2evolution PHP Cross Reference Blogging Systems

Source: /contact.php - 215 lines - 7602 bytes - Text - Print

Description: This is a demo template displaying a form to contact the admin user of the site This template is designed to be used aside of your blog, in case you have a website containing other sections than your blog. This lets you use b2evolution as a contact form handler outside of your blog per se.

   1  <?php
   2  /**
   3   * This is a demo template displaying a form to contact the admin user of the site
   4   *
   5   * This template is designed to be used aside of your blog, in case you have a website containing other sections than your blog.
   6   * This lets you use b2evolution as a contact form handler outside of your blog per se.
   7   *
   8   * b2evolution - {@link http://b2evolution.net/}
   9   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  10   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  11   *
  12   * @package evoskins
  13   * @subpackage noskin
  14   */
  15  
  16  // The User ID of the administrator:
  17  $recipient_id = 1;
  18  
  19  // Tie this to no blog in particular. (Do not include a link to any blog in the emails you will receive).
  20  $blog = 0;
  21  
  22  // This is the page where we want to go after sending an email. (This page should be able to display $Messages)
  23  // If empty, we will default to return to the same page, but you could put any URL here.
  24  $redirect_to = '';
  25  
  26  /**
  27   * Check this: we are requiring _main.inc.php INSTEAD of _blog_main.inc.php because we are not
  28   * trying to initialize any particular blog
  29   */
  30  require_once dirname(__FILE__).'/conf/_config.php';
  31  
  32  require_once $inc_path.'_main.inc.php';
  33  
  34  load_funcs( 'skins/_skin.funcs.php' );
  35  
  36  // Are we returning to this page?
  37  param( 'return', 'integer', 0 );
  38  
  39  // Note: This is an interactive page: not a good candidate for caching.
  40  
  41  // Add CSS:
  42  require_css( 'basic_styles.css', 'rsc_url' ); // the REAL basic styles
  43  require_css( 'basic.css', 'rsc_url' ); // Basic styles
  44  require_css( 'blog_base.css', 'rsc_url' ); // Default styles for the blog navigation
  45  require_css( 'item_base.css', 'rsc_url' ); // Default styles for the post CONTENT
  46  require_css( 'fp02.css', 'rsc_url' );
  47  
  48  add_js_for_toolbar();        // Registers all the javascripts needed by the toolbar menu
  49  init_tokeninput_js();
  50  
  51  headers_content_mightcache( 'text/html', 0 );        // Never even think about caching FORMs!
  52  ?>
  53  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  54  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>"><!-- InstanceBegin template="/Templates/Standard.dwt" codeOutsideHTMLIsLocked="false" -->
  55  <head>
  56  <!-- InstanceBeginEditable name="doctitle" -->
  57  <title><?php echo T_('Contact Form Demo'); ?></title>
  58  <!-- InstanceEndEditable -->
  59  <!-- InstanceBeginEditable name="head" -->
  60      <?php include_headlines() /* Add javascript and css files included by plugins and skin */ ?>
  61   <!-- InstanceEndEditable -->
  62  </head>
  63  <body>
  64  <!-- InstanceBeginEditable name="ToolBar" -->
  65  <?php
  66      // ---------------------------- TOOLBAR INCLUDED HERE ----------------------------
  67      require $skins_path.'_toolbar.inc.php';
  68      // ------------------------------- END OF TOOLBAR --------------------------------
  69      echo "\n";
  70      if( show_toolbar() )
  71      {
  72          echo '<div id="skin_wrapper" class="skin_wrapper_loggedin">';
  73      }
  74      else
  75      {
  76          echo '<div id="skin_wrapper" class="skin_wrapper_anonymous">';
  77      }
  78      echo "\n";
  79  ?>
  80  <!-- InstanceEndEditable -->
  81  <div class="pageHeader">
  82  <!-- InstanceBeginEditable name="NavBar2" -->
  83  <?php
  84      // --------------------------------- START OF BLOG LIST --------------------------------
  85      skin_widget( array(
  86                          // CODE for the widget:
  87                          'widget' => 'colls_list_public',
  88                          // Optional display params
  89                          'block_start' => '<div class="NavBar">',
  90                          'block_end' => '</div>',
  91                          'block_display_title' => false,
  92                          'list_start' => '',
  93                          'list_end' => '',
  94                          'item_start' => '',
  95                          'item_end' => '',
  96                          'item_selected_start' => '',
  97                          'item_selected_end' => '',
  98                          'link_selected_class' => 'NavButton2',
  99                          'link_default_class' => 'NavButton2',
 100                  ) );
 101      // ---------------------------------- END OF BLOG LIST ---------------------------------
 102  ?>
 103  <!-- InstanceEndEditable -->
 104  <div class="pageTitle">
 105  <h1 id="pageTitle"><!-- InstanceBeginEditable name="PageTitle" --><?php echo T_('Contact Form Demo') ?><!-- InstanceEndEditable --></h1>
 106  </div>
 107  </div>
 108  
 109  
 110  <div class="pageSubTitle"><!-- InstanceBeginEditable name="SubTitle" --><?php echo T_('This demo displays a form to contact the site admin.') ?><!-- InstanceEndEditable --></div>
 111  
 112  
 113  <div class="main"><!-- InstanceBeginEditable name="Main" -->
 114  
 115  
 116  <?php
 117      // ------------------------- MESSAGES GENERATED FROM ACTIONS -------------------------
 118      $has_errors = 'false';
 119      messages( array(
 120              'block_start' => '<div class="action_messages">',
 121              'block_end'   => '</div>',
 122              'has_errors'  => & $has_errors,
 123          ) );
 124      // --------------------------------- END OF MESSAGES ---------------------------------
 125  ?>
 126  
 127  
 128  <?php
 129      // ----------------------------- MESSAGE FORM ----------------------------
 130      if( empty( $return ) || $has_errors )
 131      {    // We are *not* coming back after sending a message:
 132  
 133          if( $has_errors )
 134          { // There was some error, the message was not sent
 135              echo '<p>'.T_('Your message was not sent. You may try again.').'</p>';
 136          }
 137  
 138          if( empty( $redirect_to ) )
 139          {    // We haven't asked for a specific return URL, so we'll come back to here with a param.
 140              $redirect_to = empty( $return ) ? url_add_param( $ReqURI, 'return=1', '&' ) : $ReqURI;
 141          }
 142  
 143          // Check admin user allow message forms
 144          $UserCache = & get_UserCache();
 145          $recipient_User = $UserCache->get_by_ID( $recipient_id );
 146          $allow_msgform = $recipient_User->get_msgform_possibility();
 147          // The form, per se:
 148          switch( $allow_msgform )
 149          {
 150              case 'login':
 151                  echo '<p>'.sprintf( T_('Sorry, but you must <a %s>log in</a> before you can contact to me.'), 'href="'.get_login_url( 'contact.php', regenerate_url() ).'"' ).'</p>';
 152                  break;
 153  
 154              case 'PM':
 155                  if( !check_create_thread_limit() )
 156                  { // the current User didn't reached the thread limit
 157                      // Load classes
 158                      load_class( 'messaging/model/_thread.class.php', 'Thread' );
 159                      load_class( 'messaging/model/_message.class.php', 'Message' );
 160  
 161                      // Set global variable to auto define the FB autocomplete plugin field
 162                      $recipients_selected = array( array(
 163                              'id'    => $recipient_User->ID,
 164                              'title' => $recipient_User->login,
 165                          ) );
 166                      $edited_Thread = new Thread();
 167                      $edited_Message = new Message();
 168                      $edited_Message->Thread = & $edited_Thread;
 169                      $edited_Thread->recipients = $recipient_User->login;
 170                      param( 'action', 'string', 'new', true );
 171                      param( 'thrdtype', 'string', 'individual', true );
 172                      $params = array(
 173                              'redirect_to' => $redirect_to,
 174                              'allow_select_recipients' => false,
 175                          );
 176  
 177                      require $skins_path.'_threads.disp.php';
 178                      break;
 179                  }
 180                  // don't break, because we may let the user to send email
 181  
 182              case 'email':
 183                  if( $recipient_User->accepts_email() )
 184                  {
 185                      require $skins_path.'_msgform.disp.php';
 186                      break;
 187                  }
 188                  // don't break, display the message below
 189  
 190              default:
 191                  echo '<p>'.T_('The administrator of this site has turned off all means of being contacted.').'</p>';
 192          }
 193      }
 194      else
 195      {    // We are coming back after sending a message:
 196          echo '<p>'.T_('Thank you for your message. We will reply as soon as possible.').'</p>';
 197  
 198          // This is useful for testing but does not really make sense on production:
 199          echo '<p><a href="'.regenerate_url().'">'.T_('Send another message?').'</a></p>';
 200      }
 201      // ------------------------- END OF MESSAGE FORM -------------------------
 202  ?>
 203  
 204  
 205  
 206  
 207  
 208  <!-- InstanceEndEditable --></div>
 209  <div class="footer">
 210  This is a demo page for <a href="http://b2evolution.net/">b2evolution</a>.
 211  <!-- InstanceBeginEditable name="Baseline" -->
 212  <?php echo '</div>' ?>
 213  <!-- InstanceEndEditable --></div>
 214  </body>
 215  <!-- InstanceEnd --></html>

title

Description

title

Description

title

Description

title

title

Body