[Customisation Database Commits] r1126 [3/3] - in /branches/stable: ./ titania/includes/ titania/includes/library/automod/ titania/manage/

Nathan Guse exreaction at phpbb.com
Mon Apr 26 19:30:03 BST 2010


Modified: branches/stable/titania/includes/library/automod/editor.php
==============================================================================
*** branches/stable/titania/includes/library/automod/editor.php (original)
--- branches/stable/titania/includes/library/automod/editor.php Mon Apr 26 19:30:02 2010
***************
*** 70,76 ****
  
  	/**
  	* Only used when board has templates stored in the database
! 	*/
  	var $template_id = 0;
  
  	/**
--- 70,76 ----
  
  	/**
  	* Only used when board has templates stored in the database
! 	*/ 
  	var $template_id = 0;
  
  	/**
***************
*** 169,181 ****
  					{
  						$find_ary[$j] = $function($find_ary[$j]);
  					}
! 
  					// if we've reached the EOF, the find failed.
  					if (!isset($this->file_contents[$i + $j]))
  					{
  						return false;
  					}
! 
  					if (!trim($find_ary[$j]))
  					{
  						// line is blank.  Assume we can find a blank line, and continue on
--- 169,181 ----
  					{
  						$find_ary[$j] = $function($find_ary[$j]);
  					}
! 	
  					// if we've reached the EOF, the find failed.
  					if (!isset($this->file_contents[$i + $j]))
  					{
  						return false;
  					}
! 	
  					if (!trim($find_ary[$j]))
  					{
  						// line is blank.  Assume we can find a blank line, and continue on
***************
*** 194,200 ****
  					else if (strpos($find_ary[$j], '{%:') !== false)
  					{
  						$regex = preg_replace('#{%:(\d+)}#', '(\d+)', $find_ary[$j]);
! 
  						if (preg_match('#' . $regex . '#is', $this->file_contents[$i + $j]))
  						{
  							$find_success += 1;
--- 194,200 ----
  					else if (strpos($find_ary[$j], '{%:') !== false)
  					{
  						$regex = preg_replace('#{%:(\d+)}#', '(\d+)', $find_ary[$j]);
! 	
  						if (preg_match('#' . $regex . '#is', $this->file_contents[$i + $j]))
  						{
  							$find_success += 1;
***************
*** 208,230 ****
  					{
  						// the find failed.  Reset $find_success
  						$find_success = 0;
! 
  						// skip to next iteration of outer loop, that is, skip to the next line
  						break;
  					}
! 
  					if ($find_success == $find_lines)
  					{
  						// we found the proper number of lines
  						$this->start_index = $i;
! 
  						// return our array offsets
  						return array(
  							'start' => $i,
  							'end' => $i + $j,
  						);
  					}
! 
  				}
  			}
  		}
--- 208,230 ----
  					{
  						// the find failed.  Reset $find_success
  						$find_success = 0;
! 	
  						// skip to next iteration of outer loop, that is, skip to the next line
  						break;
  					}
! 	
  					if ($find_success == $find_lines)
  					{
  						// we found the proper number of lines
  						$this->start_index = $i;
! 	
  						// return our array offsets
  						return array(
  							'start' => $i,
  							'end' => $i + $j,
  						);
  					}
! 	
  				}
  			}
  		}
***************
*** 234,240 ****
  	}
  
  	/**
! 	* This function is used to determine when an edit has ended, so we know that
  	* the current line will not be looked at again.  This fixes some former bugs.
  	*/
  	function close_edit()
--- 234,240 ----
  	}
  
  	/**
! 	* This function is used to determine when an edit has ended, so we know that 
  	* the current line will not be looked at again.  This fixes some former bugs.
  	*/
  	function close_edit()
***************
*** 614,620 ****
  		else if ($pos == 'BEFORE')
  		{
  			$this->file_contents[$array_offset] = substr_replace($this->file_contents[$array_offset], $inline_add, $string_offset, 0);
! 			$this->last_string_offset += $length;
  		}
  
  		$this->curr_action = func_get_args();
