[Customisation Database Commits] r572 - in /trunk/titania: authors/ contributions/ includes/core/ includes/tools/ styles/default/template/contributions/

Nathan Guse exreaction at phpbb.com
Thu Feb 4 00:19:54 GMT 2010


Author: exreaction
Date: Thu Feb  4 00:19:54 2010
New Revision: 572

Log:
This should fix the problem with data not being saved when attaching files

Fixing the bug with editing/posting and having the disable bbcode/smilies checked by default

Preview available for the manage/create contrib page

Modified:
    trunk/titania/authors/create.php
    trunk/titania/contributions/faq.php
    trunk/titania/contributions/manage.php
    trunk/titania/contributions/support.php
    trunk/titania/includes/core/object_message.php
    trunk/titania/includes/tools/attachment.php
    trunk/titania/includes/tools/message.php
    trunk/titania/styles/default/template/contributions/contribution_manage.html

Modified: trunk/titania/authors/create.php
==============================================================================
*** trunk/titania/authors/create.php (original)
--- trunk/titania/authors/create.php Thu Feb  4 00:19:54 2010
***************
*** 48,60 ****
  
  $submit = (isset($_POST['submit'])) ? true : false;
  
! $contrib_categories = array();
! $active_coauthors = $nonactive_coauthors = '';
  
