#
#-----[ OPEN ]------------------------------------------------
#
phpbb_root_path/common.php
#
#-----[ FIND ]------------------------------------------------
#
	$mx_root_path = './../';
#
#-----[ AFTER, ADD ]------------------------------------------
#
	$mx_table_prefix = 'mx_';

#
#-----[ OPEN ]------------------------------------------------
#
phpbb_root_path/includes/page_header.php
#
#-----[ FIND ]------------------------------------------------
#

//
// The following assigns all _common_ variables that may be used at any point
// in a template.
//

#
#-----[ BEAFORE, ADD ]------------------------------------------
#

// Replace 'mx_' with your table prefix!
$mx_table_prefix = !empty($mx_table_prefix) ? $mx_table_prefix : 'mx_';

!defined('ALBUM_CONFIG_TABLE') ? define('ALBUM_CONFIG_TABLE', $mx_table_prefix.'smartor_album_config') : false;

$sql = "SELECT config_value
	FROM " . ALBUM_CONFIG_TABLE . "
	WHERE config_name = 'index'";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(CRITICAL_ERROR, 'Could not query album config database');
}

if ( $row = $db->sql_fetchrow($result) )
{
	$db->sql_freeresult($result);
	$album_index = $page_id = $row['config_value'];
}

function this_smartor_mxurl($args = '', $force_standalone_mode = false)
{
	global $mx_root_path, $page_id, $album_index, $phpEx, $integration_enabled;

	$module_root_path = $mx_root_path . 'modules/mx_smartor/';

	if( $force_standalone_mode )
	{
		$mxurl = $mx_root_path . 'modules/mx_smartor/' . 'album.' . $phpEx . ($args == '' ? '' : '?' . $args);
	}
	else
	{
		$mxurl = $mx_root_path . 'index.' . $phpEx;
		if( is_numeric($page_id) && !empty($page_id) )
		{
			$mxurl .= '?page=' . $page_id . ($args == '' ? '' : '&' . $args);
		}
		else
		{
			$mxurl .= '?page=' . $album_index . ($args == '' ? '' : '&' . $args);
		}
	}
	return $mxurl;
}

define('ALBUM_INDEX', this_smartor_mxurl());
define('ALBUM_SHOWPAGE', this_smartor_mxurl('smartor_mode=album_showpage'));
define('ALBUM_PICM', this_smartor_mxurl('smartor_mode=album_picm', true));
define('ALBUM_THUMBNAIL', this_smartor_mxurl('smartor_mode=album_thumbnail', true));

#
#-----[ FIND ]------------------------------------------------
#
	'S_LOGIN_ACTION' => append_sid('login.'.$phpEx),

#
#-----[ AFTER, ADD ]------------------------------------------
#

	//ADDED FOR FAP
	'ALBUM_INDEX' => this_smartor_mxurl(),
	'ALBUM_SHOWPAGE' => this_smartor_mxurl('smartor_mode=album_showpage'),
	'ALBUM_PICM' => this_smartor_mxurl('smartor_mode=album_picm', true),
	'ALBUM_THUMBNAIL' => this_smartor_mxurl('smartor_mode=album_thumbnail', true),
	//ADDED FOR FAP
#
#-----[ OPEN ]------------------------------------------------
#
phpbb_root_path/includes/bbcode.php
#
#-----[ FIND ]------------------------------------------------
#
	$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);
