Vergleich admin/modules/style/templates.php - 1.4.7 - 1.4.15

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: index.php 2992 2007-04-05 14:43:48Z chris $

 * $Id: templates.php 5379 2011-02-21 11:06:42Z Tomm $

 */

// Disallow direct access to this file for security reasons

 */

// Disallow direct access to this file for security reasons

Zeile 388Zeile 388
		
if(!$errors)
{

		
if(!$errors)
{

 
			$query = $db->simple_select("templates", "*", "tid='{$mybb->input['tid']}'");
$template = $db->fetch_array($query);


			$template_array = array(
'title' => $db->escape_string($mybb->input['title']),
'sid' => $sid,

			$template_array = array(
'title' => $db->escape_string($mybb->input['title']),
'sid' => $sid,

Zeile 397Zeile 400
				'dateline' => TIME_NOW
);


				'dateline' => TIME_NOW
);


			$tid = intval($mybb->input['tid']);
if($mybb->input['sid'] > 0)




			// Make sure we have the correct tid associated with this template. If the user double submits then the tid could originally be the master template tid, but because the form is sumbitted again, the tid doesn't get updated to the new modified template one. This then causes the master template to be overwritten
$query = $db->simple_select("templates", "tid", "title='".$db->escape_string($template['title'])."' AND (sid = '-2' OR sid = '{$template['sid']}')", array('order_by' => 'sid', 'order_dir' => 'desc', 'limit' => 1));
$template['tid'] = $db->fetch_field($query, "tid");

if($sid > 0)

			{

			{

				$query = $db->simple_select("templates", "sid", "title='".$db->escape_string($mybb->input['title'])."' AND (sid = '-2' OR sid = '{$sid}')", array('order_by' => 'sid', 'order_dir' => 'desc', 'limit' => 1));
if($db->fetch_field($query, "sid") == -2)





				// Check to see if it's never been edited before (i.e. master) of if this a new template (i.e. we've renamed it)  or if it's a custom template
$query = $db->simple_select("templates", "sid", "title='".$db->escape_string($mybb->input['title'])."' AND (sid = '-2' OR sid = '{$sid}' OR sid='{$template['sid']}')", array('order_by' => 'sid', 'order_dir' => 'desc'));
$existing_sid = $db->fetch_field($query, "sid");
$existing_rows = $db->num_rows($query);

if(($existing_sid == -2 && $existing_rows == 1) || $existing_rows == 0)

				{
$tid = $db->insert_query("templates", $template_array);
}
else
{

				{
$tid = $db->insert_query("templates", $template_array);
}
else
{

					$db->update_query("templates", $template_array, "tid='{$tid}'");

					$db->update_query("templates", $template_array, "tid='{$template['tid']}' AND sid != '-2'");

				}
}
else
{
// Global template set

				}
}
else
{
// Global template set

				$db->update_query("templates", $template_array, "tid='{$tid}'");

				$db->update_query("templates", $template_array, "tid='{$template['tid']}' AND sid != '-2'");

			}

$plugins->run_hooks("admin_style_templates_edit_template_commit");

			}

$plugins->run_hooks("admin_style_templates_edit_template_commit");

Zeile 433Zeile 443
			}		

// Log admin action

			}		

// Log admin action

			log_admin_action($tid, $mybb->input['title'], $sid, $set['title']);

			log_admin_action($tid, $mybb->input['title'], $mybb->input['sid'], $set['title']);

			
flash_message($lang->success_template_saved, 'success');


			
flash_message($lang->success_template_saved, 'success');


Zeile 441Zeile 451
			{
if($mybb->input['from'] == "diff_report")
{

			{
if($mybb->input['from'] == "diff_report")
{

					admin_redirect("index.php?module=style/templates&action=edit_template&title=".urlencode($mybb->input['title'])."&sid=".$sid.$expand_str2."&from=diff_report");

					admin_redirect("index.php?module=style/templates&action=edit_template&title=".urlencode($mybb->input['title'])."&sid=".intval($mybb->input['sid']).$expand_str2."&from=diff_report");

				}
else
{

				}
else
{

					admin_redirect("index.php?module=style/templates&action=edit_template&title=".urlencode($mybb->input['title'])."&sid=".$sid.$expand_str2);

					admin_redirect("index.php?module=style/templates&action=edit_template&title=".urlencode($mybb->input['title'])."&sid=".intval($mybb->input['sid']).$expand_str2);

				}
}
else

				}
}
else

