From aefbf93541a97d877a0dc189239045de4cc22aca Mon Sep 17 00:00:00 2001 From: Fabrixxm Date: Wed, 20 Jan 2016 11:39:31 +0100 Subject: [PATCH 001/498] Bump version --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index af40027b0..c21a47f4c 100644 --- a/boot.php +++ b/boot.php @@ -17,7 +17,7 @@ require_once('include/dbstructure.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Lily of the valley'); -define ( 'FRIENDICA_VERSION', '3.4.3' ); +define ( 'FRIENDICA_VERSION', '3.4.3-2' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DB_UPDATE_VERSION', 1191 ); define ( 'EOL', "
\r\n" ); From 2ca9d011fe2118293a53b0fda068b3ec27d34c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Sat, 30 Jan 2016 23:21:03 +0100 Subject: [PATCH 002/498] add simple option for HTTPS in .htaccess people have it easier to just uncomment 2 lines if they want such an important feature --- .htaccess | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.htaccess b/.htaccess index 1b63f9ad6..8c8a8861c 100644 --- a/.htaccess +++ b/.htaccess @@ -30,5 +30,9 @@ Deny from all RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?pagename=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA] + # If you want to restrict access to your Friendica site to HTTPS only, + # uncommment the following lines + RewriteCond %{HTTPS} !=on + RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] From e80d5a7f23143d10ff6043a00fc06f36e239e9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Sat, 30 Jan 2016 23:22:40 +0100 Subject: [PATCH 003/498] additional blank line --- .htaccess | 1 + 1 file changed, 1 insertion(+) diff --git a/.htaccess b/.htaccess index 8c8a8861c..a2c3c8914 100644 --- a/.htaccess +++ b/.htaccess @@ -34,5 +34,6 @@ Deny from all # uncommment the following lines RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] + From 545e4f645e274af0e29a7e70159f0750b7ef8b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Sun, 31 Jan 2016 16:20:06 +0100 Subject: [PATCH 004/498] really uncomment the lines. --- .htaccess | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.htaccess b/.htaccess index a2c3c8914..d2aaa4e13 100644 --- a/.htaccess +++ b/.htaccess @@ -32,8 +32,8 @@ Deny from all # If you want to restrict access to your Friendica site to HTTPS only, # uncommment the following lines - RewriteCond %{HTTPS} !=on - RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] + #RewriteCond %{HTTPS} !=on + #RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] From aa548be3b95f1a4292f51e0758e80d759a9b14d1 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:33:54 +0100 Subject: [PATCH 005/498] Introduced is_filled_array() + added some missing array initialization Signed-off-by: Roland Haeder --- boot.php | 4 ++++ mod/message.php | 10 ++++++---- mod/ping.php | 25 +++++++++++++------------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/boot.php b/boot.php index d82669f23..bf98cf5c3 100644 --- a/boot.php +++ b/boot.php @@ -2138,3 +2138,7 @@ function argv($x) { return ''; } + +function is_filled_array ($array) { + return (is_array($array) && count($array) > 0); +} diff --git a/mod/message.php b/mod/message.php index 734bf3471..6e176f712 100644 --- a/mod/message.php +++ b/mod/message.php @@ -8,7 +8,7 @@ function message_init(&$a) { $tabs = ''; if ($a->argc >1 && is_numeric($a->argv[1])) { - $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); + $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); } $new = array( @@ -360,11 +360,13 @@ function message_content(&$a) { dbesc($myprofile) ); - if(count($r)) $a->set_pager_total($r[0]['total']); + if (is_filled_array($r)) { + $a->set_pager_total($r[0]['total']); + } $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! count($r)) { + if(! is_filled_array($r)) { info( t('No messages.') . EOL); return $o; } @@ -542,7 +544,7 @@ function get_messages($user, $lstart, $lend) { ); } -function render_messages($msg, $t) { +function render_messages(array $msg, $t) { $a = get_app(); diff --git a/mod/ping.php b/mod/ping.php index 2eb94576b..8deab28ed 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -32,6 +32,8 @@ function ping_init(&$a) { $dislikes = array(); $friends = array(); $posts = array(); + $regs = array(); + $mails = array(); $home = 0; $network = 0; @@ -49,7 +51,7 @@ function ping_init(&$a) { intval(local_user()), intval(local_user()) ); - if(count($r)) { + if(is_filled_array($r)) { $arr = array('items' => $r); call_hooks('network_ping', $arr); @@ -116,8 +118,6 @@ function ping_init(&$a) { $intro = count($intros1) + count($intros2); $intros = $intros1+$intros2; - - $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ; $mails = q("SELECT * FROM `mail` WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", @@ -150,7 +150,7 @@ function ping_init(&$a) { dbesc(datetime_convert('UTC','UTC','now')) ); - if($ev && count($ev)) { + if(is_filled_array($ev)) { $all_events = intval($ev[0]['total']); if($all_events) { @@ -219,7 +219,7 @@ function ping_init(&$a) { $home\r\n"; if ($register!=0) echo "$register"; - if (count($groups_unseen)) { + if ( is_filled_array($groups_unseen) ) { echo ''; foreach ($groups_unseen as $it) if ($it['count'] > 0) @@ -228,7 +228,7 @@ function ping_init(&$a) { echo ""; } - if (count($forums_unseen)) { + if ( is_filled_array($forums_unseen) ) { echo ''; foreach ($forums_unseen as $it) if ($it['count'] > 0) @@ -245,8 +245,8 @@ function ping_init(&$a) { $birthdays_today\r\n"; - if(count($notifs) && (! $sysnotify)) { - foreach($notifs as $zz) { + if (is_filled_array($notifs) && (! $sysnotify)) { + foreach ($notifs as $zz) { if($zz['seen'] == 0) $sysnotify ++; } @@ -255,7 +255,7 @@ function ping_init(&$a) { echo ' '; // merge all notification types in one array - if ($intro>0){ + if ( is_filled_array($intros) ) { foreach ($intros as $i) { $n = array( 'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'], @@ -270,7 +270,7 @@ function ping_init(&$a) { } } - if ($mail>0){ + if ( is_filled_array($mails) ) { foreach ($mails as $i) { $n = array( 'href' => $a->get_baseurl().'/message/'.$i['id'], @@ -285,7 +285,7 @@ function ping_init(&$a) { } } - if ($register>0){ + if ( is_filled_array($regs) ) { foreach ($regs as $i) { $n = array( 'href' => $a->get_baseurl().'/admin/users/', @@ -299,6 +299,7 @@ function ping_init(&$a) { $notifs[] = $n; } } + // sort notifications by $[]['date'] $sort_function = function($a, $b) { $adate = date($a['date']); @@ -310,7 +311,7 @@ function ping_init(&$a) { }; usort($notifs, $sort_function); - if(count($notifs)) { + if( is_filled_array($notifs) ) { foreach($notifs as $n) { echo xmlize($n); } From 78e6569b27260b6cf156c372f22e90f6f122dd67 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:38:02 +0100 Subject: [PATCH 006/498] Also use is_filled_array() here, too. if $contacts is FALSE count() issues are E_WARNING Signed-off-by: Roland Haeder --- include/ForumManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ForumManager.php b/include/ForumManager.php index 6fede0204..bbf881c9d 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -86,7 +86,7 @@ class ForumManager { $total = count($contacts); $visible_forums = 10; - if(count($contacts)) { + if(is_filled_array($contacts)) { $id = 0; From f7a02601290ff37a5081af30c3571ee0df4fa79a Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:27:38 +0100 Subject: [PATCH 007/498] No need to set $a->theme_info = array() everywhere if you can define it in App itself. Signed-off-by: Roland Haeder --- boot.php | 5 +++-- view/theme/decaf-mobile/theme.php | 1 - view/theme/duepuntozero/theme.php | 1 - view/theme/facepark/theme.php | 1 - view/theme/frost-mobile/theme.php | 1 - view/theme/frost/theme.php | 1 - view/theme/quattro/theme.php | 2 -- view/theme/smoothly/theme.php | 1 - view/theme/vier/theme.php | 2 -- 9 files changed, 3 insertions(+), 12 deletions(-) diff --git a/boot.php b/boot.php index d82669f23..4b2e83f18 100644 --- a/boot.php +++ b/boot.php @@ -465,11 +465,12 @@ class App { public $plugins; public $apps = array(); public $identities; - public $is_mobile; - public $is_tablet; + public $is_mobile = false; + public $is_tablet = false; public $is_friendica_app; public $performance = array(); public $callstack = array(); + public $theme_info = array(); public $nav_sel; diff --git a/view/theme/decaf-mobile/theme.php b/view/theme/decaf-mobile/theme.php index 1a32fb724..9b1c1daa6 100644 --- a/view/theme/decaf-mobile/theme.php +++ b/view/theme/decaf-mobile/theme.php @@ -10,7 +10,6 @@ */ function decaf_mobile_init(&$a) { - $a->theme_info = array(); $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; $a->videoheight = 200; diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index ba3f25d3e..50d57f91e 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -2,7 +2,6 @@ function duepuntozero_init(&$a) { -$a->theme_info = array(); set_template_engine($a, 'smarty3'); $colorset = get_pconfig( local_user(), 'duepuntozero','colorset'); diff --git a/view/theme/facepark/theme.php b/view/theme/facepark/theme.php index e7203c664..e6255f118 100644 --- a/view/theme/facepark/theme.php +++ b/view/theme/facepark/theme.php @@ -1,7 +1,6 @@ theme_info = array(); set_template_engine($a, 'smarty3'); $a->page['htmlhead'] .= <<< EOT diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index beec92493..29a990f7b 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -10,7 +10,6 @@ */ function frost_mobile_init(&$a) { - $a->theme_info = array(); $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; $a->videoheight = 200; diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 868a840de..1093a0472 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -10,7 +10,6 @@ */ function frost_init(&$a) { - $a->theme_info = array(); $a->videowidth = 400; $a->videoheight = 330; $a->theme_thread_allow = false; diff --git a/view/theme/quattro/theme.php b/view/theme/quattro/theme.php index a1cd29ee7..0b67c6b49 100644 --- a/view/theme/quattro/theme.php +++ b/view/theme/quattro/theme.php @@ -8,8 +8,6 @@ */ function quattro_init(&$a) { - $a->theme_info = array(); - $a->page['htmlhead'] .= ''; $a->page['htmlhead'] .= '';; } diff --git a/view/theme/smoothly/theme.php b/view/theme/smoothly/theme.php index d3ebbc1d1..0dae3a6e4 100644 --- a/view/theme/smoothly/theme.php +++ b/view/theme/smoothly/theme.php @@ -11,7 +11,6 @@ */ function smoothly_init(&$a) { - $a->theme_info = array(); set_template_engine($a, 'smarty3'); $cssFile = null; diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 7f6ead079..925ac76a1 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -19,8 +19,6 @@ function vier_init(&$a) { set_template_engine($a, 'smarty3'); - $a->theme_info = array(); - if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) { vier_community_info(); From c54e38fddb9e0132124094bd7848157af943f1ea Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:32:19 +0100 Subject: [PATCH 008/498] Prevent some E_NOTICE in boot.php Signed-off-by: Roland Haeder --- boot.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/boot.php b/boot.php index 4b2e83f18..0a2f5c50c 100644 --- a/boot.php +++ b/boot.php @@ -1047,11 +1047,21 @@ class App { function save_timestamp($stamp, $value) { $duration = (float)(microtime(true)-$stamp); + if (!isset($this->performance[$value])) { + // Prevent ugly E_NOTICE + $this->performance[$value] = 0; + } + $this->performance[$value] += (float)$duration; $this->performance["marktime"] += (float)$duration; $callstack = $this->callstack(); + if (!isset($this->callstack[$value][$callstack])) { + // Prevent ugly E_NOTICE + $this->callstack[$value][$callstack] = 0; + } + $this->callstack[$value][$callstack] += (float)$duration; } From 2c37eab808bb18c929a861b9cad54df865a95322 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:33:54 +0100 Subject: [PATCH 009/498] Introduced is_filled_array() + added some missing array initialization Signed-off-by: Roland Haeder --- boot.php | 4 ++++ mod/message.php | 10 ++++++---- mod/ping.php | 25 +++++++++++++------------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/boot.php b/boot.php index 0a2f5c50c..a1f29398f 100644 --- a/boot.php +++ b/boot.php @@ -2149,3 +2149,7 @@ function argv($x) { return ''; } + +function is_filled_array ($array) { + return (is_array($array) && count($array) > 0); +} diff --git a/mod/message.php b/mod/message.php index 734bf3471..6e176f712 100644 --- a/mod/message.php +++ b/mod/message.php @@ -8,7 +8,7 @@ function message_init(&$a) { $tabs = ''; if ($a->argc >1 && is_numeric($a->argv[1])) { - $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); + $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); } $new = array( @@ -360,11 +360,13 @@ function message_content(&$a) { dbesc($myprofile) ); - if(count($r)) $a->set_pager_total($r[0]['total']); + if (is_filled_array($r)) { + $a->set_pager_total($r[0]['total']); + } $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! count($r)) { + if(! is_filled_array($r)) { info( t('No messages.') . EOL); return $o; } @@ -542,7 +544,7 @@ function get_messages($user, $lstart, $lend) { ); } -function render_messages($msg, $t) { +function render_messages(array $msg, $t) { $a = get_app(); diff --git a/mod/ping.php b/mod/ping.php index 2eb94576b..8deab28ed 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -32,6 +32,8 @@ function ping_init(&$a) { $dislikes = array(); $friends = array(); $posts = array(); + $regs = array(); + $mails = array(); $home = 0; $network = 0; @@ -49,7 +51,7 @@ function ping_init(&$a) { intval(local_user()), intval(local_user()) ); - if(count($r)) { + if(is_filled_array($r)) { $arr = array('items' => $r); call_hooks('network_ping', $arr); @@ -116,8 +118,6 @@ function ping_init(&$a) { $intro = count($intros1) + count($intros2); $intros = $intros1+$intros2; - - $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ; $mails = q("SELECT * FROM `mail` WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", @@ -150,7 +150,7 @@ function ping_init(&$a) { dbesc(datetime_convert('UTC','UTC','now')) ); - if($ev && count($ev)) { + if(is_filled_array($ev)) { $all_events = intval($ev[0]['total']); if($all_events) { @@ -219,7 +219,7 @@ function ping_init(&$a) { $home\r\n"; if ($register!=0) echo "$register"; - if (count($groups_unseen)) { + if ( is_filled_array($groups_unseen) ) { echo ''; foreach ($groups_unseen as $it) if ($it['count'] > 0) @@ -228,7 +228,7 @@ function ping_init(&$a) { echo ""; } - if (count($forums_unseen)) { + if ( is_filled_array($forums_unseen) ) { echo ''; foreach ($forums_unseen as $it) if ($it['count'] > 0) @@ -245,8 +245,8 @@ function ping_init(&$a) { $birthdays_today\r\n"; - if(count($notifs) && (! $sysnotify)) { - foreach($notifs as $zz) { + if (is_filled_array($notifs) && (! $sysnotify)) { + foreach ($notifs as $zz) { if($zz['seen'] == 0) $sysnotify ++; } @@ -255,7 +255,7 @@ function ping_init(&$a) { echo ' '; // merge all notification types in one array - if ($intro>0){ + if ( is_filled_array($intros) ) { foreach ($intros as $i) { $n = array( 'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'], @@ -270,7 +270,7 @@ function ping_init(&$a) { } } - if ($mail>0){ + if ( is_filled_array($mails) ) { foreach ($mails as $i) { $n = array( 'href' => $a->get_baseurl().'/message/'.$i['id'], @@ -285,7 +285,7 @@ function ping_init(&$a) { } } - if ($register>0){ + if ( is_filled_array($regs) ) { foreach ($regs as $i) { $n = array( 'href' => $a->get_baseurl().'/admin/users/', @@ -299,6 +299,7 @@ function ping_init(&$a) { $notifs[] = $n; } } + // sort notifications by $[]['date'] $sort_function = function($a, $b) { $adate = date($a['date']); @@ -310,7 +311,7 @@ function ping_init(&$a) { }; usort($notifs, $sort_function); - if(count($notifs)) { + if( is_filled_array($notifs) ) { foreach($notifs as $n) { echo xmlize($n); } From 962536330a145cacddf4794eb4ba16ea20402daf Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:36:23 +0100 Subject: [PATCH 010/498] Prevent some E_NOTICE in identity.php Signed-off-by: Roland Haeder --- include/identity.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/identity.php b/include/identity.php index aba69bae4..888a09ee6 100644 --- a/include/identity.php +++ b/include/identity.php @@ -237,6 +237,7 @@ function profile_sidebar($profile, $block = 0) { if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect'])) $connect = false; + $remoteconnect = NULL; if (isset($profile['remoteconnect'])) $remoteconnect = $profile['remoteconnect']; @@ -292,9 +293,9 @@ function profile_sidebar($profile, $block = 0) { // check if profile is a forum if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP) - || (intval($profile['forum'])) - || (intval($profile['prv'])) - || (intval($profile['community']))) + || (isset($profile['forum']) && intval($profile['forum'])) + || (isset($profile['prv']) && intval($profile['prv'])) + || (isset($profile['community']) && intval($profile['community']))) $account_type = t('Forum'); else $account_type = ""; From f53af9732c18fb81f7c3eb95b3e3d2356f840d87 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:38:02 +0100 Subject: [PATCH 011/498] Also use is_filled_array() here, too. if $contacts is FALSE count() issues are E_WARNING Signed-off-by: Roland Haeder --- include/ForumManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ForumManager.php b/include/ForumManager.php index 6fede0204..bbf881c9d 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -86,7 +86,7 @@ class ForumManager { $total = count($contacts); $visible_forums = 10; - if(count($contacts)) { + if(is_filled_array($contacts)) { $id = 0; From 438026aafdad8be1d449369055a26cd8d9e862df Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:42:55 +0100 Subject: [PATCH 012/498] More logging in case of errors + logged network type + added TODO (for ugly E_NOTICE). Signed-off-by: Roland Haeder --- mod/dfrn_request.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 2741ad59b..82886a6ef 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -42,8 +42,10 @@ function dfrn_request_init(&$a) { if(! function_exists('dfrn_request_post')) { function dfrn_request_post(&$a) { - if(($a->argc != 2) || (! count($a->profile))) + if(($a->argc != 2) || (! count($a->profile))) { + logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); return; + } if(x($_POST, 'cancel')) { @@ -461,7 +463,7 @@ function dfrn_request_post(&$a) { $network = NETWORK_DFRN; } - logger('dfrn_request: url: ' . $url); + logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG); if($network === NETWORK_DFRN) { $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", @@ -825,6 +827,7 @@ function dfrn_request_content(&$a) { else $tpl = get_markup_template('auto_request.tpl'); + // TODO This .= triggers an E_NOTICE, really needed? $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); // see if we are allowed to have NETWORK_MAIL2 contacts @@ -850,6 +853,7 @@ function dfrn_request_content(&$a) { get_server() ); + // TODO This .= triggers an E_NOTICE, really needed? $o .= replace_macros($tpl,array( '$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), From 262618201651aac7c971dfd526edcc35fa9c784a Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:49:07 +0100 Subject: [PATCH 013/498] Don't miss to add exit() after header('Location: bla') as header() does *NOT* exit the script quickly enough. Always use an explicit exit() or you get real trouble. Signed-off-by: Roland Haeder --- index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index e364389b2..625c2d82d 100644 --- a/index.php +++ b/index.php @@ -72,7 +72,8 @@ if(!$install) { (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND (substr($a->get_baseurl(), 0, 8) == "https://")) { header("HTTP/1.1 302 Moved Temporarily"); - header("location: ".$a->get_baseurl()."/".$a->query_string); + header("Location: ".$a->get_baseurl()."/".$a->query_string); + exit(); } require_once("include/session.php"); From 7e485f25ab0fee428f159d91f2b958173d02f26c Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:49:56 +0100 Subject: [PATCH 014/498]
and or are not self-closing tags. Signed-off-by: Roland Haeder --- view/templates/dfrn_request.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/templates/dfrn_request.tpl b/view/templates/dfrn_request.tpl index 3b96d3eef..5225bd60b 100644 --- a/view/templates/dfrn_request.tpl +++ b/view/templates/dfrn_request.tpl @@ -18,13 +18,13 @@ {{/if}} {{if $request}} - + {{else}} - + {{/if}} {{if $photo}} - + {{/if}} {{if $url}}
{{$url_label}}
{{$url}}
{{/if}} From 858438daec44cad20153b4160f7d1c9ddeac7484 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 16:00:55 +0100 Subject: [PATCH 015/498] More calls replaced with is_filled_array(), ticket #2390 Signed-off-by: Roland Haeder --- boot.php | 10 +++++----- index.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/boot.php b/boot.php index bf98cf5c3..b049099ea 100644 --- a/boot.php +++ b/boot.php @@ -926,7 +926,7 @@ class App { } else { $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'", $common_filename); - if(! count($r)){ + if(! is_filled_array($r)){ $this->cached_profile_image[$avatar_image] = $avatar_image; } else { $this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']); @@ -1352,7 +1352,7 @@ function run_update_function($x) { function check_plugins(&$a) { $r = q("SELECT * FROM `addon` WHERE `installed` = 1"); - if(count($r)) + if(is_filled_array($r)) $installed = $r; else $installed = array(); @@ -1680,7 +1680,7 @@ function current_theme(){ $r = q("select theme from user where uid = %d limit 1", intval($a->profile_uid) ); - if($r) + if(is_filled_array($r)) $page_theme = $r[0]['theme']; } @@ -1793,7 +1793,7 @@ function feed_birthday($uid,$tz) { intval($uid) ); - if($p && count($p)) { + if(is_filled_array($p)) { $tmp_dob = substr($p[0]['dob'],5); if(intval($tmp_dob)) { $y = datetime_convert($tz,$tz,'now','Y'); @@ -1838,7 +1838,7 @@ function load_contact_links($uid) { $r = q("SELECT `id`,`network`,`url`,`thumb`, `rel` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `thumb` != ''", intval($uid) ); - if(count($r)) { + if(is_filled_array($r)) { foreach($r as $rr){ $url = normalise_link($rr['url']); $ret[$url] = $rr; diff --git a/index.php b/index.php index e364389b2..e03d38a0c 100644 --- a/index.php +++ b/index.php @@ -107,7 +107,7 @@ if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) { // we didn't loaded user data yet, but we need user language $r = q("SELECT language FROM user WHERE uid=%d", intval($_SESSION['uid'])); $_SESSION['language'] = $lang; - if (count($r)>0) $_SESSION['language'] = $r[0]['language']; + if (is_filled_array($r)) $_SESSION['language'] = $r[0]['language']; } if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) { From 1f2bf81844f5a319c74d2566eb92e281001dffa7 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:27:38 +0100 Subject: [PATCH 016/498] No need to set $a->theme_info = array() everywhere if you can define it in App itself. Signed-off-by: Roland Haeder --- boot.php | 5 +++-- view/theme/decaf-mobile/theme.php | 1 - view/theme/duepuntozero/theme.php | 1 - view/theme/facepark/theme.php | 1 - view/theme/frost-mobile/theme.php | 1 - view/theme/frost/theme.php | 1 - view/theme/quattro/theme.php | 2 -- view/theme/smoothly/theme.php | 1 - view/theme/vier/theme.php | 2 -- 9 files changed, 3 insertions(+), 12 deletions(-) diff --git a/boot.php b/boot.php index d82669f23..4b2e83f18 100644 --- a/boot.php +++ b/boot.php @@ -465,11 +465,12 @@ class App { public $plugins; public $apps = array(); public $identities; - public $is_mobile; - public $is_tablet; + public $is_mobile = false; + public $is_tablet = false; public $is_friendica_app; public $performance = array(); public $callstack = array(); + public $theme_info = array(); public $nav_sel; diff --git a/view/theme/decaf-mobile/theme.php b/view/theme/decaf-mobile/theme.php index 1a32fb724..9b1c1daa6 100644 --- a/view/theme/decaf-mobile/theme.php +++ b/view/theme/decaf-mobile/theme.php @@ -10,7 +10,6 @@ */ function decaf_mobile_init(&$a) { - $a->theme_info = array(); $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; $a->videoheight = 200; diff --git a/view/theme/duepuntozero/theme.php b/view/theme/duepuntozero/theme.php index ba3f25d3e..50d57f91e 100644 --- a/view/theme/duepuntozero/theme.php +++ b/view/theme/duepuntozero/theme.php @@ -2,7 +2,6 @@ function duepuntozero_init(&$a) { -$a->theme_info = array(); set_template_engine($a, 'smarty3'); $colorset = get_pconfig( local_user(), 'duepuntozero','colorset'); diff --git a/view/theme/facepark/theme.php b/view/theme/facepark/theme.php index e7203c664..e6255f118 100644 --- a/view/theme/facepark/theme.php +++ b/view/theme/facepark/theme.php @@ -1,7 +1,6 @@ theme_info = array(); set_template_engine($a, 'smarty3'); $a->page['htmlhead'] .= <<< EOT diff --git a/view/theme/frost-mobile/theme.php b/view/theme/frost-mobile/theme.php index beec92493..29a990f7b 100644 --- a/view/theme/frost-mobile/theme.php +++ b/view/theme/frost-mobile/theme.php @@ -10,7 +10,6 @@ */ function frost_mobile_init(&$a) { - $a->theme_info = array(); $a->sourcename = 'Friendica mobile web'; $a->videowidth = 250; $a->videoheight = 200; diff --git a/view/theme/frost/theme.php b/view/theme/frost/theme.php index 868a840de..1093a0472 100644 --- a/view/theme/frost/theme.php +++ b/view/theme/frost/theme.php @@ -10,7 +10,6 @@ */ function frost_init(&$a) { - $a->theme_info = array(); $a->videowidth = 400; $a->videoheight = 330; $a->theme_thread_allow = false; diff --git a/view/theme/quattro/theme.php b/view/theme/quattro/theme.php index a1cd29ee7..0b67c6b49 100644 --- a/view/theme/quattro/theme.php +++ b/view/theme/quattro/theme.php @@ -8,8 +8,6 @@ */ function quattro_init(&$a) { - $a->theme_info = array(); - $a->page['htmlhead'] .= ''; $a->page['htmlhead'] .= '';; } diff --git a/view/theme/smoothly/theme.php b/view/theme/smoothly/theme.php index d3ebbc1d1..0dae3a6e4 100644 --- a/view/theme/smoothly/theme.php +++ b/view/theme/smoothly/theme.php @@ -11,7 +11,6 @@ */ function smoothly_init(&$a) { - $a->theme_info = array(); set_template_engine($a, 'smarty3'); $cssFile = null; diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 7f6ead079..925ac76a1 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -19,8 +19,6 @@ function vier_init(&$a) { set_template_engine($a, 'smarty3'); - $a->theme_info = array(); - if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] or $a->argv[0] === "network" && local_user()) { vier_community_info(); From 0142ff7f0f93b5120daf7b0f60a11b1717f711c2 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:32:19 +0100 Subject: [PATCH 017/498] Prevent some E_NOTICE in boot.php Signed-off-by: Roland Haeder --- boot.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/boot.php b/boot.php index 4b2e83f18..0a2f5c50c 100644 --- a/boot.php +++ b/boot.php @@ -1047,11 +1047,21 @@ class App { function save_timestamp($stamp, $value) { $duration = (float)(microtime(true)-$stamp); + if (!isset($this->performance[$value])) { + // Prevent ugly E_NOTICE + $this->performance[$value] = 0; + } + $this->performance[$value] += (float)$duration; $this->performance["marktime"] += (float)$duration; $callstack = $this->callstack(); + if (!isset($this->callstack[$value][$callstack])) { + // Prevent ugly E_NOTICE + $this->callstack[$value][$callstack] = 0; + } + $this->callstack[$value][$callstack] += (float)$duration; } From 118d4280135755d6054295ea89467975be9cae07 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:36:23 +0100 Subject: [PATCH 018/498] Prevent some E_NOTICE in identity.php Signed-off-by: Roland Haeder --- include/identity.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/identity.php b/include/identity.php index aba69bae4..888a09ee6 100644 --- a/include/identity.php +++ b/include/identity.php @@ -237,6 +237,7 @@ function profile_sidebar($profile, $block = 0) { if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect'])) $connect = false; + $remoteconnect = NULL; if (isset($profile['remoteconnect'])) $remoteconnect = $profile['remoteconnect']; @@ -292,9 +293,9 @@ function profile_sidebar($profile, $block = 0) { // check if profile is a forum if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP) - || (intval($profile['forum'])) - || (intval($profile['prv'])) - || (intval($profile['community']))) + || (isset($profile['forum']) && intval($profile['forum'])) + || (isset($profile['prv']) && intval($profile['prv'])) + || (isset($profile['community']) && intval($profile['community']))) $account_type = t('Forum'); else $account_type = ""; From cf50bb34710de6845ab0a5fa6b289de7dee8d630 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:42:55 +0100 Subject: [PATCH 019/498] More logging in case of errors + logged network type + added TODO (for ugly E_NOTICE). Signed-off-by: Roland Haeder --- mod/dfrn_request.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 2741ad59b..82886a6ef 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -42,8 +42,10 @@ function dfrn_request_init(&$a) { if(! function_exists('dfrn_request_post')) { function dfrn_request_post(&$a) { - if(($a->argc != 2) || (! count($a->profile))) + if(($a->argc != 2) || (! count($a->profile))) { + logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); return; + } if(x($_POST, 'cancel')) { @@ -461,7 +463,7 @@ function dfrn_request_post(&$a) { $network = NETWORK_DFRN; } - logger('dfrn_request: url: ' . $url); + logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG); if($network === NETWORK_DFRN) { $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", @@ -825,6 +827,7 @@ function dfrn_request_content(&$a) { else $tpl = get_markup_template('auto_request.tpl'); + // TODO This .= triggers an E_NOTICE, really needed? $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); // see if we are allowed to have NETWORK_MAIL2 contacts @@ -850,6 +853,7 @@ function dfrn_request_content(&$a) { get_server() ); + // TODO This .= triggers an E_NOTICE, really needed? $o .= replace_macros($tpl,array( '$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), From 2247d85b28e681ba4dd0f1f9de6179e019c9733e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:49:07 +0100 Subject: [PATCH 020/498] Don't miss to add exit() after header('Location: bla') as header() does *NOT* exit the script quickly enough. Always use an explicit exit() or you get real trouble. Signed-off-by: Roland Haeder --- index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index e364389b2..625c2d82d 100644 --- a/index.php +++ b/index.php @@ -72,7 +72,8 @@ if(!$install) { (intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND (substr($a->get_baseurl(), 0, 8) == "https://")) { header("HTTP/1.1 302 Moved Temporarily"); - header("location: ".$a->get_baseurl()."/".$a->query_string); + header("Location: ".$a->get_baseurl()."/".$a->query_string); + exit(); } require_once("include/session.php"); From 0510b31b7b933293396b6d1611a2712c39183ef4 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:49:56 +0100 Subject: [PATCH 021/498] and or are not self-closing tags. Signed-off-by: Roland Haeder --- view/templates/dfrn_request.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/templates/dfrn_request.tpl b/view/templates/dfrn_request.tpl index 3b96d3eef..5225bd60b 100644 --- a/view/templates/dfrn_request.tpl +++ b/view/templates/dfrn_request.tpl @@ -18,13 +18,13 @@ {{/if}} {{if $request}} - + {{else}} - + {{/if}} {{if $photo}} - + {{/if}} {{if $url}}
{{$url_label}}
{{$url}}
{{/if}} From 0c1cc0d32f949d566820a243eb2ebb3d622fc994 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:33:54 +0100 Subject: [PATCH 022/498] Introduced is_filled_array() + added some missing array initialization Signed-off-by: Roland Haeder --- boot.php | 4 ++++ mod/message.php | 10 ++++++---- mod/ping.php | 25 +++++++++++++------------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/boot.php b/boot.php index 0a2f5c50c..a1f29398f 100644 --- a/boot.php +++ b/boot.php @@ -2149,3 +2149,7 @@ function argv($x) { return ''; } + +function is_filled_array ($array) { + return (is_array($array) && count($array) > 0); +} diff --git a/mod/message.php b/mod/message.php index 734bf3471..6e176f712 100644 --- a/mod/message.php +++ b/mod/message.php @@ -8,7 +8,7 @@ function message_init(&$a) { $tabs = ''; if ($a->argc >1 && is_numeric($a->argv[1])) { - $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); + $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); } $new = array( @@ -360,11 +360,13 @@ function message_content(&$a) { dbesc($myprofile) ); - if(count($r)) $a->set_pager_total($r[0]['total']); + if (is_filled_array($r)) { + $a->set_pager_total($r[0]['total']); + } $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! count($r)) { + if(! is_filled_array($r)) { info( t('No messages.') . EOL); return $o; } @@ -542,7 +544,7 @@ function get_messages($user, $lstart, $lend) { ); } -function render_messages($msg, $t) { +function render_messages(array $msg, $t) { $a = get_app(); diff --git a/mod/ping.php b/mod/ping.php index 2eb94576b..8deab28ed 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -32,6 +32,8 @@ function ping_init(&$a) { $dislikes = array(); $friends = array(); $posts = array(); + $regs = array(); + $mails = array(); $home = 0; $network = 0; @@ -49,7 +51,7 @@ function ping_init(&$a) { intval(local_user()), intval(local_user()) ); - if(count($r)) { + if(is_filled_array($r)) { $arr = array('items' => $r); call_hooks('network_ping', $arr); @@ -116,8 +118,6 @@ function ping_init(&$a) { $intro = count($intros1) + count($intros2); $intros = $intros1+$intros2; - - $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ; $mails = q("SELECT * FROM `mail` WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", @@ -150,7 +150,7 @@ function ping_init(&$a) { dbesc(datetime_convert('UTC','UTC','now')) ); - if($ev && count($ev)) { + if(is_filled_array($ev)) { $all_events = intval($ev[0]['total']); if($all_events) { @@ -219,7 +219,7 @@ function ping_init(&$a) { $home\r\n"; if ($register!=0) echo "$register"; - if (count($groups_unseen)) { + if ( is_filled_array($groups_unseen) ) { echo ''; foreach ($groups_unseen as $it) if ($it['count'] > 0) @@ -228,7 +228,7 @@ function ping_init(&$a) { echo ""; } - if (count($forums_unseen)) { + if ( is_filled_array($forums_unseen) ) { echo ''; foreach ($forums_unseen as $it) if ($it['count'] > 0) @@ -245,8 +245,8 @@ function ping_init(&$a) { $birthdays_today\r\n"; - if(count($notifs) && (! $sysnotify)) { - foreach($notifs as $zz) { + if (is_filled_array($notifs) && (! $sysnotify)) { + foreach ($notifs as $zz) { if($zz['seen'] == 0) $sysnotify ++; } @@ -255,7 +255,7 @@ function ping_init(&$a) { echo ' '; // merge all notification types in one array - if ($intro>0){ + if ( is_filled_array($intros) ) { foreach ($intros as $i) { $n = array( 'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'], @@ -270,7 +270,7 @@ function ping_init(&$a) { } } - if ($mail>0){ + if ( is_filled_array($mails) ) { foreach ($mails as $i) { $n = array( 'href' => $a->get_baseurl().'/message/'.$i['id'], @@ -285,7 +285,7 @@ function ping_init(&$a) { } } - if ($register>0){ + if ( is_filled_array($regs) ) { foreach ($regs as $i) { $n = array( 'href' => $a->get_baseurl().'/admin/users/', @@ -299,6 +299,7 @@ function ping_init(&$a) { $notifs[] = $n; } } + // sort notifications by $[]['date'] $sort_function = function($a, $b) { $adate = date($a['date']); @@ -310,7 +311,7 @@ function ping_init(&$a) { }; usort($notifs, $sort_function); - if(count($notifs)) { + if( is_filled_array($notifs) ) { foreach($notifs as $n) { echo xmlize($n); } From f05c1e82f0b3c43ece556d86a024147363497397 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:38:02 +0100 Subject: [PATCH 023/498] Also use is_filled_array() here, too. if $contacts is FALSE count() issues are E_WARNING Signed-off-by: Roland Haeder --- include/ForumManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ForumManager.php b/include/ForumManager.php index 6fede0204..bbf881c9d 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -86,7 +86,7 @@ class ForumManager { $total = count($contacts); $visible_forums = 10; - if(count($contacts)) { + if(is_filled_array($contacts)) { $id = 0; From 51a2d31f545122afa2500b936efdb53c22c0b442 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 18:28:06 +0100 Subject: [PATCH 024/498] Closed TODO: no .= needed here. #2392 Signed-off-by: Roland Haeder --- mod/dfrn_request.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 82886a6ef..545599606 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -827,8 +827,7 @@ function dfrn_request_content(&$a) { else $tpl = get_markup_template('auto_request.tpl'); - // TODO This .= triggers an E_NOTICE, really needed? - $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); + $page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:"); // see if we are allowed to have NETWORK_MAIL2 contacts @@ -853,8 +852,7 @@ function dfrn_request_content(&$a) { get_server() ); - // TODO This .= triggers an E_NOTICE, really needed? - $o .= replace_macros($tpl,array( + $o = replace_macros($tpl,array( '$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$pls_answer' => t('Please answer the following:'), From 4ec377008db92033c117a66140879f6b1c75afd8 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:33:54 +0100 Subject: [PATCH 025/498] Introduced is_filled_array() + added some missing array initialization Signed-off-by: Roland Haeder --- boot.php | 4 ++++ mod/message.php | 10 ++++++---- mod/ping.php | 25 +++++++++++++------------ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/boot.php b/boot.php index 0a2f5c50c..a1f29398f 100644 --- a/boot.php +++ b/boot.php @@ -2149,3 +2149,7 @@ function argv($x) { return ''; } + +function is_filled_array ($array) { + return (is_array($array) && count($array) > 0); +} diff --git a/mod/message.php b/mod/message.php index 734bf3471..6e176f712 100644 --- a/mod/message.php +++ b/mod/message.php @@ -8,7 +8,7 @@ function message_init(&$a) { $tabs = ''; if ($a->argc >1 && is_numeric($a->argv[1])) { - $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); + $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); } $new = array( @@ -360,11 +360,13 @@ function message_content(&$a) { dbesc($myprofile) ); - if(count($r)) $a->set_pager_total($r[0]['total']); + if (is_filled_array($r)) { + $a->set_pager_total($r[0]['total']); + } $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! count($r)) { + if(! is_filled_array($r)) { info( t('No messages.') . EOL); return $o; } @@ -542,7 +544,7 @@ function get_messages($user, $lstart, $lend) { ); } -function render_messages($msg, $t) { +function render_messages(array $msg, $t) { $a = get_app(); diff --git a/mod/ping.php b/mod/ping.php index 2eb94576b..8deab28ed 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -32,6 +32,8 @@ function ping_init(&$a) { $dislikes = array(); $friends = array(); $posts = array(); + $regs = array(); + $mails = array(); $home = 0; $network = 0; @@ -49,7 +51,7 @@ function ping_init(&$a) { intval(local_user()), intval(local_user()) ); - if(count($r)) { + if(is_filled_array($r)) { $arr = array('items' => $r); call_hooks('network_ping', $arr); @@ -116,8 +118,6 @@ function ping_init(&$a) { $intro = count($intros1) + count($intros2); $intros = $intros1+$intros2; - - $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ; $mails = q("SELECT * FROM `mail` WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", @@ -150,7 +150,7 @@ function ping_init(&$a) { dbesc(datetime_convert('UTC','UTC','now')) ); - if($ev && count($ev)) { + if(is_filled_array($ev)) { $all_events = intval($ev[0]['total']); if($all_events) { @@ -219,7 +219,7 @@ function ping_init(&$a) { $home\r\n"; if ($register!=0) echo "$register"; - if (count($groups_unseen)) { + if ( is_filled_array($groups_unseen) ) { echo ''; foreach ($groups_unseen as $it) if ($it['count'] > 0) @@ -228,7 +228,7 @@ function ping_init(&$a) { echo ""; } - if (count($forums_unseen)) { + if ( is_filled_array($forums_unseen) ) { echo ''; foreach ($forums_unseen as $it) if ($it['count'] > 0) @@ -245,8 +245,8 @@ function ping_init(&$a) { $birthdays_today\r\n"; - if(count($notifs) && (! $sysnotify)) { - foreach($notifs as $zz) { + if (is_filled_array($notifs) && (! $sysnotify)) { + foreach ($notifs as $zz) { if($zz['seen'] == 0) $sysnotify ++; } @@ -255,7 +255,7 @@ function ping_init(&$a) { echo ' '; // merge all notification types in one array - if ($intro>0){ + if ( is_filled_array($intros) ) { foreach ($intros as $i) { $n = array( 'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'], @@ -270,7 +270,7 @@ function ping_init(&$a) { } } - if ($mail>0){ + if ( is_filled_array($mails) ) { foreach ($mails as $i) { $n = array( 'href' => $a->get_baseurl().'/message/'.$i['id'], @@ -285,7 +285,7 @@ function ping_init(&$a) { } } - if ($register>0){ + if ( is_filled_array($regs) ) { foreach ($regs as $i) { $n = array( 'href' => $a->get_baseurl().'/admin/users/', @@ -299,6 +299,7 @@ function ping_init(&$a) { $notifs[] = $n; } } + // sort notifications by $[]['date'] $sort_function = function($a, $b) { $adate = date($a['date']); @@ -310,7 +311,7 @@ function ping_init(&$a) { }; usort($notifs, $sort_function); - if(count($notifs)) { + if( is_filled_array($notifs) ) { foreach($notifs as $n) { echo xmlize($n); } From 24cbac1a5b6b10882238253822794efca1fb2be3 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:38:02 +0100 Subject: [PATCH 026/498] Also use is_filled_array() here, too. if $contacts is FALSE count() issues are E_WARNING Signed-off-by: Roland Haeder --- include/ForumManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ForumManager.php b/include/ForumManager.php index 6fede0204..bbf881c9d 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -86,7 +86,7 @@ class ForumManager { $total = count($contacts); $visible_forums = 10; - if(count($contacts)) { + if(is_filled_array($contacts)) { $id = 0; From 8cb011a07ed947a01e34590cf1ea3fe4ee7f3043 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 14:42:55 +0100 Subject: [PATCH 027/498] More logging in case of errors + logged network type + added TODO (for ugly E_NOTICE). Signed-off-by: Roland Haeder --- mod/dfrn_request.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 2741ad59b..82886a6ef 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -42,8 +42,10 @@ function dfrn_request_init(&$a) { if(! function_exists('dfrn_request_post')) { function dfrn_request_post(&$a) { - if(($a->argc != 2) || (! count($a->profile))) + if(($a->argc != 2) || (! count($a->profile))) { + logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); return; + } if(x($_POST, 'cancel')) { @@ -461,7 +463,7 @@ function dfrn_request_post(&$a) { $network = NETWORK_DFRN; } - logger('dfrn_request: url: ' . $url); + logger('dfrn_request: url: ' . $url . ',network=' . $network, LOGGER_DEBUG); if($network === NETWORK_DFRN) { $ret = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `self` = 0 LIMIT 1", @@ -825,6 +827,7 @@ function dfrn_request_content(&$a) { else $tpl = get_markup_template('auto_request.tpl'); + // TODO This .= triggers an E_NOTICE, really needed? $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); // see if we are allowed to have NETWORK_MAIL2 contacts @@ -850,6 +853,7 @@ function dfrn_request_content(&$a) { get_server() ); + // TODO This .= triggers an E_NOTICE, really needed? $o .= replace_macros($tpl,array( '$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), From 2d154ae72fef27c846c570fd0f362376dd5e10b1 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 1 Mar 2016 18:28:06 +0100 Subject: [PATCH 028/498] Closed TODO: no .= needed here. #2392 Signed-off-by: Roland Haeder --- mod/dfrn_request.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 82886a6ef..545599606 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -827,8 +827,7 @@ function dfrn_request_content(&$a) { else $tpl = get_markup_template('auto_request.tpl'); - // TODO This .= triggers an E_NOTICE, really needed? - $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); + $page_desc = t("Please enter your 'Identity Address' from one of the following supported communications networks:"); // see if we are allowed to have NETWORK_MAIL2 contacts @@ -853,8 +852,7 @@ function dfrn_request_content(&$a) { get_server() ); - // TODO This .= triggers an E_NOTICE, really needed? - $o .= replace_macros($tpl,array( + $o = replace_macros($tpl,array( '$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$pls_answer' => t('Please answer the following:'), From d88606321dd9c8d2f43d8f24789bfaad9f9b346d Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 4 Mar 2016 22:39:08 +0100 Subject: [PATCH 029/498] Just easier code ... Signed-off-by: Roland Haeder --- include/poller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/poller.php b/include/poller.php index 755862eb6..558eda25f 100644 --- a/include/poller.php +++ b/include/poller.php @@ -206,7 +206,7 @@ function poller_max_connections_reached() { function poller_kill_stale_workers() { $r = q("SELECT `pid`, `executed` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); - if (!is_array($r) || count($r) == 0) { + if (!is_filled_array($r)) { // No processing here needed return; } From 5a439a31f3ef58b826ffe21c8972d6373165b8bb Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 4 Mar 2016 22:46:30 +0100 Subject: [PATCH 030/498] Fixes E_WARNING from foreach() because count() seem to return TRUE even when $r is no array ?! Signed-off-by: Roland Haeder --- boot.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index a1f29398f..fdf0fa3aa 100644 --- a/boot.php +++ b/boot.php @@ -1849,7 +1849,8 @@ function load_contact_links($uid) { $r = q("SELECT `id`,`network`,`url`,`thumb`, `rel` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `thumb` != ''", intval($uid) ); - if(count($r)) { + + if(is_filled_array($r)) { foreach($r as $rr){ $url = normalise_link($rr['url']); $ret[$url] = $rr; From b56a9bfaccbd22a632f71af96120b35fb3246547 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 4 Mar 2016 22:46:30 +0100 Subject: [PATCH 031/498] Fixes E_WARNING from foreach() because count() seem to return TRUE even when $r is no array ?! Signed-off-by: Roland Haeder --- boot.php | 1 + 1 file changed, 1 insertion(+) diff --git a/boot.php b/boot.php index b049099ea..ea9f7f9e0 100644 --- a/boot.php +++ b/boot.php @@ -1838,6 +1838,7 @@ function load_contact_links($uid) { $r = q("SELECT `id`,`network`,`url`,`thumb`, `rel` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `thumb` != ''", intval($uid) ); + if(is_filled_array($r)) { foreach($r as $rr){ $url = normalise_link($rr['url']); From 9cfc249b12b3d8b756cc914b0a03a17957e49a77 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 12 Mar 2016 18:54:55 +0100 Subject: [PATCH 032/498] Moved is_filled_array() to both dba classes and named it is_result(). Please see ticket #2390 for full discussion. Signed-off-by: Roland Haeder --- boot.php | 14 +++++--------- include/ForumManager.php | 2 +- include/dba.php | 11 ++++++++++- include/dba_pdo.php | 10 ++++++++++ include/poller.php | 2 +- index.php | 2 +- mod/message.php | 4 ++-- mod/ping.php | 18 +++++++++--------- 8 files changed, 39 insertions(+), 24 deletions(-) diff --git a/boot.php b/boot.php index 72d34229e..a9ff0c30c 100644 --- a/boot.php +++ b/boot.php @@ -927,7 +927,7 @@ class App { } else { $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like '%%/%s'", $common_filename); - if(! is_filled_array($r)){ + if(! dba::is_result($r)){ $this->cached_profile_image[$avatar_image] = $avatar_image; } else { $this->cached_profile_picdate[$common_filename] = "?rev=".urlencode($r[0]['picdate']); @@ -1412,7 +1412,7 @@ function run_update_function($x) { function check_plugins(&$a) { $r = q("SELECT * FROM `addon` WHERE `installed` = 1"); - if(is_filled_array($r)) + if(dba::is_result($r)) $installed = $r; else $installed = array(); @@ -1743,7 +1743,7 @@ function current_theme(){ $r = q("select theme from user where uid = %d limit 1", intval($a->profile_uid) ); - if(is_filled_array($r)) + if(dba::is_result($r)) $page_theme = $r[0]['theme']; } @@ -1856,7 +1856,7 @@ function feed_birthday($uid,$tz) { intval($uid) ); - if(is_filled_array($p)) { + if(dba::is_result($p)) { $tmp_dob = substr($p[0]['dob'],5); if(intval($tmp_dob)) { $y = datetime_convert($tz,$tz,'now','Y'); @@ -1902,7 +1902,7 @@ function load_contact_links($uid) { intval($uid) ); - if(is_filled_array($r)) { + if(dba::is_result($r)) { foreach($r as $rr){ $url = normalise_link($rr['url']); $ret[$url] = $rr; @@ -2202,7 +2202,3 @@ function argv($x) { return ''; } - -function is_filled_array ($array) { - return (is_array($array) && count($array) > 0); -} diff --git a/include/ForumManager.php b/include/ForumManager.php index bbf881c9d..99a78be71 100644 --- a/include/ForumManager.php +++ b/include/ForumManager.php @@ -86,7 +86,7 @@ class ForumManager { $total = count($contacts); $visible_forums = 10; - if(is_filled_array($contacts)) { + if(dba::is_result($contacts)) { $id = 0; diff --git a/include/dba.php b/include/dba.php index cae045d87..3a16c187c 100644 --- a/include/dba.php +++ b/include/dba.php @@ -230,6 +230,16 @@ class dba { } } + /** + * Checks if $array is a filled array with at least one entry. + * + * @param $array mixed A filled array with at least one entry + * @return Whether $array is a filled array + */ + public function is_result ($array) { + return (is_array($array) && count($array) > 0); + } + function __destruct() { if ($this->db) if($this->mysqli) @@ -340,4 +350,3 @@ function dbesc_array(&$arr) { function dba_timer() { return microtime(true); } - diff --git a/include/dba_pdo.php b/include/dba_pdo.php index 7b720fb6c..b48aba448 100644 --- a/include/dba_pdo.php +++ b/include/dba_pdo.php @@ -232,6 +232,16 @@ class dba { } } + /** + * Checks if $array is a filled array with at least one entry. + * + * @param $array mixed A filled array with at least one entry + * @return Whether $array is a filled array + */ + public function is_result ($array) { + return (is_array($array) && count($array) > 0); + } + function __destruct() { if ($this->db) \DDDBL\disconnect(); diff --git a/include/poller.php b/include/poller.php index 0b3d89ab3..b0e88f73d 100644 --- a/include/poller.php +++ b/include/poller.php @@ -197,7 +197,7 @@ function poller_max_connections_reached() { function poller_kill_stale_workers() { $r = q("SELECT `pid`, `executed` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); - if (!is_filled_array($r)) { + if (!dba::is_result($r)) { // No processing here needed return; } diff --git a/index.php b/index.php index 841eede0a..484c27634 100644 --- a/index.php +++ b/index.php @@ -108,7 +108,7 @@ if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) { // we didn't loaded user data yet, but we need user language $r = q("SELECT language FROM user WHERE uid=%d", intval($_SESSION['uid'])); $_SESSION['language'] = $lang; - if (is_filled_array($r)) $_SESSION['language'] = $r[0]['language']; + if (dba::is_result($r)) $_SESSION['language'] = $r[0]['language']; } if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) { diff --git a/mod/message.php b/mod/message.php index 6e176f712..b6981cc88 100644 --- a/mod/message.php +++ b/mod/message.php @@ -360,13 +360,13 @@ function message_content(&$a) { dbesc($myprofile) ); - if (is_filled_array($r)) { + if (dba::is_result($r)) { $a->set_pager_total($r[0]['total']); } $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! is_filled_array($r)) { + if(! dba::is_result($r)) { info( t('No messages.') . EOL); return $o; } diff --git a/mod/ping.php b/mod/ping.php index f572b430e..9338b8b68 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -51,7 +51,7 @@ function ping_init(&$a) { intval(local_user()), intval(local_user()) ); - if(is_filled_array($r)) { + if(dba::is_result($r)) { $arr = array('items' => $r); call_hooks('network_ping', $arr); @@ -150,7 +150,7 @@ function ping_init(&$a) { dbesc(datetime_convert('UTC','UTC','now')) ); - if(is_filled_array($ev)) { + if(dba::is_result($ev)) { $all_events = intval($ev[0]['total']); if($all_events) { @@ -219,7 +219,7 @@ function ping_init(&$a) { $home\r\n"; if ($register!=0) echo "$register"; - if ( is_filled_array($groups_unseen) ) { + if ( dba::is_result($groups_unseen) ) { echo ''; foreach ($groups_unseen as $it) if ($it['count'] > 0) @@ -228,7 +228,7 @@ function ping_init(&$a) { echo ""; } - if ( is_filled_array($forums_unseen) ) { + if ( dba::is_result($forums_unseen) ) { echo ''; foreach ($forums_unseen as $it) if ($it['count'] > 0) @@ -245,7 +245,7 @@ function ping_init(&$a) { $birthdays_today\r\n"; - if (is_filled_array($notifs) && (! $sysnotify)) { + if (dba::is_result($notifs) && (! $sysnotify)) { foreach ($notifs as $zz) { if($zz['seen'] == 0) $sysnotify ++; @@ -255,7 +255,7 @@ function ping_init(&$a) { echo ' '; // merge all notification types in one array - if ( is_filled_array($intros) ) { + if ( dba::is_result($intros) ) { foreach ($intros as $i) { $n = array( 'href' => $a->get_baseurl().'/notifications/intros/'.$i['id'], @@ -270,7 +270,7 @@ function ping_init(&$a) { } } - if ( is_filled_array($mails) ) { + if ( dba::is_result($mails) ) { foreach ($mails as $i) { $n = array( 'href' => $a->get_baseurl().'/message/'.$i['id'], @@ -285,7 +285,7 @@ function ping_init(&$a) { } } - if ( is_filled_array($regs) ) { + if ( dba::is_result($regs) ) { foreach ($regs as $i) { $n = array( 'href' => $a->get_baseurl().'/admin/users/', @@ -311,7 +311,7 @@ function ping_init(&$a) { }; usort($notifs, $sort_function); - if( is_filled_array($notifs) ) { + if( dba::is_result($notifs) ) { foreach($notifs as $n) { echo xmlize($n); } From 7f0ae9843f2e2e1268e6f1913949c7912ce9b534 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 12 Mar 2016 22:54:06 +0100 Subject: [PATCH 033/498] count() didn't notice about FALSE ... #2390 Signed-off-by: Roland Haeder --- mod/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/profile.php b/mod/profile.php index 26bd39523..c3f58ab52 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -300,7 +300,7 @@ function profile_content(&$a, $update = 0) { $parents_arr = array(); $parents_str = ''; - if(count($r)) { + if (dba::is_result($r)) { foreach($r as $rr) $parents_arr[] = $rr['item_id']; $parents_str = implode(', ', $parents_arr); From 47b591c09a7773ff3eeaa60e53d3508d79bcc129 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 12 Mar 2016 23:02:42 +0100 Subject: [PATCH 034/498] Fixes another warning because of count()'s lazyness. #2390 Signed-off-by: Roland Haeder --- mod/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/network.php b/mod/network.php index a9f369a89..202be047e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -792,7 +792,7 @@ function network_content(&$a, $update = 0) { $parents_str = ''; $date_offset = ""; - if(count($r)) { + if(dba::is_result($r)) { foreach($r as $rr) if(! in_array($rr['item_id'],$parents_arr)) $parents_arr[] = $rr['item_id']; From 0af572ffbaca04ac757a76ced22ab48a90e29a4a Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 12 Jun 2016 18:23:10 +0200 Subject: [PATCH 035/498] frio: first part for event template work --- mod/events.php | 10 +- view/theme/frio/css/style.css | 62 ++++++++ view/theme/frio/js/modal.js | 11 +- view/theme/frio/js/theme.js | 156 +++++++++++++++++++ view/theme/frio/templates/event.tpl | 19 +++ view/theme/frio/templates/event_form.tpl | 53 +++++++ view/theme/frio/templates/event_head.tpl | 188 +++++++++++++++++++++++ view/theme/frio/templates/events-js.tpl | 41 +++++ 8 files changed, 537 insertions(+), 3 deletions(-) create mode 100644 view/theme/frio/templates/event.tpl create mode 100644 view/theme/frio/templates/event_form.tpl create mode 100644 view/theme/frio/templates/event_head.tpl create mode 100644 view/theme/frio/templates/events-js.tpl diff --git a/mod/events.php b/mod/events.php index 633aaf0c1..46f33355b 100644 --- a/mod/events.php +++ b/mod/events.php @@ -67,9 +67,9 @@ function events_post(&$a) { $action = ($event_id == '') ? 'new' : "event/" . $event_id; $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish"; - if(strcmp($finish,$start) < 0 && !$nofinish) { + if(strcmp($finish,$start) < 0 && !$nofinish) { notice( t('Event can not end before it has started.') . EOL); - if(intval($_REQUEST['preview'])) { + if(intval($_REQUEST['preview'])) { echo( t('Event can not end before it has started.')); killme(); } @@ -462,6 +462,12 @@ function events_content(&$a) { '$events' => $events, + // eignene + "today" => t("today"), + "month" => t("month"), + "week" => t("week"), + "day" => t("day"), + )); diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 49d78e131..185888b71 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -163,6 +163,15 @@ a#item-delete-selected { .btn-link:focus, .btn-link:hover { color: #23527c; } +.btn-eventnav, btn-eventnav:hover { + font-size: 16px; + background: none; + background-color: transparent; + padding: 0 14px; +} +.btn-separator { + border-left: 1px solid #777; +} /*.btn-info { background: #6fdbe8; color: #fff!important; @@ -1901,6 +1910,59 @@ ul li:hover .contact-wrapper a.contact-action-link:hover { #poke-wrapper-end { clear: both; } + +/* Events page */ +#fc-header { + margin-top: 20px; + margin-bottom: 10px; +} +#fc-header-left, +#fc-header-right, +#event-calendar-title { + display: inline-block; +} +#fc-title { + margin: 0; + padding-left: 20px; + +} +#fc-header-right { + margin-top: -4px; +} +#event-calendar-title { + vertical-align: middle; +} +a#event-calendar-views { + padding: 6px 9px; + font-size: 14px +} +tr.fc-first, +tr.fc-first th { + border-left: none; + border-right: none; + border-top: none; +} +td.fc-day { + border-left: none; + border-right: none; + padding: 0 6px; +} +#events-calendar .fc-grid .fc-day-number { + float: left; + font-size: 0.9em; +} +.event-wrapper .event-owner { + margin-bottom: 15px; +} +.event-owner img { + margin-right: 5px; + height: 48px; + width: 48; + border-radius: 3px; +} +.event-wrapper .event-buttons { + margin-top: 15px; +} /* * Overwriting for transparency and other colors */ diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index 0a881f10f..f99946019 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -158,8 +158,17 @@ function loadModalTitle() { // hide the first element with the class "heading" of the modal body $("#modal-body .heading").first().hide(); + var title = ""; + // get the text of the first element with "heading" class - var title = $("#modal-body .heading").first().text(); + title = $("#modal-body .heading").first().text(); + + // for event modals we need some speacial handling + if($("#modal-body .event-wrapper .event-summary").length) { + title = ' '; + var eventsum = $("#modal-body .event-wrapper .event-summary").text(); + title = title + eventsum; + } // and append it to modal title if (title!=="") { diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 28221dcd0..414df7c1a 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -482,3 +482,159 @@ String.prototype.rtrim = function() { return trimmed; }; + + +// $(document).ready(function() { +// $('#events-calendar').fullCalendar({ +// firstDay: {{$i18n.firstDay}}, +// monthNames: ['{{$i18n.January}}','{{$i18n.February}}','{{$i18n.March}}','{{$i18n.April}}','{{$i18n.May}}','{{$i18n.June}}','{{$i18n.July}}','{{$i18n.August}}','{{$i18n.September}}','{{$i18n.October}}','{{$i18n.November}}','{{$i18n.December}}'], +// monthNamesShort: ['{{$i18n.Jan}}','{{$i18n.Feb}}','{{$i18n.Mar}}','{{$i18n.Apr}}','{{$i18n.May}}','{{$i18n.Jun}}','{{$i18n.Jul}}','{{$i18n.Aug}}','{{$i18n.Sep}}','{{$i18n.Oct}}','{{$i18n.Nov}}','{{$i18n.Dec}}'], +// dayNames: ['{{$i18n.Sunday}}','{{$i18n.Monday}}','{{$i18n.Tuesday}}','{{$i18n.Wednesday}}','{{$i18n.Thursday}}','{{$i18n.Friday}}','{{$i18n.Saturday}}'], +// dayNamesShort: ['{{$i18n.Sun}}','{{$i18n.Mon}}','{{$i18n.Tue}}','{{$i18n.Wed}}','{{$i18n.Thu}}','{{$i18n.Fri}}','{{$i18n.Sat}}'], +// buttonText: { +// prev: "", +// next: "", +// prevYear: "«", +// nextYear: "»", +// today: '{{$i18n.today}}', +// month: '{{$i18n.month}}', +// week: '{{$i18n.week}}', +// day: '{{$i18n.day}}' +// }, +// events: '{{$baseurl}}/events/json/', +// header: { +// left: '', +// // center: 'title', +// right: '' +// }, +// timeFormat: 'H(:mm)', +// eventClick: function(calEvent, jsEvent, view) { +// showEvent(calEvent.id); +// }, +// loading: function(isLoading, view) { +// if(!isLoading) { +// $('td.fc-day').dblclick(function() { window.location.href='/events/new?start='+$(this).data('date'); }); +// } +// }, +// +// eventRender: function(event, element, view) { +// //console.log(view.name); +// if (event.item['author-name']==null) return; +// switch(view.name){ +// case "month": +// element.find(".fc-event-title").html( +// "{1} : {2}".format( +// event.item['author-avatar'], +// event.item['author-name'], +// event.title +// )); +// break; +// case "agendaWeek": +// element.find(".fc-event-title").html( +// "{1}

{2}

{3}

".format( +// event.item['author-avatar'], +// event.item['author-name'], +// event.item.desc, +// event.item.location +// )); +// break; +// case "agendaDay": +// element.find(".fc-event-title").html( +// "{1}

{2}

{3}

".format( +// event.item['author-avatar'], +// event.item['author-name'], +// event.item.desc, +// event.item.location +// )); +// break; +// } +// } +// +// }) +// +// // center on date +// var args=location.href.replace(baseurl,"").split("/"); +// if (args.length>=4) { +// $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1); +// } +// +// // echo the title +// var view = $('#events-calendar').fullCalendar('getView'); +// $('#fc-title').text(view.title); +// +// // show event popup +// var hash = location.hash.split("-") +// if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]); +// +// }); + +// $(document).ready(function() { +// $('#events-calendar').fullCalendar({ +// +// events: '{{$baseurl}}/events/json/', +// header: { +// left: '', +// // center: 'title', +// right: '' +// }, +// timeFormat: 'H(:mm)', +// eventClick: function(calEvent, jsEvent, view) { +// showEvent(calEvent.id); +// }, +// loading: function(isLoading, view) { +// if(!isLoading) { +// $('td.fc-day').dblclick(function() { window.location.href='/events/new?start='+$(this).data('date'); }); +// } +// }, +// +// eventRender: function(event, element, view) { +// //console.log(view.name); +// if (event.item['author-name']==null) return; +// switch(view.name){ +// case "month": +// element.find(".fc-event-title").html( +// "{1} : {2}".format( +// event.item['author-avatar'], +// event.item['author-name'], +// event.title +// )); +// break; +// case "agendaWeek": +// element.find(".fc-event-title").html( +// "{1}

{2}

{3}

".format( +// event.item['author-avatar'], +// event.item['author-name'], +// event.item.desc, +// event.item.location +// )); +// break; +// case "agendaDay": +// element.find(".fc-event-title").html( +// "{1}

{2}

{3}

".format( +// event.item['author-avatar'], +// event.item['author-name'], +// event.item.desc, +// event.item.location +// )); +// break; +// } +// } +// +// }) +// +// // center on date +// var args=location.href.replace(baseurl,"").split("/"); +// if (args.length>=4) { +// $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1); +// } +// +// // echo the title +// var view = $('#events-calendar').fullCalendar('getView'); +// $('#fc-title').text(view.title); +// +// // show event popup +// var hash = location.hash.split("-") +// if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]); +// +// }); + \ No newline at end of file diff --git a/view/theme/frio/templates/event.tpl b/view/theme/frio/templates/event.tpl new file mode 100644 index 000000000..380bc7cb1 --- /dev/null +++ b/view/theme/frio/templates/event.tpl @@ -0,0 +1,19 @@ + +{{foreach $events as $event}} +
+
+
+ {{if $event.item.author_name}} + {{$event.item.author_name}} + {{/if}} +
+ {{$event.html}} + +
+ {{if $event.item.plink}}{{/if}} + {{if $event.edit}}{{/if}} +
+
+
+
+{{/foreach}} diff --git a/view/theme/frio/templates/event_form.tpl b/view/theme/frio/templates/event_form.tpl new file mode 100644 index 000000000..ff59833b5 --- /dev/null +++ b/view/theme/frio/templates/event_form.tpl @@ -0,0 +1,53 @@ + +

{{$title}}

+ +

+{{$desc}} +

+ + + + + + + + +
{{$s_text}}
+{{$s_dsel}} + +
{{$f_text}}
+{{$f_dsel}} + +
+ +
{{$n_text}}
+ +
+ +
{{$a_text}}
+ +
+ +
{{$t_text}}
+ + + +
{{$d_text}}
+ + + +
{{$l_text}}
+ + +
+ +
{{$sh_text}}
+
+ +{{$acl}} + +
+ + + + diff --git a/view/theme/frio/templates/event_head.tpl b/view/theme/frio/templates/event_head.tpl new file mode 100644 index 000000000..e11f93ea7 --- /dev/null +++ b/view/theme/frio/templates/event_head.tpl @@ -0,0 +1,188 @@ + + + + + + + +{{if $editselect != 'none'}} + + + diff --git a/view/theme/frio/templates/events-js.tpl b/view/theme/frio/templates/events-js.tpl new file mode 100644 index 000000000..dcd522c58 --- /dev/null +++ b/view/theme/frio/templates/events-js.tpl @@ -0,0 +1,41 @@ +
+ {{$tabs}} + {{include file="section_title.tpl" title=$title}} + + + +
+
+ +
+
+ + + +
+ +

+ +
+
+
From 5e98f27fcd99f0431a5f62ca7a825a5ad6a2f8a3 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 13 Jun 2016 10:19:38 +0200 Subject: [PATCH 036/498] frio: events - work on event_form.tpl + datetime.php --- include/datetime.php | 20 ++++---- mod/events.php | 7 ++- view/theme/frio/templates/event_form.tpl | 59 ++++++++++++++++++------ view/theme/frio/templates/events-js.tpl | 2 +- 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/include/datetime.php b/include/datetime.php index 89305a240..bbb60ba72 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -202,7 +202,7 @@ function dob($dob) { * @return string Parsed HTML output. */ function datesel($format, $min, $max, $default, $id = 'datepicker') { - return datetimesel($format,$min,$max,$default,$id,true,false, '',''); + return datetimesel($format,$min,$max,$default,'',$id,true,false, '',''); } /** @@ -220,7 +220,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') { * @return string Parsed HTML output. */ function timesel($format, $h, $m, $id='timepicker') { - return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),$id,false,true); + return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),'',$id,false,true); } /** @@ -251,7 +251,7 @@ function timesel($format, $h, $m, $id='timepicker') { * @todo Once browser support is better this could probably be replaced with * native HTML5 date picker. */ -function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) { +function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) { // First day of the week (0 = Sunday) $firstDay = get_pconfig(local_user(),'system','first_day_of_week'); @@ -283,9 +283,9 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic $extra_js = ''; $pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'"; if($minfrom != '') - $extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; + $extra_js .= "\$('id_#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; if($maxfrom != '') - $extra_js .= "\$('#$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; + $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; $readable_format = $dateformat; $readable_format = str_replace('Y','yyyy',$readable_format); @@ -294,10 +294,14 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic $readable_format = str_replace('H','HH',$readable_format); $readable_format = str_replace('i','MM',$readable_format); - $o .= "
"; - $o .= '
'; + $tpl = get_markup_template('field_input.tpl'); + $o .= replace_macros($tpl,array( + '$field' => array($id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '" '), + )); +// $o .= "
"; +// $o .= '
'; $o .= ""; return $o; diff --git a/mod/events.php b/mod/events.php index 46f33355b..f6872a616 100644 --- a/mod/events.php +++ b/mod/events.php @@ -561,11 +561,11 @@ function events_content(&$a) { '$title' => t('Event details'), '$desc' => t('Starting date and Title are required.'), '$s_text' => t('Event Starts:') . ' *', - '$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"),'start_text',true,true,'','',true), + '$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"),t('Event Starts:'),'start_text',true,true,'','',true), '$n_text' => t('Finish date/time is not known or not relevant'), '$n_checked' => $n_checked, '$f_text' => t('Event Finishes:'), - '$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"),'finish_text',true,true,'start_text'), + '$f_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$fyear+5),DateTime::createFromFormat('Y-m-d H:i',"$fyear-$fmonth-$fday $fhour:$fminute"),t('Event Finishes:'),'finish_text',true,true,'start_text'), '$a_text' => t('Adjust for viewer timezone'), '$a_checked' => $a_checked, '$d_text' => t('Description:'), @@ -574,8 +574,11 @@ function events_content(&$a) { '$l_orig' => $l_orig, '$t_text' => t('Title:') . ' *', '$t_orig' => $t_orig, + '$summary' => array('summary', t('Title:'), $t_orig, '', '*'), '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, + '$nofinish' => array('nofinish', t('Finish date/time is not known or not relevant'), $n_checked), + '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked), '$preview' => t('Preview'), '$acl' => $acl, '$submit' => t('Submit') diff --git a/view/theme/frio/templates/event_form.tpl b/view/theme/frio/templates/event_form.tpl index ff59833b5..ebe4faa35 100644 --- a/view/theme/frio/templates/event_form.tpl +++ b/view/theme/frio/templates/event_form.tpl @@ -12,28 +12,59 @@ -
{{$s_text}}
{{$s_dsel}} -
{{$f_text}}
{{$f_dsel}} -
+{{include file="field_checkbox.tpl" field=$nofinish}} -
{{$n_text}}
+{{include file="field_checkbox.tpl" field=$adjust}} -
+{{include file="field_input.tpl" field=$summary}} -
{{$a_text}}
+
+
{{$d_text}}
+ + +
+
{{$l_text}}
diff --git a/view/theme/frio/templates/events-js.tpl b/view/theme/frio/templates/events-js.tpl index dcd522c58..93c131b36 100644 --- a/view/theme/frio/templates/events-js.tpl +++ b/view/theme/frio/templates/events-js.tpl @@ -1,7 +1,7 @@
{{$tabs}} {{include file="section_title.tpl" title=$title}} - +
From 0e35427dfcc06ee00fcb0f6369a0b76a2db1cbff Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 15 Jun 2016 21:20:55 +0200 Subject: [PATCH 037/498] New fields "author-id" and "owner-id" in the item table --- boot.php | 2 +- database.sql | 4 +++- include/dbstructure.php | 2 ++ include/items.php | 6 ++++++ update.php | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/boot.php b/boot.php index 318a87346..62baf116d 100644 --- a/boot.php +++ b/boot.php @@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica'); define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_VERSION', '3.5-dev' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); -define ( 'DB_UPDATE_VERSION', 1196 ); +define ( 'DB_UPDATE_VERSION', 1197 ); /** * @brief Constant with a HTML line break. diff --git a/database.sql b/database.sql index 8269a8bba..275982d84 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 3.5-dev (Asparagus) --- DB_UPDATE_VERSION 1196 +-- DB_UPDATE_VERSION 1197 -- ------------------------------------------ @@ -458,9 +458,11 @@ CREATE TABLE IF NOT EXISTS `item` ( `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `received` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `owner-id` int(11) NOT NULL DEFAULT 0, `owner-name` varchar(255) NOT NULL DEFAULT '', `owner-link` varchar(255) NOT NULL DEFAULT '', `owner-avatar` varchar(255) NOT NULL DEFAULT '', + `author-id` int(11) NOT NULL DEFAULT 0, `author-name` varchar(255) NOT NULL DEFAULT '', `author-link` varchar(255) NOT NULL DEFAULT '', `author-avatar` varchar(255) NOT NULL DEFAULT '', diff --git a/include/dbstructure.php b/include/dbstructure.php index f89a3ff92..8ae3ae6c8 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -792,9 +792,11 @@ function db_definition() { "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), + "owner-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), + "author-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"), "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""), diff --git a/include/items.php b/include/items.php index 203b7d0ee..f5e568306 100644 --- a/include/items.php +++ b/include/items.php @@ -584,6 +584,12 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa "photo" => $arr['author-avatar'], "name" => $arr['author-name'])); } + if ($arr["author-id"] == 0) + $arr["author-id"] = get_contact($arr["author-link"], 0); + + if ($arr["owner-id"] == 0) + $arr["owner-id"] = get_contact($arr["owner-link"], 0); + if ($arr['guid'] != "") { // Checking if there is already an item with the same guid logger('checking for an item for user '.$arr['uid'].' on network '.$arr['network'].' with the guid '.$arr['guid'], LOGGER_DEBUG); diff --git a/update.php b/update.php index 1189ac4a9..f2d790aa4 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@ Date: Thu, 16 Jun 2016 11:38:12 +0200 Subject: [PATCH 038/498] port of Hubzillas code highlight feature --- include/bbcode.php | 12 + include/text.php | 40 + library/Text_Highlighter/README | 455 +++ library/Text_Highlighter/TODO | 12 + library/Text_Highlighter/Text/Highlighter.php | 398 +++ .../Text/Highlighter/ABAP.php | 519 +++ .../Text/Highlighter/AVRC.php | 894 ++++++ .../Text_Highlighter/Text/Highlighter/CPP.php | 891 ++++++ .../Text_Highlighter/Text/Highlighter/CSS.php | 437 +++ .../Text/Highlighter/DIFF.php | 384 +++ .../Text_Highlighter/Text/Highlighter/DTD.php | 426 +++ .../Text/Highlighter/Generator.php | 1291 ++++++++ .../Text/Highlighter/HTML.php | 234 ++ .../Text/Highlighter/JAVA.php | 802 +++++ .../Text/Highlighter/JAVASCRIPT.php | 631 ++++ .../Text/Highlighter/MYSQL.php | 434 +++ .../Text/Highlighter/PERL.php | 1352 ++++++++ .../Text_Highlighter/Text/Highlighter/PHP.php | 1107 +++++++ .../Text/Highlighter/PYTHON.php | 647 ++++ .../Text/Highlighter/RUBY.php | 825 +++++ .../Text/Highlighter/Renderer.php | 164 + .../Text/Highlighter/Renderer/Array.php | 200 ++ .../Text/Highlighter/Renderer/BB.php | 238 ++ .../Text/Highlighter/Renderer/Console.php | 208 ++ .../Text/Highlighter/Renderer/Html.php | 465 +++ .../Text/Highlighter/Renderer/HtmlTags.php | 187 ++ .../Text/Highlighter/Renderer/JSON.php | 86 + .../Text/Highlighter/Renderer/XML.php | 104 + .../Text_Highlighter/Text/Highlighter/SH.php | 1225 +++++++ .../Text_Highlighter/Text/Highlighter/SQL.php | 419 +++ .../Text/Highlighter/VBSCRIPT.php | 318 ++ .../Text_Highlighter/Text/Highlighter/XML.php | 263 ++ library/Text_Highlighter/abap.xml | 802 +++++ library/Text_Highlighter/avrc.xml | 316 ++ library/Text_Highlighter/cpp.xml | 201 ++ library/Text_Highlighter/css.xml | 368 +++ library/Text_Highlighter/diff.xml | 45 + library/Text_Highlighter/dtd.xml | 66 + library/Text_Highlighter/generate | 171 + library/Text_Highlighter/generate.bat | 188 ++ library/Text_Highlighter/html.xml | 33 + library/Text_Highlighter/java.xml | 2824 +++++++++++++++++ library/Text_Highlighter/javascript.xml | 174 + library/Text_Highlighter/mysql.xml | 424 +++ library/Text_Highlighter/perl.xml | 439 +++ library/Text_Highlighter/php.xml | 194 ++ library/Text_Highlighter/python.xml | 229 ++ library/Text_Highlighter/release | 4 + library/Text_Highlighter/ruby.xml | 141 + library/Text_Highlighter/sample.css | 62 + library/Text_Highlighter/sh.xml | 242 ++ library/Text_Highlighter/sql.xml | 496 +++ library/Text_Highlighter/vbscript.xml | 305 ++ library/Text_Highlighter/xml.xml | 37 + view/templates/head.tpl | 1 + view/theme/frio/templates/head.tpl | 1 + 56 files changed, 23431 insertions(+) create mode 100644 library/Text_Highlighter/README create mode 100644 library/Text_Highlighter/TODO create mode 100644 library/Text_Highlighter/Text/Highlighter.php create mode 100644 library/Text_Highlighter/Text/Highlighter/ABAP.php create mode 100644 library/Text_Highlighter/Text/Highlighter/AVRC.php create mode 100644 library/Text_Highlighter/Text/Highlighter/CPP.php create mode 100644 library/Text_Highlighter/Text/Highlighter/CSS.php create mode 100644 library/Text_Highlighter/Text/Highlighter/DIFF.php create mode 100644 library/Text_Highlighter/Text/Highlighter/DTD.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Generator.php create mode 100644 library/Text_Highlighter/Text/Highlighter/HTML.php create mode 100644 library/Text_Highlighter/Text/Highlighter/JAVA.php create mode 100644 library/Text_Highlighter/Text/Highlighter/JAVASCRIPT.php create mode 100644 library/Text_Highlighter/Text/Highlighter/MYSQL.php create mode 100644 library/Text_Highlighter/Text/Highlighter/PERL.php create mode 100644 library/Text_Highlighter/Text/Highlighter/PHP.php create mode 100644 library/Text_Highlighter/Text/Highlighter/PYTHON.php create mode 100644 library/Text_Highlighter/Text/Highlighter/RUBY.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer/Array.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer/BB.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer/Console.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer/Html.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer/HtmlTags.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer/JSON.php create mode 100644 library/Text_Highlighter/Text/Highlighter/Renderer/XML.php create mode 100644 library/Text_Highlighter/Text/Highlighter/SH.php create mode 100644 library/Text_Highlighter/Text/Highlighter/SQL.php create mode 100644 library/Text_Highlighter/Text/Highlighter/VBSCRIPT.php create mode 100644 library/Text_Highlighter/Text/Highlighter/XML.php create mode 100644 library/Text_Highlighter/abap.xml create mode 100644 library/Text_Highlighter/avrc.xml create mode 100644 library/Text_Highlighter/cpp.xml create mode 100644 library/Text_Highlighter/css.xml create mode 100644 library/Text_Highlighter/diff.xml create mode 100644 library/Text_Highlighter/dtd.xml create mode 100644 library/Text_Highlighter/generate create mode 100644 library/Text_Highlighter/generate.bat create mode 100644 library/Text_Highlighter/html.xml create mode 100644 library/Text_Highlighter/java.xml create mode 100644 library/Text_Highlighter/javascript.xml create mode 100644 library/Text_Highlighter/mysql.xml create mode 100644 library/Text_Highlighter/perl.xml create mode 100644 library/Text_Highlighter/php.xml create mode 100644 library/Text_Highlighter/python.xml create mode 100644 library/Text_Highlighter/release create mode 100644 library/Text_Highlighter/ruby.xml create mode 100644 library/Text_Highlighter/sample.css create mode 100644 library/Text_Highlighter/sh.xml create mode 100644 library/Text_Highlighter/sql.xml create mode 100644 library/Text_Highlighter/vbscript.xml create mode 100644 library/Text_Highlighter/xml.xml diff --git a/include/bbcode.php b/include/bbcode.php index 62f56558f..01aae691b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -717,6 +717,13 @@ function bb_CleanPictureLinks($text) { return ($text); } +function bb_highlight($match) { + if(in_array(strtolower($match[1]),['php','css','mysql','sql','abap','diff','html','perl','ruby', + 'vbscript','avrc','dtd','java','xml','cpp','python','javascript','js','sh'])) + return text_highlight($match[2],strtolower($match[1])); + return $match[0]; +} + // BBcode 2 HTML was written by WAY2WEB.net // extended to work with Mistpark/Friendica - Mike Macgirvin @@ -769,6 +776,11 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal if (!$tryoembed) $Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text); + // Check for [code] text here, before the linefeeds are messed with. + // The highlighter will unescape and re-escape the content. + if (strpos($Text,'[code=') !== false) { + $Text = preg_replace_callback("/\[code=(.*?)\](.*?)\[\/code\]/ism", 'bb_highlight', $Text); + } // Convert new line chars to html
tags // nlbr seems to be hopelessly messed up diff --git a/include/text.php b/include/text.php index c57af1feb..16c0845ac 100644 --- a/include/text.php +++ b/include/text.php @@ -2087,3 +2087,43 @@ function format_network_name($network, $url = 0) { } } + +/** + * @brief Syntax based code highlighting for popular languages. + * @param string $s Code block + * @param string $lang Programming language + * @return string Formated html + */ +function text_highlight($s,$lang) { + if($lang === 'js') + $lang = 'javascript'; + if(! strpos('Text_Highlighter',get_include_path())) { + set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter'); + } + require_once('library/Text_Highlighter/Text/Highlighter.php'); + require_once('library/Text_Highlighter/Text/Highlighter/Renderer/Html.php'); + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 4, + ); + $tag_added = false; + $s = trim(html_entity_decode($s,ENT_COMPAT)); + $s = str_replace(" ","\t",$s); + if($lang === 'php') { + if(strpos('setRenderer($renderer); + $o = $hl->highlight($s); + $o = str_replace([" ","\n"],["    ",''],$o); + if($tag_added) { + $b = substr($o,0,strpos($o,'
  • ')); + $e = substr($o,strpos($o,'
  • ')); + $o = $b . $e; + } + return('' . $o . ''); +} diff --git a/library/Text_Highlighter/README b/library/Text_Highlighter/README new file mode 100644 index 000000000..88f71aed2 --- /dev/null +++ b/library/Text_Highlighter/README @@ -0,0 +1,455 @@ +# $Id$ + +Introduction +============ + +Text_Highlighter is a class for syntax highlighting. The main idea is to +simplify creation of subclasses implementing syntax highlighting for +particular language. Subclasses do not implement any new functioanality, they +just provide syntax highlighting rules. The rules sources are in XML format. +To create a highlighter for a language, there is no need to code a new class +manually. Simply describe the rules in XML file and use Text_Highlighter_Generator +to create a new class. + + +This document does not contain a formal description of API - it is very +simple, and I believe providing some examples of code is sufficient. + + +Highlighter XML source +====================== + +Basics +------ + +Creating a new syntax highlighter begins with describing the highlighting +rules. There are two basic elements: block and region. A block is just a +portion of text matching a regular expression and highlighted with a single +color. Keyword is an example of a block. A region is defined by two regular +expressions: one for start of region, and another for the end. The main +difference from a block is that a region can contain blocks and regions +(including same-named regions). An example of a region is a group of +statements enclosed in curly brackets (this is used in many languages, for +example PHP and C). Also, characters matching start and end of a region may be +highlighted with their own color, and region contents with another. + +Blocks and regions may be declared as contained. Contained blocks and regions +can only appear inside regions. If a region or a block is not declared as +contained, it can appear both on top level and inside regions. Block or region +declared as not-contained can only appear on top level. + +For any region, a list of blocks and regions that can appear inside this +region can be specified. + +In this document, the term "color group" is used. Chunks of text assigned to +same color group will be highlighted with same color. Note that in versions +prior 0.5.0 color goups were refered as CSS classes, but since 0.5.0 not only +HTML output is supported, so "color group" is more appropriate term. + +Elements +-------- + +The toplevel element is . Attribute lang is required and denotes +the name of the language. Its value is used as a part of generated class name, +and must only contain letters, digits and underscores. Optional attribute +case, when given value yes, makes the language case sensitive (default is case +insensitive). Allowed subelements are: + + * : Information about the authors of the file. + : Information about a single author of the file. (May be used + multiple times, one per author.) + - name="...": Author's name. Required. + - email="...": Author's email address. Optional. + + * : Default color group. + - innerGroup="...": color group name. Required. + + * : Region definition + - name="...": Region name. Required. + - innerGroup="...": Default color group of region contents. Required. + - delimGroup="...": color group of start and end of region. Optional, + defaults to value of innerGroup attribute. + - start="...", end="...": Regular expression matching start and end + of region. Required. Regular expression delimiters are optional, but + if you need to specify delimiter, use /. The only case when the + delimiters are needed, is specifying regular expression modifiers, + such as m or U. Examples: \/\* or /$/m. + - contained="yes": Marks region as contained. + - never-contained="yes": Marks region as not-contained. + - : Elements allowed inside this region. + - all="yes" Region can contain any other region or block + (except not-contained). May be used multiple times. + - Do not allow certain regions or blocks. + - region="..." Name of region not allowed within + current region. + - block="..." Name of block not allowed within + current region. + - region="..." Name of region allowed within current region. + - block="..." Name of block allowed within current region. + - Only allow this region within certain regions. May be + used multiple times. + - block="..." Name of parent region + + * : Block definition + - name="...": Block name. Required. + - innerGroup="...": color group of block contents. Optional. If not + specified, color group of parent region or default color group will be + used. One would only want to omit this attribute if there are + keyword groups (see below) inherited from this block, and no special + highlighting should apply when the block does not match the keyword. + - match="..." Regular expression matching the block. Required. + Regular expression delimiters are optional, but if you need to + specify delimiter, use /. The only case when the delimiters are + needed, is specifying regular expression modifiers, such as m or U. + Examples: #|\/\/ or /$/m. + - contained="yes": Marks block as contained. + - never-contained="yes": Marks block as not-contained. + - Only allow this block within certain regions. May be used + multiple times. + - block="..." Name of parent region + - multiline="yes": Marks block as multi-line. By default, whole + blocks are assumed to reside in a single line. This make the things + faster. If you need to declare a multi-line block, use this + attribute. + - : Assigns another color group to a part of the block that + matched a subpattern. + - index="n": Subpattern index. Required. + - innerGroup="...": color group name. Required. + + This is an example from CSS highlighter: the measure is matched as + a whole, but the measurement units are highlighted with different + color. + + + + + + + * : Keyword group definition. Keyword groups are useful when you + want to highlight some words that match a condition for a block with a + different color. Keywords are defined with literal match, not regular + expressions. For example, you have a block named identifier matching a + general identifier, and want to highlight reserved words (which match + this block as well) with different color. You inherit a keyword group + "reserved" from "identifier" block. + - name="...": Keyword group. Required. + - ifdef="...", ifndef="..." : Conditional declaration. See + "Conditions" below. + - inherits="...": Inherited block name. Required. + - innerGroup="...": color group of keyword group. Required. + - case="yes|no": Overrides case-sensitivity of the language. + Optional, defaults to global value. + - : Single keyword definition. + - match="..." The keyword. Note: this is not a regular + expression, but literal match (possibly case insensitive). + +Note that for BC reasons element partClass is alias for partGroup, and +attributes innerClass and delimClass are aliases of innerGroup and +delimGroup, respectively. + + +Conditions +---------- + +Conditional declarations allow enabling or disabling certain highlighting +rules at runtime. For example, Java highlighter has a very big list of +keywords matching Java standard classes. Finding a match in this list can take +much time. For that reason, corresponding keyword group is declared with +"ifdef" attribute : + + + + + + ... + ... + + + + + +This keyword group will be only enabled when "java.builtins" is passed as an +element of "defines" option: + + $options = array( + 'defines' => array( + 'java.builtins', + ), + 'numbers' => HL_NUMBERS_TABLE, + ); + $highlighter = Text_Highlighter::factory('java', $options); + +"ifndef" attribute has reverse meaning. + +Currently, "ifdef" and "ifndef" attributes are only supported for +tag. + + + +Class generation +================ + +Creating XML description of highlighting rules is the most complicated part of +the process. To generate the class, you need just few lines of code: + + generate(); + $generator->saveCode('PHP.php'); + ?> + + + +Command-line class generation tool +================================== + +Example from previous section looks pretty simple, but it does not handle any +errors which may occur during parsing of XML source. The package provides a +command-line script to make generation of classes even more simple, and takes +care of possible errors. It is called generate (on Unix/Linux) or generate.bat +(on Windows). This script is able to process multiple files in one run, and +also to process XML from standard input and write generated code to standard +output. + + Usage: + generate options + + Options: + -x filename, --xml=filename + source XML file. Multiple input files can be specified, in which + case each -x option must be followed by -p unless -d is specified + Defaults to stdin + -p filename, --php=filename + destination PHP file. Defaults to stdout. If specied multiple times, + each -p must follow -x + -d dirname, --dir=dirname + Default destination directory. File names will be taken from XML input + ("lang" attribute of tag) + -h, --help + This help + +Examples + + Read from php.xml, write to PHP.php + + generate -x php.xml -p PHP.php + + Read from php.xml, write to standard output + + generate -x php.xml + + Read from php.xml, write to PHP.php, read from xml.xml, write to XML.php + + generate -x php.xml -p PHP.php -x xml.xml -p XML.php + + Read from php.xml, write to /some/dir/PHP.php, read from xml.xml, write to + /some/dir/XML.php (assuming that xml.xml contains , and + php.xml contains ) + + generate -x php.xml -x xml.xml -d /some/dir/ + + + +Renderers +========= + +Introduction +------------ + +Text_Highlighter supports renderes. Using renderers, you can get output in +different formats. Two renderers are included in the package: + + - HTML renderer. Generates HTML output. A style sheet should be linked to + the document to display colored text + + - Console renderer. Can be used to output highlighted text to + color-capable terminals, either directly or trough less -r + + +Renderers API +------------- + +Renderers are subclasses of Text_Highlighter_Renderer. Renderer should +override at least two methods - acceptToken and getOutput. Overriding other +methods is optional, depending on the nature of renderer's output and details +of implementation. + + string reset() + resets renderer state. This method is called every time before a new + source file is highlighted. + + string preprocess(string $code) + preprocesses code. Can be used, for example, to normalize whitespace + before highlighting. Returns preprocessed string. + + void acceptToken(string $group, string $content) + the core method of the renderer. Highlighter passes chunks of text to + this method in $content, and color group in $group + + void finalize() + signals the renderer that no more tokens are available. + + mixed getOutput() + returns generated output. + + +Setting renderer options +-------------------------------- + +Renderers accept an optional argument to their constructor - options array. +Elements of this array are renderer-specific. + +HTML renderer +------------- + +HTML renderer produces HTML output with optional line numbering. The renderer +itself does not provide information about actual colors of highlighted text. +Instead, is used, where XXX is replaced with color group +name (hl-var, hl-string, etc.). It is up to you to create a CSS stylesheet. +If 'use_language' option with value evaluating to true was passed, class names +will be formatted as "LANG-hl-XXX", where LANG is language name as defined in +highlighter XML source ("lang" attribute of tag) in lower case. + +There are 3 special CSS classes: + + hl-main - this class applies to whole output or right table column, + depending on 'numbers' option + hl-gutter - applies to left column in table + hl-table - applies to whole table + +HTML renderer accepts following options (each being optional): + + * numbers - line numbering style. + 0 - no numbering (default) + HL_NUMBERS_LI - use
      for line numbering + HL_NUMBERS_TABLE - create a 2-column table, with line numbers in left + column and highlighted text in right column + + * tabsize - tabulation size. Defaults to 4 + + Example: + + require_once 'Text/Highlighter/Renderer/Html.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $renderer = new Text_Highlighter_Renderer_HTML($options); + +Console renderer +---------------- + +Console renderer produces output for displaying on a color-capable terminal, +either directly or through less -r, using ANSI escape sequences. By default, +this renderer only highlights most common color groups. Additional colors +can be specified using 'colors' option. This renderer also accepts 'numbers' +option - a boolean value, and 'tabsize' option. + + Example : + + require_once 'Text/Highlighter/Renderer/Console.php'; + $colors = array( + 'prepro' => "\033[35m", + 'types' => "\033[32m", + ); + $options = array( + 'numbers' => true, + 'tabsize' => 8, + 'colors' => $colors, + ); + $renderer = new Text_Highlighter_Renderer_Console($options); + + +ANSI color escape sequences have the following format: + + ESC[#;#;....;#m + +where ESC is character with ASCII code 27 (033 octal, 0x1B hexadecimal). # is +one of the following: + + 0 for normal display + 1 for bold on + 4 underline (mono only) + 5 blink on + 7 reverse video on + 8 nondisplayed (invisible) + 30 black foreground + 31 red foreground + 32 green foreground + 33 yellow foreground + 34 blue foreground + 35 magenta foreground + 36 cyan foreground + 37 white foreground + 40 black background + 41 red background + 42 green background + 43 yellow background + 44 blue background + 45 magenta background + 46 cyan background + 47 white background + + +How to use Text_Highlighter class +================================= + +Creating a highlighter object +----------------------------- + +To create a highlighter for a certain language, use Text_Highlighter::factory() +static method: + + require_once 'Text/Highlighter.php'; + $hl = Text_Highlighter::factory('php'); + + +Setting a renderer +------------------ + +Actual output is produced by a renderer. + + require_once 'Text/Highlighter.php'; + require_once 'Text/Highlighter/Renderer/Html.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $renderer = new Text_Highlighter_Renderer_HTML($options); + $hl = Text_Highlighter::factory('php'); + $hl->setRenderer($renderer); + +Note that for BC reasons, it is possible to use highlighter without setting a +renderer. If no renderer is set, HTML renderer will be used by default. In +this case, you should pass options as second parameter to factory method. The +following example works exactly as previous one: + + require_once 'Text/Highlighter.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $hl = Text_Highlighter::factory('php', $options); + + +Getting output +-------------- + +And finally, do the highlighting and get the output: + + require_once 'Text/Highlighter.php'; + require_once 'Text/Highlighter/Renderer/Html.php'; + $options = array( + 'numbers' => HL_NUMBERS_LI, + 'tabsize' => 8, + ); + $renderer = new Text_Highlighter_Renderer_HTML($options); + $hl = Text_Highlighter::factory('php'); + $hl->setRenderer($renderer); + $html = $hl->highlight(file_get_contents('example.php')); + +# vim: set autoindent tabstop=4 shiftwidth=4 softtabstop=4 tw=78: */ + diff --git a/library/Text_Highlighter/TODO b/library/Text_Highlighter/TODO new file mode 100644 index 000000000..77a148b8a --- /dev/null +++ b/library/Text_Highlighter/TODO @@ -0,0 +1,12 @@ +# $Id$ + +Major issues to solve (but I currently have no idea how) : + +- speedup highlighting process + +- switching between highlighters depending on context, for example : + PHP code -> HTML -> (JavaScript|CSS) + + +# vim: set autoindent tabstop=4 shiftwidth=4 softtabstop=4 tw=78: */ + diff --git a/library/Text_Highlighter/Text/Highlighter.php b/library/Text_Highlighter/Text/Highlighter.php new file mode 100644 index 000000000..480113c16 --- /dev/null +++ b/library/Text_Highlighter/Text/Highlighter.php @@ -0,0 +1,398 @@ + + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Highlighter + */ + +// require_once 'PEAR.php'; + +// {{{ BC constants + +// BC trick : define constants related to default +// renderer if needed +if (!defined('HL_NUMBERS_LI')) { + /**#@+ + * Constant for use with $options['numbers'] + * @see Text_Highlighter_Renderer_Html::_init() + */ + /** + * use numbered list + */ + define ('HL_NUMBERS_LI' , 1); + /** + * Use 2-column table with line numbers in left column and code in right column. + * Forces $options['tag'] = HL_TAG_PRE + */ + define ('HL_NUMBERS_TABLE' , 2); + /**#@-*/ +} + +// }}} +// {{{ constants +/** + * for our purpose, it is infinity + */ +define ('HL_INFINITY', 1000000000); + +// }}} + +/** + * Text highlighter base class + * + * @author Andrey Demenev + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Highlighter + */ + +// {{{ Text_Highlighter + +/** + * Text highlighter base class + * + * This class implements all functions necessary for highlighting, + * but it does not contain highlighting rules. Actual highlighting is + * done using a descendent of this class. + * + * One is not supposed to manually create descendent classes. + * Instead, describe highlighting rules in XML format and + * use {@link Text_Highlighter_Generator} to create descendent class. + * Alternatively, an instance of a descendent class can be created + * directly. + * + * Use {@link Text_Highlighter::factory()} to create an + * object for particular language highlighter + * + * Usage example + * + *require_once 'Text/Highlighter.php'; + *$hlSQL = Text_Highlighter::factory('SQL',array('numbers'=>true)); + *echo $hlSQL->highlight('SELECT * FROM table a WHERE id = 12'); + * + * + * @author Andrey Demenev + * @package Text_Highlighter + * @access public + */ + +class Text_Highlighter +{ + // {{{ members + + /** + * Syntax highlighting rules. + * Auto-generated classes set this var + * + * @access protected + * @see _init + * @var array + */ + var $_syntax; + + /** + * Renderer object. + * + * @access private + * @var array + */ + var $_renderer; + + /** + * Options. Keeped for BC + * + * @access protected + * @var array + */ + var $_options = array(); + + /** + * Conditionds + * + * @access protected + * @var array + */ + var $_conditions = array(); + + /** + * Disabled keywords + * + * @access protected + * @var array + */ + var $_disabled = array(); + + /** + * Language + * + * @access protected + * @var string + */ + var $_language = ''; + + // }}} + // {{{ _checkDefines + + /** + * Called by subclssses' constructors to enable/disable + * optional highlighter rules + * + * @param array $defines Conditional defines + * + * @access protected + */ + function _checkDefines() + { + if (isset($this->_options['defines'])) { + $defines = $this->_options['defines']; + } else { + $defines = array(); + } + foreach ($this->_conditions as $name => $actions) { + foreach($actions as $action) { + $present = in_array($name, $defines); + if (!$action[1]) { + $present = !$present; + } + if ($present) { + unset($this->_disabled[$action[0]]); + } else { + $this->_disabled[$action[0]] = true; + } + } + } + } + + // }}} + // {{{ factory + + /** + * Create a new Highlighter object for specified language + * + * @param string $lang language, for example "SQL" + * @param array $options Rendering options. This + * parameter is only keeped for BC reasons, use + * {@link Text_Highlighter::setRenderer()} instead + * + * @return mixed a newly created Highlighter object, or + * a PEAR error object on error + * + * @static + * @access public + */ + function &factory($lang, $options = array()) + { + $lang = strtoupper($lang); + @include_once 'Text/Highlighter/' . $lang . '.php'; + + $classname = 'Text_Highlighter_' . $lang; + + if (!class_exists($classname)) { + return PEAR::raiseError('Highlighter for ' . $lang . ' not found'); + } + + $obj = new $classname($options); + + return $obj; + } + + // }}} + // {{{ setRenderer + + /** + * Set renderer object + * + * @param object $renderer Text_Highlighter_Renderer + * + * @access public + */ + function setRenderer(&$renderer) + { + $this->_renderer = $renderer; + } + + // }}} + + /** + * Helper function to find matching brackets + * + * @access private + */ + function _matchingBrackets($str) + { + return strtr($str, '()<>[]{}', ')(><][}{'); + } + + + + + function _getToken() + { + if (!empty($this->_tokenStack)) { + return array_pop($this->_tokenStack); + } + if ($this->_pos >= $this->_len) { + return NULL; + } + + if ($this->_state != -1 && preg_match($this->_endpattern, $this->_str, $m, PREG_OFFSET_CAPTURE, $this->_pos)) { + $endpos = $m[0][1]; + $endmatch = $m[0][0]; + } else { + $endpos = -1; + } + preg_match ($this->_regs[$this->_state], $this->_str, $m, PREG_OFFSET_CAPTURE, $this->_pos); + $n = 1; + + + foreach ($this->_counts[$this->_state] as $i=>$count) { + if (!isset($m[$n])) { + break; + } + if ($m[$n][1]>-1 && ($endpos == -1 || $m[$n][1] < $endpos)) { + if ($this->_states[$this->_state][$i] != -1) { + $this->_tokenStack[] = array($this->_delim[$this->_state][$i], $m[$n][0]); + } else { + $inner = $this->_inner[$this->_state][$i]; + if (isset($this->_parts[$this->_state][$i])) { + $parts = array(); + $partpos = $m[$n][1]; + for ($j=1; $j<=$count; $j++) { + if ($m[$j+$n][1] < 0) { + continue; + } + if (isset($this->_parts[$this->_state][$i][$j])) { + if ($m[$j+$n][1] > $partpos) { + array_unshift($parts, array($inner, substr($this->_str, $partpos, $m[$j+$n][1]-$partpos))); + } + array_unshift($parts, array($this->_parts[$this->_state][$i][$j], $m[$j+$n][0])); + } + $partpos = $m[$j+$n][1] + strlen($m[$j+$n][0]); + } + if ($partpos < $m[$n][1] + strlen($m[$n][0])) { + array_unshift($parts, array($inner, substr($this->_str, $partpos, $m[$n][1] - $partpos + strlen($m[$n][0])))); + } + $this->_tokenStack = array_merge($this->_tokenStack, $parts); + } else { + foreach ($this->_keywords[$this->_state][$i] as $g => $re) { + if (isset($this->_disabled[$g])) { + continue; + } + if (preg_match($re, $m[$n][0])) { + $inner = $this->_kwmap[$g]; + break; + } + } + $this->_tokenStack[] = array($inner, $m[$n][0]); + } + } + if ($m[$n][1] > $this->_pos) { + $this->_tokenStack[] = array($this->_lastinner, substr($this->_str, $this->_pos, $m[$n][1]-$this->_pos)); + } + $this->_pos = $m[$n][1] + strlen($m[$n][0]); + if ($this->_states[$this->_state][$i] != -1) { + $this->_stack[] = array($this->_state, $this->_lastdelim, $this->_lastinner, $this->_endpattern); + $this->_lastinner = $this->_inner[$this->_state][$i]; + $this->_lastdelim = $this->_delim[$this->_state][$i]; + $l = $this->_state; + $this->_state = $this->_states[$this->_state][$i]; + $this->_endpattern = $this->_end[$this->_state]; + if ($this->_subst[$l][$i]) { + for ($k=0; $k<=$this->_counts[$l][$i]; $k++) { + if (!isset($m[$i+$k])) { + break; + } + $quoted = preg_quote($m[$n+$k][0], '/'); + $this->_endpattern = str_replace('%'.$k.'%', $quoted, $this->_endpattern); + $this->_endpattern = str_replace('%b'.$k.'%', $this->_matchingBrackets($quoted), $this->_endpattern); + } + } + } + return array_pop($this->_tokenStack); + } + $n += $count + 1; + } + + if ($endpos > -1) { + $this->_tokenStack[] = array($this->_lastdelim, $endmatch); + if ($endpos > $this->_pos) { + $this->_tokenStack[] = array($this->_lastinner, substr($this->_str, $this->_pos, $endpos-$this->_pos)); + } + list($this->_state, $this->_lastdelim, $this->_lastinner, $this->_endpattern) = array_pop($this->_stack); + $this->_pos = $endpos + strlen($endmatch); + return array_pop($this->_tokenStack); + } + $p = $this->_pos; + $this->_pos = HL_INFINITY; + return array($this->_lastinner, substr($this->_str, $p)); + } + + + + + // {{{ highlight + + /** + * Highlights code + * + * @param string $str Code to highlight + * @access public + * @return string Highlighted text + * + */ + + function highlight($str) + { + if (!($this->_renderer)) { + include_once('Text/Highlighter/Renderer/Html.php'); + $this->_renderer = new Text_Highlighter_Renderer_Html($this->_options); + } + $this->_state = -1; + $this->_pos = 0; + $this->_stack = array(); + $this->_tokenStack = array(); + $this->_lastinner = $this->_defClass; + $this->_lastdelim = $this->_defClass; + $this->_endpattern = ''; + $this->_renderer->reset(); + $this->_renderer->setCurrentLanguage($this->_language); + $this->_str = $this->_renderer->preprocess($str); + $this->_len = strlen($this->_str); + while ($token = $this->_getToken()) { + $this->_renderer->acceptToken($token[0], $token[1]); + } + $this->_renderer->finalize(); + return $this->_renderer->getOutput(); + } + + // }}} + +} + +// }}} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * c-hanging-comment-ender-p: nil + * End: + */ + +?> diff --git a/library/Text_Highlighter/Text/Highlighter/ABAP.php b/library/Text_Highlighter/Text/Highlighter/ABAP.php new file mode 100644 index 000000000..b2f7bda94 --- /dev/null +++ b/library/Text_Highlighter/Text/Highlighter/ABAP.php @@ -0,0 +1,519 @@ + + * + */ + +/** + * @ignore + */ + +require_once 'Text/Highlighter.php'; + +/** + * Auto-generated class. ABAP syntax highlighting + * + * @author Stoyan Stefanov + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Highlighter + */ +class Text_Highlighter_ABAP extends Text_Highlighter +{ + var $_language = 'abap'; + + /** + * PHP4 Compatible Constructor + * + * @param array $options + * @access public + */ + function Text_Highlighter_ABAP($options=array()) + { + $this->__construct($options); + } + + + /** + * Constructor + * + * @param array $options + * @access public + */ + function __construct($options=array()) + { + + $this->_options = $options; + $this->_regs = array ( + -1 => '/((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)^\\*|")|((?i)\')|((?i)[a-z_\\-]\\w*)/', + 0 => '/((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)^\\*|")|((?i)\')|((?i)0[xX][\\da-f]+)|((?i)\\d\\d*|\\b0\\b)|((?i)0[0-7]+)|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)[a-z_\\-]\\w*)/', + 1 => '/((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)^\\*|")|((?i)\')|((?i)0[xX][\\da-f]+)|((?i)\\d\\d*|\\b0\\b)|((?i)0[0-7]+)|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)[a-z_\\-]\\w*)/', + 2 => '/((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)^\\*|")|((?i)\')|((?i)0[xX][\\da-f]+)|((?i)\\d\\d*|\\b0\\b)|((?i)0[0-7]+)|((?i)(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)[a-z_\\-]\\w*)/', + 3 => '//', + 4 => '//', + ); + $this->_counts = array ( + -1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + ), + 0 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + ), + 1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + ), + 2 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_delim = array ( + -1 => + array ( + 0 => 'brackets', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'comment', + 4 => 'quotes', + 5 => '', + ), + 0 => + array ( + 0 => 'brackets', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'comment', + 4 => 'quotes', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => '', + ), + 1 => + array ( + 0 => 'brackets', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'comment', + 4 => 'quotes', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => '', + ), + 2 => + array ( + 0 => 'brackets', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'comment', + 4 => 'quotes', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => '', + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_inner = array ( + -1 => + array ( + 0 => 'code', + 1 => 'code', + 2 => 'code', + 3 => 'comment', + 4 => 'string', + 5 => 'identifier', + ), + 0 => + array ( + 0 => 'code', + 1 => 'code', + 2 => 'code', + 3 => 'comment', + 4 => 'string', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'identifier', + ), + 1 => + array ( + 0 => 'code', + 1 => 'code', + 2 => 'code', + 3 => 'comment', + 4 => 'string', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'identifier', + ), + 2 => + array ( + 0 => 'code', + 1 => 'code', + 2 => 'code', + 3 => 'comment', + 4 => 'string', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'identifier', + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_end = array ( + 0 => '/(?i)\\}/', + 1 => '/(?i)\\)/', + 2 => '/(?i)\\]/', + 3 => '/(?mi)$/', + 4 => '/(?i)\'/', + ); + $this->_states = array ( + -1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => -1, + ), + 0 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => -1, + ), + 1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => -1, + ), + 2 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => 4, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => -1, + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_keywords = array ( + -1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => -1, + 5 => + array ( + 'sy' => '/^((?i)screen-name|screen-group1|screen-group2|screen-group3|screen-group4|screen-required|screen-input|screen-output|screen-intensified|screen-invisible|screen-length|screen-active|sy-index|sy-pagno|sy-tabix|sy-tfill|sy-tlopc|sy-tmaxl|sy-toccu|sy-ttabc|sy-tstis|sy-ttabi|sy-dbcnt|sy-fdpos|sy-colno|sy-linct|sy-linno|sy-linsz|sy-pagct|sy-macol|sy-marow|sy-tleng|sy-sfoff|sy-willi|sy-lilli|sy-subrc|sy-fleng|sy-cucol|sy-curow|sy-lsind|sy-listi|sy-stepl|sy-tpagi|sy-winx1|sy-winy1|sy-winx2|sy-winy2|sy-winco|sy-winro|sy-windi|sy-srows|sy-scols|sy-loopc|sy-folen|sy-fodec|sy-tzone|sy-dayst|sy-ftype|sy-appli|sy-fdayw|sy-ccurs|sy-ccurt|sy-debug|sy-ctype|sy-input|sy-langu|sy-modno|sy-batch|sy-binpt|sy-calld|sy-dynnr|sy-dyngr|sy-newpa|sy-pri40|sy-rstrt|sy-wtitl|sy-cpage|sy-dbnam|sy-mandt|sy-prefx|sy-fmkey|sy-pexpi|sy-prini|sy-primm|sy-prrel|sy-playo|sy-prbig|sy-playp|sy-prnew|sy-prlog|sy-pdest|sy-plist|sy-pauth|sy-prdsn|sy-pnwpa|sy-callr|sy-repi2|sy-rtitl|sy-prrec|sy-prtxt|sy-prabt|sy-lpass|sy-nrpag|sy-paart|sy-prcop|sy-batzs|sy-bspld|sy-brep4|sy-batzo|sy-batzd|sy-batzw|sy-batzm|sy-ctabl|sy-dbsys|sy-dcsys|sy-macdb|sy-sysid|sy-opsys|sy-pfkey|sy-saprl|sy-tcode|sy-ucomm|sy-cfwae|sy-chwae|sy-spono|sy-sponr|sy-waers|sy-cdate|sy-datum|sy-slset|sy-subty|sy-subcs|sy-group|sy-ffile|sy-uzeit|sy-dsnam|sy-repid|sy-tabid|sy-tfdsn|sy-uname|sy-lstat|sy-abcde|sy-marky|sy-sfnam|sy-tname|sy-msgli|sy-title|sy-entry|sy-lisel|sy-uline|sy-xcode|sy-cprog|sy-xprog|sy-xform|sy-ldbpg|sy-tvar0|sy-tvar1|sy-tvar2|sy-tvar3|sy-tvar4|sy-tvar5|sy-tvar6|sy-tvar7|sy-tvar8|sy-tvar9|sy-msgid|sy-msgty|sy-msgno|sy-msgv1|sy-msgv2|sy-msgv3|sy-msgv4|sy-oncom|sy-vline|sy-winsl|sy-staco|sy-staro|sy-datar|sy-host|sy-locdb|sy-locop|sy-datlo|sy-timlo|sy-zonlo|syst-index|syst-pagno|syst-tabix|syst-tfill|syst-tlopc|syst-tmaxl|syst-toccu|syst-ttabc|syst-tstis|syst-ttabi|syst-dbcnt|syst-fdpos|syst-colno|syst-linct|syst-linno|syst-linsz|syst-pagct|syst-macol|syst-marow|syst-tleng|syst-sfoff|syst-willi|syst-lilli|syst-subrc|syst-fleng|syst-cucol|syst-curow|syst-lsind|syst-listi|syst-stepl|syst-tpagi|syst-winx1|syst-winy1|syst-winx2|syst-winy2|syst-winco|syst-winro|syst-windi|syst-srows|syst-scols|syst-loopc|syst-folen|syst-fodec|syst-tzone|syst-dayst|syst-ftype|syst-appli|syst-fdayw|syst-ccurs|syst-ccurt|syst-debug|syst-ctype|syst-input|syst-langu|syst-modno|syst-batch|syst-binpt|syst-calld|syst-dynnr|syst-dyngr|syst-newpa|syst-pri40|syst-rstrt|syst-wtitl|syst-cpage|syst-dbnam|syst-mandt|syst-prefx|syst-fmkey|syst-pexpi|syst-prini|syst-primm|syst-prrel|syst-playo|syst-prbig|syst-playp|syst-prnew|syst-prlog|syst-pdest|syst-plist|syst-pauth|syst-prdsn|syst-pnwpa|syst-callr|syst-repi2|syst-rtitl|syst-prrec|syst-prtxt|syst-prabt|syst-lpass|syst-nrpag|syst-paart|syst-prcop|syst-batzs|syst-bspld|syst-brep4|syst-batzo|syst-batzd|syst-batzw|syst-batzm|syst-ctabl|syst-dbsys|syst-dcsys|syst-macdb|syst-sysid|syst-opsys|syst-pfkey|syst-saprl|syst-tcode|syst-ucomm|syst-cfwae|syst-chwae|syst-spono|syst-sponr|syst-waers|syst-cdate|syst-datum|syst-slset|syst-subty|syst-subcs|syst-group|syst-ffile|syst-uzeit|syst-dsnam|syst-repid|syst-tabid|syst-tfdsn|syst-uname|syst-lstat|syst-abcde|syst-marky|syst-sfnam|syst-tname|syst-msgli|syst-title|syst-entry|syst-lisel|syst-uline|syst-xcode|syst-cprog|syst-xprog|syst-xform|syst-ldbpg|syst-tvar0|syst-tvar1|syst-tvar2|syst-tvar3|syst-tvar4|syst-tvar5|syst-tvar6|syst-tvar7|syst-tvar8|syst-tvar9|syst-msgid|syst-msgty|syst-msgno|syst-msgv1|syst-msgv2|syst-msgv3|syst-msgv4|syst-oncom|syst-vline|syst-winsl|syst-staco|syst-staro|syst-datar|syst-host|syst-locdb|syst-locop|syst-datlo|syst-timlo|syst-zonlo)$/', + 'reserved' => '/^((?i)abs|acos|add|add-corresponding|adjacent|after|aliases|all|analyzer|and|any|append|as|ascending|asin|assign|assigned|assigning|at|atan|authority-check|avg|back|before|begin|binary|bit|bit-and|bit-not|bit-or|bit-xor|blank|block|break-point|buffer|by|c|call|case|catch|ceil|centered|chain|change|changing|check|checkbox|class|class-data|class-events|class-methods|class-pool|clear|client|close|cnt|code|collect|color|comment|commit|communication|compute|concatenate|condense|constants|context|contexts|continue|control|controls|convert|copy|corresponding|cos|cosh|count|country|create|currency|cursor|customer-function|data|database|dataset|delete|decimals|default|define|demand|descending|describe|dialog|distinct|div|divide|divide-corresponding|do|duplicates|dynpro|edit|editor-call|else|elseif|end|end-of-definition|end-of-page|end-of-selection|endat|endcase|endcatch|endchain|endclass|enddo|endexec|endform|endfunction|endif|endinterface|endloop|endmethod|endmodule|endon|endprovide|endselect|endwhile|entries|events|exec|exit|exit-command|exp|exponent|export|exporting|exceptions|extended|extract|fetch|field|field-groups|field-symbols|fields|floor|for|form|format|frac|frame|free|from|function|function-pool|generate|get|group|hashed|header|help-id|help-request|hide|hotspot|icon|id|if|import|importing|include|index|infotypes|initialization|inner|input|insert|intensified|interface|interface-pool|interfaces|into|inverse|join|key|language|last|leave|left|left-justified|like|line|line-count|line-selection|line-size|lines|list-processing|load|load-of-program|local|locale|log|log10|loop|m|margin|mask|matchcode|max|memory|message|message-id|messages|method|methods|min|mod|mode|modif|modify|module|move|move-corresponding|multiply|multiply-corresponding|new|new-line|new-page|next|no|no-gap|no-gaps|no-heading|no-scrolling|no-sign|no-title|no-zero|nodes|non-unique|o|object|obligatory|occurs|of|off|on|open|or|order|others|outer|output|overlay|pack|page|parameter|parameters|perform|pf-status|position|print|print-control|private|process|program|property|protected|provide|public|put|radiobutton|raise|raising|range|ranges|read|receive|refresh|reject|replace|report|requested|reserve|reset|right-justified|rollback|round|rows|rtti|run|scan|screen|search|separated|scroll|scroll-boundary|select|select-options|selection-screen|selection-table|set|shared|shift|sign|sin|single|sinh|size|skip|sort|sorted|split|sql|sqrt|stamp|standard|start-of-selection|statics|stop|string|strlen|structure|submit|subtract|subtract-corresponding|sum|supply|suppress|symbol|syntax-check|syntax-trace|system-call|system-exceptions|table|table_line|tables|tan|tanh|text|textpool|time|times|title|titlebar|to|top-of-page|transaction|transfer|translate|transporting|trunc|type|type-pool|type-pools|types|uline|under|unique|unit|unpack|up|update|user-command|using|value|value-request|values|vary|when|where|while|window|with|with-title|work|write|x|xstring|z|zone)$/', + 'constants' => '/^((?i)initial|null|space|col_background|col_heading|col_normal|col_total|col_key|col_positive|col_negative|col_group)$/', + ), + ), + 0 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => -1, + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => + array ( + 'sy' => '/^((?i)screen-name|screen-group1|screen-group2|screen-group3|screen-group4|screen-required|screen-input|screen-output|screen-intensified|screen-invisible|screen-length|screen-active|sy-index|sy-pagno|sy-tabix|sy-tfill|sy-tlopc|sy-tmaxl|sy-toccu|sy-ttabc|sy-tstis|sy-ttabi|sy-dbcnt|sy-fdpos|sy-colno|sy-linct|sy-linno|sy-linsz|sy-pagct|sy-macol|sy-marow|sy-tleng|sy-sfoff|sy-willi|sy-lilli|sy-subrc|sy-fleng|sy-cucol|sy-curow|sy-lsind|sy-listi|sy-stepl|sy-tpagi|sy-winx1|sy-winy1|sy-winx2|sy-winy2|sy-winco|sy-winro|sy-windi|sy-srows|sy-scols|sy-loopc|sy-folen|sy-fodec|sy-tzone|sy-dayst|sy-ftype|sy-appli|sy-fdayw|sy-ccurs|sy-ccurt|sy-debug|sy-ctype|sy-input|sy-langu|sy-modno|sy-batch|sy-binpt|sy-calld|sy-dynnr|sy-dyngr|sy-newpa|sy-pri40|sy-rstrt|sy-wtitl|sy-cpage|sy-dbnam|sy-mandt|sy-prefx|sy-fmkey|sy-pexpi|sy-prini|sy-primm|sy-prrel|sy-playo|sy-prbig|sy-playp|sy-prnew|sy-prlog|sy-pdest|sy-plist|sy-pauth|sy-prdsn|sy-pnwpa|sy-callr|sy-repi2|sy-rtitl|sy-prrec|sy-prtxt|sy-prabt|sy-lpass|sy-nrpag|sy-paart|sy-prcop|sy-batzs|sy-bspld|sy-brep4|sy-batzo|sy-batzd|sy-batzw|sy-batzm|sy-ctabl|sy-dbsys|sy-dcsys|sy-macdb|sy-sysid|sy-opsys|sy-pfkey|sy-saprl|sy-tcode|sy-ucomm|sy-cfwae|sy-chwae|sy-spono|sy-sponr|sy-waers|sy-cdate|sy-datum|sy-slset|sy-subty|sy-subcs|sy-group|sy-ffile|sy-uzeit|sy-dsnam|sy-repid|sy-tabid|sy-tfdsn|sy-uname|sy-lstat|sy-abcde|sy-marky|sy-sfnam|sy-tname|sy-msgli|sy-title|sy-entry|sy-lisel|sy-uline|sy-xcode|sy-cprog|sy-xprog|sy-xform|sy-ldbpg|sy-tvar0|sy-tvar1|sy-tvar2|sy-tvar3|sy-tvar4|sy-tvar5|sy-tvar6|sy-tvar7|sy-tvar8|sy-tvar9|sy-msgid|sy-msgty|sy-msgno|sy-msgv1|sy-msgv2|sy-msgv3|sy-msgv4|sy-oncom|sy-vline|sy-winsl|sy-staco|sy-staro|sy-datar|sy-host|sy-locdb|sy-locop|sy-datlo|sy-timlo|sy-zonlo|syst-index|syst-pagno|syst-tabix|syst-tfill|syst-tlopc|syst-tmaxl|syst-toccu|syst-ttabc|syst-tstis|syst-ttabi|syst-dbcnt|syst-fdpos|syst-colno|syst-linct|syst-linno|syst-linsz|syst-pagct|syst-macol|syst-marow|syst-tleng|syst-sfoff|syst-willi|syst-lilli|syst-subrc|syst-fleng|syst-cucol|syst-curow|syst-lsind|syst-listi|syst-stepl|syst-tpagi|syst-winx1|syst-winy1|syst-winx2|syst-winy2|syst-winco|syst-winro|syst-windi|syst-srows|syst-scols|syst-loopc|syst-folen|syst-fodec|syst-tzone|syst-dayst|syst-ftype|syst-appli|syst-fdayw|syst-ccurs|syst-ccurt|syst-debug|syst-ctype|syst-input|syst-langu|syst-modno|syst-batch|syst-binpt|syst-calld|syst-dynnr|syst-dyngr|syst-newpa|syst-pri40|syst-rstrt|syst-wtitl|syst-cpage|syst-dbnam|syst-mandt|syst-prefx|syst-fmkey|syst-pexpi|syst-prini|syst-primm|syst-prrel|syst-playo|syst-prbig|syst-playp|syst-prnew|syst-prlog|syst-pdest|syst-plist|syst-pauth|syst-prdsn|syst-pnwpa|syst-callr|syst-repi2|syst-rtitl|syst-prrec|syst-prtxt|syst-prabt|syst-lpass|syst-nrpag|syst-paart|syst-prcop|syst-batzs|syst-bspld|syst-brep4|syst-batzo|syst-batzd|syst-batzw|syst-batzm|syst-ctabl|syst-dbsys|syst-dcsys|syst-macdb|syst-sysid|syst-opsys|syst-pfkey|syst-saprl|syst-tcode|syst-ucomm|syst-cfwae|syst-chwae|syst-spono|syst-sponr|syst-waers|syst-cdate|syst-datum|syst-slset|syst-subty|syst-subcs|syst-group|syst-ffile|syst-uzeit|syst-dsnam|syst-repid|syst-tabid|syst-tfdsn|syst-uname|syst-lstat|syst-abcde|syst-marky|syst-sfnam|syst-tname|syst-msgli|syst-title|syst-entry|syst-lisel|syst-uline|syst-xcode|syst-cprog|syst-xprog|syst-xform|syst-ldbpg|syst-tvar0|syst-tvar1|syst-tvar2|syst-tvar3|syst-tvar4|syst-tvar5|syst-tvar6|syst-tvar7|syst-tvar8|syst-tvar9|syst-msgid|syst-msgty|syst-msgno|syst-msgv1|syst-msgv2|syst-msgv3|syst-msgv4|syst-oncom|syst-vline|syst-winsl|syst-staco|syst-staro|syst-datar|syst-host|syst-locdb|syst-locop|syst-datlo|syst-timlo|syst-zonlo)$/', + 'reserved' => '/^((?i)abs|acos|add|add-corresponding|adjacent|after|aliases|all|analyzer|and|any|append|as|ascending|asin|assign|assigned|assigning|at|atan|authority-check|avg|back|before|begin|binary|bit|bit-and|bit-not|bit-or|bit-xor|blank|block|break-point|buffer|by|c|call|case|catch|ceil|centered|chain|change|changing|check|checkbox|class|class-data|class-events|class-methods|class-pool|clear|client|close|cnt|code|collect|color|comment|commit|communication|compute|concatenate|condense|constants|context|contexts|continue|control|controls|convert|copy|corresponding|cos|cosh|count|country|create|currency|cursor|customer-function|data|database|dataset|delete|decimals|default|define|demand|descending|describe|dialog|distinct|div|divide|divide-corresponding|do|duplicates|dynpro|edit|editor-call|else|elseif|end|end-of-definition|end-of-page|end-of-selection|endat|endcase|endcatch|endchain|endclass|enddo|endexec|endform|endfunction|endif|endinterface|endloop|endmethod|endmodule|endon|endprovide|endselect|endwhile|entries|events|exec|exit|exit-command|exp|exponent|export|exporting|exceptions|extended|extract|fetch|field|field-groups|field-symbols|fields|floor|for|form|format|frac|frame|free|from|function|function-pool|generate|get|group|hashed|header|help-id|help-request|hide|hotspot|icon|id|if|import|importing|include|index|infotypes|initialization|inner|input|insert|intensified|interface|interface-pool|interfaces|into|inverse|join|key|language|last|leave|left|left-justified|like|line|line-count|line-selection|line-size|lines|list-processing|load|load-of-program|local|locale|log|log10|loop|m|margin|mask|matchcode|max|memory|message|message-id|messages|method|methods|min|mod|mode|modif|modify|module|move|move-corresponding|multiply|multiply-corresponding|new|new-line|new-page|next|no|no-gap|no-gaps|no-heading|no-scrolling|no-sign|no-title|no-zero|nodes|non-unique|o|object|obligatory|occurs|of|off|on|open|or|order|others|outer|output|overlay|pack|page|parameter|parameters|perform|pf-status|position|print|print-control|private|process|program|property|protected|provide|public|put|radiobutton|raise|raising|range|ranges|read|receive|refresh|reject|replace|report|requested|reserve|reset|right-justified|rollback|round|rows|rtti|run|scan|screen|search|separated|scroll|scroll-boundary|select|select-options|selection-screen|selection-table|set|shared|shift|sign|sin|single|sinh|size|skip|sort|sorted|split|sql|sqrt|stamp|standard|start-of-selection|statics|stop|string|strlen|structure|submit|subtract|subtract-corresponding|sum|supply|suppress|symbol|syntax-check|syntax-trace|system-call|system-exceptions|table|table_line|tables|tan|tanh|text|textpool|time|times|title|titlebar|to|top-of-page|transaction|transfer|translate|transporting|trunc|type|type-pool|type-pools|types|uline|under|unique|unit|unpack|up|update|user-command|using|value|value-request|values|vary|when|where|while|window|with|with-title|work|write|x|xstring|z|zone)$/', + 'constants' => '/^((?i)initial|null|space|col_background|col_heading|col_normal|col_total|col_key|col_positive|col_negative|col_group)$/', + ), + ), + 1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => -1, + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => + array ( + 'sy' => '/^((?i)screen-name|screen-group1|screen-group2|screen-group3|screen-group4|screen-required|screen-input|screen-output|screen-intensified|screen-invisible|screen-length|screen-active|sy-index|sy-pagno|sy-tabix|sy-tfill|sy-tlopc|sy-tmaxl|sy-toccu|sy-ttabc|sy-tstis|sy-ttabi|sy-dbcnt|sy-fdpos|sy-colno|sy-linct|sy-linno|sy-linsz|sy-pagct|sy-macol|sy-marow|sy-tleng|sy-sfoff|sy-willi|sy-lilli|sy-subrc|sy-fleng|sy-cucol|sy-curow|sy-lsind|sy-listi|sy-stepl|sy-tpagi|sy-winx1|sy-winy1|sy-winx2|sy-winy2|sy-winco|sy-winro|sy-windi|sy-srows|sy-scols|sy-loopc|sy-folen|sy-fodec|sy-tzone|sy-dayst|sy-ftype|sy-appli|sy-fdayw|sy-ccurs|sy-ccurt|sy-debug|sy-ctype|sy-input|sy-langu|sy-modno|sy-batch|sy-binpt|sy-calld|sy-dynnr|sy-dyngr|sy-newpa|sy-pri40|sy-rstrt|sy-wtitl|sy-cpage|sy-dbnam|sy-mandt|sy-prefx|sy-fmkey|sy-pexpi|sy-prini|sy-primm|sy-prrel|sy-playo|sy-prbig|sy-playp|sy-prnew|sy-prlog|sy-pdest|sy-plist|sy-pauth|sy-prdsn|sy-pnwpa|sy-callr|sy-repi2|sy-rtitl|sy-prrec|sy-prtxt|sy-prabt|sy-lpass|sy-nrpag|sy-paart|sy-prcop|sy-batzs|sy-bspld|sy-brep4|sy-batzo|sy-batzd|sy-batzw|sy-batzm|sy-ctabl|sy-dbsys|sy-dcsys|sy-macdb|sy-sysid|sy-opsys|sy-pfkey|sy-saprl|sy-tcode|sy-ucomm|sy-cfwae|sy-chwae|sy-spono|sy-sponr|sy-waers|sy-cdate|sy-datum|sy-slset|sy-subty|sy-subcs|sy-group|sy-ffile|sy-uzeit|sy-dsnam|sy-repid|sy-tabid|sy-tfdsn|sy-uname|sy-lstat|sy-abcde|sy-marky|sy-sfnam|sy-tname|sy-msgli|sy-title|sy-entry|sy-lisel|sy-uline|sy-xcode|sy-cprog|sy-xprog|sy-xform|sy-ldbpg|sy-tvar0|sy-tvar1|sy-tvar2|sy-tvar3|sy-tvar4|sy-tvar5|sy-tvar6|sy-tvar7|sy-tvar8|sy-tvar9|sy-msgid|sy-msgty|sy-msgno|sy-msgv1|sy-msgv2|sy-msgv3|sy-msgv4|sy-oncom|sy-vline|sy-winsl|sy-staco|sy-staro|sy-datar|sy-host|sy-locdb|sy-locop|sy-datlo|sy-timlo|sy-zonlo|syst-index|syst-pagno|syst-tabix|syst-tfill|syst-tlopc|syst-tmaxl|syst-toccu|syst-ttabc|syst-tstis|syst-ttabi|syst-dbcnt|syst-fdpos|syst-colno|syst-linct|syst-linno|syst-linsz|syst-pagct|syst-macol|syst-marow|syst-tleng|syst-sfoff|syst-willi|syst-lilli|syst-subrc|syst-fleng|syst-cucol|syst-curow|syst-lsind|syst-listi|syst-stepl|syst-tpagi|syst-winx1|syst-winy1|syst-winx2|syst-winy2|syst-winco|syst-winro|syst-windi|syst-srows|syst-scols|syst-loopc|syst-folen|syst-fodec|syst-tzone|syst-dayst|syst-ftype|syst-appli|syst-fdayw|syst-ccurs|syst-ccurt|syst-debug|syst-ctype|syst-input|syst-langu|syst-modno|syst-batch|syst-binpt|syst-calld|syst-dynnr|syst-dyngr|syst-newpa|syst-pri40|syst-rstrt|syst-wtitl|syst-cpage|syst-dbnam|syst-mandt|syst-prefx|syst-fmkey|syst-pexpi|syst-prini|syst-primm|syst-prrel|syst-playo|syst-prbig|syst-playp|syst-prnew|syst-prlog|syst-pdest|syst-plist|syst-pauth|syst-prdsn|syst-pnwpa|syst-callr|syst-repi2|syst-rtitl|syst-prrec|syst-prtxt|syst-prabt|syst-lpass|syst-nrpag|syst-paart|syst-prcop|syst-batzs|syst-bspld|syst-brep4|syst-batzo|syst-batzd|syst-batzw|syst-batzm|syst-ctabl|syst-dbsys|syst-dcsys|syst-macdb|syst-sysid|syst-opsys|syst-pfkey|syst-saprl|syst-tcode|syst-ucomm|syst-cfwae|syst-chwae|syst-spono|syst-sponr|syst-waers|syst-cdate|syst-datum|syst-slset|syst-subty|syst-subcs|syst-group|syst-ffile|syst-uzeit|syst-dsnam|syst-repid|syst-tabid|syst-tfdsn|syst-uname|syst-lstat|syst-abcde|syst-marky|syst-sfnam|syst-tname|syst-msgli|syst-title|syst-entry|syst-lisel|syst-uline|syst-xcode|syst-cprog|syst-xprog|syst-xform|syst-ldbpg|syst-tvar0|syst-tvar1|syst-tvar2|syst-tvar3|syst-tvar4|syst-tvar5|syst-tvar6|syst-tvar7|syst-tvar8|syst-tvar9|syst-msgid|syst-msgty|syst-msgno|syst-msgv1|syst-msgv2|syst-msgv3|syst-msgv4|syst-oncom|syst-vline|syst-winsl|syst-staco|syst-staro|syst-datar|syst-host|syst-locdb|syst-locop|syst-datlo|syst-timlo|syst-zonlo)$/', + 'reserved' => '/^((?i)abs|acos|add|add-corresponding|adjacent|after|aliases|all|analyzer|and|any|append|as|ascending|asin|assign|assigned|assigning|at|atan|authority-check|avg|back|before|begin|binary|bit|bit-and|bit-not|bit-or|bit-xor|blank|block|break-point|buffer|by|c|call|case|catch|ceil|centered|chain|change|changing|check|checkbox|class|class-data|class-events|class-methods|class-pool|clear|client|close|cnt|code|collect|color|comment|commit|communication|compute|concatenate|condense|constants|context|contexts|continue|control|controls|convert|copy|corresponding|cos|cosh|count|country|create|currency|cursor|customer-function|data|database|dataset|delete|decimals|default|define|demand|descending|describe|dialog|distinct|div|divide|divide-corresponding|do|duplicates|dynpro|edit|editor-call|else|elseif|end|end-of-definition|end-of-page|end-of-selection|endat|endcase|endcatch|endchain|endclass|enddo|endexec|endform|endfunction|endif|endinterface|endloop|endmethod|endmodule|endon|endprovide|endselect|endwhile|entries|events|exec|exit|exit-command|exp|exponent|export|exporting|exceptions|extended|extract|fetch|field|field-groups|field-symbols|fields|floor|for|form|format|frac|frame|free|from|function|function-pool|generate|get|group|hashed|header|help-id|help-request|hide|hotspot|icon|id|if|import|importing|include|index|infotypes|initialization|inner|input|insert|intensified|interface|interface-pool|interfaces|into|inverse|join|key|language|last|leave|left|left-justified|like|line|line-count|line-selection|line-size|lines|list-processing|load|load-of-program|local|locale|log|log10|loop|m|margin|mask|matchcode|max|memory|message|message-id|messages|method|methods|min|mod|mode|modif|modify|module|move|move-corresponding|multiply|multiply-corresponding|new|new-line|new-page|next|no|no-gap|no-gaps|no-heading|no-scrolling|no-sign|no-title|no-zero|nodes|non-unique|o|object|obligatory|occurs|of|off|on|open|or|order|others|outer|output|overlay|pack|page|parameter|parameters|perform|pf-status|position|print|print-control|private|process|program|property|protected|provide|public|put|radiobutton|raise|raising|range|ranges|read|receive|refresh|reject|replace|report|requested|reserve|reset|right-justified|rollback|round|rows|rtti|run|scan|screen|search|separated|scroll|scroll-boundary|select|select-options|selection-screen|selection-table|set|shared|shift|sign|sin|single|sinh|size|skip|sort|sorted|split|sql|sqrt|stamp|standard|start-of-selection|statics|stop|string|strlen|structure|submit|subtract|subtract-corresponding|sum|supply|suppress|symbol|syntax-check|syntax-trace|system-call|system-exceptions|table|table_line|tables|tan|tanh|text|textpool|time|times|title|titlebar|to|top-of-page|transaction|transfer|translate|transporting|trunc|type|type-pool|type-pools|types|uline|under|unique|unit|unpack|up|update|user-command|using|value|value-request|values|vary|when|where|while|window|with|with-title|work|write|x|xstring|z|zone)$/', + 'constants' => '/^((?i)initial|null|space|col_background|col_heading|col_normal|col_total|col_key|col_positive|col_negative|col_group)$/', + ), + ), + 2 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => -1, + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => + array ( + 'sy' => '/^((?i)screen-name|screen-group1|screen-group2|screen-group3|screen-group4|screen-required|screen-input|screen-output|screen-intensified|screen-invisible|screen-length|screen-active|sy-index|sy-pagno|sy-tabix|sy-tfill|sy-tlopc|sy-tmaxl|sy-toccu|sy-ttabc|sy-tstis|sy-ttabi|sy-dbcnt|sy-fdpos|sy-colno|sy-linct|sy-linno|sy-linsz|sy-pagct|sy-macol|sy-marow|sy-tleng|sy-sfoff|sy-willi|sy-lilli|sy-subrc|sy-fleng|sy-cucol|sy-curow|sy-lsind|sy-listi|sy-stepl|sy-tpagi|sy-winx1|sy-winy1|sy-winx2|sy-winy2|sy-winco|sy-winro|sy-windi|sy-srows|sy-scols|sy-loopc|sy-folen|sy-fodec|sy-tzone|sy-dayst|sy-ftype|sy-appli|sy-fdayw|sy-ccurs|sy-ccurt|sy-debug|sy-ctype|sy-input|sy-langu|sy-modno|sy-batch|sy-binpt|sy-calld|sy-dynnr|sy-dyngr|sy-newpa|sy-pri40|sy-rstrt|sy-wtitl|sy-cpage|sy-dbnam|sy-mandt|sy-prefx|sy-fmkey|sy-pexpi|sy-prini|sy-primm|sy-prrel|sy-playo|sy-prbig|sy-playp|sy-prnew|sy-prlog|sy-pdest|sy-plist|sy-pauth|sy-prdsn|sy-pnwpa|sy-callr|sy-repi2|sy-rtitl|sy-prrec|sy-prtxt|sy-prabt|sy-lpass|sy-nrpag|sy-paart|sy-prcop|sy-batzs|sy-bspld|sy-brep4|sy-batzo|sy-batzd|sy-batzw|sy-batzm|sy-ctabl|sy-dbsys|sy-dcsys|sy-macdb|sy-sysid|sy-opsys|sy-pfkey|sy-saprl|sy-tcode|sy-ucomm|sy-cfwae|sy-chwae|sy-spono|sy-sponr|sy-waers|sy-cdate|sy-datum|sy-slset|sy-subty|sy-subcs|sy-group|sy-ffile|sy-uzeit|sy-dsnam|sy-repid|sy-tabid|sy-tfdsn|sy-uname|sy-lstat|sy-abcde|sy-marky|sy-sfnam|sy-tname|sy-msgli|sy-title|sy-entry|sy-lisel|sy-uline|sy-xcode|sy-cprog|sy-xprog|sy-xform|sy-ldbpg|sy-tvar0|sy-tvar1|sy-tvar2|sy-tvar3|sy-tvar4|sy-tvar5|sy-tvar6|sy-tvar7|sy-tvar8|sy-tvar9|sy-msgid|sy-msgty|sy-msgno|sy-msgv1|sy-msgv2|sy-msgv3|sy-msgv4|sy-oncom|sy-vline|sy-winsl|sy-staco|sy-staro|sy-datar|sy-host|sy-locdb|sy-locop|sy-datlo|sy-timlo|sy-zonlo|syst-index|syst-pagno|syst-tabix|syst-tfill|syst-tlopc|syst-tmaxl|syst-toccu|syst-ttabc|syst-tstis|syst-ttabi|syst-dbcnt|syst-fdpos|syst-colno|syst-linct|syst-linno|syst-linsz|syst-pagct|syst-macol|syst-marow|syst-tleng|syst-sfoff|syst-willi|syst-lilli|syst-subrc|syst-fleng|syst-cucol|syst-curow|syst-lsind|syst-listi|syst-stepl|syst-tpagi|syst-winx1|syst-winy1|syst-winx2|syst-winy2|syst-winco|syst-winro|syst-windi|syst-srows|syst-scols|syst-loopc|syst-folen|syst-fodec|syst-tzone|syst-dayst|syst-ftype|syst-appli|syst-fdayw|syst-ccurs|syst-ccurt|syst-debug|syst-ctype|syst-input|syst-langu|syst-modno|syst-batch|syst-binpt|syst-calld|syst-dynnr|syst-dyngr|syst-newpa|syst-pri40|syst-rstrt|syst-wtitl|syst-cpage|syst-dbnam|syst-mandt|syst-prefx|syst-fmkey|syst-pexpi|syst-prini|syst-primm|syst-prrel|syst-playo|syst-prbig|syst-playp|syst-prnew|syst-prlog|syst-pdest|syst-plist|syst-pauth|syst-prdsn|syst-pnwpa|syst-callr|syst-repi2|syst-rtitl|syst-prrec|syst-prtxt|syst-prabt|syst-lpass|syst-nrpag|syst-paart|syst-prcop|syst-batzs|syst-bspld|syst-brep4|syst-batzo|syst-batzd|syst-batzw|syst-batzm|syst-ctabl|syst-dbsys|syst-dcsys|syst-macdb|syst-sysid|syst-opsys|syst-pfkey|syst-saprl|syst-tcode|syst-ucomm|syst-cfwae|syst-chwae|syst-spono|syst-sponr|syst-waers|syst-cdate|syst-datum|syst-slset|syst-subty|syst-subcs|syst-group|syst-ffile|syst-uzeit|syst-dsnam|syst-repid|syst-tabid|syst-tfdsn|syst-uname|syst-lstat|syst-abcde|syst-marky|syst-sfnam|syst-tname|syst-msgli|syst-title|syst-entry|syst-lisel|syst-uline|syst-xcode|syst-cprog|syst-xprog|syst-xform|syst-ldbpg|syst-tvar0|syst-tvar1|syst-tvar2|syst-tvar3|syst-tvar4|syst-tvar5|syst-tvar6|syst-tvar7|syst-tvar8|syst-tvar9|syst-msgid|syst-msgty|syst-msgno|syst-msgv1|syst-msgv2|syst-msgv3|syst-msgv4|syst-oncom|syst-vline|syst-winsl|syst-staco|syst-staro|syst-datar|syst-host|syst-locdb|syst-locop|syst-datlo|syst-timlo|syst-zonlo)$/', + 'reserved' => '/^((?i)abs|acos|add|add-corresponding|adjacent|after|aliases|all|analyzer|and|any|append|as|ascending|asin|assign|assigned|assigning|at|atan|authority-check|avg|back|before|begin|binary|bit|bit-and|bit-not|bit-or|bit-xor|blank|block|break-point|buffer|by|c|call|case|catch|ceil|centered|chain|change|changing|check|checkbox|class|class-data|class-events|class-methods|class-pool|clear|client|close|cnt|code|collect|color|comment|commit|communication|compute|concatenate|condense|constants|context|contexts|continue|control|controls|convert|copy|corresponding|cos|cosh|count|country|create|currency|cursor|customer-function|data|database|dataset|delete|decimals|default|define|demand|descending|describe|dialog|distinct|div|divide|divide-corresponding|do|duplicates|dynpro|edit|editor-call|else|elseif|end|end-of-definition|end-of-page|end-of-selection|endat|endcase|endcatch|endchain|endclass|enddo|endexec|endform|endfunction|endif|endinterface|endloop|endmethod|endmodule|endon|endprovide|endselect|endwhile|entries|events|exec|exit|exit-command|exp|exponent|export|exporting|exceptions|extended|extract|fetch|field|field-groups|field-symbols|fields|floor|for|form|format|frac|frame|free|from|function|function-pool|generate|get|group|hashed|header|help-id|help-request|hide|hotspot|icon|id|if|import|importing|include|index|infotypes|initialization|inner|input|insert|intensified|interface|interface-pool|interfaces|into|inverse|join|key|language|last|leave|left|left-justified|like|line|line-count|line-selection|line-size|lines|list-processing|load|load-of-program|local|locale|log|log10|loop|m|margin|mask|matchcode|max|memory|message|message-id|messages|method|methods|min|mod|mode|modif|modify|module|move|move-corresponding|multiply|multiply-corresponding|new|new-line|new-page|next|no|no-gap|no-gaps|no-heading|no-scrolling|no-sign|no-title|no-zero|nodes|non-unique|o|object|obligatory|occurs|of|off|on|open|or|order|others|outer|output|overlay|pack|page|parameter|parameters|perform|pf-status|position|print|print-control|private|process|program|property|protected|provide|public|put|radiobutton|raise|raising|range|ranges|read|receive|refresh|reject|replace|report|requested|reserve|reset|right-justified|rollback|round|rows|rtti|run|scan|screen|search|separated|scroll|scroll-boundary|select|select-options|selection-screen|selection-table|set|shared|shift|sign|sin|single|sinh|size|skip|sort|sorted|split|sql|sqrt|stamp|standard|start-of-selection|statics|stop|string|strlen|structure|submit|subtract|subtract-corresponding|sum|supply|suppress|symbol|syntax-check|syntax-trace|system-call|system-exceptions|table|table_line|tables|tan|tanh|text|textpool|time|times|title|titlebar|to|top-of-page|transaction|transfer|translate|transporting|trunc|type|type-pool|type-pools|types|uline|under|unique|unit|unpack|up|update|user-command|using|value|value-request|values|vary|when|where|while|window|with|with-title|work|write|x|xstring|z|zone)$/', + 'constants' => '/^((?i)initial|null|space|col_background|col_heading|col_normal|col_total|col_key|col_positive|col_negative|col_group)$/', + ), + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_parts = array ( + 0 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + ), + 1 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + ), + 2 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_subst = array ( + -1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + ), + 0 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + ), + 1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + ), + 2 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_conditions = array ( + ); + $this->_kwmap = array ( + 'sy' => 'reserved', + 'reserved' => 'reserved', + 'constants' => 'reserved', + ); + $this->_defClass = 'code'; + $this->_checkDefines(); + } + +} \ No newline at end of file diff --git a/library/Text_Highlighter/Text/Highlighter/AVRC.php b/library/Text_Highlighter/Text/Highlighter/AVRC.php new file mode 100644 index 000000000..de4b82ccd --- /dev/null +++ b/library/Text_Highlighter/Text/Highlighter/AVRC.php @@ -0,0 +1,894 @@ + + + * + */ + +/** + * @ignore + */ + +require_once 'Text/Highlighter.php'; + +/** + * Auto-generated class. AVRC syntax highlighting + * + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.7.0 + * @link http://pear.php.net/package/Text_Highlighter + */ +class Text_Highlighter_AVRC extends Text_Highlighter +{ + var $_language = 'avrc'; + + /** + * PHP4 Compatible Constructor + * + * @param array $options + * @access public + */ + function Text_Highlighter_AVRC($options=array()) + { + $this->__construct($options); + } + + + /** + * Constructor + * + * @param array $options + * @access public + */ + function __construct($options=array()) + { + + $this->_options = $options; + $this->_regs = array ( + -1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 0 => '/((?i)\\\\)/', + 1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 2 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 3 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 4 => '//', + 5 => '/((?i)")|((?i)<)/', + 6 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 7 => '/((?i)\\$\\w+\\s*:.+\\$)/', + 8 => '/((?i)\\$\\w+\\s*:.+\\$)/', + ); + $this->_counts = array ( + -1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 0 => + array ( + 0 => 0, + ), + 1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 2 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 3 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 0, + 1 => 0, + ), + 6 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 2, + 8 => 0, + 9 => 0, + ), + 7 => + array ( + 0 => 0, + ), + 8 => + array ( + 0 => 0, + ), + ); + $this->_delim = array ( + -1 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 0 => + array ( + 0 => '', + ), + 1 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 2 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 3 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 'quotes', + 1 => 'quotes', + ), + 6 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => 'mlcomment', + 9 => 'comment', + ), + 7 => + array ( + 0 => '', + ), + 8 => + array ( + 0 => '', + ), + ); + $this->_inner = array ( + -1 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 0 => + array ( + 0 => 'special', + ), + 1 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 2 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 3 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 'string', + 1 => 'string', + ), + 6 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'identifier', + 4 => 'number', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'mlcomment', + 9 => 'comment', + ), + 7 => + array ( + 0 => 'inlinedoc', + ), + 8 => + array ( + 0 => 'inlinedoc', + ), + ); + $this->_end = array ( + 0 => '/(?i)"/', + 1 => '/(?i)\\}/', + 2 => '/(?i)\\)/', + 3 => '/(?i)\\]/', + 4 => '/(?i)>/', + 5 => '/(?mi)(? '/(?mi)(? '/(?i)\\*\\//', + 8 => '/(?mi)$/', + ); + $this->_states = array ( + -1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 0 => + array ( + 0 => -1, + ), + 1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 2 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 3 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 0, + 1 => 4, + ), + 6 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => -1, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => 7, + 9 => 8, + ), + 7 => + array ( + 0 => -1, + ), + 8 => + array ( + 0 => -1, + ), + ); + $this->_keywords = array ( + -1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 0 => + array ( + 0 => + array ( + ), + ), + 1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 2 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 3 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => -1, + 1 => -1, + ), + 6 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'registers' => '/^(ACSR|ADCH|ADCL|ADCSRA|ADMUX|ASSR|DDRA|DDRB|DDRC|DDRD|DDRE|DDRF|DDRG|EEARH|EEARL|EECR|EEDR|EICRA|EICRB|EIFR|EIMSK|ETIFR|ETIMSK|GICR|GIFR|ICR1H|ICR1L|ICR3H|ICR3L|MCUCR|MCUCSR|OCDR|OCR0|OCR1AH|OCR1AL|OCR1BH|OCR1BL|OCR1CH|OCR1CL|OCR2|OCR3AH|OCR3AL|OCR3BH|OCR3BL|OCR3CH|OCR3CL|OSCCAL|PINA|PINB|PINC|PIND|PINE|PINF|PING|PORTA|PORTB|PORTC|PORTD|PORTE|PORTF|PORTG|RAMPZ|SFIOR|SPCR|SPDR|SPH|SPL|SPMCR|SPMCSR|SPSR|SREG|TCCR0|TCCR1A|TCCR1B|TCCR1C|TCCR2|TCCR3A|TCCR3B|TCCR3C|TCNT0|TCNT1H|TCNT1L|TCNT2|TCNT3H|TCNT3L|TIFR|TIMSK|TWAR|TWBR|TWCR|TWDR|TWSR|UBRR0H|UBRR0L|UBRR1H|UBRR1L|UBRRH|UBRRL|UCSR0A|UCSR0B|UCSR0C|UCSR1A|UCSR1B|UCSR1C|UCSRA|UCSRB|UCSRC|UDR|UDR0|UDR1|WDTCR|XDIV|XMCRA|XMCRB)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 4 => + array ( + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => -1, + 9 => -1, + ), + 7 => + array ( + 0 => + array ( + ), + ), + 8 => + array ( + 0 => + array ( + ), + ), + ); + $this->_parts = array ( + 0 => + array ( + 0 => NULL, + ), + 1 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 2 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 3 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => NULL, + 1 => NULL, + ), + 6 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + ), + 7 => + array ( + 0 => NULL, + ), + 8 => + array ( + 0 => NULL, + ), + ); + $this->_subst = array ( + -1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 0 => + array ( + 0 => false, + ), + 1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 2 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 3 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => false, + 1 => false, + ), + 6 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + ), + 7 => + array ( + 0 => false, + ), + 8 => + array ( + 0 => false, + ), + ); + $this->_conditions = array ( + ); + $this->_kwmap = array ( + 'reserved' => 'reserved', + 'registers' => 'reserved', + 'types' => 'types', + 'Common Macros' => 'prepro', + ); + $this->_defClass = 'code'; + $this->_checkDefines(); + } + +} \ No newline at end of file diff --git a/library/Text_Highlighter/Text/Highlighter/CPP.php b/library/Text_Highlighter/Text/Highlighter/CPP.php new file mode 100644 index 000000000..eaa47c575 --- /dev/null +++ b/library/Text_Highlighter/Text/Highlighter/CPP.php @@ -0,0 +1,891 @@ + + + * + */ + +/** + * @ignore + */ + +require_once 'Text/Highlighter.php'; + +/** + * Auto-generated class. CPP syntax highlighting + * + * @author Aaron Kalin + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.7.0 + * @link http://pear.php.net/package/Text_Highlighter + */ +class Text_Highlighter_CPP extends Text_Highlighter +{ + var $_language = 'cpp'; + + /** + * PHP4 Compatible Constructor + * + * @param array $options + * @access public + */ + function Text_Highlighter_CPP($options=array()) + { + $this->__construct($options); + } + + + /** + * Constructor + * + * @param array $options + * @access public + */ + function __construct($options=array()) + { + + $this->_options = $options; + $this->_regs = array ( + -1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 0 => '/((?i)\\\\)/', + 1 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 2 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 3 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)\\[)|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?mi)^[ \\t]*#include)|((?mii)^[ \\t]*#[ \\t]*[a-z]+)|((?i)\\d*\\.?\\d+)|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 4 => '//', + 5 => '/((?i)")|((?i)<)/', + 6 => '/((?i)")|((?i)\\{)|((?i)\\()|((?i)[a-z_]\\w*)|((?i)\\b0[xX][\\da-f]+)|((?i)\\b\\d\\d*|\\b0\\b)|((?i)\\b0[0-7]+)|((?i)\\b(\\d*\\.\\d+)|(\\d+\\.\\d*))|((?i)\\/\\*)|((?i)\\/\\/.+)/', + 7 => '/((?i)\\$\\w+\\s*:.+\\$)/', + 8 => '/((?i)\\$\\w+\\s*:.+\\$)/', + ); + $this->_counts = array ( + -1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 0 => + array ( + 0 => 0, + ), + 1 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 2 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 3 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 2, + 9 => 0, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 0, + 1 => 0, + ), + 6 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + 3 => 0, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 2, + 8 => 0, + 9 => 0, + ), + 7 => + array ( + 0 => 0, + ), + 8 => + array ( + 0 => 0, + ), + ); + $this->_delim = array ( + -1 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 0 => + array ( + 0 => '', + ), + 1 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 2 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 3 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => 'brackets', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => 'prepro', + 10 => 'prepro', + 11 => '', + 12 => 'mlcomment', + 13 => 'comment', + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 'quotes', + 1 => 'quotes', + ), + 6 => + array ( + 0 => 'quotes', + 1 => 'brackets', + 2 => 'brackets', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => 'mlcomment', + 9 => 'comment', + ), + 7 => + array ( + 0 => '', + ), + 8 => + array ( + 0 => '', + ), + ); + $this->_inner = array ( + -1 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 0 => + array ( + 0 => 'special', + ), + 1 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 2 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 3 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'code', + 4 => 'identifier', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'number', + 9 => 'prepro', + 10 => 'code', + 11 => 'number', + 12 => 'mlcomment', + 13 => 'comment', + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 'string', + 1 => 'string', + ), + 6 => + array ( + 0 => 'string', + 1 => 'code', + 2 => 'code', + 3 => 'identifier', + 4 => 'number', + 5 => 'number', + 6 => 'number', + 7 => 'number', + 8 => 'mlcomment', + 9 => 'comment', + ), + 7 => + array ( + 0 => 'inlinedoc', + ), + 8 => + array ( + 0 => 'inlinedoc', + ), + ); + $this->_end = array ( + 0 => '/(?i)"/', + 1 => '/(?i)\\}/', + 2 => '/(?i)\\)/', + 3 => '/(?i)\\]/', + 4 => '/(?i)>/', + 5 => '/(?mi)(? '/(?mi)(? '/(?i)\\*\\//', + 8 => '/(?mi)$/', + ); + $this->_states = array ( + -1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 0 => + array ( + 0 => -1, + ), + 1 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 2 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 3 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 3, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => 5, + 10 => 6, + 11 => -1, + 12 => 7, + 13 => 8, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => 0, + 1 => 4, + ), + 6 => + array ( + 0 => 0, + 1 => 1, + 2 => 2, + 3 => -1, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => 7, + 9 => 8, + ), + 7 => + array ( + 0 => -1, + ), + 8 => + array ( + 0 => -1, + ), + ); + $this->_keywords = array ( + -1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 0 => + array ( + 0 => + array ( + ), + ), + 1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 2 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 3 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => -1, + 10 => -1, + 11 => + array ( + ), + 12 => -1, + 13 => -1, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => -1, + 1 => -1, + ), + 6 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => + array ( + 'reserved' => '/^(and|and_eq|asm|bitand|bitor|break|case|catch|compl|const_cast|continue|default|delete|do|dynamic_cast|else|for|fortran|friend|goto|if|new|not|not_eq|operator|or|or_eq|private|protected|public|reinterpret_cast|return|sizeof|static_cast|switch|this|throw|try|typeid|using|while|xor|xor_eq|false|true)$/', + 'types' => '/^(auto|bool|char|class|const|double|enum|explicit|export|extern|float|inline|int|long|mutable|namespace|register|short|signed|static|struct|template|typedef|typename|union|unsigned|virtual|void|volatile|wchar_t)$/', + 'Common Macros' => '/^(NULL|TRUE|FALSE|MAX|MIN|__LINE__|__DATA__|__FILE__|__TIME__|__STDC__)$/', + ), + 4 => + array ( + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => -1, + 9 => -1, + ), + 7 => + array ( + 0 => + array ( + ), + ), + 8 => + array ( + 0 => + array ( + ), + ), + ); + $this->_parts = array ( + 0 => + array ( + 0 => NULL, + ), + 1 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 2 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 3 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + 10 => NULL, + 11 => NULL, + 12 => NULL, + 13 => NULL, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => NULL, + 1 => NULL, + ), + 6 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + 4 => NULL, + 5 => NULL, + 6 => NULL, + 7 => NULL, + 8 => NULL, + 9 => NULL, + ), + 7 => + array ( + 0 => NULL, + ), + 8 => + array ( + 0 => NULL, + ), + ); + $this->_subst = array ( + -1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 0 => + array ( + 0 => false, + ), + 1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 2 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 3 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + ), + 4 => + array ( + ), + 5 => + array ( + 0 => false, + 1 => false, + ), + 6 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + ), + 7 => + array ( + 0 => false, + ), + 8 => + array ( + 0 => false, + ), + ); + $this->_conditions = array ( + ); + $this->_kwmap = array ( + 'reserved' => 'reserved', + 'types' => 'types', + 'Common Macros' => 'prepro', + ); + $this->_defClass = 'code'; + $this->_checkDefines(); + } + +} \ No newline at end of file diff --git a/library/Text_Highlighter/Text/Highlighter/CSS.php b/library/Text_Highlighter/Text/Highlighter/CSS.php new file mode 100644 index 000000000..51757c88e --- /dev/null +++ b/library/Text_Highlighter/Text/Highlighter/CSS.php @@ -0,0 +1,437 @@ + + * + */ + +/** + * @ignore + */ + +require_once 'Text/Highlighter.php'; + +/** + * Auto-generated class. CSS syntax highlighting + * + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: 0.7.0 + * @link http://pear.php.net/package/Text_Highlighter + */ +class Text_Highlighter_CSS extends Text_Highlighter +{ + var $_language = 'css'; + + /** + * PHP4 Compatible Constructor + * + * @param array $options + * @access public + */ + function Text_Highlighter_CSS($options=array()) + { + $this->__construct($options); + } + + + /** + * Constructor + * + * @param array $options + * @access public + */ + function __construct($options=array()) + { + + $this->_options = $options; + $this->_regs = array ( + -1 => '/((?i)\\/\\*)|((?i)(@[a-z\\d]+))|((?i)(((\\.|#)?[a-z]+[a-z\\d\\-]*(?![a-z\\d\\-]))|(\\*))(?!\\s*:\\s*[\\s\\{]))|((?i):[a-z][a-z\\d\\-]*)|((?i)\\[)|((?i)\\{)/', + 0 => '//', + 1 => '/((?i)\\d*\\.?\\d+(\\%|em|ex|pc|pt|px|in|mm|cm))|((?i)\\d*\\.?\\d+)|((?i)[a-z][a-z\\d\\-]*)|((?i)#([\\da-f]{6}|[\\da-f]{3})\\b)/', + 2 => '/((?i)\')|((?i)")|((?i)[\\w\\-\\:]+)/', + 3 => '/((?i)\\/\\*)|((?i)[a-z][a-z\\d\\-]*\\s*:)|((?i)(((\\.|#)?[a-z]+[a-z\\d\\-]*(?![a-z\\d\\-]))|(\\*))(?!\\s*:\\s*[\\s\\{]))|((?i)\\{)/', + 4 => '/((?i)\\\\[\\\\(\\\\)\\\\])/', + 5 => '/((?i)\\\\\\\\|\\\\"|\\\\\'|\\\\`)/', + 6 => '/((?i)\\\\\\\\|\\\\"|\\\\\'|\\\\`|\\\\t|\\\\n|\\\\r)/', + ); + $this->_counts = array ( + -1 => + array ( + 0 => 0, + 1 => 1, + 2 => 4, + 3 => 0, + 4 => 0, + 5 => 0, + ), + 0 => + array ( + ), + 1 => + array ( + 0 => 1, + 1 => 0, + 2 => 0, + 3 => 1, + ), + 2 => + array ( + 0 => 0, + 1 => 0, + 2 => 0, + ), + 3 => + array ( + 0 => 0, + 1 => 0, + 2 => 4, + 3 => 0, + ), + 4 => + array ( + 0 => 0, + ), + 5 => + array ( + 0 => 0, + ), + 6 => + array ( + 0 => 0, + ), + ); + $this->_delim = array ( + -1 => + array ( + 0 => 'comment', + 1 => '', + 2 => '', + 3 => '', + 4 => 'brackets', + 5 => 'brackets', + ), + 0 => + array ( + ), + 1 => + array ( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + ), + 2 => + array ( + 0 => 'quotes', + 1 => 'quotes', + 2 => '', + ), + 3 => + array ( + 0 => 'comment', + 1 => 'reserved', + 2 => '', + 3 => 'brackets', + ), + 4 => + array ( + 0 => '', + ), + 5 => + array ( + 0 => '', + ), + 6 => + array ( + 0 => '', + ), + ); + $this->_inner = array ( + -1 => + array ( + 0 => 'comment', + 1 => 'var', + 2 => 'identifier', + 3 => 'special', + 4 => 'code', + 5 => 'code', + ), + 0 => + array ( + ), + 1 => + array ( + 0 => 'number', + 1 => 'number', + 2 => 'code', + 3 => 'var', + ), + 2 => + array ( + 0 => 'string', + 1 => 'string', + 2 => 'var', + ), + 3 => + array ( + 0 => 'comment', + 1 => 'code', + 2 => 'identifier', + 3 => 'code', + ), + 4 => + array ( + 0 => 'string', + ), + 5 => + array ( + 0 => 'special', + ), + 6 => + array ( + 0 => 'special', + ), + ); + $this->_end = array ( + 0 => '/(?i)\\*\\//', + 1 => '/(?i)(?=;|\\})/', + 2 => '/(?i)\\]/', + 3 => '/(?i)\\}/', + 4 => '/(?i)\\)/', + 5 => '/(?i)\'/', + 6 => '/(?i)"/', + ); + $this->_states = array ( + -1 => + array ( + 0 => 0, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => 2, + 5 => 3, + ), + 0 => + array ( + ), + 1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + ), + 2 => + array ( + 0 => 5, + 1 => 6, + 2 => -1, + ), + 3 => + array ( + 0 => 0, + 1 => 1, + 2 => -1, + 3 => 3, + ), + 4 => + array ( + 0 => -1, + ), + 5 => + array ( + 0 => -1, + ), + 6 => + array ( + 0 => -1, + ), + ); + $this->_keywords = array ( + -1 => + array ( + 0 => -1, + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => -1, + 5 => -1, + ), + 0 => + array ( + ), + 1 => + array ( + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + 'propertyValue' => '/^((?i)far-left|left|center-left|center-right|center|far-right|right-side|right|behind|leftwards|rightwards|inherit|scroll|fixed|transparent|none|repeat-x|repeat-y|repeat|no-repeat|collapse|separate|auto|top|bottom|both|open-quote|close-quote|no-open-quote|no-close-quote|crosshair|default|pointer|move|e-resize|ne-resize|nw-resize|n-resize|se-resize|sw-resize|s-resize|text|wait|help|ltr|rtl|inline|block|list-item|run-in|compact|marker|table|inline-table|table-row-group|table-header-group|table-footer-group|table-row|table-column-group|table-column|table-cell|table-caption|below|level|above|higher|lower|show|hide|caption|icon|menu|message-box|small-caption|status-bar|normal|wider|narrower|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|italic|oblique|small-caps|bold|bolder|lighter|inside|outside|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-greek|lower-alpha|lower-latin|upper-alpha|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha|crop|cross|invert|visible|hidden|always|avoid|x-low|low|medium|high|x-high|mix?|repeat?|static|relative|absolute|portrait|landscape|spell-out|once|digits|continuous|code|x-slow|slow|fast|x-fast|faster|slower|justify|underline|overline|line-through|blink|capitalize|uppercase|lowercase|embed|bidi-override|baseline|sub|super|text-top|middle|text-bottom|silent|x-soft|soft|loud|x-loud|pre|nowrap|serif|sans-serif|cursive|fantasy|monospace|empty|string|strict|loose|char|true|false|dotted|dashed|solid|double|groove|ridge|inset|outset|larger|smaller|xx-small|x-small|small|large|x-large|xx-large|all|newspaper|distribute|distribute-all-lines|distribute-center-last|inter-word|inter-ideograph|inter-cluster|kashida|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|keep-all|break-all|break-word|lr-tb|tb-rl|thin|thick|inline-block|w-resize|hand|distribute-letter|distribute-space|whitespace|male|female|child)$/', + 'namedcolor' => '/^((?i)aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|activeborder|activecaption|appworkspace|background|buttonface|buttonhighlight|buttonshadow|buttontext|captiontext|graytext|highlight|highlighttext|inactiveborder|inactivecaption|inactivecaptiontext|infobackground|infotext|menu|menutext|scrollbar|threeddarkshadow|threedface|threedhighlight|threedlightshadow|threedshadow|window|windowframe|windowtext)$/', + ), + 3 => + array ( + ), + ), + 2 => + array ( + 0 => -1, + 1 => -1, + 2 => + array ( + ), + ), + 3 => + array ( + 0 => -1, + 1 => -1, + 2 => + array ( + ), + 3 => -1, + ), + 4 => + array ( + 0 => + array ( + ), + ), + 5 => + array ( + 0 => + array ( + ), + ), + 6 => + array ( + 0 => + array ( + ), + ), + ); + $this->_parts = array ( + 0 => + array ( + ), + 1 => + array ( + 0 => + array ( + 1 => 'string', + ), + 1 => NULL, + 2 => NULL, + 3 => NULL, + ), + 2 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + ), + 3 => + array ( + 0 => NULL, + 1 => NULL, + 2 => NULL, + 3 => NULL, + ), + 4 => + array ( + 0 => NULL, + ), + 5 => + array ( + 0 => NULL, + ), + 6 => + array ( + 0 => NULL, + ), + ); + $this->_subst = array ( + -1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + ), + 0 => + array ( + ), + 1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + ), + 2 => + array ( + 0 => false, + 1 => false, + 2 => false, + ), + 3 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + ), + 4 => + array ( + 0 => false, + ), + 5 => + array ( + 0 => false, + ), + 6 => + array ( + 0 => false, + ), + ); + $this->_conditions = array ( + ); + $this->_kwmap = array ( + 'propertyValue' => 'string', + 'namedcolor' => 'var', + ); + $this->_defClass = 'code'; + $this->_checkDefines(); + } + +} diff --git a/library/Text_Highlighter/Text/Highlighter/DIFF.php b/library/Text_Highlighter/Text/Highlighter/DIFF.php new file mode 100644 index 000000000..2bb25a453 --- /dev/null +++ b/library/Text_Highlighter/Text/Highlighter/DIFF.php @@ -0,0 +1,384 @@ + + * + */ + +/** + * @ignore + */ + +require_once 'Text/Highlighter.php'; + +/** + * Auto-generated class. DIFF syntax highlighting + * + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Highlighter + */ +class Text_Highlighter_DIFF extends Text_Highlighter +{ + var $_language = 'diff'; + + /** + * PHP4 Compatible Constructor + * + * @param array $options + * @access public + */ + function Text_Highlighter_DIFF($options=array()) + { + $this->__construct($options); + } + + + /** + * Constructor + * + * @param array $options + * @access public + */ + function __construct($options=array()) + { + + $this->_options = $options; + $this->_regs = array ( + -1 => '/((?m)^\\\\\\sNo\\snewline.+$)|((?m)^\\-\\-\\-$)|((?m)^(diff\\s+\\-|Only\\s+|Index).*$)|((?m)^(\\-\\-\\-|\\+\\+\\+)\\s.+$)|((?m)^\\*.*$)|((?m)^\\+.*$)|((?m)^!.*$)|((?m)^\\<\\s.*$)|((?m)^\\>\\s.*$)|((?m)^\\d+(\\,\\d+)?[acd]\\d+(,\\d+)?$)|((?m)^\\-.*$)|((?m)^\\+.*$)|((?m)^@@.+@@$)|((?m)^d\\d+\\s\\d+$)|((?m)^a\\d+\\s\\d+$)|((?m)^(\\d+)(,\\d+)?(a)$)|((?m)^(\\d+)(,\\d+)?(c)$)|((?m)^(\\d+)(,\\d+)?(d)$)|((?m)^a(\\d+)(\\s\\d+)?$)|((?m)^c(\\d+)(\\s\\d+)?$)|((?m)^d(\\d+)(\\s\\d+)?$)/', + 0 => '//', + 1 => '//', + 2 => '//', + 3 => '//', + 4 => '//', + ); + $this->_counts = array ( + -1 => + array ( + 0 => 0, + 1 => 0, + 2 => 1, + 3 => 1, + 4 => 0, + 5 => 0, + 6 => 0, + 7 => 0, + 8 => 0, + 9 => 2, + 10 => 0, + 11 => 0, + 12 => 0, + 13 => 0, + 14 => 0, + 15 => 3, + 16 => 3, + 17 => 3, + 18 => 2, + 19 => 2, + 20 => 2, + ), + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_delim = array ( + -1 => + array ( + 0 => '', + 1 => '', + 2 => '', + 3 => '', + 4 => '', + 5 => '', + 6 => '', + 7 => '', + 8 => '', + 9 => '', + 10 => '', + 11 => '', + 12 => '', + 13 => '', + 14 => 'code', + 15 => 'code', + 16 => 'code', + 17 => '', + 18 => 'code', + 19 => 'code', + 20 => '', + ), + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_inner = array ( + -1 => + array ( + 0 => 'special', + 1 => 'code', + 2 => 'var', + 3 => 'reserved', + 4 => 'quotes', + 5 => 'string', + 6 => 'inlinedoc', + 7 => 'quotes', + 8 => 'string', + 9 => 'code', + 10 => 'quotes', + 11 => 'string', + 12 => 'code', + 13 => 'code', + 14 => 'var', + 15 => 'string', + 16 => 'inlinedoc', + 17 => 'code', + 18 => 'string', + 19 => 'inlinedoc', + 20 => 'code', + ), + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_end = array ( + 0 => '/(?m)(?=^[ad]\\d+\\s\\d+)/', + 1 => '/(?m)^(\\.)$/', + 2 => '/(?m)^(\\.)$/', + 3 => '/(?m)^(\\.)$/', + 4 => '/(?m)^(\\.)$/', + ); + $this->_states = array ( + -1 => + array ( + 0 => -1, + 1 => -1, + 2 => -1, + 3 => -1, + 4 => -1, + 5 => -1, + 6 => -1, + 7 => -1, + 8 => -1, + 9 => -1, + 10 => -1, + 11 => -1, + 12 => -1, + 13 => -1, + 14 => 0, + 15 => 1, + 16 => 2, + 17 => -1, + 18 => 3, + 19 => 4, + 20 => -1, + ), + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_keywords = array ( + -1 => + array ( + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + 5 => + array ( + ), + 6 => + array ( + ), + 7 => + array ( + ), + 8 => + array ( + ), + 9 => + array ( + ), + 10 => + array ( + ), + 11 => + array ( + ), + 12 => + array ( + ), + 13 => + array ( + ), + 14 => -1, + 15 => -1, + 16 => -1, + 17 => + array ( + ), + 18 => -1, + 19 => -1, + 20 => + array ( + ), + ), + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_parts = array ( + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_subst = array ( + -1 => + array ( + 0 => false, + 1 => false, + 2 => false, + 3 => false, + 4 => false, + 5 => false, + 6 => false, + 7 => false, + 8 => false, + 9 => false, + 10 => false, + 11 => false, + 12 => false, + 13 => false, + 14 => false, + 15 => false, + 16 => false, + 17 => false, + 18 => false, + 19 => false, + 20 => false, + ), + 0 => + array ( + ), + 1 => + array ( + ), + 2 => + array ( + ), + 3 => + array ( + ), + 4 => + array ( + ), + ); + $this->_conditions = array ( + ); + $this->_kwmap = array ( + ); + $this->_defClass = 'default'; + $this->_checkDefines(); + } + +} \ No newline at end of file diff --git a/library/Text_Highlighter/Text/Highlighter/DTD.php b/library/Text_Highlighter/Text/Highlighter/DTD.php new file mode 100644 index 000000000..41b0faa78 --- /dev/null +++ b/library/Text_Highlighter/Text/Highlighter/DTD.php @@ -0,0 +1,426 @@ + + * + */ + +/** + * @ignore + */ + +require_once 'Text/Highlighter.php'; + +/** + * Auto-generated class. DTD syntax highlighting + * + * @author Andrey Demenev + * @category Text + * @package Text_Highlighter + * @copyright 2004-2006 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Text_Highlighter + */ +class Text_Highlighter_DTD extends Text_Highlighter +{ + var $_language = 'dtd'; + + /** + * PHP4 Compatible Constructor + * + * @param array $options + * @access public + */ + function Text_Highlighter_DTD($options=array()) + { + $this->__construct($options); + } + + + /** + * Constructor + * + * @param array $options + * @access public + */ + function __construct($options=array()) + { + + $this->_options = $options; + $this->_regs = array ( + -1 => '/(\\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/avrc.xml b/library/Text_Highlighter/avrc.xml new file mode 100644 index 000000000..dec571e13 --- /dev/null +++ b/library/Text_Highlighter/avrc.xml @@ -0,0 +1,316 @@ + + + + + + + + + + + C/C++ highlighter specific to Atmel AVR microcontrollers + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/cpp.xml b/library/Text_Highlighter/cpp.xml new file mode 100644 index 000000000..2cbaa930f --- /dev/null +++ b/library/Text_Highlighter/cpp.xml @@ -0,0 +1,201 @@ + + + + + + + + + + + +Thanks to Aaron Kalin for initial +implementation of this highlighter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/css.xml b/library/Text_Highlighter/css.xml new file mode 100644 index 000000000..2473bcfb7 --- /dev/null +++ b/library/Text_Highlighter/css.xml @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/diff.xml b/library/Text_Highlighter/diff.xml new file mode 100644 index 000000000..d088f9257 --- /dev/null +++ b/library/Text_Highlighter/diff.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/dtd.xml b/library/Text_Highlighter/dtd.xml new file mode 100644 index 000000000..18fa07db7 --- /dev/null +++ b/library/Text_Highlighter/dtd.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/generate b/library/Text_Highlighter/generate new file mode 100644 index 000000000..4e22e82fd --- /dev/null +++ b/library/Text_Highlighter/generate @@ -0,0 +1,171 @@ +#!@php_bin@ + + * @copyright 2004 Andrey Demenev + * @license http://www.php.net/license/3_0.txt PHP License + * @version CVS: $Id$ + * @link http://pear.php.net/package/Text_Highlighter + */ + +require_once 'Text/Highlighter/Generator.php'; +require_once 'Console/Getopt.php'; + +$options = Console_Getopt::getopt($argv, 'x:p:d:h', array('xml=', 'php=','dir=', 'help')); + +if (PEAR::isError($options)) { + $message = str_replace('Console_Getopt: ','',$options->message); + usage($message); +} + +$source = array(); +$dest = array(); +$dir = ''; + +$expectp = false; +$expectx = false; +$unexpectedx = false; +$unexpectedp = false; +$si = $di = 0; + +foreach ($options[0] as $option) { + switch ($option[0]) { + case 'x': + case '--xml': + $source[$si] = $option[1]; + if ($si) { + $di++; + } + $si++; + if ($expectp) { + $unexpectedx = true; + } + $expectp = true; + $expectx = false; + break; + + case 'p': + case '--php': + if ($expectx) { + $unexpectedp = true; + } + $dest[$di] = $option[1]; + $expectp = false; + $expectx = true; + break; + + case 'd': + case '--dir': + $dir = $option[1]; + break; + + case 'h': + case '--help': + usage(); + break; + } +} + + +if ($unexpectedx && !$dir) { + usage('Unexpected -x or --xml', STDERR); +} + +if ($unexpectedp) { + usage('Unexpected -p or --php', STDERR); +} + +$nsource = count($source); +$ndest = count($dest); + +if (!$nsource && !$ndest) { + $source[]='php://stdin'; + if (!$dir) { + $dest[]='php://stdout'; + } else { + $dest[] = null; + } +} elseif ($expectp && !$dir && $nsource > 1) { + usage('-x or --xml without following -p or --php', STDERR); +} elseif ($nsource == 1 && !$ndest && !$dir) { + $dest[]='php://stdout'; +} + +if ($dir && substr($dir,-1)!='/' && substr($dir,-1)!=='\\' ) { + $dir .= DIRECTORY_SEPARATOR; +} + + +foreach ($source as $i => $xmlfile) +{ + $gen = new Text_Highlighter_Generator; + $gen->setInputFile($xmlfile); + if ($gen->hasErrors()) { + break; + } + $gen->generate(); + if ($gen->hasErrors()) { + break; + } + if (isset($dest[$i])) { + $phpfile = $dest[$i]; + } else { + $phpfile = $dir . $gen->language . '.php'; + } + $gen->saveCode($phpfile); + if ($gen->hasErrors()) { + break; + } +} +if ($gen->hasErrors()) { + $errors = $gen->getErrors(); + foreach ($errors as $error) { + fwrite (STDERR, $error . "\n"); + } + exit(1); +} + +function usage($message='', $file=STDOUT) +{ + $code = 0; + if ($message) { + $message .= "\n\n"; + $code = 1; + } + $message .= << tag) + -h, --help + This help +MSG; + fwrite ($file, $message); + exit($code); +} +?> + diff --git a/library/Text_Highlighter/generate.bat b/library/Text_Highlighter/generate.bat new file mode 100644 index 000000000..3960486c1 --- /dev/null +++ b/library/Text_Highlighter/generate.bat @@ -0,0 +1,188 @@ +@echo off +rem vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: + +rem Console highlighter class generator + +rem PHP versions 4 and 5 + +rem LICENSE: This source file is subject to version 3.0 of the PHP license +rem that is available through the world-wide-web at the following URI: +rem http://www.php.net/license/3_0.txt. If you did not receive a copy of +rem the PHP License and are unable to obtain it through the web, please +rem send a note to license@php.net so we can mail you a copy immediately. + +rem @category Text +rem @package Text_Highlighter +rem @author Andrey Demenev +rem @copyright 2004 Andrey Demenev +rem @license http://www.php.net/license/3_0.txt PHP License +rem @version CVS: $Id: generate.bat,v 1.1 2007-06-03 02:35:28 ssttoo Exp $ +rem @link http://pear.php.net/package/Text_Highlighter + +set "MHL_PARAMS=" +:doshift +set "MHL_PARAMS=%MHL_PARAMS% %1" +shift +if -%1- == -- GOTO noshift +GOTO doshift +:noshift +@php_bin@ -q -d output_buffering=1 -d include_path="@php_dir@" @bin_dir@/Text/Highlighter/generate.bat %MHL_PARAMS% + +GOTO finish +message); + usage($message); +} + +$source = array(); +$dest = array(); +$dir = ''; + +$expectp = false; +$expectx = false; +$unexpectedx = false; +$unexpectedp = false; +$si = $di = 0; + +foreach ($options[0] as $option) { + switch ($option[0]) { + case 'x': + case '--xml': + $source[$si] = $option[1]; + if ($si) { + $di++; + } + $si++; + if ($expectp) { + $unexpectedx = true; + } + $expectp = true; + $expectx = false; + break; + + case 'p': + case '--php': + if ($expectx) { + $unexpectedp = true; + } + $dest[$di] = $option[1]; + $expectp = false; + $expectx = true; + break; + + case 'd': + case '--dir': + $dir = $option[1]; + break; + + case 'h': + case '--help': + usage(); + break; + } +} + + +if ($unexpectedx && !$dir) { + usage('Unexpected -x or --xml', STDERR); +} + +if ($unexpectedp) { + usage('Unexpected -p or --php', STDERR); +} + +$nsource = count($source); +$ndest = count($dest); + +if (!$nsource && !$ndest) { + $source[]='php://stdin'; + if (!$dir) { + $dest[]='php://stdout'; + } else { + $dest[] = null; + } +} elseif ($expectp && !$dir && $nsource > 1) { + usage('-x or --xml without following -p or --php', STDERR); +} elseif ($nsource == 1 && !$ndest && !$dir) { + $dest[]='php://stdout'; +} + +if ($dir && substr($dir,-1)!='/' && substr($dir,-1)!=='\\' ) { + $dir .= DIRECTORY_SEPARATOR; +} + + +foreach ($source as $i => $xmlfile) +{ + $gen = new Text_Highlighter_Generator; + $gen->setInputFile($xmlfile); + if ($gen->hasErrors()) { + break; + } + $gen->generate(); + if ($gen->hasErrors()) { + break; + } + if (isset($dest[$i])) { + $phpfile = $dest[$i]; + } else { + $phpfile = $dir . $gen->language . '.php'; + } + $gen->saveCode($phpfile); + if ($gen->hasErrors()) { + break; + } +} +if ($gen->hasErrors()) { + $errors = $gen->getErrors(); + foreach ($errors as $error) { + fwrite (STDERR, $error . "\n"); + } + exit(1); +} + +exit(0); + +function usage($message='', $file=STDOUT) +{ + $code = 0; + if ($message) { + $message .= "\n\n"; + $code = 1; + } + $message .= << tag) + -h, --help + This help +MSG; + fwrite ($file, $message); + exit($code); +} +?> +:finish diff --git a/library/Text_Highlighter/html.xml b/library/Text_Highlighter/html.xml new file mode 100644 index 000000000..58d51fc5b --- /dev/null +++ b/library/Text_Highlighter/html.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/java.xml b/library/Text_Highlighter/java.xml new file mode 100644 index 000000000..12052b5db --- /dev/null +++ b/library/Text_Highlighter/java.xml @@ -0,0 +1,2824 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/javascript.xml b/library/Text_Highlighter/javascript.xml new file mode 100644 index 000000000..e478515a7 --- /dev/null +++ b/library/Text_Highlighter/javascript.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/mysql.xml b/library/Text_Highlighter/mysql.xml new file mode 100644 index 000000000..082b62795 --- /dev/null +++ b/library/Text_Highlighter/mysql.xml @@ -0,0 +1,424 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/perl.xml b/library/Text_Highlighter/perl.xml new file mode 100644 index 000000000..54f8835ea --- /dev/null +++ b/library/Text_Highlighter/perl.xml @@ -0,0 +1,439 @@ + + + + + + + + + + + This highlighter is EXPERIMENTAL, so that it may work incorrectly. +Most rules were created by Mariusz Jakubowski, and extended by me. +My knowledge of Perl is poor, and Perl syntax seems too +complicated to me. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/php.xml b/library/Text_Highlighter/php.xml new file mode 100644 index 000000000..1b08ea203 --- /dev/null +++ b/library/Text_Highlighter/php.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/python.xml b/library/Text_Highlighter/python.xml new file mode 100644 index 000000000..29e77203c --- /dev/null +++ b/library/Text_Highlighter/python.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/release b/library/Text_Highlighter/release new file mode 100644 index 000000000..66f1fa603 --- /dev/null +++ b/library/Text_Highlighter/release @@ -0,0 +1,4 @@ +#!/bin/sh + +/usr/local/bin/php package.php make +/usr/local/bin/pear package diff --git a/library/Text_Highlighter/ruby.xml b/library/Text_Highlighter/ruby.xml new file mode 100644 index 000000000..599f5af17 --- /dev/null +++ b/library/Text_Highlighter/ruby.xml @@ -0,0 +1,141 @@ + + + + + + + + + + +FIXME: While this construction : s.split /z/i +is valid, regular expression is not recognized as such +(/ folowing an identifier or number is not recognized as +start of RE), making highlighting improper + +%q(a (nested) string) does not get highlighted correctly + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/sample.css b/library/Text_Highlighter/sample.css new file mode 100644 index 000000000..b4b38c5fc --- /dev/null +++ b/library/Text_Highlighter/sample.css @@ -0,0 +1,62 @@ +.hl-main ol { + line-height: 1.0; +} +.hl-default { + color: Black; +} +.hl-code { + color: Black; +} +.hl-brackets { + color: Olive; +} +.hl-comment { + color: Purple; +} +.hl-quotes { + color: Darkred; +} +.hl-string { + color: Red; +} +.hl-identifier { + color: Blue; +} +.hl-builtin { + color: Teal; +} +.hl-reserved { + color: Green; +} +.hl-inlinedoc { + color: Blue; +} +.hl-var { + color: Darkblue; +} +.hl-url { + color: Blue; +} +.hl-special { + color: Navy; +} +.hl-number { + color: Maroon; +} +.hl-inlinetags { + color: Blue; +} +.hl-main { + background: #ccc none repeat scroll 0 0; + color: #000; +/* background-color: White; */ +} +.hl-gutter { + background-color: #999999; + color: White +} +.hl-table { + font-family: courier; + font-size: 12px; + border: solid 1px Lightgrey; +} diff --git a/library/Text_Highlighter/sh.xml b/library/Text_Highlighter/sh.xml new file mode 100644 index 000000000..1250de3bc --- /dev/null +++ b/library/Text_Highlighter/sh.xml @@ -0,0 +1,242 @@ + + + + + + + + + + This highlighter is EXPERIMENTAL. It may work incorrectly. + It is a crude hack of the perl syntax, which itself wasn't so good. + But this seems to work OK. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/sql.xml b/library/Text_Highlighter/sql.xml new file mode 100644 index 000000000..19cae49a0 --- /dev/null +++ b/library/Text_Highlighter/sql.xml @@ -0,0 +1,496 @@ + + + + + + + + + + + Based on SQL-99 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/vbscript.xml b/library/Text_Highlighter/vbscript.xml new file mode 100644 index 000000000..09c37ffde --- /dev/null +++ b/library/Text_Highlighter/vbscript.xml @@ -0,0 +1,305 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/library/Text_Highlighter/xml.xml b/library/Text_Highlighter/xml.xml new file mode 100644 index 000000000..2271ff3ae --- /dev/null +++ b/library/Text_Highlighter/xml.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/view/templates/head.tpl b/view/templates/head.tpl index b4f82aca4..70add44c2 100644 --- a/view/templates/head.tpl +++ b/view/templates/head.tpl @@ -7,6 +7,7 @@ + diff --git a/view/theme/frio/templates/head.tpl b/view/theme/frio/templates/head.tpl index 57148736d..72d7cbf07 100644 --- a/view/theme/frio/templates/head.tpl +++ b/view/theme/frio/templates/head.tpl @@ -12,6 +12,7 @@ + From 8b4c41671372a074750798080d8e2d262552bee4 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Thu, 16 Jun 2016 20:16:16 +0200 Subject: [PATCH 039/498] frio: events - split event form in different sections --- include/datetime.php | 6 +- view/theme/frio/templates/event_form.tpl | 189 +++++++++++++++-------- view/theme/frio/templates/event_head.tpl | 45 +++++- 3 files changed, 168 insertions(+), 72 deletions(-) diff --git a/include/datetime.php b/include/datetime.php index bbb60ba72..4b0bbb576 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -273,7 +273,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : ''; $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : ''; - $input_text = $default ? 'value="' . date($dateformat, $default->getTimestamp()) . '"' : ''; + $input_text = $default ? date($dateformat, $default->getTimestamp()) : ''; $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : ''; $pickers = ''; @@ -283,7 +283,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke $extra_js = ''; $pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'"; if($minfrom != '') - $extra_js .= "\$('id_#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; + $extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; if($maxfrom != '') $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; @@ -296,7 +296,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke $tpl = get_markup_template('field_input.tpl'); $o .= replace_macros($tpl,array( - '$field' => array($id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '" '), + '$field' => array($id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'), )); // $o .= "
      "; // $o .= '
      '; diff --git a/view/theme/frio/templates/event_form.tpl b/view/theme/frio/templates/event_form.tpl index ebe4faa35..3a6161198 100644 --- a/view/theme/frio/templates/event_form.tpl +++ b/view/theme/frio/templates/event_form.tpl @@ -1,84 +1,139 @@

      {{$title}}

      -

      -{{$desc}} -

      +{{* The event edit navigation menu (text input, permissions, preview, filebrowser) *}} +
      - - - - + + + + -{{$s_dsel}} +
      +

      + {{$desc}} +

      -{{$f_dsel}} + {{$s_dsel}} -{{include file="field_checkbox.tpl" field=$nofinish}} + {{$f_dsel}} -{{include file="field_checkbox.tpl" field=$adjust}} + {{include file="field_checkbox.tpl" field=$nofinish}} -{{include file="field_input.tpl" field=$summary}} + {{include file="field_checkbox.tpl" field=$adjust}} -
      -
      {{$d_text}}
      - -
      + + -
    1. - - - -
    2. -
    3. - - - -
    4. -
    5. - - - -
    6. -
    7. - - - -
    8. -
      -
      - -
      {{$l_text}}
      - - -
      - -
      {{$sh_text}}
      -
      - -{{$acl}} - -
      - -
      diff --git a/view/theme/frio/templates/event_head.tpl b/view/theme/frio/templates/event_head.tpl index e11f93ea7..e0cfceec9 100644 --- a/view/theme/frio/templates/event_head.tpl +++ b/view/theme/frio/templates/event_head.tpl @@ -159,13 +159,17 @@ $("#comment-edit-text-desc").bbco_autocomplete('bbcode'); {{/if}} - $('#event-share-checkbox').change(function() { + $('body').change("#event-share-checkbox", function() { - if ($('#event-share-checkbox').is(':checked')) { + if ($('#event-share-checkbox').is(':checked') && !( $('#event-share-checkbox').attr("disabled"))) { $('#acl-wrapper').show(); + $("a#event-perms-lnk").parent("li").show(); + toggleEventNav("a#event-perms-lnk"); + eventAclActive(); } else { $('#acl-wrapper').hide(); + $("a#event-perms-lnk").parent("li").hide(); } }).trigger('change'); @@ -182,7 +186,44 @@ }).trigger('change'); + // Event nav menu. + $("body").on("click", "#event-nav li a", function(e){ + e.preventDefault(); + toggleEventNav(this); + }); + }); + From c99da380cf3d22f023e7526881d78027f8f41acf Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 10:33:12 +0200 Subject: [PATCH 040/498] frio: events - adapt changes to the templates of the other themes --- mod/events.php | 1 + view/templates/event_form.tpl | 20 +- view/templates/event_head.tpl | 17 +- view/theme/frio/js/modal.js | 2 +- view/theme/frio/templates/event.tpl | 2 +- view/theme/frio/templates/event_form.tpl | 259 +++++++++++--------- view/theme/frio/templates/event_head.tpl | 69 +++++- view/theme/frio/templates/events-js.tpl | 2 +- view/theme/frost/js/theme.js | 4 +- view/theme/frost/templates/event_form.tpl | 20 +- view/theme/quattro/templates/event_form.tpl | 20 +- view/theme/vier/templates/event_form.tpl | 20 +- 12 files changed, 247 insertions(+), 189 deletions(-) diff --git a/mod/events.php b/mod/events.php index f6872a616..778613609 100644 --- a/mod/events.php +++ b/mod/events.php @@ -576,6 +576,7 @@ function events_content(&$a) { '$t_orig' => $t_orig, '$summary' => array('summary', t('Title:'), $t_orig, '', '*'), '$sh_text' => t('Share this event'), + '$share' => array('share', t('Share this event'), $sh_checked, ''), '$sh_checked' => $sh_checked, '$nofinish' => array('nofinish', t('Finish date/time is not known or not relevant'), $n_checked), '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked), diff --git a/view/templates/event_form.tpl b/view/templates/event_form.tpl index 1c065477b..de8de44e8 100644 --- a/view/templates/event_form.tpl +++ b/view/templates/event_form.tpl @@ -12,24 +12,15 @@ -
      {{$s_text}}
      {{$s_dsel}} -
      {{$f_text}}
      {{$f_dsel}} -
      +{{include file="field_checkbox.tpl" field=$nofinish}} -
      {{$n_text}}
      +{{include file="field_checkbox.tpl" field=$adjust}} -
      - -
      {{$a_text}}
      - -
      - -
      {{$t_text}}
      - +{{include file="field_input.tpl" field=$summary}}
      {{$d_text}}
      @@ -41,8 +32,9 @@
      -
      {{$sh_text}}
      -
      +{{if ! $eid}} +{{include file="field_checkbox.tpl" field=$share}} +{{/if}} {{$acl}} diff --git a/view/templates/event_head.tpl b/view/templates/event_head.tpl index de5ad6070..0c015f4bf 100644 --- a/view/templates/event_head.tpl +++ b/view/templates/event_head.tpl @@ -21,6 +21,14 @@ $('#event-edit-preview').val(0); } + // disable the input for the finish date if it is not available + function enableDisableFinishDate() { + if( $('#id_nofinish').is(':checked')) + $('#id_finish_text').prop("disabled", true); + else + $('#id_finish_text').prop("disabled", false); + } + $(document).ready(function() { $('#events-calendar').fullCalendar({ @@ -152,9 +160,9 @@ $("#comment-edit-text-desc").bbco_autocomplete('bbcode'); {{/if}} - $('#event-share-checkbox').change(function() { + $('#id_share').change(function() { - if ($('#event-share-checkbox').is(':checked')) { + if ($('#id_share').is(':checked')) { $('#acl-wrapper').show(); } else { @@ -175,6 +183,11 @@ }).trigger('change'); + // disable the finish time input if the user disable it + $('body').change("#id_nofinish", function() { + enableDisableFinishDate() + }).trigger('change'); + }); diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index f99946019..d27048e2d 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -153,7 +153,7 @@ Dialog._load = function(url) { */ function loadModalTitle() { // clear the text of the title - //$("#modal-title").empty(); + $("#modal-title").empty(); // hide the first element with the class "heading" of the modal body $("#modal-body .heading").first().hide(); diff --git a/view/theme/frio/templates/event.tpl b/view/theme/frio/templates/event.tpl index 380bc7cb1..27965bb59 100644 --- a/view/theme/frio/templates/event.tpl +++ b/view/theme/frio/templates/event.tpl @@ -11,7 +11,7 @@
      {{if $event.item.plink}}{{/if}} - {{if $event.edit}}{{/if}} + {{if $event.edit}}{{/if}}
      diff --git a/view/theme/frio/templates/event_form.tpl b/view/theme/frio/templates/event_form.tpl index 3a6161198..df97e01ff 100644 --- a/view/theme/frio/templates/event_form.tpl +++ b/view/theme/frio/templates/event_form.tpl @@ -1,139 +1,162 @@ -

      {{$title}}

      +
      +

      {{$title}}

      -{{* The event edit navigation menu (text input, permissions, preview, filebrowser) *}} - + {{* The event edit navigation menu (text input, permissions, preview, filebrowser) *}} + -
      +
      + - - - - + + + + -
      -

      - {{$desc}} -

      +
      +

      + {{$desc}} +

      - {{$s_dsel}} + {{$s_dsel}} - {{$f_dsel}} + {{$f_dsel}} - {{include file="field_checkbox.tpl" field=$nofinish}} + {{include file="field_checkbox.tpl" field=$nofinish}} - {{include file="field_checkbox.tpl" field=$adjust}} + {{include file="field_checkbox.tpl" field=$adjust}} - {{include file="field_input.tpl" field=$summary}} + {{include file="field_input.tpl" field=$summary}} -
      -
      {{$d_text}}
      - - +
      +
      + +
      +
      {{$l_text}}
      + + +
      +
      + + {{if ! $eid}} + {{include file="field_checkbox.tpl" field=$share}} + {{/if}} + +
      + +
      -
      -
      {{$l_text}}
      - - -
      + -
      {{$sh_text}}
      -
      + - - +
      + +
      +
      - - -
      - - - + \ No newline at end of file diff --git a/view/theme/frio/templates/event_head.tpl b/view/theme/frio/templates/event_head.tpl index e0cfceec9..dc1457a87 100644 --- a/view/theme/frio/templates/event_head.tpl +++ b/view/theme/frio/templates/event_head.tpl @@ -5,16 +5,18 @@ @@ -200,18 +223,19 @@ // the following functions show/hide the specific event-edit content // in dependence of the selected nav function eventAclActive() { - $("#event-edit-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide(); + $("#event-edit-wrapper, #event-preview").hide(); $("#event-acl-wrapper").show(); } - function previewActive() { - $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").hide(); - preview_post(); + function eventPreviewActive() { + $("#event-acl-wrapper, #event-edit-wrapper").hide(); + $("#event-preview").show(); + doEventPreview(); } function eventEditActive() { - $("#event-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide(); + $("#event-acl-wrapper, #event-preview").hide(); $("#event-edit-wrapper").show(); //make sure jot text does have really the active class (we do this because there are some @@ -226,4 +250,25 @@ // add the active class to the parent of the link which was selected $(elm).parent("li").addClass("active"); } + + // this function load the content of the edit url into a modal + function eventEdit(url) { + var char = qOrAmp(url); + url = url + char + 'mode=none'; + + $.get(url, function(data) { + $("#modal-body").empty(); + $("#modal-body").append(data); + }).done(function() { + loadModalTitle(); + }); + } + + // disable the input for the finish date if it is not available + function enableDisableFinishDate() { + if( $('#id_nofinish').is(':checked')) + $('#id_finish_text').prop("disabled", true); + else + $('#id_finish_text').prop("disabled", false); + } diff --git a/view/theme/frio/templates/events-js.tpl b/view/theme/frio/templates/events-js.tpl index 93c131b36..dcd522c58 100644 --- a/view/theme/frio/templates/events-js.tpl +++ b/view/theme/frio/templates/events-js.tpl @@ -1,7 +1,7 @@
      {{$tabs}} {{include file="section_title.tpl" title=$title}} - +
      diff --git a/view/theme/frost/js/theme.js b/view/theme/frost/js/theme.js index fc1bb643c..038f83e0e 100644 --- a/view/theme/frost/js/theme.js +++ b/view/theme/frost/js/theme.js @@ -70,9 +70,9 @@ $(document).ready(function() { return false; });*/ - $('#event-share-checkbox').change(function() { + $('#id_share').change(function() { - if ($('#event-share-checkbox').is(':checked')) { + if ($('#id_share').is(':checked')) { $('#acl-wrapper').show(); } else { diff --git a/view/theme/frost/templates/event_form.tpl b/view/theme/frost/templates/event_form.tpl index 43f2a782f..27631d9f7 100644 --- a/view/theme/frost/templates/event_form.tpl +++ b/view/theme/frost/templates/event_form.tpl @@ -12,24 +12,15 @@ -
      {{$s_text}}
      {{$s_dsel}} -
      {{$f_text}}
      {{$f_dsel}} -
      +{{include file="field_checkbox.tpl" field=$nofinish}} -
      {{$n_text}}
      +{{include file="field_checkbox.tpl" field=$adjust}} -
      - -
      {{$a_text}}
      - -
      - -
      {{$t_text}}
      - +{{include file="field_input.tpl" field=$summary}}
      {{$d_text}}
      @@ -40,8 +31,9 @@
      -
      {{$sh_text}}
      -
      +{{if ! $eid}} +{{include file="field_checkbox.tpl" field=$share}} +{{/if}} {{$acl}} diff --git a/view/theme/quattro/templates/event_form.tpl b/view/theme/quattro/templates/event_form.tpl index 098b57850..484fe6744 100644 --- a/view/theme/quattro/templates/event_form.tpl +++ b/view/theme/quattro/templates/event_form.tpl @@ -10,23 +10,23 @@ - {{include file="field_custom.tpl" field=array('start_text', $s_text, $s_dsel, "")}} - {{include file="field_custom.tpl" field=array('finish_text', $f_text, $f_dsel, "")}} + {{$s_dsel}} - {{include file="field_checkbox.tpl" field=array('nofinish', $n_text, $n_checked, "")}} - {{include file="field_checkbox.tpl" field=array('adjust', $a_text, $a_checked, "")}} + {{$f_dsel}} + + {{include file="field_checkbox.tpl" field=$nofinish}} + + {{include file="field_checkbox.tpl" field=$adjust}}
      - {{include file="field_input.tpl" field=array('summary', $t_text, $t_orig, "")}} + {{include file="field_input.tpl" field=$summary}} {{include file="field_textarea.tpl" field=array('desc', $d_text, $d_orig, "")}} {{include file="field_textarea.tpl" field=array('location', $l_text, $l_orig, "")}}
      -
      - - - -
      + {{if ! $eid}} + {{include file="field_checkbox.tpl" field=$share}} + {{/if}} {{$acl}} diff --git a/view/theme/vier/templates/event_form.tpl b/view/theme/vier/templates/event_form.tpl index 4f3240de8..0507c36aa 100644 --- a/view/theme/vier/templates/event_form.tpl +++ b/view/theme/vier/templates/event_form.tpl @@ -13,24 +13,15 @@ -
      {{$s_text}}
      {{$s_dsel}} -
      {{$f_text}}
      {{$f_dsel}} -
      +{{include file="field_checkbox.tpl" field=$nofinish}} -
      {{$n_text}}
      +{{include file="field_checkbox.tpl" field=$adjust}} -
      - -
      {{$a_text}}
      - -
      - -
      {{$t_text}}
      - +{{include file="field_input.tpl" field=$summary}}
      {{$d_text}}
      @@ -61,8 +52,9 @@
      -
      {{$sh_text}}
      -
      +{{if ! $eid}} +{{include file="field_checkbox.tpl" field=$share}} +{{/if}} {{$acl}} From 2f266382c5c096eacd3127786fc8126f4ee8d4a1 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 11:02:27 +0200 Subject: [PATCH 041/498] code highlight - add docu --- doc/BBCode.md | 6 ++++++ doc/de/BBCode.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/doc/BBCode.md b/doc/BBCode.md index 186b1cda9..d22f7afa5 100644 --- a/doc/BBCode.md +++ b/doc/BBCode.md @@ -42,6 +42,12 @@ Block

       

      +
      [code=php]function text_highlight($s,$lang)[/code]
      + +
      1.  function text_highlight($s,$lang)
      + +

       

      +
      [quote]quote[/quote]
      quote
      diff --git a/doc/de/BBCode.md b/doc/de/BBCode.md index cd9fa7673..d852a4a4f 100644 --- a/doc/de/BBCode.md +++ b/doc/de/BBCode.md @@ -42,6 +42,12 @@ Block Tags

       

      +
      [code=php]function text_highlight($s,$lang)[/code]
      + +
      1.  function text_highlight($s,$lang)
      + +

       

      +
      [quote]Zitat[/quote]
      Zitat
      From 0148d0e5d2676d174305930110850ce74f2fa474 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 11:18:54 +0200 Subject: [PATCH 042/498] frio - event - correct some js --- view/templates/event_head.tpl | 2 +- view/theme/frio/templates/event_head.tpl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/view/templates/event_head.tpl b/view/templates/event_head.tpl index 0c015f4bf..01c69b8b3 100644 --- a/view/templates/event_head.tpl +++ b/view/templates/event_head.tpl @@ -184,7 +184,7 @@ }).trigger('change'); // disable the finish time input if the user disable it - $('body').change("#id_nofinish", function() { + $('#id_nofinish').change(function() { enableDisableFinishDate() }).trigger('change'); diff --git a/view/theme/frio/templates/event_head.tpl b/view/theme/frio/templates/event_head.tpl index dc1457a87..ee60f183e 100644 --- a/view/theme/frio/templates/event_head.tpl +++ b/view/theme/frio/templates/event_head.tpl @@ -163,7 +163,7 @@ {{/if}} // go to the permissions tab if the checkbox is checked - $('body').change("#id_share", function() { + $('body').on("change", "#id_share", function() { if ($('#id_share').is(':checked') && !( $('#id_share').attr("disabled"))) { $('#acl-wrapper').show(); @@ -178,7 +178,7 @@ }).trigger('change'); // disable the finish time input if the user disable it - $('body').change("#id_nofinish", function() { + $('body').on("change", "#id_nofinish", function() { enableDisableFinishDate() }).trigger('change'); From 606f42701ccd545a04fdf0b2a6bea3bce2ee9dd0 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 14:09:18 +0200 Subject: [PATCH 043/498] frio - event - some js and template refactoring + event view css styling --- mod/events.php | 6 +- view/theme/frio/css/style.css | 20 ++++ view/theme/frio/js/event.js | 124 +++++++++++++++++++++++ view/theme/frio/templates/event.tpl | 19 ++-- view/theme/frio/templates/event_form.tpl | 47 +++++---- view/theme/frio/templates/event_head.tpl | 119 ---------------------- view/theme/frio/templates/events-js.tpl | 2 +- 7 files changed, 187 insertions(+), 150 deletions(-) create mode 100644 view/theme/frio/js/event.js diff --git a/mod/events.php b/mod/events.php index 778613609..e4526ac59 100644 --- a/mod/events.php +++ b/mod/events.php @@ -455,6 +455,7 @@ function events_content(&$a) { '$baseurl' => $a->get_baseurl(), '$tabs' => $tabs, '$title' => t('Events'), + '$view' => t('View'), '$new_event'=> array($a->get_baseurl().'/events/new',t('Create New Event'),'',''), '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), @@ -462,7 +463,6 @@ function events_content(&$a) { '$events' => $events, - // eignene "today" => t("today"), "month" => t("month"), "week" => t("week"), @@ -582,7 +582,9 @@ function events_content(&$a) { '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked), '$preview' => t('Preview'), '$acl' => $acl, - '$submit' => t('Submit') + '$submit' => t('Submit'), + '$basic' => t("Basic"), + '$advanced' => t("Advanced") )); diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 185888b71..deb3436de 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -1954,15 +1954,35 @@ td.fc-day { .event-wrapper .event-owner { margin-bottom: 15px; } +.event-wrapper .event-owner img { + display: block; +} .event-owner img { margin-right: 5px; height: 48px; width: 48; border-radius: 3px; } +.event-wrapper .vevent { + margin-left: 0; + margin-right: 0; + box-shadow: 1.5px 0 0 0 rgba(0, 0, 0, .1) inset; +} .event-wrapper .event-buttons { margin-top: 15px; } +#event-form-wrapper { + padding-top: 5px; +} +#event-edit-form-wrapper { + padding-top: 15px; +} +#event-nav a { + color: #555; +} +#event-edit-form-wrapper #event-edit-time { + padding: 10px 0; +} /* * Overwriting for transparency and other colors */ diff --git a/view/theme/frio/js/event.js b/view/theme/frio/js/event.js new file mode 100644 index 000000000..c6a3541f6 --- /dev/null +++ b/view/theme/frio/js/event.js @@ -0,0 +1,124 @@ +$(document).ready(function() { + // go to the permissions tab if the checkbox is checked + $('body').on("change", "#id_share", function() { + + if ($('#id_share').is(':checked') && !( $('#id_share').attr("disabled"))) { + $('#acl-wrapper').show(); + $("a#event-perms-lnk").parent("li").show(); + toggleEventNav("a#event-perms-lnk"); + eventAclActive(); + } + else { + $('#acl-wrapper').hide(); + $("a#event-perms-lnk").parent("li").hide(); + } + }).trigger('change'); + + // disable the finish time input if the user disable it + $('body').on("change", "#id_nofinish", function() { + enableDisableFinishDate() + }).trigger('change'); + + // js for the permission sextion + $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { + var selstr; + $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() { + selstr = $(this).text(); + $('#jot-public').hide(); + }); + if(selstr == null) { + $('#jot-public').show(); + } + + }).trigger('change'); + + // Change the event nav menu.tabs on click + $("body").on("click", "#event-nav > li > a", function(e){ + e.preventDefault(); + toggleEventNav(this); + }); + + // this is experimental. We maybe can make use of it to inject + // some js code while the event modal opens + //$('body').on('show.bs.modal', function () { + // enableDisableFinishDate(); + //}); + + // clear some elements (e.g. the event-preview container) when + // selecting a event nav link so it don't appear more than once + $('body').on("click", "#event-nav a", function(e) { + $("#event-preview").empty(); + e.preventDefault(); + }); + +}); + +// Load the html of the actual event and incect the output to the +// event-edit section +function doEventPreview() { + $('#event-edit-preview').val(1); + $.post('events',$('#event-edit-form').serialize(), function(data) { + $("#event-preview").append(data); + }); + $('#event-edit-preview').val(0); +} + + +// this function load the content of the edit url into a modal +function eventEdit(url) { + var char = qOrAmp(url); + url = url + char + 'mode=none'; + + $.get(url, function(data) { + $("#modal-body").empty(); + $("#modal-body").append(data); + }).done(function() { + loadModalTitle(); + }); +} + +// the following functions show/hide the specific event-edit content +// in dependence of the selected nav +function eventAclActive() { + $("#event-edit-wrapper, #event-preview, #event-desc-wrapper").hide(); + $("#event-acl-wrapper").show(); +} + + +function eventPreviewActive() { + $("#event-acl-wrapper, #event-edit-wrapper, #event-desc-wrapper").hide(); + $("#event-preview").show(); + doEventPreview(); +} + +function eventEditActive() { + $("#event-acl-wrapper, #event-preview, #event-desc-wrapper").hide(); + $("#event-edit-wrapper").show(); + + //make sure jot text does have really the active class (we do this because there are some + // other events which trigger jot text + toggleEventNav($("#event-edit-lnk")); +} + +function eventDescActive() { + $("#event-edit-wrapper, #event-preview, #event-acl-wrapper").hide(); + $("#event-desc-wrapper").show(); +} + +// Give the active "event-nav" list element the class "active" +function toggleEventNav (elm) { + // select all li of #event-nav and remove the active class + $(elm).closest("#event-nav").children("li").removeClass("active"); + // add the active class to the parent of the link which was selected + $(elm).parent("li").addClass("active"); +} + + + +// disable the input for the finish date if it is not available +function enableDisableFinishDate() { + if( $('#id_nofinish').is(':checked')) + $('#id_finish_text').prop("disabled", true); + else + $('#id_finish_text').prop("disabled", false); +} diff --git a/view/theme/frio/templates/event.tpl b/view/theme/frio/templates/event.tpl index 27965bb59..32e740581 100644 --- a/view/theme/frio/templates/event.tpl +++ b/view/theme/frio/templates/event.tpl @@ -1,16 +1,23 @@ + {{foreach $events as $event}}
      -
      - {{if $event.item.author_name}} - {{$event.item.author_name}} - {{/if}} +
      +
      + {{if $event.item.author_name}} + + {{$event.item.author_name}} + {{/if}} +
      +
      + {{$event.html}} +
      - {{$event.html}}
      - {{if $event.item.plink}}{{/if}} + {{if $event.item.plink}}{{/if}} {{if $event.edit}}{{/if}}
      diff --git a/view/theme/frio/templates/event_form.tpl b/view/theme/frio/templates/event_form.tpl index df97e01ff..6ccce703b 100644 --- a/view/theme/frio/templates/event_form.tpl +++ b/view/theme/frio/templates/event_form.tpl @@ -1,4 +1,5 @@ - +

      {{$title}}

      @@ -6,7 +7,8 @@
      - - {{if ! $eid}} - {{include file="field_checkbox.tpl" field=$share}} - {{/if}} - -
      - -
      -
      From d0900c5389dc2b0a753d7d022928f569951b81e2 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 14:35:24 +0200 Subject: [PATCH 045/498] Merge develop into 1206-events-template - restore gitignore --- .gitignore | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.gitignore b/.gitignore index 77151060d..b300f579e 100644 --- a/.gitignore +++ b/.gitignore @@ -42,16 +42,3 @@ nbproject #ignore local folder /local/ - -#other stuff -.directory -.gitignore - -/view/theme/Friendiboot -/view/theme/Viereinhalb -/view/theme/blog -/view/theme/boheme -/view/theme/clean -/view/theme/suckerberg - -/addon/frio_hovercard From 134d5949d5d1ddb3c03c5f6aa294edf73b027350 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 14:39:59 +0200 Subject: [PATCH 046/498] frio - events - restore lost css bracket after merging develop branch --- view/theme/frio/css/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index eda0b3d71..edc4a55a7 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -2040,6 +2040,7 @@ td.fc-day { } #event-edit-form-wrapper #event-edit-time { padding: 10px 0; +} /* Profiles Page */ .profile-listing-table { display: table; From 48a77af49d51a203b95e6fb07fcb5a78d40bee1b Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 14:52:42 +0200 Subject: [PATCH 047/498] frio - events - delete unneeded css --- view/theme/frio/css/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index edc4a55a7..bfce21a65 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -1769,8 +1769,8 @@ ul.dropdown-menu li:hover { .contacts-content-wrapper, .suggest-content-wrapper, .common-content-wrapper, .allfriends-content-wrapper, .match-content-wrapper, .dirfind-content-wrapper, .directory-content-wrapper, .manage-content-wrapper, .notes-content-wrapper, -.events-content-wrapper, .message-content-wrapper, .apps-content-wrapper, -.notifications-content-wrapper, .admin-content-wrapper, .group-content-wrapper { +.message-content-wrapper, .apps-content-wrapper, .notifications-content-wrapper, +.admin-content-wrapper, .group-content-wrapper { min-height: calc(100vh - 150px); padding: 15px; padding-bottom: 20px; From b977efc95ca923ccd1a8f6928ba65b40d366e0e2 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Fri, 17 Jun 2016 15:29:01 +0200 Subject: [PATCH 048/498] code highlight - some spacing for readability --- include/text.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/include/text.php b/include/text.php index 16c0845ac..9b34b0884 100644 --- a/include/text.php +++ b/include/text.php @@ -2097,33 +2097,44 @@ function format_network_name($network, $url = 0) { function text_highlight($s,$lang) { if($lang === 'js') $lang = 'javascript'; + if(! strpos('Text_Highlighter',get_include_path())) { set_include_path(get_include_path() . PATH_SEPARATOR . 'library/Text_Highlighter'); } + require_once('library/Text_Highlighter/Text/Highlighter.php'); require_once('library/Text_Highlighter/Text/Highlighter/Renderer/Html.php'); $options = array( 'numbers' => HL_NUMBERS_LI, 'tabsize' => 4, ); + $tag_added = false; $s = trim(html_entity_decode($s,ENT_COMPAT)); $s = str_replace(" ","\t",$s); + + // The highlighter library insists on an opening php tag for php code blocks. If + // it isn't present, nothing is highlighted. So we're going to see if it's present. + // If not, we'll add it, and then quietly remove it after we get the processed output back. + if($lang === 'php') { if(strpos('setRenderer($renderer); - $o = $hl->highlight($s); - $o = str_replace([" ","\n"],["    ",''],$o); - if($tag_added) { - $b = substr($o,0,strpos($o,'
    9. ')); - $e = substr($o,strpos($o,'
    10. ')); - $o = $b . $e; - } + $o = $hl->highlight($s); + $o = str_replace([" ","\n"],["    ",''],$o); + + if($tag_added) { + $b = substr($o,0,strpos($o,'
    11. ')); + $e = substr($o,strpos($o,'
    12. ')); + $o = $b . $e; + } + return('' . $o . ''); } From 22de27327c030a8f494348c52bef3f6a4f85b0fc Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sat, 18 Jun 2016 08:16:09 -0400 Subject: [PATCH 049/498] recreate fix for #2617 on correct branch --- .htaccess | 9 ++++++++- util/.htaccess | 11 +++++++++-- view/.htaccess | 11 +++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.htaccess b/.htaccess index 1b63f9ad6..2348cdc38 100644 --- a/.htaccess +++ b/.htaccess @@ -4,7 +4,14 @@ AddType audio/ogg .oga #AddHandler php53-cgi .php -Deny from all + + #Apache 2.4 + Require all denied + + + #Apache 2.2 + Deny from all + diff --git a/util/.htaccess b/util/.htaccess index b311c14c2..7b1f94f0e 100644 --- a/util/.htaccess +++ b/util/.htaccess @@ -1,5 +1,12 @@ Options -Indexes -# Remove the following line or modify it to run the string translator utility -Deny from all +# Remove the following lines or modify it to run the string translator utility + + #Apache 2.4 + Require all denied + + + #Apache 2.2 + Deny from all + diff --git a/view/.htaccess b/view/.htaccess index 559a5fcc0..04cd54685 100644 --- a/view/.htaccess +++ b/view/.htaccess @@ -1,3 +1,10 @@ -Deny from all - \ No newline at end of file + + #Apache 2.4 + Require all denied + + + #Apache 2.2 + Deny from all + + From ee0942b96d9b9054d29eb5492bc910e74bc92ff9 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sat, 18 Jun 2016 15:23:35 +0200 Subject: [PATCH 050/498] frio - events - fix double click on date --- view/theme/frio/templates/event_head.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/frio/templates/event_head.tpl b/view/theme/frio/templates/event_head.tpl index a44fd30be..3e7dfc1c5 100644 --- a/view/theme/frio/templates/event_head.tpl +++ b/view/theme/frio/templates/event_head.tpl @@ -45,7 +45,7 @@ }, loading: function(isLoading, view) { if(!isLoading) { - $('td.fc-day').dblclick(function() { window.location.href='/events/new?start='+$(this).data('date'); }); + $('td.fc-day').dblclick(function() { addToModal('/events/new?start='+$(this).data('date')); }); } }, From e512a83ecc003a5f63329193ce25bde2d96d1e6d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 Jun 2016 01:07:20 +0200 Subject: [PATCH 051/498] Massively updated avatar handling --- include/Contact.php | 24 +++++++- include/bbcode.php | 11 +++- include/conversation.php | 126 +++++++++++++++++++++++++-------------- include/dbstructure.php | 2 + include/dfrn.php | 20 ++++--- include/threads.php | 6 +- mod/community.php | 12 ++-- mod/display.php | 14 +---- mod/network.php | 13 +--- mod/notes.php | 2 +- mod/profile.php | 6 +- mod/search.php | 16 ++--- object/Item.php | 25 +++++--- 13 files changed, 169 insertions(+), 108 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 86ef4a30f..896edaac7 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -451,8 +451,18 @@ function get_contact($url, $uid = 0) { $data = probe_url($url); // Does this address belongs to a valid network? - if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) - return 0; + if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) { + if ($uid != 0) + return 0; + + // Get data from the gcontact table + $r = q("SELECT `name`, `nick`, `url`, `photo`, `addr`, `alias`, `network` FROM `gcontact` WHERE `nurl` = '%s'", + dbesc(normalise_link($url))); + if (!$r) + return 0; + + $data = $r[0]; + } $url = $data["url"]; @@ -490,6 +500,16 @@ function get_contact($url, $uid = 0) { return 0; $contactid = $contact[0]["id"]; + + // Update the newly created contact from data in the gcontact table + $r = q("SELECT `location`, `about`, `keywords`, `gender` FROM `gcontact` WHERE `nurl` = '%s'", + dbesc(normalise_link($data["url"]))); + if ($r) { + logger("Update contact ".$data["url"]); + q("UPDATE `contact` SET `location` = '%s', `about` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `id` = %d", + dbesc($r["location"]), dbesc($r["about"]), dbesc($r["keywords"]), + dbesc($r["gender"]), intval($contactid)); + } } if ((count($contact) > 1) AND ($uid == 0) AND ($contactid != 0) AND ($url != "")) diff --git a/include/bbcode.php b/include/bbcode.php index 62f56558f..84425e8ef 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -408,6 +408,11 @@ function bb_ShareAttributes($share, $simplehtml) { if ($itemcache == "") $reldate = (($posted) ? " " . relative_date($posted) : ''); + // We only call this so that a previously unknown contact can be added. + // This is important for the function "get_contact_details_by_url". + // This function then can fetch an entry from the contact table. + get_contact($profile, 0); + $data = get_contact_details_by_url($profile); if (isset($data["name"]) AND isset($data["addr"])) @@ -423,8 +428,8 @@ function bb_ShareAttributes($share, $simplehtml) { if (isset($data["name"])) $author = $data["name"]; - if (isset($data["photo"])) - $avatar = $data["photo"]; + if (isset($data["thumb"])) + $avatar = $data["thumb"]; $preshare = trim($share[1]); @@ -490,6 +495,8 @@ function bb_ShareAttributes($share, $simplehtml) { default: $text = trim($share[1])."\n"; + $avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB); + $tpl = get_markup_template('shared_content.tpl'); $text .= replace_macros($tpl, array( diff --git a/include/conversation.php b/include/conversation.php index 87ad42b04..411ffe388 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -373,15 +373,55 @@ function visible_activity($item) { return true; } +/** + * @brief SQL query for items + */ +function item_query() { + + return "SELECT ".item_fieldlists()." FROM `item` ". + item_joins()." WHERE ".item_condition(); +} + +/** + * @brief All fieldlists that are needed for the item query + */ +function item_fieldlists() { + + return item_fieldlist().", ".zcontact_fieldlist().", ".contact_fieldlist(); +} + +/** + * @brief SQL join for contacts + */ +function item_joins() { + + return contact_join()." ".zcontact_join(); +} + +/** + * @brief Fieldlist for author and owner + */ +function zcontact_fieldlist() { + + return "`author`.`thumb` AS `author-thumb`, `owner`.`thumb` AS `owner-thumb`"; +} + +/** + * @brief Join for author and owner + */ +function zcontact_join() { + + return "LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` + LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`author-id`"; +} + /** * @brief List of all contact fields that are needed for the conversation function */ function contact_fieldlist() { - $fieldlist = "`contact`.`network`, `contact`.`url`, `contact`.`name`, `contact`.`writable`, - `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`alias`"; - - return $fieldlist; + return "`contact`.`network`, `contact`.`url`, `contact`.`name`, `contact`.`writable`, + `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`alias`"; } /** @@ -389,9 +429,15 @@ function contact_fieldlist() { */ function contact_condition() { - $condition = "NOT `contact`.`blocked` AND NOT `contact`.`pending`"; + return "NOT `contact`.`blocked` AND NOT `contact`.`pending`"; +} - return $condition; +/** + * @brief SQL join for contacts + */ +function contact_join() { + + return "INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND ".contact_condition(); } /** @@ -402,11 +448,11 @@ function item_fieldlist() { /* These Fields are not added below (yet). They are here to for bug search. `item`.`type`, +`item`.`object`, `item`.`extid`, `item`.`received`, `item`.`changed`, -`item`.`author-avatar`, -`item`.`object`, +`item`.`moderated`, `item`.`target-type`, `item`.`target`, `item`.`resource-id`, @@ -414,10 +460,8 @@ These Fields are not added below (yet). They are here to for bug search. `item`.`attach`, `item`.`inform`, `item`.`pubmail`, -`item`.`moderated`, `item`.`visible`, `item`.`spam`, -`item`.`starred`, `item`.`bookmark`, `item`.`unseen`, `item`.`deleted`, @@ -430,18 +474,18 @@ These Fields are not added below (yet). They are here to for bug search. `item`.`shadow`, */ - $fieldlist = "`item`.`author-link`, `item`.`verb`, `item`.`id`, `item`.`parent`, `item`.`file`, - `item`.`uid`, `item`.`author-name`, `item`.`location`, `item`.`coord`, - `item`.`title`, `item`.`uri`, `item`.`created`, `item`.`app`, `item`.`guid`, - `item`.`contact-id`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`rendered-hash`, - `item`.`body`, `item`.`rendered-html`, `item`.`private`, `item`.`edited`, + return "`item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`, + `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`, + `item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`, + `item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, + `item`.`commented`, `item`.`created`, `item`.`edited`, + `item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`, + `item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`, + `item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`, + `item`.`location`, `item`.`coord`, `item`.`app`, + `item`.`rendered-hash`, `item`.`rendered-html`, `item`.`allow_cid`, `item`.`allow_gid`, `item`.`deny_cid`, `item`.`deny_gid`, - `item`.`event-id`, `item`.`object-type`, `item`.`starred`, `item`.`created`, - `item`.`postopts`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`, - `item`.`plink`, `item`.`wall`, `item`.`commented`, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`"; - - return $fieldlist; } /** @@ -449,9 +493,7 @@ These Fields are not added below (yet). They are here to for bug search. */ function item_condition() { - $condition = "`item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`"; - - return $condition; + return "`item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`"; } /** @@ -623,7 +665,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comment = ''; $owner_url = ''; - $owner_photo = ''; $owner_name = ''; $sparkle = ''; @@ -668,18 +709,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $tags[] = $prefix."
      ".$tag["term"].""; } - /*foreach(explode(',',$item['tag']) as $tag){ - $tag = trim($tag); - if ($tag!="") { - $t = bbcode($tag); - $tags[] = $t; - if($t[0] == '#') - $hashtags[] = $t; - elseif($t[0] == '@') - $mentions[] = $t; - } - }*/ - $sp = false; $profile_link = best_link_url($item,$sp); if($profile_link === 'mailbox') @@ -689,12 +718,21 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { else $profile_link = zrl($profile_link); - // Don't rely on the author-avatar. It is better to use the data from the contact table - $author_contact = get_contact_details_by_url($item['author-link'], $profile_owner); - if ($author_contact["thumb"]) - $profile_avatar = $author_contact["thumb"]; - else - $profile_avatar = $item['author-avatar']; + if (!isset($item['author-thumb'])) { + $author_contact = get_contact_details_by_url($item['author-link'], $profile_owner); + if ($author_contact["thumb"]) + $item['author-thumb'] = $author_contact["thumb"]; + else + $item['author-thumb'] = $item['author-avatar']; + } + + if (!isset($item['owner-thumb'])) { + $owner_contact = get_contact_details_by_url($item['owner-link'], $profile_owner); + if ($owner_contact["thumb"]) + $item['owner-thumb'] = $owner_contact["thumb"]; + else + $item['owner-thumb'] = $item['owner-avatar']; + } $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location',$locate); @@ -762,7 +800,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'name' => $profile_name_e, 'sparkle' => $sparkle, 'lock' => $lock, - 'thumb' => App::remove_baseurl(proxy_url($profile_avatar, false, PROXY_SIZE_THUMB)), + 'thumb' => App::remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), 'title' => $item['title_e'], 'body' => $body_e, 'tags' => $tags_e, @@ -781,7 +819,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'indent' => '', 'owner_name' => $owner_name_e, 'owner_url' => $owner_url, - 'owner_photo' => proxy_url($owner_photo, false, PROXY_SIZE_THUMB), + 'owner_photo' => App::remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), 'plink' => get_plink($item), 'edpost' => false, 'isstarred' => $isstarred, diff --git a/include/dbstructure.php b/include/dbstructure.php index 8ae3ae6c8..549d077ed 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -1298,6 +1298,8 @@ function db_definition() { "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"), "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "gcontact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), + "owner-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), + "author-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"), "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"), diff --git a/include/dfrn.php b/include/dfrn.php index c9b907acc..9828763bf 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -1631,17 +1631,23 @@ class dfrn { $fields = array( 'owner-link' => array($old["url"], $relocate["url"]), 'author-link' => array($old["url"], $relocate["url"]), - 'owner-avatar' => array($old["photo"], $relocate["photo"]), - 'author-avatar' => array($old["photo"], $relocate["photo"]), + //'owner-avatar' => array($old["photo"], $relocate["photo"]), + //'author-avatar' => array($old["photo"], $relocate["photo"]), ); - foreach ($fields as $n=>$f){ - $x = q("UPDATE `item` SET `%s` = '%s' WHERE `%s` = '%s' AND `uid` = %d", - $n, dbesc($f[1]), + foreach ($fields as $n=>$f) { + $r = q("SELECT `id` FROM `item` WHERE `%s` = '%s' AND `uid` = %d LIMIT 1", $n, dbesc($f[0]), intval($importer["importer_uid"])); - if ($x === false) - return false; + + if ($r) { + $x = q("UPDATE `item` SET `%s` = '%s' WHERE `%s` = '%s' AND `uid` = %d", + $n, dbesc($f[1]), + $n, dbesc($f[0]), + intval($importer["importer_uid"])); + if ($x === false) + return false; } + } /// @TODO /// merge with current record, current contents have priority diff --git a/include/threads.php b/include/threads.php index 0320eaa01..0b2b26e8d 100644 --- a/include/threads.php +++ b/include/threads.php @@ -1,7 +1,9 @@ profile['uid']), intval($item_id) ); + if(!$r && local_user()) { // Check if this is another person's link to a post that we have $r = q("SELECT `item`.uri FROM `item` @@ -385,13 +382,9 @@ function display_content(&$a, $update = 0) { if($r) { $item_uri = $r[0]['uri']; - $r = q("SELECT %s, %s FROM `item` - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s - WHERE %s AND `item`.`uid` = %d + $r = q(item_query()." AND `item`.`uid` = %d AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d) ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ", - item_fieldlist(), contact_fieldlist(), - contact_condition(), item_condition(), intval(local_user()), dbesc($item_uri), intval(local_user()) @@ -399,7 +392,6 @@ function display_content(&$a, $update = 0) { } } - if($r) { if((local_user()) && (local_user() == $a->profile['uid'])) { diff --git a/mod/network.php b/mod/network.php index ba97b4a4c..1ac732d11 100644 --- a/mod/network.php +++ b/mod/network.php @@ -720,14 +720,12 @@ function network_content(&$a, $update = 0) { $sql_order = "`item`.`received`"; // "New Item View" - show all items unthreaded in reverse created date order - $items = q("SELECT %s, %s FROM $sql_table $sql_post_table - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s + $items = q("SELECT %s FROM $sql_table $sql_post_table %s WHERE %s AND `item`.`uid` = %d $simple_update $sql_extra $sql_nets ORDER BY $sql_order DESC $pager_sql ", - item_fieldlist(), contact_fieldlist(), - contact_condition(), item_condition(), + item_fieldlists(), item_joins(), item_condition(), intval($_SESSION['uid']) ); @@ -806,14 +804,9 @@ function network_content(&$a, $update = 0) { $items = array(); foreach ($parents_arr AS $parents) { -// $sql_extra ORDER BY `item`.`commented` DESC LIMIT %d", - $thread_items = q("SELECT %s, %s FROM `item` - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s - WHERE %s AND `item`.`uid` = %d + $thread_items = q(item_query()." AND `item`.`uid` = %d AND `item`.`parent` = %d ORDER BY `item`.`commented` DESC LIMIT %d", - item_fieldlist(), contact_fieldlist(), - contact_condition(), item_condition(), intval(local_user()), intval($parents), intval($max_comments + 1) diff --git a/mod/notes.php b/mod/notes.php index 8d93fc13d..24d541be5 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -108,7 +108,7 @@ function notes_content(&$a,$update = false) { $parents_arr[] = $rr['item_id']; $parents_str = implode(', ', $parents_arr); - $r = q("SELECT %s, %s FROM `item` + $r = q("SELECT %s FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s) $sql_extra diff --git a/mod/profile.php b/mod/profile.php index 88de0227b..67db5d0d9 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -303,13 +303,9 @@ function profile_content(&$a, $update = 0) { $parents_arr[] = $rr['item_id']; $parents_str = implode(', ', $parents_arr); - $items = q("SELECT %s, %s FROM `item` - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s - WHERE %s AND `item`.`uid` = %d + $items = q(item_query()." AND `item`.`uid` = %d AND `item`.`parent` IN (%s) $sql_extra ", - item_fieldlist(), contact_fieldlist(), - contact_condition(), item_condition(), intval($a->profile['profile_uid']), dbesc($parents_str) ); diff --git a/mod/search.php b/mod/search.php index 99ec6c5f7..d2251ce58 100644 --- a/mod/search.php +++ b/mod/search.php @@ -191,14 +191,12 @@ function search_content(&$a) { if($tag) { logger("Start tag search for '".$search."'", LOGGER_DEBUG); - $r = q("SELECT STRAIGHT_JOIN %s, %s + $r = q("SELECT STRAIGHT_JOIN %s FROM `term` - INNER JOIN `item` ON `item`.`id`=`term`.`oid` - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s + INNER JOIN `item` ON `item`.`id`=`term`.`oid` %s WHERE %s AND (`term`.`uid` = 0 OR (`term`.`uid` = %d AND NOT `term`.`global`)) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s' ORDER BY term.created DESC LIMIT %d , %d ", - item_fieldlist(), contact_fieldlist(), - contact_condition(), item_condition(), + item_fieldlists(), item_joins(), item_condition(), intval(local_user()), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)), intval($a->pager['start']), intval($a->pager['itemspage'])); @@ -211,14 +209,12 @@ function search_content(&$a) { $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); } - $r = q("SELECT STRAIGHT_JOIN %s, %s - FROM `item` - INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s + $r = q("SELECT STRAIGHT_JOIN %s + FROM `item` %s WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`)) $sql_extra GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d", - item_fieldlist(), contact_fieldlist(), - contact_condition(), item_condition(), + item_fieldlists(), item_joins(), item_condition(), intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage'])); } diff --git a/object/Item.php b/object/Item.php index ad3da4701..e6d6bd45f 100644 --- a/object/Item.php +++ b/object/Item.php @@ -150,12 +150,21 @@ class Item extends BaseObject { else $profile_link = zrl($profile_link); - // Don't rely on the author-avatar. It is better to use the data from the contact table - $author_contact = get_contact_details_by_url($item['author-link'], $conv->get_profile_owner()); - if ($author_contact["thumb"]) - $profile_avatar = $author_contact["thumb"]; - else - $profile_avatar = $item['author-avatar']; + if (!isset($item['author-thumb'])) { + $author_contact = get_contact_details_by_url($item['author-link'], $conv->get_profile_owner()); + if ($author_contact["thumb"]) + $item['author-thumb'] = $author_contact["thumb"]; + else + $item['author-thumb'] = $item['author-avatar']; + } + + if (!isset($item['owner-thumb'])) { + $owner_contact = get_contact_details_by_url($item['owner-link'], $conv->get_profile_owner()); + if ($owner_contact["thumb"]) + $item['owner-thumb'] = $owner_contact["thumb"]; + else + $item['owner-thumb'] = $item['owner-avatar']; + } $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); call_hooks('render_location',$locate); @@ -364,7 +373,7 @@ class Item extends BaseObject { 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, - 'thumb' => $a->remove_baseurl(proxy_url($profile_avatar, false, PROXY_SIZE_THUMB)), + 'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)), 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => $title_e, @@ -377,7 +386,7 @@ class Item extends BaseObject { 'indent' => $indent, 'shiny' => $shiny, 'owner_url' => $this->get_owner_url(), - 'owner_photo' => proxy_url($this->get_owner_photo(), false, PROXY_SIZE_THUMB), + 'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)), 'owner_name' => htmlentities($owner_name_e), 'plink' => get_plink($item), 'edpost' => ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''), From c3ed6f7d0116dfc5a5a13ee5c88b75bb8c86a76c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 Jun 2016 01:22:32 +0200 Subject: [PATCH 052/498] Improved default value handling --- include/Contact.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/Contact.php b/include/Contact.php index 896edaac7..3ee491e50 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -255,11 +255,20 @@ function get_contact_details_by_url($url, $uid = -1, $default = array()) { $profile["bd"] = (++$current_year)."-".$month."-".$day; } else $profile["bd"] = "0000-00-00"; - } else { + } else $profile = $default; - if (!isset($profile["thumb"]) AND isset($profile["photo"])) - $profile["thumb"] = $profile["photo"]; - } + + if (($profile["photo"] == "") AND isset($default["photo"])) + $profile["photo"] = $default["photo"]; + + if (($profile["name"] == "") AND isset($default["name"])) + $profile["name"] = $default["name"]; + + if (($profile["network"] == "") AND isset($default["network"])) + $profile["network"] = $default["network"]; + + if (!isset($profile["thumb"]) AND isset($profile["photo"])) + $profile["thumb"] = $profile["photo"]; if ((($profile["addr"] == "") OR ($profile["name"] == "")) AND ($profile["gid"] != 0) AND in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) From 91db7a549cdd50ea06ca0b53fc20369ad088141b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 Jun 2016 08:32:38 +0200 Subject: [PATCH 053/498] Optimised the amount of function for the item query --- include/conversation.php | 103 +++++++++++---------------------------- mod/community.php | 13 ++--- mod/notes.php | 15 +++--- 3 files changed, 40 insertions(+), 91 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 411ffe388..ffd9d45e2 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -383,68 +383,10 @@ function item_query() { } /** - * @brief All fieldlists that are needed for the item query + * @brief List of all data fields that are needed for displaying items */ function item_fieldlists() { - return item_fieldlist().", ".zcontact_fieldlist().", ".contact_fieldlist(); -} - -/** - * @brief SQL join for contacts - */ -function item_joins() { - - return contact_join()." ".zcontact_join(); -} - -/** - * @brief Fieldlist for author and owner - */ -function zcontact_fieldlist() { - - return "`author`.`thumb` AS `author-thumb`, `owner`.`thumb` AS `owner-thumb`"; -} - -/** - * @brief Join for author and owner - */ -function zcontact_join() { - - return "LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` - LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`author-id`"; -} - -/** - * @brief List of all contact fields that are needed for the conversation function - */ -function contact_fieldlist() { - - return "`contact`.`network`, `contact`.`url`, `contact`.`name`, `contact`.`writable`, - `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`alias`"; -} - -/** - * @brief SQL condition for contacts - */ -function contact_condition() { - - return "NOT `contact`.`blocked` AND NOT `contact`.`pending`"; -} - -/** - * @brief SQL join for contacts - */ -function contact_join() { - - return "INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND ".contact_condition(); -} - -/** - * @brief List of all item fields that are needed for the conversation function - */ -function item_fieldlist() { - /* These Fields are not added below (yet). They are here to for bug search. `item`.`type`, @@ -475,21 +417,37 @@ These Fields are not added below (yet). They are here to for bug search. */ return "`item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`, - `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`, - `item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`, - `item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, - `item`.`commented`, `item`.`created`, `item`.`edited`, - `item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`, - `item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`, - `item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`, - `item`.`location`, `item`.`coord`, `item`.`app`, - `item`.`rendered-hash`, `item`.`rendered-html`, - `item`.`allow_cid`, `item`.`allow_gid`, `item`.`deny_cid`, `item`.`deny_gid`, - `item`.`id` AS `item_id`, `item`.`network` AS `item_network`"; + `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`, + `item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`, + `item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, + `item`.`commented`, `item`.`created`, `item`.`edited`, + `item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`, + `item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`, + `item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`, + `item`.`location`, `item`.`coord`, `item`.`app`, + `item`.`rendered-hash`, `item`.`rendered-html`, + `item`.`allow_cid`, `item`.`allow_gid`, `item`.`deny_cid`, `item`.`deny_gid`, + `item`.`id` AS `item_id`, `item`.`network` AS `item_network`, + + `author`.`thumb` AS `author-thumb`, `owner`.`thumb` AS `owner-thumb`, + + `contact`.`network`, `contact`.`url`, `contact`.`name`, `contact`.`writable`, + `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`alias`"; } /** - * @brief SQL condition for items + * @brief SQL join for contacts that are needed for displaying items + */ +function item_joins() { + + return "STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND + NOT `contact`.`blocked` AND NOT `contact`.`pending` + LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` + LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`author-id`"; +} + +/** + * @brief SQL condition for items that are needed for displaying items */ function item_condition() { @@ -923,8 +881,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { function best_link_url($item,&$sparkle,$ssl_state = false) { - $a = get_app(); - $best_url = ''; $sparkle = false; @@ -951,7 +907,6 @@ function best_link_url($item,&$sparkle,$ssl_state = false) { if(! function_exists('item_photo_menu')){ function item_photo_menu($item){ - $a = get_app(); $ssl_state = false; diff --git a/mod/community.php b/mod/community.php index 535e7dc3f..06a96c740 100644 --- a/mod/community.php +++ b/mod/community.php @@ -120,18 +120,17 @@ function community_getitems($start, $itemspage) { if (get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY) return(community_getpublicitems($start, $itemspage)); - $r = q("SELECT %s, %s, `user`.`nickname` + $r = q("SELECT %s FROM `thread` FORCE INDEX (`wall_private_received`) INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall` INNER JOIN `item` ON `item`.`id` = `thread`.`iid` AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' - INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` - AND %s AND `contact`.`self` + %s AND `contact`.`self` WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated` AND NOT `thread`.`private` AND `thread`.`wall` ORDER BY `thread`.`received` DESC LIMIT %d, %d", - item_fieldlist(), contact_fieldlist(), contact_condition(), + item_fieldlists(), item_joins(), intval($start), intval($itemspage) ); @@ -141,14 +140,12 @@ function community_getitems($start, $itemspage) { function community_getpublicitems($start, $itemspage) { - $r = q("SELECT %s, %s, `author-name` AS `name`, `owner-avatar` AS `photo`, - `owner-link` AS `url`, `owner-avatar` AS `thumb` + $r = q("SELECT %s FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid` %s WHERE `thread`.`uid` = 0 ORDER BY `thread`.`created` DESC LIMIT %d, %d", - item_fieldlist(), zcontact_fieldlist(), - zcontact_join(), + item_fieldlists(), item_joins(), intval($start), intval($itemspage) ); diff --git a/mod/notes.php b/mod/notes.php index 24d541be5..a25d090ed 100644 --- a/mod/notes.php +++ b/mod/notes.php @@ -73,11 +73,11 @@ function notes_content(&$a,$update = false) { $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' "; $r = q("SELECT COUNT(*) AS `total` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s + FROM `item` %s WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note' AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall` $sql_extra ", - contact_condition(), item_condition(), + item_joins(), item_condition(), intval(local_user()) ); @@ -87,13 +87,12 @@ function notes_content(&$a,$update = false) { $a->set_pager_itemspage(40); } - $r = q("SELECT `item`.`id` AS `item_id` FROM `item` - LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s AND `contact`.`self` + $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note' AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall` $sql_extra ORDER BY `item`.`created` DESC LIMIT %d ,%d ", - contact_condition(), item_condition(), + item_joins(), item_condition(), intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']) @@ -108,13 +107,11 @@ function notes_content(&$a,$update = false) { $parents_arr[] = $rr['item_id']; $parents_str = implode(', ', $parents_arr); - $r = q("SELECT %s FROM `item` - LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s + $r = q("SELECT %s FROM `item` %s WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s) $sql_extra ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ", - item_fieldlist(), contact_fieldlist(), - contact_condition(), item_condition(), + item_fieldlists(), item_joins(), item_condition(), intval(local_user()), dbesc($parents_str) ); From 0adff6f6b893bd7562547bb00021f358383f51ba Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 Jun 2016 20:01:25 +0200 Subject: [PATCH 054/498] Fix for author-thumb/owner-thumb - DFRN: Relocate stuff --- include/conversation.php | 2 +- include/dfrn.php | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index ffd9d45e2..c4d4fcdde 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -443,7 +443,7 @@ function item_joins() { return "STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND NOT `contact`.`blocked` AND NOT `contact`.`pending` LEFT JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id` - LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`author-id`"; + LEFT JOIN `contact` AS `owner` ON `owner`.`id`=`item`.`owner-id`"; } /** diff --git a/include/dfrn.php b/include/dfrn.php index 9828763bf..9d91cbce7 100644 --- a/include/dfrn.php +++ b/include/dfrn.php @@ -369,6 +369,7 @@ class dfrn { xml::add_element($doc, $relocate, "dfrn:url", $owner['url']); xml::add_element($doc, $relocate, "dfrn:name", $owner['name']); xml::add_element($doc, $relocate, "dfrn:addr", $owner['addr']); + xml::add_element($doc, $relocate, "dfrn:avatar", $owner['avatar']); xml::add_element($doc, $relocate, "dfrn:photo", $photos[4]); xml::add_element($doc, $relocate, "dfrn:thumb", $photos[5]); xml::add_element($doc, $relocate, "dfrn:micro", $photos[6]); @@ -1548,6 +1549,7 @@ class dfrn { $relocate["url"] = $xpath->query("dfrn:url/text()", $relocation)->item(0)->nodeValue; $relocate["addr"] = $xpath->query("dfrn:addr/text()", $relocation)->item(0)->nodeValue; $relocate["name"] = $xpath->query("dfrn:name/text()", $relocation)->item(0)->nodeValue; + $relocate["avatar"] = $xpath->query("dfrn:avatar/text()", $relocation)->item(0)->nodeValue; $relocate["photo"] = $xpath->query("dfrn:photo/text()", $relocation)->item(0)->nodeValue; $relocate["thumb"] = $xpath->query("dfrn:thumb/text()", $relocation)->item(0)->nodeValue; $relocate["micro"] = $xpath->query("dfrn:micro/text()", $relocation)->item(0)->nodeValue; @@ -1557,6 +1559,9 @@ class dfrn { $relocate["poll"] = $xpath->query("dfrn:poll/text()", $relocation)->item(0)->nodeValue; $relocate["sitepubkey"] = $xpath->query("dfrn:sitepubkey/text()", $relocation)->item(0)->nodeValue; + if (($relocate["avatar"] == "") AND ($relocate["photo"] != "")) + $relocate["avatar"] = $relocate["photo"]; + if ($relocate["addr"] == "") $relocate["addr"] = preg_replace("=(https?://)(.*)/profile/(.*)=ism", "$3@$2", $relocate["url"]); @@ -1583,7 +1588,7 @@ class dfrn { `server_url` = '%s' WHERE `nurl` = '%s';", dbesc($relocate["name"]), - dbesc($relocate["photo"]), + dbesc($relocate["avatar"]), dbesc($relocate["url"]), dbesc(normalise_link($relocate["url"])), dbesc($relocate["addr"]), @@ -1595,9 +1600,7 @@ class dfrn { // Update the contact table. We try to find every entry. $x = q("UPDATE `contact` SET `name` = '%s', - `photo` = '%s', - `thumb` = '%s', - `micro` = '%s', + `avatar` = '%s', `url` = '%s', `nurl` = '%s', `addr` = '%s', @@ -1608,9 +1611,7 @@ class dfrn { `site-pubkey` = '%s' WHERE (`id` = %d AND `uid` = %d) OR (`nurl` = '%s');", dbesc($relocate["name"]), - dbesc($relocate["photo"]), - dbesc($relocate["thumb"]), - dbesc($relocate["micro"]), + dbesc($relocate["avatar"]), dbesc($relocate["url"]), dbesc(normalise_link($relocate["url"])), dbesc($relocate["addr"]), @@ -1623,6 +1624,8 @@ class dfrn { intval($importer["importer_uid"]), dbesc(normalise_link($old["url"]))); + update_contact_avatar($relocate["avatar"], $importer["importer_uid"], $importer["id"], true); + if ($x === false) return false; From 51b5d16f1b3384552e1f060cf9c5305c989fa54c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 19 Jun 2016 21:41:06 +0200 Subject: [PATCH 055/498] Improved SQL queries --- mod/network.php | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/mod/network.php b/mod/network.php index 1ac732d11..6d30797fe 100644 --- a/mod/network.php +++ b/mod/network.php @@ -682,8 +682,8 @@ function network_content(&$a, $update = 0) { if(get_config('system', 'old_pager')) { $r = q("SELECT COUNT(*) AS `total` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - WHERE $sql_table.`uid` = %d AND $sql_table.`visible` = 1 AND $sql_table.`deleted` = 0 + AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + WHERE $sql_table.`uid` = %d AND $sql_table.`visible` AND NOT $sql_table.`deleted` $sql_extra2 $sql_extra3 $sql_extra $sql_nets ", intval($_SESSION['uid']) @@ -714,7 +714,7 @@ function network_content(&$a, $update = 0) { } if($nouveau) { - $simple_update = (($update) ? " AND `item`.`unseen` = 1 " : ''); + $simple_update = (($update) ? " AND `item`.`unseen` " : ''); if ($sql_order == "") $sql_order = "`item`.`received`"; @@ -753,28 +753,26 @@ function network_content(&$a, $update = 0) { // Fetch a page full of parent items for this page if($update) { - if (!get_config("system", "like_no_comment")) - $sql_extra4 = "(`item`.`deleted` = 0 - OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."' - OR `item`.`verb` = '".ACTIVITY_ATTEND."' OR `item`.`verb` = '".ACTIVITY_ATTENDNO."' - OR `item`.`verb` = '".ACTIVITY_ATTENDMAYBE."')"; + if (get_config("system", "like_no_comment")) + $sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'"; else - $sql_extra4 = "`item`.`deleted` = 0 AND `item`.`verb` = '".ACTIVITY_POST."'"; + $sql_extra4 = ""; $r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND $sql_extra4 - AND `item`.`moderated` = 0 AND `item`.`unseen` = 1 - $sql_extra3 $sql_extra $sql_nets ORDER BY `item_id` DESC LIMIT 100", + AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` $sql_extra4 + AND NOT `item`.`moderated` AND `item`.`unseen` + $sql_extra3 $sql_extra $sql_nets + ORDER BY `item_id` DESC LIMIT 100", intval(local_user()) ); } else { $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid` FROM $sql_table $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id` - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0 - AND `thread`.`moderated` = 0 + AND NOT `contact`.`blocked` AND NOT `contact`.`pending` + WHERE `thread`.`uid` = %d AND `thread`.`visible` AND NOT `thread`.`deleted` + AND NOT `thread`.`moderated` $sql_extra2 $sql_extra3 $sql_extra $sql_nets ORDER BY $sql_order DESC $pager_sql ", intval(local_user()) From 7495a34b32fdf1ea08bd2eaa378b216345077f7f Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 19 Jun 2016 22:04:34 +0200 Subject: [PATCH 056/498] implement a public calendar for vistors of someones profile page --- include/event.php | 187 ++++++++++++ include/identity.php | 18 +- mod/cal.php | 279 ++++++++++++++++++ mod/events.php | 147 ++------- view/templates/event_head.tpl | 12 +- view/theme/frio/templates/event_head.tpl | 14 +- view/theme/frost-mobile/js/theme.js | 10 +- .../frost-mobile/templates/event_head.tpl | 2 + view/theme/frost/js/theme.js | 12 +- view/theme/frost/templates/event_head.tpl | 2 + 10 files changed, 542 insertions(+), 141 deletions(-) create mode 100644 mod/cal.php diff --git a/include/event.php b/include/event.php index c5e5ff18d..df9b95857 100644 --- a/include/event.php +++ b/include/event.php @@ -1,7 +1,12 @@ $firstDay, + "Sun" => t("Sun"), + "Mon" => t("Mon"), + "Tue" => t("Tue"), + "Wed" => t("Wed"), + "Thu" => t("Thu"), + "Fri" => t("Fri"), + "Sat" => t("Sat"), + "Sunday" => t("Sunday"), + "Monday" => t("Monday"), + "Tuesday" => t("Tuesday"), + "Wednesday" => t("Wednesday"), + "Thursday" => t("Thursday"), + "Friday" => t("Friday"), + "Saturday" => t("Saturday"), + "Jan" => t("Jan"), + "Feb" => t("Feb"), + "Mar" => t("Mar"), + "Apr" => t("Apr"), + "May" => t("May"), + "Jun" => t("Jun"), + "Jul" => t("Jul"), + "Aug" => t("Aug"), + "Sep" => t("Sept"), + "Oct" => t("Oct"), + "Nov" => t("Nov"), + "Dec" => t("Dec"), + "January" => t("January"), + "February" => t("February"), + "March" => t("March"), + "April" => t("April"), + "May" => t("May"), + "June" => t("June"), + "July" => t("July"), + "August" => t("August"), + "September" => t("September"), + "October" => t("October"), + "November" => t("November"), + "December" => t("December"), + "today" => t("today"), + "month" => t("month"), + "week" => t("week"), + "day" => t("day"), + ); + + return $i18n; +} + +/** + * @brief Get an event by its event ID + * + * @param type $owner_uid The User ID of the owner of the event + * @param type $event_params An assoziative array with + * int 'event_id' => The ID of the event in the event table + * @param type $sql_extra + * @return array Query result + */ +function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') { + // ownly allow events if there is a valid owner_id + if($owner_uid == 0) + return; + + // query for the event by event id + $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, + `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` + LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` + WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra", + intval($owner_uid), + intval($event_params["event_id"]) + ); + + if(count($r)) + return $r; + +} + +/** + * @brief Get all events in a specific timeframe + * + * @param int $owner_uid The User ID of the owner of the events + * @param array $event_params An assoziative array with + * int 'ignored' => + * string 'start' => Start time of the timeframe + * string 'finish' => Finish time of the timeframe + * string 'adjust_start' => + * string 'adjust_start' => + * + * @param string $sql_extra Additional sql conditions (e.g. permission request) + * @return array Query results + */ +function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') { + // ownly allow events if there is a valid owner_id + if($owner_uid == 0) + return; + + // query for the event by date + $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, + `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` + LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` + WHERE `event`.`uid` = %d AND event.ignore = %d + AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s') + OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')) + $sql_extra ", + intval($owner_uid), + intval($event_params["ignored"]), + dbesc($event_params["start"]), + dbesc($event_params["start"]), + dbesc($event_params["finish"]), + dbesc($event_params["adjust_start"]), + dbesc($event_params["adjust_start"]), + dbesc($event_params["adjust_finish"]) + ); + + if(count($r)) + return $r; +} + +/** + * @brief Convert an array query results in an arry which could be used by the events template + * + * @param array $arr Event query array + * @return array Event array for the template + */ +function process_events ($arr) { + $events=array(); + + $last_date = ''; + $fmt = t('l, F j'); + if (count($arr)) { + foreach($arr as $rr) { + + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); + $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt)); + $d = day_translate($d); + + $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c')); + if ($rr['nofinish']){ + $end = null; + } else { + $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c')); + } + + + $is_first = ($d !== $last_date); + + $last_date = $d; + $edit = ((! $rr['cid']) ? array(App::get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); + $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); + if(! $title) { + list($title, $_trash) = explode("$rr['id'], + 'start'=> $start, + 'end' => $end, + 'allDay' => false, + 'title' => $title, + + 'j' => $j, + 'd' => $d, + 'is_first'=>$is_first, + 'item'=>$rr, + 'html'=>$html, + 'plink' => array($rr['plink'],t('link to source'),'',''), + ); + } + } + + return $events; +} diff --git a/include/identity.php b/include/identity.php index 48a6c5bbf..136452e78 100644 --- a/include/identity.php +++ b/include/identity.php @@ -740,8 +740,8 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ ), ); - if ($is_owner){ - if ($a->theme_events_in_profile) + // the calendar link for the full featured events calendar + if ($is_owner && $a->theme_events_in_profile) { $tabs[] = array( 'label' => t('Events'), 'url' => $a->get_baseurl() . '/events', @@ -750,6 +750,20 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){ 'id' => 'events-tab', 'accesskey' => 'e', ); + // if the user is not the owner of the calendar we only show a calendar + // with the public events of the calendar owner + } elseif (! $is_owner) { + $tabs[] = array( + 'label' => t('Events'), + 'url' => $a->get_baseurl() . '/cal/' . $nickname, + 'sel' =>((!isset($tab)&&$a->argv[0]=='cal')?'active':''), + 'title' => t('Events and Calendar'), + 'id' => 'events-tab', + 'accesskey' => 'e', + ); + } + + if ($is_owner){ $tabs[] = array( 'label' => t('Personal Notes'), 'url' => $a->get_baseurl() . '/notes', diff --git a/mod/cal.php b/mod/cal.php new file mode 100644 index 000000000..0cde2a6ec --- /dev/null +++ b/mod/cal.php @@ -0,0 +1,279 @@ +argc > 1) + auto_redir($a, $a->argv[1]); + + if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + return; + } + + nav_set_selected('events'); + + $o = ''; + + if($a->argc > 1) { + $nick = $a->argv[1]; + $user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1", + dbesc($nick) + ); + + if(! count($user)) + return; + + $a->data['user'] = $user[0]; + $a->profile_uid = $user[0]['uid']; + + $profile = get_profiledata_by_nick($nick, $a->profile_uid); + + if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP)) + $account_type = t('Forum'); + else + $account_type = ""; + + $tpl = get_markup_template("vcard-widget.tpl"); + + $vcard_widget .= replace_macros($tpl, array( + '$name' => $profile['name'], + '$photo' => $profile['photo'], + '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""), + '$account_type' => $account_type, + '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""), + )); + + if(! x($a->page,'aside')) + $a->page['aside'] = ''; + + $a->page['aside'] .= $vcard_widget; + } + + return; +} + +function cal_content(&$a) { + nav_set_selected('events'); + + $editselect = 'none'; + if( feature_enabled(local_user(), 'richtext') ) + $editselect = 'textareas'; + + // First day of the week (0 = Sunday) + $firstDay = get_pconfig(local_user(),'system','first_day_of_week'); + if ($firstDay === false) $firstDay=0; + + // get the translation strings for the callendar + $i18n = get_event_strings(); + + $htpl = get_markup_template('event_head.tpl'); + $a->page['htmlhead'] .= replace_macros($htpl,array( + '$baseurl' => $a->get_baseurl(), + '$module_url' => '/cal/' . $a->data['user']['nickname'], + '$modparams' => 2, + '$i18n' => $i18n, + '$editselect' => $editselect + )); + + $etpl = get_markup_template('event_end.tpl'); + $a->page['end'] .= replace_macros($etpl,array( + '$baseurl' => $a->get_baseurl(), + '$editselect' => $editselect + )); + + $o =""; + + $mode = 'view'; + $y = 0; + $m = 0; + $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); + + // + // Setup permissions structures + // + + $contact = null; + $remote_contact = false; + $contact_id = 0; + + $owner_uid = $a->data['user']['uid']; + + if(is_array($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $v) { + if($v['uid'] == $a->profile['profile_uid']) { + $contact_id = $v['cid']; + break; + } + } + } + if($contact_id) { + $groups = init_groups_visitor($contact_id); + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($contact_id), + intval($a->profile['profile_uid']) + ); + if(count($r)) { + $contact = $r[0]; + $remote_contact = true; + } + } + if(! $remote_contact) { + if(local_user()) { + $contact_id = $_SESSION['cid']; + $contact = $a->contact; + } + } + $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false); + + if($a->profile['hidewall'] && (! $is_owner) && (! $remote_contact)) { + notice( t('Access to this profile has been restricted.') . EOL); + return; + } + + $sql_extra = item_permissions_sql($owner_uid,$remote_contact,$groups); + + // get the tab navigation bar + $tabs .= profile_tabs($a,false, $a->data['user']['nickname']); + + // The view mode part is similiar to /mod/events.php + if($mode == 'view') { + + + $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y'); + $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m'); + if(! $y) + $y = intval($thisyear); + if(! $m) + $m = intval($thismonth); + + // Put some limits on dates. The PHP date functions don't seem to do so well before 1900. + // An upper limit was chosen to keep search engines from exploring links millions of years in the future. + + if($y < 1901) + $y = 1900; + if($y > 2099) + $y = 2100; + + $nextyear = $y; + $nextmonth = $m + 1; + if($nextmonth > 12) { + $nextmonth = 1; + $nextyear ++; + } + + $prevyear = $y; + if($m > 1) + $prevmonth = $m - 1; + else { + $prevmonth = 12; + $prevyear --; + } + + $dim = get_dim($y,$m); + $start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0); + $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59); + + + if ($a->argv[2] === 'json'){ + if (x($_GET,'start')) $start = date("Y-m-d h:i:s", $_GET['start']); + if (x($_GET,'end')) $finish = date("Y-m-d h:i:s", $_GET['end']); + } + + $start = datetime_convert('UTC','UTC',$start); + $finish = datetime_convert('UTC','UTC',$finish); + + $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start); + $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); + + // put the event parametes in an array so we can better transmit them + $event_params = array( + 'event_id' => (x($_GET,'id') ? $_GET["id"] : 0), + 'start' => $start, + 'finish' => $finish, + 'adjust_start' => $adjust_start, + 'adjust_finish' => $adjust_finish, + 'ignored' => $ignored, + ); + + // get events by id or by date + if (x($_GET,'id')){ + $r = event_by_id($owner_uid, $event_params, $sql_extra); + } else { + $r = events_by_date($owner_uid, $event_params, $sql_extra); + } + + $links = array(); + + if(count($r)) { + $r = sort_by_date($r); + foreach($r as $rr) { + $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); + if(! x($links,$j)) + $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j; + } + } + + + $events=array(); + + // transform the event in a usable array + if(count($r)) + $r = sort_by_date($r); + $events = process_events($r); + + if ($a->argv[2] === 'json'){ + echo json_encode($events); killme(); + } + + // links: array('href', 'text', 'extra css classes', 'title') + if (x($_GET,'id')){ + $tpl = get_markup_template("event.tpl"); + } else { +// if (get_config('experimentals','new_calendar')==1){ + $tpl = get_markup_template("events-js.tpl"); +// } else { +// $tpl = get_markup_template("events.tpl"); +// } + } + + // Get rid of dashes in key names, Smarty3 can't handle them + foreach($events as $key => $event) { + $event_item = array(); + foreach($event['item'] as $k => $v) { + $k = str_replace('-','_',$k); + $event_item[$k] = $v; + } + $events[$key]['item'] = $event_item; + } + + $o = replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(), + '$tabs' => $tabs, + '$title' => t('Events'), + '$view' => t('View'), + '$previus' => array($a->get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), + '$next' => array($a->get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), + '$calendar' => cal($y,$m,$links, ' eventcal'), + + '$events' => $events, + + "today" => t("today"), + "month" => t("month"), + "week" => t("week"), + "day" => t("day"), + + + )); + + if (x($_GET,'id')){ echo $o; killme(); } + + return $o; + } +} diff --git a/mod/events.php b/mod/events.php index e4526ac59..617627ac4 100644 --- a/mod/events.php +++ b/mod/events.php @@ -1,5 +1,8 @@ $firstDay, - "Sun" => t("Sun"), - "Mon" => t("Mon"), - "Tue" => t("Tue"), - "Wed" => t("Wed"), - "Thu" => t("Thu"), - "Fri" => t("Fri"), - "Sat" => t("Sat"), - "Sunday" => t("Sunday"), - "Monday" => t("Monday"), - "Tuesday" => t("Tuesday"), - "Wednesday" => t("Wednesday"), - "Thursday" => t("Thursday"), - "Friday" => t("Friday"), - "Saturday" => t("Saturday"), - "Jan" => t("Jan"), - "Feb" => t("Feb"), - "Mar" => t("Mar"), - "Apr" => t("Apr"), - "May" => t("May"), - "Jun" => t("Jun"), - "Jul" => t("Jul"), - "Aug" => t("Aug"), - "Sep" => t("Sept"), - "Oct" => t("Oct"), - "Nov" => t("Nov"), - "Dec" => t("Dec"), - "January" => t("January"), - "February" => t("February"), - "March" => t("March"), - "April" => t("April"), - "May" => t("May"), - "June" => t("June"), - "July" => t("July"), - "August" => t("August"), - "September" => t("September"), - "October" => t("October"), - "November" => t("November"), - "December" => t("December"), - "today" => t("today"), - "month" => t("month"), - "week" => t("week"), - "day" => t("day"), - ); + // get the translation strings for the callendar + $i18n = get_event_strings(); $htpl = get_markup_template('event_head.tpl'); $a->page['htmlhead'] .= replace_macros($htpl,array( '$baseurl' => $a->get_baseurl(), + '$module_url' => '/events', + '$modparams' => 1, '$i18n' => $i18n, '$editselect' => $editselect )); @@ -284,6 +242,7 @@ function events_content(&$a) { } } + // The view mode part is similiar to /mod/cal.php if($mode == 'view') { @@ -333,31 +292,21 @@ function events_content(&$a) { $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start); $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); + // put the event parametes in an array so we can better transmit them + $event_params = array( + 'event_id' => (x($_GET,'id') ? $_GET["id"] : 0), + 'start' => $start, + 'finish' => $finish, + 'adjust_start' => $adjust_start, + 'adjust_finish' => $adjust_finish, + 'ignored' => $ignored, + ); + // get events by id or by date if (x($_GET,'id')){ - $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, - `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` - LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` - WHERE `event`.`uid` = %d AND `event`.`id` = %d", - intval(local_user()), - intval($_GET['id']) - ); + $r = event_by_id(local_user(), $event_params); } else { - $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, - `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` - LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid` - WHERE `event`.`uid` = %d and event.ignore = %d - AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s') - OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')) ", - intval(local_user()), - intval($ignored), - dbesc($start), - dbesc($start), - dbesc($finish), - dbesc($adjust_start), - dbesc($adjust_start), - dbesc($adjust_finish) - ); + $r = events_by_date(local_user(), $event_params); } $links = array(); @@ -371,60 +320,12 @@ function events_content(&$a) { } } - $events=array(); - $last_date = ''; - $fmt = t('l, F j'); - - if(count($r)) { + // transform the event in a usable array + if(count($r)) $r = sort_by_date($r); - foreach($r as $rr) { - - - $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j')); - $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], $fmt) : datetime_convert('UTC','UTC',$rr['start'],$fmt)); - $d = day_translate($d); - - $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c')); - if ($rr['nofinish']){ - $end = null; - } else { - $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c')); - } - - - $is_first = ($d !== $last_date); - - $last_date = $d; - $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); - $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); - if(! $title) { - list($title, $_trash) = explode("$rr['id'], - 'start'=> $start, - 'end' => $end, - 'allDay' => false, - 'title' => $title, - - 'j' => $j, - 'd' => $d, - 'edit' => $edit, - 'is_first'=>$is_first, - 'item'=>$rr, - 'html'=>$html, - 'plink' => array($rr['plink'],t('link to source'),'',''), - ); - - - } - } + $events = process_events($r); if ($a->argv[1] === 'json'){ echo json_encode($events); killme(); diff --git a/view/templates/event_head.tpl b/view/templates/event_head.tpl index 01c69b8b3..99a320a89 100644 --- a/view/templates/event_head.tpl +++ b/view/templates/event_head.tpl @@ -6,7 +6,7 @@ diff --git a/view/theme/frost/js/theme.js b/view/theme/frost/js/theme.js index 038f83e0e..eb8bb51cc 100644 --- a/view/theme/frost/js/theme.js +++ b/view/theme/frost/js/theme.js @@ -149,7 +149,7 @@ $(document).ready(function() { if(window.aclType == "event_head") { $('#events-calendar').fullCalendar({ - events: baseurl + '/events/json/', + events: baseurl + window.eventModuleUrl +'/json/', header: { left: 'prev,next today', center: 'title', @@ -202,10 +202,12 @@ $(document).ready(function() { // center on date var args=location.href.replace(baseurl,"").split("/"); - if (args.length>=4) { + if (args.length>=5 && window.eventModeParams == 2) { + $("#events-calendar").fullCalendar('gotoDate',args[3] , args[4]-1); + } else if (args.length>=4 && window.eventModeParams == 1) { $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1); - } - + } + // show event popup var hash = location.hash.split("-") if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]); @@ -352,7 +354,7 @@ if(typeof window.photoEdit != 'undefined') { function showEvent(eventid) { $.get( - baseurl + '/events/?id='+eventid, + baseurl + window.eventModuleUrl + '/?id=' + eventid, function(data){ $.colorbox({html:data}); $.colorbox.resize(); diff --git a/view/theme/frost/templates/event_head.tpl b/view/theme/frost/templates/event_head.tpl index f33f7fce2..47efb56ae 100644 --- a/view/theme/frost/templates/event_head.tpl +++ b/view/theme/frost/templates/event_head.tpl @@ -4,5 +4,7 @@ From 140886a6a50307ffa527a0f1b2650c40e7c2bf36 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 06:29:56 +0200 Subject: [PATCH 057/498] Updated database.sql --- database.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database.sql b/database.sql index 275982d84..4a36384d9 100644 --- a/database.sql +++ b/database.sql @@ -964,6 +964,8 @@ CREATE TABLE IF NOT EXISTS `thread` ( `uid` int(10) unsigned NOT NULL DEFAULT 0, `contact-id` int(11) unsigned NOT NULL DEFAULT 0, `gcontact-id` int(11) unsigned NOT NULL DEFAULT 0, + `owner-id` int(11) unsigned NOT NULL DEFAULT 0, + `author-id` int(11) unsigned NOT NULL DEFAULT 0, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `commented` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', From 80f5065eb0ea472daae6fb0238e433de1a7c425a Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 20 Jun 2016 13:44:11 +0200 Subject: [PATCH 058/498] frio: disable the events module link in the profile tab --- view/theme/frio/theme.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index bab2d696a..69f9267c2 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -12,6 +12,10 @@ $frio = "view/theme/frio"; global $frio; function frio_init(&$a) { + + // disable the events module link in the profile tab + $a->theme_events_in_profile = false; + set_template_engine($a, 'smarty3'); $baseurl = $a->get_baseurl(); From 939bd965c5702baa13099a878a261b8243076d6b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 22:03:40 +0200 Subject: [PATCH 059/498] Search query optimized --- mod/search.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mod/search.php b/mod/search.php index d2251ce58..a83725999 100644 --- a/mod/search.php +++ b/mod/search.php @@ -191,9 +191,9 @@ function search_content(&$a) { if($tag) { logger("Start tag search for '".$search."'", LOGGER_DEBUG); - $r = q("SELECT STRAIGHT_JOIN %s + $r = q("SELECT %s FROM `term` - INNER JOIN `item` ON `item`.`id`=`term`.`oid` %s + STRAIGHT_JOIN `item` ON `item`.`id`=`term`.`oid` %s WHERE %s AND (`term`.`uid` = 0 OR (`term`.`uid` = %d AND NOT `term`.`global`)) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s' ORDER BY term.created DESC LIMIT %d , %d ", item_fieldlists(), item_joins(), item_condition(), @@ -209,7 +209,8 @@ function search_content(&$a) { $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); } - $r = q("SELECT STRAIGHT_JOIN %s + + $r = q("SELECT %s FROM `item` %s WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`)) $sql_extra From 467176fa65bde8801945994aa2c68f7f91345c54 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 22:43:14 +0200 Subject: [PATCH 060/498] Diaspora: Ensure that we always store the correct URI --- include/diaspora.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 2ff7a90cf..84aed8147 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -981,6 +981,23 @@ class diaspora { return true; } + /** + * @brief Fetch the uri from our database if we already have this item (maybe from ourselves) + * + * @param string $author Author handle + * @param string $guid Message guid + * + * @return string The constructed uri or the one from our database + */ + private function get_uri_from_guid($author, $guid) { + + $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid)); + if ($r) + return $r[0]["uri"]; + else + return $author.":".$guid; + } + /** * @brief Processes an incoming comment * @@ -1033,7 +1050,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "remote-comment"; $datarray["verb"] = ACTIVITY_POST; @@ -1370,7 +1387,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "activity"; $datarray["verb"] = $verb; @@ -1969,7 +1986,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; @@ -2171,7 +2188,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; From 40a44f15716abde7de658557a5738d251b642408 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 22:48:09 +0200 Subject: [PATCH 061/498] Some manual revert ... --- include/diaspora.php | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 84aed8147..2ff7a90cf 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -981,23 +981,6 @@ class diaspora { return true; } - /** - * @brief Fetch the uri from our database if we already have this item (maybe from ourselves) - * - * @param string $author Author handle - * @param string $guid Message guid - * - * @return string The constructed uri or the one from our database - */ - private function get_uri_from_guid($author, $guid) { - - $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid)); - if ($r) - return $r[0]["uri"]; - else - return $author.":".$guid; - } - /** * @brief Processes an incoming comment * @@ -1050,7 +1033,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $author.":".$guid; $datarray["type"] = "remote-comment"; $datarray["verb"] = ACTIVITY_POST; @@ -1387,7 +1370,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $author.":".$guid; $datarray["type"] = "activity"; $datarray["verb"] = $verb; @@ -1986,7 +1969,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; @@ -2188,7 +2171,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; From a6573776160f1911784252f1ad960178d403f8ed Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 22:48:55 +0200 Subject: [PATCH 062/498] Diaspora: Try to fetch the uri if we already received the message --- include/diaspora.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 2ff7a90cf..84aed8147 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -981,6 +981,23 @@ class diaspora { return true; } + /** + * @brief Fetch the uri from our database if we already have this item (maybe from ourselves) + * + * @param string $author Author handle + * @param string $guid Message guid + * + * @return string The constructed uri or the one from our database + */ + private function get_uri_from_guid($author, $guid) { + + $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid)); + if ($r) + return $r[0]["uri"]; + else + return $author.":".$guid; + } + /** * @brief Processes an incoming comment * @@ -1033,7 +1050,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "remote-comment"; $datarray["verb"] = ACTIVITY_POST; @@ -1370,7 +1387,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "activity"; $datarray["verb"] = $verb; @@ -1969,7 +1986,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; @@ -2171,7 +2188,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; From 71c9f562ae4664beef2da6ee11c0f38d3e4eb094 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 20 Jun 2016 23:31:49 +0200 Subject: [PATCH 063/498] move the cal addon (exporting calendars) to core --- include/event.php | 219 +++++++++++++++++++++++++++++++- include/features.php | 1 + mod/cal.php | 50 ++++++++ mod/events.php | 21 +++ view/templates/events_aside.tpl | 9 ++ 5 files changed, 298 insertions(+), 2 deletions(-) create mode 100644 view/templates/events_aside.tpl diff --git a/include/event.php b/include/event.php index df9b95857..befda64eb 100644 --- a/include/event.php +++ b/include/event.php @@ -10,8 +10,6 @@ require_once('include/datetime.php'); function format_event_html($ev, $simple = false) { - - if(! ((is_array($ev)) && count($ev))) return ''; @@ -614,3 +612,220 @@ function process_events ($arr) { return $events; } + +/** + * @brief Format event to export format (ical/csv) + * + * @param array $events Query result for events + * @param string $format The output format (ical/csv) + * @param string $timezone The timezone of the user (not implemented yet) + * + * @return string Content according to selected export format + */ +function event_format_export ($events, $format = 'ical', $timezone) { + if(! ((is_array($events)) && count($events))) + return; + + switch ($format) { + // format the exported data as a CSV file + case "csv": + header("Content-type: text/csv"); + $o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL; + + foreach ($events as $event) { + /// @todo the time / date entries don't include any information about the + // timezone the event is scheduled in :-/ + $tmp1 = strtotime($event['start']); + $tmp2 = strtotime($event['finish']); + $time_format = "%H:%M:%S"; + $date_format = "%Y-%m-%d"; + $o .= '"'.$event['summary'].'", "'.strftime($date_format, $tmp1) . + '", "'.strftime($time_format, $tmp1).'", "'.$event['desc'] . + '", "'.strftime($date_format, $tmp2) . + '", "'.strftime($time_format, $tmp2) . + '", "'.$event['location'].'"' . PHP_EOL; + } + break; + + // format the exported data as a ics file + case "ical": + header("Content-type: text/ics"); + $o = 'BEGIN:VCALENDAR'. PHP_EOL + . 'VERSION:2.0' . PHP_EOL + . 'PRODID:-//friendica calendar export//0.1//EN' . PHP_EOL; + /// @todo include timezone informations in cases were the time is not in UTC + // see http://tools.ietf.org/html/rfc2445#section-4.8.3 + // . 'BEGIN:VTIMEZONE' . PHP_EOL + // . 'TZID:' . $timezone . PHP_EOL + // . 'END:VTIMEZONE' . PHP_EOL; + // TODO instead of PHP_EOL CRLF should be used for long entries + // but test your solution against http://icalvalid.cloudapp.net/ + // also long lines SHOULD be split at 75 characters length + foreach ($events as $event) { + if ($event['adjust'] == 1) { + $UTC = 'Z'; + } else { + $UTC = ''; + } + $o .= 'BEGIN:VEVENT' . PHP_EOL; + if ($event[start]) { + $tmp = strtotime($event['start']); + $dtformat = "%Y%m%dT%H%M%S".$UTC; + $o .= 'DTSTART:'.strftime($dtformat, $tmp).PHP_EOL; + } + if ($event['finish']) { + $tmp = strtotime($event['finish']); + $dtformat = "%Y%m%dT%H%M%S".$UTC; + $o .= 'DTEND:'.strftime($dtformat, $tmp).PHP_EOL; + } + if ($event['summary']) + $tmp = $event['summary']; + $tmp = str_replace(PHP_EOL, PHP_EOL.' ',$tmp); + $tmp = addcslashes($tmp, ',;'); + $o .= 'SUMMARY:' . $tmp . PHP_EOL; + if ($event['desc']) + $tmp = $event['desc']; + $tmp = str_replace(PHP_EOL, PHP_EOL.' ',$tmp); + $tmp = addcslashes($tmp, ',;'); + $o .= 'DESCRIPTION:' . $tmp . PHP_EOL; + if ($event['location']) { + $tmp = $event['location']; + $tmp = str_replace(PHP_EOL, PHP_EOL.' ',$tmp); + $tmp = addcslashes($tmp, ',;'); + $o .= 'LOCATION:' . $tmp . PHP_EOL; + } + + $o .= 'END:VEVENT' . PHP_EOL; + $o .= PHP_EOL; + } + + $o .= 'END:VCALENDAR' . PHP_EOL; + break; + } + + return $o; +} + +/** + * @brief Get all events for a user ID + * + * The query for events is done permission sensitive + * If the user is the owner of the calendar he/she + * will get all of his/her available events. + * If the user is only a visitor only the public events will + * be available + * + * @param int $uid The user ID + * @param int $sql_extra Additional sql conditions for permission + * + * @return array Query results + */ +function events_by_uid($uid = 0, $sql_extra = '') { + if($uid == 0) + return; + + // The permission condition if no condition was transmitted + if($sql_extra == '') + $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' "; + + // does the user who requests happen to be the owner of the events + // requested? then show all of your events, otherwise only those that + // don't have limitations set in allow_cid and allow_gid + if (local_user() == $uid) { + $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location` + FROM `event` WHERE `uid`= %d AND `cid` = 0 ", + intval($uid) + ); + } else { + $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location`FROM `event` + WHERE `uid` = %d AND `cid` = 0 $sql_extra ", + intval($uid) + ); + } + + if(count($r)) + return $r; +} + +/** + * + * @param int $uid The user ID + * @param string $format Output format (ical/csv) + * @return array With the results + * bool 'success' => True if the processing was successful + * string 'format' => The output format + * string 'extension' => The file extension of the output format + * string 'content' => The formatted output content + * + * @todo Respect authenticated users with events_by_uid() + */ +function event_export($uid, $format = 'ical') { + + $process = false; + + // we are allowed to show events + // get the timezone the user is in + $r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid)); + if (count($r)) + $timezone = $r[0]['timezone']; + + // get all events which are owned by a uid (respects permissions); + $events = events_by_uid($uid); + + // we have the events that are available for the requestor + // now format the output according to the requested format + if(count($events)) + $res = event_format_export($events, $format, $timezone); + + // If there are results the precess was successfull + if(x($res)) + $process = true; + + // get the file extension for the format + switch ($format) { + case "ical": + $file_ext = "ics"; + break; + + case "csv": + $file_ext = "csv"; + break; + + default: + $file_ext = ""; + } + + $arr = array( + 'success' => $process, + 'format' => $format, + 'extension' => $file_ext, + 'content' => $res, + ); + + return $arr; +} + +/** + * @brief Get the events widget + * + * @return string Formated html of the evens widget + */ +function widget_events() { + $a = get_app(); + + $owner_uid = $a->data['user']['uid']; + // $a->data is only available if the profile page is visited. If the visited page is not part + // of the profile page it should be the personal /events page. So we can use $a->user + $user = ($a->data['user']['nickname'] ? $a->data['user']['nickname'] : $a->user['nickname']); + + if( !(local_user() )&& !(feature_enabled($owner_uid, "export_calendar")) ) + return; + + return replace_macros(get_markup_template("events_aside.tpl"), array( + '$etitle' => t("Export"), + '$export_ical' => t("Export calendar as ical"), + '$export_csv' => t("Export calendar as csv"), + '$user' => $user + )); + +} diff --git a/include/features.php b/include/features.php index 87a9b46d5..b3e3454b1 100644 --- a/include/features.php +++ b/include/features.php @@ -64,6 +64,7 @@ function get_features($filtered = true) { //array('expire', t('Content Expiration'), t('Remove old posts/comments after a period of time')), array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles'), false, get_config('feature_lock','multi_profiles')), array('photo_location', t('Photo Location'), t('Photo metadata is normally stripped. This extracts the location (if present) prior to stripping metadata and links it to a map.'), false, get_config('feature_lock','photo_location')), + array('export_calendar', t('Export Public Calendar'), t('Ability for visitors to download the public calendar'), false, get_config('feature_lock','export_calendar')), ), // Post composition diff --git a/mod/cal.php b/mod/cal.php index 0cde2a6ec..a12a65342 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -33,6 +33,11 @@ function cal_init(&$a) { $a->data['user'] = $user[0]; $a->profile_uid = $user[0]['uid']; + // if it's a json request abort here becaus we don't + // need the widget data + if ($a->argv[2] === 'json') + return; + $profile = get_profiledata_by_nick($nick, $a->profile_uid); if((intval($profile['page-flags']) == PAGE_COMMUNITY) || (intval($profile['page-flags']) == PAGE_PRVGROUP)) @@ -50,10 +55,13 @@ function cal_init(&$a) { '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""), )); + $cal_widget = widget_events(); + if(! x($a->page,'aside')) $a->page['aside'] = ''; $a->page['aside'] .= $vcard_widget; + $a->page['aside'] .= $cal_widget; } return; @@ -95,6 +103,13 @@ function cal_content(&$a) { $m = 0; $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); + if($a->argc == 4) { + if($a->argv[2] == 'export') { + $mode = 'export'; + $format = $a->argv[3]; + } + } + // // Setup permissions structures // @@ -104,6 +119,7 @@ function cal_content(&$a) { $contact_id = 0; $owner_uid = $a->data['user']['uid']; + $nick = $a->data['user']['nickname']; if(is_array($_SESSION['remote'])) { foreach($_SESSION['remote'] as $v) { @@ -276,4 +292,38 @@ function cal_content(&$a) { return $o; } + + if($mode == 'export') { + if(! (intval($owner_uid))) { + notice( t('User not found')); + return; + } + + if(! (feature_enabled($owner_uid, "export_calendar"))) { + notice( t('Permission denied.') . EOL); + return; + } + + // Get the export data by uid + $evexport = event_export($owner_uid, $format); + + if ($evexport["success"] == false ) { + if($evexport["content"]) + notice( t('This calendar format is not supported') ); + else + notice( t('No exportable data found')); + + return; + } + + // If nothing went wrong we can echo the export content + if ($evexport["success"] == true ) { + header('Content-type: text/calendar'); + header('content-disposition: attachment; filename="' . t('calendar') . '-' . $nick . '.' . $evexport["extension"] . '"' ); + echo $evexport["content"]; + killme(); + } + + return; + } } diff --git a/mod/events.php b/mod/events.php index 617627ac4..b53fe9fd9 100644 --- a/mod/events.php +++ b/mod/events.php @@ -8,6 +8,27 @@ require_once('include/datetime.php'); require_once('include/event.php'); require_once('include/items.php'); +function events_init(&$a) { + if(! local_user()) + return; + + if($a->argc == 1) { + // if it's a json request abort here becaus we don't + // need the widget data + if($a->argv[1] !== 'json') + return; + + $cal_widget = widget_events(); + + if(! x($a->page,'aside')) + $a->page['aside'] = ''; + + $a->page['aside'] .= $cal_widget; + } + + return; +} + function events_post(&$a) { logger('post: ' . print_r($_REQUEST,true)); diff --git a/view/templates/events_aside.tpl b/view/templates/events_aside.tpl new file mode 100644 index 000000000..e9b54771d --- /dev/null +++ b/view/templates/events_aside.tpl @@ -0,0 +1,9 @@ + + From d076f61a4aa6faaef981a47ed53c09c950027464 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Mon, 20 Jun 2016 23:38:34 +0200 Subject: [PATCH 064/498] cal export - little fix for json --- mod/events.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/events.php b/mod/events.php index b53fe9fd9..878bf841d 100644 --- a/mod/events.php +++ b/mod/events.php @@ -15,7 +15,7 @@ function events_init(&$a) { if($a->argc == 1) { // if it's a json request abort here becaus we don't // need the widget data - if($a->argv[1] !== 'json') + if($a->argv[1] === 'json') return; $cal_widget = widget_events(); From 9a7653a4feafc191e449e0d33915b3083122d38d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 21 Jun 2016 07:54:45 +0200 Subject: [PATCH 065/498] Store the author-id and owner-id in mod/item.php as well --- mod/item.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/mod/item.php b/mod/item.php index d0e1ffed5..6f5f8fc1e 100644 --- a/mod/item.php +++ b/mod/item.php @@ -25,6 +25,7 @@ require_once('include/text.php'); require_once('include/items.php'); require_once('include/Scrape.php'); require_once('include/diaspora.php'); +require_once('include/Contact.php'); function item_post(&$a) { @@ -676,9 +677,11 @@ function item_post(&$a) { $datarray['owner-name'] = $contact_record['name']; $datarray['owner-link'] = $contact_record['url']; $datarray['owner-avatar'] = $contact_record['thumb']; + $datarray["owner-id"] = get_contact($datarray["owner-link"], 0); $datarray['author-name'] = $author['name']; $datarray['author-link'] = $author['url']; $datarray['author-avatar'] = $author['thumb']; + $datarray["author-id"] = get_contact($datarray["author-link"], 0); $datarray['created'] = datetime_convert(); $datarray['edited'] = datetime_convert(); $datarray['commented'] = datetime_convert(); @@ -711,6 +714,7 @@ function item_post(&$a) { $datarray['moderated'] = $allow_moderated; $datarray['gcontact-id'] = get_gcontact_id(array("url" => $datarray['author-link'], "network" => $datarray['network'], "photo" => $datarray['author-avatar'], "name" => $datarray['author-name'])); + /** * These fields are for the convenience of plugins... * 'self' if true indicates the owner is posting on their own wall @@ -790,10 +794,24 @@ function item_post(&$a) { $post_id = 0; - $r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`, - `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, `tag`, `inform`, `verb`, `object-type`, `postopts`, - `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file`, `rendered-html`, `rendered-hash`) - VALUES( '%s', '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s')", + $r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`, + `owner-name`,`owner-link`,`owner-avatar`, `owner-id`, + `author-name`, `author-link`, `author-avatar`, `author-id`, + `created`, `edited`, `commented`, `received`, `changed`, + `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, + `tag`, `inform`, `verb`, `object-type`, `postopts`, + `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, + `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file`, + `rendered-html`, `rendered-hash`) + VALUES('%s', '%s', %d, '%s', %d, %d, '%s', %d, + '%s', '%s', '%s', %d, + '%s', '%s', '%s', %d, + '%s', '%s', '%s', '%s', '%s', + '%s', '%s', '%s', '%s', '%s', '%s', '%s', + '%s', '%s', '%s', '%s', '%s', + '%s', '%s', '%s', '%s', %d, + %d, '%s', %d, %d, %d, '%s', + '%s', '%s')", dbesc($datarray['guid']), dbesc($datarray['extid']), intval($datarray['uid']), @@ -805,9 +823,11 @@ function item_post(&$a) { dbesc($datarray['owner-name']), dbesc($datarray['owner-link']), dbesc($datarray['owner-avatar']), + intval($datarray['owner-id']), dbesc($datarray['author-name']), dbesc($datarray['author-link']), dbesc($datarray['author-avatar']), + intval($datarray['author-id']), dbesc($datarray['created']), dbesc($datarray['edited']), dbesc($datarray['commented']), From 864cf0f70d26b82b20ff07c975ca05d3fca7341d Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Tue, 21 Jun 2016 10:23:43 -0400 Subject: [PATCH 066/498] update MF2 and vcard data for issue #2629 --- view/templates/diaspora_vcard.tpl | 18 ++++++------ view/templates/profile_vcard.tpl | 4 +-- view/templates/vcard-widget.tpl | 10 +++---- view/templates/wall_thread.tpl | 20 ++++++------- .../decaf-mobile/templates/profile_vcard.tpl | 22 +++++++-------- .../decaf-mobile/templates/wall_thread.tpl | 20 +++++++------ .../diabook/templates/directory_item.tpl | 2 +- .../theme/diabook/templates/profile_vcard.tpl | 22 +++++++-------- view/theme/diabook/templates/wall_thread.tpl | 16 ++++++----- view/theme/dispy/templates/profile_vcard.tpl | 22 +++++++-------- view/theme/dispy/templates/wall_thread.tpl | 20 ++++++------- .../duepuntozero/templates/profile_vcard.tpl | 22 +++++++-------- .../facepark/templates/profile_vcard.tpl | 22 +++++++-------- view/theme/frio/templates/profile_vcard.tpl | 2 +- view/theme/frio/templates/vcard-widget.tpl | 8 +++--- view/theme/frio/templates/wall_thread.tpl | 28 +++++++++---------- .../frost-mobile/templates/profile_vcard.tpl | 22 +++++++-------- .../frost-mobile/templates/wall_thread.tpl | 18 ++++++------ view/theme/frost/templates/profile_vcard.tpl | 22 +++++++-------- view/theme/frost/templates/wall_thread.tpl | 20 ++++++------- .../theme/quattro/templates/profile_vcard.tpl | 22 +++++++-------- .../templates/threaded_conversation.tpl | 2 +- view/theme/quattro/templates/wall_thread.tpl | 20 ++++++------- view/theme/smoothly/templates/wall_thread.tpl | 20 ++++++------- .../testbubble/templates/profile_vcard.tpl | 22 +++++++-------- .../testbubble/templates/wall_thread.tpl | 16 +++++------ view/theme/vier/templates/profile_vcard.tpl | 6 ++-- .../vier/templates/threaded_conversation.tpl | 2 +- view/theme/vier/templates/wall_thread.tpl | 22 +++++++-------- 29 files changed, 239 insertions(+), 233 deletions(-) diff --git a/view/templates/diaspora_vcard.tpl b/view/templates/diaspora_vcard.tpl index 45b9fa4ff..c71577aee 100644 --- a/view/templates/diaspora_vcard.tpl +++ b/view/templates/diaspora_vcard.tpl @@ -3,19 +3,19 @@
      Uid
      - {{$diaspora.guid}} + {{$diaspora.guid}}
      Nickname
      - {{$diaspora.nickname}} + {{$diaspora.nickname}}
      Full_name
      - {{$diaspora.fullname}} + {{$diaspora.fullname}}
      @@ -27,37 +27,37 @@
      First_name
      - {{$diaspora.firstname}} + {{$diaspora.firstname}}
      Family_name
      - {{$diaspora.lastname}} + {{$diaspora.lastname}}
      Url
      - {{$diaspora.podloc}}/ + {{$diaspora.podloc}}/
      Photo
      - +
      Photo_medium
      - +
      Photo_small
      - +
      diff --git a/view/templates/profile_vcard.tpl b/view/templates/profile_vcard.tpl index 0f1cf070c..558daf26d 100644 --- a/view/templates/profile_vcard.tpl +++ b/view/templates/profile_vcard.tpl @@ -16,7 +16,7 @@ {{if $profile.network_name}}
      {{$network}}
      {{$profile.network_name}}
      {{/if}} {{if $location}}
      {{$location}}
      -
      +
      {{if $profile.address}}
      {{$profile.address}}
      {{/if}} {{$profile.locality}}{{if $profile.locality}}, {{/if}} @@ -28,7 +28,7 @@
      {{/if}} - {{if $gender}}
      {{$gender}}
      {{$profile.gender}}
      {{/if}} + {{if $gender}}
      {{$gender}}
      {{$profile.gender}}
      {{/if}} {{if $profile.pubkey}}{{/if}} diff --git a/view/templates/vcard-widget.tpl b/view/templates/vcard-widget.tpl index ec59fa46d..47b64b68d 100644 --- a/view/templates/vcard-widget.tpl +++ b/view/templates/vcard-widget.tpl @@ -1,12 +1,12 @@ -
      -
      {{$name}}
      +
      +
      {{$name}}
      {{if $addr}}
      {{$addr}}
      {{/if}} - {{if $pdesc}}
      {{$pdesc}}
      {{/if}} + {{if $pdesc}}
      {{$pdesc}}
      {{/if}} {{if $url}} -
      {{$name}}
      +
      {{$name}}
      {{else}} -
      {{$name}}
      +
      {{$name}}
      {{/if}} {{if $account_type}}{{/if}} {{if $network_name}}
      {{$network}}
      {{$network_name}}
      {{/if}} diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index ae360adff..335d54f41 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -5,7 +5,7 @@