wp-jalali - Version 5.0.0-RC2

Version Description

Download this release

Release Info

Developer mani_monaj
Plugin Icon 128x128 wp-jalali
Version 5.0.0-RC2
Comparing to
See all releases

Code changes from version 5.0.0-RC to 5.0.0-RC2

images/logo.png DELETED
Binary file
images/wp-fa-logo.png DELETED
Binary file
inc/dashboard-core.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
- $primary_replacement =
3
- array (
4
- 1 => array (
5
- 'link' => 'http://wordpress.org/development/',
6
- 'feed' => 'http://wordpress.org/development/feed/',
7
- 'title' => 'WordPress Development Blog'
8
- ),
9
- 2 => array (
10
- 'link' => 'http://wp-persian.com/',
11
- 'feed' => 'http://wp-persian.com/feed/',
12
- 'title' => 'اخبار وردپرس فارسی'
13
- )
14
- );
15
- $secondary_replacement =
16
- array (
17
- 1 => array (
18
- 'link' => 'http://planet.wordpress.org/',
19
- 'feed' => 'http://planet.wordpress.org/feed/',
20
- 'title' => 'Other WordPress News'
21
- ),
22
- 2 => array (
23
- 'link' => 'http://planet.wp-persian.com/',
24
- 'feed' => 'http://planet.wp-persian.com/feed/',
25
- 'title' => 'سیاره وردپرس فارسی'
26
- )
27
- );
28
-
29
- function mps_dashboard_primary_link ($value) {
30
- global $primary_replacement, $mps_jd_optionsDB;
31
- $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
32
-
33
- $ret = ($mps_jd_dashboard == 0) ? $value : $primary_replacement[$mps_jd_dashboard]['link'];
34
- return $ret;
35
- }
36
-
37
- function mps_dashboard_primary_feed ($value) {
38
- global $primary_replacement, $mps_jd_optionsDB;
39
- $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
40
-
41
- return ($mps_jd_dashboard == 0) ? $value : $primary_replacement[$mps_jd_dashboard]['feed'];
42
- }
43
-
44
- function mps_dashboard_primary_title ($value) {
45
- global $primary_replacement, $mps_jd_optionsDB;
46
- $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
47
-
48
- return ($mps_jd_dashboard == 0) ? $value : $primary_replacement[$mps_jd_dashboard]['title'];
49
- }
50
-
51
- function mps_dashboard_secondary_link ($value) {
52
- global $secondary_replacement, $mps_jd_optionsDB;
53
- $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
54
-
55
- return ($mps_jd_dashboard == 0) ? $value : $secondary_replacement[$mps_jd_dashboard]['link'];
56
- }
57
-
58
- function mps_dashboard_secondary_feed ($value) {
59
- global $secondary_replacement, $mps_jd_optionsDB;
60
- $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
61
-
62
- return ($mps_jd_dashboard == 0) ? $value : $secondary_replacement[$mps_jd_dashboard]['feed'];
63
- }
64
-
65
- function mps_dashboard_secondary_title ($value) {
66
- global $secondary_replacement, $mps_jd_optionsDB;
67
- $mps_jd_dashboard = $mps_jd_optionsDB['mps_jd_dashboard'];
68
-
69
- return ($mps_jd_dashboard == 0) ? $value : $secondary_replacement[$mps_jd_dashboard]['title'];
70
- }
71
-
72
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/deprecated.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- if (!function_exists('fetch_rss')) require_once (ABSPATH . WPINC . '/class-simplepie.php');
3
- if (!function_exists('error')) {
4
- function error ($errormsg, $lvl=E_USER_WARNING) {
5
- // append PHP's error message if track_errors enabled
6
- if ( $php_errormsg ) {
7
- $errormsg .= " ($php_errormsg)";
8
- }
9
- if ( MAGPIE_DEBUG ) {
10
- trigger_error( $errormsg, $lvl);
11
- }
12
- else {
13
- error_log( $errormsg, 0);
14
- }
15
-
16
- $notices = E_USER_NOTICE|E_NOTICE;
17
- if ( $lvl&$notices ) {
18
- $this->WARNING = $errormsg;
19
- } else {
20
- $this->ERROR = $errormsg;
21
- }
22
- }
23
- }
24
-
25
- function mps_mce_pretext($input=null){
26
- $_nbsp = "&nbsp;";
27
- $_p = "<p dir=\"rtl\">".$_nbsp."</p>";
28
- return (strlen($input)==0?$_p:$input);
29
- }
30
-
31
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/editjalali-core.php DELETED
@@ -1,91 +0,0 @@
1
- <?php
2
- function jalali_touch_time( $edit = 1, $for_post = 1 ) {
3
- global $wp_locale, $post, $comment, $j_month_name;
4
-
5
- if ( $for_post )
6
- $edit = ( ('draft' == $post->post_status ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
7
-
8
- $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
9
- $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
10
- $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
11
- $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
12
- $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
13
- $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
14
- $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
15
- $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
16
-
17
- // making jalali date from post time/current time
18
- $jalali_time = gregorian_to_jalali($aa,$mm,$jj);
19
- $jy = $jalali_time[0];
20
- $jm = $jalali_time[1];
21
- $jd = $jalali_time[2];
22
-
23
- echo "\n<script type=\"text/javascript\" src=\"" . get_option('siteurl') ."/wp-content/plugins/wp-jalali/inc/js/editjalali.js\"></script>\n";
24
- ?>
25
-
26
- <style>#jmonths {direction:rtl;text-align: right}</style>
27
-
28
- <script type="text/javascript">
29
-
30
- function jalali_timestamp_func() {
31
- var jd = jQuery('#jd').attr('value');
32
- var jy = jQuery('#jy').attr('value');
33
- var jm = jQuery('select#jm_select > option:selected').attr('value');
34
- if(!jd) jd = <?php echo $jd; ?>;
35
- if(!jm) jm = <?php echo $jm; ?>;
36
- if(!jy) jy = <?php echo $jy; ?>;
37
- var j_time_array = new Array(jy,jm,jd);
38
- var j2g = jalali_to_gregorian(j_time_array);
39
- var gy = j2g[0];
40
- var gm = j2g[1];
41
- var gd = j2g[2];
42
- jQuery('#jj').attr('value',gd);
43
- jQuery('#aa').attr('value',gy);
44
- if(gm<10) gm = "0"+gm;
45
- jQuery('div.timestamp-wrap > select#mm > option[value='+gm+']').attr('selected','selected');
46
- }
47
-
48
- function inject_jalali_div() { // use for injecting jalali input boxes and month list under the default georgian date place
49
- jQuery("#timestampdiv *").hide();
50
- jQuery("#timestampdiv p *").show();
51
- jQuery("#timestampdiv p").show();
52
- jQuery("#timestampdiv").append('<div id="jalalitimestamp"></div>');
53
- jQuery("#jalalitimestamp").append('<select tabindex="501" onchange="jalali_timestamp_func()" name="jm" id="jm_select"></select> ');
54
- <?php
55
- for ( $i = 1; $i < 13; $i = $i +1 ) {
56
- if($i == $jm) $selected_month = 'selected="selected"';
57
- echo "\tjQuery(\"#jm_select\").append('<option $selected_month value=\"$i\" id=\"jm_$i\">$j_month_name[$i]</option>');\n";
58
- $selected_month = '';
59
- }
60
- ?>
61
- jQuery("#jalalitimestamp").append('<input tabindex="502" type="text" id="jd" name="jd" value="<?php echo $jd; ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()"/> ');
62
- jQuery("#jalalitimestamp").append('<input tabindex="500" type="text" id="jy" name="jy" value="<?php echo $jy ?>" size="4" maxlength="5" onchange="jalali_timestamp_func()" />');
63
- jQuery("#jalalitimestamp").append('<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()" />');
64
- jQuery("#jalalitimestamp").append('<br />ساعت: <input tabindex="503" type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()" /> : <input tabindex="504" type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="jalali_timestamp_func()" /> دقیقه');
65
-
66
- jQuery("select#mm, input#jj, input#aa").attr("onchange","georgian_timestamp_func()");
67
- jQuery(".save-timestamp").click(function(){
68
- jQuery("#jalali-edit-date").text(jQuery('#jd').attr('value')+' '+ jQuery('select#jm_select > option:selected').text()+ ' ' + jQuery('#jy').attr('value') + ' در ' + jQuery('#hh').attr('value') + ':' + jQuery('#mn').attr('value'));
69
- });
70
- <?php
71
- if ( $edit ) {
72
- echo "jQuery(\"a.edit-timestamp\").before('" . farsi_num(sprintf( __('<br /><span style="text-align:right;direction:rtl;" id="jalali-edit-date"> %2$s %1$s / %3$s در %4$s:%5$s' ), $j_month_name[$jm], $jd, $jy, $hh, $mn )) . " </span> ');\n";
73
- }
74
- ?>
75
- }
76
- inject_jalali_div(); // inject!
77
- </script>
78
- <?php
79
-
80
- }
81
-
82
- function jalali_timestamp_admin() {
83
- if(isset($_GET['action']) AND $_GET['action']=='edit') {
84
- $Edit = 1;
85
- } else {
86
- $Edit = 0;
87
- }
88
- if ( current_user_can('edit_posts') ) jalali_touch_time($Edit);
89
- }
90
-
91
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/farsinum-core.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- /* Originally written by Farhadi , www.farhadi.ir */
4
-
5
- function convertToFarsi($matches) {
6
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
7
- $mps_jd_decimal = $mps_jd_optionsDB['mps_jd_decimal'];
8
- if($mps_jd_decimal == true)
9
- //$farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "<sub><small>/</small></sub>");
10
- $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "٫");
11
- else
12
- $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", ".");
13
-
14
- $english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".");
15
-
16
- $out = '';
17
- if (isset($matches[1])) {
18
- return str_replace($english_array, $farsi_array, $matches[1]);
19
- }
20
- return $matches[0];
21
- }
22
-
23
- function farsi_num($num,$fake = null,$fake2=null) {
24
- return preg_replace_callback('/(?:&#\d{2,4};)|(\d+[\.\d]*)|(?:[a-z](?:[\x00-\x3B\x3D-\x7F]|<\s*[^>]+>)*)|<\s*[^>]+>/i', 'convertToFarsi', $num);
25
- }
26
-
27
- function english_num($num) {
28
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
29
- $mps_jd_decimal = $mps_jd_optionsDB['mps_jd_decimal'];
30
- if($mps_jd_decimal == true)
31
- //$farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "<sub><small>/</small></sub>");
32
- $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "٫");
33
- else
34
- $farsi_array = array("۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", ".");
35
-
36
- $english_array = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".");
37
-
38
- return str_replace($farsi_array, $english_array, $num);
39
- }
40
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/jalali-core.php DELETED
@@ -1,484 +0,0 @@
1
- <?php
2
- /* get options for month names (IR|AF) */
3
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
4
- $country = $mps_jd_optionsDB['mps_jd_country'];
5
-
6
- /* Jalali Core Functions */
7
-
8
- define("_JDF_USE_PERSIANNUM","0");
9
- define("_JDF_TZhours","0");
10
- define("_JDF_TZminute","0");
11
- define('_JDF_AM_LONG','قبل از ظهر');
12
- define('_JDF_PM_LONG','بعد از ظهر');
13
- define('_JDF_AM_SHORT','ق.ظ');
14
- define('_JDF_PM_SHORT','ب.ظ');
15
- define('_JDF_Sat_LONG','شنبه');
16
- define('_JDF_Sun_LONG','یکشنبه');
17
- define('_JDF_Mon_LONG','دوشنبه');
18
- define('_JDF_Tue_LONG','سه شنبه');
19
- define('_JDF_Wed_LONG','چهارشنبه');
20
- define('_JDF_Thu_LONG','پنجشنبه');
21
- define('_JDF_Fri_LONG','جمعه');
22
- define('_JDF_Sat_SHORT','ش');
23
- define('_JDF_Sun_SHORT','ی');
24
- define('_JDF_Mon_SHORT','د');
25
- define('_JDF_Tue_SHORT','س');
26
- define('_JDF_Wed_SHORT','چ');
27
- define('_JDF_Thu_SHORT','پ');
28
- define('_JDF_Fri_SHORT','ج');
29
- define('_JDF_Suffix','م');
30
- define('_JDF_Num0','۰');
31
- define('_JDF_Num1','۱');
32
- define('_JDF_Num2','۲');
33
- define('_JDF_Num3','۳');
34
- define('_JDF_Num4','۴');
35
- define('_JDF_Num5','۵');
36
- define('_JDF_Num6','۶');
37
- define('_JDF_Num7','۷');
38
- define('_JDF_Num8','۸');
39
- define('_JDF_Num9','۹');
40
- if($country == 'AF') {
41
- define('_JDF_Far','حمل');
42
- define('_JDF_Ord','ثور');
43
- define('_JDF_Kho','جوزا');
44
- define('_JDF_Tir','سرطان');
45
- define('_JDF_Mor','اسد');
46
- define('_JDF_Sha','سنبله');
47
- define('_JDF_Meh','میزان');
48
- define('_JDF_Aba','عقرب');
49
- define('_JDF_Aza','قوس');
50
- define('_JDF_Dey','جدی');
51
- define('_JDF_Bah','دلو');
52
- define('_JDF_Esf','حوت');
53
- $j_month_name = array("", "حمل", "ثور", "جوزا", "سرطان","اسد", "سنبله", "میزان", "عقرب", "قوس","جدی", "دلو", "حوت");
54
- } else {
55
- define('_JDF_Far','فروردین');
56
- define('_JDF_Ord','اردیبهشت');
57
- define('_JDF_Kho','خرداد');
58
- define('_JDF_Tir','تیر');
59
- define('_JDF_Mor','مرداد');
60
- define('_JDF_Sha','شهریور');
61
- define('_JDF_Meh','مهر');
62
- define('_JDF_Aba','آبان');
63
- define('_JDF_Aza','آذر');
64
- define('_JDF_Dey','دی');
65
- define('_JDF_Bah','بهمن');
66
- define('_JDF_Esf','اسفند');
67
- $j_month_name = array("", "فروردین", "اردیبهشت", "خرداد", "تیر","مرداد", "شهریور", "مهر", "آبان", "آذر","دی", "بهمن", "اسفند");
68
- }
69
-
70
- $g_days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
71
- $j_days_in_month = array(31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29);
72
- $j_day_name = array("یکشنبه","دوشنبه","سه شنبه","چهارشنبه","پنجشنبه","جمعه","شنبه");
73
- $jday_abbrev = array("ی","د","س","چ","پ","ج","ش");
74
-
75
- /* Farsiweb.info Jaladi/Gregorian Convertion Functions */
76
-
77
- function div($a, $b)
78
- {
79
- return (int) ($a / $b);
80
- }
81
-
82
- function jalali_to_gregorian($j_y, $j_m, $j_d)
83
- {
84
- global $g_days_in_month;
85
- global $j_days_in_month;
86
-
87
- $jy = $j_y-979;
88
- $jm = $j_m-1;
89
- $jd = $j_d-1;
90
-
91
- $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4);
92
- for ($i=0; $i < $jm; ++$i)
93
- $j_day_no += $j_days_in_month[$i];
94
-
95
- $j_day_no += $jd;
96
-
97
- $g_day_no = $j_day_no+79;
98
-
99
- $gy = 1600 + 400*div($g_day_no, 146097); /* 146097 = 365*400 + 400/4 - 400/100 + 400/400 */
100
- $g_day_no = $g_day_no % 146097;
101
-
102
- $leap = true;
103
- if ($g_day_no >= 36525) /* 36525 = 365*100 + 100/4 */
104
- {
105
- $g_day_no--;
106
- $gy += 100*div($g_day_no, 36524); /* 36524 = 365*100 + 100/4 - 100/100 */
107
- $g_day_no = $g_day_no % 36524;
108
-
109
- if ($g_day_no >= 365)
110
- $g_day_no++;
111
- else
112
- $leap = false;
113
- }
114
-
115
- $gy += 4*div($g_day_no, 1461); /* 1461 = 365*4 + 4/4 */
116
- $g_day_no %= 1461;
117
-
118
- if ($g_day_no >= 366) {
119
- $leap = false;
120
-
121
- $g_day_no--;
122
- $gy += div($g_day_no, 365);
123
- $g_day_no = $g_day_no % 365;
124
- }
125
-
126
- for ($i = 0; $g_day_no >= $g_days_in_month[$i] + ($i == 1 && $leap); $i++)
127
- $g_day_no -= $g_days_in_month[$i] + ($i == 1 && $leap);
128
- $gm = $i+1;
129
- $gd = $g_day_no+1;
130
-
131
- return array($gy, $gm, $gd);
132
- }
133
-
134
- function jcheckdate($j_m, $j_d, $j_y)
135
- {
136
- global $j_days_in_month;
137
-
138
- if ($j_y < 0 || $j_y > 32767 || $j_m < 1 || $j_m > 12 || $j_d < 1 || $j_d >
139
- ($j_days_in_month[$j_m-1] + ($j_m == 12 && !(($j_y-979)%33%4))))
140
- return false;
141
- return true;
142
- }
143
-
144
- function gregorian_week_day($g_y, $g_m, $g_d)
145
- {
146
- global $g_days_in_month;
147
-
148
- $gy = $g_y-1600;
149
- $gm = $g_m-1;
150
- $gd = $g_d-1;
151
-
152
- $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400);
153
-
154
- for ($i=0; $i < $gm; ++$i)
155
- $g_day_no += $g_days_in_month[$i];
156
- if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0)))
157
- /* leap and after Feb */
158
- ++$g_day_no;
159
- $g_day_no += $gd;
160
-
161
- return ($g_day_no + 5) % 7 + 1;
162
- }
163
-
164
- function jalali_week_day($j_y, $j_m, $j_d)
165
- {
166
- global $j_days_in_month;
167
-
168
- $jy = $j_y-979;
169
- $jm = $j_m-1;
170
- $jd = $j_d-1;
171
-
172
- $j_day_no = 365*$jy + div($jy, 33)*8 + div($jy%33+3, 4);
173
-
174
- for ($i=0; $i < $jm; ++$i)
175
- $j_day_no += $j_days_in_month[$i];
176
-
177
- $j_day_no += $jd;
178
-
179
- return ($j_day_no + 2) % 7 + 1;
180
- }
181
-
182
-
183
- function gregorian_to_jalali($g_y, $g_m, $g_d)
184
- {
185
- global $g_days_in_month;
186
- global $j_days_in_month;
187
-
188
- $gy = $g_y-1600;
189
- $gm = $g_m-1;
190
- $gd = $g_d-1;
191
-
192
- $g_day_no = 365*$gy+div($gy+3,4)-div($gy+99,100)+div($gy+399,400);
193
-
194
- for ($i=0; $i < $gm; ++$i)
195
- $g_day_no += $g_days_in_month[$i];
196
- if ($gm>1 && (($gy%4==0 && $gy%100!=0) || ($gy%400==0)))
197
- /* leap and after Feb */
198
- ++$g_day_no;
199
- $g_day_no += $gd;
200
-
201
- $j_day_no = $g_day_no-79;
202
-
203
- $j_np = div($j_day_no, 12053);
204
- $j_day_no %= 12053;
205
-
206
- $jy = 979+33*$j_np+4*div($j_day_no,1461);
207
-
208
- $j_day_no %= 1461;
209
-
210
- if ($j_day_no >= 366) {
211
- $jy += div($j_day_no-1, 365);
212
- $j_day_no = ($j_day_no-1)%365;
213
- }
214
-
215
- for ($i = 0; $i < 11 && $j_day_no >= $j_days_in_month[$i]; ++$i) {
216
- $j_day_no -= $j_days_in_month[$i];
217
- }
218
- $jm = $i+1;
219
- $jd = $j_day_no+1;
220
-
221
-
222
- return array($jy, $jm, $jd);
223
- }
224
-
225
- /*
226
- Jalali Date function by Milad Rastian (miladmovie AT yahoo DOT com)
227
- jdf.farsiprojects.com
228
- */
229
-
230
-
231
- function jdate($type,$maket="now",$forcelatinnums=false)
232
- {
233
- $result="";
234
- if($maket=="now"){
235
- $year=date("Y");
236
- $month=date("m");
237
- $day=date("d");
238
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
239
- $maket=jmaketime(date("h")+_JDF_TZhours,date("i")+_JDF_TZminute,date("s"),$jmonth,$jday,$jyear);
240
- }else{
241
- $maket+=_JDF_TZhours*3600+_JDF_TZminute*60;
242
- $date=date("Y-m-d",$maket);
243
- list( $year, $month, $day ) = preg_split ( '/-/', $date );
244
-
245
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
246
- }
247
-
248
- $need= $maket;
249
- $year=date("Y",$need);
250
- $month=date("m",$need);
251
- $day=date("d",$need);
252
- $i=0;
253
- $skipnext = false;
254
- while($i<strlen($type))
255
- {
256
- $subtype=substr($type,$i,1);
257
-
258
- if ($skipnext) {
259
- $result .= $subtype;
260
- $skipnext = false;
261
- $i++;
262
- continue;
263
- }
264
-
265
-
266
- switch ($subtype)
267
- {
268
- case "A":
269
- $result1=date("a",$need);
270
- if($result1=="pm")
271
- $result.=_JDF_PM_LONG;
272
- else
273
- $result.=_JDF_AM_LONG;
274
- break;
275
-
276
- case "a":
277
- $result1=date("a",$need);
278
- if($result1=="pm")
279
- $result.=_JDF_PM_SHORT;
280
- else
281
- $result.=_JDF_AM_SHORT;
282
- break;
283
-
284
- case "d":
285
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
286
- if($jday<10)
287
- $result1="0".$jday;
288
- else
289
- $result1=$jday;
290
-
291
- $result.=$result1;
292
- break;
293
-
294
- case "D":
295
- $result1=date("D",$need);
296
- if($result1=="Sat") $result1=_JDF_Sat_SHORT;
297
- else if($result1=="Sun") $result1=_JDF_Sun_SHORT;
298
- else if($result1=="Mon") $result1=_JDF_Mon_SHORT;
299
- else if($result1=="Tue") $result1=_JDF_Tue_SHORT;
300
- else if($result1=="Wed") $result1=_JDF_Wed_SHORT;
301
- else if($result1=="Thu") $result1=_JDF_Thu_SHORT;
302
- else if($result1=="Fri") $result1=_JDF_Fri_SHORT;
303
- $result.=$result1;
304
- break;
305
-
306
- case"F":
307
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
308
- $result.=monthname($jmonth);
309
- break;
310
-
311
- case "g":
312
- $result1=date("g",$need);
313
- $result.=$result1;
314
- break;
315
-
316
- case "G":
317
- $result1=date("G",$need);
318
- $result.=$result1;
319
- break;
320
-
321
- case "h":
322
- $result1=date("h",$need);
323
- $result.=$result1;
324
- break;
325
-
326
- case "H":
327
- $result1=date("H",$need);
328
- $result.=$result1;
329
- break;
330
-
331
- case "i":
332
- $result1=date("i",$need);
333
- $result.=$result1;
334
- break;
335
-
336
- case "j":
337
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
338
- $result1=$jday;
339
- $result.=$result1;
340
- break;
341
-
342
- case "l":
343
- $result1=date("l",$need);
344
- if($result1=="Saturday") $result1=_JDF_Sat_LONG;
345
- else if($result1=="Sunday") $result1=_JDF_Sun_LONG;
346
- else if($result1=="Monday") $result1=_JDF_Mon_LONG;
347
- else if($result1=="Tuesday") $result1=_JDF_Tue_LONG;
348
- else if($result1=="Wednesday") $result1=_JDF_Wed_LONG;
349
- else if($result1=="Thursday") $result1=_JDF_Thu_LONG;
350
- else if($result1=="Friday") $result1=_JDF_Fri_LONG;
351
- $result.=$result1;
352
- break;
353
-
354
- case "m":
355
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
356
- if($jmonth<10)
357
- $result1="0".$jmonth;
358
- else
359
- $result1=$jmonth;
360
- $result.=$result1;
361
- break;
362
-
363
- case "M":
364
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
365
- $result.=monthname($jmonth);
366
- break;
367
-
368
- case "n":
369
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
370
- $result1=$jmonth;
371
- $result.=$result1;
372
- break;
373
-
374
- case "s":
375
- $result1=date("s",$need);
376
- $result.=$result1;
377
- break;
378
-
379
- case "S":
380
- $result.=_JDF_Suffix;
381
- break;
382
-
383
- case "t":
384
- $result.=lastday ($month,$day,$year);
385
- break;
386
-
387
- case "w":
388
- $result1=date("w",$need);
389
- $result.=$result1;
390
- break;
391
-
392
- case "y":
393
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
394
- $result1=substr($jyear,2,4);
395
- $result.=$result1;
396
- break;
397
-
398
- case "Y":
399
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
400
- $result1=$jyear;
401
- $result.=$result1;
402
- break;
403
-
404
- case "\\":
405
- $result.='';
406
- $skipnext = true;
407
- break;
408
-
409
- default:
410
- $result.=$subtype;
411
- }
412
- $i++;
413
- }
414
-
415
- $mps_jd_optionsDB = get_option(MPS_JD_OPTIONS_NAME);
416
- $mps_jd_farsinum_date = $mps_jd_optionsDB['mps_jd_farsinum_date'];
417
-
418
- if ((!$forcelatinnums) && ($mps_jd_farsinum_date))
419
- $result = farsi_num($result);
420
-
421
- return $result;
422
- }
423
-
424
-
425
-
426
- function jmaketime($hour,$minute,$second,$jmonth,$jday,$jyear)
427
- {
428
- list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, $jday);
429
- //$i=mktime((int) $hour,(int) $minute,(int) $second, (int) $month, (int) $day, (int) $year, 0);
430
- $i=mktime((int) $hour,(int) $minute,(int) $second, (int) $month, (int) $day, (int) $year);
431
- return $i;
432
- }
433
-
434
-
435
- ///Find Day Begining Of Month
436
- function mstart($month,$day,$year)
437
- {
438
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
439
- list( $year, $month, $day ) = jalali_to_gregorian($jyear, $jmonth, "1");
440
- $timestamp=mktime(0,0,0,$month,$day,$year);
441
- return date("w",$timestamp);
442
- }
443
-
444
- //Find Number Of Days In This Month
445
- function lastday ($month,$day,$year)
446
- {
447
- $lastdayen=date("d",mktime(0,0,0,$month+1,0,$year));
448
- list( $jyear, $jmonth, $jday ) = gregorian_to_jalali($year, $month, $day);
449
- $lastdatep=$jday;
450
- $jday=$jday2;
451
- while($jday2!="1")
452
- {
453
- if($day<$lastdayen)
454
- {
455
- $day++;
456
- list( $jyear, $jmonth, $jday2 ) = gregorian_to_jalali($year, $month, $day);
457
- if($jdate2=="1") break;
458
- if($jdate2!="1") $lastdatep++;
459
- }
460
- else
461
- {
462
- $day=0;
463
- $month++;
464
- if($month==13)
465
- {
466
- $month="1";
467
- $year++;
468
- }
469
- }
470
-
471
- }
472
- return $lastdatep-1;
473
- }
474
-
475
- //translate number of month to name of month
476
- function monthname($month)
477
- {
478
- $month_map = array(1 => _JDF_Far, 2 => _JDF_Ord, 3 => _JDF_Kho, 4 => _JDF_Tir
479
- , 5 => _JDF_Mor, 6 => _JDF_Sha, 7 => _JDF_Meh, 8 => _JDF_Aba, 9 => _JDF_Aza
480
- , 10 => _JDF_Dey, 11 => _JDF_Bah, 12 => _JDF_Esf);
481
- return $month_map[(int) $month];
482
- }
483
-
484
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/js/editjalali.js DELETED
@@ -1 +0,0 @@
1
- eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('t=l q(9,Z,9,e,9,e,9,9,e,9,e,9);u=l q(9,9,9,9,9,9,e,e,e,e,e,U);y c(a,b){v W.N(a/b)}y E(g){d 7,k,p;d f,o,n;d 5,6;d z;d i;7=g[0]-I;k=g[1]-1;p=g[2]-1;5=h*7+c((7+3),4)-c((7+P),C)+c((7+Q),B);s(i=0;i<k;++i)5+=t[i];r(k>1&&((7%4==0&&7%C!=0)||(7%B==0)))++5;5+=p;6=5-H;z=c(6,F);6%=F;f=G+A*z+4*c(6,x);6%=x;r(6>=D){f+=c((6-1),h);6=(6-1)%h}s(i=0;i<R&&6>=u[i];++i){6-=u[i]}o=i+1;n=6+1;v l q(f,o,n)}y S(j){d 7,k,p;d f,o,n;d 5,6;d m;d i;f=j[0]-G;o=j[1]-1;n=j[2]-1;6=h*f+c(f,A)*8+c((f%A+3),4);s(i=0;i<o;++i)6+=u[i];6+=n;5=6+H;7=I+B*c(5,J);5=5%J;m=1;r(5>=Y){5--;7+=C*c(5,K);5=5%K;r(5>=h)5++;L m=0}7+=4*c(5,x);5%=x;r(5>=D){m=0;5--;7+=c(5,h);5=5%h}s(i=0;5>=t[i]+(i==1&&m);i++)5-=t[i]+(i==1&&m);k=i+1;p=5+1;v l q(7,k,p)}y M(){w=l T();j=E(l q(w.V(),w.X()+1,w.O()));v j[2]+"/"+j[1]+"/"+j[0]}',62,62,'|||||g_day_no|j_day_no|gy||31|||div|var|30|jy||365|||gm|new|leap|jd|jm|gd|Array|if|for|g_days_in_month|j_days_in_month|return|Today|1461|function|j_np|33|400|100|366|gregorian_to_jalali|12053|979|79|1600|146097|36524|else|jalali_today|floor|getDate|99|399|11|jalali_to_gregorian|Date|29|getFullYear|Math|getMonth|36525|28'.split('|'),0,{}))
 
