diff options
Diffstat (limited to 'phpBB')
20 files changed, 265 insertions, 33 deletions
diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 0337080f3d..a486a69514 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -39,7 +39,8 @@  <script type="text/javascript" src="{T_JQUERY_LINK}"></script>  <!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF -->  <script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js"></script> -<script type="text/javascript" src="style/ajax.js"></script> +<!-- INCLUDEJS ajax.js --> +{SCRIPTS}  </body>  </html> diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 74db8cb8fd..a44ebb04e8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4770,7 +4770,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0  		'T_ASSETS_PATH'			=> "{$web_path}assets",  		'T_THEME_PATH'			=> "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme',  		'T_TEMPLATE_PATH'		=> "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', -		'T_SUPER_TEMPLATE_PATH'	=> ($user->theme['style_parent_id']) ? "{$web_path}styles/" . rawurlencode($user->theme['style_parent_tree']) . '/template' : "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', +		'T_SUPER_TEMPLATE_PATH'	=> "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template',  		'T_IMAGES_PATH'			=> "{$web_path}images/",  		'T_SMILIES_PATH'		=> "{$web_path}{$config['smilies_path']}/",  		'T_AVATAR_PATH'			=> "{$web_path}{$config['avatar_path']}/", diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 39505cedb5..3e6dd5d6aa 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -185,9 +185,12 @@ class phpbb_style_resource_locator  	* handle to a path without any filesystem or styles tree checks.  	*  	* @param string $handle Template handle (i.e. "friendly" template name) +	* @param bool $find_all If true, each root path will be checked and function +	*				will return array of files instead of string and will not +	*				trigger a error if template does not exist  	* @return string Source file path  	*/ -	public function get_source_file_for_handle($handle) +	public function get_source_file_for_handle($handle, $find_all = false)  	{  		// If we don't have a file assigned to this handle, die.  		if (!isset($this->files['style'][0][$handle])) @@ -198,20 +201,91 @@ class phpbb_style_resource_locator  		// locate a source file that exists  		$source_file = $this->files['style'][0][$handle];  		$tried = $source_file; +		$found = false; +		$found_all = array();  		foreach ($this->roots as $root_key => $root_paths)  		{  			foreach ($root_paths as $root_index => $root)  			{  				$source_file = $this->files[$root_key][$root_index][$handle]; +				$tried .= ', ' . $source_file;  				if (file_exists($source_file))  				{ -					return $source_file; +					$found = true; +					break; +				} +			} +			if ($found) +			{ +				if ($find_all) +				{ +					$found_all[] = $source_file; +					$found = false; +				} +				else +				{ +					break; +				} +			} +		} + +		// search failed +		if (!$found && !$find_all) +		{ +			trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); +		} + +		return ($find_all) ? $found_all : $source_file; +	} + +	/** +	* Locates source file path, accounting for styles tree and verifying that +	* the path exists. +	* +	* Unlike previous functions, this function works without template handle +	* and it can search for more than one file. If more than one file name is +	* specified, it will return location of file that it finds first. +	* +	* @param array $files List of files to locate. +	* @param bool $return_default Determines what to return if file does not +	*				exist. If true, function will return location where file is +	*				supposed to be. If false, function will return false. +	* @param bool $return_full_path If true, function will return full path +	*				to file. If false, function will return file name. This +	*				parameter can be used to check which one of set of files +	*				is available. +	* @return string or boolean Source file path if file exists or $return_default is +	*				true. False if file does not exist and $return_default is false +	*/ +	public function get_first_file_location($files, $return_default = false, $return_full_path = true) +	{ +		// set default value +		$default_result = false; + +		// check all available paths +		foreach ($this->roots as $root_paths) +		{ +			foreach ($root_paths as $path) +			{ +				// check all files +				foreach ($files as $filename) +				{ +					$source_file = $path . '/' . $filename; +					if (file_exists($source_file)) +					{ +						return ($return_full_path) ? $source_file : $filename; +					} + +					// assign first file as result if $return_default is true +					if ($return_default && $default_result === false) +					{ +						$default_result = $source_file; +					}  				} -				$tried .= ', ' . $source_file;  			}  		}  		// search failed -		trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); +		return $default_result;  	}  } diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index dc1e71dff6..5ac61c9f10 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -150,4 +150,32 @@ class phpbb_style  	{  		$this->provider->set_ext_dir_prefix($ext_dir_prefix);  	} + +	/** +	* Locates source file path, accounting for styles tree and verifying that +	* the path exists. +	* +	* @param string or array $files List of files to locate. If there is only +	*				one file, $files can be a string to make code easier to read. +	* @param bool $return_default Determines what to return if file does not +	*				exist. If true, function will return location where file is +	*				supposed to be. If false, function will return false. +	* @param bool $return_full_path If true, function will return full path +	*				to file. If false, function will return file name. This +	*				parameter can be used to check which one of set of files +	*				is available. +	* @return string or boolean Source file path if file exists or $return_default is +	*				true. False if file does not exist and $return_default is false +	*/ +	public function locate($files, $return_default = false, $return_full_path = true) +	{ +		// convert string to array +		if (is_string($files)) +		{ +			$files = array($files); +		} + +		// use resource locator to find files +		return $this->locator->get_first_file_location($files, $return_default, $return_full_path); +	}  } diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index 21a2e821dd..3f15355f7a 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -288,7 +288,7 @@ class phpbb_style_template  			return new phpbb_style_template_renderer_include($output_file, $this);  		} -		$compile = new phpbb_style_template_compile($this->config['tpl_allow_php']); +		$compile = new phpbb_style_template_compile($this->config['tpl_allow_php'], $this->locator, $this->phpbb_root_path);  		if ($compile->compile_file_to_file($source_file, $output_file) !== false)  		{ @@ -456,4 +456,59 @@ class phpbb_style_template  		}  		include($file);  	} + +	/** +	* Locates source template path, accounting for styles tree and verifying that +	* the path exists. +	* +	* @param string or array $files List of templates to locate. If there is only +	*				one template, $files can be a string to make code easier to read. +	* @param bool $return_default Determines what to return if template does not +	*				exist. If true, function will return location where template is +	*				supposed to be. If false, function will return false. +	* @param bool $return_full_path If true, function will return full path +	*				to template. If false, function will return template file name. +	*				This parameter can be used to check which one of set of template +	*				files is available. +	* @return string or boolean Source template path if template exists or $return_default is +	*				true. False if template does not exist and $return_default is false +	*/ +	public function locate($files, $return_default = false, $return_full_path = true) +	{ +		// add tempalte path prefix +		$templates = array(); +		if (is_string($files)) +		{ +			$templates[] = $this->template_path . $files; +		} +		else +		{ +			foreach ($files as $file) +			{ +				$templates[] = $this->template_path . $file; +			} +		} + +		// use resource locator to find files +		return $this->locator->get_first_file_location($templates, $return_default, $return_full_path); +	} + +	/** +	* Include JS file +	* +	* @param string $file file name +	* @param bool $locate True if file needs to be located +	*/ +	public function _js_include($file, $locate = false) +	{ +		// Locate file +		if ($locate) +		{ +			$file = $this->locator->get_first_file_location(array($file), true, true); +		} + +		// Add HTML code +		$code = '<script src="' . htmlspecialchars($file) . '"></script>'; +		$this->context->append_var('SCRIPTS', $code); +	}  } diff --git a/phpBB/includes/style/template_compile.php b/phpBB/includes/style/template_compile.php index 3ef3fffc00..fa0928f424 100644 --- a/phpBB/includes/style/template_compile.php +++ b/phpBB/includes/style/template_compile.php @@ -26,20 +26,26 @@ stream_filter_register('phpbb_template', 'phpbb_style_template_filter');  class phpbb_style_template_compile  {  	/** -	* Whether <!-- PHP --> tags are allowed +	* Array of parameters to forward to template filter  	* -	* @var bool +	* @var array  	*/ -	private $allow_php; +	private $filter_params;  	/**  	* Constructor.  	*  	* @param bool @allow_php Whether PHP code will be allowed in templates (inline PHP code, PHP tag and INCLUDEPHP tag) +	* @param phpbb_style_resource_locator $locator Resource locator +	* @param string $phpbb_root_path Path to phpBB root directory  	*/ -	public function __construct($allow_php) +	public function __construct($allow_php, $locator, $phpbb_root_path)  	{ -		$this->allow_php = $allow_php; +		$this->filter_params = array( +			'allow_php'	=> $allow_php, +			'locator'	=> $locator, +			'phpbb_root_path'	=> $phpbb_root_path +		);  	}  	/** @@ -116,7 +122,7 @@ class phpbb_style_template_compile  	*/  	private function compile_stream_to_stream($source_stream, $dest_stream)  	{ -		stream_filter_append($source_stream, 'phpbb_template', null, array('allow_php' => $this->allow_php)); +		stream_filter_append($source_stream, 'phpbb_template', null, $this->filter_params);  		stream_copy_to_stream($source_stream, $dest_stream);  	}  } diff --git a/phpBB/includes/style/template_filter.php b/phpBB/includes/style/template_filter.php index 04fe85e07f..d62ad0ba1e 100644 --- a/phpBB/includes/style/template_filter.php +++ b/phpBB/includes/style/template_filter.php @@ -76,6 +76,18 @@ class phpbb_style_template_filter extends php_user_filter  	private $allow_php;  	/** +	* Resource locator. +	* +	* @var phpbb_template_locator +	*/ +	private $locator; + +	/** +	* @var string phpBB root path +	*/ +	private $phpbb_root_path; + +	/**  	* Stream filter  	*  	* Is invoked for evey chunk of the stream, allowing us @@ -126,14 +138,16 @@ class phpbb_style_template_filter extends php_user_filter  	/**  	* Initializer, called on creation.  	* -	* Get the allow_php option from params, which is passed -	* to stream_filter_append. +	* Get the allow_php option, root directory and locator from params,  +	* which are passed to stream_filter_append.  	*/  	public function onCreate()  	{  		$this->chunk = '';  		$this->in_php = false;  		$this->allow_php = $this->params['allow_php']; +		$this->locator = $this->params['locator']; +		$this->phpbb_root_path = $this->params['phpbb_root_path'];  		return true;  	} @@ -281,6 +295,10 @@ class phpbb_style_template_filter extends php_user_filter  				return ($this->allow_php) ? '<?php ' . $this->compile_tag_include_php($matches[2]) . ' ?>' : '';  			break; +			case 'INCLUDEJS': +				return '<?php ' . $this->compile_tag_include_js($matches[2]) . ' ?>'; +			break; +  			case 'PHP':  				if ($this->allow_php)  				{ @@ -857,6 +875,45 @@ class phpbb_style_template_filter extends php_user_filter  	}  	/** +	* Compile INCLUDEJS tag +	* +	* @param string $tag_args Expression given with INCLUDEJS in source template +	* @return string compiled template code +	*/ +	private function compile_tag_include_js($tag_args) +	{ +		// Process dynamic includes +		if ($tag_args[0] == '{') +		{ +			$var = $this->get_varref($tag_args, $is_expr); +			if (!$is_expr) +			{ +				return " \$_template->_js_include($var, true);"; +			} +			return ''; +		} + +		// Locate file +		$filename = $this->locator->get_first_file_location(array($tag_args), false, true); +		 +		if ($filename === false) +		{ +			// File does not exist, find it during run time +			return ' $_template->_js_include(\'' . addslashes($tag_args) . '\', true); '; +		} +		 +		if (substr($filename, 0, strlen($this->phpbb_root_path)) != $this->phpbb_root_path) +		{ +			// Absolute path, include as is +			return ' $_template->_js_include(\'' . addslashes($filename) . '\', false); '; +		} + +		// Relative path, remove root path from it +		$filename = substr($filename, strlen($this->phpbb_root_path)); +		return ' global $phpbb_root_path; $_template->_js_include($phpbb_root_path . \'' . addslashes($filename) . '\', false); '; +	} + +	/**  	* Generates a reference to the given variable inside the given (possibly nested)  	* block namespace. This is a string of the form:  	* ' . $_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' diff --git a/phpBB/language/en/viewtopic.php b/phpBB/language/en/viewtopic.php index 1460490672..184f88ed3c 100644 --- a/phpBB/language/en/viewtopic.php +++ b/phpBB/language/en/viewtopic.php @@ -62,7 +62,7 @@ $lang = array_merge($lang, array(  	'FILE_NOT_FOUND_404'	=> 'The file <strong>%s</strong> does not exist.',  	'FORK_TOPIC'			=> 'Copy topic', -	'FULL_EDITOR'			=> 'Full Editor', +	'FULL_EDITOR'			=> 'Full Editor & Preview',  	'LINKAGE_FORBIDDEN'		=> 'You are not authorised to view, download or link from/to this site.',  	'LOGIN_NOTIFY_TOPIC'	=> 'You have been notified about this topic, please login to view it.', diff --git a/phpBB/posting.php b/phpBB/posting.php index 56fb7832f2..7f57f693af 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -38,7 +38,7 @@ $load		= (isset($_POST['load'])) ? true : false;  $delete		= (isset($_POST['delete'])) ? true : false;  $cancel		= (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; -$refresh	= (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$refresh	= (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview) ? true : false;  $mode		= ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', '');  $error = $post_data = array(); @@ -1198,8 +1198,8 @@ if (!sizeof($error) && $preview)  			'PREVIEW_MESSAGE'		=> $preview_message,  			'PREVIEW_SIGNATURE'		=> $preview_signature, -			'S_DISPLAY_PREVIEW'		=> true) -		); +			'S_DISPLAY_PREVIEW'		=> !empty($preview_message), +		));  	}  } diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index cc886c42b1..54f34e4204 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -66,6 +66,17 @@ $('[data-ajax]').each(function() {  }); +/** + * This simply appends #preview to the action of the + * QR action when you click the Full Editor & Preview button + */ +$('#qr_full_editor').click(function() { +	$('#qr_postform').attr('action', function(i, val) { +		return val + '#preview'; +	}); +}); + +  /**   * This AJAXifies the quick-mod tools. The reason it cannot be a standard diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js index 2c41b543b5..c16b0ef703 100644 --- a/phpBB/styles/prosilver/template/editor.js +++ b/phpBB/styles/prosilver/template/editor.js @@ -219,7 +219,7 @@ function addquote(post_id, username, l_wrote)  	// Get text selection - not only the post content :(  	// IE9 must use the document.selection method but has the *.getSelection so we just force no IE -	if (window.getSelection && !is_ie) +	if (window.getSelection && !is_ie && !window.opera)  	{  		theSelection = window.getSelection().toString();  	} diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 1561bae26a..47071ba4df 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -52,7 +52,8 @@  <script type="text/javascript" src="{T_JQUERY_LINK}"></script>  <!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF -->  <script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js"></script> -<script type="text/javascript" src="{T_TEMPLATE_PATH}/ajax.js"></script> +<!-- INCLUDEJS template/ajax.js --> +{SCRIPTS}  </body>  </html> diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index 4cd5eedd3e..a08b5dc3cc 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -1,4 +1,4 @@ -<form method="post" action="{U_QR_ACTION}"> +<form method="post" action="{U_QR_ACTION}" id="qr_postform">  	<div class="panel">  		<div class="inner"><span class="corners-top"><span></span></span>  				<h2>{L_QUICKREPLY}</h2> @@ -14,8 +14,8 @@  				<fieldset class="submit-buttons">  					{S_FORM_TOKEN}  					{QR_HIDDEN_FIELDS} -					<input type="submit" accesskey="s" tabindex="6" name="post" value="{L_SUBMIT}" class="button1" />  -					<input type="submit" accesskey="f" tabindex="7" name="full_editor" value="{L_FULL_EDITOR}" class="button2" data-ajax="false" />  +					<input type="submit" accesskey="f" tabindex="6" name="preview" value="{L_FULL_EDITOR}" class="button2" data-ajax="false" id="qr_full_editor" />  +					<input type="submit" accesskey="s" tabindex="7" name="post" value="{L_SUBMIT}" class="button1" />   				</fieldset>  		<span class="corners-bottom"><span></span></span></div>  	</div> diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index 3458d02495..549c31cfb6 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -8,6 +8,7 @@  <script type="text/javascript" src="{T_JQUERY_LINK}"></script>  <!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF --> +{SCRIPTS}  </body>  </html> diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 1d645ed177..e95acf52b8 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -385,7 +385,7 @@ ul.rightside {  /* Table styles  ----------------------------------------*/  table.table1 { -	/* See tweaks.css */ +	width: 100%;  }  #ucp-main table.table1 { @@ -594,7 +594,7 @@ li.pagination {  	border: 1px solid transparent;  	position: fixed;  	display: none; -	top: 100px; +	top: 40%;  	left: 35%;  	width: 30%;  	z-index: 50; diff --git a/phpBB/styles/prosilver/theme/tweaks.css b/phpBB/styles/prosilver/theme/tweaks.css index 416c4a5510..b32faaf501 100644 --- a/phpBB/styles/prosilver/theme/tweaks.css +++ b/phpBB/styles/prosilver/theme/tweaks.css @@ -4,10 +4,6 @@ These style definitions are IE 7 and 8 specific  tweaks required due to its poor CSS support.  -------------------------------------------------*/ -table.table1 { -	width: 100%; -} -  /* Align checkboxes/radio buttons nicely */  dd label input {   	vertical-align: text-bottom;  diff --git a/phpBB/styles/subsilver2/template/editor.js b/phpBB/styles/subsilver2/template/editor.js index b47583ec75..151cf53ff1 100644 --- a/phpBB/styles/subsilver2/template/editor.js +++ b/phpBB/styles/subsilver2/template/editor.js @@ -221,7 +221,7 @@ function addquote(post_id, username, l_wrote)  	// Get text selection - not only the post content :(  	// IE9 must use the document.selection method but has the *.getSelection so we just force no IE -	if (window.getSelection && !is_ie) +	if (window.getSelection && !is_ie && !window.opera)  	{  		theSelection = window.getSelection().toString();  	} diff --git a/phpBB/styles/subsilver2/template/overall_footer.html b/phpBB/styles/subsilver2/template/overall_footer.html index 9b0b95372e..77b11034b9 100644 --- a/phpBB/styles/subsilver2/template/overall_footer.html +++ b/phpBB/styles/subsilver2/template/overall_footer.html @@ -10,6 +10,7 @@  <script type="text/javascript" src="{T_JQUERY_LINK}"></script>  <!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF --> +{SCRIPTS}  </body>  </html> diff --git a/phpBB/styles/subsilver2/template/quickreply_editor.html b/phpBB/styles/subsilver2/template/quickreply_editor.html index de5017280c..4c3f7a3d0b 100644 --- a/phpBB/styles/subsilver2/template/quickreply_editor.html +++ b/phpBB/styles/subsilver2/template/quickreply_editor.html @@ -14,8 +14,8 @@  		</tr>  		<tr>  			<td class="cat" colspan="2" align="center"> -				<input class="btnmain" type="submit" accesskey="s" tabindex="6" name="post" value="{L_SUBMIT}" />  -				<input class="btnlite" type="submit" accesskey="f" tabindex="7" name="full_editor" value="{L_FULL_EDITOR}" /> +				<input class="btnlite" type="submit" accesskey="f" tabindex="6" name="preview" value="{L_FULL_EDITOR}" />  +				<input class="btnmain" type="submit" accesskey="s" tabindex="7" name="post" value="{L_SUBMIT}" />  				{S_FORM_TOKEN}  				{QR_HIDDEN_FIELDS} diff --git a/phpBB/styles/subsilver2/template/simple_footer.html b/phpBB/styles/subsilver2/template/simple_footer.html index b51be3ac4c..4a65bafd1c 100644 --- a/phpBB/styles/subsilver2/template/simple_footer.html +++ b/phpBB/styles/subsilver2/template/simple_footer.html @@ -7,6 +7,7 @@  <script type="text/javascript" src="{T_JQUERY_LINK}"></script>  <!-- IF S_JQUERY_FALLBACK --><script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript src="{T_ASSETS_PATH}/javascript/jquery.js" type="text/javascript"%3E%3C/script%3E'));</script><!-- ENDIF --> +{SCRIPTS}  </body>  </html>  | 
