PDA

View Full Version : Calendar Enhancements - Jalali Calander (Solar Or Shamsi) For vBulletin


SANBOR
06-07-2012, 10:00 PM
Hello
I have made on Jalali Calander for vBulletin.

Thanks from:
1- Hamed Hadadian
2- Reza Gholampanahi (jdf.scr.ir)

jalali date on forum is completed but in cms and blogs completed up to 99%
For do this action must be in original vBulletin files to manually do the changes.
This changes is:

1. Upload 'jalali.php' to vBulletin's includes folder. EX: vb/includes
************************************************** **************************




2. Upload 'hooks_jlalali.xml' to includes's xml folder. EX: vb/includes/xml
************************************************** **************************




3. Open 'includes/functions.php' then
************************************************** **************************
Find below, at first:
// ###### ...


Before add below:
require_once('jalali.php');
************************************************** **************************
Find below:
$datefunc = 'strftime';


After add with:
($hook = vBulletinHook::fetch_hook('jalali_strftime')) ? eval($hook) : false;
************************************************** **************************
Find below:
$datefunc = 'date';


After add with:
($hook = vBulletinHook::fetch_hook('jalali_date')) ? eval($hook) : false;
************************************************** **************************
Find below:
$datetest = @date('n-j-Y', $timestamp - $hourdiff);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_datetest')) ? eval($hook) : false;
************************************************** **************************




4. Open 'includes/functions_misc.php' then
************************************************** **************************
Find below:
return mktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];


Replace with:
if ( VB_AREA == 'AdminCP' or VB_AREA == 'ModCP' or THIS_SCRIPT == 'blog' ){
return mktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];}
else{
if ($vbulletin->options['jalali_act'] == 1){
return jmktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];}
else{
return mktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];}
}
************************************************** **************************
Find below:
$datearray = array(
'day' => date('d', $timestamp),
'month' => date('n', $timestamp),
'year' => date('Y', $timestamp)
);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_datearray')) ? eval($hook) : false;
************************************************** *************************