inc/js/farsitype.js DELETED
@@ -1,378 +0,0 @@
1
- /*
2
- FARSI TYPE
3
- This script developed to ease typing Farsi(Persian) in web forms where there is no Farsi Keyboard installed on a PC.Works with Internet Explorer, Gecko family (Mozilla/FireFox) and Opera.
4
-
5
- Author : Kaveh Ahmadi
6
- Author Contact : kaveh@ashoob.net
7
- Version : 1.3.0
8
-
9
- Copyright 2002-2007 Kaveh Ahmadi (email : kaveh@ashoob.net)
10
- Special Thanks to Gonahkar (gonahkar.com), Mani Monajjemi (manionline.org) and Mazdak Aghakhani (mazdakam.com) for their support and their great ideas!
11
-
12
- This program is free software; you can redistribute it and/or modify
13
- it under the terms of the GNU General Public License as published by
14
- the Free Software Foundation; either version 2 of the License, or
15
- (at your option) any later version.
16
-
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
-
22
- You should have received a copy of the GNU General Public License
23
- along with this program; if not, write to the Free Software
24
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
-
26
- > > > USAGE < < <
27
-
28
- Step 0. Customize settings
29
- Set ShowChangeLangButton, KeyBoardError, ChangeDir variables values with your own opinon!
30
- ShowChangeLangButton // Show Change Language Button --> 0: Show / 1: Visible
31
- KeyBoardError // the action when useres keyboard is farsi --> 0: Disable FarsiType / 1: Show Error
32
- ChangeDir // change the input or textarea direction when language is change --> 0: No Action / 1: Change direction / 2: set Rtl/Ltr button
33
-
34
- Step 1.
35
- Include the "farsitype.js" file to your HTML <head> part (before </head>):
36
- <script language="javascript" src="farsitype.js" type="text/javascript"></script>
37
-
38
- Step 2.
39
- Add "lang" attribute with value "fa" to any <input> or <textarea> tag which you want to have FarsiType enabled!
40
- <input type="text" name="whatever" lang="fa" />
41
- or
42
- <textarea cols="30" rows="7" name="whatever" lang="fa"></textarea>
43
- [Magic : only the lang="fa" is important for FarsiType!]
44
- [As ver 1.2.1 , you can also use lang="fa-IR"]
45
-
46
- Step 3. (OPTIONAL)
47
- You can also add an enable/disable checkbox beside your form.
48
- <input type="checkbox" id="disableFarsiType" />
49
-
50
- Note : You can use F8 keybord button to switch languages instead of using the change language button.
51
-
52
- > > > CHANFGELOG < < <
53
-
54
- V 1.3.0
55
- - Optional controls is added for users
56
-
57
- V 1.2.1
58
- - Comments clean up
59
- - GPL Licence added
60
- - lang = 'fa-IR' support added
61
-
62
- V 1.2
63
- - Opera full support added
64
-
65
- V 1.1
66
- - Some little Gecko fixes
67
-
68
- > > > EXTRA < < <
69
- Mozilla solving problem idea is from: http://forum.persiantools.com/showthread.php?p=667351
70
- Auto Creation idea is from: http://ip.webkar.com/forums/index.php?act=ST&f=19&t=99
71
- with a look at behdad.org/editor and blogfa.com farsi solutions!
72
- */
73
-
74
- // insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement() for Netscape 6/Mozilla by Thor Larholm me@jscript.dk
75
- if(typeof HTMLElement!="undefined" && ! HTMLElement.prototype.insertAdjacentElement) {
76
- HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode) {
77
- switch (where) {
78
- case 'beforeBegin':
79
- this.parentNode.insertBefore(parsedNode,this)
80
- break;
81
- case 'afterBegin':
82
- this.insertBefore(parsedNode,this.firstChild);
83
- break;
84
- case 'beforeEnd':
85
- this.appendChild(parsedNode);
86
- break;
87
- case 'afterEnd':
88
- if (this.nextSibling)
89
- this.parentNode.insertBefore(parsedNode,this.nextSibling);
90
- else
91
- this.parentNode.appendChild(parsedNode);
92
- break;
93
- }
94
- }
95
-
96
- HTMLElement.prototype.insertAdjacentHTML = function (where,htmlStr) {
97
- var r = this.ownerDocument.createRange();
98
- r.setStartBefore(this);
99
- var parsedHTML = r.createContextualFragment(htmlStr);
100
- this.insertAdjacentElement(where,parsedHTML)
101
- }
102
-
103
- HTMLElement.prototype.insertAdjacentText = function (where,txtStr) {
104
- var parsedText = document.createTextNode(txtStr)
105
- this.insertAdjacentElement(where,parsedText)
106
- }
107
- }
108
-
109
- var FarsiType =
110
- {
111
- // Farsi keyboard map based on Iran Popular Keyboard Layout
112
- farsiKey : [
113
- 32 , 33 , 34 , 35 , 36 , 37 , 1548 , 1711 ,
114
- 41 , 40 , 215 , 43 , 1608 , 45 , 46 , 47 ,
115
- 48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 ,
116
- 56 , 57 , 58 , 1705 , 44 , 61 , 46 , 1567 ,
117
- 64 , 1616 , 1584 , 125 , 1609 , 1615 , 1609 , 1604 ,
118
- 1570 , 247 , 1600 , 1548 , 47 , 8217 , 1583 , 215 ,
119
- 1563 , 1614 , 1569 , 1613 , 1601 , 8216 , 123 , 1611 ,
120
- 1618 , 1573 , 126 , 1580 , 1688 , 1670 , 94 , 95 ,
121
- 1662 , 1588 , 1584 , 1586 , 1740 , 1579 , 1576 , 1604 ,
122
- 1575 , 1607 , 1578 , 1606 , 1605 , 1574 , 1583 , 1582 ,
123
- 1581 , 1590 , 1602 , 1587 , 1601 , 1593 , 1585 , 1589 ,
124
- 1591 , 1594 , 1592 , 60 , 124 , 62 , 1617
125
- ],
126
- Type : true,
127
- counter : 0,
128
- ShowChangeLangButton : 1, // 0: Show / 1: Visible
129
- KeyBoardError : 0, // 0: Disable FarsiType / 1: Show Error
130
- ChangeDir : 2 // 0: No Action / 1: Do Rtl-Ltr / 2: Rtl-Ltr button
131
- }
132
-
133
- FarsiType.enable_disable = function(Dis) {
134
- var invis, obj;
135
-
136
- if (!Dis.checked) {
137
- FarsiType.Type = true;
138
- disable = false;
139
- color = 'darkblue';
140
- }
141
- else {
142
- FarsiType.Type = false;
143
- disable = true;
144
- color = '#ECE9D8';
145
- }
146
-
147
- if (FarsiType.ShowChangeLangButton == 1) {
148
- for (var i=1; i<= FarsiType.counter; i++) {
149
- obj = document.getElementById('FarsiType_button_' + i);
150
- obj.disabled = disable;
151
- obj.style.backgroundColor = color;
152
- }
153
- }
154
- }
155
-
156
- FarsiType.Disable = function(){
157
- FarsiType.Type = false;
158
- var Dis = document.getElementById('disableFarsiType')
159
- if (Dis != null) {
160
- Dis.checked = true;
161
- }
162
- if (FarsiType.ShowChangeLangButton == 1) {
163
- for (var i=1; i<= FarsiType.counter; i++) {
164
- obj = document.getElementById('FarsiType_button_' + i);
165
- obj.disabled = true;
166
- obj.style.backgroundColor = '#ECE9D8';
167
- }
168
- }
169
- }
170
-
171
- FarsiType.init = function() {
172
-
173
- var Inputs = document.getElementsByTagName('INPUT');
174
- for (var i=0; i<Inputs.length; i++) {
175
- if (Inputs[i].type.toLowerCase() == 'text' && (Inputs[i].lang.toLowerCase() == 'fa' || Inputs[i].lang.toLowerCase() == 'fa-ir')) {
176
- FarsiType.counter++;
177
- new FarsiType.KeyObject(Inputs[i], FarsiType.counter);
178
- }
179
- }
180
-
181
- var Areas = document.getElementsByTagName('TEXTAREA');
182
- for (var i=0; i<Areas.length; i++) {
183
- if (Areas[i].lang.toLowerCase() == 'fa' || Areas[i].lang.toLowerCase() == 'fa-ir') {
184
- FarsiType.counter++;
185
- new FarsiType.KeyObject(Areas[i], FarsiType.counter);
186
- }
187
- }
188
-
189
- var Dis = document.getElementById('disableFarsiType')
190
- if (Dis != null) {
191
- FarsiType.enable_disable (Dis);
192
- Dis.onclick = new Function( "FarsiType.enable_disable (this);" )
193
- }
194
- }
195
-
196
- FarsiType.KeyObject = function(z,x) {
197
-
198
- GenerateStr = "";
199
- if (FarsiType.ShowChangeLangButton == 1) {
200
- GenerateStr = GenerateStr + "<input type='button' id=FarsiType_button_"+x+" style='border: none; background-color:darkblue; font-size:11; color:white; font-family:tahoma; padding: 1px; margin: 1px; width: auto; height: auto;' value='FA' />&nbsp;";
201
- }
202
- if (FarsiType.ChangeDir == 2) {
203
- GenerateStr = GenerateStr + "<input type='button' id=FarsiType_ChangeDir_"+x+" style='border: none; background-color:darkblue; font-size:11; color:white; font-family:tahoma; padding: 1px; margin: 1px; width: auto; height: auto;' value='RTL' />"
204
- }
205
- z.insertAdjacentHTML("afterEnd", GenerateStr);
206
-
207
- if (FarsiType.ShowChangeLangButton == 1) {
208
- z.bottelm = document.getElementById ('FarsiType_button_' + x);
209
- z.bottelm.title = 'Change lang to english';
210
- }
211
- if (FarsiType.ChangeDir == 2) {
212
- z.Direlm = document.getElementById ('FarsiType_ChangeDir_' + x);
213
- }
214
-
215
- z.farsi = true;
216
- z.dir = "rtl";
217
- z.align = "right";
218
-
219
- z.style.textAlign = z.align;
220
- z.style.direction = z.dir;
221
-
222
- setSelectionRange = function(input, selectionStart, selectionEnd) {
223
- input.focus()
224
- input.setSelectionRange(selectionStart, selectionEnd)
225
- }
226
-
227
- ChangeDirection = function(e) {
228
- if (z.dir == "rtl") {
229
- z.dir = "ltr";
230
- z.align = "left";
231
- z.Direlm.value = "LTR";
232
- z.Direlm.title = "Change direction: Right to Left"
233
- }
234
- else {
235
- z.dir = "rtl";
236
- z.align = "right";
237
- z.Direlm.value = "RTL";
238
- z.Direlm.title = "Change direction: Left to Right"
239
- }
240
- z.style.textAlign = z.align;
241
- z.style.direction = z.dir;
242
- z.focus();
243
- }
244
-
245
- ChangeLang = function(e) {
246
- if (e == null) e = window.event;
247
- var key = e.keyCode ? e.keyCode : e.charCode;
248
-
249
- if (FarsiType.Type) {
250
- if (key==119 || !key) {
251
- if (z.farsi) {
252
- z.farsi = false;
253
- if (FarsiType.ShowChangeLangButton == 1) {
254
- z.bottelm.value = "EN";
255
- z.bottelm.title = 'Change lang to persian';
256
- }
257
- if (FarsiType.ChangeDir == 1) {
258
- z.style.textAlign = "left";
259
- z.style.direction = "ltr";
260
- }
261
- }
262
- else {
263
- z.farsi = true;
264
- if (FarsiType.ShowChangeLangButton == 1) {
265
- z.bottelm.value = "FA";
266
- z.bottelm.title = 'Change lang to english';
267
- }
268
- if (FarsiType.ChangeDir == 1) {
269
- z.style.textAlign = "right";
270
- z.style.direction = "rtl";
271
- }
272
- }
273
- z.focus();
274
- }
275
- }
276
- }
277
-
278
- Convert = function(e) {
279
-
280
- if (FarsiType.Type) {
281
-
282
- if (e == null) e = window.event;
283
- eElement = (e.srcElement) ? e.srcElement : e.originalTarget;
284
-
285
- var key = e.keyCode ? e.keyCode : e.charCode;
286
- if (navigator.userAgent.toLowerCase().indexOf('opera')>-1) key = e.which;
287
-
288
- if ( (e.charCode != null) && (e.charCode != key) ) return;
289
- if (e.ctrlKey || e.altKey || e.metaKey || key == 13 || key == 27 || key == 8) return;
290
-
291
- //check windows lang
292
- if (key>128){
293
- if (FarsiType.KeyBoardError == 0) {
294
- FarsiType.Disable();
295
- }
296
- else {
297
- alert("Please change your windows language to English");
298
- return false;
299
- }
300
- }
301
-
302
- // if Farsi
303
- if (z.farsi && key > 31 && key < 128) {
304
-
305
- //check CpasLock
306
- if ( (key >= 65 && key <= 90) && !e.shiftKey ) {
307
- alert("Caps Lock is On. To prevent entering farsi incorrectly, you should press Caps Lock to turn it off.");
308
- return false;
309
- }
310
- else if ( (key >= 97 && key <= 122 ) && e.shiftKey ) {
311
- alert("Caps Lock is On. To prevent entering farsi incorrectly, you should press Caps Lock to turn it off.");
312
- return false;
313
- }
314
-
315
- // Shift-space -> ZWNJ
316
- if (key == 32 && e.shiftKey)
317
- key = 8204;
318
- else
319
- key = FarsiType.farsiKey[key-32];
320
-
321
- // to farsi
322
- try {
323
- // IE
324
- e.keyCode = key
325
- }
326
- catch(error) {
327
- try {
328
- // Gecko before
329
- e.initKeyEvent("keypress", true, true, document.defaultView, false, false, true, false, 0, key, eElement);
330
- }
331
- catch(error) {
332
- try {
333
- // Gecko & Opera now
334
- var nScrollTop = eElement.scrollTop;
335
- var nScrollLeft = eElement.scrollLeft;
336
- var nScrollWidth = eElement.scrollWidth;
337
-
338
- replaceString = String.fromCharCode(key);
339
-
340
- var selectionStart = eElement.selectionStart;
341
- var selectionEnd = eElement.selectionEnd;
342
- eElement.value = eElement.value.substring(0, selectionStart) + replaceString + eElement.value.substring(selectionEnd);
343
- setSelectionRange(eElement, selectionStart + replaceString.length, selectionStart + replaceString.length);
344
-
345
- var nW = eElement.scrollWidth - nScrollWidth;
346
- if (eElement.scrollTop == 0) { eElement.scrollTop = nScrollTop }
347
-
348
- e.preventDefault()
349
- }
350
- catch(error) {
351
- // else no farsi type!
352
- alert('Sorry! no FarsiType support')
353
- FarsiType.Disable();
354
- var Dis = document.getElementById('disableFarsiType')
355
- if (Dis != null) {
356
- Dis.disabled = true;
357
- }
358
- return false;
359
- }
360
- }
361
- }
362
- }
363
- }
364
- return true;
365
- }
366
-
367
- if (FarsiType.ShowChangeLangButton == 1) { z.bottelm.onmouseup = ChangeLang; }
368
- if (FarsiType.ChangeDir == 2) { z.Direlm.onmouseup = ChangeDirection; }
369
- z.onkeydown = ChangeLang;
370
- z.onkeypress = Convert;
371
- }
372
-
373
- if (window.attachEvent) {
374
- window.attachEvent('onload', FarsiType.init)
375
- }
376
- else if (window.addEventListener) {
377
- window.addEventListener('load', FarsiType.init, false)
378
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/tables-date.php DELETED
@@ -1,143 +0,0 @@
1
- <?php
2
-
3
- /* Originally written by Reza Moallemi , www.moallemi.ir */
4
-
5
-
6
- /*
7
- * Hook into default wordpress date column for posts date
8
- */
9
- add_filter('post_date_column_time', 'wp_fa_date_columns');
10
- function wp_fa_date_columns($time) {
11
- //$arrtime = split('/', $time);
12
- $arrtime = explode('/', $time);
13
- if(count($arrtime) == 1)
14
- return farsi_num($time);
15
- $gmt = mktime(0,0,0,$arrtime[1],$arrtime[2],$arrtime[0]);
16
- $time = jdate('d M Y',$gmt);
17
- return $time;
18
- }
19
-
20
-
21
- /*
22
- * Hook into default wordpress filter in order to filter post by jalali date
23
- */
24
- add_action('restrict_manage_posts', 'wp_fa_restrict_manage_posts');
25
- function wp_fa_restrict_manage_posts() {
26
- global $post_type, $wpdb, $wp_locale;
27
-
28
- $months = $wpdb->get_results( $wpdb->prepare( "
29
- SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month, DAY( post_date ) as day
30
- FROM $wpdb->posts
31
- WHERE post_type = %s AND post_status <> 'auto-draft'
32
- ORDER BY post_date DESC
33
- ", $post_type ) );
34
- $month_count = count( $months );
35
- if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
36
- return;
37
- $m = isset( $_GET['mfa'] ) ? (int) $_GET['mfa'] : 0;
38
- ?>
39
- <select name='mfa'>
40
- <option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
41
- <?php
42
- foreach ( $months as $arc_row ) {
43
- if ( 0 == $arc_row->year )
44
- continue;
45
- $month = zeroise( $arc_row->month, 2 );
46
- $year = $arc_row->year;
47
- $gmt = mktime(0 ,0 , 0, $month, $arc_row->day, $year);
48
- $dateshow = jdate('M Y',$gmt);
49
- $date = english_num(jdate('Ym',$gmt));
50
- if($predate != $date)
51
- printf( "<option %s value='?m=%s'>%s</option>\n",
52
- selected( $m, $year . $month, false ),
53
- esc_attr( $date ),
54
- $dateshow
55
- );
56
- $predate = $date;
57
- }
58
- ?>
59
- </select>
60
- <?php
61
- }
62
-
63
- add_action('load-edit.php', 'wp_fa_admin_init');
64
- add_action('admin_init', 'wp_fa_admin_init');
65
-
66
- function wp_fa_admin_init() {
67
- add_filter('posts_where', 'wp_fa_posts_where');
68
-
69
- /*
70
- * Hook into media date column to support jalali date for WP 3.1 and later only
71
- */
72
- add_filter('manage_media_columns', 'wp_fa_new_media_columns');
73
- add_action('manage_media_custom_column', 'wp_fa_manage_media_columns', 10, 2);
74
- add_filter('manage_upload_sortable_columns', 'wp_fa_media_date_register_sortable');
75
- add_filter('request', 'wp_fa_date_fa_column_orderby');
76
- }
77
-
78
- function wp_fa_date_fa_column_orderby( $vars ) {
79
- if (isset($vars['orderby']) && 'date_fa' == $vars['orderby']) {
80
- $vars = array_merge( $vars, array(
81
- 'orderby' => 'date'
82
- ) );
83
- }
84
- return $vars;
85
- }
86
-
87
- function wp_fa_media_date_register_sortable( $columns ) {
88
- $columns['date_fa'] = 'date_fa';
89
- return $columns;
90
- }
91
-
92
- function wp_fa_new_media_columns($default_columns) {
93
- unset($default_columns['date']);
94
- $default_columns['date_fa'] = _x('Date', 'column name');
95
- return $default_columns;
96
- }
97
-
98
- function wp_fa_manage_media_columns($column_name, $id) {
99
- if($column_name == 'date_fa') {
100
- global $post, $id;
101
- if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
102
- $t_time = $h_time = __( 'Unpublished' );
103
- } else {
104
- $t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
105
- $m_time = $post->post_date;
106
- $time = get_post_time( 'G', true, $post, false );
107
- if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
108
- if ( $t_diff < 0 )
109
- $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
110
- else
111
- $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
112
- } else {
113
- $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
114
- }
115
- }
116
- echo wp_fa_date_columns($h_time);
117
- }
118
- }
119
-
120
- function wp_fa_posts_where($where) {
121
- global $wpdb, $wp_query;
122
- if( isset($_GET['mfa']) and $_GET['mfa'] != '0' )
123
- {
124
- $wp_query->query_vars['m'] = substr($_GET['mfa'], strpos($_GET['mfa'], '=') + 1);
125
- $where = mps_jalali_query($where);
126
- }
127
- return $where;
128
- }
129
-
130
- /*
131
- * Use this hack to hide the default wordpress month filter in edit.php (List off all posts)
132
- */
133
- add_action('admin_footer', 'wp_fa_admin_footer', 9999);
134
- function wp_fa_admin_footer() {
135
- ?>
136
- <script type="text/javascript" language="javascript">
137
- jQuery(document).ready(function() {
138
- jQuery('select[name="m"]').hide()
139
- });
140
- </script>
141
- <?php
142
- }
143
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/widgets-core.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
- function widget_mps_calendar_init() {
3
- if ( !function_exists('mps_calendar') )
4
- return;
5
-
6
- if ( !function_exists('wp_register_sidebar_widget') )
7
- return;
8
-
9
- function mps_calendar_widget($args) {
10
- extract($args);
11
- $options = get_option('mps_calendar_widget');
12
- $title = $options['title'];
13
- echo $before_widget;
14
- echo $before_title . $title . $after_title;
15
- mps_calendar();
16
- echo $after_widget;
17
- }
18
-
19
- function widget_mps_calendar_control() {
20
-
21
- $options = get_option('mps_calendar_widget');
22
- if ( !is_array($options) )
23
- $options = array('title'=>'');
24
- if ( $_POST['mps_calendar_submit'] ) {
25
- $options['title'] = strip_tags(stripslashes($_POST['mps_calendar_title']));
26
- update_option('mps_calendar_widget', $options);
27
- }
28
- $title = htmlspecialchars($options['title'], ENT_QUOTES);
29
- ?>
30
- <p style="text-align:right; direction:rtl"><label for="mps_calendar_title">عنوان: <input style="width: 200px;" id="mps_calendar_title" name="mps_calendar_title" type="text" value="<?php echo $title; ?>" /></label></p>
31
- <input type="hidden" id="mps_calendar_submit" name="mps_calendar_submit" value="1" />
32
- <?php
33
- }
34
-
35
- wp_register_sidebar_widget(1000, 'Jalali Calendar','mps_calendar_widget');
36
- wp_register_widget_control(1000, 'Jalali Calendar', 'widget_mps_calendar_control', 250, 100);
37
- }
38
-
39
- function widget_jarchive_init() {
40
- if ( !function_exists('wp_get_jarchives') )
41
- return;
42
-
43
- if ( !function_exists('wp_register_sidebar_widget') )
44
- return;
45
-
46
- function jarchive_widget($args) {
47
- extract($args);
48
- $options = get_option('jarchive_widget');
49
- $title = $options['title'];
50
- if (!isset($options['type'])) {
51
- $type="monthly";
52
- } else {
53
- $type = $options['type'];
54
- }
55
- $show_post_count = ($options['show_post_count'] == '1') ? "1" : "0"; // More Safer Way
56
- $dropdown = ($options['dropdown'] == '1') ? "1" : "0";
57
- echo $before_widget;
58
- echo $before_title . $title . $after_title;
59
- if ($dropdown) {
60
- echo "<select name=\"jarchive-dropdown\" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=\"\">".attribute_escape($title)."</option>";
61
- wp_get_jarchives("type=$type&format=option&show_post_count=$show_post_count");
62
- echo "</select>";
63
- } else {
64
- echo '<ul>';
65
- wp_get_jarchives("type=$type"."&show_post_count=".$show_post_count);
66
- echo '</ul>';
67
- }
68
-
69
- echo $after_widget;
70
- }
71
-
72
- function widget_jarchive_control() {
73
-
74
- $options = get_option('jarchive_widget');
75
- if ( !is_array($options) )
76
- $options = array('title'=>'');
77
- if ( $_POST['jarchive_submit'] ) {
78
- $options['title'] = strip_tags(stripslashes($_POST['jarchive_title']));
79
- $options['type'] = strip_tags(stripslashes($_POST['jarchive_type']));
80
- $options['show_post_count'] = strip_tags(stripslashes($_POST['jarchive_show_post_count']));
81
- $options['dropdown'] = isset($_POST['jarchives_dropdown']);
82
- update_option('jarchive_widget', $options);
83
- }
84
- $title = htmlspecialchars($options['title'], ENT_QUOTES);
85
- $type = htmlspecialchars($options['type'], ENT_QUOTES);
86
-
87
- if (empty($options['type']))
88
- $options['type'] = 'monthly';
89
- ?>
90
- <div dir="rtl" align="justify">
91
- <p style="text-align:right"><label for="jarchive_title">عنوان: <input style="width: 200px;" id="jarchive_title" name="jarchive_title" type="text" value="<?php echo $title; ?>" /></label></p>
92
- <input name="jarchive_type" type="radio" value="yearly" id="yearly" <?php echo $options['type']=='yearly' ? 'checked="checked"':'' ?> /> <label for="yearly">سالیانه</label><br />
93
- <input name="jarchive_type" type="radio" value="monthly" id="monthly" <?php echo $options['type']=='monthly' ? 'checked="checked"':'' ?> /> <label for="monthly">ماهیانه</label><br />
94
- <input name="jarchive_type" type="radio" value="daily" id="daily" <?php echo $options['type']=='daily' ? 'checked="checked"':'' ?> /> <label for="daily">روزانه</label><br />
95
- <input name="jarchive_type" type="radio" value="postbypost" id="postbypost" <?php echo $options['type']=='postbypost' ? 'checked="checked"':'' ?> /> <label for="postbypost">نوشته به نوشته</label><br /><br />
96
- <input name="jarchive_show_post_count" type="checkbox" value="1" id="show_post_count" <?php echo $options['show_post_count']=='1' ? 'checked="checked"':'' ?> /> <label for="show_post_count">نمایش تعداد نوشته ها (فقط برای بایگانی ماهیانه و سالیانه)</label><br />
97
- <input name="jarchives_dropdown" type="checkbox" value="1" id="dropdown" <?php echo $options['dropdown']=='1' ? 'checked="checked"':'' ?> /> <label for="dropdown">نمایش به صورت لیست بازشو (فقط برای بایگانی ماهیانه و سالیانه)</label>
98
- <input type="hidden" id="jarchive_submit" name="jarchive_submit" value="1" />
99
- </div>
100
- <?php
101
- }
102
-
103
- wp_register_sidebar_widget(1001, 'Jalali Archive','jarchive_widget');
104
- if(get_bloginfo('version') < 2.5)
105
- wp_register_widget_control(1001, 'Jalali Archive', 'widget_jarchive_control', 300, 150);
106
- else
107
- wp_register_widget_control(1001,'Jalali Archive', 'widget_jarchive_control');
108
- }
109
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/yk-core.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- function mps_yk_solve_callback($matches) {
3
- $arabic = array("ي", "ك", "٤", "٥", "٦");
4
- $persian = array("ی", "ک", "۴", "۵", "۶");
5
-
6
- $clause = $matches[1];
7
- $phrase = $matches[2];
8
-
9
- $phrase_persian = str_replace($arabic, $persian, $phrase); //Pure Persian
10
- $phrase_arabic = str_replace($persian, $arabic, $phrase); //Pure Arabic
11
-
12
- $clause_persian = str_replace($phrase, $phrase_persian, $clause);
13
- $clause_arabic = str_replace($phrase, $phrase_arabic, $clause);
14
-
15
- return "( ".$clause_persian." OR ".$clause_arabic." )";
16
- }
17
-
18
- function mps_yk_solve_search($query) {
19
- $pattern = "/(\([^\)\(]* LIKE '([^']*)'\))/";
20
-
21
- if (strstr($query,"LIKE")) { //Is Search?
22
- if (strstr($query,"ی") || strstr($query,"ک") || strstr($query,"ي") || strstr($query,"ك") || strstr($query,"٤") || strstr($query,"٥") || strstr($query,"٦") || strstr($query,"۴") || strstr($query,"۵") || strstr($query,"۶")) {
23
- $query = preg_replace_callback($pattern, 'mps_yk_solve_callback', $query);
24
- }
25
-
26
- }
27
- //echo "<!--".$query."-->";
28
- return $query;
29
- }
30
- function mps_yk_solve_persian($content) {
31
- $arabic = array("ي", "ك", "٤", "٥", "٦");
32
- $persian = array("ی", "ک", "۴", "۵", "۶");
33
- $content = str_replace($arabic, $persian, $content);
34
- return $content;
35
- }
36
-
37
- /*
38
- // for debug purpose only.
39
- function mps_yk_solve_persian_debug($content) {
40
- print_r($content);
41
- }
42
- */
43
-
44
- function shortcode_arabic($atts, $text) {
45
- $arabic = array("ي", "ك", "٤", "٥", "٦");
46
- $persian = array("ی", "ک", "۴", "۵", "۶");
47
- return str_replace($persian, $arabic, $text);
48
- }
49
-
50
- add_shortcode('arabic','shortcode_arabic');
51
-
52
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.wp-persian.com/donate
4
  Tags: Calendar Conversion, Persian, Farsi, Afghan, Tajik, Jalali, Date, Calendar, i18n, l10n
5
  Tested up to: 4.0.0
6
  Requires at least: 3.9
7
- Stable tag: 5.0.0-RC
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
4
  Tags: Calendar Conversion, Persian, Farsi, Afghan, Tajik, Jalali, Date, Calendar, i18n, l10n
5
  Tested up to: 4.0.0
6
  Requires at least: 3.9
7
+ Stable tag: 5.0.0-RC2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
wp-jalali.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: wp-jalali
4
  Plugin URI: http://wp-persian.com/wp-jalali
5
  Description: Full Jalali calendar support for Wordpress and localization improvements for Persian/Afghan/Tajik users.
6
- Version: 5.0.0-RC
7
  Author: Zakrot Web Solutions (in collaboration with WP-Persian team)
8
  Author URI: http://zakrot.com/
9
  Text Domain: ztjalali
3
  Plugin Name: wp-jalali
4
  Plugin URI: http://wp-persian.com/wp-jalali
5
  Description: Full Jalali calendar support for Wordpress and localization improvements for Persian/Afghan/Tajik users.
6
+ Version: 5.0.0-RC2
7
  Author: Zakrot Web Solutions (in collaboration with WP-Persian team)
8
  Author URI: http://zakrot.com/
9
  Text Domain: ztjalali