Zeile 456Zeile 466
				}
else
{

				}
else
{

					admin_redirect("index.php?module=style/templates&sid=".$sid.$expand_str2."#group_{$group}");

					admin_redirect("index.php?module=style/templates&sid=".intval($mybb->input['sid']).$expand_str2."#group_{$group}");

				}
}
}

				}
}
}

Zeile 527Zeile 537
		
$form_container = new FormContainer($lang->edit_template_breadcrumb.$template['title']);
$form_container->output_row($lang->template_name, $lang->template_name_desc, $form->generate_text_box('title', $template['title'], array('id' => 'title')), 'title');

		
$form_container = new FormContainer($lang->edit_template_breadcrumb.$template['title']);
$form_container->output_row($lang->template_name, $lang->template_name_desc, $form->generate_text_box('title', $template['title'], array('id' => 'title')), 'title');

 

// Force users to save the default template to a specific set, rather than the "global" templates - where they can delete it
if($template['sid'] == "-2")
{
unset($template_sets[-1]);
}


	$form_container->output_row($lang->template_set, $lang->template_set_desc, $form->generate_select_box('sid', $template_sets, $sid));

	$form_container->output_row($lang->template_set, $lang->template_set_desc, $form->generate_select_box('sid', $template_sets, $sid));

 


	$form_container->output_row("", "", $form->generate_text_area('template', $template['template'], array('id' => 'template', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 500px;')));
$form_container->end();


	$form_container->output_row("", "", $form->generate_text_area('template', $template['template'], array('id' => 'template', 'class' => 'codepress mybb', 'style' => 'width: 100%; height: 500px;')));
$form_container->end();


Zeile 583Zeile 601
				$table = new Table;

$template_sets = array();

				$table = new Table;

$template_sets = array();

				

				

				// Get the names of all template sets
$template_sets[-2] = $lang->master_templates;
$template_sets[-1] = $lang->global_templates;

				// Get the names of all template sets
$template_sets[-2] = $lang->master_templates;
$template_sets[-1] = $lang->global_templates;

				

				

				$query = $db->simple_select("templatesets", "sid, title");
while($set = $db->fetch_array($query))
{

				$query = $db->simple_select("templatesets", "sid, title");
while($set = $db->fetch_array($query))
{

Zeile 597Zeile 615
				// Select all templates with that search term
$query = $db->simple_select("templates", "tid, title, template, sid", "template LIKE '%".$db->escape_string($mybb->input['find'])."%'", array('order_by' => 'sid, title', 'order_dir' => 'ASC'));
if($db->num_rows($query) == 0)

				// Select all templates with that search term
$query = $db->simple_select("templates", "tid, title, template, sid", "template LIKE '%".$db->escape_string($mybb->input['find'])."%'", array('order_by' => 'sid, title', 'order_dir' => 'ASC'));
if($db->num_rows($query) == 0)

				{

				{

					$table->construct_cell($lang->sprintf($lang->search_noresults, htmlspecialchars_uni($mybb->input['find'])), array("class" => "align_center"));

$table->construct_row();

					$table->construct_cell($lang->sprintf($lang->search_noresults, htmlspecialchars_uni($mybb->input['find'])), array("class" => "align_center"));

$table->construct_row();

Zeile 639Zeile 657
											"version" => $mybb->version_code,
"status" => '',
"dateline" => TIME_NOW

											"version" => $mybb->version_code,
"status" => '',
"dateline" => TIME_NOW

										);

										);

										$new_tid = $db->insert_query("templates", $new_template);
$label = $lang->sprintf($lang->search_created_custom, $template['title']);
$url = "index.php?module=style/templates&action=edit_template&title=".urlencode($template['title'])."&sid=1";

										$new_tid = $db->insert_query("templates", $new_template);
$label = $lang->sprintf($lang->search_created_custom, $template['title']);
$url = "index.php?module=style/templates&action=edit_template&title=".urlencode($template['title'])."&sid=1";

Zeile 702Zeile 720
							}
else
{

							}
else
{

								$table->construct_cell("<a href=\"{$url}\">Edit</a>", array("class" => "align_center"));

								$table->construct_cell("<a href=\"{$url}\">{$lang->edit}</a>", array("class" => "align_center"));

							}

$table->construct_row();

							}

$table->construct_row();

Zeile 846Zeile 864
							$template['pretty_title'] = "<span style=\"color: blue;\">{$template['title']}</span>";
}


							$template['pretty_title'] = "<span style=\"color: blue;\">{$template['title']}</span>";
}


						$table->construct_cell("<span style=\"padding: 20px;\"><a href=\"index.php?module=style/templates&amp;action=edit_template&amp;title=".urlencode($template['title'])."&amp;sid={$sid}\">{$template['pretty_title']}</a></span>", array("width" => "85%"));

						$table->construct_cell("<span style=\"padding: 20px;\">{$template['pretty_title']}</span>", array("width" => "85%"));

						$table->construct_cell($popup->fetch(), array("class" => "align_center"));

$table->construct_row();

						$table->construct_cell($popup->fetch(), array("class" => "align_center"));

$table->construct_row();

Zeile 883Zeile 901
	$page->output_header($lang->search_replace);

$page->output_nav_tabs($sub_tabs, 'search_replace');

	$page->output_header($lang->search_replace);

$page->output_nav_tabs($sub_tabs, 'search_replace');

	

	

	$form = new Form("index.php?module=style/templates&amp;action=search_replace", "post", "do_template");
echo $form->generate_hidden_field('type', "templates");


	$form = new Form("index.php?module=style/templates&amp;action=search_replace", "post", "do_template");
echo $form->generate_hidden_field('type', "templates");


Zeile 914Zeile 932
	$buttons = array();
$buttons[] = $form->generate_submit_button($lang->find_templates);
$buttons[] = $form->generate_reset_button($lang->reset);

	$buttons = array();
$buttons[] = $form->generate_submit_button($lang->find_templates);
$buttons[] = $form->generate_reset_button($lang->reset);





	$form->output_submit_wrapper($buttons);

$form->end();

if($admin_options['codepress'] != 0)

	$form->output_submit_wrapper($buttons);

$form->end();

if($admin_options['codepress'] != 0)

	{

	{

		echo "<script type=\"text/javascript\">
Event.observe('do_template', 'submit', function()
{

		echo "<script type=\"text/javascript\">
Event.observe('do_template', 'submit', function()
{

Zeile 928Zeile 946
			var area = $('find_cp');
area.id = 'find';
area.value = find.getCode();

			var area = $('find_cp');
area.id = 'find';
area.value = find.getCode();

			area.disabled = false;
}

			area.disabled = false;
}

		
if($('replace_cp')) {
var area = $('replace_cp');

		
if($('replace_cp')) {
var area = $('replace_cp');

Zeile 959Zeile 977
	$count = $db->fetch_array($query);

if($count['updated_count'] < 1)

	$count = $db->fetch_array($query);

if($count['updated_count'] < 1)

	{

	{

		flash_message($lang->no_updated_templates, 'success');
admin_redirect("index.php?module=style/templates");
}

		flash_message($lang->no_updated_templates, 'success');
admin_redirect("index.php?module=style/templates");
}

Zeile 1004Zeile 1022
	while($template = $db->fetch_array($query))
{
$templates[$template['sid']][] = $template;

	while($template = $db->fetch_array($query))
{
$templates[$template['sid']][] = $template;

	}

	}

	
foreach($templates as $sid => $templates)
{

	
foreach($templates as $sid => $templates)
{

Zeile 1017Zeile 1035
		}

foreach($templates as $template)

		}

foreach($templates as $template)

		{		

		{		

			$popup = new PopupMenu("template_{$template['tid']}", $lang->options);
$popup->add_item($lang->full_edit, "index.php?module=style/templates&amp;action=edit_template&amp;title=".urlencode($template['title'])."&amp;sid={$sid}&amp;from=diff_report");
$popup->add_item($lang->diff_report, "index.php?module=style/templates&amp;action=diff_report&amp;title=".urlencode($template['title'])."&amp;sid1=".$template['sid']."&amp;sid2=-2");

			$popup = new PopupMenu("template_{$template['tid']}", $lang->options);
$popup->add_item($lang->full_edit, "index.php?module=style/templates&amp;action=edit_template&amp;title=".urlencode($template['title'])."&amp;sid={$sid}&amp;from=diff_report");
$popup->add_item($lang->diff_report, "index.php?module=style/templates&amp;action=diff_report&amp;title=".urlencode($template['title'])."&amp;sid1=".$template['sid']."&amp;sid2=-2");

Zeile 1110Zeile 1128
		FROM ".TABLE_PREFIX."templates t
LEFT JOIN ".TABLE_PREFIX."templatesets s ON(t.sid=s.sid)
WHERE t.title='".$db->escape_string($mybb->input['title'])."' AND t.sid > '-2' AND t.sid = '{$sid}'

		FROM ".TABLE_PREFIX."templates t
LEFT JOIN ".TABLE_PREFIX."templatesets s ON(t.sid=s.sid)
WHERE t.title='".$db->escape_string($mybb->input['title'])."' AND t.sid > '-2' AND t.sid = '{$sid}'

	");
$template = $db->fetch_array($query);

// Does the template not exist?
if(!$template)
{
flash_message($lang->error_invalid_template, 'error');
admin_redirect("index.php?module=style/templates");
}

// User clicked no
if($mybb->input['no'])
{
admin_redirect("index.php?module=style/templates&sid={$template['sid']}{$expand_str2}");
}


	");
$template = $db->fetch_array($query);

// Does the template not exist?
if(!$template)
{
flash_message($lang->error_invalid_template, 'error');
admin_redirect("index.php?module=style/templates");
}

// User clicked no
if($mybb->input['no'])
{
admin_redirect("index.php?module=style/templates&sid={$template['sid']}{$expand_str2}");
}


	if($mybb->request_method == "post")
{
// Delete the template

	if($mybb->request_method == "post")
{
// Delete the template

Zeile 1171Zeile 1189
	
$query = $db->simple_select("templates", "*", "title='".$db->escape_string($mybb->input['title'])."' AND sid='".intval($mybb->input['sid1'])."'");
$template1 = $db->fetch_array($query);

	
$query = $db->simple_select("templates", "*", "title='".$db->escape_string($mybb->input['title'])."' AND sid='".intval($mybb->input['sid1'])."'");
$template1 = $db->fetch_array($query);





	$query = $db->simple_select("templates", "*", "title='".$db->escape_string($mybb->input['title'])."' AND sid='".intval($mybb->input['sid2'])."'");
$template2 = $db->fetch_array($query);


	$query = $db->simple_select("templates", "*", "title='".$db->escape_string($mybb->input['title'])."' AND sid='".intval($mybb->input['sid2'])."'");
$template2 = $db->fetch_array($query);


Zeile 1196Zeile 1214
	require_once MYBB_ROOT."inc/3rdparty/diff/Diff.php";	
require_once MYBB_ROOT."inc/3rdparty/diff/Diff/Renderer/inline.php";


	require_once MYBB_ROOT."inc/3rdparty/diff/Diff.php";	
require_once MYBB_ROOT."inc/3rdparty/diff/Diff/Renderer/inline.php";


	$diff = &new Text_Diff('auto', array($template1['template'], $template2['template']));
$renderer = &new Text_Diff_Renderer_inline();

	$diff = new Text_Diff('auto', array($template1['template'], $template2['template']));
$renderer = new Text_Diff_Renderer_inline();

	
if($sid)
{
$page->add_breadcrumb_item($template_sets[$sid], "index.php?module=style/templates&amp;sid={$sid}{$expand_str}");

	
if($sid)
{
$page->add_breadcrumb_item($template_sets[$sid], "index.php?module=style/templates&amp;sid={$sid}{$expand_str}");

	}


	}


	if($mybb->input['sid2'] == -2)
{
$page->add_breadcrumb_item($lang->find_updated, "index.php?module=style/templates&amp;action=find_updated");

	if($mybb->input['sid2'] == -2)
{
$page->add_breadcrumb_item($lang->find_updated, "index.php?module=style/templates&amp;action=find_updated");

Zeile 1218Zeile 1236
	$table = new Table;

$table->construct_header("<ins>".$lang->master_updated_ins."</ins><br /><del>".$lang->master_updated_del."</del>");

	$table = new Table;

$table->construct_header("<ins>".$lang->master_updated_ins."</ins><br /><del>".$lang->master_updated_del."</del>");

	

	

	$table->construct_cell("<pre class=\"differential\">".$renderer->render($diff)."</pre>");
$table->construct_row();


	$table->construct_cell("<pre class=\"differential\">".$renderer->render($diff)."</pre>");
$table->construct_row();


Zeile 1248Zeile 1266
	
// User clicked no
if($mybb->input['no'])

	
// User clicked no
if($mybb->input['no'])

	{

	{

		admin_redirect("index.php?module=style/templates&sid={$template['sid']}{$expand_str2}");
}


		admin_redirect("index.php?module=style/templates&sid={$template['sid']}{$expand_str2}");
}


Zeile 1258Zeile 1276
		$db->delete_query("templates", "tid='{$template['tid']}'");

$plugins->run_hooks("admin_style_templates_revert_commit");

		$db->delete_query("templates", "tid='{$template['tid']}'");

$plugins->run_hooks("admin_style_templates_revert_commit");





		// Log admin action
log_admin_action($template['tid'], $template['sid'], $template['sid'], $template['set_title']);

flash_message($lang->success_template_reverted, 'success');

		// Log admin action
log_admin_action($template['tid'], $template['sid'], $template['sid'], $template['set_title']);

flash_message($lang->success_template_reverted, 'success');

		

		

		if($mybb->input['from'] == "diff_report")

		if($mybb->input['from'] == "diff_report")

		{

		{

			admin_redirect("index.php?module=style/templates&action=find_updated");

			admin_redirect("index.php?module=style/templates&action=find_updated");

		}

		}

		else
{
admin_redirect("index.php?module=style/templates&sid={$template['sid']}{$expand_str2}");

		else
{
admin_redirect("index.php?module=style/templates&sid={$template['sid']}{$expand_str2}");

Zeile 1278Zeile 1296
		$page->output_confirm_action("index.php?module=style/templates&amp;sid={$template['sid']}{$expand_str}", $lang->confirm_template_revertion);
}
}

		$page->output_confirm_action("index.php?module=style/templates&amp;sid={$template['sid']}{$expand_str}", $lang->confirm_template_revertion);
}
}





if($mybb->input['sid'] && !$mybb->input['action'])
{
$plugins->run_hooks("admin_style_templates_set");


if($mybb->input['sid'] && !$mybb->input['action'])
{
$plugins->run_hooks("admin_style_templates_set");


	$table = new Table;


	$table = new Table;


	$page->add_breadcrumb_item($template_sets[$sid], "index.php?module=style/templates&amp;sid={$sid}");

$page->output_header($lang->template_sets);

	$page->add_breadcrumb_item($template_sets[$sid], "index.php?module=style/templates&amp;sid={$sid}");

$page->output_header($lang->template_sets);

	

	

	$page->output_nav_tabs($sub_tabs, 'manage_templates');

$table->construct_header($lang->template_set);
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));

	$page->output_nav_tabs($sub_tabs, 'manage_templates');

$table->construct_header($lang->template_set);
$table->construct_header($lang->controls, array("class" => "align_center", "width" => 150));

	

	

	// Global Templates
if($sid == -1)
{

	// Global Templates
if($sid == -1)
{

Zeile 1307Zeile 1325
			$table->construct_cell("<a href=\"index.php?module=style/templates&amp;action=edit_template&amp;title=".urlencode($template['title'])."&amp;sid=-1\">{$template['title']}</a>");
$table->construct_cell($popup->fetch(), array("class" => "align_center"));


			$table->construct_cell("<a href=\"index.php?module=style/templates&amp;action=edit_template&amp;title=".urlencode($template['title'])."&amp;sid=-1\">{$template['title']}</a>");
$table->construct_cell($popup->fetch(), array("class" => "align_center"));


			$table->construct_row();
}

			$table->construct_row();
}

		
if($table->num_rows() == 0)
{

		
if($table->num_rows() == 0)
{

Zeile 1368Zeile 1386
		{
$template_sql = " AND (1=0{$template_sql})";
}

		{
$template_sql = " AND (1=0{$template_sql})";
}

					

		

		// Load the list of templates

		// Load the list of templates

		$query = $db->simple_select("templates", "*", "(sid='".intval($mybb->input['sid'])."' OR sid='-2') {$template_sql}", array('order_by' => 'sid DESC, title', 'order_dir' => 'ASC'));

		$query = $db->simple_select("templates", "*", "(sid='".intval($mybb->input['sid'])."' {$template_sql}) OR sid='-2'", array('order_by' => 'sid DESC, title', 'order_dir' => 'ASC'));

		while($template = $db->fetch_array($query))
{
$exploded = explode("_", $template['title'], 2);

		while($template = $db->fetch_array($query))
{
$exploded = explode("_", $template['title'], 2);