#
#-----[ AFTER, ADD ]------------------------------------------
#
	// Mighty Gorgon - Full Album Pack - BEGIN
	// Get Album PIC based on ID
	$bbcode_tpl['fullalbumimg'] = str_replace('{IMG_NUM}', '\\1', $bbcode_tpl['fullalbumimg']);
	$bbcode_tpl['albumimg'] = str_replace('{IMG_NUM}', '\\1', $bbcode_tpl['albumimg']);
	$bbcode_tpl['albumimgl'] = str_replace('{IMG_NUM}', '\\1', $bbcode_tpl['albumimgl']);
	$bbcode_tpl['albumimgr'] = str_replace('{IMG_NUM}', '\\1', $bbcode_tpl['albumimgr']);
	$bbcode_tpl['albumimgc'] = str_replace('{IMG_NUM}', '\\1', $bbcode_tpl['albumimgc']);

	$bbcode_tpl['fullalbumimg'] = str_replace('{ALBUM_SHOWPAGE}', ALBUM_SHOWPAGE, $bbcode_tpl['fullalbumimg']);
	$bbcode_tpl['albumimg'] = str_replace('{ALBUM_SHOWPAGE}', ALBUM_SHOWPAGE, $bbcode_tpl['albumimg']);
	$bbcode_tpl['albumimgl'] = str_replace('{ALBUM_SHOWPAGE}', ALBUM_SHOWPAGE, $bbcode_tpl['albumimgl']);
	$bbcode_tpl['albumimgr'] = str_replace('{ALBUM_SHOWPAGE}', ALBUM_SHOWPAGE, $bbcode_tpl['albumimgr']);
	$bbcode_tpl['albumimgc'] = str_replace('{ALBUM_SHOWPAGE}', ALBUM_SHOWPAGE, $bbcode_tpl['albumimgc']);

	$bbcode_tpl['fullalbumimg'] = str_replace('{ALBUM_PICM}', ALBUM_PICM, $bbcode_tpl['fullalbumimg']);
	$bbcode_tpl['albumimg'] = str_replace('{ALBUM_THUMBNAIL}', ALBUM_THUMBNAIL, $bbcode_tpl['albumimg']);
	$bbcode_tpl['albumimgl'] = str_replace('{ALBUM_THUMBNAIL}', ALBUM_THUMBNAIL, $bbcode_tpl['albumimgl']);
	$bbcode_tpl['albumimgr'] = str_replace('{ALBUM_THUMBNAIL}', ALBUM_THUMBNAIL, $bbcode_tpl['albumimgr']);
	$bbcode_tpl['albumimgc'] = str_replace('{ALBUM_THUMBNAIL}', ALBUM_THUMBNAIL, $bbcode_tpl['albumimgc']);
	// Mighty Gorgon - Full Album Pack - END
#
#-----[ FIND ]------------------------------------------------
#
	$replacements[] = $bbcode_tpl['url4'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
	// Mighty Gorgon - Full Album Pack - BEGIN
	// [albumimg]image number here[/albumimg]
	$album_img_patterns[1] = "#\[albumimg:$uid\]([0-9]+)\[/albumimg:$uid\]#si";
	$album_img_replacements[1] = $bbcode_tpl['albumimg'];

	// [albumimgl]image number here[/albumimgl]
	$album_img_patterns[2] = "#\[albumimgl:$uid\]([0-9]+)\[/albumimgl:$uid\]#si";
	$album_img_replacements[2] = $bbcode_tpl['albumimgl'];

	// [albumimgr]image number here[/albumimgr]
	$album_img_patterns[3] = "#\[albumimgr:$uid\]([0-9]+)\[/albumimgr:$uid\]#si";
	$album_img_replacements[3] = $bbcode_tpl['albumimgr'];

	// [albumimgc]image number here[/albumimgc]
	$album_img_patterns[4] = "#\[albumimgc:$uid\]([0-9]+)\[/albumimgc:$uid\]#si";
	$album_img_replacements[4] = $bbcode_tpl['albumimgc'];
	// site image-end

	// [fullalbumimg]image number here[/fullalbumimg]
	$album_img_patterns[5] = "#\[fullalbumimg:$uid\]([0-9]+)\[/fullalbumimg:$uid\]#si";
	$album_img_replacements[5] = $bbcode_tpl['fullalbumimg'];

	$text = preg_replace($album_img_patterns, $album_img_replacements, $text);
	// Mighty Gorgon - Full Album Pack - END
#
#-----[ FIND ]------------------------------------------------
#
	$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);
#
#-----[ AFTER, ADD ]------------------------------------------
#
	// Mighty Gorgon - Full Album Pack - BEGIN
	// [albumimg]album image id here[/albumimg]
	$text = preg_replace("#\[fullalbumimg\]([0-9]+)\[/fullalbumimg\]#sie", "'[fullalbumimg:$uid]\\1[/fullalbumimg:$uid]'", $text);
	$text = preg_replace("#\[albumimg\]([0-9]+)\[/albumimg\]#sie", "'[albumimg:$uid]\\1[/albumimg:$uid]'", $text);
	$text = preg_replace("#\[albumimgl\]([0-9]+)\[/albumimgl\]#sie", "'[albumimgl:$uid]\\1[/albumimgl:$uid]'", $text);
	$text = preg_replace("#\[albumimgr\]([0-9]+)\[/albumimgr\]#sie", "'[albumimgr:$uid]\\1[/albumimgr:$uid]'", $text);
	$text = preg_replace("#\[albumimgc\]([0-9]+)\[/albumimgc\]#sie", "'[albumimgc:$uid]\\1[/albumimgc:$uid]'", $text);
	// Mighty Gorgon - Full Album Pack - END