--- 614,620 ----
  		else if ($pos == 'BEFORE')
  		{
  			$this->file_contents[$array_offset] = substr_replace($this->file_contents[$array_offset], $inline_add, $string_offset, 0);
! 			$this->last_string_offset += (strlen($inline_add) - 1);
  		}
  
  		$this->curr_action = func_get_args();
***************
*** 626,632 ****
  
  	/**
  	* Function to build full edits such that uninstall will work more often
! 	*
  	* @param $find - The largest find we can put together -- sometimes this
  	* 		comes from the file itself, other times from the MODX file
  	* @param $inline_find - Subset of $find or NULL
--- 626,632 ----
  
  	/**
  	* Function to build full edits such that uninstall will work more often
! 	* 
  	* @param $find - The largest find we can put together -- sometimes this
  	* 		comes from the file itself, other times from the MODX file
  	* @param $inline_find - Subset of $find or NULL
***************
*** 636,653 ****
  	*/
  	function build_uninstall($find, $inline_find, $action_type, $action)
  	{
! 		$find = trim($find);
! 		$inline_find = trim($inline_find);
! 		$action = trim($action);
  
  		/*
! 		* This if statement finds out if we are in the special case where
  		* a MOD specifies a before action and an after action on the same
  		* find.  If this is the case, the uninstaller must see a replace
  		* rather than an add
  		*/
  		if (!empty($this->last_action) && $this->last_action[0] == $this->curr_action[0] &&
! 			(($this->last_action[2] == 'AFTER' && $this->curr_action[2] == 'BEFORE')
  			|| ($this->last_action[2] == 'BEFORE' && $this->curr_action[2] == 'AFTER')))
  		{
  			$last_action_index = sizeof($this->mod_actions[$this->open_filename]) - 1;
--- 636,653 ----
  	*/
  	function build_uninstall($find, $inline_find, $action_type, $action)
  	{
! 		$find = trim($find, "\n");
! 		$inline_find = trim($inline_find, "\n");
! 		$action = trim($action, "\n");
  
  		/*
! 		* This if statement finds out if we are in the special case where 
  		* a MOD specifies a before action and an after action on the same
  		* find.  If this is the case, the uninstaller must see a replace
  		* rather than an add
  		*/
  		if (!empty($this->last_action) && $this->last_action[0] == $this->curr_action[0] &&
! 			(($this->last_action[2] == 'AFTER' && $this->curr_action[2] == 'BEFORE') 
  			|| ($this->last_action[2] == 'BEFORE' && $this->curr_action[2] == 'AFTER')))
  		{
  			$last_action_index = sizeof($this->mod_actions[$this->open_filename]) - 1;
***************
*** 712,718 ****
  
  /**
  * @package automod
! * class editor_direct will alter files by using the local file access functions
  * such as fopen and fwrite.  This is typically only useful in Windows environments
  * due to permissions settings.
  */
--- 712,718 ----
  
  /**
  * @package automod
! * class editor_direct will alter files by using the local file access functions 
  * such as fopen and fwrite.  This is typically only useful in Windows environments
  * due to permissions settings.
  */
***************
*** 731,739 ****
  	* @param $to string Where to move the file(s) to. If not specified then will get moved to the root folder
  	* @param $strip Used for FTP only
  	* @return mixed: Bool true on success, error string on failure, NULL if no action was taken
! 	*
! 	* NOTE: function should preferably not return in case of failure on only one file.
! 	* 	The current method makes error handling difficult
  	*/
  	function copy_content($from, $to = '', $strip = '')
  	{
--- 731,739 ----
  	* @param $to string Where to move the file(s) to. If not specified then will get moved to the root folder
  	* @param $strip Used for FTP only
  	* @return mixed: Bool true on success, error string on failure, NULL if no action was taken
! 	* 
! 	* NOTE: function should preferably not return in case of failure on only one file.  
! 	* 	The current method makes error handling difficult 
  	*/
  	function copy_content($from, $to = '', $strip = '')
  	{
***************
*** 846,852 ****
  		$length_written = @fwrite($fr, $file_contents);
  		@chmod($new_filename, octdec($config['am_file_perms']));
  
! 		// This appears to be correct even with multibyte encodings.  strlen and
  		// fwrite both return the number of bytes written, not the number of chars
  		if ($length_written < strlen($file_contents))
  		{
--- 846,852 ----
  		$length_written = @fwrite($fr, $file_contents);
  		@chmod($new_filename, octdec($config['am_file_perms']));
  
! 		// This appears to be correct even with multibyte encodings.  strlen and 
  		// fwrite both return the number of bytes written, not the number of chars
  		if ($length_written < strlen($file_contents))
  		{
***************
*** 855,861 ****
  
  		if (!@fclose($fr))
  		{
! 			return sprintf($user->lang['WRITE_DIRECT_FAIL'], $new_filename);
  		}
  
  		return true;
--- 855,861 ----
  
  		if (!@fclose($fr))
  		{
! 			return sprintf($user->lang['WRITE_DIRECT_FAIL'], $new_filename);			
  		}
  
  		return true;
***************
*** 964,972 ****
  	* @param $to string Where to move the file(s) to. If not specified then will get moved to the root folder
  	* @param $strip Used for FTP only
  	* @return mixed: Bool true on success, error string on failure, NULL if no action was taken
! 	*
! 	* NOTE: function should preferably not return in case of failure on only one file.
! 	* 	The current method makes error handling difficult
  	*/
  	function copy_content($from, $to = '', $strip = '')
  	{
--- 964,972 ----
  	* @param $to string Where to move the file(s) to. If not specified then will get moved to the root folder
  	* @param $strip Used for FTP only
  	* @return mixed: Bool true on success, error string on failure, NULL if no action was taken
! 	* 
! 	* NOTE: function should preferably not return in case of failure on only one file.  
! 	* 	The current method makes error handling difficult 
  	*/
  	function copy_content($from, $to = '', $strip = '')
  	{
***************
*** 1008,1021 ****
  		// ftp
  		foreach ($files as $file)
  		{
! 			if (is_dir($to))
! 			{
! 				$to_file = str_replace(array($phpbb_root_path, $strip), '', $file);
! 			}
! 			else
! 			{
! 				$to_file = str_replace($phpbb_root_path, '', $to);
! 			}
  
  			$this->recursive_mkdir(dirname($to_file));
  
--- 1008,1014 ----
  		// ftp
  		foreach ($files as $file)
  		{
! 			$to_file = str_replace($strip, '', $file);
  
  			$this->recursive_mkdir(dirname($to_file));
  
***************
*** 1154,1171 ****
  		{
  			if (is_dir($to))
  			{
! 				$to_file = str_replace(array($phpbb_root_path, $strip), '', $file);
  			}
  			else
  			{
  				$to_file = str_replace($phpbb_root_path, '', $to);
  			}
  
! 			// filename calculation is involved here: be sure to remove "store/mods/foo"
  			// and prepend the "files" directory
! 			if (!$this->compress->add_file($to_file, substr($to_file, 0, strpos($to_file, 'root/') + 5), 'files'))
  			{
! 				return sprintf($user->lang['WRITE_MANUAL_FAIL'], $new_filename);
  			}
  		}
  
--- 1147,1167 ----
  		{
  			if (is_dir($to))
  			{
! 				// this would find the directory part specified in MODX
! 				$to_file = str_replace(array($phpbb_root_path, $strip), '', $to);
! 				// and this fetches any subdirectories and the filename of the destination file
! 				$to_file .= substr($file, strpos($file, $to_file) + strlen($to_file));
  			}
  			else
  			{
  				$to_file = str_replace($phpbb_root_path, '', $to);
  			}
  
! 			// filename calculation is involved here:
  			// and prepend the "files" directory
! 			if (!$this->compress->add_custom_file($file, 'files/' . $to_file))
  			{
! 				return sprintf($user->lang['WRITE_MANUAL_FAIL'], $to_file);
  			}
  		}
  
***************
*** 1190,1196 ****
  
  		// don't include extra dirs in zip file
  		$strip_position = strpos($new_filename, '_edited') + 8; // want the end of the string
! 		if (!$strip_position)
  		{
  			$strip_position = strpos($new_filename, '_uninst') + 7;
  		}
--- 1186,1192 ----
  
  		// don't include extra dirs in zip file
  		$strip_position = strpos($new_filename, '_edited') + 8; // want the end of the string
! 		if ($strip_position == 8)
  		{
  			$strip_position = strpos($new_filename, '_uninst') + 7;
  		}
***************
*** 1244,1249 ****
  	{
  		return NULL;
  	}
! }
  
  ?>
\ No newline at end of file
--- 1240,1245 ----
  	{
  		return NULL;
  	}
! } 
  
  ?>
\ No newline at end of file

Modified: branches/stable/titania/includes/library/automod/functions_mods.php
==============================================================================
*** branches/stable/titania/includes/library/automod/functions_mods.php (original)
--- branches/stable/titania/includes/library/automod/functions_mods.php Mon Apr 26 19:30:02 2010
***************
*** 273,278 ****
--- 273,312 ----
  }
  
  /**
+  * Recursively delete a directory
+  *
+  * @param string $file File name
+  * @author A_Jelly_Doughnut
+  */
+ function recursive_unlink($file)
+ {
+ 	if (!($dh = opendir($file)))
+ 	{
+ 		return false;
+ 	}
+ 
+ 	while (($subfile = readdir($dh)) !== false)
+ 	{
+ 		if ($subfile[0] == '.')
+ 		{
+ 		    continue;
+ 		}
+ 
+ 		if (!unlink($file. '/' . $subfile))
+ 		{
+ 			recursive_unlink($file . '/' . $subfile);
+ 		}
+ 	}
+ 
+ 	closedir($dh);
+ 
+ 	rmdir($file);
+ 
+ 	return true;
+ }
+ 
+ 
+ /**
  * PHP 5 Wrapper - simulate scandir, but only those features that we actually need
  * NB: The third parameter of PHP5 native scandir is _not_ present in this wrapper
  */

Modified: branches/stable/titania/includes/library/automod/mod_parser.php
==============================================================================
*** branches/stable/titania/includes/library/automod/mod_parser.php (original)
--- branches/stable/titania/includes/library/automod/mod_parser.php Mon Apr 26 19:30:02 2010
***************
*** 1,10 ****
  <?php
! /**
  *
  * @package automod
  * @version $Id$
  * @copyright (c) 2008 phpBB Group
! * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
  *
  */
  /**
--- 1,10 ----
  <?php
! /** 
  *
  * @package automod
  * @version $Id$
  * @copyright (c) 2008 phpBB Group
! * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License 
  *
  */
  /**
***************
*** 151,156 ****
--- 151,157 ----
  							break;
  
  							case 'IN-LINE-EDIT':
+ 								$action_id = 0;
  								// build the reverse just like the normal action
  								foreach ($command as $inline_find => $inline_action_ary)
  								{
***************
*** 163,188 ****
  											case 'IN-LINE-AFTER-ADD':
  											case 'IN-LINE-BEFORE-ADD':
  												// Replace with a blank string
! 												$reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$inline_command]['in-line-replace'][] = '';
  											break;
! 
  											case 'IN-LINE-REPLACE':
  												// replace with the inline find
! 												$reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$inline_command][$inline_action][] = $inline_find;
  											break;
! 
  											default:
  												// For the moment, we do nothing.  What about increment?
  											break;
  										}
  									}
  								}
  							break;
  
- 							case 'SQL':
- 								$reverse_edits['SQL'][] = $this->reverse_query($command);
- 							break;
- 
  							default:
  								// again, increment
  							break;
--- 164,187 ----
  											case 'IN-LINE-AFTER-ADD':
  											case 'IN-LINE-BEFORE-ADD':
  												// Replace with a blank string
! 												$reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command]['in-line-replace'][] = '';
  											break;
! 	
  											case 'IN-LINE-REPLACE':
  												// replace with the inline find
! 												$reverse_edits['EDITS'][$file][$edit_id][$find]['in-line-edit'][$action_id][$inline_command][$inline_action][] = $inline_find;
  											break;
! 	
  											default:
  												// For the moment, we do nothing.  What about increment?
  											break;
  										}
+ 
+ 										$action_id++;
  									}
  								}
  							break;
  
  							default:
  								// again, increment
  							break;
***************
*** 192,197 ****
--- 191,211 ----
  			}
  		}
  
+ 		if (empty($actions['SQL']))
+ 		{
+ 			return $reverse_edits;
+ 		}
+ 
+ 		if (sizeof($actions['SQL']) == 1)
+ 		{
+ 			$actions['SQL'] = explode("\n", $actions['SQL'][0]);
+ 		}
+ 
+ 		foreach ($actions['SQL'] as $query)
+ 		{
+ 			$reverse_edits['SQL'][] = parser::reverse_query($query);
+ 		}
+ 
  		return $reverse_edits;
  	}
  }
***************
*** 268,274 ****
  		{
  			$this->modx_version = 1.2;
  
! 			$version = trim($header['MOD-VERSION'][0]['data']);
  		}
  
  		// get phpBB version recommendation
--- 282,288 ----
  		{
  			$this->modx_version = 1.2;
  
! 			$version = trim($header['MOD-VERSION'][0]['data']); 
  		}
  
  		// get phpBB version recommendation
***************
*** 320,326 ****
  
  			for ($j = 0; $j < $changelog_size; $j++)
  			{
! 				// Ignore changelogs in foreign languages except in the case that there is no
  				// match for the current user's language
  				// TODO: Look at modifying localise_tags() for use here.
  				if (match_language($user->data['user_lang'], $changelog[$j]['attrs']['LANG']))
--- 334,340 ----
  
  			for ($j = 0; $j < $changelog_size; $j++)
  			{
! 				// Ignore changelogs in foreign languages except in the case that there is no 
  				// match for the current user's language
  				// TODO: Look at modifying localise_tags() for use here.
  				if (match_language($user->data['user_lang'], $changelog[$j]['attrs']['LANG']))
***************
*** 371,385 ****
  				for ($i = 0, $size = sizeof($link_group['LINK']); $i <= $size; $i++)
  				{
  					// do some stuff with attrs
! 					// commented out due to a possible PHP bug.  When using this,
  					// sizeof($link_group) changed each time ...
  					// $attrs = &$link_group[$i]['attrs'];
! 
  					if (!isset($link_group['LINK'][$i]))
  					{
  						continue;
  					}
  
  					$children[$link_group['LINK'][$i]['attrs']['TYPE']][] = array(
  						'href'		=> $link_group['LINK'][$i]['attrs']['HREF'],
  						'realname'	=> isset($link_group['LINK'][$i]['attrs']['REALNAME']) ? $link_group['LINK'][$i]['attrs']['REALNAME'] : core_basename($link_group['LINK'][$i]['attrs']['HREF']),
--- 385,404 ----
  				for ($i = 0, $size = sizeof($link_group['LINK']); $i <= $size; $i++)
  				{
  					// do some stuff with attrs
! 					// commented out due to a possible PHP bug.  When using this, 
  					// sizeof($link_group) changed each time ...
  					// $attrs = &$link_group[$i]['attrs'];
! 	
  					if (!isset($link_group['LINK'][$i]))
  					{
  						continue;
  					}
  
+                     if ($link_group['LINK'][$i]['attrs']['TYPE'] == 'text')
+ 					{
+ 						continue;
+ 					}
+ 
  					$children[$link_group['LINK'][$i]['attrs']['TYPE']][] = array(
  						'href'		=> $link_group['LINK'][$i]['attrs']['HREF'],
  						'realname'	=> isset($link_group['LINK'][$i]['attrs']['REALNAME']) ? $link_group['LINK'][$i]['attrs']['REALNAME'] : core_basename($link_group['LINK'][$i]['attrs']['HREF']),
***************
*** 439,445 ****
  			break;
  
  			// and now for the MySQL fun
! 			// This will generate an array of things we can probably use, but
  			// will not have any priority
  			case 'mysqli':
  				$match_dbms = array('mysql_41', 'mysqli', 'mysql');
--- 458,464 ----
  			break;
  
  			// and now for the MySQL fun
! 			// This will generate an array of things we can probably use, but	
  			// will not have any priority
  			case 'mysqli':
  				$match_dbms = array('mysql_41', 'mysqli', 'mysql');
***************
*** 502,507 ****
--- 521,537 ----
  			}
  		}
  
+ 		$delete_files_info = (!empty($xml_actions['DELETE'])) ? $xml_actions['DELETE'] : array();
+ 		for ($i = 0; $i < sizeof($delete_files_info); $i++)
+ 		{
+ 			$delete_files = $delete_files_info[$i]['children']['FILE'];
+ 			for ($j = 0; $j < sizeof($delete_files); $j++)
+ 			{
+ 				$name = str_replace('\\', '/', $delete_files[$j]['attrs']['NAME']);
+ 				$actions['DELETE_FILES'][] = $name;
+ 			}
+ 		}
+ 
  		// open
  		$open_info = (!empty($xml_actions['OPEN'])) ? $xml_actions['OPEN'] : array();
  		for ($i = 0; $i < sizeof($open_info); $i++)
***************
*** 516,522 ****
  				$action_info = (!empty($edit_info[$j]['children'])) ? $edit_info[$j]['children'] : array();
  
  				// store some array information to help decide what kind of operation we're doing
! 				$action_count = $total_action_count = 0;
  				if (isset($action_info['ACTION']))
  				{
  					$action_count += sizeof($action_info['ACTION']);
--- 546,552 ----
  				$action_info = (!empty($edit_info[$j]['children'])) ? $edit_info[$j]['children'] : array();
  
  				// store some array information to help decide what kind of operation we're doing
! 				$action_count = $total_action_count = $remove_count = $find_count = 0;
  				if (isset($action_info['ACTION']))
  				{
  					$action_count += sizeof($action_info['ACTION']);
***************
*** 527,533 ****
  					$total_action_count += sizeof($action_info['INLINE-EDIT']);
  				}
  
! 				$find_count = sizeof($action_info['FIND']);
  				// first we try all the possibilities for a FIND/ACTION combo, then look at inline possibilities.
  
  				if (isset($action_info['ACTION']))
--- 557,601 ----
  					$total_action_count += sizeof($action_info['INLINE-EDIT']);
  				}
  
! 				if (isset($action_info['REMOVE']))
! 				{
! 					$remove_count = sizeof($action_info['REMOVE']); // should be an integer bounded between zero and one
! 				}
! 
! 				if (isset($action_info['FIND']))
! 				{
! 					$find_count = sizeof($action_info['FIND']);
! 				}
! 
! 				// the basic idea is to transform a "remove" tag into a replace-with action
! 				if ($remove_count && !$find_count)
! 				{
! 					// but we still support it if $remove_count is > 1
! 					for ($k = 0; $k < $remove_count; $k++)
! 					{
! 						// if there is no find tag associated, handle it directly
! 						$actions['EDITS'][$current_file][$j][trim($action_info['REMOVE'][$k]['data'], "\n\r")]['replace with'] = '';
! 					}
! 				}
! 				else if ($remove_count && $find_count)
! 				{
! 					// if there is a find and a remove, transform into a replace-with
! 					// action, and let the logic below sort out the relationships.
!                     for ($k = 0; $k < $remove_count; $k++)
! 					{
! 						$insert_index = (isset($action_info['ACTION'])) ? sizeof($action_info['ACTION']) : 0;
! 
! 						$action_info['ACTION'][$insert_index] = array(
! 							'data' => '',
! 							'attrs' => array('TYPE'	=> 'replace with'),
! 						);
! 					}
! 				}
! 				else if (!$find_count)
! 				{
! 					trigger_error(sprintf($user->lang['INVALID_MOD_NO_FIND'], htmlspecialchars($action_info['ACTION'][0]['data'])), E_USER_WARNING);
! 				}
! 
  				// first we try all the possibilities for a FIND/ACTION combo, then look at inline possibilities.
  
  				if (isset($action_info['ACTION']))
***************
*** 537,549 ****
  						// is this anything but the last iteration of the loop?
  						if ($k < ($find_count - 1))
  						{
! 							// NULL has special meaning for an action ... no action to be taken; advance pointer
  							$actions['EDITS'][$current_file][$j][$action_info['FIND'][$k]['data']] = NULL;
  						}
  						else
  						{
! 							// this is the last iteration, assign the action tags
! 
  							for ($l = 0; $l < $action_count; $l++)
  							{
  								$type = str_replace('-', ' ', $action_info['ACTION'][$l]['attrs']['TYPE']);
--- 605,617 ----
  						// is this anything but the last iteration of the loop?
  						if ($k < ($find_count - 1))
  						{
! 							// NULL has special meaning for an action ... no action to be taken; advance pointer 
  							$actions['EDITS'][$current_file][$j][$action_info['FIND'][$k]['data']] = NULL;
  						}
  						else
  						{
! 							// this is the last iteration, assign the action tags 
! 			
  							for ($l = 0; $l < $action_count; $l++)
  							{
  								$type = str_replace('-', ' ', $action_info['ACTION'][$l]['attrs']['TYPE']);
***************
*** 552,557 ****
--- 620,632 ----
  						}
  					}
  				}
+ 				else
+ 				{
+ 					if (!$remove_count && !$total_action_count)
+ 					{
+ 						trigger_error(sprintf($user->lang['INVALID_MOD_NO_ACTION'], htmlspecialchars($action_info['FIND'][0]['data'])), E_USER_WARNING);
+ 					}
+ 				}
  
  				// add comment to the actions array
  				$actions['EDITS'][$current_file][$j]['comment'] = localise_tags($action_info, 'COMMENT');
***************
*** 561,566 ****
--- 636,654 ----
  				{
  					$inline_info = (!empty($action_info['INLINE-EDIT'])) ? $action_info['INLINE-EDIT'] : array();
  
+ 					if (isset($inline_info[0]['children']['INLINE-REMOVE']) && sizeof($inline_info[0]['children']['INLINE-REMOVE']))
+ 					{
+ 						// overwrite the existing array with the new one
+ 						$inline_info[0]['children'] = array(
+ 							'INLINE-FIND'   => $inline_info[0]['children']['INLINE-REMOVE'],
+ 							'INLINE-ACTION' => array(
+ 								0 => array(
+ 									'attrs'	=> array('TYPE'	=> 'replace-with'),
+ 									'data'	=> '',
+ 								),
+ 							),
+ 						);
+ 					}
  					if ($find_count > $total_action_count)
  					{
  						// Yeah, $k is used more than once for different information
***************
*** 569,575 ****
  							// is this anything but the last iteration of the loop?
  							if ($k < ($find_count - 1))
  							{
! 								// NULL has special meaning for an action ... no action to be taken; advance pointer
  								$actions['EDITS'][$current_file][$j][trim($action_info['FIND'][$k]['data'], "\r\n")] = NULL;
  							}
  						}
--- 657,663 ----
  							// is this anything but the last iteration of the loop?
  							if ($k < ($find_count - 1))
  							{
! 								// NULL has special meaning for an action ... no action to be taken; advance pointer 
  								$actions['EDITS'][$current_file][$j][trim($action_info['FIND'][$k]['data'], "\r\n")] = NULL;
  							}
  						}
***************
*** 584,595 ****
  					{
  						$inline_data = (!empty($inline_info[$k]['children'])) ? $inline_info[$k]['children'] : array();
  
! 						$inline_find_count = sizeof($inline_data['INLINE-FIND']);
  
  						$inline_comment = localise_tags($inline_data, 'INLINE-COMMENT');
  						$actions['EDITS'][$current_file][$j][trim($action_info['FIND'][$find_count - 1]['data'], "\r\n")]['in-line-edit']['inline-comment'] = $inline_comment;
  
  						$inline_actions = (!empty($inline_data['INLINE-ACTION'])) ? $inline_data['INLINE-ACTION'] : array();
  						for ($l = 0; $l < $inline_find_count; $l++)
  						{
  							$inline_find = $inline_data['INLINE-FIND'][$l]['data'];
--- 672,693 ----
  					{
  						$inline_data = (!empty($inline_info[$k]['children'])) ? $inline_info[$k]['children'] : array();
  
! 						$inline_find_count = (isset($inline_data['INLINE-FIND'])) ? sizeof($inline_data['INLINE-FIND']) : 0;
  
  						$inline_comment = localise_tags($inline_data, 'INLINE-COMMENT');
  						$actions['EDITS'][$current_file][$j][trim($action_info['FIND'][$find_count - 1]['data'], "\r\n")]['in-line-edit']['inline-comment'] = $inline_comment;
  
  						$inline_actions = (!empty($inline_data['INLINE-ACTION'])) ? $inline_data['INLINE-ACTION'] : array();
+ 
+ 						if (empty($inline_actions))
+ 						{
+ 							trigger_error(sprintf($user->lang['INVALID_MOD_NO_ACTION'], htmlspecialchars($inline_data['INLINE-FIND'][0]['data'])), E_USER_WARNING);
+ 						}
+ 						if (empty($inline_find_count))
+ 						{
+ 							trigger_error(sprintf($user->lang['INVALID_MOD_NO_FIND'], htmlspecialchars($inline_actions[0]['data'])), E_USER_WARNING);
+ 						}
+ 
  						for ($l = 0; $l < $inline_find_count; $l++)
  						{
  							$inline_find = $inline_data['INLINE-FIND'][$l]['data'];
***************
*** 624,629 ****
--- 722,732 ----
  			}
  		}
  
+ 		if (!empty($xml_actions['PHP-INSTALLER']))
+ 		{
+ 			$actions['PHP_INSTALLER'] = $xml_actions['PHP-INSTALLER'][0]['data'];
+ 		}
+ 
  		if (!empty($xml_actions['DIY-INSTRUCTIONS']))
  		{
  			$actions['DIY_INSTRUCTIONS'] = localise_tags($xml_actions, 'DIY-INSTRUCTIONS');
***************
*** 653,659 ****
  		$this->XML = xml_parse($this->parser, $XML);
  		if (!$this->XML)
  		{
! 			die(sprintf("<strong>XML error</strong>: %s at line %d.  View the file %s in a web browser for a more detailed error message.",
  				xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser), $file));
  		}
  
--- 756,762 ----
  		$this->XML = xml_parse($this->parser, $XML);
  		if (!$this->XML)
  		{
! 			die(sprintf("<strong>XML error</strong>: %s at line %d.  View the file %s in a web browser for a more detailed error message.", 
  				xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser), $file));
  		}
  

Modified: branches/stable/titania/manage/queue.php
==============================================================================
*** branches/stable/titania/manage/queue.php (original)
--- branches/stable/titania/manage/queue.php Mon Apr 26 19:30:02 2010
***************
*** 150,155 ****
--- 150,158 ----
  					// Install the style on the demo board?
  					if ($contrib->contrib_type == TITANIA_TYPE_STYLE && isset($_POST['style_demo_install']) && titania::$config->demo_style_path)
  					{
+ 						// Reload the contrib, it hath changed
+ 						$contrib->load((int) $queue->contrib_id);
+ 
  						$revision = $queue->get_revision();
  
  						$sql = 'SELECT attachment_directory, physical_filename FROM ' . TITANIA_ATTACHMENTS_TABLE . '




More information about the customisationdb-commits mailing list