5. Open 'includes/class_dm_user.php' then
************************************************** *************************
Find below:
function verify_birthday(&$birthday)
{


After Add Below:
($hook = vBulletinHook::fetch_hook('jalali_verify_birthday' )) ? eval($hook) : false;
************************************************** *************************





6. Open 'includes/class_userprofile.php' then
************************************************** **************************
Find below:
$bday = explode('-', $userinfo['birthday']);

$year = vbdate('Y', TIMENOW, false, false);
$month = vbdate('n', TIMENOW, false, false);
$day = vbdate('j', TIMENOW, false, false);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_bday')) ? eval($hook) : false;
************************************************** **************************
Find below:
$this->registry->options['calformat1'] = mktimefix($this->registry->options['calformat1'], $bday[2]);


Before add with:
($hook = vBulletinHook::fetch_hook('jalali_tbday')) ? eval($hook) : false;
************************************************** **************************




7. Open 'includes/class_postbit.php' then
************************************************** **************************
Find below:
$this->cache['year'] = vbdate('Y', TIMENOW, false, false);
$this->cache['month'] = vbdate('n', TIMENOW, false, false);
$this->cache['day'] = vbdate('j', TIMENOW, false, false);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_bday')) ? eval($hook) : false;
************************************************** **************************




8. open 'includes/blog_functions.php' then
************************************************** **************************
Find below:
$startdate = getdate(gmmktime(12, 0, 0, $month, 1, $year));


Before add below:
($hook = vBulletinHook::fetch_hook('jalali_blog')) ? eval($hook) : false;
************************************************** **************************
Find below:
if ($userinfo['showbirthday'] == 1 OR $userinfo['showbirthday'] == 2)
{
$year = vbdate('Y', TIMENOW, false, false);
$month = vbdate('n', TIMENOW, false, false);
$day = vbdate('j', TIMENOW, false, false);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_blog')) ? eval($hook) : false;
************************************************** **************************




9. Open 'register.php' then
************************************************** *************************
Find below:
$bday = explode('-', $birthday);


After add below:
($hook = vBulletinHook::fetch_hook('jalali_bday_register')) ? eval($hook) : false;
************************************************** *************************
Find below:
if ($vbulletin->GPC['month'] == 0 OR $vbulletin->GPC['day'] == 0 OR !preg_match('#^\d{4}$#', $vbulletin->GPC['year']) OR $vbulletin->GPC['year'] < 1901 OR $vbulletin->GPC['year'] > $current['year'])
{
eval(standard_error(fetch_error('select_valid_dob' , $current['year'])));
}


Replace with:
if ($vbulletin->options['jalali_act'] == 1){
$jalalicurrent['year'] = jdate('Y');
list ( $vbulletin->GPC['year'], $vbulletin->GPC['month'], $vbulletin->GPC['day'] ) = jalali_to_gregorian ( $vbulletin->GPC['year'], $vbulletin->GPC['month'], $vbulletin->GPC['day'] );
if ($vbulletin->GPC['month'] == 0 OR $vbulletin->GPC['day'] == 0 OR !preg_match('#^\d{4}$#', $vbulletin->GPC['year']) OR $vbulletin->GPC['year'] < 1901 OR $vbulletin->GPC['year'] > $current['year']){
eval(standard_error(fetch_error('jalali_select_val id_month_and_year', $jalalicurrent['year'])));}}
else{
if ($vbulletin->GPC['month'] == 0 OR $vbulletin->GPC['day'] == 0 OR !preg_match('#^\d{4}$#', $vbulletin->GPC['year']) OR $vbulletin->GPC['year'] < 1901 OR $vbulletin->GPC['year'] > $current['year']){
eval(standard_error(fetch_error('select_valid_dob' , $current['year'])));}
}
************************************************** *************************
Find below:
// pre-cache templates used by specific actions


Before add below:
require_once('./global.php');
($hook = vBulletinHook::fetch_hook('jalali_globaltemplates' )) ? eval($hook) : false;
************************************************** **************************
Find below:
$templater = vB_Template::create('register_verify_age');


After add with:
($hook = vBulletinHook::fetch_hook('jalali_templater_regist er')) ? eval($hook) : false;
************************************************** **************************
Find below:
$templater = vB_Template::create('modifyprofile_birthday');


After add with:
($hook = vBulletinHook::fetch_hook('jalali_templater_modify profile')) ? eval($hook) : false;
************************************************** **************************




10.Open 'private.php' then
************************************************** **************************
Find below:
$templater = vB_Template::create('pm_filter');

After add with:
($hook = vBulletinHook::fetch_hook('jalali_templater_privat e')) ? eval($hook) : false;
************************************************** **************************




11.Open 'announcement.php' then
************************************************** **************************
Find below:
$templater = vB_Template::create('announcement_edit');


After add with:
($hook = vBulletinHook::fetch_hook('jalali_templater_announ cement')) ? eval($hook) : false;
************************************************** **************************
Find below:
$GLOBALS["{$date_type}_date_array"] = array(
'day' => vbdate('j', $announcementinfo["{$date_type}date"], false, false),
'month' => vbdate('n', $announcementinfo["{$date_type}date"], false, false),
'year' => vbdate('Y', $announcementinfo["{$date_type}date"], false, false)
);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_fields')) ? eval($hook) : false;
************************************************** **************************




12. Open 'profile.php' then
************************************************** **************************
Find below:
if (date('Y') >= $birthday[2] AND $birthday[2] != '0000')
{
$year = $birthday[2];
}

After add with:
($hook = vBulletinHook::fetch_hook('jalali_set_birthday')) ? eval($hook) : false;
************************************************** **************************
Find below:
$vbulletin->options['calformat1'] = mktimefix($vbulletin->options['calformat1'], $birthday[2]);

Before add with:
($hook = vBulletinHook::fetch_hook('jalali_calformat')) ? eval($hook) : false;
************************************************** **************************
Find below:
$actiontemplates['docustomize'] = $actiontemplates['customize'];


Before add below:
require_once('./global.php');
($hook = vBulletinHook::fetch_hook('jalali_actiontemplates' )) ? eval($hook) : false;
************************************************** **************************
Find below:
$birthdaybit = $templater->render();

After add with:
($hook = vBulletinHook::fetch_hook('jalali_templater_profil e')) ? eval($hook) : false;
************************************************** **************************




13. Open 'forum.php' then
************************************************** **************************
Find below:
$today = vbdate('Y-m-d', TIMENOW, false, false);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_today')) ? eval($hook) : false;
************************************************** **************************




14. Open 'memberlist.php' then
************************************************** **************************
Find below:
if ($vbulletin->options['usememberlistadvsearch'])
{


After add below:
($hook = vBulletinHook::fetch_hook('jalali_usememberlistadv search')) ? eval($hook) : false;
************************************************** **************************
Find below:
$today_year = vbdate('Y', TIMENOW, false, false);
$today_month = vbdate('n', TIMENOW, false, false);
$today_day = vbdate('j', TIMENOW, false, false);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_memberlistbits') ) ? eval($hook) : false;
************************************************** **************************
Find below:
$birthdayformat = mktimefix($vbulletin->options['calformat1'], $bday[2]);


After add with:
($hook = vBulletinHook::fetch_hook('jalali_birthdayformat') ) ? eval($hook) : false;
************************************************** **************************



15. Final: Goto Admin Control Panel then
************************************************** **************************
Product Manager -> Add/Import Product -> Select jalali.xml and import it.




Enjoy it!


Then go to :
Settings > Options > jalali date > And click Yes

================================================== ==========================


For better display the Forum's proposed use this format :


Format For Date :
l d F y


Format For Time:
H:i


Format For Registration Date
F Y


Format For Birthdays with Year Specified
l j F Y


Format For Birthdays with Year Unspecified
j F


Log Date Format
F Y H:i

================================================== ===============
Other Format is :
https://vborg.vbsupport.ru/external/2012/06/20.png

Mehdi_Zakhire
06-09-2012, 04:23 AM
Mamnoon Mostafa Jan Midonam Ye Donya Zahmat Keshidi O Vaght Gozzashti Barash

Tested And Working For vBulletin 4.2

SANBOR
06-09-2012, 07:26 AM
Comments Persian

سلام
این تقویم شمسی برای ایرانیان و فارسی زبانان عزیز اماده شده است
این شمسی ساز 100 درصد در قسمت انجمن تکمیل شده است و به خوبی بر روی انجمن خودم کار میکند
در قسمت بلاگ 99 درصد تکمیل شده است و تنها مشکلی که دارد این است که تقویم رو میلادی میزاره


امکانات
1- قسمت انجمن شمسی شده است
2- قسمت کنترل پنل ادمین میلادی است
3- ورودی سن و یا تولد در کل انجمن به صورت شمسی است
4- نمایش تمامی قسمت ها که سن و یا تاریخ تولد را نشون میدهد درست است
5- متولدین امروز را نشان میدهد
6- قسمت سی ام اس شمسی شده است
7- قابلیت فعال و یا غیر فعال کردن حالت شمسی در انجمن ایجاد شده است


1. فايل 'jalali.php' را در مسير ./includes کپي فرماييد



2. فايل 'hooks_jlalali.xml' را در مسير ./includes/xml کپي فرماييد



3. فايل 'includes/functions.php' رابازکنيد
نوشته زیر را پيدا کنيد پيدا کنيد ( خط دوم است)
// ###### ...

قبل از خط بالا کد زير رو اضافه کنيد
require_once('jalali.php');


کد زير را پيدا کنيد
$datefunc = 'strftime';

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_strftime')) ? eval($hook) : false;


کد زير را پيدا کنيد
$datefunc = 'date';

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_date')) ? eval($hook) : false;


کد زير را پيدا کنيد
$datetest = @date('n-j-Y', $timestamp - $hourdiff);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_datetest')) ? eval($hook) : false;



4. فايل 'includes/functions_misc.php' باز کنيد
کد زير را پيدا کنيد
return mktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];

با کد زير جايگزين کنيد
if ( VB_AREA == 'AdminCP' or VB_AREA == 'ModCP or THIS_SCRIPT == 'blog' ' ){
return mktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];}
else{
if ($vbulletin->options['jalali_act'] == 1){
return jmktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];}
else{
return mktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)) + $vbulletin->options['hourdiff'];}
}


