Mod: | Avatar Select |
Yazan: | vbgamer45 |
Çeviren: | iki satır zaten! |
Açıklama: | Üyelik sırasında avatar seçimini sağlar |
URL: | http://mods.simplemachines.org/index.php?mod=368 |
Türkçesi: | Modu kurduktan sonra, Register.template.php dosyasında bul: Code (html) Select <b>Avatar Select:</b>değiştirCode (html) Select <b>Avatar Seçimi:</b> Subs-Members.php dosyasında bul Code (php) Select fatal_error('An avatar is required! Please select one.', false); değiştir Code (php) Select fatal_error('Avatar gerekmektedir! Lütfen bir tane seçin.', false); |
// Are there age restrictions in place?
if (!empty($modSettings['coppaAge']))
//For the no pic language file
loadlanguage('Profile');
echo '<tr>
<td width="40%">
<b>Avatar Select:</b>
<div class="smalltext">Please select an avatar.</div>
<div style="margin: 2ex;"><img name="avatar" id="avatar" src="' . $modSettings['avatar_url'] . '/blank.gif', '" alt="Do Nothing" /></div>
</td>
<td>
<select name="cat" id="cat" size="10" onchange="changeSel(\'\');">';
// Get a list of all the avatars.
$context['avatar_list'] = array();
$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
// This lists all the file catergories.
foreach ($context['avatars'] as $avatar)
echo '
<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected="selected"' : ''), '>', $avatar['name'], '</option>';
echo '</select>
<select name="file" id="file" size="10" style="display: none;" onchange="showAvatar()" disabled="disabled"><option></option></select>
</td>
</tr>';
// Uncheck the agreement thing....
if ($context['require_agreement'])
echo '
<script language="JavaScript" type="text/javascript">';
echo '
<!-- // -->'. chr(60) . chr(33) . chr(91) . chr(67) . chr(68) . chr(65) . chr(84) . chr(65) . chr(91);
echo '
var files = ["' . implode('", "', $context['avatar_list']) . '"];
var avatar = document.getElementById("avatar");
var cat = document.getElementById("cat");
var selavatar = "' . $context['avatar_selected'] . '";
var avatardir = "' . $modSettings['avatar_url'] . '/";
var size = avatar.alt.substr(3, 2) + " " + avatar.alt.substr(0, 2) + String.fromCharCode(117, 98, 116);
var file = document.getElementById("file");
if (avatar.src.indexOf("blank.gif") > -1)
changeSel(selavatar);
else
previewExternalAvatar(avatar.src)
function changeSel(selected)
{
if (cat.selectedIndex == -1)
return;
if (cat.options[cat.selectedIndex].value.indexOf("/") > 0)
{
var i;
var count = 0;
file.style.display = "inline";
file.disabled = false;
for (i = file.length; i >= 0; i = i - 1)
file.options[i] = null;
for (i = 0; i < files.length; i++)
if (files[i].indexOf(cat.options[cat.selectedIndex].value) == 0)
{
var filename = files[i].substr(files[i].indexOf("/") + 1);
var showFilename = filename.substr(0, filename.lastIndexOf("."));
showFilename = showFilename.replace(/[_]/g, " ");
file.options[count] = new Option(showFilename, files[i]);
if (filename == selected)
{
if (file.options.defaultSelected)
file.options[count].defaultSelected = true;
else
file.options[count].selected = true;
}
count++;
}
if (file.selectedIndex == -1 && file.options[0])
file.options[0].selected = true;
showAvatar();
}
else
{
file.style.display = "none";
file.disabled = true;
document.getElementById("avatar").src = avatardir + cat.options[cat.selectedIndex].value;
document.getElementById("avatar").style.width = "";
document.getElementById("avatar").style.height = "";
}
}
function showAvatar()
{
if (file.selectedIndex == -1)
return;
document.getElementById("avatar").src = avatardir + file.options[file.selectedIndex].value;
document.getElementById("avatar").alt = file.options[file.selectedIndex].text;
document.getElementById("avatar").alt += file.options[file.selectedIndex].text == size ? "!" : "";
document.getElementById("avatar").style.width = "";
document.getElementById("avatar").style.height = "";
}
function previewExternalAvatar(src)
{
if (!document.getElementById("avatar"))
return;
var maxHeight = ', !empty($modSettings['avatar_max_height_external']) ? $modSettings['avatar_max_height_external'] : 0, ';
var maxWidth = ', !empty($modSettings['avatar_max_width_external']) ? $modSettings['avatar_max_width_external'] : 0, ';
var tempImage = new Image();
tempImage.src = src;
if (maxWidth != 0 && tempImage.width > maxWidth)
{
document.getElementById("avatar").style.height = parseInt((maxWidth * tempImage.height) / tempImage.width) + "px";
document.getElementById("avatar").style.width = maxWidth + "px";
}
else if (maxHeight != 0 && tempImage.height > maxHeight)
{
document.getElementById("avatar").style.width = parseInt((maxHeight * tempImage.width) / tempImage.height) + "px";
document.getElementById("avatar").style.height = maxHeight + "px";
}
document.getElementById("avatar").src = src;
}';
echo '
//' . chr(93) . chr(93) . chr(62);
echo '
</script>';
?>
// Recursive function to retrieve avatar files
function getAvatars($directory, $level)
{
global $context, $txt, $modSettings;
$result = array();
// Open the directory..
$dir = dir($modSettings['avatar_directory'] . (!empty($directory) ? '/' : '') . $directory);
$dirs = array();
$files = array();
if (!$dir)
return array();
while ($line = $dir->read())
{
if (in_array($line, array('.', '..', 'blank.gif', 'index.php')))
continue;
if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
$dirs[] = $line;
else
$files[] = $line;
}
$dir->close();
// Sort the results...
natcasesort($dirs);
natcasesort($files);
if ($level == 0)
{
$result[] = array(
'filename' => 'blank.gif',
'checked' => in_array($context['member']['avatar']['server_pic'], array('', 'blank.gif')),
'name' => &$txt[422],
'is_dir' => false
);
}
foreach ($dirs as $line)
{
$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
if (!empty($tmp))
$result[] = array(
'filename' => htmlspecialchars($line),
'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
'name' => '[' . htmlspecialchars(str_replace('_', ' ', $line)) . ']',
'is_dir' => true,
'files' => $tmp
);
unset($tmp);
}
foreach ($files as $line)
{
$filename = substr($line, 0, (strlen($line) - strlen(strrchr($line, '.'))));
$extension = substr(strrchr($line, '.'), 1);
// Make sure it is an image.
if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
continue;
$result[] = array(
'filename' => htmlspecialchars($line),
'checked' => $line == $context['member']['avatar']['server_pic'],
'name' => htmlspecialchars(str_replace('_', ' ', $filename)),
'is_dir' => false
);
if ($level == 1)
$context['avatar_list'][] = $directory . '/' . $line;
}
return $result;
}
// Collect all extra registration fields someone might have filled in.
$_POST['avatar'] = strtr(empty($_POST['file']) ? (empty($_POST['cat']) ? '' : $_POST['cat']) : $_POST['file'], array('&' => '&'));
$_POST['avatar'] = preg_match('~^([\w _!@%*=\-#()\[\]&.,]+/)?[\w _!@%*=\-#()\[\]&.,]+$~', $_POST['avatar']) != 0 && preg_match('/\.\./', $_POST['avatar']) == 0 && file_exists($modSettings['avatar_directory'] . '/' . $_POST['avatar']) ? ($_POST['avatar'] == 'blank.gif' ? '' : $_POST['avatar']) : '';
'extra_register_vars' => array(),
'avatar' => $_POST['avatar'],
// No name?! How can you register with no name?
if (empty($regOptions['username']))
fatal_lang_error(37, false);
// No avatar?! You need to get an avatar!
if (empty($regOptions['avatar']) && $_REQUEST['action'] == 'register2')
fatal_error('An avatar is required! Please select one.', false);
'avatar' => "''",
"'$regOptions[avatar]'",
Quote from: Jee[F]o on April 01, 2007, 05:59:42 PM
Register.template.php Nerde yaa
<td valign="top" width="20" class="windowbg"><input type="radio" name="avatar_choice" id="avatar_choice_external" value="external" checked="checked" class="check" /></td>
<td valign="top" style="padding-left: 1ex;"><b><label for="avatar_choice_external">Kendi resmim var:</label></b><div class="smalltext">Resminizin URL adresini belirtin. (Örn.: <b>http://www.simplemachines.org/avatar.gif</b>)</div></td>
</tr></table>
</td>
<
Quote from: Emreyuce on June 15, 2007, 02:19:23 AM
1.1.2 sürümü içinde geçerlimi bu mod ? ayrıca bi sorum daha olacak, modu yükleyin diyorsunuzda bunu nasıl yapıcaz? gerekli dosyayı çektim ama ilerisi için bi bilgim yok, yardımcı olabilirmisiniz ?
Quote from: etapbilgisayar on June 27, 2007, 02:53:45 PM
Ustalar bir maruzatım olacak çok uzun zaman önce avatar select modunu manuel olarak kurmuştum. Lakin üye olurken avatar seçilmeyince ingilizce olarak uyarı veriyor avatar seçmediniz diye üyeliği kaydetmiyor buna bir çözüm istiyorum..
Üyelik sırasında avatar seçilmezse site otomatik olarak benim önceden hazırlamış olduğum bir avatarı atamalı kullanıcıya veya ordaki uyarı yazısını ingilizceden türkçe ye nasıl cevirebiliriz ? şimdiden yardımlarınız için teşekkür ederim...
fatal_error('An avatar is required! Please select one.', false);fatal_error('Avatar gerekmektedir! Lütfen bir tane seçin.', false);
Quote from: SiveroN on January 03, 2007, 08:12:00 AMTeşekkürler :)
Register.template.php yi ac ;
Bunu Bul ;Code Select
// Are there age restrictions in place?
if (!empty($modSettings['coppaAge']))
altına bunu ekle ;Code Select
//For the no pic language file
loadlanguage('Profile');
echo '<tr>
<td width="40%">
<b>Avatar Select:</b>
<div class="smalltext">Please select an avatar.</div>
<div style="margin: 2ex;"><img name="avatar" id="avatar" src="' . $modSettings['avatar_url'] . '/blank.gif', '" alt="Do Nothing" /></div>
</td>
<td>
<select name="cat" id="cat" size="10" onchange="changeSel(\'\');">';
// Get a list of all the avatars.
$context['avatar_list'] = array();
$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
// This lists all the file catergories.
foreach ($context['avatars'] as $avatar)
echo '
<option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected="selected"' : ''), '>', $avatar['name'], '</option>';
echo '</select>
<select name="file" id="file" size="10" style="display: none;" onchange="showAvatar()" disabled="disabled"><option></option></select>
</td>
</tr>';
Bunu Bul ;Code Select
// Uncheck the agreement thing....
if ($context['require_agreement'])
Altına bunu ekle ;Code Select
echo '
<script language="JavaScript" type="text/javascript">';
echo '
<!-- // -->'. chr(60) . chr(33) . chr(91) . chr(67) . chr(68) . chr(65) . chr(84) . chr(65) . chr(91);
echo '
var files = ["' . implode('", "', $context['avatar_list']) . '"];
var avatar = document.getElementById("avatar");
var cat = document.getElementById("cat");
var selavatar = "' . $context['avatar_selected'] . '";
var avatardir = "' . $modSettings['avatar_url'] . '/";
var size = avatar.alt.substr(3, 2) + " " + avatar.alt.substr(0, 2) + String.fromCharCode(117, 98, 116);
var file = document.getElementById("file");
if (avatar.src.indexOf("blank.gif") > -1)
changeSel(selavatar);
else
previewExternalAvatar(avatar.src)
function changeSel(selected)
{
if (cat.selectedIndex == -1)
return;
if (cat.options[cat.selectedIndex].value.indexOf("/") > 0)
{
var i;
var count = 0;
file.style.display = "inline";
file.disabled = false;
for (i = file.length; i >= 0; i = i - 1)
file.options[i] = null;
for (i = 0; i < files.length; i++)
if (files[i].indexOf(cat.options[cat.selectedIndex].value) == 0)
{
var filename = files[i].substr(files[i].indexOf("/") + 1);
var showFilename = filename.substr(0, filename.lastIndexOf("."));
showFilename = showFilename.replace(/[_]/g, " ");
file.options[count] = new Option(showFilename, files[i]);
if (filename == selected)
{
if (file.options.defaultSelected)
file.options[count].defaultSelected = true;
else
file.options[count].selected = true;
}
count++;
}
if (file.selectedIndex == -1 && file.options[0])
file.options[0].selected = true;
showAvatar();
}
else
{
file.style.display = "none";
file.disabled = true;
document.getElementById("avatar").src = avatardir + cat.options[cat.selectedIndex].value;
document.getElementById("avatar").style.width = "";
document.getElementById("avatar").style.height = "";
}
}
function showAvatar()
{
if (file.selectedIndex == -1)
return;
document.getElementById("avatar").src = avatardir + file.options[file.selectedIndex].value;
document.getElementById("avatar").alt = file.options[file.selectedIndex].text;
document.getElementById("avatar").alt += file.options[file.selectedIndex].text == size ? "!" : "";
document.getElementById("avatar").style.width = "";
document.getElementById("avatar").style.height = "";
}
function previewExternalAvatar(src)
{
if (!document.getElementById("avatar"))
return;
var maxHeight = ', !empty($modSettings['avatar_max_height_external']) ? $modSettings['avatar_max_height_external'] : 0, ';
var maxWidth = ', !empty($modSettings['avatar_max_width_external']) ? $modSettings['avatar_max_width_external'] : 0, ';
var tempImage = new Image();
tempImage.src = src;
if (maxWidth != 0 && tempImage.width > maxWidth)
{
document.getElementById("avatar").style.height = parseInt((maxWidth * tempImage.height) / tempImage.width) + "px";
document.getElementById("avatar").style.width = maxWidth + "px";
}
else if (maxHeight != 0 && tempImage.height > maxHeight)
{
document.getElementById("avatar").style.width = parseInt((maxHeight * tempImage.width) / tempImage.height) + "px";
document.getElementById("avatar").style.height = maxHeight + "px";
}
document.getElementById("avatar").src = src;
}';
echo '
//' . chr(93) . chr(93) . chr(62);
echo '
</script>';
Bunu Bul ;Code Select
?>
öncesine bunu ekle ;Code Select
// Recursive function to retrieve avatar files
function getAvatars($directory, $level)
{
global $context, $txt, $modSettings;
$result = array();
// Open the directory..
$dir = dir($modSettings['avatar_directory'] . (!empty($directory) ? '/' : '') . $directory);
$dirs = array();
$files = array();
if (!$dir)
return array();
while ($line = $dir->read())
{
if (in_array($line, array('.', '..', 'blank.gif', 'index.php')))
continue;
if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
$dirs[] = $line;
else
$files[] = $line;
}
$dir->close();
// Sort the results...
natcasesort($dirs);
natcasesort($files);
if ($level == 0)
{
$result[] = array(
'filename' => 'blank.gif',
'checked' => in_array($context['member']['avatar']['server_pic'], array('', 'blank.gif')),
'name' => &$txt[422],
'is_dir' => false
);
}
foreach ($dirs as $line)
{
$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
if (!empty($tmp))
$result[] = array(
'filename' => htmlspecialchars($line),
'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
'name' => '[' . htmlspecialchars(str_replace('_', ' ', $line)) . ']',
'is_dir' => true,
'files' => $tmp
);
unset($tmp);
}
foreach ($files as $line)
{
$filename = substr($line, 0, (strlen($line) - strlen(strrchr($line, '.'))));
$extension = substr(strrchr($line, '.'), 1);
// Make sure it is an image.
if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
continue;
$result[] = array(
'filename' => htmlspecialchars($line),
'checked' => $line == $context['member']['avatar']['server_pic'],
'name' => htmlspecialchars(str_replace('_', ' ', $filename)),
'is_dir' => false
);
if ($level == 1)
$context['avatar_list'][] = $directory . '/' . $line;
}
return $result;
}
Sources klasöründe Register.php aç
Bunu bul ;Code Select
// Collect all extra registration fields someone might have filled in.
Altına bunu ekle ;Code Select
$_POST['avatar'] = strtr(empty($_POST['file']) ? (empty($_POST['cat']) ? '' : $_POST['cat']) : $_POST['file'], array('&' => '&'));
$_POST['avatar'] = preg_match('~^([\w _!@%*=\-#()\[\]&.,]+/)?[\w _!@%*=\-#()\[\]&.,]+$~', $_POST['avatar']) != 0 && preg_match('/\.\./', $_POST['avatar']) == 0 && file_exists($modSettings['avatar_directory'] . '/' . $_POST['avatar']) ? ($_POST['avatar'] == 'blank.gif' ? '' : $_POST['avatar']) : '';
Bunu Bul ;Code Select
'extra_register_vars' => array(),
Altına bunu ekle ;Code Select
'avatar' => $_POST['avatar'],
Sources Klasöründeki Subs-members.php yi ac ;
Bunu bul ;Code Select
// No name?! How can you register with no name?
if (empty($regOptions['username']))
fatal_lang_error(37, false);
öncesine şunu ekle ;Code Select
// No avatar?! You need to get an avatar!
if (empty($regOptions['avatar']) && $_REQUEST['action'] == 'register2')
fatal_error('An avatar is required! Please select one.', false);
Bunu bul ;Code Select
'avatar' => "''",
Bununla değiştir ;Code Select
"'$regOptions[avatar]'",
Yukarıdaki modifikasyonun icindeki AvatarSelect.xml de yazanlar buraya aktarılmıştır.
Kendim kullanmadığım için denemedim ; Uygulama yapmadan önce uygulayacağınız dosyaların birer tane yedeklerini bilgisayarınıza indirin. ;)
Quote from: €®Ю€∏∏----® on May 12, 2009, 10:14:35 AM
Arkadaşlar bunu SMF 2.0 RC1 için uygulaya bilirmiyiz?
Quote from: DNA27 on May 12, 2009, 11:30:39 AM
paket çözümlemede yok ama manuel olarak verebılırler.. bence
' . $txt['Avatar Seçin_avatar'] . '</strong>
<div class="smalltext">' . $txt['avatarselect_pleaseselect'] . '</div>// No avatar?! You need to get an avatar!
if (empty($regOptions['avatar']) && $_REQUEST['action'] == 'register2')
fatal_error($txt['avatarselect_error_req'], false);