! if ($submit)
  {
  	titania::$contrib->post_data($message);
- 	$contrib_categories = request_var('contrib_category', array(0));
  	titania::$contrib->__set_array(array(
  		'contrib_type'			=> request_var('contrib_type', 0),
  		'contrib_name_clean'	=> request_var('permalink', '', true),
--- 48,66 ----
  
  $submit = (isset($_POST['submit'])) ? true : false;
  
! $contrib_categories = request_var('contrib_category', array(0));
! $active_coauthors = $active_coauthors_list = utf8_normalize_nfc(request_var('active_coauthors', '', true));
! $nonactive_coauthors = $nonactive_coauthors_list = utf8_normalize_nfc(request_var('nonactive_coauthors', '', true));
  
! if (isset($_POST['preview']))
! {
! 	titania::$contrib->post_data($message);
! 
! 	$message->preview();
! }
! else if ($submit)
  {
  	titania::$contrib->post_data($message);
  	titania::$contrib->__set_array(array(
  		'contrib_type'			=> request_var('contrib_type', 0),
  		'contrib_name_clean'	=> request_var('permalink', '', true),
***************
*** 69,76 ****
  	}
  
  	$missing_active = $missing_nonactive = array();
- 	$active_coauthors = $active_coauthors_list = utf8_normalize_nfc(request_var('active_coauthors', '', true));
- 	$nonactive_coauthors = $nonactive_coauthors_list = utf8_normalize_nfc(request_var('nonactive_coauthors', '', true));
  	get_author_ids_from_list($active_coauthors_list, $missing_active);
  	get_author_ids_from_list($nonactive_coauthors_list, $missing_nonactive);
  	if (sizeof($missing_active) || sizeof($missing_nonactive))
--- 75,80 ----

Modified: trunk/titania/contributions/faq.php
==============================================================================
*** trunk/titania/contributions/faq.php (original)
--- trunk/titania/contributions/faq.php Thu Feb  4 00:19:54 2010
***************
*** 20,27 ****
  
  $faq_id		= request_var('f', 0);
  $action 	= request_var('action', '');
- $submit		= isset($_POST['submit']) ? true : false;
- $preview	= isset($_POST['preview']) ? true : false;
  
  // Setup faq object
  $faq = new titania_faq($faq_id);
--- 20,25 ----
***************
*** 64,79 ****
  			'attachments_group'		=> TITANIA_ATTACH_EXT_FAQ,
  		));
  
! 		if ($preview)
! 		{
! 			$faq->post_data($message);
  
! 			$message->preview();
! 		}
! 		else if ($submit)
  		{
- 			$faq->post_data($message);
- 
  			$error = $faq->validate();
  			$error = array_merge($error, $message->error);
  
--- 62,72 ----
  			'attachments_group'		=> TITANIA_ATTACH_EXT_FAQ,
  		));
  
! 		// Submit check...handles running $faq->post_data() if required
! 		$submit = $message->submit_check();
  
! 		if ($submit)
  		{
  			$error = $faq->validate();
  			$error = array_merge($error, $message->error);
  

Modified: trunk/titania/contributions/manage.php
==============================================================================
*** trunk/titania/contributions/manage.php (original)
--- trunk/titania/contributions/manage.php Thu Feb  4 00:19:54 2010
***************
*** 28,34 ****
  // Set some main vars up
  $submit = (isset($_POST['submit']) || isset($_POST['new_revision'])) ? true : false;
  $change_owner = request_var('change_owner', '', true); // Blame Nathan, he said this was okay
! $contrib_categories = array();
  
  /**
  * ---------------------------- Create a new revision ----------------------------
--- 28,36 ----
  // Set some main vars up
  $submit = (isset($_POST['submit']) || isset($_POST['new_revision'])) ? true : false;
  $change_owner = request_var('change_owner', '', true); // Blame Nathan, he said this was okay
! $contrib_categories = request_var('contrib_category', array(0));
! $active_coauthors = $active_coauthors_list = utf8_normalize_nfc(request_var('active_coauthors', '', true));
! $nonactive_coauthors = $nonactive_coauthors_list = utf8_normalize_nfc(request_var('nonactive_coauthors', '', true));
  
  /**
  * ---------------------------- Create a new revision ----------------------------
***************
*** 144,153 ****
  	'subject_name'		=> 'name',
  ));
  
! if ($submit)
  {
  	titania::$contrib->post_data($message);
- 	$contrib_categories = request_var('contrib_category', array(0));
  
  	// Begin Error checking
  	$error = titania::$contrib->validate($contrib_categories);
--- 146,160 ----
  	'subject_name'		=> 'name',
  ));
  
! if (isset($_POST['preview']))
! {
! 	titania::$contrib->post_data($message);
! 
! 	$message->preview();
! }
! else if ($submit)
  {
  	titania::$contrib->post_data($message);
  
  	// Begin Error checking
  	$error = titania::$contrib->validate($contrib_categories);
***************
*** 158,165 ****
  	}
  
  	$missing_active = $missing_nonactive = array();
- 	$active_coauthors = $active_coauthors_list = utf8_normalize_nfc(request_var('active_coauthors', '', true));
- 	$nonactive_coauthors = $nonactive_coauthors_list = utf8_normalize_nfc(request_var('nonactive_coauthors', '', true));
  	get_author_ids_from_list($active_coauthors_list, $missing_active);
  	get_author_ids_from_list($nonactive_coauthors_list, $missing_nonactive);
  	if (sizeof($missing_active) || sizeof($missing_nonactive))
--- 165,170 ----

Modified: trunk/titania/contributions/support.php
==============================================================================
*** trunk/titania/contributions/support.php (original)
--- trunk/titania/contributions/support.php Thu Feb  4 00:19:54 2010
***************
*** 68,75 ****
  // Output the simple info on the contrib
  titania::$contrib->assign_details(true);
  
- $submit = (isset($_POST['submit'])) ? true : false;
- $preview = (isset($_POST['preview'])) ? true : false;
  $action = request_var('action', '');
  
  switch ($action)
--- 68,73 ----
***************
*** 120,132 ****
  			'attachments_group'			=> TITANIA_ATTACH_EXT_SUPPORT,
  		));
  
! 		$post->post_data($message);
  
! 		if ($preview)
! 		{
! 			$message->preview();
! 		}
! 		else if ($submit)
  		{
  			$error = $post->validate();
  
--- 118,127 ----
  			'attachments_group'			=> TITANIA_ATTACH_EXT_SUPPORT,
  		));
  
! 		// Submit check...handles running $post->post_data() if required
! 		$submit = $message->submit_check();
  
! 		if ($submit)
  		{
  			$error = $post->validate();
  

Modified: trunk/titania/includes/core/object_message.php
==============================================================================
*** trunk/titania/includes/core/object_message.php (original)
--- trunk/titania/includes/core/object_message.php Thu Feb  4 00:19:54 2010
***************
*** 110,116 ****
  		//'allow_smilies'
  		//'allow_urls'
  		//'text'
! 		$for_edit = array_merge($for_edit, generate_text_for_edit($message, $message_uid, $message_bitfield, $message_options));
  
  		// Add any of the marked fields to the array
  		foreach ($this->object_config as $field => $options)
--- 110,116 ----
  		//'allow_smilies'
  		//'allow_urls'
  		//'text'
! 		$for_edit = array_merge($for_edit, generate_text_for_edit($message, $message_uid, $message_options));
  
  		// Add any of the marked fields to the array
  		foreach ($this->object_config as $field => $options)

Modified: trunk/titania/includes/tools/attachment.php
==============================================================================
*** trunk/titania/includes/tools/attachment.php (original)
--- trunk/titania/includes/tools/attachment.php Thu Feb  4 00:19:54 2010
***************
*** 77,87 ****
  	public $error = array();
  
  	/**
! 	* Did we upload a file?
  	*
  	* @param bool True if we did False if not
  	*/
  	public $uploaded = false;
  
  	/**
  	 * Constructor for attachment/download class
--- 77,88 ----
  	public $error = array();
  
  	/**
! 	* Did we upload/delete a file?
  	*
  	* @param bool True if we did False if not
  	*/
  	public $uploaded = false;
+ 	public $deleted = false;
  
  	/**
  	 * Constructor for attachment/download class
***************
*** 277,282 ****
--- 278,285 ----
  		{
  			$this->delete($attach_id);
  
+ 			$this->deleted = true;
+ 
  			// Sometime I'll look into this again; having it setup to only delete attachments after the form is submitted
  			/*if (isset($this->attachments[$attach_id]))
  			{

Modified: trunk/titania/includes/tools/message.php
==============================================================================
*** trunk/titania/includes/tools/message.php (original)
--- trunk/titania/includes/tools/message.php Thu Feb  4 00:19:54 2010
***************
*** 69,74 ****
--- 69,75 ----
  		'form_name'				=> 'postform',
  		'text_name'				=> 'message',
  		'subject_name'			=> 'subject',
+ 		'display_preview'		=> true, // If set to false you will need to handle the preview output yourself (otherwise calls $this->preview if isset($_POST['preview']))
  		'display_error'			=> true, // If set to false make sure you output the error in the template yourself (turns the S_DISPLAY_ERROR on/off)
  		'display_subject'		=> true, // Display the subject field or not
  		'display_edit_reason'	=> false, // Display the edit reason field or not
***************
*** 123,128 ****
--- 124,159 ----
  	}
  
  	/**
+ 	* Submit check
+ 	* Runs $this->post_object->post_data if required (and exists)
+ 	* Displays the preview automatically if requested
+ 	*
+ 	* @return bool True if the form was submitted, False if not
+ 	*/
+ 	public function submit_check()
+ 	{
+ 		// Setup the attachments!
+ 		$this->setup_attachments();
+ 
+ 		$submit = isset($_POST['submit']) ? true : false;
+ 		$preview = isset($_POST['preview']) ? true : false;
+ 
+ 		// Submit the data to the post object
+ 		if (method_exists($this->post_object, 'post_data') && $submit || $preview || ($this->attachments && ($this->attachments->uploaded || $this->attachments->deleted)))
+ 		{
+ 			$this->post_object->post_data($this);
+ 		}
+ 
+ 		// Display the preview
+ 		if ($preview && $this->settings['display_preview'])
+ 		{
+ 			$this->preview();
+ 		}
+ 
+ 		return $submit;
+ 	}
+ 
+ 	/**
  	 * Display the message box
  	 */
  	public function display()

Modified: trunk/titania/styles/default/template/contributions/contribution_manage.html
==============================================================================
*** trunk/titania/styles/default/template/contributions/contribution_manage.html (original)
--- trunk/titania/styles/default/template/contributions/contribution_manage.html Thu Feb  4 00:19:54 2010
***************
*** 33,38 ****
--- 33,41 ----
  	<!-- ELSE -->
  		<div class="container">
  			<div class="inner"><span class="corners-top main-corners"><span></span></span>
+ 
+ 				<!-- IF S_DISPLAY_PREVIEW --><!-- INCLUDE posting/posting_preview.html --><!-- ENDIF -->
+ 
  				<fieldset>
  					<dl>
  						<dt><label for="name">{L_CONTRIB_NAME}:</label></dt>
***************
*** 104,109 ****
--- 107,113 ----
  			<div class="inner"><span class="corners-top main-corners"><span></span></span>
  				<fieldset class="submit-buttons">
  					<input type="reset" value="{L_RESET}" name="reset" class="button2" />&nbsp;
+ 					<input type="submit" name="preview" value="{L_PREVIEW}" class="button1" />&nbsp;
  					<input type="submit" name="submit" value="{L_SUBMIT}" class="button1" />
  					<!-- IF S_SUBMIT_NEW_REVISION --><input type="submit" name="new_revision" value="{L_SUBMIT_NEW_REVISION}" class="button1" /><!-- ENDIF -->
  					{S_FORM_TOKEN}




More information about the customisationdb-commits mailing list