کد زير را پيدا کنيد
$datearray = array(
'day' => date('d', $timestamp),
'month' => date('n', $timestamp),
'year' => date('Y', $timestamp)
);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_datearray')) ? eval($hook) : false;



5. فايل 'includes/class_dm_user.php' باز کنيد
کد زير را پيدا کنيد
function verify_birthday(&$birthday)
{

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_verify_birthday' )) ? eval($hook) : false;



6. فايل 'includes/class_userprofile.php' باز کنيد
کد زير را پيدا کنيد
$bday = explode('-', $userinfo['birthday']);

$year = vbdate('Y', TIMENOW, false, false);
$month = vbdate('n', TIMENOW, false, false);
$day = vbdate('j', TIMENOW, false, false);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_bday')) ? eval($hook) : false;


کد زير را پيدا کنيد
$this->registry->options['calformat1'] = mktimefix($this->registry->options['calformat1'], $bday[2]);

قبل از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_tbday')) ? eval($hook) : false;



7. فايل 'includes/class_postbit.php' باز کنيد
کد زير را پيدا کنيد
$this->cache['year'] = vbdate('Y', TIMENOW, false, false);
$this->cache['month'] = vbdate('n', TIMENOW, false, false);
$this->cache['day'] = vbdate('j', TIMENOW, false, false);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_bday')) ? eval($hook) : false;



8. فايل 'includes/blog_functions.php' باز کنيد
کد زير را پيدا کنيد
$startdate = getdate(gmmktime(12, 0, 0, $month, 1, $year));

قبل از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_blog')) ? eval($hook) : false;


کد زير را پيدا کنيد
if ($userinfo['showbirthday'] == 1 OR $userinfo['showbirthday'] == 2)
{
$year = vbdate('Y', TIMENOW, false, false);
$month = vbdate('n', TIMENOW, false, false);
$day = vbdate('j', TIMENOW, false, false);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_blog')) ? eval($hook) : false;



9. فايل 'register.php' باز کنيد
کد زير را پيدا کنيد
$bday = explode('-', $birthday);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_bday_register')) ? eval($hook) : false;


کد زير را پيدا کنيد
if ($vbulletin->GPC['month'] == 0 OR $vbulletin->GPC['day'] == 0 OR !preg_match('#^\d{4}$#', $vbulletin->GPC['year']) OR $vbulletin->GPC['year'] < 1901 OR $vbulletin->GPC['year'] > $current['year'])
{
eval(standard_error(fetch_error('select_valid_dob' , $current['year'])));
}

کد بالا را با کد زير جايگزين کنيد
if ($vbulletin->options['jalali_act'] == 1){
$jalalicurrent['year'] = jdate('Y');
list ( $vbulletin->GPC['year'], $vbulletin->GPC['month'], $vbulletin->GPC['day'] ) = jalali_to_gregorian ( $vbulletin->GPC['year'], $vbulletin->GPC['month'], $vbulletin->GPC['day'] );
if ($vbulletin->GPC['month'] == 0 OR $vbulletin->GPC['day'] == 0 OR !preg_match('#^\d{4}$#', $vbulletin->GPC['year']) OR $vbulletin->GPC['year'] < 1901 OR $vbulletin->GPC['year'] > $current['year']){
eval(standard_error(fetch_error('jalali_select_val id_month_and_year', $jalalicurrent['year'])));}}
else{
if ($vbulletin->GPC['month'] == 0 OR $vbulletin->GPC['day'] == 0 OR !preg_match('#^\d{4}$#', $vbulletin->GPC['year']) OR $vbulletin->GPC['year'] < 1901 OR $vbulletin->GPC['year'] > $current['year']){
eval(standard_error(fetch_error('select_valid_dob' , $current['year'])));}
}


کد زير را پيدا کنيد
// pre-cache templates used by specific actions

قبل از کد بالا کد زير را قرار دهید
require_once('./global.php');
($hook = vBulletinHook::fetch_hook('jalali_globaltemplates' )) ? eval($hook) : false;


کد زير را پيدا کنيد
$templater = vB_Template::create('register_verify_age');

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_templater_regist er')) ? eval($hook) : false;


کد زير را پيدا کنيد
$templater = vB_Template::create('modifyprofile_birthday');

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_templater_modify profile')) ? eval($hook) : false;



10.فايل 'private.php' باز کنيد

نکته : دوستان پی ام هیلتر که در پایین میبینید رو بهم بچسبونید

کد زير را پيدا کنيد
$templater = vB_Template::create('pm_f ilter');

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_templater_privat e')) ? eval($hook) : false;



11.فايل 'announcement.php' باز کنيد
کد زير را پيدا کنيد
$templater = vB_Template::create('announcement_edit');

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_templater_announ cement')) ? eval($hook) : false;


کد زير را پيدا کنيد
$GLOBALS["{$date_type}_date_array"] = array(
'day' => vbdate('j', $announcementinfo["{$date_type}date"], false, false),
'month' => vbdate('n', $announcementinfo["{$date_type}date"], false, false),
'year' => vbdate('Y', $announcementinfo["{$date_type}date"], false, false)
);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_fields')) ? eval($hook) : false;




12. فايل 'profile.php' باز کنيد
کد زير را پيدا کنيد
if (date('Y') >= $birthday[2] AND $birthday[2] != '0000')
{
$year = $birthday[2];
}

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_set_birthday')) ? eval($hook) : false;


کد زير را پيدا کنيد
$vbulletin->options['calformat1'] = mktimefix($vbulletin->options['calformat1'], $birthday[2]);

قبل از کد بالا کد زير را قرار دهید
$hook = vBulletinHook::fetch_hook('jalali_calformat')) ? eval($hook) : false;


کد زير را پيدا کنيد
$actiontemplates['docustomize'] = $actiontemplates['customize'];

قبل از کد بالا کد زير را قرار دهید
require_once('./global.php');
($hook = vBulletinHook::fetch_hook('jalali_actiontemplates' )) ? eval($hook) : false;


کد زير را پيدا کنيد
$birthdaybit = $templater->render();

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_templater_profil e')) ? eval($hook) : false;



13. فايل 'forum.php' باز کنيد
کد زير را پيدا کنيد
$today = vbdate('Y-m-d', TIMENOW, false, false);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_today')) ? eval($hook) : false;



14. فايل 'memberlist.php' باز کنيد
کد زير را پيدا کنيد
if ($vbulletin->options['usememberlistadvsearch'])
{

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_usememberlistadv search')) ? eval($hook) : false;


کد زير را پيدا کنيد
$today_year = vbdate('Y', TIMENOW, false, false);
$today_month = vbdate('n', TIMENOW, false, false);
$today_day = vbdate('j', TIMENOW, false, false);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_memberlistbits') ) ? eval($hook) : false;


کد زير را پيدا کنيد
$birthdayformat = mktimefix($vbulletin->options['calformat1'], $bday[2]);

بعد از کد بالا کد زير را قرار دهید
($hook = vBulletinHook::fetch_hook('jalali_birthdayformat') ) ? eval($hook) : false;



15. حال به مسير زير بريد و هک را وارد کنید
محصولات -> اضافه کردن محصول -> فايل jalali.xml را ايمپرت کنيد.


کار شما عالی بود!

Lynne
06-10-2012, 12:01 AM
Is this a modification you wrote yourself or one that you have permission to share?

SANBOR
06-11-2012, 04:48 PM
Hi again
I wrote this modification myself .
i want you just a request :
among webmasters , vbulletin is best script . So, you can improve and put it as excellent by adding jalali and hijri calenders in vbulletin source .
By adding these calenders , webmasters that use vbulletin will be more than before .
note : by modifying this jalali calender we can write hijri calender
I can write hijri calender like this jalali calender or help vbulletin developers to write hijri calender too

best regards

Greight
06-13-2012, 06:10 PM
Thanks a million, buddy!

you can improve and put it as excellent by adding jalali and hijri calenders in vbulletin source .

Yes, I believe as vBulletin is not restricted to just one nationality or one language, it must support at least main kinds of calendar systems. Anyways I think it should be mentioned at vBulletin.com.

yaghoub
06-14-2012, 11:10 AM
hi my friend big Lynne

this modification has been created by SANBOR and other friends .

thanks sanbor and other friends for this great effort. We are trying to nationality vbulletin

Mark as Installed sanbor

kamran_dotnet
06-18-2012, 05:25 PM
by the roles of this forum i cant talk Persian so I'm sorry before

thank you Mr shamsi
install step is very hard and i recommend to backup files before edit them.
anyway result is perfect.it works fine in my forum:
http://forum.winphonecenter.com

one thing i experiences when changing the files and i want to share it with others
when you editing files, try not to select code from this topic with double click.because sometimes it select a ":" with code and maybe you replace it in your files
just drag and highlight code and paste it carefully

kamran_dotnet
06-20-2012, 02:15 AM
Bug report
one of users set his birthday date to 31 mar 1992
but system show him a birthday message in yesterday: 20 June 2012

SANBOR
06-20-2012, 04:05 AM
Bug report
one of users set his birthday date to 31 mar 1992
but system show him a birthday message in yesterday: 20 June 2012
I CHECKED

NO BOG

ecitizen
08-09-2012, 09:10 PM
HI
thanks a lot.
it is very good
i hop the vbultin adding jalali and hijri calenders in vbulletin source .