#
#-----[ OPEN ]------------------------------------------------
#
phpbb_root_path/templates/subSilver/bbcode.tpl
#
#-----[ FIND ]------------------------------------------------
#
<!-- BEGIN img --><img src="{URL}" border="0" /><!-- END img -->
#
#-----[ AFTER, ADD ]------------------------------------------
#
<!-- BEGIN fullalbumimg --><a href="{ALBUM_SHOWPAGE}&pic_id={IMG_NUM}" target="_blank" class="postlink"><img src="{ALBUM_PICM}&pic_id={IMG_NUM}" alt="Image {IMG_NUM}" title="Image {IMG_NUM}" border="0" /></a><!-- END fullalbumimg -->
<!-- BEGIN albumimg --><a href="{ALBUM_SHOWPAGE}&pic_id={IMG_NUM}" target="_blank" class="postlink"><img src="{ALBUM_THUMBNAIL}&pic_id={IMG_NUM}" alt="Image {IMG_NUM}" title="Image {IMG_NUM}" border="0" /></a><!-- END albumimg -->
<!-- BEGIN albumimgl --><a href="{ALBUM_SHOWPAGE}&pic_id={IMG_NUM}" target="_blank" class="postlink"><img src="{ALBUM_THUMBNAIL}&pic_id={IMG_NUM}" border="0" align="left" alt="Image {IMG_NUM}" title="Image {IMG_NUM}" /></a><!-- END albumimgl -->
<!-- BEGIN albumimgr --><a href="{ALBUM_SHOWPAGE}&pic_id={IMG_NUM}" target="_blank" class="postlink"><img src="{ALBUM_THUMBNAIL}&pic_id={IMG_NUM}" border="0" align="right" alt="Image {IMG_NUM}" title="Image {IMG_NUM}" /></a><!-- END albumimgr -->
<!-- BEGIN albumimgc --><center><a href="{ALBUM_SHOWPAGE}&pic_id={IMG_NUM}" target="_blank" class="postlink"><img src="{ALBUM_THUMBNAIL}&pic_id={IMG_NUM}" border="0" align="center" alt="Image {IMG_NUM}" title="Image {IMG_NUM}" /></a></center><!-- END albumimgc -->

#
#-----[ OPEN ]------------------------------------------------
#
mx_smartor/templates/subSilver/album_showpage_body.tpl
#
#-----[ FIND ]------------------------------------------------
#

	  <!-- BEGIN bbcode_switch -->
	  <tr>
		<td valign="top" align="right"><span class="genmed">{L_PIC_BBCODE}:</span></td>
		<td valign="top" align="left"><form name="select_all" action=""><input name="BBCode" size="50" maxlength="100" value="{PIC_BBCODE}" type="text" readonly="1" onClick="javascript:this.form.BBCode.focus();this.form.BBCode.select();"/></form></td>
	 </tr>
	  <!-- END bbcode_switch -->

#
#-----[ REPLACE WITH ]------------------------------------------
#

	  <tr>
		<td valign="top" align="right"><span class="genmed">{L_PIC_BBCODE}:</span></td>
		<td valign="top" align="left"><form name="select_all" action=""><input name="BBCode" size="50" maxlength="100" value="{PIC_BBCODE}" type="text" readonly="1" onClick="javascript:this.form.BBCode.focus();this.form.BBCode.select();"/></form></td>
	 </tr>

#
#-----[ OPEN ]------------------------------------------------
#
mx_root_path/common.php
#
#-----[ FIND ]------------------------------------------------
#

?>

#
#-----[ BEAFORE, ADD ]------------------------------------------
#

//ADDED FOR SMARTOR ALBUMING
@include_once($mx_root_path . 'modules/mx_smartor/album_mod/album_bbconstants.' . $phpEx);
//ADDED FOR SMARTOR ALBUMIN