Date: Wed, 17 Dec 2008 04:04:42 +0000
Subject: [PATCH 116/250] Prepare for 0.2-rc1
---
ChangeLog | 42 ++++++++++++++++++++++++++++++++++++++++++
README | 8 ++------
2 files changed, 44 insertions(+), 6 deletions(-)
create mode 100644 ChangeLog
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..90e5c8a
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,42 @@
+ChangeLog
+
+0.2.0
+
+Features
+ - Blogs can now be configured to use HTML instead of BBCode
+ - Tags now follow the rel-tag microformat standard
+ - Blog module is now translatable
+ - The entries shown on the BlogHolder when not browsing by date/tag can now be restricted to only show entries that are younger than a user specified age
+ - The RSS feed name can now be changed in the CMS
+ - Added support for receiving trackback pings
+ - Added SubscribeRSSWidget for linking directly to the blog RSS feed
+ - Tag widget title is now editable
+ - Added empty relationship statics so BlogEntry and BlogHolder can be decorated by a DataObjectDecorator
+ - Use pagination summary, so a full list of pages isnt generated
+ - Added Date variable to RSSWidget feed items, so Date can be used in template if wanted
+ - Cast Title variable on RSSWidget feed items, so Title can have Text functions called in the template if wanted
+
+Bugfixes
+ - Removed deprecated calls to sapphire, and made other fixes to support sapphire 2.3.0
+ - Don't use PHP short tags
+ - Don't display $Content on a BlogHolder, as it isnt editable in the CMS
+ - Prevent infinite loops when an RSSWidget on a blog points to itself
+ - Fix URL segment generation
+ - RSS feed is now sorted by date, newest first
+ - Fixed pagination
+ - Fixed summaries on BlogHolder
+ - Fixed issues with display by month when blog post is on last month of the day
+ - BlogEntry::Tags() was renamed to TagsCollection() to prevent conflicts with the database fields called Tags
+ - Fixed invalid use of single quotes in BlogEntryForm HTML
+ - Fixed extra tags around blog content
+ - Default parent needs to be a string instead of an array
+ - Fixed escaping in BlogHolder
+ - Use themedCSS instead of hardlinking paths
+ - Fixed rss feed caching
+ - Fixed archive widget showing months and years for unpublished posts
+ - SetDate doesn't need to be called, as the date is automatically set
+
+
+0.1
+
+Initial release
diff --git a/README b/README
index 4e45cdf..4e582d7 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
####################################################
-Blog Moudle
+Blog Module
####################################################
# Maintainer Contact
@@ -7,13 +7,9 @@ Andrew O'Neil (Nickname: aoneil)
# Requirements
-...
+SilverStripe minimum version 2.3.0
# Documentation
http://doc.silverstripe.com/doku.php?id=modules:blog
-# Installation Instructions
-...
-# Usage Overview
-...
\ No newline at end of file
From 3c8df2e6236cccba325c7689d277ec5263a319ce Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Thu, 18 Dec 2008 05:26:43 +0000
Subject: [PATCH 117/250] MINOR: added seperate URLTag element so you can use
the tag segment for something else
---
code/BlogEntry.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index abe4468..85e051b 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -100,7 +100,8 @@ class BlogEntry extends Page {
foreach($tags as $tag) {
$output->push(new ArrayData(array(
'Tag' => $tag,
- 'Link' => $this->getParent()->Link() . 'tag/' . urlencode($tag)
+ 'Link' => $this->getParent()->Link() . 'tag/' . urlencode($tag),
+ 'URLTag' => urlencode($tag)
)));
}
From ff4a95ec26c52b306fa4b246836e73088d0b0ca1 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Mon, 12 Jan 2009 04:35:57 +0000
Subject: [PATCH 118/250] MINOR Updated translations
---
lang/ar_SA.php | 1 +
lang/bg_BG.php | 1 +
lang/de_DE.php | 2 ++
lang/fr_FR.php | 1 +
lang/is_IS.php | 1 +
lang/it_IT.php | 31 +++++++++++++++++++++++++++++++
lang/nl_NL.php | 26 ++++++++++++++++++++++++++
lang/pl_PL.php | 1 +
lang/ru_RU.php | 3 ++-
lang/tr_TR.php | 1 +
10 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/lang/ar_SA.php b/lang/ar_SA.php
index b9fc088..ad29c13 100644
--- a/lang/ar_SA.php
+++ b/lang/ar_SA.php
@@ -48,6 +48,7 @@ $lang['ar_SA']['BlogManagementWidget.ss']['POSTNEW'] = 'نشر تدوينة جد
$lang['ar_SA']['BlogManagementWidget']['UNM1'] = 'يوجد تعليق واØد لا ÙŠØتاج إلى مواÙقة';
$lang['ar_SA']['BlogManagementWidget']['UNMM'] = 'يوجد %i تعليقات لا تØتاج إلى مواÙقة';
$lang['ar_SA']['BlogSummary.ss']['COMMENTS'] = 'التعليقات';
+$lang['ar_SA']['BlogSummary.ss']['POSTEDBY'] = 'بواسطة';
$lang['ar_SA']['BlogSummary.ss']['POSTEDON'] = 'ÙÙŠ';
$lang['ar_SA']['BlogSummary.ss']['VIEWFULL'] = 'عرض كامل التدوينة';
$lang['ar_SA']['RSSWidget']['CT'] = 'العنوان المخصص للخلاصة';
diff --git a/lang/bg_BG.php b/lang/bg_BG.php
index 72f9d65..9015a77 100644
--- a/lang/bg_BG.php
+++ b/lang/bg_BG.php
@@ -48,6 +48,7 @@ $lang['bg_BG']['BlogManagementWidget.ss']['POSTNEW'] = 'Публикувайте
$lang['bg_BG']['BlogManagementWidget']['UNM1'] = 'Вие имате 1 непрегледан коментар';
$lang['bg_BG']['BlogManagementWidget']['UNMM'] = 'Вие имате %i непрегледани коментара';
$lang['bg_BG']['BlogSummary.ss']['COMMENTS'] = 'Коментари';
+$lang['bg_BG']['BlogSummary.ss']['POSTEDBY'] = 'Публикувано от';
$lang['bg_BG']['BlogSummary.ss']['POSTEDON'] = 'на';
$lang['bg_BG']['BlogSummary.ss']['VIEWFULL'] = 'Разгледай цÑлата ÑтатиÑ';
$lang['bg_BG']['RSSWidget']['CT'] = 'СобÑтвено заглавие за емиÑиÑта';
diff --git a/lang/de_DE.php b/lang/de_DE.php
index 5803db9..c189964 100644
--- a/lang/de_DE.php
+++ b/lang/de_DE.php
@@ -48,7 +48,9 @@ $lang['de_DE']['BlogManagementWidget.ss']['POSTNEW'] = 'Neuen Eintrag schreiben'
$lang['de_DE']['BlogManagementWidget']['UNM1'] = 'Sie haben 1 noch nicht moderierten Kommentar';
$lang['de_DE']['BlogManagementWidget']['UNMM'] = 'Sie haben %i noch nicht moderierte Kommentare';
$lang['de_DE']['BlogSummary.ss']['COMMENTS'] = 'Kommentare';
+$lang['de_DE']['BlogSummary.ss']['POSTEDBY'] = 'Verfasst von';
$lang['de_DE']['BlogSummary.ss']['POSTEDON'] = 'am';
+$lang['de_DE']['BlogSummary.ss']['VIEWFULL'] = 'Detaillierte Ansicht von dem Titel --';
$lang['de_DE']['RSSWidget']['CT'] = 'Eigener Titel für den feed';
$lang['de_DE']['RSSWidget']['NTS'] = 'Anzahl der angezeigten Items';
$lang['de_DE']['RSSWidget']['URL'] = 'URL des RSS Feed';
diff --git a/lang/fr_FR.php b/lang/fr_FR.php
index 1f66042..05b9c55 100644
--- a/lang/fr_FR.php
+++ b/lang/fr_FR.php
@@ -48,6 +48,7 @@ $lang['fr_FR']['BlogManagementWidget.ss']['POSTNEW'] = 'Publier une nouvelle ent
$lang['fr_FR']['BlogManagementWidget']['UNM1'] = 'Vous avez 1 commentaire non modéré';
$lang['fr_FR']['BlogManagementWidget']['UNMM'] = 'Vous avez %i commentaires non modérés';
$lang['fr_FR']['BlogSummary.ss']['COMMENTS'] = 'Commentaires';
+$lang['fr_FR']['BlogSummary.ss']['POSTEDBY'] = 'Posté par';
$lang['fr_FR']['BlogSummary.ss']['POSTEDON'] = 'sur';
$lang['fr_FR']['BlogSummary.ss']['VIEWFULL'] = 'Voir le titre du post en entier -';
$lang['fr_FR']['RSSWidget']['CT'] = 'Titre personnalisé pour le flux';
diff --git a/lang/is_IS.php b/lang/is_IS.php
index 26e5236..d679a2f 100644
--- a/lang/is_IS.php
+++ b/lang/is_IS.php
@@ -49,6 +49,7 @@ $lang['is_IS']['BlogManagementWidget.ss']['POSTNEW'] = 'Birta nýju blogg færsl
$lang['is_IS']['BlogManagementWidget']['UNM1'] = 'Þú átt 1 óskoðaða athugasemd';
$lang['is_IS']['BlogManagementWidget']['UNMM'] = 'Þú átt %i óskoðaða athugasemd';
$lang['is_IS']['BlogSummary.ss']['COMMENTS'] = 'Athugasemdir';
+$lang['is_IS']['BlogSummary.ss']['POSTEDBY'] = 'Skráð af';
$lang['is_IS']['BlogSummary.ss']['POSTEDON'] = 'á';
$lang['is_IS']['BlogSummary.ss']['VIEWFULL'] = 'Skoða alla færslu -';
$lang['is_IS']['RSSWidget']['CT'] = 'Titill fyrir þjónustuna';
diff --git a/lang/it_IT.php b/lang/it_IT.php
index 020d24f..c7469b5 100644
--- a/lang/it_IT.php
+++ b/lang/it_IT.php
@@ -16,14 +16,45 @@ if(array_key_exists('it_IT', $lang) && is_array($lang['it_IT'])) {
$lang['it_IT'] = $lang['en_US'];
}
+$lang['it_IT']['ArchiveWidget']['DispBY'] = 'Visualizzato da';
$lang['it_IT']['ArchiveWidget']['MONTH'] = 'mese';
$lang['it_IT']['ArchiveWidget']['YEAR'] = 'anno';
$lang['it_IT']['BlogEntry']['AU'] = 'Autore';
+$lang['it_IT']['BlogEntry']['BBH'] = 'Aiuto BBCode';
+$lang['it_IT']['BlogEntry']['CN'] = 'Contenuto';
$lang['it_IT']['BlogEntry']['DT'] = 'Data';
$lang['it_IT']['BlogEntry.ss']['COMMENTS'] = 'Commenti';
+$lang['it_IT']['BlogEntry.ss']['EDITTHIS'] = 'Modifica questo post';
+$lang['it_IT']['BlogEntry.ss']['POSTEDBY'] = 'Inserito da';
+$lang['it_IT']['BlogEntry.ss']['POSTEDON'] = 'su';
+$lang['it_IT']['BlogEntry.ss']['TAGS'] = 'Etichette:';
+$lang['it_IT']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Non pubblicare questo post';
+$lang['it_IT']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Visualizza tutti i post con etichetta';
+$lang['it_IT']['BlogEntry']['TS'] = 'Etichette (separate da virgola)';
+$lang['it_IT']['BlogHolder']['HAVENTPERM'] = 'Scrivere nel blog è un\'attività dell\'amministratore. Accedi come amministratore.';
+$lang['it_IT']['BlogHolder']['POST'] = 'Salva il post nel blog';
+$lang['it_IT']['BlogHolder']['RSSFEED'] = 'RSS feed di questo blog';
$lang['it_IT']['BlogHolder']['SJ'] = 'Soggetto';
+$lang['it_IT']['BlogHolder']['SPUC'] = 'Per favore separa le etichette usando virgole.';
+$lang['it_IT']['BlogHolder.ss']['NOENTRIES'] = 'Non ci sono voci nel blog';
+$lang['it_IT']['BlogHolder.ss']['VIEWINGTAGGED'] = 'Visualizza voci con etichetta';
+$lang['it_IT']['BlogHolder']['SUCCONTENT'] = 'Congratulazioni, il blog SilverStripe è stato installato correttamente. Questo messaggio del blog può essere eliminato. Puoi configurare l\'aspetto del tuo blog (come la visualizzazione dei widgets nella sidebar) in [url=admin] del CMS[/url]';
$lang['it_IT']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
+$lang['it_IT']['BlogHolder']['SUCTITLE'] = 'Modulo blog SilverStripe installato correttamente';
+$lang['it_IT']['BlogHolder']['TE'] = 'Ad esempio: sport, personale, fantascienza';
+$lang['it_IT']['BlogManagementWidget']['COMADM'] = 'Amministrazione commenti';
+$lang['it_IT']['BlogManagementWidget.ss']['LOGOUT'] = 'Esci';
+$lang['it_IT']['BlogManagementWidget.ss']['POSTNEW'] = 'Inserisci un nuovo post';
+$lang['it_IT']['BlogManagementWidget']['UNM1'] = 'Hai 1 commento da moderare';
+$lang['it_IT']['BlogManagementWidget']['UNMM'] = 'Hai %i commenti non approvati';
$lang['it_IT']['BlogSummary.ss']['COMMENTS'] = 'Commenti';
+$lang['it_IT']['BlogSummary.ss']['POSTEDBY'] = 'Inserito da';
+$lang['it_IT']['BlogSummary.ss']['POSTEDON'] = 'su';
+$lang['it_IT']['BlogSummary.ss']['VIEWFULL'] = 'Visualizza post intitolato - ';
+$lang['it_IT']['RSSWidget']['CT'] = 'Titolo del feed';
+$lang['it_IT']['RSSWidget']['NTS'] = 'Numero di argomenti da visualizzare';
+$lang['it_IT']['RSSWidget']['URL'] = 'URL per il Feed RSS';
+$lang['it_IT']['TagCloudWidget']['LIMIT'] = 'Limitare il numero dei tag a';
$lang['it_IT']['TagCloudWidget']['SBAL'] = 'alfabeto';
$lang['it_IT']['TagCloudWidget']['SBFREQ'] = 'frequenza';
$lang['it_IT']['TagCloudWidget']['SORTBY'] = 'Ordina per';
diff --git a/lang/nl_NL.php b/lang/nl_NL.php
index 35afd06..8df768c 100644
--- a/lang/nl_NL.php
+++ b/lang/nl_NL.php
@@ -16,6 +16,13 @@ if(array_key_exists('nl_NL', $lang) && is_array($lang['nl_NL'])) {
$lang['nl_NL'] = $lang['en_US'];
}
+$lang['nl_NL']['ArchiveWidget']['DispBY'] = 'Tonen door';
+$lang['nl_NL']['ArchiveWidget']['MONTH'] = 'maand';
+$lang['nl_NL']['ArchiveWidget']['YEAR'] = 'jaar';
+$lang['nl_NL']['BlogEntry']['AU'] = 'Auteur';
+$lang['nl_NL']['BlogEntry']['BBH'] = 'BBCode hulp';
+$lang['nl_NL']['BlogEntry']['CN'] = 'Inhoud';
+$lang['nl_NL']['BlogEntry']['DT'] = 'Datum';
$lang['nl_NL']['BlogEntry.ss']['COMMENTS'] = 'Reacties';
$lang['nl_NL']['BlogEntry.ss']['EDITTHIS'] = 'Bewerk dit post';
$lang['nl_NL']['BlogEntry.ss']['POSTEDBY'] = 'Auteur';
@@ -23,15 +30,34 @@ $lang['nl_NL']['BlogEntry.ss']['POSTEDON'] = 'Aan';
$lang['nl_NL']['BlogEntry.ss']['TAGS'] = 'Tags:';
$lang['nl_NL']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'onpubliceer dit post';
$lang['nl_NL']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Bekijk alle posten getiteld';
+$lang['nl_NL']['BlogEntry']['TS'] = 'Tags (Komma gescheiden)';
+$lang['nl_NL']['BlogHolder']['HAVENTPERM'] = 'Het plaatsen van blogartikelen is een beheerder taak. Log aub in.';
+$lang['nl_NL']['BlogHolder']['POST'] = 'Blogartikel plaatsen';
+$lang['nl_NL']['BlogHolder']['RSSFEED'] = 'RSS-feed van deze blog';
+$lang['nl_NL']['BlogHolder']['SJ'] = 'Onderwerp';
+$lang['nl_NL']['BlogHolder']['SPUC'] = 'Scheid de tags met behulp van komma\'s.';
$lang['nl_NL']['BlogHolder.ss']['NOENTRIES'] = 'Er zijn geen blog entrees ';
$lang['nl_NL']['BlogHolder.ss']['VIEWINGTAGGED'] = 'U bekijkt entrees tagged met';
+$lang['nl_NL']['BlogHolder']['SUCCONTENT'] = 'Gefeliciteerd, de SilverStripe blog module is met succes geïnstalleerd. Dit blogartikel kan veilig worden verwijderd. U kunt aspecten van uw blog (zoals de widgets weergegeven in de zijbalk) in [url=admin]het CMS[/url] veranderen.';
+$lang['nl_NL']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
+$lang['nl_NL']['BlogHolder']['SUCTITLE'] = 'SilverStripe blog module met succes geïnstalleerd';
+$lang['nl_NL']['BlogHolder']['TE'] = 'Bijvoorbeeld: sport, persoonlijke, science fiction';
+$lang['nl_NL']['BlogManagementWidget']['COMADM'] = 'Opmerking administratie';
$lang['nl_NL']['BlogManagementWidget.ss']['LOGOUT'] = 'Afmelden';
$lang['nl_NL']['BlogManagementWidget.ss']['POSTNEW'] = 'Publiceer een nieuw blog entree';
+$lang['nl_NL']['BlogManagementWidget']['UNM1'] = 'U heeft 1 niet gecontroleerde opmerking';
+$lang['nl_NL']['BlogManagementWidget']['UNMM'] = 'U heeft %i niet gecontroleerde opmerkingen';
$lang['nl_NL']['BlogSummary.ss']['COMMENTS'] = 'Reacties';
+$lang['nl_NL']['BlogSummary.ss']['POSTEDBY'] = 'Geplaatst door';
$lang['nl_NL']['BlogSummary.ss']['POSTEDON'] = 'Aan';
$lang['nl_NL']['BlogSummary.ss']['VIEWFULL'] = 'Bekijk het gehele post getitled';
+$lang['nl_NL']['RSSWidget']['CT'] = 'Aangepaste titel voor de RSS-feed';
+$lang['nl_NL']['RSSWidget']['NTS'] = 'Aantal objecten tonen';
+$lang['nl_NL']['RSSWidget']['URL'] = 'URL van de RSS-feed';
+$lang['nl_NL']['TagCloudWidget']['LIMIT'] = 'Beperk aantal tags';
$lang['nl_NL']['TagCloudWidget']['SBAL'] = 'alfabet';
$lang['nl_NL']['TagCloudWidget']['SBFREQ'] = 'frequentie';
$lang['nl_NL']['TagCloudWidget']['SORTBY'] = 'Sorteer bij';
+$lang['nl_NL']['TagCloudWidget']['TILE'] = 'Titel';
?>
\ No newline at end of file
diff --git a/lang/pl_PL.php b/lang/pl_PL.php
index 2c6a555..187889c 100644
--- a/lang/pl_PL.php
+++ b/lang/pl_PL.php
@@ -48,6 +48,7 @@ $lang['pl_PL']['BlogManagementWidget.ss']['POSTNEW'] = 'Dodaj nowy wpis';
$lang['pl_PL']['BlogManagementWidget']['UNM1'] = 'Masz 1 niesprawdzony komentarz';
$lang['pl_PL']['BlogManagementWidget']['UNMM'] = 'Masz %i niesprawdzonych komentarzy';
$lang['pl_PL']['BlogSummary.ss']['COMMENTS'] = 'Komentarze';
+$lang['pl_PL']['BlogSummary.ss']['POSTEDBY'] = 'Napisane przez';
$lang['pl_PL']['BlogSummary.ss']['POSTEDON'] = 'w';
$lang['pl_PL']['BlogSummary.ss']['VIEWFULL'] = 'Zobacz pełny post zatytułowany - ';
$lang['pl_PL']['RSSWidget']['CT'] = 'Tytuł dla kanału';
diff --git a/lang/ru_RU.php b/lang/ru_RU.php
index 5f4ac94..11a5347 100644
--- a/lang/ru_RU.php
+++ b/lang/ru_RU.php
@@ -41,13 +41,14 @@ $lang['ru_RU']['BlogHolder.ss']['VIEWINGTAGGED'] = 'ПроÑмотр запиÑ
$lang['ru_RU']['BlogHolder']['SUCCONTENT'] = 'ПоздравлÑем, модуль блога SilverStripe был уÑпешно уÑтановлен. Ðта запиÑÑŒ в блоге может быть удалена. Ð’Ñ‹ можете наÑтроить вид блога (например, отображение виджетов в боковой панели) в [url=admin]СиÑтеме Ð£Ð¿Ñ€Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð¡Ð¾Ð´ÐµÑ€Ð¶Ð¸Ð¼Ñ‹Ð¼[/url].';
$lang['ru_RU']['BlogHolder']['SUCTAGS'] = 'silverstripe, блог';
$lang['ru_RU']['BlogHolder']['SUCTITLE'] = 'Модуль блога SilverStripe уÑпешно уÑтановлен';
-$lang['ru_RU']['BlogHolder']['TE'] = 'Ðапример, Ñпорт, личное, фантаÑтика';
+$lang['ru_RU']['BlogHolder']['TE'] = 'Ðапример - Ñпорт, личное, фантаÑтика';
$lang['ru_RU']['BlogManagementWidget']['COMADM'] = 'Управление комментариÑми';
$lang['ru_RU']['BlogManagementWidget.ss']['LOGOUT'] = 'Выход';
$lang['ru_RU']['BlogManagementWidget.ss']['POSTNEW'] = 'Опубликовать новую запиÑÑŒ';
$lang['ru_RU']['BlogManagementWidget']['UNM1'] = 'У Ð²Ð°Ñ 1 непроверенный комментарий';
$lang['ru_RU']['BlogManagementWidget']['UNMM'] = 'У Ð²Ð°Ñ %i непроверенных комментариев';
$lang['ru_RU']['BlogSummary.ss']['COMMENTS'] = 'Комментарии';
+$lang['ru_RU']['BlogSummary.ss']['POSTEDBY'] = 'Ðвтор:';
$lang['ru_RU']['BlogSummary.ss']['POSTEDON'] = ':';
$lang['ru_RU']['BlogSummary.ss']['VIEWFULL'] = 'См. полноÑтью запиÑÑŒ под названием: ';
$lang['ru_RU']['RSSWidget']['CT'] = 'СобÑтвенное название ленты новоÑтей';
diff --git a/lang/tr_TR.php b/lang/tr_TR.php
index 0244791..15cbbc7 100644
--- a/lang/tr_TR.php
+++ b/lang/tr_TR.php
@@ -48,6 +48,7 @@ $lang['tr_TR']['BlogManagementWidget.ss']['POSTNEW'] = 'Yeni bir blog girdisi ol
$lang['tr_TR']['BlogManagementWidget']['UNM1'] = '1 adet onay bekleyen yorumunuz var';
$lang['tr_TR']['BlogManagementWidget']['UNMM'] = '%i adet onay bekleyen yorumunuz var';
$lang['tr_TR']['BlogSummary.ss']['COMMENTS'] = 'Yorumlar';
+$lang['tr_TR']['BlogSummary.ss']['POSTEDBY'] = 'Gönderen: ';
$lang['tr_TR']['BlogSummary.ss']['POSTEDON'] = 'üzerinde';
$lang['tr_TR']['BlogSummary.ss']['VIEWFULL'] = 'Postun tamamını görüntüle -';
$lang['tr_TR']['RSSWidget']['CT'] = 'Besleme için özel başlık';
From 4340fb91dba6cc3740efbd0da09c2846309dd1ad Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Mon, 12 Jan 2009 04:58:29 +0000
Subject: [PATCH 119/250] MINOR Updated language master tables
---
lang/en_US.php | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lang/en_US.php b/lang/en_US.php
index 00a64b6..6609931 100644
--- a/lang/en_US.php
+++ b/lang/en_US.php
@@ -90,6 +90,18 @@ $lang['en_US']['RSSWidget']['SINGULARNAME'] = array(
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
);
$lang['en_US']['RSSWidget']['URL'] = 'URL of RSS Feed';
+$lang['en_US']['SubscribeRSSWidget']['PLURALNAME'] = array(
+ 'Subscribe R S S Widgets',
+ 50,
+ 'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
+);
+$lang['en_US']['SubscribeRSSWidget']['SINGULARNAME'] = array(
+ 'Subscribe R S S Widget',
+ 50,
+ 'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
+);
+$lang['en_US']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Subscribe';
+$lang['en_US']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Subscribe to this blog via RSS';
$lang['en_US']['TagCloudWidget']['LIMIT'] = 'Limit number of tags';
$lang['en_US']['TagCloudWidget']['PLURALNAME'] = array(
'Tag Cloud Widgets',
From 94391c22d7f68e0d1d5e143c74dbf893f1afce53 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Mon, 12 Jan 2009 22:27:05 +0000
Subject: [PATCH 120/250] BUGFIX Allow SearchForm URL action for default SS
search on BlogEntry
---
code/BlogEntry.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 85e051b..2239fe7 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -181,7 +181,8 @@ class BlogEntry_Controller extends Page_Controller {
static $allowed_actions = array(
'trackbackping',
'unpublishPost',
- 'PageComments'
+ 'PageComments',
+ 'SearchForm'
);
function init() {
From c18af6c47322eb206e5419438b5044971261a41a Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Tue, 13 Jan 2009 22:03:27 +0000
Subject: [PATCH 121/250] MINOR Updated translations
---
lang/tr_TR.php | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/lang/tr_TR.php b/lang/tr_TR.php
index 15cbbc7..24d4b57 100644
--- a/lang/tr_TR.php
+++ b/lang/tr_TR.php
@@ -18,11 +18,15 @@ if(array_key_exists('tr_TR', $lang) && is_array($lang['tr_TR'])) {
$lang['tr_TR']['ArchiveWidget']['DispBY'] = 'Görüntüle';
$lang['tr_TR']['ArchiveWidget']['MONTH'] = 'ay';
+$lang['tr_TR']['ArchiveWidget']['PLURALNAME'] = 'Arşiv Zımbırtıları';
+$lang['tr_TR']['ArchiveWidget']['SINGULARNAME'] = 'Arşiv Zımbırtısı';
$lang['tr_TR']['ArchiveWidget']['YEAR'] = 'yıl';
$lang['tr_TR']['BlogEntry']['AU'] = 'Yazar';
$lang['tr_TR']['BlogEntry']['BBH'] = 'BBCode yardımı';
$lang['tr_TR']['BlogEntry']['CN'] = 'İçerik';
$lang['tr_TR']['BlogEntry']['DT'] = 'Tarih';
+$lang['tr_TR']['BlogEntry']['PLURALNAME'] = 'Blog Girdileri';
+$lang['tr_TR']['BlogEntry']['SINGULARNAME'] = 'Blog Girdisi';
$lang['tr_TR']['BlogEntry.ss']['COMMENTS'] = 'Yorumlar';
$lang['tr_TR']['BlogEntry.ss']['EDITTHIS'] = 'Bu girdiyi yeniden düzenle';
$lang['tr_TR']['BlogEntry.ss']['POSTEDBY'] = 'Gönderen ';
@@ -32,8 +36,10 @@ $lang['tr_TR']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Bu girdiyi yayından kaldır'
$lang['tr_TR']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Etiketlenen tüm girdileri görüntüle';
$lang['tr_TR']['BlogEntry']['TS'] = 'Etiketler (virgülle ayrılmış)';
$lang['tr_TR']['BlogHolder']['HAVENTPERM'] = 'Sadece yöneticiler blog girebilirler. Lütfen oturum açın.';
+$lang['tr_TR']['BlogHolder']['PLURALNAME'] = 'Blog Sahipleri';
$lang['tr_TR']['BlogHolder']['POST'] = 'Blog girdisi gönderin';
$lang['tr_TR']['BlogHolder']['RSSFEED'] = 'Bu blog\'un RSS beslemesi';
+$lang['tr_TR']['BlogHolder']['SINGULARNAME'] = 'Blog Sahibi';
$lang['tr_TR']['BlogHolder']['SJ'] = 'Konu';
$lang['tr_TR']['BlogHolder']['SPUC'] = 'Lüfen etiketleri virgülle ayırın.';
$lang['tr_TR']['BlogHolder.ss']['NOENTRIES'] = 'Blog girdileri mevcut deÄŸil';
@@ -43,6 +49,8 @@ $lang['tr_TR']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
$lang['tr_TR']['BlogHolder']['SUCTITLE'] = 'SilverStripe blog modülü başarıyla kuruldu';
$lang['tr_TR']['BlogHolder']['TE'] = 'Örneğin: spor, kişisel, bilim kurgu';
$lang['tr_TR']['BlogManagementWidget']['COMADM'] = 'Yorum yönetimi';
+$lang['tr_TR']['BlogManagementWidget']['PLURALNAME'] = 'Blog Yönetim Zımbırtıları';
+$lang['tr_TR']['BlogManagementWidget']['SINGULARNAME'] = 'Blog Yönetim Zımbırtısı';
$lang['tr_TR']['BlogManagementWidget.ss']['LOGOUT'] = 'Oturumu kapat';
$lang['tr_TR']['BlogManagementWidget.ss']['POSTNEW'] = 'Yeni bir blog girdisi oluÅŸtur';
$lang['tr_TR']['BlogManagementWidget']['UNM1'] = '1 adet onay bekleyen yorumunuz var';
@@ -53,11 +61,21 @@ $lang['tr_TR']['BlogSummary.ss']['POSTEDON'] = 'üzerinde';
$lang['tr_TR']['BlogSummary.ss']['VIEWFULL'] = 'Postun tamamını görüntüle -';
$lang['tr_TR']['RSSWidget']['CT'] = 'Besleme için özel başlık';
$lang['tr_TR']['RSSWidget']['NTS'] = 'Görüntülenecek öğe adedi';
+$lang['tr_TR']['RSSWidget']['PLURALNAME'] = 'R S S Zımbırtıları';
+$lang['tr_TR']['RSSWidget']['SINGULARNAME'] = 'R S S Zımbırtısı';
$lang['tr_TR']['RSSWidget']['URL'] = 'RSS beslemesi\'nin URL\'i';
+$lang['tr_TR']['SubscribeRSSWidget']['PLURALNAME'] = 'R S S Zımbırtılarına abone ol';
+$lang['tr_TR']['SubscribeRSSWidget']['SINGULARNAME'] = 'R S S Zımbırtısına abone ol';
+$lang['tr_TR']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Abone Ol';
+$lang['tr_TR']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Bu bloÄŸa RSS ile abone ol';
$lang['tr_TR']['TagCloudWidget']['LIMIT'] = 'Etiket sayısini sınırla';
+$lang['tr_TR']['TagCloudWidget']['PLURALNAME'] = 'Etiket Bulutu Zımbırtıları';
$lang['tr_TR']['TagCloudWidget']['SBAL'] = 'alfabe';
$lang['tr_TR']['TagCloudWidget']['SBFREQ'] = 'frekans';
+$lang['tr_TR']['TagCloudWidget']['SINGULARNAME'] = 'Etiket Bulutu Zımbırtısı';
$lang['tr_TR']['TagCloudWidget']['SORTBY'] = 'Sıralama';
$lang['tr_TR']['TagCloudWidget']['TILE'] = 'Başlık';
+$lang['tr_TR']['TrackBackPing']['PLURALNAME'] = 'Geri İz Yoklamaları';
+$lang['tr_TR']['TrackBackPing']['SINGULARNAME'] = 'Geri İz Yoklaması';
?>
\ No newline at end of file
From 32f4579718ee2c38caa58982748a4520102bc759 Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Tue, 20 Jan 2009 04:01:45 +0000
Subject: [PATCH 122/250] MINOR: added empty statics to blog
---
code/ArchiveWidget.php | 8 ++++++++
code/BlogEntry.php | 11 +++++------
code/BlogHolder.php | 10 ++++++----
code/BlogManagementWidget.php | 16 +++++++++++++++-
code/RSSWidget.php | 7 +++++++
code/TagCloudWidget.php | 8 ++++++++
code/TrackBackPing.php | 6 ++++++
7 files changed, 55 insertions(+), 11 deletions(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 93227b4..7e5db71 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -6,9 +6,17 @@
* @package blog
*/
class ArchiveWidget extends Widget {
+
static $db = array(
'DisplayMode' => 'Varchar'
);
+ static $has_one = array();
+
+ static $has_many = array();
+
+ static $many_many = array();
+
+ static $belongs_many_many = array();
static $defaults = array(
'DisplayMode' => 'month'
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 2239fe7..8a36c12 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -18,14 +18,13 @@ class BlogEntry extends Page {
"Tags" => "Text"
);
- static $has_one = array(
- );
+ static $has_one = array();
- static $has_many = array(
- );
+ static $has_many = array();
- static $many_many = array(
- );
+ static $many_many = array();
+
+ static $belongs_many_many = array();
static $defaults = array(
"ProvideComments" => true,
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 2bdc475..5cccf10 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -22,11 +22,13 @@ class BlogHolder extends Page {
"SideBar" => "WidgetArea"
);
- static $has_many = array(
- );
+ static $has_many = array();
- static $many_many = array(
- );
+ static $many_many = array();
+
+ static $belongs_many_many = array();
+
+ static $defaults = array();
static $allowed_children = array(
'BlogEntry'
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index 0fbb41e..57be2bd 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -1,8 +1,22 @@
"Text",
"NumberToShow" => "Int"
);
+ static $has_one = array();
+
+ static $has_many = array();
+
+ static $many_many = array();
+
+ static $belongs_many_many = array();
static $defaults = array(
"NumberToShow" => 10,
diff --git a/code/TagCloudWidget.php b/code/TagCloudWidget.php
index 46e42d1..6500c3b 100644
--- a/code/TagCloudWidget.php
+++ b/code/TagCloudWidget.php
@@ -7,6 +7,14 @@ class TagCloudWidget extends Widget {
"Sortby" => "Varchar"
);
+ static $has_one = array();
+
+ static $has_many = array();
+
+ static $many_many = array();
+
+ static $belongs_many_many = array();
+
static $defaults = array(
"Title" => "Tag Cloud",
"Limit" => "0",
diff --git a/code/TrackBackPing.php b/code/TrackBackPing.php
index 900a50a..899346e 100644
--- a/code/TrackBackPing.php
+++ b/code/TrackBackPing.php
@@ -11,6 +11,12 @@ class TrackBackPing extends DataObject {
static $has_one = array(
'Page' => 'Page'
);
+
+ static $has_many = array();
+
+ static $many_many = array();
+
+ static $belongs_many_many = array()
}
?>
From 058a3c393c7b1d4dbc712775a564b7da2bc45a2d Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Tue, 20 Jan 2009 04:37:44 +0000
Subject: [PATCH 123/250] BUGFIX: added missing semi colon
---
code/TrackBackPing.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/TrackBackPing.php b/code/TrackBackPing.php
index 899346e..a38771a 100644
--- a/code/TrackBackPing.php
+++ b/code/TrackBackPing.php
@@ -16,7 +16,7 @@ class TrackBackPing extends DataObject {
static $many_many = array();
- static $belongs_many_many = array()
+ static $belongs_many_many = array();
}
?>
From 94601547aff8347d2d3ebfaf39549c7a281ec9e6 Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Sat, 7 Feb 2009 02:19:27 +0000
Subject: [PATCH 124/250] FEATURE: added userblog support. Thanks simon_w -
#3463
---
code/BlogEntry.php | 5 ++++-
code/BlogHolder.php | 35 ++++++++++++++++++++++++-------
code/BlogManagementWidget.php | 8 +++++--
templates/BlogManagementWidget.ss | 4 ++--
templates/Layout/BlogEntry.ss | 2 +-
5 files changed, 41 insertions(+), 13 deletions(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 8a36c12..bb73f93 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -167,6 +167,9 @@ class BlogEntry extends Page {
}
}
+ function IsOwner() {
+ return $this->Parent()->IsOwner();
+ }
/**
* Call this to enable WYSIWYG editing on your blog entries.
* By default the blog uses BBCode
@@ -194,7 +197,7 @@ class BlogEntry_Controller extends Page_Controller {
* Gets a link to unpublish the blog entry
*/
function unpublishPost() {
- if(!Permission::check('ADMIN')) {
+ if(!$this->IsOwner()) {
Security::permissionFailure(
$this,
'Unpublishing blogs is an administrator task. Please log in.'
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 5cccf10..8a166a3 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -15,11 +15,13 @@ class BlogHolder extends Page {
static $db = array(
'LandingPageFreshness' => 'Varchar',
'Name' => 'Varchar',
- 'TrackBacksEnabled' => 'Boolean'
+ 'TrackBacksEnabled' => 'Boolean',
+ 'AllowCustomAuthors' => 'Boolean',
);
static $has_one = array(
- "SideBar" => "WidgetArea"
+ "SideBar" => "WidgetArea",
+ 'Owner' => 'Member',
);
static $has_many = array();
@@ -57,6 +59,8 @@ class BlogHolder extends Page {
)));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
+ $fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', DataObject::get('Member')->toDropDownMap('ID', 'Name', 'None')));
+ $fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
return $fields;
}
@@ -119,6 +123,15 @@ class BlogHolder extends Page {
return $this->Link('post');
}
+ /**
+ * Returns true if the current user is an admin, or is the owner of this blog
+ *
+ * @return Boolean
+ */
+ function IsOwner() {
+ return Permission::check('ADMIN') || (Member::CurrentMember() && Member::CurrentMember()->ID == $this->OwnerID);
+ }
+
/**
* Create default blog setup
*/
@@ -260,7 +273,7 @@ class BlogHolder_Controller extends Page_Controller {
* Post a new blog entry
*/
function post(){
- if(!Permission::check('ADMIN')){
+ if(!$this->IsOwner()){
Security::permissionFailure($this, _t('BlogHolder.HAVENTPERM', 'Posting blogs is an administrator task. Please log in.'));
}
@@ -315,11 +328,14 @@ class BlogHolder_Controller extends Page_Controller {
} else {
$tagfield = new TextField('Tags');
}
-
+ $field = 'TextField';
+ if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
+ $field = 'ReadonlyField';
+ }
$fields = new FieldSet(
new HiddenField("ID", "ID"),
new TextField("Title",_t('BlogHolder.SJ', "Subject")),
- new TextField("Author",_t('BlogEntry.AU'),$membername),
+ new $field("Author",_t('BlogEntry.AU'),$membername),
$contentfield,
$tagfield,
new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
@@ -334,8 +350,10 @@ class BlogHolder_Controller extends Page_Controller {
if($id != 0) {
$entry = DataObject::get_by_id('BlogEntry', $id);
- $form->loadNonBlankDataFrom($entry);
- $form->datafieldByName('BlogPost')->setValue($entry->Content);
+ if($entry->IsOwner()) {
+ $form->loadNonBlankDataFrom($entry);
+ $form->datafieldByName('BlogPost')->setValue($entry->Content);
+ }
} else {
$form->loadNonBlankDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
}
@@ -349,6 +367,9 @@ class BlogHolder_Controller extends Page_Controller {
if($data['ID']) {
$blogentry = DataObject::get_by_id("BlogEntry", $data['ID']);
+ if(!$blogentry->IsOwner()) {
+ unset($blogentry);
+ }
}
if(!$blogentry) {
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index 57be2bd..0ba2669 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -33,6 +33,9 @@ class BlogManagementWidget extends Widget {
}
function CommentLink() {
+ if(!Permission::check('ADMIN')) {
+ return false;
+ }
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
if($unmoderatedcount > 0) {
@@ -43,9 +46,10 @@ class BlogManagementWidget extends Widget {
}
function WidgetHolder() {
- if(Permission::check("ADMIN")) {
- return $this->renderWith("WidgetHolder");
+ if($this->getBlogHolder()->IsOwner()) {
+ return $this->renderWith('WidgetHolder');
}
+ return '';
}
function PostLink() {
diff --git a/templates/BlogManagementWidget.ss b/templates/BlogManagementWidget.ss
index c2e6a6a..29f4b4a 100644
--- a/templates/BlogManagementWidget.ss
+++ b/templates/BlogManagementWidget.ss
@@ -1,5 +1,5 @@
\ No newline at end of file
+
diff --git a/templates/Layout/BlogEntry.ss b/templates/Layout/BlogEntry.ss
index cc37068..fffc930 100644
--- a/templates/Layout/BlogEntry.ss
+++ b/templates/Layout/BlogEntry.ss
@@ -21,7 +21,7 @@
- <% if CurrentMember %><% _t('EDITTHIS', 'Edit this post') %> | <% _t('UNPUBLISHTHIS', 'Unpublish this post') %>
<% end_if %>
+ <% if IsOwner %><% _t('EDITTHIS', 'Edit this post') %> | <% _t('UNPUBLISHTHIS', 'Unpublish this post') %>
<% end_if %>
<% if TrackBacksEnabled %>
<% include TrackBacks %>
From 0adb9da4665a6fce7023eeb46adad1fb59ef2bbd Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Wed, 25 Feb 2009 06:55:58 +0000
Subject: [PATCH 125/250] ENHANCEMENT Added 'rss' suffix to BlogHolder->rss()
to point back to the feed properly (was causing feed validation errors)
---
code/BlogHolder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 8a166a3..58eee37 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -257,7 +257,7 @@ class BlogHolder_Controller extends Page_Controller {
$entries = $this->Entries(20);
if($entries) {
- $rss = new RSSFeed($entries, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent");
+ $rss = new RSSFeed($entries, $this->Link() . 'rss', ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent");
$rss->outputToBrowser();
}
}
From baa470dd10e9522e266a50564938bc2c931a2a18 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Tue, 21 Apr 2009 23:06:12 +0000
Subject: [PATCH 126/250] Added css class to blog post titles
---
templates/Includes/BlogSummary.ss | 2 +-
templates/Layout/BlogEntry.ss | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/templates/Includes/BlogSummary.ss b/templates/Includes/BlogSummary.ss
index 7904a6b..07a149c 100644
--- a/templates/Includes/BlogSummary.ss
+++ b/templates/Includes/BlogSummary.ss
@@ -1,5 +1,5 @@
-
+
<% _t('POSTEDBY', 'Posted by') %> $Author.XML <% _t('POSTEDON', 'on') %> $Date.Long | $Comments.Count <% _t('COMMENTS', 'Comments') %>
<% if TagsCollection %>
diff --git a/templates/Layout/BlogEntry.ss b/templates/Layout/BlogEntry.ss
index fffc930..524c538 100644
--- a/templates/Layout/BlogEntry.ss
+++ b/templates/Layout/BlogEntry.ss
@@ -3,7 +3,7 @@
<% include BreadCrumbs %>
-
$Title
+
$Title
<% _t('POSTEDBY', 'Posted by') %> $Author.XML <% _t('POSTEDON', 'on') %> $Date.Long | $Comments.Count <% _t('COMMENTS', 'Comments') %>
<% if TagsCollection %>
From 05b0992f7e803879327188ce42b9af2a771cfaf7 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Sun, 26 Apr 2009 23:52:14 +0000
Subject: [PATCH 127/250] MINOR: Show BlogManagementWidget if the user has
permissions to post
---
code/BlogManagementWidget.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index 0ba2669..eca72ec 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -46,7 +46,7 @@ class BlogManagementWidget extends Widget {
}
function WidgetHolder() {
- if($this->getBlogHolder()->IsOwner()) {
+ if($this->getBlogHolder()->canEdit()) {
return $this->renderWith('WidgetHolder');
}
return '';
@@ -71,4 +71,4 @@ class BlogManagementWidget extends Widget {
}
}
-?>
\ No newline at end of file
+?>
From 16c7b2d431932fd12c193151e23f926b5c61948f Mon Sep 17 00:00:00 2001
From: Hamish Friedlander
Date: Thu, 30 Apr 2009 22:05:54 +0000
Subject: [PATCH 128/250] FEATURE: Add an additional level of blog container,
called the tree. You can now use blogs in the previous manner (holder has
many entries) or as a deep tree of many holders. Viewing a level up the tree
will show all blog entries within that tree.
@todo:
More Tests
Better documentation
---
code/ArchiveWidget.php | 34 ++---
code/BlogHolder.php | 167 ++-------------------
code/BlogManagementWidget.php | 23 +--
code/BlogTree.php | 268 ++++++++++++++++++++++++++++++++++
code/SubscribeRSSWidget.php | 24 +--
code/TagCloudWidget.php | 19 +--
tests/BlogTreeTest.php | 30 ++++
tests/BlogTreeTest.yml | 53 +++++++
8 files changed, 392 insertions(+), 226 deletions(-)
create mode 100644 code/BlogTree.php
create mode 100644 tests/BlogTreeTest.php
create mode 100644 tests/BlogTreeTest.yml
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 7e5db71..7cec3ae 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -28,18 +28,6 @@ class ArchiveWidget extends Widget {
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
- function getBlogHolder() {
- $page = Director::currentPage();
-
- if($page instanceof BlogHolder) {
- return $page;
- } elseif(($page instanceof BlogEntry) && ($page->getParent() instanceof BlogHolder)) {
- return $page->getParent();
- } else {
- return DataObject::get_one('BlogHolder');
- }
- }
-
function getCMSFields() {
return new FieldSet(
new OptionsetField(
@@ -57,17 +45,27 @@ class ArchiveWidget extends Widget {
Requirements::themedCSS('archivewidget');
$results = new DataObjectSet();
- $blogHolder = $this->getBlogHolder();
- $id = $blogHolder->ID;
+ $container = BlogTree::current();
+ $ids = $container->BlogHolderIDs();
$stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
if($this->DisplayMode == 'month') {
- $sqlResults = DB::query("SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year` FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix` WHERE `ParentID` = $id ORDER BY `Date` DESC");
+ $sqlResults = DB::query("
+ SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year`
+ FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
+ WHERE `ParentID` in (".implode(', ',$ids).")
+ ORDER BY `Date` DESC"
+ );
} else {
- $sqlResults = DB::query("SELECT DISTINCT YEAR(`Date`) AS `Year` FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix` WHERE `ParentID` = $id ORDER BY `Date` DESC");
+ $sqlResults = DB::query("
+ SELECT DISTINCT YEAR(`Date`) AS `Year`
+ FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
+ WHERE `ParentID` in (".implode(', ',$ids).")
+ ORDER BY `Date` DESC"
+ );
}
if(!$sqlResults) return new DataObjectSet();
@@ -83,9 +81,9 @@ class ArchiveWidget extends Widget {
));
if($this->DisplayMode == 'month') {
- $link = $blogHolder->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $sqlResult['Month']);
+ $link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $sqlResult['Month']);
} else {
- $link = $blogHolder->Link() . $sqlResult['Year'];
+ $link = $container->Link() . $sqlResult['Year'];
}
$results->push(new ArrayData(array(
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 58eee37..e766729 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -5,59 +5,34 @@
*/
/**
- * Blog holder to display summarised blog entries
+ * Blog holder to display summarised blog entries.
+ *
+ * A blog holder is the leaf end of a BlogTree, but can also be used standalone in simpler circumstances.
+ * BlogHolders can only hold BlogEntries, BlogTrees can only hold BlogTrees and BlogHolders
+ * BlogHolders have a form on them for easy posting, and an owner that can post to them, BlogTrees don't
*/
-
-class BlogHolder extends Page {
+class BlogHolder extends BlogTree {
static $icon = "blog/images/blogholder";
static $db = array(
- 'LandingPageFreshness' => 'Varchar',
'Name' => 'Varchar',
'TrackBacksEnabled' => 'Boolean',
'AllowCustomAuthors' => 'Boolean',
);
static $has_one = array(
- "SideBar" => "WidgetArea",
'Owner' => 'Member',
);
- static $has_many = array();
-
- static $many_many = array();
-
- static $belongs_many_many = array();
-
- static $defaults = array();
-
static $allowed_children = array(
'BlogEntry'
);
function getCMSFields() {
$fields = parent::getCMSFields();
- $fields->removeFieldFromTab("Root.Content.Main","Content");
- $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("SideBar"));
$fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
-
- $fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
- "" => "All entries",
- "1 MONTH" => "Last month's entries",
- "2 MONTH" => "Last 2 months' entries",
- "3 MONTH" => "Last 3 months' entries",
- "4 MONTH" => "Last 4 months' entries",
- "5 MONTH" => "Last 5 months' entries",
- "6 MONTH" => "Last 6 months' entries",
- "7 MONTH" => "Last 7 months' entries",
- "8 MONTH" => "Last 8 months' entries",
- "9 MONTH" => "Last 9 months' entries",
- "10 MONTH" => "Last 10 months' entries",
- "11 MONTH" => "Last 11 months' entries",
- "12 MONTH" => "Last year's entries"
- )));
-
+
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', DataObject::get('Member')->toDropDownMap('ID', 'Name', 'None')));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
@@ -65,41 +40,14 @@ class BlogHolder extends Page {
return $fields;
}
- /**
- * Get entries in this blog.
- * @param string limit A clause to insert into the limit clause.
- * @param string tag Only get blog entries with this tag
- * @param string date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02'
- * @return DataObjectSet
- */
- public function Entries($limit = '', $tag = '', $date = '') {
- $tagCheck = '';
- $dateCheck = '';
-
- if($tag) {
- $SQL_tag = Convert::raw2sql($tag);
- $tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
- }
-
- if($date) {
- if(strpos($date, '-')) {
- $year = (int) substr($date, 0, strpos($date, '-'));
- $month = (int) substr($date, strpos($date, '-') + 1);
-
- if($year && $month) {
- $dateCheck = "AND MONTH(`BlogEntry`.Date) = $month AND YEAR(`BlogEntry`.Date) = $year";
- }
- } else {
- $year = (int) $date;
- if($year) {
- $dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
- }
- }
- }
-
- return DataObject::get("Page","`ParentID` = $this->ID $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$limit");
+ public function BlogHolderIDs() {
+ return array( $this->ID );
}
-
+
+ /*
+ * @todo: These next few functions don't really belong in the model. Can we remove them?
+ */
+
/**
* Only display the blog entries that have the specified tag
*/
@@ -180,88 +128,12 @@ class BlogHolder extends Page {
}
}
-class BlogHolder_Controller extends Page_Controller {
+class BlogHolder_Controller extends BlogTree_Controller {
function init() {
parent::init();
-
- // This will create a tag point to the RSS feed
- RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of this blog"));
- Requirements::themedCSS("blog");
Requirements::themedCSS("bbcodehelp");
-
}
-
- function BlogEntries($limit = 10) {
- $start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
- $tag = '';
- $date = '';
- if(Director::urlParams()) {
- if(Director::urlParam('Action') == 'tag') {
- $tag = Director::urlParam('ID');
- } else {
- $year = Director::urlParam('Action');
- $month = Director::urlParam('ID');
-
- if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
- $date = "$year-$month";
- } else if(is_numeric($year)) {
- $date = $year;
- }
- }
- }
-
- return $this->Entries("$start,$limit", $tag, $date);
- }
-
- /**
- * Gets the archived blogs for a particular month or year, in the format /year/month/ eg: /2008/10/
- */
- function showarchive() {
- $month = addslashes($this->urlParams['ID']);
- return array(
- "Children" => DataObject::get('SiteTree', "ParentID = $this->ID AND DATE_FORMAT(`BlogEntry`.`Date`, '%Y-%M') = '$month'"),
- );
- }
-
- function ArchiveMonths() {
- $months = DB::query("SELECT DISTINCT DATE_FORMAT(`BlogEntry`.`Date`, '%M') AS `Month`, DATE_FORMAT(`BlogEntry`.`Date`, '%Y') AS `Year` FROM `BlogEntry` ORDER BY `BlogEntry`.`Date` DESC");
- $output = new DataObjectSet();
- foreach($months as $month) {
- $month['Link'] = $this->Link() . "showarchive/$month[Year]-$month[Month]";
- $output->push(new ArrayData($month));
- }
-
- return $output;
- }
-
- function tag() {
- if($this->ShowTag()) {
- return array(
- 'Tag' => $this->ShowTag()
- );
- } else {
- return array();
- }
- }
-
- /**
- * Get the rss feed for this blog holder's entries
- */
- function rss() {
- global $project;
-
- $blogName = $this->Name;
- $altBlogName = $project . ' blog';
-
- $entries = $this->Entries(20);
-
- if($entries) {
- $rss = new RSSFeed($entries, $this->Link() . 'rss', ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent");
- $rss->outputToBrowser();
- }
- }
-
/**
* Return list of usable tags for help
*/
@@ -284,16 +156,7 @@ class BlogHolder_Controller extends Page_Controller {
return $page->renderWith('Page');
}
-
- function defaultAction($action) {
- // Protection against infinite loops when an RSS widget pointing to this page is added to this page
- if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) {
- return $this->rss();
- }
- return parent::defaultAction($action);
- }
-
/**
* A simple form for creating blog entries
*/
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index eca72ec..67503e6 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -46,28 +46,15 @@ class BlogManagementWidget extends Widget {
}
function WidgetHolder() {
- if($this->getBlogHolder()->canEdit()) {
- return $this->renderWith('WidgetHolder');
- }
+ $container = BlogTree::current();
+
+ if ($container && $container instanceof BlogHolder && $container->canEdit()) return $this->renderWith('WidgetHolder');
return '';
}
function PostLink() {
- $blogholder = $this->getBlogHolder();
-
- return $blogholder->Link('post');
- }
-
- function getBlogHolder() {
- $page = Director::currentPage();
-
- if($page->is_a("BlogHolder")) {
- return $page;
- } else if($page->is_a("BlogEntry") && $page->getParent()->is_a("BlogHolder")) {
- return $page->getParent();
- } else {
- return DataObject::get_one("BlogHolder");
- }
+ $container = BlogTree::current();
+ if ($container) return $container->Link('post');
}
}
diff --git a/code/BlogTree.php b/code/BlogTree.php
new file mode 100644
index 0000000..a5f0dfe
--- /dev/null
+++ b/code/BlogTree.php
@@ -0,0 +1,268 @@
+ 'Boolean',
+ 'LandingPageFreshness' => 'Varchar',
+ );
+
+ static $defaults = array(
+ 'InheritSideBar' => True
+ );
+
+ static $has_one = array(
+ "SideBar" => "WidgetArea",
+ );
+
+ static $allowed_children = array(
+ 'BlogTree', 'BlogHolder'
+ );
+
+ /*
+ * Finds the BlogTree object most related to the current page.
+ * - If this page is a BlogTree, use that
+ * - If this page is a BlogEntry, use the parent Holder
+ * - Otherwise, try and find a 'top-level' BlogTree
+ */
+ static function current() {
+ $page = Director::currentPage();
+
+ // If we _are_ a BlogTree, use us
+ if ($page instanceof BlogTree) return $page;
+
+ // Or, if we a a BlogEntry underneath a BlogTree, use our parent
+ if ($page->is_a("BlogEntry")) {
+ $parent = $page->getParent();
+ if ($parent instanceof BlogTree) return $parent;
+ }
+
+ // Try to find a top-level BlogTree
+ $top = DataObject::get_one('BlogTree','ParentId = 0');
+ if ($top) return $top;
+
+ // Try to find any BlogTree that is not inside another BlogTree
+ foreach(DataObject::get('BlogTree') as $tree) {
+ if (!($tree->getParent() instanceof BlogTree)) return $tree;
+ }
+
+ // This shouldn't be possible, but assuming the above fails, just return anything you can get
+ return DataObject::get_one('BlogTree');
+ }
+
+ /* ----------- ACCESSOR OVERRIDES -------------- */
+
+ public function getLandingPageFreshness() {
+ $freshness = $this->getField('LandingPageFreshness');
+ // If we want to inherit freshness, try that first
+ if ($freshness = "INHERIT" && $this->getParent()) $freshness = $this->getParent()->LandingPageFreshness;
+ // If we don't have a parent, or the inherited result was still inherit, use default
+ if ($freshness = "INHERIT") $freshness = '';
+
+ return $freshness;
+ }
+
+ function SideBar() {
+ if ($this->InheritSideBar && $this->getParent()) return $this->getParent()->SideBar() ;
+ return $this->getComponent('SideBar');
+ }
+
+ /* ----------- CMS CONTROL -------------- */
+
+ function getCMSFields() {
+ $fields = parent::getCMSFields();
+ $fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
+ "" => "All entries",
+ "1 MONTH" => "Last month's entries",
+ "2 MONTH" => "Last 2 months' entries",
+ "3 MONTH" => "Last 3 months' entries",
+ "4 MONTH" => "Last 4 months' entries",
+ "5 MONTH" => "Last 5 months' entries",
+ "6 MONTH" => "Last 6 months' entries",
+ "7 MONTH" => "Last 7 months' entries",
+ "8 MONTH" => "Last 8 months' entries",
+ "9 MONTH" => "Last 9 months' entries",
+ "10 MONTH" => "Last 10 months' entries",
+ "11 MONTH" => "Last 11 months' entries",
+ "12 MONTH" => "Last year's entries",
+ "INHERIT" => "Take value from parent Blog Tree"
+ )));
+
+ $fields->addFieldToTab("Root.Content.Widgets", new CheckboxField("InheritSideBar", 'Inherit Sidebar From Parent'));
+ $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("SideBar"));
+
+ return $fields;
+ }
+
+ /* ----------- New accessors -------------- */
+
+ public function loadDescendantBlogHolderIDListInto(&$idList) {
+ if ($children = $this->AllChildren()) {
+ foreach($children as $child) {
+ if (in_array($child->ID, $idList)) continue;
+
+ if ($child instanceof BlogHolder) $idList[] = $child->ID;
+ else $child->loadDescendantBlogHolderIDListInto($idList);
+ }
+ }
+ }
+
+ // Build a list of all IDs for BlogHolders that are children of us
+ public function BlogHolderIDs() {
+ $holderIDs = array();
+ $this->loadDescendantBlogHolderIDListInto($holderIDs);
+ return $holderIDs;
+ }
+
+ /**
+ * Get entries in this blog.
+ * @param string limit A clause to insert into the limit clause.
+ * @param string tag Only get blog entries with this tag
+ * @param string date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02'
+ * @param callback retrieveCallback A function to call with pagetype, filter and limit for custom blog sorting or filtering
+ * @return DataObjectSet
+ */
+ public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null) {
+ $tagCheck = '';
+ $dateCheck = '';
+
+ if ($tag) {
+ $SQL_tag = Convert::raw2sql($tag);
+ $tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
+ }
+
+ if ($date) {
+ if(strpos($date, '-')) {
+ $year = (int) substr($date, 0, strpos($date, '-'));
+ $month = (int) substr($date, strpos($date, '-') + 1);
+
+ if($year && $month) {
+ $dateCheck = "AND MONTH(`BlogEntry`.Date) = $month AND YEAR(`BlogEntry`.Date) = $year";
+ }
+ } else {
+ $year = (int) $date;
+ if($year) {
+ $dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
+ }
+ }
+ }
+ elseif ($this->LandingPageFreshness) {
+ $dateCheck = "AND `BlogEntry`.Date > NOW() - INTERVAL " . $this->LandingPageFreshness;
+ }
+
+ // Build a list of all IDs for BlogHolders that are children of us
+ $holderIDs = $this->BlogHolderIDs();
+
+ // If no BlogHolders, no BlogEntries. So return false
+ if (empty($holderIDs)) return false;
+
+ // Otherwise, do the actual query
+ $where = 'ParentID IN ('.implode(',', $holderIDs).") $tagCheck $dateCheck";
+
+ // By specifying a callback, you can alter the SQL, or sort on something other than date.
+ if ($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit);
+ else return DataObject::get('BlogEntry', $where, '`BlogEntry`.`Date` DESC', '', $limit);
+ }
+}
+
+class BlogURL {
+ static function tag() {
+ if (Director::urlParam('Action') == 'tag') return Director::urlParam('ID');
+ return '';
+ }
+
+ static function date() {
+ $year = Director::urlParam('Action');
+ $month = Director::urlParam('ID');
+
+ if ($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
+ return "$year-$month";
+ }
+ elseif (is_numeric($year)) {
+ return $year;
+ }
+
+ return '';
+ }
+}
+
+class BlogTree_Controller extends Page_Controller {
+ function init() {
+ parent::init();
+
+ // This will create a tag point to the RSS feed
+ RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
+ Requirements::themedCSS("blog");
+ }
+
+ function BlogEntries($limit = 10) {
+ $start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
+ return $this->Entries("$start,$limit", BlogURL::tag(), BlogURL::date());
+ }
+
+ /*
+ * @todo: It doesn't look like these are used. Remove if no-one complains - Hamish
+
+ /**
+ * Gets the archived blogs for a particular month or year, in the format /year/month/ eg: /2008/10/
+ * /
+ function showarchive() {
+ $month = addslashes($this->urlParams['ID']);
+ return array(
+ "Children" => DataObject::get('SiteTree', "ParentID = $this->ID AND DATE_FORMAT(`BlogEntry`.`Date`, '%Y-%M') = '$month'"),
+ );
+ }
+
+ function ArchiveMonths() {
+ $months = DB::query("SELECT DISTINCT DATE_FORMAT(`BlogEntry`.`Date`, '%M') AS `Month`, DATE_FORMAT(`BlogEntry`.`Date`, '%Y') AS `Year` FROM `BlogEntry` ORDER BY `BlogEntry`.`Date` DESC");
+ $output = new DataObjectSet();
+ foreach($months as $month) {
+ $month['Link'] = $this->Link() . "showarchive/$month[Year]-$month[Month]";
+ $output->push(new ArrayData($month));
+ }
+
+ return $output;
+ }
+
+ function tag() {
+ if (Director::urlParam('Action') == 'tag') {
+ return array(
+ 'Tag' => Convert::raw2xml(Director::urlParam('ID'))
+ );
+ }
+ return array();
+ }
+ */
+
+ /**
+ * Get the rss feed for this blog holder's entries
+ */
+ function rss() {
+ global $project;
+
+ $blogName = $this->Name;
+ $altBlogName = $project . ' blog';
+
+ $entries = $this->Entries(20);
+
+ if($entries) {
+ $rss = new RSSFeed($entries, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent");
+ $rss->outputToBrowser();
+ }
+ }
+
+ function defaultAction($action) {
+ // Protection against infinite loops when an RSS widget pointing to this page is added to this page
+ if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) return $this->rss();
+
+ return parent::defaultAction($action);
+ }
+}
diff --git a/code/SubscribeRSSWidget.php b/code/SubscribeRSSWidget.php
index e3f8c07..f2725e2 100644
--- a/code/SubscribeRSSWidget.php
+++ b/code/SubscribeRSSWidget.php
@@ -15,24 +15,6 @@ class SubscribeRSSWidget extends Widget {
static $description = 'Shows a link allowing a user to subscribe to this blog via RSS.';
- /**
- * Get the BlogHolder instance that this widget
- * is located on.
- *
- * @return BlogHolder
- */
- function getBlogHolder() {
- $page = Director::currentPage();
-
- if($page instanceof BlogHolder) {
- return $page;
- } elseif(($page instanceof BlogEntry) && ($page->getParent() instanceof BlogHolder)) {
- return $page->getParent();
- } else {
- return DataObject::get_one('BlogHolder');
- }
- }
-
/**
* Return an absolute URL based on the BlogHolder
* that this widget is located on.
@@ -41,10 +23,8 @@ class SubscribeRSSWidget extends Widget {
*/
function RSSLink() {
Requirements::themedCSS('subscribersswidget');
- $blogHolder = $this->getBlogHolder();
- if($blogHolder) {
- return $blogHolder->Link() . 'rss';
- }
+ $container = BlogTree::current();
+ if ($container) return $container->Link() . 'rss';
}
}
diff --git a/code/TagCloudWidget.php b/code/TagCloudWidget.php
index 6500c3b..e6925bb 100644
--- a/code/TagCloudWidget.php
+++ b/code/TagCloudWidget.php
@@ -24,19 +24,6 @@ class TagCloudWidget extends Widget {
static $cmsTitle = "Tag Cloud";
static $description = "Shows a tag cloud of tags on your blog.";
- function getBlogHolder() {
- $page = Director::currentPage();
-
- if($page->is_a("BlogHolder")) {
- return $page;
- } else if($page->is_a("BlogEntry") && $page->getParent()->is_a("BlogHolder")) {
- return $page->getParent();
- } else {
- return DataObject::get_one("BlogHolder");
- }
- }
-
-
function getCMSFields() {
return new FieldSet(
new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
@@ -54,9 +41,9 @@ class TagCloudWidget extends Widget {
$allTags = array();
$max = 0;
- $blogHolder = $this->getBlogHolder();
+ $container = BlogTree::current();
- $entries = $blogHolder->Entries();
+ $entries = $container->Entries();
if($entries) {
foreach($entries as $entry) {
@@ -117,7 +104,7 @@ class TagCloudWidget extends Widget {
"Tag" => $tag,
"Count" => $count,
"Class" => $class,
- "Link" => $blogHolder->Link() . 'tag/' . urlencode($tag)
+ "Link" => $container->Link() . 'tag/' . urlencode($tag)
);
}
}
diff --git a/tests/BlogTreeTest.php b/tests/BlogTreeTest.php
new file mode 100644
index 0000000..bb6349e
--- /dev/null
+++ b/tests/BlogTreeTest.php
@@ -0,0 +1,30 @@
+fixture->objFromFixture('BlogTree', 'root');
+ $this->assertEquals($node->Entries()->Count(), 3);
+
+ $node = $this->fixture->objFromFixture('BlogTree', 'levela');
+ $this->assertEquals($node->Entries()->Count(), 2);
+
+ $node = $this->fixture->objFromFixture('BlogTree', 'levelaa');
+ $this->assertEquals($node->Entries()->Count(), 2);
+
+ $node = $this->fixture->objFromFixture('BlogTree', 'levelab');
+ $this->assertNull($node->Entries());
+
+ $node = $this->fixture->objFromFixture('BlogTree', 'levelb');
+ $this->assertEquals($node->Entries()->Count(), 1);
+
+ $node = $this->fixture->objFromFixture('BlogTree', 'levelba');
+ $this->assertEquals($node->Entries()->Count(), 1);
+ }
+
+
+
+}
+
+?>
diff --git a/tests/BlogTreeTest.yml b/tests/BlogTreeTest.yml
new file mode 100644
index 0000000..3112d40
--- /dev/null
+++ b/tests/BlogTreeTest.yml
@@ -0,0 +1,53 @@
+BlogTree:
+ root:
+ Title: Root BlogTree
+ levela:
+ Title: Level A
+ Parent: =>BlogTree.root
+ levelb:
+ Title: Level B
+ Parent: =>BlogTree.root
+ levelaa:
+ Title: Level AA
+ Parent: =>BlogTree.levela
+ levelab:
+ Title: Level AB
+ Parent: =>BlogTree.levela
+ levelba:
+ Title: Level BA
+ Parent: =>BlogTree.levelb
+BlogHolder:
+ levelaa_blog1:
+ Title: Level AA Blog 1
+ Parent: =>BlogTree.levelaa
+ levelaa_blog2:
+ Title: Level AA Blog 2
+ Parent: =>BlogTree.levelaa
+ levelab_blog:
+ Title: Level AB Blog
+ Parent: =>BlogTree.levelab
+ levelba_blog:
+ Title: Level BA Blog
+ Parent: =>BlogTree.levelba
+BlogEntry:
+ testpost:
+ Title: Test Post
+ URLSegment: test-post
+ Date: 2007-02-17 18:45:00
+ Parent: =>BlogHolder.levelaa_blog1
+ Tags: tag1,tag2
+ testpost2:
+ Title: Test Post 2
+ URLSegment: test-post-2
+ Date: 2008-01-31 20:48:00
+ Parent: =>BlogHolder.levelaa_blog2
+ Tags: tag2,tag3
+ testpost3:
+ Title: Test Post 3
+ URLSegment: test-post-3
+ Date: 2008-01-17 18:45:00
+ Parent: =>BlogHolder.levelba_blog
+ Tags: tag1,tag2,tag3
+
+
+
From 37a60707143903e109346fc5cd5d769d44a32f35 Mon Sep 17 00:00:00 2001
From: Hamish Friedlander
Date: Wed, 6 May 2009 05:00:54 +0000
Subject: [PATCH 129/250] BUGFIX: Check owner with less complex logic
---
code/BlogHolder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index e766729..ce31665 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -77,7 +77,7 @@ class BlogHolder extends BlogTree {
* @return Boolean
*/
function IsOwner() {
- return Permission::check('ADMIN') || (Member::CurrentMember() && Member::CurrentMember()->ID == $this->OwnerID);
+ return Permission::check('ADMIN') || (Member::currentUserID() == $this->OwnerID);
}
/**
From 2d1eb07478ade34f2e04131a8cb93ac876f15a17 Mon Sep 17 00:00:00 2001
From: Hamish Friedlander
Date: Wed, 6 May 2009 05:01:28 +0000
Subject: [PATCH 130/250] BUGFIX: Use parent->canAddChildren, not
parent->canEdit to determine if this user can add children to parent blog
holder
---
code/BlogManagementWidget.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index 67503e6..206897b 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -48,7 +48,7 @@ class BlogManagementWidget extends Widget {
function WidgetHolder() {
$container = BlogTree::current();
- if ($container && $container instanceof BlogHolder && $container->canEdit()) return $this->renderWith('WidgetHolder');
+ if ($container && $container instanceof BlogHolder && $container->canAddChildren()) return $this->renderWith('WidgetHolder');
return '';
}
From 58775ea256361d08c7748ddb96c091c4f66a867f Mon Sep 17 00:00:00 2001
From: Hamish Friedlander
Date: Wed, 6 May 2009 05:02:01 +0000
Subject: [PATCH 131/250] ENHANCEMENT: Allow specifying the class buckets to
assign tags into based on popularity
---
code/TagCloudWidget.php | 50 ++++++++++++++++-------------------------
1 file changed, 19 insertions(+), 31 deletions(-)
diff --git a/code/TagCloudWidget.php b/code/TagCloudWidget.php
index e6925bb..8d6e8be 100644
--- a/code/TagCloudWidget.php
+++ b/code/TagCloudWidget.php
@@ -23,6 +23,8 @@ class TagCloudWidget extends Widget {
static $cmsTitle = "Tag Cloud";
static $description = "Shows a tag cloud of tags on your blog.";
+
+ static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
function getCMSFields() {
return new FieldSet(
@@ -67,38 +69,24 @@ class TagCloudWidget extends Widget {
}
$sizes = array();
- foreach($allTags as $tag => $count){
- $sizes[$count] = true;
- }
- $numsizes = count($sizes)-1; //Work out the number of different sizes
- if($numsizes > 5){$numsizes = 5;}
- foreach($allTags as $tag => $count) {
+ foreach ($allTags as $tag => $count) $sizes[$count] = true;
- $popularity = floor($count / $max * $numsizes);
-
- switch($popularity) {
- case 0:
- $class = "not-popular";
- break;
- case 1:
- $class = "not-very-popular";
- break;
- case 2:
- $class = "somewhat-popular";
- break;
- case 3:
- $class = "popular";
- break;
- case 4:
- $class = "very-popular";
- break;
- case 5:
- $class = "ultra-popular";
- break;
- default:
- $class = "broken";
- break;
- }
+ $offset = 0;
+ $numsizes = count($sizes)-1; //Work out the number of different sizes
+ $buckets = count(self::$popularities)-1;
+
+ // If there are more frequencies then buckets, divide frequencies into buckets
+ if ($numsizes > $buckets) {
+ $numsizes = $buckets;
+ }
+ // Otherwise center use central buckets
+ else {
+ $offset = round(($buckets-$numsizes)/2);
+ }
+
+ foreach($allTags as $tag => $count) {
+ $popularity = round($count / $max * $numsizes) + $offset; $popularity=min($buckets,$popularity);
+ $class = self::$popularities[$popularity];
$allTags[$tag] = array(
"Tag" => $tag,
From 23591eec35afd4bd74a030bbcaba03ac813e1a6a Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Mon, 11 May 2009 02:48:24 +0000
Subject: [PATCH 132/250] BUGFIX Fixed BlogTree, ArchiveWidget SQL queries to
work with ANSI and non-ANSI compatible queries
---
code/ArchiveWidget.php | 43 ++++++++++++++++++++++++++------------
code/BlogTree.php | 47 +++++++++++++++++++++++++++++++++++-------
2 files changed, 69 insertions(+), 21 deletions(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 7cec3ae..7cf20df 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -51,21 +51,38 @@ class ArchiveWidget extends Widget {
$stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
-
if($this->DisplayMode == 'month') {
- $sqlResults = DB::query("
- SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year`
- FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
- WHERE `ParentID` in (".implode(', ',$ids).")
- ORDER BY `Date` DESC"
- );
+ if(defined('Database::USE_ANSI_SQL')) {
+ $sqlResults = DB::query("
+ SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\", \"Date\"
+ FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
+ WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
+ ORDER BY \"Date\" DESC"
+ );
+ } else {
+ $sqlResults = DB::query("
+ SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year`
+ FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
+ WHERE `ParentID` IN (" . implode(', ', $ids) . ")
+ ORDER BY `Date` DESC"
+ );
+ }
} else {
- $sqlResults = DB::query("
- SELECT DISTINCT YEAR(`Date`) AS `Year`
- FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
- WHERE `ParentID` in (".implode(', ',$ids).")
- ORDER BY `Date` DESC"
- );
+ if(defined('Database::USE_ANSI_SQL')) {
+ $sqlResults = DB::query("
+ SELECT DISTINCT YEAR(\"Date\") AS \"Year\", \"Date\"
+ FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
+ WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
+ ORDER BY \"Date\" DESC"
+ );
+ } else {
+ $sqlResults = DB::query("
+ SELECT DISTINCT YEAR(`Date`) AS `Year`
+ FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
+ WHERE `ParentID` in (".implode(', ',$ids).")
+ ORDER BY `Date` DESC"
+ );
+ }
}
if(!$sqlResults) return new DataObjectSet();
diff --git a/code/BlogTree.php b/code/BlogTree.php
index a5f0dfe..0137385 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -46,7 +46,12 @@ class BlogTree extends Page {
}
// Try to find a top-level BlogTree
- $top = DataObject::get_one('BlogTree','ParentId = 0');
+ if(defined('Database::USE_ANSI_SQL')) {
+ $top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'");
+ } else {
+ $top = DataObject::get_one('BlogTree', 'ParentID = 0');
+ }
+
if ($top) return $top;
// Try to find any BlogTree that is not inside another BlogTree
@@ -136,7 +141,11 @@ class BlogTree extends Page {
if ($tag) {
$SQL_tag = Convert::raw2sql($tag);
- $tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
+ if(defined('Database::USE_ANSI_SQL')) {
+ $tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
+ } else {
+ $tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
+ }
}
if ($date) {
@@ -145,17 +154,29 @@ class BlogTree extends Page {
$month = (int) substr($date, strpos($date, '-') + 1);
if($year && $month) {
- $dateCheck = "AND MONTH(`BlogEntry`.Date) = $month AND YEAR(`BlogEntry`.Date) = $year";
+ if(defined('Database::USE_ANSI_SQL')) {
+ $dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
+ } else {
+ $dateCheck = "AND MONTH(`BlogEntry`.Date) = $month AND YEAR(`BlogEntry`.Date) = $year";
+ }
}
} else {
$year = (int) $date;
if($year) {
- $dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
+ if(defined('Database::USE_ANSI_SQL')) {
+ $dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
+ } else {
+ $dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
+ }
}
}
}
- elseif ($this->LandingPageFreshness) {
- $dateCheck = "AND `BlogEntry`.Date > NOW() - INTERVAL " . $this->LandingPageFreshness;
+ elseif ($this->LandingPageFreshness) {
+ if(defined('Database::USE_ANSI_SQL')) {
+ $dateCheck = "AND \"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
+ } else {
+ $dateCheck = "AND `BlogEntry`.Date > NOW() - INTERVAL " . $this->LandingPageFreshness;
+ }
}
// Build a list of all IDs for BlogHolders that are children of us
@@ -165,11 +186,21 @@ class BlogTree extends Page {
if (empty($holderIDs)) return false;
// Otherwise, do the actual query
- $where = 'ParentID IN ('.implode(',', $holderIDs).") $tagCheck $dateCheck";
+ if(defined('Database::USE_ANSI_SQL')) {
+ $where = '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
+ } else {
+ $where = 'ParentID IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
+ }
+
+ if(defined('Database::USE_ANSI_SQL')) {
+ $order = '"BlogEntry"."Date" DESC';
+ } else {
+ $order = '`BlogEntry`.`Date` DESC';
+ }
// By specifying a callback, you can alter the SQL, or sort on something other than date.
if ($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit);
- else return DataObject::get('BlogEntry', $where, '`BlogEntry`.`Date` DESC', '', $limit);
+ else return DataObject::get('BlogEntry', $where, $order, '', $limit);
}
}
From 05cf841808441fd17a47a40b5bb6392be26d86b5 Mon Sep 17 00:00:00 2001
From: Hamish Friedlander
Date: Fri, 15 May 2009 03:46:49 +0000
Subject: [PATCH 133/250] BUGFIX: Segfault on BlogTree#Sidebar calling
getComponent. Fix by directly getting sidebar for now.
---
code/BlogTree.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 0137385..d829397 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -77,7 +77,8 @@ class BlogTree extends Page {
function SideBar() {
if ($this->InheritSideBar && $this->getParent()) return $this->getParent()->SideBar() ;
- return $this->getComponent('SideBar');
+ return DataObject::get_by_id('WidgetArea', $this->SideBarID);
+ // @todo: This segfaults - investigate why then fix: return $this->getComponent('SideBar');
}
/* ----------- CMS CONTROL -------------- */
From 61a2cc2332106c5d382850232910dd005132aaf1 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Wed, 20 May 2009 02:18:48 +0000
Subject: [PATCH 134/250] MINOR: move Name field from BlogHolder to BlogTree
---
code/BlogHolder.php | 2 --
code/BlogTree.php | 2 ++
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index ce31665..62a1749 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -16,7 +16,6 @@ class BlogHolder extends BlogTree {
static $icon = "blog/images/blogholder";
static $db = array(
- 'Name' => 'Varchar',
'TrackBacksEnabled' => 'Boolean',
'AllowCustomAuthors' => 'Boolean',
);
@@ -31,7 +30,6 @@ class BlogHolder extends BlogTree {
function getCMSFields() {
$fields = parent::getCMSFields();
- $fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', DataObject::get('Member')->toDropDownMap('ID', 'Name', 'None')));
diff --git a/code/BlogTree.php b/code/BlogTree.php
index d829397..6f146fb 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -11,6 +11,7 @@
class BlogTree extends Page {
static $db = array(
+ 'Name' => 'Varchar',
'InheritSideBar' => 'Boolean',
'LandingPageFreshness' => 'Varchar',
);
@@ -85,6 +86,7 @@ class BlogTree extends Page {
function getCMSFields() {
$fields = parent::getCMSFields();
+ $fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
"" => "All entries",
"1 MONTH" => "Last month's entries",
From 488319ceb54b6ae57ebb835474aefc87475f7d7b Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Wed, 20 May 2009 02:34:57 +0000
Subject: [PATCH 135/250] MINOR: change blog alternative name to use global
project_name variable
---
code/BlogTree.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 6f146fb..2293ccf 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -280,10 +280,10 @@ class BlogTree_Controller extends Page_Controller {
* Get the rss feed for this blog holder's entries
*/
function rss() {
- global $project;
+ global $project_name;
$blogName = $this->Name;
- $altBlogName = $project . ' blog';
+ $altBlogName = $project_name . ' blog';
$entries = $this->Entries(20);
From dfb9e17c2c074372d229c6282a2664ccf91e1eac Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Wed, 20 May 2009 05:00:32 +0000
Subject: [PATCH 136/250] BUGFIX Fixed call to deprecated function
Form::loadNonBlankDataFrom() on BlogHolder, replacing it with
Form::loadDataFrom()
---
code/BlogHolder.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 62a1749..216059c 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -212,11 +212,11 @@ class BlogHolder_Controller extends BlogTree_Controller {
if($id != 0) {
$entry = DataObject::get_by_id('BlogEntry', $id);
if($entry->IsOwner()) {
- $form->loadNonBlankDataFrom($entry);
+ $form->loadDataFrom($entry);
$form->datafieldByName('BlogPost')->setValue($entry->Content);
}
} else {
- $form->loadNonBlankDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
+ $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
}
return $form;
From 43118ecb033645327106532b2608fb489f9e8ad3 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Wed, 20 May 2009 05:37:30 +0000
Subject: [PATCH 137/250] MINOR Renamed deprecated extraDBFields() function on
TrackBackDecorator to extraStatics()
---
code/TrackBackDecorator.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index 436a48b..abe6bca 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -1,7 +1,7 @@
array(
'TrackBacks' => 'TrackBackPing'
From 1b7de7e092ea8d8c7aac511556e1180e060723c4 Mon Sep 17 00:00:00 2001
From: Julian Seidenberg
Date: Thu, 21 May 2009 04:07:53 +0000
Subject: [PATCH 138/250] ENHANCEMENT: allow administators to make it possible
for non-admin users to view blog management widget
---
code/BlogManagementWidget.php | 51 ++++++++++++++++++++++-------------
1 file changed, 33 insertions(+), 18 deletions(-)
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index 206897b..dedc59c 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -3,24 +3,24 @@
* Blog Management Widget
* @package blog
*/
-class BlogManagementWidget extends Widget {
-
+class BlogManagementWidget extends Widget implements PermissionProvider {
+
static $db = array();
-
+
static $has_one = array();
-
+
static $has_many = array();
-
+
static $many_many = array();
-
+
static $belongs_many_many = array();
-
+
static $defaults = array();
-
+
static $title = "Blog Management";
static $cmsTitle = "Blog Management";
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
-
+
function CommentText() {
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
if($unmoderatedcount == 1) {
@@ -31,31 +31,46 @@ class BlogManagementWidget extends Widget {
return _t("BlogManagementWidget.COMADM", "Comment administration");
}
}
-
+
function CommentLink() {
if(!Permission::check('ADMIN')) {
return false;
}
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
-
+
if($unmoderatedcount > 0) {
return "admin/comments/unmoderated";
} else {
return "admin/comments";
}
}
-
- function WidgetHolder() {
- $container = BlogTree::current();
-
- if ($container && $container instanceof BlogHolder && $container->canAddChildren()) return $this->renderWith('WidgetHolder');
- return '';
+
+ function providePermissions() {
+ return array("BLOGMANAGEMENTWIDGET_VIEW" => "View blog management widget");
}
-
+
+ function WidgetHolder() {
+ if(Permission::check("BLOGMANAGEMENTWIDGET_VIEW")) {
+ return $this->renderWith("WidgetHolder");
+ }
+ }
+
function PostLink() {
$container = BlogTree::current();
if ($container) return $container->Link('post');
}
+
+ function getBlogHolder() {
+ $page = Director::currentPage();
+
+ if($page->is_a("BlogHolder")) {
+ return $page;
+ } else if($page->is_a("BlogEntry") && $page->getParent()->is_a("BlogHolder")) {
+ return $page->getParent();
+ } else {
+ return DataObject::get_one("BlogHolder");
+ }
+ }
}
?>
From b088e1ff8ce5a5c23eeb11603afe1683b6f30ffb Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Thu, 21 May 2009 04:16:18 +0000
Subject: [PATCH 139/250] MINOR Removed unused getBlogHolder() method from
BlogManagementWidget.php
---
code/BlogManagementWidget.php | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index dedc59c..2874682 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -60,17 +60,5 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
if ($container) return $container->Link('post');
}
- function getBlogHolder() {
- $page = Director::currentPage();
-
- if($page->is_a("BlogHolder")) {
- return $page;
- } else if($page->is_a("BlogEntry") && $page->getParent()->is_a("BlogHolder")) {
- return $page->getParent();
- } else {
- return DataObject::get_one("BlogHolder");
- }
- }
}
-
-?>
+?>
\ No newline at end of file
From 5755d3e67964a728c7955a2e2a8a2d9aaa8ebb54 Mon Sep 17 00:00:00 2001
From: James Kirkus-Lamont
Date: Mon, 25 May 2009 22:30:10 +0000
Subject: [PATCH 140/250] BUGFIX: check if the parent of the blog holder has a
method called 'SideBar' before calling it
---
code/BlogTree.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 2293ccf..fc327c1 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -77,7 +77,9 @@ class BlogTree extends Page {
}
function SideBar() {
- if ($this->InheritSideBar && $this->getParent()) return $this->getParent()->SideBar() ;
+ if ($this->InheritSideBar && $this->getParent()) {
+ if (method_exists($this->getParent(), 'SideBar')) return $this->getParent()->SideBar();
+ }
return DataObject::get_by_id('WidgetArea', $this->SideBarID);
// @todo: This segfaults - investigate why then fix: return $this->getComponent('SideBar');
}
From 038cad9b636c0ad96a0b1152ef5acac87dbf53e8 Mon Sep 17 00:00:00 2001
From: Julian Seidenberg
Date: Wed, 27 May 2009 01:26:34 +0000
Subject: [PATCH 141/250] BUGFIX: fixed permissions to allow non-admin user to
post and manage blog entries
---
code/BlogHolder.php | 99 ++++++++++++++++++-----------------
code/BlogManagementWidget.php | 6 +--
2 files changed, 55 insertions(+), 50 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 216059c..d6f9786 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -5,47 +5,47 @@
*/
/**
- * Blog holder to display summarised blog entries.
- *
+ * Blog holder to display summarised blog entries.
+ *
* A blog holder is the leaf end of a BlogTree, but can also be used standalone in simpler circumstances.
* BlogHolders can only hold BlogEntries, BlogTrees can only hold BlogTrees and BlogHolders
* BlogHolders have a form on them for easy posting, and an owner that can post to them, BlogTrees don't
*/
-class BlogHolder extends BlogTree {
-
+class BlogHolder extends BlogTree implements PermissionProvider {
+
static $icon = "blog/images/blogholder";
-
+
static $db = array(
'TrackBacksEnabled' => 'Boolean',
'AllowCustomAuthors' => 'Boolean',
);
-
+
static $has_one = array(
'Owner' => 'Member',
);
-
+
static $allowed_children = array(
'BlogEntry'
);
-
+
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', DataObject::get('Member')->toDropDownMap('ID', 'Name', 'None')));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
-
+
return $fields;
}
public function BlogHolderIDs() {
return array( $this->ID );
}
-
+
/*
* @todo: These next few functions don't really belong in the model. Can we remove them?
*/
-
+
/**
* Only display the blog entries that have the specified tag
*/
@@ -54,63 +54,64 @@ class BlogHolder extends BlogTree {
return Convert::raw2xml(Director::urlParam('ID'));
}
}
-
+
/**
* Check if url has "/post"
*/
function isPost() {
return Director::urlParam('Action') == 'post';
}
-
+
/**
* Link for creating a new blog entry
*/
function postURL(){
return $this->Link('post');
}
-
+
/**
* Returns true if the current user is an admin, or is the owner of this blog
*
* @return Boolean
*/
function IsOwner() {
- return Permission::check('ADMIN') || (Member::currentUserID() == $this->OwnerID);
+ return (Permission::check('BLOGMANAGEMENT') || Permission::check('ADMIN'));
+ //return Permission::check('ADMIN') || (Member::currentUserID() == $this->OwnerID);
}
-
+
/**
* Create default blog setup
*/
function requireDefaultRecords() {
parent::requireDefaultRecords();
-
+
if(!DataObject::get_one('BlogHolder')) {
$blogholder = new BlogHolder();
$blogholder->Title = "Blog";
$blogholder->URLSegment = "blog";
$blogholder->Status = "Published";
-
+
$widgetarea = new WidgetArea();
$widgetarea->write();
-
+
$blogholder->SideBarID = $widgetarea->ID;
$blogholder->write();
$blogholder->publish("Stage", "Live");
-
+
$managementwidget = new BlogManagementWidget();
$managementwidget->ParentID = $widgetarea->ID;
$managementwidget->write();
-
+
$tagcloudwidget = new TagCloudWidget();
$tagcloudwidget->ParentID = $widgetarea->ID;
$tagcloudwidget->write();
-
+
$archivewidget = new ArchiveWidget();
$archivewidget->ParentID = $widgetarea->ID;
$archivewidget->write();
-
+
$widgetarea->write();
-
+
$blog = new BlogEntry();
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
$blog->URLSegment = 'sample-blog-entry';
@@ -120,7 +121,7 @@ class BlogHolder extends BlogTree {
$blog->ParentID = $blogholder->ID;
$blog->write();
$blog->publish("Stage", "Live");
-
+
Database::alteration_message("Blog page created","created");
}
}
@@ -131,30 +132,34 @@ class BlogHolder_Controller extends BlogTree_Controller {
parent::init();
Requirements::themedCSS("bbcodehelp");
}
-
+
/**
* Return list of usable tags for help
*/
function BBTags() {
return BBCodeParser::usable_tags();
}
-
+
+ function providePermissions() {
+ return array("BLOGMANAGEMENT" => "Blog management");
+ }
+
/**
* Post a new blog entry
*/
function post(){
if(!$this->IsOwner()){
- Security::permissionFailure($this, _t('BlogHolder.HAVENTPERM', 'Posting blogs is an administrator task. Please log in.'));
+ Security::permissionFailure($this, _t('BlogHolder.HAVENTPERM', 'You do not have sufficient permissions to post blog entries. Please log in.'));
}
-
+
$page = $this->customise(array(
'Content' => false,
'Form' => $this->BlogEntryForm()
));
-
+
return $page->renderWith('Page');
}
-
+
/**
* A simple form for creating blog entries
*/
@@ -164,25 +169,25 @@ class BlogHolder_Controller extends BlogTree_Controller {
Requirements::javascript('jsparty/scriptaculous/effects.js');
Requirements::javascript('cms/javascript/PageCommentInterface.js');
Requirements::javascript('blog/javascript/bbcodehelp.js');
-
+
$id = 0;
if(Director::urlParam('ID')) {
$id = (int) Director::urlParam('ID');
}
-
+
$codeparser = new BBCodeParser();
$membername = Member::currentMember() ? Member::currentMember()->getName() : "";
-
+
if(BlogEntry::$allow_wysiwyg_editing) {
$contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
} else {
- $contentfield = new CompositeField(
+ $contentfield = new CompositeField(
new LiteralField("BBCodeHelper",""._t("BlogEntry.BBH")."
" ),
new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already
new LiteralField("BBCodeTags","".$codeparser->useable_tagsHTML()."
")
);
}
-
+
if(class_exists('TagField')) {
$tagfield = new TagField('Tags', null, null, 'BlogEntry');
$tagfield->setSeparator(', ');
@@ -201,14 +206,14 @@ class BlogHolder_Controller extends BlogTree_Controller {
$tagfield,
new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
_t('BlogHolder.SPUC', "Please separate tags using commas.")." ")
- );
-
+ );
+
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
$actions = new FieldSet($submitAction);
$validator = new RequiredFields('Title','Content');
-
+
$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
-
+
if($id != 0) {
$entry = DataObject::get_by_id('BlogEntry', $id);
if($entry->IsOwner()) {
@@ -218,33 +223,33 @@ class BlogHolder_Controller extends BlogTree_Controller {
} else {
$form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
}
-
+
return $form;
}
-
+
function postblog($data, $form) {
Cookie::set("BlogHolder_Name", $data['Author']);
$blogentry = false;
-
+
if($data['ID']) {
$blogentry = DataObject::get_by_id("BlogEntry", $data['ID']);
if(!$blogentry->IsOwner()) {
unset($blogentry);
}
}
-
+
if(!$blogentry) {
$blogentry = new BlogEntry();
}
-
+
$form->saveInto($blogentry);
$blogentry->ParentID = $this->ID;
$blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
-
+
$blogentry->Status = "Published";
$blogentry->writeToStage("Stage");
$blogentry->publish("Stage", "Live");
-
+
Director::redirect($this->Link());
}
}
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index 2874682..9cafcf9 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -33,7 +33,7 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
}
function CommentLink() {
- if(!Permission::check('ADMIN')) {
+ if(!Permission::check('BLOGMANAGEMENT')) {
return false;
}
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
@@ -46,11 +46,11 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
}
function providePermissions() {
- return array("BLOGMANAGEMENTWIDGET_VIEW" => "View blog management widget");
+ return array("BLOGMANAGEMENT" => "Blog management");
}
function WidgetHolder() {
- if(Permission::check("BLOGMANAGEMENTWIDGET_VIEW")) {
+ if(Permission::check("BLOGMANAGEMENT")) {
return $this->renderWith("WidgetHolder");
}
}
From d55d5e21c2942c2ec7f49c8b378860d017bf95c5 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Thu, 28 May 2009 04:38:57 +0000
Subject: [PATCH 142/250] ENHANCEMENT Added language files
---
lang/ar_SA.php | 18 ++++++++++++++++++
lang/de_DE.php | 18 ++++++++++++++++++
lang/en_GB.php | 16 ++++++++++++++++
lang/es_ES.php | 13 +++++++++++++
lang/es_MX.php | 19 +++++++++++++++++++
lang/et_EE.php | 19 +++++++++++++++++++
lang/fr_FR.php | 14 ++++++++++++++
lang/is_IS.php | 6 ++++--
lang/ms_MY.php | 34 ++++++++++++++++++++++++++++++++++
lang/nl_NL.php | 22 ++++++++++++++++++----
lang/pt_PT.php | 1 +
11 files changed, 174 insertions(+), 6 deletions(-)
create mode 100644 lang/ms_MY.php
diff --git a/lang/ar_SA.php b/lang/ar_SA.php
index ad29c13..98a6f0b 100644
--- a/lang/ar_SA.php
+++ b/lang/ar_SA.php
@@ -18,11 +18,15 @@ if(array_key_exists('ar_SA', $lang) && is_array($lang['ar_SA'])) {
$lang['ar_SA']['ArchiveWidget']['DispBY'] = 'استعراض بواسطة';
$lang['ar_SA']['ArchiveWidget']['MONTH'] = 'شهر';
+$lang['ar_SA']['ArchiveWidget']['PLURALNAME'] = 'مربعات الأرشيÙ';
+$lang['ar_SA']['ArchiveWidget']['SINGULARNAME'] = 'مربع الأرشيÙ';
$lang['ar_SA']['ArchiveWidget']['YEAR'] = 'سنة';
$lang['ar_SA']['BlogEntry']['AU'] = 'الكاتب';
$lang['ar_SA']['BlogEntry']['BBH'] = 'مساعدة BBCode';
$lang['ar_SA']['BlogEntry']['CN'] = 'المØتوى';
$lang['ar_SA']['BlogEntry']['DT'] = 'تاريخ';
+$lang['ar_SA']['BlogEntry']['PLURALNAME'] = 'تدوينات المدونة';
+$lang['ar_SA']['BlogEntry']['SINGULARNAME'] = 'تدوينة المدونة';
$lang['ar_SA']['BlogEntry.ss']['COMMENTS'] = 'التعليقات';
$lang['ar_SA']['BlogEntry.ss']['EDITTHIS'] = 'تØرير التدوينة';
$lang['ar_SA']['BlogEntry.ss']['POSTEDBY'] = 'نشرت بواسطة';
@@ -32,8 +36,10 @@ $lang['ar_SA']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'عدم نشر التدوين
$lang['ar_SA']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'عرض جميع التدوينات';
$lang['ar_SA']['BlogEntry']['TS'] = 'وسوم (Ùاصلة,بين,الوسوم)';
$lang['ar_SA']['BlogHolder']['HAVENTPERM'] = 'تدوين المدونات يعتبر مهمة إدارية. Ùضلاً قم بتسجيل الدخول';
+$lang['ar_SA']['BlogHolder']['PLURALNAME'] = 'Øاويات المدونة';
$lang['ar_SA']['BlogHolder']['POST'] = 'Post blog entry';
$lang['ar_SA']['BlogHolder']['RSSFEED'] = 'RSS لهذه المدونة';
+$lang['ar_SA']['BlogHolder']['SINGULARNAME'] = 'Øاوية المدونة';
$lang['ar_SA']['BlogHolder']['SJ'] = 'الموضوع';
$lang['ar_SA']['BlogHolder']['SPUC'] = 'Ùضلاً اÙصل بين الوسوم بÙاصلة';
$lang['ar_SA']['BlogHolder.ss']['NOENTRIES'] = 'لا يوجد مدخلات';
@@ -43,6 +49,8 @@ $lang['ar_SA']['BlogHolder']['SUCTAGS'] = 'ÙŽsilverstripe , blog';
$lang['ar_SA']['BlogHolder']['SUCTITLE'] = 'تم تركيب SilverStripe Blog بنجاØ';
$lang['ar_SA']['BlogHolder']['TE'] = 'مثال:رياضة,شخصية,علمية';
$lang['ar_SA']['BlogManagementWidget']['COMADM'] = 'إدارة التعليقات';
+$lang['ar_SA']['BlogManagementWidget']['PLURALNAME'] = 'مربعات إدارة المدونة';
+$lang['ar_SA']['BlogManagementWidget']['SINGULARNAME'] = 'مربع إدارة المدونة';
$lang['ar_SA']['BlogManagementWidget.ss']['LOGOUT'] = 'خروج';
$lang['ar_SA']['BlogManagementWidget.ss']['POSTNEW'] = 'نشر تدوينة جديدة';
$lang['ar_SA']['BlogManagementWidget']['UNM1'] = 'يوجد تعليق واØد لا ÙŠØتاج إلى مواÙقة';
@@ -53,11 +61,21 @@ $lang['ar_SA']['BlogSummary.ss']['POSTEDON'] = 'ÙÙŠ';
$lang['ar_SA']['BlogSummary.ss']['VIEWFULL'] = 'عرض كامل التدوينة';
$lang['ar_SA']['RSSWidget']['CT'] = 'العنوان المخصص للخلاصة';
$lang['ar_SA']['RSSWidget']['NTS'] = 'عدد العناصر لعرضها';
+$lang['ar_SA']['RSSWidget']['PLURALNAME'] = 'مربعات الخلاصات RSS';
+$lang['ar_SA']['RSSWidget']['SINGULARNAME'] = 'مربع الخلاصات RSS';
$lang['ar_SA']['RSSWidget']['URL'] = 'رابط الخلاصة';
+$lang['ar_SA']['SubscribeRSSWidget']['PLURALNAME'] = 'مربعات الاشتراك ÙÙŠ الخلاصات RSS';
+$lang['ar_SA']['SubscribeRSSWidget']['SINGULARNAME'] = 'مربع الاشتراك ÙÙŠ الخلاصات RSS';
+$lang['ar_SA']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'اشتراك';
+$lang['ar_SA']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'الاشتراك ÙÙŠ المدونة عن طريق الخلاصات RSS';
$lang['ar_SA']['TagCloudWidget']['LIMIT'] = 'العدد المØدد للوسوم';
+$lang['ar_SA']['TagCloudWidget']['PLURALNAME'] = 'مربعات الوسوم السØابية';
$lang['ar_SA']['TagCloudWidget']['SBAL'] = 'هجائي';
$lang['ar_SA']['TagCloudWidget']['SBFREQ'] = 'تكرار';
+$lang['ar_SA']['TagCloudWidget']['SINGULARNAME'] = 'مربع الوسوم السØابيةَ';
$lang['ar_SA']['TagCloudWidget']['SORTBY'] = 'ترتيب';
$lang['ar_SA']['TagCloudWidget']['TILE'] = 'العنوان';
+$lang['ar_SA']['TrackBackPing']['PLURALNAME'] = 'تنبيهات التعقيبات';
+$lang['ar_SA']['TrackBackPing']['SINGULARNAME'] = 'تنبيه التعقيبات';
?>
\ No newline at end of file
diff --git a/lang/de_DE.php b/lang/de_DE.php
index c189964..09e58d8 100644
--- a/lang/de_DE.php
+++ b/lang/de_DE.php
@@ -18,11 +18,15 @@ if(array_key_exists('de_DE', $lang) && is_array($lang['de_DE'])) {
$lang['de_DE']['ArchiveWidget']['DispBY'] = 'Anzeige nach';
$lang['de_DE']['ArchiveWidget']['MONTH'] = 'Monat';
+$lang['de_DE']['ArchiveWidget']['PLURALNAME'] = 'Archiv-Widgets';
+$lang['de_DE']['ArchiveWidget']['SINGULARNAME'] = 'Archiv-Widget';
$lang['de_DE']['ArchiveWidget']['YEAR'] = 'Jahr';
$lang['de_DE']['BlogEntry']['AU'] = 'Autor';
$lang['de_DE']['BlogEntry']['BBH'] = 'BBCode Hilfe';
$lang['de_DE']['BlogEntry']['CN'] = 'Inhalt';
$lang['de_DE']['BlogEntry']['DT'] = 'Datum';
+$lang['de_DE']['BlogEntry']['PLURALNAME'] = 'Blog-Einträge';
+$lang['de_DE']['BlogEntry']['SINGULARNAME'] = 'Blog-Eintrag';
$lang['de_DE']['BlogEntry.ss']['COMMENTS'] = 'Kommentare';
$lang['de_DE']['BlogEntry.ss']['EDITTHIS'] = 'Eintrag bearbeiten';
$lang['de_DE']['BlogEntry.ss']['POSTEDBY'] = 'Eintrag von';
@@ -32,8 +36,10 @@ $lang['de_DE']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Eintrag zurückziehen';
$lang['de_DE']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Alle Beiträge mit Tag';
$lang['de_DE']['BlogEntry']['TS'] = 'Tags (Komma getrennt)';
$lang['de_DE']['BlogHolder']['HAVENTPERM'] = 'Beiträge können nur von Administratoren eingestellt werden. Bitte einloggen.';
+$lang['de_DE']['BlogHolder']['PLURALNAME'] = 'Blog-Besitzer';
$lang['de_DE']['BlogHolder']['POST'] = 'Eintrag senden';
$lang['de_DE']['BlogHolder']['RSSFEED'] = 'RSS feed von diesem Blog';
+$lang['de_DE']['BlogHolder']['SINGULARNAME'] = 'Blog-Besitzer';
$lang['de_DE']['BlogHolder']['SJ'] = 'Betreff';
$lang['de_DE']['BlogHolder']['SPUC'] = 'Bitte Tags mit Kommata trennen.';
$lang['de_DE']['BlogHolder.ss']['NOENTRIES'] = 'Es gibt keine Blog Einträge';
@@ -43,6 +49,8 @@ $lang['de_DE']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
$lang['de_DE']['BlogHolder']['SUCTITLE'] = 'SilverStripe Blog Module erfolgreich installiert';
$lang['de_DE']['BlogHolder']['TE'] = 'Zum Beispiel: sport, musik, video';
$lang['de_DE']['BlogManagementWidget']['COMADM'] = 'Kommentare bearbeiten';
+$lang['de_DE']['BlogManagementWidget']['PLURALNAME'] = 'Blog-Verwaltungs-Widgets';
+$lang['de_DE']['BlogManagementWidget']['SINGULARNAME'] = 'Blog-Verwaltungs-Widget';
$lang['de_DE']['BlogManagementWidget.ss']['LOGOUT'] = 'Logout';
$lang['de_DE']['BlogManagementWidget.ss']['POSTNEW'] = 'Neuen Eintrag schreiben';
$lang['de_DE']['BlogManagementWidget']['UNM1'] = 'Sie haben 1 noch nicht moderierten Kommentar';
@@ -53,11 +61,21 @@ $lang['de_DE']['BlogSummary.ss']['POSTEDON'] = 'am';
$lang['de_DE']['BlogSummary.ss']['VIEWFULL'] = 'Detaillierte Ansicht von dem Titel --';
$lang['de_DE']['RSSWidget']['CT'] = 'Eigener Titel für den feed';
$lang['de_DE']['RSSWidget']['NTS'] = 'Anzahl der angezeigten Items';
+$lang['de_DE']['RSSWidget']['PLURALNAME'] = 'RSS-Widgets';
+$lang['de_DE']['RSSWidget']['SINGULARNAME'] = 'RSS-Widget';
$lang['de_DE']['RSSWidget']['URL'] = 'URL des RSS Feed';
+$lang['de_DE']['SubscribeRSSWidget']['PLURALNAME'] = 'RSS-Abonnier-Widgets';
+$lang['de_DE']['SubscribeRSSWidget']['SINGULARNAME'] = 'RSS-Abonnier-Widget';
+$lang['de_DE']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Abonnieren';
+$lang['de_DE']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Abonniere diesen Blog per RSS';
$lang['de_DE']['TagCloudWidget']['LIMIT'] = 'Anzahl der erlaubten Tags';
+$lang['de_DE']['TagCloudWidget']['PLURALNAME'] = 'Tag-Cloud-Widgets';
$lang['de_DE']['TagCloudWidget']['SBAL'] = 'Alphabet';
$lang['de_DE']['TagCloudWidget']['SBFREQ'] = 'Häufigkeit';
+$lang['de_DE']['TagCloudWidget']['SINGULARNAME'] = 'Tag-Cloud-Widget';
$lang['de_DE']['TagCloudWidget']['SORTBY'] = 'Sortiert nach';
$lang['de_DE']['TagCloudWidget']['TILE'] = 'Titel';
+$lang['de_DE']['TrackBackPing']['PLURALNAME'] = 'Ping-Verfolgung';
+$lang['de_DE']['TrackBackPing']['SINGULARNAME'] = 'Ping-Verfolgung';
?>
\ No newline at end of file
diff --git a/lang/en_GB.php b/lang/en_GB.php
index 671fb1a..54a1d22 100644
--- a/lang/en_GB.php
+++ b/lang/en_GB.php
@@ -18,11 +18,15 @@ if(array_key_exists('en_GB', $lang) && is_array($lang['en_GB'])) {
$lang['en_GB']['ArchiveWidget']['DispBY'] = 'Display by';
$lang['en_GB']['ArchiveWidget']['MONTH'] = 'month';
+$lang['en_GB']['ArchiveWidget']['PLURALNAME'] = 'Archive Widgets';
+$lang['en_GB']['ArchiveWidget']['SINGULARNAME'] = 'Archive Widget';
$lang['en_GB']['ArchiveWidget']['YEAR'] = 'year';
$lang['en_GB']['BlogEntry']['AU'] = 'Author';
$lang['en_GB']['BlogEntry']['BBH'] = 'BBCode help';
$lang['en_GB']['BlogEntry']['CN'] = 'Content';
$lang['en_GB']['BlogEntry']['DT'] = 'Date';
+$lang['en_GB']['BlogEntry']['PLURALNAME'] = 'Blog Entries';
+$lang['en_GB']['BlogEntry']['SINGULARNAME'] = 'Blog Entry';
$lang['en_GB']['BlogEntry.ss']['COMMENTS'] = 'Comments';
$lang['en_GB']['BlogEntry.ss']['EDITTHIS'] = 'Edit this post';
$lang['en_GB']['BlogEntry.ss']['POSTEDBY'] = 'Posted by';
@@ -32,8 +36,10 @@ $lang['en_GB']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Unpublish this post';
$lang['en_GB']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'View all posts tagged';
$lang['en_GB']['BlogEntry']['TS'] = 'Tags (comma sep.)';
$lang['en_GB']['BlogHolder']['HAVENTPERM'] = 'Posting blogs is an administrator task. Please log in.';
+$lang['en_GB']['BlogHolder']['PLURALNAME'] = 'Blog Holders';
$lang['en_GB']['BlogHolder']['POST'] = 'Post blog entry';
$lang['en_GB']['BlogHolder']['RSSFEED'] = 'RSS feed of this blog';
+$lang['en_GB']['BlogHolder']['SINGULARNAME'] = 'Blog Holder';
$lang['en_GB']['BlogHolder']['SJ'] = 'Subject';
$lang['en_GB']['BlogHolder']['SPUC'] = 'Please separate tags using commas.';
$lang['en_GB']['BlogHolder.ss']['NOENTRIES'] = 'There are no blog entries';
@@ -43,6 +49,8 @@ $lang['en_GB']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
$lang['en_GB']['BlogHolder']['SUCTITLE'] = 'SilverStripe blog module successfully installed';
$lang['en_GB']['BlogHolder']['TE'] = 'For example: sport, personal, science fiction';
$lang['en_GB']['BlogManagementWidget']['COMADM'] = 'Comment administration';
+$lang['en_GB']['BlogManagementWidget']['PLURALNAME'] = 'Blog Management Widgets';
+$lang['en_GB']['BlogManagementWidget']['SINGULARNAME'] = 'Blog Management Widget';
$lang['en_GB']['BlogManagementWidget.ss']['LOGOUT'] = 'Logout';
$lang['en_GB']['BlogManagementWidget.ss']['POSTNEW'] = 'Post a new blog entry';
$lang['en_GB']['BlogManagementWidget']['UNM1'] = 'You have 1 unmoderated comment';
@@ -52,11 +60,19 @@ $lang['en_GB']['BlogSummary.ss']['POSTEDON'] = 'on';
$lang['en_GB']['BlogSummary.ss']['VIEWFULL'] = 'View full post titled -';
$lang['en_GB']['RSSWidget']['CT'] = 'Custom title for the feed';
$lang['en_GB']['RSSWidget']['NTS'] = 'Number of Items to show';
+$lang['en_GB']['RSSWidget']['PLURALNAME'] = 'RSS Widgets';
+$lang['en_GB']['RSSWidget']['SINGULARNAME'] = 'RSS Widget';
$lang['en_GB']['RSSWidget']['URL'] = 'URL of RSS Feed';
+$lang['en_GB']['SubscribeRSSWidget']['PLURALNAME'] = 'Subscript to RSS Widgets';
+$lang['en_GB']['SubscribeRSSWidget']['SINGULARNAME'] = 'Subscript to an RSS Widget';
$lang['en_GB']['TagCloudWidget']['LIMIT'] = 'Limit number of tags';
+$lang['en_GB']['TagCloudWidget']['PLURALNAME'] = 'Tag Cloud Widgets';
$lang['en_GB']['TagCloudWidget']['SBAL'] = 'alphabet';
$lang['en_GB']['TagCloudWidget']['SBFREQ'] = 'frequency';
+$lang['en_GB']['TagCloudWidget']['SINGULARNAME'] = 'Tag Cloud Widget';
$lang['en_GB']['TagCloudWidget']['SORTBY'] = 'Sort by';
$lang['en_GB']['TagCloudWidget']['TILE'] = 'Title';
+$lang['en_GB']['TrackBackPing']['PLURALNAME'] = 'Track Back Pings';
+$lang['en_GB']['TrackBackPing']['SINGULARNAME'] = 'Track Back Ping';
?>
\ No newline at end of file
diff --git a/lang/es_ES.php b/lang/es_ES.php
index 6f2645d..0783464 100644
--- a/lang/es_ES.php
+++ b/lang/es_ES.php
@@ -17,11 +17,15 @@ if(array_key_exists('es_ES', $lang) && is_array($lang['es_ES'])) {
}
$lang['es_ES']['ArchiveWidget']['MONTH'] = 'mes';
+$lang['es_ES']['ArchiveWidget']['PLURALNAME'] = 'Archivar Widgets';
+$lang['es_ES']['ArchiveWidget']['SINGULARNAME'] = 'Archivar Widget';
$lang['es_ES']['ArchiveWidget']['YEAR'] = 'año';
$lang['es_ES']['BlogEntry']['AU'] = 'Autor';
$lang['es_ES']['BlogEntry']['BBH'] = 'BBCode ayuda';
$lang['es_ES']['BlogEntry']['CN'] = 'Contenido';
$lang['es_ES']['BlogEntry']['DT'] = 'Fecha';
+$lang['es_ES']['BlogEntry']['PLURALNAME'] = 'Entradas del Blog';
+$lang['es_ES']['BlogEntry']['SINGULARNAME'] = 'Entrada del Blog';
$lang['es_ES']['BlogEntry.ss']['COMMENTS'] = 'Comentarios';
$lang['es_ES']['BlogEntry.ss']['POSTEDBY'] = 'Publicado por';
$lang['es_ES']['BlogEntry.ss']['TAGS'] = 'Etiquetas:';
@@ -29,8 +33,17 @@ $lang['es_ES']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Ver todas las publicacion
$lang['es_ES']['BlogEntry']['TS'] = 'Etiquetas (separados por comas)';
$lang['es_ES']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
$lang['es_ES']['BlogHolder']['TE'] = 'Por ejemplo: deporte, cine, tecnologÃa';
+$lang['es_ES']['BlogManagementWidget']['PLURALNAME'] = 'Widgets de gestión del Blog';
+$lang['es_ES']['BlogManagementWidget']['SINGULARNAME'] = 'Widget de gestión del Blog';
$lang['es_ES']['BlogManagementWidget.ss']['LOGOUT'] = 'Salir';
$lang['es_ES']['BlogSummary.ss']['COMMENTS'] = 'Comentarios';
+$lang['es_ES']['BlogSummary.ss']['POSTEDBY'] = 'Publicado por';
+$lang['es_ES']['RSSWidget']['PLURALNAME'] = 'Widgets RSS';
+$lang['es_ES']['RSSWidget']['SINGULARNAME'] = 'Widget RSS';
+$lang['es_ES']['SubscribeRSSWidget']['PLURALNAME'] = 'Suscribir a Widgets RSS';
+$lang['es_ES']['SubscribeRSSWidget']['SINGULARNAME'] = 'Suscribir a Widget RSS';
+$lang['es_ES']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Suscribir';
+$lang['es_ES']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Suscribirse a este blog vÃa RSS';
$lang['es_ES']['TagCloudWidget']['SBAL'] = 'alfabeto';
$lang['es_ES']['TagCloudWidget']['SBFREQ'] = 'frecuencia';
$lang['es_ES']['TagCloudWidget']['SORTBY'] = 'Ordenar por';
diff --git a/lang/es_MX.php b/lang/es_MX.php
index 915a34d..31d04dc 100644
--- a/lang/es_MX.php
+++ b/lang/es_MX.php
@@ -18,11 +18,15 @@ if(array_key_exists('es_MX', $lang) && is_array($lang['es_MX'])) {
$lang['es_MX']['ArchiveWidget']['DispBY'] = 'Mostrar por';
$lang['es_MX']['ArchiveWidget']['MONTH'] = 'mes';
+$lang['es_MX']['ArchiveWidget']['PLURALNAME'] = 'Archivos de Widgets';
+$lang['es_MX']['ArchiveWidget']['SINGULARNAME'] = 'Archivo de Widget';
$lang['es_MX']['ArchiveWidget']['YEAR'] = 'año';
$lang['es_MX']['BlogEntry']['AU'] = 'Autor';
$lang['es_MX']['BlogEntry']['BBH'] = 'Ayuda de BBCode';
$lang['es_MX']['BlogEntry']['CN'] = 'Contenido';
$lang['es_MX']['BlogEntry']['DT'] = 'Fecha';
+$lang['es_MX']['BlogEntry']['PLURALNAME'] = 'Entradas del Blog';
+$lang['es_MX']['BlogEntry']['SINGULARNAME'] = 'Entrada del BLog';
$lang['es_MX']['BlogEntry.ss']['COMMENTS'] = 'Comentarios';
$lang['es_MX']['BlogEntry.ss']['EDITTHIS'] = 'Editar este mensaje';
$lang['es_MX']['BlogEntry.ss']['POSTEDBY'] = 'Enviado por';
@@ -32,8 +36,10 @@ $lang['es_MX']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Ocultar este mensaje';
$lang['es_MX']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Ver todos los mensajes marcados con la etiqueta';
$lang['es_MX']['BlogEntry']['TS'] = 'Etiquetas (separadas por coma)';
$lang['es_MX']['BlogHolder']['HAVENTPERM'] = 'La corrección de la bitácora es tarea del administrador. Por favor ingresa como tal.';
+$lang['es_MX']['BlogHolder']['PLURALNAME'] = 'Titulares del Blog';
$lang['es_MX']['BlogHolder']['POST'] = 'Enviar entrada a la bitácora';
$lang['es_MX']['BlogHolder']['RSSFEED'] = 'Alimentar al RSS con esta bitácora';
+$lang['es_MX']['BlogHolder']['SINGULARNAME'] = 'Titular del Blog';
$lang['es_MX']['BlogHolder']['SJ'] = 'Asunto';
$lang['es_MX']['BlogHolder']['SPUC'] = 'Por favor separa etiquetas utilizando comas.';
$lang['es_MX']['BlogHolder.ss']['NOENTRIES'] = 'Bitácora vacÃa';
@@ -43,20 +49,33 @@ $lang['es_MX']['BlogHolder']['SUCTAGS'] = 'bitácora, silverstripe';
$lang['es_MX']['BlogHolder']['SUCTITLE'] = 'El Módulo bitácora Silverstripe se ha instalado satisfactoriamente.';
$lang['es_MX']['BlogHolder']['TE'] = 'Por ejemplo: deportes, personal. ciencia ficción';
$lang['es_MX']['BlogManagementWidget']['COMADM'] = 'Administración de comentarios';
+$lang['es_MX']['BlogManagementWidget']['PLURALNAME'] = 'Widget para la Gestión de Blogs';
+$lang['es_MX']['BlogManagementWidget']['SINGULARNAME'] = 'Wisdget para la Gestion del Blog';
$lang['es_MX']['BlogManagementWidget.ss']['LOGOUT'] = 'Salir';
$lang['es_MX']['BlogManagementWidget.ss']['POSTNEW'] = 'Enviar nueva entrada a la bitácora';
$lang['es_MX']['BlogManagementWidget']['UNM1'] = 'Tienes 1 comentario pendiente de moderación';
$lang['es_MX']['BlogManagementWidget']['UNMM'] = 'Tienes %i comentarios pendientes de moderación';
$lang['es_MX']['BlogSummary.ss']['COMMENTS'] = 'Comentarios';
+$lang['es_MX']['BlogSummary.ss']['POSTEDBY'] = 'Enviado por';
$lang['es_MX']['BlogSummary.ss']['POSTEDON'] = 'en';
$lang['es_MX']['BlogSummary.ss']['VIEWFULL'] = 'Ver completo el mensaje titulado -';
$lang['es_MX']['RSSWidget']['CT'] = 'TÃtulo personalizado para el alimentador';
$lang['es_MX']['RSSWidget']['NTS'] = 'Número de elementos a mostrar:';
+$lang['es_MX']['RSSWidget']['PLURALNAME'] = 'Widgets R S S';
+$lang['es_MX']['RSSWidget']['SINGULARNAME'] = 'Widget R S S';
$lang['es_MX']['RSSWidget']['URL'] = 'URL del RSS alimentado';
+$lang['es_MX']['SubscribeRSSWidget']['PLURALNAME'] = 'Widgets para Suscripción R S S';
+$lang['es_MX']['SubscribeRSSWidget']['SINGULARNAME'] = 'Widget para Suscrición R S S';
+$lang['es_MX']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Suscribe';
+$lang['es_MX']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Suscribirme a este blog vÃa RSS';
$lang['es_MX']['TagCloudWidget']['LIMIT'] = 'Limitar el número de etiquetas';
+$lang['es_MX']['TagCloudWidget']['PLURALNAME'] = 'Widgets de Nube de Etiquetas';
$lang['es_MX']['TagCloudWidget']['SBAL'] = 'alfabeto';
$lang['es_MX']['TagCloudWidget']['SBFREQ'] = 'frecuencia';
+$lang['es_MX']['TagCloudWidget']['SINGULARNAME'] = 'Widget Nube de Etiquetas';
$lang['es_MX']['TagCloudWidget']['SORTBY'] = 'Ordenar por';
$lang['es_MX']['TagCloudWidget']['TILE'] = 'TÃtulo';
+$lang['es_MX']['TrackBackPing']['PLURALNAME'] = 'Volver a la Pista de Pings';
+$lang['es_MX']['TrackBackPing']['SINGULARNAME'] = 'Volver a la Pista de Pings';
?>
\ No newline at end of file
diff --git a/lang/et_EE.php b/lang/et_EE.php
index c0dd740..ad25fa7 100644
--- a/lang/et_EE.php
+++ b/lang/et_EE.php
@@ -18,11 +18,15 @@ if(array_key_exists('et_EE', $lang) && is_array($lang['et_EE'])) {
$lang['et_EE']['ArchiveWidget']['DispBY'] = 'Kuva';
$lang['et_EE']['ArchiveWidget']['MONTH'] = 'kuu';
+$lang['et_EE']['ArchiveWidget']['PLURALNAME'] = 'Arhiveeri vidinad';
+$lang['et_EE']['ArchiveWidget']['SINGULARNAME'] = 'Arhiveeri vidin';
$lang['et_EE']['ArchiveWidget']['YEAR'] = 'aasta';
$lang['et_EE']['BlogEntry']['AU'] = 'Autor';
$lang['et_EE']['BlogEntry']['BBH'] = 'BBCode spikker';
$lang['et_EE']['BlogEntry']['CN'] = 'Sisu';
$lang['et_EE']['BlogEntry']['DT'] = 'Kuupäev';
+$lang['et_EE']['BlogEntry']['PLURALNAME'] = 'Blogi sisu';
+$lang['et_EE']['BlogEntry']['SINGULARNAME'] = 'Blogi sisu';
$lang['et_EE']['BlogEntry.ss']['COMMENTS'] = 'Kommentaarid';
$lang['et_EE']['BlogEntry.ss']['EDITTHIS'] = 'Muuda seda postitust';
$lang['et_EE']['BlogEntry.ss']['POSTEDBY'] = 'Autori';
@@ -32,8 +36,10 @@ $lang['et_EE']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Muuda see postitus avaldamatu
$lang['et_EE']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Vaata kõiki postitusi siltidega';
$lang['et_EE']['BlogEntry']['TS'] = 'Sildid (komaga eraldatud)';
$lang['et_EE']['BlogHolder']['HAVENTPERM'] = 'Blogi postitamine on administraatori ülesanne. Palun logi sisse.';
+$lang['et_EE']['BlogHolder']['PLURALNAME'] = 'Blogi omanikud';
$lang['et_EE']['BlogHolder']['POST'] = 'Postita blogi sissekanne';
$lang['et_EE']['BlogHolder']['RSSFEED'] = 'Selle blogi RSS voog';
+$lang['et_EE']['BlogHolder']['SINGULARNAME'] = 'Blogi omanik';
$lang['et_EE']['BlogHolder']['SJ'] = 'Teema';
$lang['et_EE']['BlogHolder']['SPUC'] = 'Palun eralda sildid komadega.';
$lang['et_EE']['BlogHolder.ss']['NOENTRIES'] = 'Blogi sissekanded puuduvad';
@@ -43,20 +49,33 @@ $lang['et_EE']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
$lang['et_EE']['BlogHolder']['SUCTITLE'] = 'SilverStripe blogimoodul edukalt installeeritud';
$lang['et_EE']['BlogHolder']['TE'] = 'Näiteks: sport, isiklik, teaduslik fantastika';
$lang['et_EE']['BlogManagementWidget']['COMADM'] = 'Kommentaaride haldamine';
+$lang['et_EE']['BlogManagementWidget']['PLURALNAME'] = 'Blogi Muudatuse vidinad';
+$lang['et_EE']['BlogManagementWidget']['SINGULARNAME'] = 'Blogi muudatuste vidin';
$lang['et_EE']['BlogManagementWidget.ss']['LOGOUT'] = 'Logi välja';
$lang['et_EE']['BlogManagementWidget.ss']['POSTNEW'] = 'Postita uus blogi sissekanne';
$lang['et_EE']['BlogManagementWidget']['UNM1'] = 'Sul on 1 üle vaatamata kommentaar';
$lang['et_EE']['BlogManagementWidget']['UNMM'] = 'Sul on %i üle vaatamata kommentaari';
$lang['et_EE']['BlogSummary.ss']['COMMENTS'] = 'Kommentaarid';
+$lang['et_EE']['BlogSummary.ss']['POSTEDBY'] = 'Postitas';
$lang['et_EE']['BlogSummary.ss']['POSTEDON'] = '-';
$lang['et_EE']['BlogSummary.ss']['VIEWFULL'] = 'Vaata tervet postitust pealkirjaga - ';
$lang['et_EE']['RSSWidget']['CT'] = 'Kohandatud pealkiri voole';
$lang['et_EE']['RSSWidget']['NTS'] = 'Kuvatavate sissekannete arv';
+$lang['et_EE']['RSSWidget']['PLURALNAME'] = 'RSS vidinad';
+$lang['et_EE']['RSSWidget']['SINGULARNAME'] = 'RSS vidin';
$lang['et_EE']['RSSWidget']['URL'] = 'URL või RSS voog';
+$lang['et_EE']['SubscribeRSSWidget']['PLURALNAME'] = 'Telli RSS Vidinad';
+$lang['et_EE']['SubscribeRSSWidget']['SINGULARNAME'] = 'Telli RSS Vidin';
+$lang['et_EE']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Telli';
+$lang['et_EE']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Telli blogi RSS kaudu';
$lang['et_EE']['TagCloudWidget']['LIMIT'] = 'Piira siltide arvu';
+$lang['et_EE']['TagCloudWidget']['PLURALNAME'] = 'Lipikute pilve vidinad';
$lang['et_EE']['TagCloudWidget']['SBAL'] = 'tähestikuliselt';
$lang['et_EE']['TagCloudWidget']['SBFREQ'] = 'sageduse järgi';
+$lang['et_EE']['TagCloudWidget']['SINGULARNAME'] = 'Lipikute pilve vidin';
$lang['et_EE']['TagCloudWidget']['SORTBY'] = 'Sorteeri';
$lang['et_EE']['TagCloudWidget']['TILE'] = 'Pealkiri';
+$lang['et_EE']['TrackBackPing']['PLURALNAME'] = 'Pingid';
+$lang['et_EE']['TrackBackPing']['SINGULARNAME'] = 'Ping';
?>
\ No newline at end of file
diff --git a/lang/fr_FR.php b/lang/fr_FR.php
index 05b9c55..c424f1c 100644
--- a/lang/fr_FR.php
+++ b/lang/fr_FR.php
@@ -18,11 +18,15 @@ if(array_key_exists('fr_FR', $lang) && is_array($lang['fr_FR'])) {
$lang['fr_FR']['ArchiveWidget']['DispBY'] = 'Afficher par';
$lang['fr_FR']['ArchiveWidget']['MONTH'] = 'mois';
+$lang['fr_FR']['ArchiveWidget']['PLURALNAME'] = 'Widgets Archive';
+$lang['fr_FR']['ArchiveWidget']['SINGULARNAME'] = 'Widget Archive';
$lang['fr_FR']['ArchiveWidget']['YEAR'] = 'années';
$lang['fr_FR']['BlogEntry']['AU'] = 'Auteur';
$lang['fr_FR']['BlogEntry']['BBH'] = 'Aide BBCode';
$lang['fr_FR']['BlogEntry']['CN'] = 'Contenu';
$lang['fr_FR']['BlogEntry']['DT'] = 'Date';
+$lang['fr_FR']['BlogEntry']['PLURALNAME'] = 'Billets de blog';
+$lang['fr_FR']['BlogEntry']['SINGULARNAME'] = 'Billet de blog';
$lang['fr_FR']['BlogEntry.ss']['COMMENTS'] = 'Commentaires';
$lang['fr_FR']['BlogEntry.ss']['EDITTHIS'] = 'Modifier ce message';
$lang['fr_FR']['BlogEntry.ss']['POSTEDBY'] = 'Posté par';
@@ -32,8 +36,10 @@ $lang['fr_FR']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Dépublier ce message';
$lang['fr_FR']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Voir tous les messages marqués';
$lang['fr_FR']['BlogEntry']['TS'] = 'Tags (Séparer par une virgule)';
$lang['fr_FR']['BlogHolder']['HAVENTPERM'] = 'L\'envoi de blog est réservé aux administrateurs. Loggez vous s\'il vous plaît.';
+$lang['fr_FR']['BlogHolder']['PLURALNAME'] = 'Conteneurs Blogs';
$lang['fr_FR']['BlogHolder']['POST'] = 'Poster une entrée sur le blog';
$lang['fr_FR']['BlogHolder']['RSSFEED'] = 'Flux RSS de ce blog';
+$lang['fr_FR']['BlogHolder']['SINGULARNAME'] = 'Conteneur Blog';
$lang['fr_FR']['BlogHolder']['SJ'] = 'Sujet';
$lang['fr_FR']['BlogHolder']['SPUC'] = 'Veuillez séparer les tags en utilisant une virgule';
$lang['fr_FR']['BlogHolder.ss']['NOENTRIES'] = 'Il n\'y a aucune entrée dans le blog';
@@ -43,6 +49,8 @@ $lang['fr_FR']['BlogHolder']['SUCTAGS'] = 'blog, silverStripe';
$lang['fr_FR']['BlogHolder']['SUCTITLE'] = 'Le module de blog SilverStripe a été installé avec succès';
$lang['fr_FR']['BlogHolder']['TE'] = 'Par exemple: sport, personnel, science fiction';
$lang['fr_FR']['BlogManagementWidget']['COMADM'] = 'Administration des commentaires';
+$lang['fr_FR']['BlogManagementWidget']['PLURALNAME'] = 'Widgets de Management Blog';
+$lang['fr_FR']['BlogManagementWidget']['SINGULARNAME'] = 'Widget de Management Blog';
$lang['fr_FR']['BlogManagementWidget.ss']['LOGOUT'] = 'Déconnexion';
$lang['fr_FR']['BlogManagementWidget.ss']['POSTNEW'] = 'Publier une nouvelle entrée dans le blog';
$lang['fr_FR']['BlogManagementWidget']['UNM1'] = 'Vous avez 1 commentaire non modéré';
@@ -53,7 +61,13 @@ $lang['fr_FR']['BlogSummary.ss']['POSTEDON'] = 'sur';
$lang['fr_FR']['BlogSummary.ss']['VIEWFULL'] = 'Voir le titre du post en entier -';
$lang['fr_FR']['RSSWidget']['CT'] = 'Titre personnalisé pour le flux';
$lang['fr_FR']['RSSWidget']['NTS'] = 'Nombre d\'éléments à afficher';
+$lang['fr_FR']['RSSWidget']['PLURALNAME'] = 'Widgets de flux RSS';
+$lang['fr_FR']['RSSWidget']['SINGULARNAME'] = 'Widget de flux RSS';
$lang['fr_FR']['RSSWidget']['URL'] = 'URL du flux RSS';
+$lang['fr_FR']['SubscribeRSSWidget']['PLURALNAME'] = 'Widgets d\'abonnement RSS';
+$lang['fr_FR']['SubscribeRSSWidget']['SINGULARNAME'] = 'Widget d\'abonnement RSS';
+$lang['fr_FR']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Souscrire';
+$lang['fr_FR']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Souscrire à ce blog par RSS';
$lang['fr_FR']['TagCloudWidget']['LIMIT'] = 'Nombre limite des tags';
$lang['fr_FR']['TagCloudWidget']['SBAL'] = 'alphabet';
$lang['fr_FR']['TagCloudWidget']['SBFREQ'] = 'fréquence';
diff --git a/lang/is_IS.php b/lang/is_IS.php
index d679a2f..f058f2f 100644
--- a/lang/is_IS.php
+++ b/lang/is_IS.php
@@ -23,6 +23,8 @@ $lang['is_IS']['BlogEntry']['AU'] = 'Höfundur';
$lang['is_IS']['BlogEntry']['BBH'] = 'BBCode hjálp';
$lang['is_IS']['BlogEntry']['CN'] = 'Efni';
$lang['is_IS']['BlogEntry']['DT'] = 'Dags';
+$lang['is_IS']['BlogEntry']['PLURALNAME'] = 'Blogg færslur';
+$lang['is_IS']['BlogEntry']['SINGULARNAME'] = 'Blogg færsla';
$lang['is_IS']['BlogEntry.ss']['COMMENTS'] = 'Athugasemdir';
$lang['is_IS']['BlogEntry.ss']['EDITTHIS'] = 'Breyta þessari færslu';
$lang['is_IS']['BlogEntry.ss']['POSTEDBY'] = 'Birt af';
@@ -43,9 +45,9 @@ $lang['is_IS']['BlogHolder']['SUCCONTENT'] = 'Til hamingju, uppsetningin á Silv
$lang['is_IS']['BlogHolder']['SUCTAGS'] = 'silverstripe, blogg';
$lang['is_IS']['BlogHolder']['SUCTITLE'] = 'Uppsetning á SilverStripe blogg einingunni tókst';
$lang['is_IS']['BlogHolder']['TE'] = 'Til dæmis: Ãþróttir, persónulegt, vÃsindasögur';
-$lang['is_IS']['BlogManagementWidget']['COMADM'] = 'Athugasemdir stjórnanda';
+$lang['is_IS']['BlogManagementWidget']['COMADM'] = 'Athugasemda stjórnun';
$lang['is_IS']['BlogManagementWidget.ss']['LOGOUT'] = 'Útskrá';
-$lang['is_IS']['BlogManagementWidget.ss']['POSTNEW'] = 'Birta nýju blogg færsluna';
+$lang['is_IS']['BlogManagementWidget.ss']['POSTNEW'] = 'Skrifa nýja færslu';
$lang['is_IS']['BlogManagementWidget']['UNM1'] = 'Þú átt 1 óskoðaða athugasemd';
$lang['is_IS']['BlogManagementWidget']['UNMM'] = 'Þú átt %i óskoðaða athugasemd';
$lang['is_IS']['BlogSummary.ss']['COMMENTS'] = 'Athugasemdir';
diff --git a/lang/ms_MY.php b/lang/ms_MY.php
new file mode 100644
index 0000000..13312e7
--- /dev/null
+++ b/lang/ms_MY.php
@@ -0,0 +1,34 @@
+
\ No newline at end of file
diff --git a/lang/nl_NL.php b/lang/nl_NL.php
index 8df768c..4fa06df 100644
--- a/lang/nl_NL.php
+++ b/lang/nl_NL.php
@@ -18,31 +18,39 @@ if(array_key_exists('nl_NL', $lang) && is_array($lang['nl_NL'])) {
$lang['nl_NL']['ArchiveWidget']['DispBY'] = 'Tonen door';
$lang['nl_NL']['ArchiveWidget']['MONTH'] = 'maand';
+$lang['nl_NL']['ArchiveWidget']['PLURALNAME'] = 'Archief-widgets';
+$lang['nl_NL']['ArchiveWidget']['SINGULARNAME'] = 'Archief-widget';
$lang['nl_NL']['ArchiveWidget']['YEAR'] = 'jaar';
$lang['nl_NL']['BlogEntry']['AU'] = 'Auteur';
$lang['nl_NL']['BlogEntry']['BBH'] = 'BBCode hulp';
$lang['nl_NL']['BlogEntry']['CN'] = 'Inhoud';
$lang['nl_NL']['BlogEntry']['DT'] = 'Datum';
+$lang['nl_NL']['BlogEntry']['PLURALNAME'] = 'Blog Artikelen';
+$lang['nl_NL']['BlogEntry']['SINGULARNAME'] = 'Blog Artikel';
$lang['nl_NL']['BlogEntry.ss']['COMMENTS'] = 'Reacties';
-$lang['nl_NL']['BlogEntry.ss']['EDITTHIS'] = 'Bewerk dit post';
+$lang['nl_NL']['BlogEntry.ss']['EDITTHIS'] = 'Bewerk deze post';
$lang['nl_NL']['BlogEntry.ss']['POSTEDBY'] = 'Auteur';
$lang['nl_NL']['BlogEntry.ss']['POSTEDON'] = 'Aan';
$lang['nl_NL']['BlogEntry.ss']['TAGS'] = 'Tags:';
-$lang['nl_NL']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'onpubliceer dit post';
+$lang['nl_NL']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'onpubliceer deze post';
$lang['nl_NL']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Bekijk alle posten getiteld';
$lang['nl_NL']['BlogEntry']['TS'] = 'Tags (Komma gescheiden)';
$lang['nl_NL']['BlogHolder']['HAVENTPERM'] = 'Het plaatsen van blogartikelen is een beheerder taak. Log aub in.';
+$lang['nl_NL']['BlogHolder']['PLURALNAME'] = 'Blog Houders';
$lang['nl_NL']['BlogHolder']['POST'] = 'Blogartikel plaatsen';
$lang['nl_NL']['BlogHolder']['RSSFEED'] = 'RSS-feed van deze blog';
+$lang['nl_NL']['BlogHolder']['SINGULARNAME'] = 'Blog Houder';
$lang['nl_NL']['BlogHolder']['SJ'] = 'Onderwerp';
$lang['nl_NL']['BlogHolder']['SPUC'] = 'Scheid de tags met behulp van komma\'s.';
-$lang['nl_NL']['BlogHolder.ss']['NOENTRIES'] = 'Er zijn geen blog entrees ';
-$lang['nl_NL']['BlogHolder.ss']['VIEWINGTAGGED'] = 'U bekijkt entrees tagged met';
+$lang['nl_NL']['BlogHolder.ss']['NOENTRIES'] = 'Er zijn geen blog artikelen';
+$lang['nl_NL']['BlogHolder.ss']['VIEWINGTAGGED'] = 'U bekijkt artikelen getagged met';
$lang['nl_NL']['BlogHolder']['SUCCONTENT'] = 'Gefeliciteerd, de SilverStripe blog module is met succes geïnstalleerd. Dit blogartikel kan veilig worden verwijderd. U kunt aspecten van uw blog (zoals de widgets weergegeven in de zijbalk) in [url=admin]het CMS[/url] veranderen.';
$lang['nl_NL']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
$lang['nl_NL']['BlogHolder']['SUCTITLE'] = 'SilverStripe blog module met succes geïnstalleerd';
$lang['nl_NL']['BlogHolder']['TE'] = 'Bijvoorbeeld: sport, persoonlijke, science fiction';
$lang['nl_NL']['BlogManagementWidget']['COMADM'] = 'Opmerking administratie';
+$lang['nl_NL']['BlogManagementWidget']['PLURALNAME'] = 'Blog Management Widgets';
+$lang['nl_NL']['BlogManagementWidget']['SINGULARNAME'] = 'Blog Management Widgets';
$lang['nl_NL']['BlogManagementWidget.ss']['LOGOUT'] = 'Afmelden';
$lang['nl_NL']['BlogManagementWidget.ss']['POSTNEW'] = 'Publiceer een nieuw blog entree';
$lang['nl_NL']['BlogManagementWidget']['UNM1'] = 'U heeft 1 niet gecontroleerde opmerking';
@@ -53,7 +61,13 @@ $lang['nl_NL']['BlogSummary.ss']['POSTEDON'] = 'Aan';
$lang['nl_NL']['BlogSummary.ss']['VIEWFULL'] = 'Bekijk het gehele post getitled';
$lang['nl_NL']['RSSWidget']['CT'] = 'Aangepaste titel voor de RSS-feed';
$lang['nl_NL']['RSSWidget']['NTS'] = 'Aantal objecten tonen';
+$lang['nl_NL']['RSSWidget']['PLURALNAME'] = 'RSS-widget';
+$lang['nl_NL']['RSSWidget']['SINGULARNAME'] = 'R S S Widget';
$lang['nl_NL']['RSSWidget']['URL'] = 'URL van de RSS-feed';
+$lang['nl_NL']['SubscribeRSSWidget']['PLURALNAME'] = 'Abonneer R S S Widgets';
+$lang['nl_NL']['SubscribeRSSWidget']['SINGULARNAME'] = 'Abonneer R S S Widget';
+$lang['nl_NL']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Inschrijven';
+$lang['nl_NL']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Inschrijven om dit weblog via RSS te volgen';
$lang['nl_NL']['TagCloudWidget']['LIMIT'] = 'Beperk aantal tags';
$lang['nl_NL']['TagCloudWidget']['SBAL'] = 'alfabet';
$lang['nl_NL']['TagCloudWidget']['SBFREQ'] = 'frequentie';
diff --git a/lang/pt_PT.php b/lang/pt_PT.php
index 63eae9b..5e4c9bc 100644
--- a/lang/pt_PT.php
+++ b/lang/pt_PT.php
@@ -16,6 +16,7 @@ if(array_key_exists('pt_PT', $lang) && is_array($lang['pt_PT'])) {
$lang['pt_PT'] = $lang['en_US'];
}
+$lang['pt_PT']['BlogEntry']['PLURALNAME'] = 'Posts no Blog';
$lang['pt_PT']['BlogEntry.ss']['COMMENTS'] = 'Comentários';
$lang['pt_PT']['BlogEntry.ss']['EDITTHIS'] = 'Editar este post';
$lang['pt_PT']['BlogEntry.ss']['POSTEDBY'] = 'Inserido por';
From 517df83ae2389ca7ab8543d1e29ccff27d54ad4f Mon Sep 17 00:00:00 2001
From: Sam Minnee
Date: Tue, 9 Jun 2009 00:46:38 +0000
Subject: [PATCH 143/250] BUGFIX: Prevent infinite loops in RSSWidget.
ENHANCEMENT: Improve the word of the RSSWidget text.
---
code/RSSWidget.php | 9 +++++++--
lang/en_US.php | 16 +++++++++++++---
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/code/RSSWidget.php b/code/RSSWidget.php
index 3209965..99d60c0 100644
--- a/code/RSSWidget.php
+++ b/code/RSSWidget.php
@@ -19,7 +19,7 @@ class RSSWidget extends Widget {
"RSSTitle" => 'RSS Feed'
);
static $cmsTitle = "RSS Feed";
- static $description = "Shows the latest entries of a RSS feed.";
+ static $description = "Downloads another page's RSS feed and displays items in a list.";
/**
* If the RssUrl is relative, convert it to absolute with the
@@ -41,7 +41,7 @@ class RSSWidget extends Widget {
function getCMSFields() {
return new FieldSet(
new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
- new TextField("RssUrl", _t('RSSWidget.URL', "URL of RSS Feed")),
+ new TextField("RssUrl", _t('RSSWidget.URL', "URL of the other page's RSS feed. Please make sure this URL points to an RSS feed.")),
new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show"))
);
}
@@ -51,6 +51,11 @@ class RSSWidget extends Widget {
function FeedItems() {
$output = new DataObjectSet();
+
+ // Protection against infinite loops when an RSS widget pointing to this page is added to this page
+ if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) {
+ return $output;
+ }
include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
diff --git a/lang/en_US.php b/lang/en_US.php
index 6609931..5d5acf7 100644
--- a/lang/en_US.php
+++ b/lang/en_US.php
@@ -37,14 +37,14 @@ $lang['en_US']['BlogEntry.ss']['POSTEDON'] = 'on';
$lang['en_US']['BlogEntry.ss']['TAGS'] = 'Tags:';
$lang['en_US']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Unpublish this post';
$lang['en_US']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'View all posts tagged';
-$lang['en_US']['BlogHolder']['HAVENTPERM'] = 'Posting blogs is an administrator task. Please log in.';
+$lang['en_US']['BlogHolder']['HAVENTPERM'] = 'You do not have sufficient permissions to post blog entries. Please log in.';
$lang['en_US']['BlogHolder']['PLURALNAME'] = array(
'Blog Holders',
50,
'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
);
$lang['en_US']['BlogHolder']['POST'] = 'Post blog entry';
-$lang['en_US']['BlogHolder']['RSSFEED'] = 'RSS feed of this blog';
+$lang['en_US']['BlogHolder']['RSSFEED'] = 'RSS feed of these blogs';
$lang['en_US']['BlogHolder']['SINGULARNAME'] = array(
'Blog Holder',
50,
@@ -77,6 +77,16 @@ $lang['en_US']['BlogSummary.ss']['COMMENTS'] = 'Comments';
$lang['en_US']['BlogSummary.ss']['POSTEDBY'] = 'Posted by';
$lang['en_US']['BlogSummary.ss']['POSTEDON'] = 'on';
$lang['en_US']['BlogSummary.ss']['VIEWFULL'] = 'View full post titled -';
+$lang['en_US']['BlogTree']['PLURALNAME'] = array(
+ 'Blog Tres',
+ 50,
+ 'Pural name of the object, used in dropdowns and to generally identify a collection of this object in the interface'
+);
+$lang['en_US']['BlogTree']['SINGULARNAME'] = array(
+ 'Blog Tree',
+ 50,
+ 'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
+);
$lang['en_US']['RSSWidget']['CT'] = 'Custom title for the feed';
$lang['en_US']['RSSWidget']['NTS'] = 'Number of Items to show';
$lang['en_US']['RSSWidget']['PLURALNAME'] = array(
@@ -89,7 +99,7 @@ $lang['en_US']['RSSWidget']['SINGULARNAME'] = array(
50,
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
);
-$lang['en_US']['RSSWidget']['URL'] = 'URL of RSS Feed';
+$lang['en_US']['RSSWidget']['URL'] = 'URL of the other page\'s RSS Feed. Please make sure this URL points to an RSS feed.';
$lang['en_US']['SubscribeRSSWidget']['PLURALNAME'] = array(
'Subscribe R S S Widgets',
50,
From 0122ac9e3766b63f24009f2fbedf399960df2856 Mon Sep 17 00:00:00 2001
From: Sam Minnee
Date: Wed, 17 Jun 2009 23:13:03 +0000
Subject: [PATCH 144/250] MINOR: Fixed newlines and set svn:eol-style to native
---
css/archivewidget.css | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/css/archivewidget.css b/css/archivewidget.css
index 0018f54..b1cdd13 100644
--- a/css/archivewidget.css
+++ b/css/archivewidget.css
@@ -1,9 +1,9 @@
-.archiveMonths{
-
-}
-
-ul.archiveYears li{
- display: inline;
- font-size: 1.2em !important;
- margin:0 !important;
+.archiveMonths{
+
+}
+
+ul.archiveYears li{
+ display: inline;
+ font-size: 1.2em !important;
+ margin:0 !important;
}
\ No newline at end of file
From f41973b838dd960471093961b7b9d28475b6d377 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Wed, 1 Jul 2009 04:24:42 +0000
Subject: [PATCH 145/250] BUGFIX If IsOwner method doesn't exist on parent
object in BlogEntry::IsOwner(), don't attempt to call it
---
code/BlogEntry.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index bb73f93..c2fbf8e 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -168,8 +168,11 @@ class BlogEntry extends Page {
}
function IsOwner() {
- return $this->Parent()->IsOwner();
+ if(method_exists($this->Parent(), 'IsOwner')) {
+ return $this->Parent()->IsOwner();
+ }
}
+
/**
* Call this to enable WYSIWYG editing on your blog entries.
* By default the blog uses BBCode
From 1e809afc65221d50d68686b87c7982594b9eca6a Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Tue, 7 Jul 2009 22:11:11 +0000
Subject: [PATCH 146/250] BUGFIX Using $allowed_actions in BlogHolder,
permission checks on BlogHoder_Controller->postblog()
---
code/BlogHolder.php | 13 +++++---
tests/BlogHolderFunctionalTest.php | 49 ++++++++++++++++++++++++++++++
tests/BlogHolderFunctionalTest.yml | 20 ++++++++++++
3 files changed, 77 insertions(+), 5 deletions(-)
create mode 100644 tests/BlogHolderFunctionalTest.php
create mode 100644 tests/BlogHolderFunctionalTest.yml
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index d6f9786..c7311cc 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -128,6 +128,13 @@ class BlogHolder extends BlogTree implements PermissionProvider {
}
class BlogHolder_Controller extends BlogTree_Controller {
+
+ static $allowed_actions = array(
+ 'postblog' => 'BLOGMANAGEMENT',
+ 'post' => 'BLOGMANAGEMENT',
+ 'BlogEntryForm' => 'BLOGMANAGEMENT',
+ );
+
function init() {
parent::init();
Requirements::themedCSS("bbcodehelp");
@@ -148,10 +155,6 @@ class BlogHolder_Controller extends BlogTree_Controller {
* Post a new blog entry
*/
function post(){
- if(!$this->IsOwner()){
- Security::permissionFailure($this, _t('BlogHolder.HAVENTPERM', 'You do not have sufficient permissions to post blog entries. Please log in.'));
- }
-
$page = $this->customise(array(
'Content' => false,
'Form' => $this->BlogEntryForm()
@@ -231,7 +234,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
Cookie::set("BlogHolder_Name", $data['Author']);
$blogentry = false;
- if($data['ID']) {
+ if(isset($data['ID']) && $data['ID']) {
$blogentry = DataObject::get_by_id("BlogEntry", $data['ID']);
if(!$blogentry->IsOwner()) {
unset($blogentry);
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
new file mode 100644
index 0000000..566cf00
--- /dev/null
+++ b/tests/BlogHolderFunctionalTest.php
@@ -0,0 +1,49 @@
+objFromFixture('BlogHolder', 'blogholder');
+ $blogHolder->publish('Stage', 'LIve');
+ $blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
+ $blogEntry->publish('Stage', 'LIve');
+ }
+
+ function testFrontendBlogPostRequiresPermission() {
+ // get valid SecurityID (from comments form, would usually be copy/pasted)
+ $blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
+ $response = $this->get($blogEntry->URLSegment);
+ $securityID = Session::get('SecurityID');
+
+ // without login
+ $data = array(
+ 'Title'=>'Disallowed',
+ 'Author'=>'Disallowed',
+ 'Content'=>'Disallowed',
+ 'action_postblog' => 'Post blog entry',
+ 'SecurityID' => $securityID
+ );
+ $response = $this->post('blog/BlogEntryForm', $data);
+ $this->assertFalse(DataObject::get_one('BlogEntry', sprintf("Title = 'Disallowed'")));
+
+ // with login
+ $blogEditor = $this->objFromFixture('Member', 'blog_editor');
+ $blogEditor->logIn();
+ $data = array(
+ 'Title'=>'Allowed',
+ 'Author'=>'Allowed',
+ 'Content'=>'Allowed',
+ 'action_postblog' => 'Post blog entry',
+ 'SecurityID' => $securityID
+ );
+ $response = $this->post('blog/BlogEntryForm', $data);
+ $this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("Title = 'Allowed'")));
+ }
+}
\ No newline at end of file
diff --git a/tests/BlogHolderFunctionalTest.yml b/tests/BlogHolderFunctionalTest.yml
new file mode 100644
index 0000000..561c1ba
--- /dev/null
+++ b/tests/BlogHolderFunctionalTest.yml
@@ -0,0 +1,20 @@
+Permission:
+ blog_management:
+ Code: BLOGMANAGEMENT
+Group:
+ blog_editors:
+ Code: blog-editors
+ Permissions: =>Permission.blog_management
+Member:
+ blog_editor:
+ Email: blogeditor@test.com
+ Groups: =>Group.blog_editors
+BlogHolder:
+ blogholder:
+ Title: Blog Holder
+ URLSegment: blog
+BlogEntry:
+ entry1:
+ Title: Blog Entry
+ ProvideComments: 1
+ Parent: =>BlogHolder.blogholder
\ No newline at end of file
From d0ee014aa575457787b907c019cc2528b817a366 Mon Sep 17 00:00:00 2001
From: Sam Minnee
Date: Tue, 7 Jul 2009 23:04:02 +0000
Subject: [PATCH 147/250] BUGFIX: Improve r81254 to fix blog/rss and subclasses
of BlogHolder_Controller
---
code/BlogHolder.php | 6 ++++++
code/BlogTree.php | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index c7311cc..ea38740 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -155,6 +155,8 @@ class BlogHolder_Controller extends BlogTree_Controller {
* Post a new blog entry
*/
function post(){
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+
$page = $this->customise(array(
'Content' => false,
'Form' => $this->BlogEntryForm()
@@ -167,6 +169,8 @@ class BlogHolder_Controller extends BlogTree_Controller {
* A simple form for creating blog entries
*/
function BlogEntryForm() {
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+
Requirements::javascript('jsparty/behaviour.js');
Requirements::javascript('jsparty/prototype.js');
Requirements::javascript('jsparty/scriptaculous/effects.js');
@@ -231,6 +235,8 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
function postblog($data, $form) {
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+
Cookie::set("BlogHolder_Name", $data['Author']);
$blogentry = false;
diff --git a/code/BlogTree.php b/code/BlogTree.php
index fc327c1..cefe9a1 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -231,6 +231,10 @@ class BlogURL {
}
class BlogTree_Controller extends Page_Controller {
+ static $allowed_actions = array(
+ 'rss' => true,
+ );
+
function init() {
parent::init();
From 076eeaa2a82e2203f99c5f39438fb671967e5cc9 Mon Sep 17 00:00:00 2001
From: Sam Minnee
Date: Tue, 7 Jul 2009 23:15:12 +0000
Subject: [PATCH 148/250] BUGFIX: Updated rss allowed_action to not use 'true'
as a value because this has a bug in 2.3.2
---
code/BlogTree.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index cefe9a1..27cb6eb 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -232,7 +232,7 @@ class BlogURL {
class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
- 'rss' => true,
+ 'rss',
);
function init() {
From 814b76ede9e8e8600c4880ea8925a4a7713d8475 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Wed, 8 Jul 2009 00:28:29 +0000
Subject: [PATCH 149/250] MINOR Using $this->objFromFixture() instead of
referring to deprecated $this->fixture
---
tests/BlogHolderTest.php | 8 ++++----
tests/BlogTreeTest.php | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tests/BlogHolderTest.php b/tests/BlogHolderTest.php
index fe2c179..68a533b 100644
--- a/tests/BlogHolderTest.php
+++ b/tests/BlogHolderTest.php
@@ -4,13 +4,13 @@ class BlogHolderTest extends SapphireTest {
static $fixture_file = 'blog/tests/BlogTest.yml';
function testGetAllBlogEntries() {
- $mainblog = $this->fixture->objFromFixture('BlogHolder', 'mainblog');
+ $mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$this->assertEquals($mainblog->Entries()->Count(), 3);
}
function testEntriesByMonth() {
- $mainblog = $this->fixture->objFromFixture('BlogHolder', 'mainblog');
+ $mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$entries = $mainblog->Entries('', '', '2008-01');
$this->assertEquals($entries->Count(), 2);
@@ -25,7 +25,7 @@ class BlogHolderTest extends SapphireTest {
}
function textEntriesByYear() {
- $mainblog = $this->fixture->objFromFixture('BlogHolder', 'mainblog');
+ $mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$entries = $mainblog->Entries('', '', '2007');
$this->assertEquals($entries->Count(), 1);
@@ -39,7 +39,7 @@ class BlogHolderTest extends SapphireTest {
}
function testEntriesByTag() {
- $mainblog = $this->fixture->objFromFixture('BlogHolder', 'mainblog');
+ $mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$entries = $mainblog->Entries('', 'tag1');
$this->assertEquals($entries->Count(), 2);
diff --git a/tests/BlogTreeTest.php b/tests/BlogTreeTest.php
index bb6349e..69daa82 100644
--- a/tests/BlogTreeTest.php
+++ b/tests/BlogTreeTest.php
@@ -4,22 +4,22 @@ class BlogTreeTest extends SapphireTest {
static $fixture_file = 'blog/tests/BlogTreeTest.yml';
function testGetAllBlogEntries() {
- $node = $this->fixture->objFromFixture('BlogTree', 'root');
+ $node = $this->objFromFixture('BlogTree', 'root');
$this->assertEquals($node->Entries()->Count(), 3);
- $node = $this->fixture->objFromFixture('BlogTree', 'levela');
+ $node = $this->objFromFixture('BlogTree', 'levela');
$this->assertEquals($node->Entries()->Count(), 2);
- $node = $this->fixture->objFromFixture('BlogTree', 'levelaa');
+ $node = $this->objFromFixture('BlogTree', 'levelaa');
$this->assertEquals($node->Entries()->Count(), 2);
- $node = $this->fixture->objFromFixture('BlogTree', 'levelab');
+ $node = $this->objFromFixture('BlogTree', 'levelab');
$this->assertNull($node->Entries());
- $node = $this->fixture->objFromFixture('BlogTree', 'levelb');
+ $node = $this->objFromFixture('BlogTree', 'levelb');
$this->assertEquals($node->Entries()->Count(), 1);
- $node = $this->fixture->objFromFixture('BlogTree', 'levelba');
+ $node = $this->objFromFixture('BlogTree', 'levelba');
$this->assertEquals($node->Entries()->Count(), 1);
}
From 098ae9b32c5bf3a803463fb2d6061cf60db258ef Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Wed, 8 Jul 2009 00:33:31 +0000
Subject: [PATCH 150/250] MINOR Fixed spelling in BlogHolderFunctionalTest
---
tests/BlogHolderFunctionalTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
index 566cf00..4137d27 100644
--- a/tests/BlogHolderFunctionalTest.php
+++ b/tests/BlogHolderFunctionalTest.php
@@ -11,9 +11,9 @@ class BlogHolderFunctionalTest extends FunctionalTest {
parent::setUp();
$blogHolder = $this->objFromFixture('BlogHolder', 'blogholder');
- $blogHolder->publish('Stage', 'LIve');
+ $blogHolder->publish('Stage', 'Live');
$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
- $blogEntry->publish('Stage', 'LIve');
+ $blogEntry->publish('Stage', 'Live');
}
function testFrontendBlogPostRequiresPermission() {
From 2e585539407a211a796643d08b4918c2a2de9685 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Thu, 16 Jul 2009 03:18:55 +0000
Subject: [PATCH 151/250] BUGFIX Ensure that a BlogHolder record doesn't exist
properly by checking if the record has an ID
---
code/BlogHolder.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index ea38740..62aff3b 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -85,7 +85,8 @@ class BlogHolder extends BlogTree implements PermissionProvider {
function requireDefaultRecords() {
parent::requireDefaultRecords();
- if(!DataObject::get_one('BlogHolder')) {
+ $blogHolder = DataObject::get_one('BlogHolder');
+ if(!($blogHolder && $blogHolder->exists())) {
$blogholder = new BlogHolder();
$blogholder->Title = "Blog";
$blogholder->URLSegment = "blog";
From 8589682b7ec2b4ae9159be6b302599313e0d8cdf Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Sun, 19 Jul 2009 21:24:45 +0000
Subject: [PATCH 152/250] BUGFIX: BlogTree always got LandingPageFreshness
value from its parent
---
code/BlogTree.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 27cb6eb..96d1d62 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -69,10 +69,9 @@ class BlogTree extends Page {
public function getLandingPageFreshness() {
$freshness = $this->getField('LandingPageFreshness');
// If we want to inherit freshness, try that first
- if ($freshness = "INHERIT" && $this->getParent()) $freshness = $this->getParent()->LandingPageFreshness;
+ if ($freshness == "INHERIT" && $this->getParent()) $freshness = $this->getParent()->LandingPageFreshness;
// If we don't have a parent, or the inherited result was still inherit, use default
- if ($freshness = "INHERIT") $freshness = '';
-
+ if ($freshness == "INHERIT") $freshness = '';
return $freshness;
}
From a91d0eeb6894d4847bcbd71901e273a11243d36b Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Mon, 20 Jul 2009 02:29:10 +0000
Subject: [PATCH 153/250] Applied an urgent hack to work new blog archive link
(e.g 2009/05)
---
code/BlogHolder.php | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 62aff3b..fb126fe 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -140,6 +140,17 @@ class BlogHolder_Controller extends BlogTree_Controller {
parent::init();
Requirements::themedCSS("bbcodehelp");
}
+
+ /**
+ * TODO: this is an urgent fix to work with archive link (e.g. 2009/04) for Nelsoncc project. Replace this with something better.
+ */
+ function checkAccessAction($action) {
+ if (preg_match('/[0-9]{4}/', $action))
+ {
+ return true;
+ }
+ return parent::checkAccessAction($action);
+ }
/**
* Return list of usable tags for help
From 6d0f161cf4d2dff02afe08b3b4efd337d96f5486 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Mon, 20 Jul 2009 04:02:12 +0000
Subject: [PATCH 154/250] MINOR: Added sorting argument to callback function
---
code/BlogTree.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 96d1d62..ef63809 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -203,7 +203,7 @@ class BlogTree extends Page {
}
// By specifying a callback, you can alter the SQL, or sort on something other than date.
- if ($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit);
+ if ($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit, $order);
else return DataObject::get('BlogEntry', $where, $order, '', $limit);
}
}
From 6eebbb217c8ab27166e794917e43503ae0878055 Mon Sep 17 00:00:00 2001
From: Hamish Friedlander
Date: Mon, 20 Jul 2009 06:40:44 +0000
Subject: [PATCH 155/250] ENHANCEMENT: Allow configuration of the default
number of entries to show on lists
---
code/BlogTree.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index ef63809..9007673 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -10,6 +10,9 @@
class BlogTree extends Page {
+ // Default number of blog entries to show
+ static $default_entries_limit = 10;
+
static $db = array(
'Name' => 'Varchar',
'InheritSideBar' => 'Boolean',
@@ -242,7 +245,9 @@ class BlogTree_Controller extends Page_Controller {
Requirements::themedCSS("blog");
}
- function BlogEntries($limit = 10) {
+ function BlogEntries($limit = null) {
+ if ($limit === null) $limit = BlogTree::$default_entries_limit;
+
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
return $this->Entries("$start,$limit", BlogURL::tag(), BlogURL::date());
}
From 67d8a8b4231cd68536f39766534a4d19748fe138 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Wed, 22 Jul 2009 03:16:06 +0000
Subject: [PATCH 156/250] Added unit test for BlogHolder_Controller's custom
checkAccessAction function
---
code/BlogHolder.php | 2 +-
tests/BlogHolderTest.php | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index fb126fe..9b05833 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -142,7 +142,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
/**
- * TODO: this is an urgent fix to work with archive link (e.g. 2009/04) for Nelsoncc project. Replace this with something better.
+ * TODO: this is an urgent fix to work with archive link (e.g. page_url/2009/04). Replace this with something better.
*/
function checkAccessAction($action) {
if (preg_match('/[0-9]{4}/', $action))
diff --git a/tests/BlogHolderTest.php b/tests/BlogHolderTest.php
index 68a533b..99a9096 100644
--- a/tests/BlogHolderTest.php
+++ b/tests/BlogHolderTest.php
@@ -52,6 +52,18 @@ class BlogHolderTest extends SapphireTest {
$this->assertContains($entry->URLSegment, $expectedEntries);
}
}
+
+ function testcheckAccessAction() {
+ $blogHolder = new BlogHolder_Controller();
+
+ $this->assertTrue($blogHolder->checkAccessAction('2009'));
+ $this->assertTrue($blogHolder->checkAccessAction('0001'));
+ $this->assertTrue($blogHolder->checkAccessAction('12345'));
+
+ $this->assertFalse($blogHolder->checkAccessAction('209'));
+ $this->assertFalse($blogHolder->checkAccessAction('123A'));
+ $this->assertFalse($blogHolder->checkAccessAction('ab01a'));
+ }
}
?>
From c438757b28c9ded425d28d026d789b9d1acce79e Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Mon, 27 Jul 2009 02:52:42 +0000
Subject: [PATCH 157/250] BUGFIX Fixed checking for correct day, month and year
values before setting the Date value in ArchiveWidget
---
code/ArchiveWidget.php | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 7cf20df..13fa279 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -85,20 +85,21 @@ class ArchiveWidget extends Widget {
}
}
- if(!$sqlResults) return new DataObjectSet();
-
- foreach($sqlResults as $sqlResult) {
- $date = new Date('Date');
- $month = ($this->DisplayMode == 'month') ? (int)$sqlResult['Month'] : 1;
+ if($sqlResults) foreach($sqlResults as $sqlResult) {
+ $isMonthDisplay = $this->DisplayMode == 'month';
- $date->setValue(array(
+ $monthVal = ($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1;
+ $month = ($isMonthDisplay) ? $monthVal : 1;
+ $year = ($sqlResult['Year']) ? (int) $sqlResult['Year'] : date('Y');
+
+ $date = DBField::create('Date', array(
'Day' => 1,
- 'Month' => $month,
- 'Year' => (int) $sqlResult['Year']
+ 'Month' => $month,
+ 'Year' => $year
));
- if($this->DisplayMode == 'month') {
- $link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $sqlResult['Month']);
+ if($isMonthDisplay) {
+ $link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $monthVal);
} else {
$link = $container->Link() . $sqlResult['Year'];
}
@@ -111,5 +112,5 @@ class ArchiveWidget extends Widget {
return $results;
}
-}
-?>
+
+}
\ No newline at end of file
From af3b9127494d5f8c7607d334d4f5a6ea88720fbf Mon Sep 17 00:00:00 2001
From: Geoff Munn
Date: Tue, 28 Jul 2009 04:17:38 +0000
Subject: [PATCH 158/250] COMMENT: in some cases, this might not be correctly
triggered
---
code/BlogHolder.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 9b05833..9ea1e14 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -86,7 +86,8 @@ class BlogHolder extends BlogTree implements PermissionProvider {
parent::requireDefaultRecords();
$blogHolder = DataObject::get_one('BlogHolder');
- if(!($blogHolder && $blogHolder->exists())) {
+ //TODO: This does not check for whether this blogholder is an orphan or not
+ if(!$blogHolder) {
$blogholder = new BlogHolder();
$blogholder->Title = "Blog";
$blogholder->URLSegment = "blog";
From a41cf18c23bc564bbc4bb5d6ee37ed166e4431be Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Tue, 28 Jul 2009 05:33:22 +0000
Subject: [PATCH 159/250] BUGFIX: trackbackping generated an exception.
getExtensionInstance returns an instance with NULL owner so
TrackBackDecorator->owner->ID was always unavailable
---
code/BlogEntry.php | 4 ++--
code/TrackBackDecorator.php | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index c2fbf8e..dc70217 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -160,8 +160,8 @@ class BlogEntry extends Page {
}
function trackbackping() {
- if($this->TrackBacksEnabled()) {
- return $this->extInstance('TrackBackDecorator')->trackbackping();
+ if($this->TrackBacksEnabled() && $this->hasExtension('TrackBackDecorator')) {
+ return $this->decoratedTrackbackping();
} else {
Director::redirect($this->Link());
}
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index abe6bca..73c1a1d 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -17,7 +17,7 @@ class TrackBackDecorator extends DataObjectDecorator {
return $this->owner->AbsoluteLink() . 'trackbackping';
}
- function trackbackping() {
+ function decoratedTrackbackping() {
$error = 0;
$message = '';
From 7fe8c11f999a67837d6eaef0ca9d99c2ef45d317 Mon Sep 17 00:00:00 2001
From: Tom Rix
Date: Mon, 3 Aug 2009 04:18:35 +0000
Subject: [PATCH 160/250]
---
tests/BlogHolderTest.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/BlogHolderTest.php b/tests/BlogHolderTest.php
index 99a9096..1941258 100644
--- a/tests/BlogHolderTest.php
+++ b/tests/BlogHolderTest.php
@@ -5,7 +5,8 @@ class BlogHolderTest extends SapphireTest {
function testGetAllBlogEntries() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
-
+
+ $this->assertNotNull($mainblog->Entries());
$this->assertEquals($mainblog->Entries()->Count(), 3);
}
From 1a2e2a1d985182f7649d00cbe6cec4e728d9f262 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Mon, 3 Aug 2009 23:37:03 +0000
Subject: [PATCH 161/250] BUGFIX: prevet calling
loadDescendantBlogHolderIDListInto() on BlogPage and its subclass
---
code/BlogTree.php | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 9007673..74a608c 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -121,8 +121,12 @@ class BlogTree extends Page {
foreach($children as $child) {
if (in_array($child->ID, $idList)) continue;
- if ($child instanceof BlogHolder) $idList[] = $child->ID;
- else $child->loadDescendantBlogHolderIDListInto($idList);
+ if ($child instanceof BlogHolder) {
+ $idList[] = $child->ID;
+ }
+ else if ($child instanceof BlogTree) {
+ $child->loadDescendantBlogHolderIDListInto($idList);
+ }
}
}
}
From 56be6ad6fae7b1ed05e840287aef633e10d08848 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Tue, 4 Aug 2009 02:18:38 +0000
Subject: [PATCH 162/250] MINOR Fixed undefined Month in ArchiveWidget
---
code/ArchiveWidget.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 13fa279..0d7da8a 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -88,7 +88,7 @@ class ArchiveWidget extends Widget {
if($sqlResults) foreach($sqlResults as $sqlResult) {
$isMonthDisplay = $this->DisplayMode == 'month';
- $monthVal = ($sqlResult['Month']) ? (int) $sqlResult['Month'] : 1;
+ $monthVal = (isset($sqlResult['Month'])) ? (int) $sqlResult['Month'] : 1;
$month = ($isMonthDisplay) ? $monthVal : 1;
$year = ($sqlResult['Year']) ? (int) $sqlResult['Year'] : date('Y');
From acbce1d50781e1a07a9496247bc9502b15eec3f4 Mon Sep 17 00:00:00 2001
From: Geoff Munn
Date: Wed, 5 Aug 2009 02:38:32 +0000
Subject: [PATCH 163/250] MINOR FIX: instances where no SideBarID exists are
now avoided
---
code/BlogTree.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 74a608c..06871ee 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -82,8 +82,11 @@ class BlogTree extends Page {
if ($this->InheritSideBar && $this->getParent()) {
if (method_exists($this->getParent(), 'SideBar')) return $this->getParent()->SideBar();
}
- return DataObject::get_by_id('WidgetArea', $this->SideBarID);
- // @todo: This segfaults - investigate why then fix: return $this->getComponent('SideBar');
+
+ if($this->SideBarID){
+ return DataObject::get_by_id('WidgetArea', $this->SideBarID);
+ // @todo: This segfaults - investigate why then fix: return $this->getComponent('SideBar');
+ }
}
/* ----------- CMS CONTROL -------------- */
From 1a566114171eebac3c0eab53f5283f8323f4fac5 Mon Sep 17 00:00:00 2001
From: Geoff Munn
Date: Wed, 5 Aug 2009 03:38:23 +0000
Subject: [PATCH 164/250] MINOR FIX: query changed to remove duplicate results
---
code/ArchiveWidget.php | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 0d7da8a..50c78c7 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -54,33 +54,33 @@ class ArchiveWidget extends Widget {
if($this->DisplayMode == 'month') {
if(defined('Database::USE_ANSI_SQL')) {
$sqlResults = DB::query("
- SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\", \"Date\"
+ SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\"
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
- ORDER BY \"Date\" DESC"
+ ORDER BY \"Year\" DESC, \"Month\" DESC;"
);
} else {
$sqlResults = DB::query("
SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year`
FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
WHERE `ParentID` IN (" . implode(', ', $ids) . ")
- ORDER BY `Date` DESC"
+ ORDER BY `Year` DESC, `Month` DESC;"
);
}
} else {
if(defined('Database::USE_ANSI_SQL')) {
$sqlResults = DB::query("
- SELECT DISTINCT YEAR(\"Date\") AS \"Year\", \"Date\"
+ SELECT DISTINCT YEAR(\"Date\") AS \"Year\"
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
- ORDER BY \"Date\" DESC"
+ ORDER BY \"Year\" DESC"
);
} else {
$sqlResults = DB::query("
SELECT DISTINCT YEAR(`Date`) AS `Year`
FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
WHERE `ParentID` in (".implode(', ',$ids).")
- ORDER BY `Date` DESC"
+ ORDER BY `Year` DESC"
);
}
}
From c37785c07b250e225a7330dd8a225f20a9e2ea58 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Thu, 6 Aug 2009 21:59:43 +0000
Subject: [PATCH 165/250] BUGFIX Fixed "tag" action not allowed on
BlogHolder_Controller
---
code/BlogHolder.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 9ea1e14..1d5e1ee 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -132,6 +132,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
+ 'tag',
'postblog' => 'BLOGMANAGEMENT',
'post' => 'BLOGMANAGEMENT',
'BlogEntryForm' => 'BLOGMANAGEMENT',
From 53bd0feb59406cd7ad60978f40a474fbd20ec724 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 27 Aug 2009 01:23:17 +0000
Subject: [PATCH 166/250] Added true in array_slice to fix problem displaying
tags
---
code/TagCloudWidget.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/TagCloudWidget.php b/code/TagCloudWidget.php
index 8d6e8be..9cfee70 100644
--- a/code/TagCloudWidget.php
+++ b/code/TagCloudWidget.php
@@ -62,7 +62,7 @@ class TagCloudWidget extends Widget {
//TODO: move some or all of the sorts to the database for more efficiency
if($this->Limit > 0){
uasort($allTags, array($this, "column_sort_by_popularity")); //sort by popularity
- $allTags = array_slice($allTags, 0, $this->Limit);
+ $allTags = array_slice($allTags, 0, $this->Limit,true);
}
if($this->Sortby == "alphabet"){
$this->natksort($allTags);
From 9462d240b584b42fae0a3c5ba4e9c6711ec3ccd6 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Thu, 10 Sep 2009 04:04:34 +0000
Subject: [PATCH 167/250] MINOR Updated master language tables
---
lang/en_US.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lang/en_US.php b/lang/en_US.php
index 5d5acf7..1496f5b 100644
--- a/lang/en_US.php
+++ b/lang/en_US.php
@@ -37,7 +37,6 @@ $lang['en_US']['BlogEntry.ss']['POSTEDON'] = 'on';
$lang['en_US']['BlogEntry.ss']['TAGS'] = 'Tags:';
$lang['en_US']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Unpublish this post';
$lang['en_US']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'View all posts tagged';
-$lang['en_US']['BlogHolder']['HAVENTPERM'] = 'You do not have sufficient permissions to post blog entries. Please log in.';
$lang['en_US']['BlogHolder']['PLURALNAME'] = array(
'Blog Holders',
50,
@@ -99,7 +98,7 @@ $lang['en_US']['RSSWidget']['SINGULARNAME'] = array(
50,
'Singular name of the object, used in dropdowns and to generally identify a single object in the interface'
);
-$lang['en_US']['RSSWidget']['URL'] = 'URL of the other page\'s RSS Feed. Please make sure this URL points to an RSS feed.';
+$lang['en_US']['RSSWidget']['URL'] = 'URL of the other page\'s RSS feed. Please make sure this URL points to an RSS feed.';
$lang['en_US']['SubscribeRSSWidget']['PLURALNAME'] = array(
'Subscribe R S S Widgets',
50,
From 26622686cc7b49da210dd8f96419575e912e2cbf Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Thu, 10 Sep 2009 06:08:22 +0000
Subject: [PATCH 168/250] MINOR Added 'index' to $allowed_actions on
BlogHolder, BlogTree, BlogEntry to comply to new RequestHandler API
---
code/BlogEntry.php | 1 +
code/BlogHolder.php | 1 +
code/BlogTree.php | 1 +
3 files changed, 3 insertions(+)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index dc70217..0b4ec1b 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -184,6 +184,7 @@ class BlogEntry extends Page {
class BlogEntry_Controller extends Page_Controller {
static $allowed_actions = array(
+ 'index',
'trackbackping',
'unpublishPost',
'PageComments',
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 1d5e1ee..a9aa426 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -132,6 +132,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
+ 'index',
'tag',
'postblog' => 'BLOGMANAGEMENT',
'post' => 'BLOGMANAGEMENT',
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 06871ee..791ea08 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -241,6 +241,7 @@ class BlogURL {
class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
+ 'index',
'rss',
);
From b4b1c5ff26ca94a3549dc20f10018ea68aee2c01 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Thu, 10 Sep 2009 07:04:40 +0000
Subject: [PATCH 169/250] MINOR More robust login mocking in
BlogHolderFunctionalTest
---
tests/BlogHolderFunctionalTest.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
index 4137d27..c8b56d4 100644
--- a/tests/BlogHolderFunctionalTest.php
+++ b/tests/BlogHolderFunctionalTest.php
@@ -35,7 +35,9 @@ class BlogHolderFunctionalTest extends FunctionalTest {
// with login
$blogEditor = $this->objFromFixture('Member', 'blog_editor');
- $blogEditor->logIn();
+ $this->session()->inst_set('loggedInAs', $blogEditor->ID);
+ Permission::flush_permission_cache();
+
$data = array(
'Title'=>'Allowed',
'Author'=>'Allowed',
@@ -44,6 +46,7 @@ class BlogHolderFunctionalTest extends FunctionalTest {
'SecurityID' => $securityID
);
$response = $this->post('blog/BlogEntryForm', $data);
+
$this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("Title = 'Allowed'")));
}
}
\ No newline at end of file
From 549603e459232b25c5ede8d787eacc7e3ef345cf Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Wed, 23 Sep 2009 08:28:46 +0000
Subject: [PATCH 170/250] MINOR: wrap current page number in SPAN tag for easy
staling
---
templates/Includes/BlogPagination.ss | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/templates/Includes/BlogPagination.ss b/templates/Includes/BlogPagination.ss
index 220aab3..da6c838 100644
--- a/templates/Includes/BlogPagination.ss
+++ b/templates/Includes/BlogPagination.ss
@@ -8,7 +8,7 @@
<% control BlogEntries.PaginationSummary(4) %>
<% if CurrentBool %>
- $PageNum
+ $PageNum
<% else %>
<% if Link %>
$PageNum
From c9200459338b0c31de7437e8e0dc9e6b93e5c232 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Thu, 24 Sep 2009 23:10:54 +0000
Subject: [PATCH 171/250] ENHANCEMENT Allow BlogEntry::getCMSFields() fields to
be manipulated on decorators
---
code/BlogEntry.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 0b4ec1b..8099135 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -86,6 +86,9 @@ class BlogEntry extends Page {
}
$fields->addFieldToTab("Root.Content.Main", new TextField("Tags", _t("BlogEntry.TS", "Tags (comma sep.)")),"Content");
+
+ $this->extend('updateCMSFields', $fields);
+
return $fields;
}
From e688e0687e1f78ddae3665a0d494d40ec718bf62 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Tue, 6 Oct 2009 03:13:00 +0000
Subject: [PATCH 172/250] BUGFIX: Fix updateCMSFields() being called twice on
BlogEntries
---
code/BlogEntry.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 8099135..1516988 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -68,8 +68,10 @@ class BlogEntry extends Page {
$firstName = Member::currentUser() ? Member::currentUser()->FirstName : '';
$codeparser = new BBCodeParser();
-
+
+ SiteTree::disableCMSFieldsExtensions();
$fields = parent::getCMSFields();
+ SiteTree::enableCMSFieldsExtensions();
if(!self::$allow_wysiwyg_editing) {
$fields->removeFieldFromTab("Root.Content.Main","Content");
From fea6a124721660c8ff1ac8395b4a327d6a99ffd7 Mon Sep 17 00:00:00 2001
From: James Kirkus-Lamont
Date: Tue, 20 Oct 2009 23:17:35 +0000
Subject: [PATCH 173/250] MINOR: moved rss feed link to its own function to
allow extensions to override
---
code/BlogTree.php | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 791ea08..2c15c9d 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -248,8 +248,8 @@ class BlogTree_Controller extends Page_Controller {
function init() {
parent::init();
- // This will create a tag point to the RSS feed
- RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
+ $this->IncludeBlogRSS();
+
Requirements::themedCSS("blog");
}
@@ -260,6 +260,11 @@ class BlogTree_Controller extends Page_Controller {
return $this->Entries("$start,$limit", BlogURL::tag(), BlogURL::date());
}
+ function IncludeBlogRSS() {
+ // This will create a tag point to the RSS feed
+ RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
+ }
+
/*
* @todo: It doesn't look like these are used. Remove if no-one complains - Hamish
From 9545d4f87c7da0bfb6b5bfbad3cc8f6b9089960e Mon Sep 17 00:00:00 2001
From: Sam Minnee
Date: Mon, 26 Oct 2009 22:03:52 +0000
Subject: [PATCH 174/250] BUGFIX: Updated blog module to support 2.4 API
changes
---
code/ArchiveWidget.php | 4 ++--
code/BlogEntry.php | 2 +-
code/BlogHolder.php | 3 ++-
code/BlogTree.php | 14 +++++++-------
4 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 50c78c7..886e4af 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -52,7 +52,7 @@ class ArchiveWidget extends Widget {
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
if($this->DisplayMode == 'month') {
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$sqlResults = DB::query("
SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\"
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
@@ -68,7 +68,7 @@ class ArchiveWidget extends Widget {
);
}
} else {
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$sqlResults = DB::query("
SELECT DISTINCT YEAR(\"Date\") AS \"Year\"
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 1516988..50f2b70 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -13,7 +13,7 @@ class BlogEntry extends Page {
static $icon = "blog/images/blogpage";
static $db = array(
- "Date" => "SSDatetime",
+ "Date" => "Datetime",
"Author" => "Text",
"Tags" => "Text"
);
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index a9aa426..b6a4512 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -124,7 +124,8 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$blog->write();
$blog->publish("Stage", "Live");
- Database::alteration_message("Blog page created","created");
+ // 2.3/2.4 dual compatibility
+ if(method_exists('DB', 'alteration_message')) DB::alteration_message("Blog page created","created");
}
}
}
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 2c15c9d..94e85de 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -50,7 +50,7 @@ class BlogTree extends Page {
}
// Try to find a top-level BlogTree
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'");
} else {
$top = DataObject::get_one('BlogTree', 'ParentID = 0');
@@ -155,7 +155,7 @@ class BlogTree extends Page {
if ($tag) {
$SQL_tag = Convert::raw2sql($tag);
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
} else {
$tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
@@ -168,7 +168,7 @@ class BlogTree extends Page {
$month = (int) substr($date, strpos($date, '-') + 1);
if($year && $month) {
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
} else {
$dateCheck = "AND MONTH(`BlogEntry`.Date) = $month AND YEAR(`BlogEntry`.Date) = $year";
@@ -177,7 +177,7 @@ class BlogTree extends Page {
} else {
$year = (int) $date;
if($year) {
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
} else {
$dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
@@ -186,7 +186,7 @@ class BlogTree extends Page {
}
}
elseif ($this->LandingPageFreshness) {
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$dateCheck = "AND \"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
} else {
$dateCheck = "AND `BlogEntry`.Date > NOW() - INTERVAL " . $this->LandingPageFreshness;
@@ -200,13 +200,13 @@ class BlogTree extends Page {
if (empty($holderIDs)) return false;
// Otherwise, do the actual query
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$where = '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
} else {
$where = 'ParentID IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
}
- if(defined('Database::USE_ANSI_SQL')) {
+ if(defined('DB::USE_ANSI_SQL')) {
$order = '"BlogEntry"."Date" DESC';
} else {
$order = '`BlogEntry`.`Date` DESC';
From 1af9fafdd73f0da839b99d51390b7efe24dd786e Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Tue, 27 Oct 2009 03:13:33 +0000
Subject: [PATCH 175/250] BUGFIX: Fix tag links when blog is on home pages
---
code/BlogEntry.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 50f2b70..07a685a 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -104,7 +104,7 @@ class BlogEntry extends Page {
foreach($tags as $tag) {
$output->push(new ArrayData(array(
'Tag' => $tag,
- 'Link' => $this->getParent()->Link() . 'tag/' . urlencode($tag),
+ 'Link' => $this->getParent()->Link('tag') . '/' . urlencode($tag),
'URLTag' => urlencode($tag)
)));
}
From 42beb23f42e9301322556f7d7909f70c972b1bf3 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Thu, 29 Oct 2009 03:15:01 +0000
Subject: [PATCH 176/250] BUGFIX: fix archive links
---
code/ArchiveWidget.php | 6 +++---
code/TagCloudWidget.php | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 886e4af..0746d11 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -99,9 +99,9 @@ class ArchiveWidget extends Widget {
));
if($isMonthDisplay) {
- $link = $container->Link() . $sqlResult['Year']. '/' . sprintf("%'02d", $monthVal);
+ $link = $container->Link($sqlResult['Year']) . '/' . sprintf("%'02d", $monthVal);
} else {
- $link = $container->Link() . $sqlResult['Year'];
+ $link = $container->Link($sqlResult['Year']);
}
$results->push(new ArrayData(array(
@@ -113,4 +113,4 @@ class ArchiveWidget extends Widget {
return $results;
}
-}
\ No newline at end of file
+}
diff --git a/code/TagCloudWidget.php b/code/TagCloudWidget.php
index 9cfee70..1bc7757 100644
--- a/code/TagCloudWidget.php
+++ b/code/TagCloudWidget.php
@@ -92,7 +92,7 @@ class TagCloudWidget extends Widget {
"Tag" => $tag,
"Count" => $count,
"Class" => $class,
- "Link" => $container->Link() . 'tag/' . urlencode($tag)
+ "Link" => $container->Link('tag') . '/' . urlencode($tag)
);
}
}
From c14ff3851bb83a104be4f0a325bedef6bba8874a Mon Sep 17 00:00:00 2001
From: Luke Hudson
Date: Wed, 11 Nov 2009 23:11:32 +0000
Subject: [PATCH 177/250] Updates to blog to work with Sapphire 2.4
---
code/BlogTree.php | 2 +-
code/RSSWidget.php | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 94e85de..c977ddc 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -38,7 +38,7 @@ class BlogTree extends Page {
* - Otherwise, try and find a 'top-level' BlogTree
*/
static function current() {
- $page = Director::currentPage();
+ $page = Director::get_current_page();
// If we _are_ a BlogTree, use us
if ($page instanceof BlogTree) return $page;
diff --git a/code/RSSWidget.php b/code/RSSWidget.php
index 99d60c0..6578411 100644
--- a/code/RSSWidget.php
+++ b/code/RSSWidget.php
@@ -60,9 +60,9 @@ class RSSWidget extends Widget {
include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
$t1 = microtime(true);
- $this->feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
- $this->feed->init();
- if($items = $this->feed->get_items(0, $this->NumberToShow)) {
+ $feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
+ $feed->init();
+ if($items = $feed->get_items(0, $this->NumberToShow)) {
foreach($items as $item) {
// Cast the Date
@@ -84,4 +84,4 @@ class RSSWidget extends Widget {
}
}
-?>
\ No newline at end of file
+?>
From dd632af9fab4439a5f0e9aa879cc09748925f78e Mon Sep 17 00:00:00 2001
From: Luke Hudson
Date: Thu, 12 Nov 2009 02:48:47 +0000
Subject: [PATCH 178/250] Updated language packs to fixed versions
---
lang/ar_SA.php | 4 ++--
lang/bg_BG.php | 4 ++--
lang/da_DK.php | 4 ++--
lang/de_DE.php | 8 ++++----
lang/en_GB.php | 7 +++++--
lang/es_ES.php | 33 +++++++++++++++++++++++++++++++--
lang/es_MX.php | 4 ++--
lang/et_EE.php | 4 ++--
lang/fr_FR.php | 6 ++++--
lang/hr_HR.php | 4 ++--
lang/is_IS.php | 20 ++++++++++++++++----
lang/it_IT.php | 24 ++++++++++++++++++++++--
lang/ms_MY.php | 4 ++--
lang/nl_NL.php | 8 ++++++--
lang/pl_PL.php | 16 ++++++++++++----
lang/pt_PT.php | 4 ++--
lang/ru_RU.php | 4 ++--
lang/sr_RS.php | 4 ++--
lang/tr_TR.php | 4 ++--
19 files changed, 122 insertions(+), 44 deletions(-)
diff --git a/lang/ar_SA.php b/lang/ar_SA.php
index 98a6f0b..0f5d23c 100644
--- a/lang/ar_SA.php
+++ b/lang/ar_SA.php
@@ -2,11 +2,11 @@
/**
* Arabic (Saudi Arabia) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/bg_BG.php b/lang/bg_BG.php
index 9015a77..0b903e6 100644
--- a/lang/bg_BG.php
+++ b/lang/bg_BG.php
@@ -2,11 +2,11 @@
/**
* Bulgarian (Bulgaria) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/da_DK.php b/lang/da_DK.php
index 0ce46e3..99a4318 100644
--- a/lang/da_DK.php
+++ b/lang/da_DK.php
@@ -2,11 +2,11 @@
/**
* Danish (Denmark) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/de_DE.php b/lang/de_DE.php
index 09e58d8..3e4ff0b 100644
--- a/lang/de_DE.php
+++ b/lang/de_DE.php
@@ -2,11 +2,11 @@
/**
* German (Germany) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -38,7 +38,7 @@ $lang['de_DE']['BlogEntry']['TS'] = 'Tags (Komma getrennt)';
$lang['de_DE']['BlogHolder']['HAVENTPERM'] = 'Beiträge können nur von Administratoren eingestellt werden. Bitte einloggen.';
$lang['de_DE']['BlogHolder']['PLURALNAME'] = 'Blog-Besitzer';
$lang['de_DE']['BlogHolder']['POST'] = 'Eintrag senden';
-$lang['de_DE']['BlogHolder']['RSSFEED'] = 'RSS feed von diesem Blog';
+$lang['de_DE']['BlogHolder']['RSSFEED'] = 'RSS Feed dieser Blogs';
$lang['de_DE']['BlogHolder']['SINGULARNAME'] = 'Blog-Besitzer';
$lang['de_DE']['BlogHolder']['SJ'] = 'Betreff';
$lang['de_DE']['BlogHolder']['SPUC'] = 'Bitte Tags mit Kommata trennen.';
@@ -63,7 +63,7 @@ $lang['de_DE']['RSSWidget']['CT'] = 'Eigener Titel für den feed';
$lang['de_DE']['RSSWidget']['NTS'] = 'Anzahl der angezeigten Items';
$lang['de_DE']['RSSWidget']['PLURALNAME'] = 'RSS-Widgets';
$lang['de_DE']['RSSWidget']['SINGULARNAME'] = 'RSS-Widget';
-$lang['de_DE']['RSSWidget']['URL'] = 'URL des RSS Feed';
+$lang['de_DE']['RSSWidget']['URL'] = 'URL des RSS Feed der anderen Seite. Bitte vergewissern Sie sich, dass diese URL auf einen RSS Feed verweist.';
$lang['de_DE']['SubscribeRSSWidget']['PLURALNAME'] = 'RSS-Abonnier-Widgets';
$lang['de_DE']['SubscribeRSSWidget']['SINGULARNAME'] = 'RSS-Abonnier-Widget';
$lang['de_DE']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Abonnieren';
diff --git a/lang/en_GB.php b/lang/en_GB.php
index 54a1d22..486f993 100644
--- a/lang/en_GB.php
+++ b/lang/en_GB.php
@@ -2,11 +2,11 @@
/**
* English (United Kingdom) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -56,6 +56,7 @@ $lang['en_GB']['BlogManagementWidget.ss']['POSTNEW'] = 'Post a new blog entry';
$lang['en_GB']['BlogManagementWidget']['UNM1'] = 'You have 1 unmoderated comment';
$lang['en_GB']['BlogManagementWidget']['UNMM'] = 'You have %i unmoderated comments';
$lang['en_GB']['BlogSummary.ss']['COMMENTS'] = 'Comments';
+$lang['en_GB']['BlogSummary.ss']['POSTEDBY'] = 'Posted by';
$lang['en_GB']['BlogSummary.ss']['POSTEDON'] = 'on';
$lang['en_GB']['BlogSummary.ss']['VIEWFULL'] = 'View full post titled -';
$lang['en_GB']['RSSWidget']['CT'] = 'Custom title for the feed';
@@ -65,6 +66,8 @@ $lang['en_GB']['RSSWidget']['SINGULARNAME'] = 'RSS Widget';
$lang['en_GB']['RSSWidget']['URL'] = 'URL of RSS Feed';
$lang['en_GB']['SubscribeRSSWidget']['PLURALNAME'] = 'Subscript to RSS Widgets';
$lang['en_GB']['SubscribeRSSWidget']['SINGULARNAME'] = 'Subscript to an RSS Widget';
+$lang['en_GB']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Subscribe';
+$lang['en_GB']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Subscribe to this blog via RSS';
$lang['en_GB']['TagCloudWidget']['LIMIT'] = 'Limit number of tags';
$lang['en_GB']['TagCloudWidget']['PLURALNAME'] = 'Tag Cloud Widgets';
$lang['en_GB']['TagCloudWidget']['SBAL'] = 'alphabet';
diff --git a/lang/es_ES.php b/lang/es_ES.php
index 0783464..adac8b6 100644
--- a/lang/es_ES.php
+++ b/lang/es_ES.php
@@ -2,11 +2,11 @@
/**
* Spanish (Spain) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -16,6 +16,7 @@ if(array_key_exists('es_ES', $lang) && is_array($lang['es_ES'])) {
$lang['es_ES'] = $lang['en_US'];
}
+$lang['es_ES']['ArchiveWidget']['DispBY'] = 'Mostrar por';
$lang['es_ES']['ArchiveWidget']['MONTH'] = 'mes';
$lang['es_ES']['ArchiveWidget']['PLURALNAME'] = 'Archivar Widgets';
$lang['es_ES']['ArchiveWidget']['SINGULARNAME'] = 'Archivar Widget';
@@ -27,26 +28,54 @@ $lang['es_ES']['BlogEntry']['DT'] = 'Fecha';
$lang['es_ES']['BlogEntry']['PLURALNAME'] = 'Entradas del Blog';
$lang['es_ES']['BlogEntry']['SINGULARNAME'] = 'Entrada del Blog';
$lang['es_ES']['BlogEntry.ss']['COMMENTS'] = 'Comentarios';
+$lang['es_ES']['BlogEntry.ss']['EDITTHIS'] = 'Editar esta entrada';
$lang['es_ES']['BlogEntry.ss']['POSTEDBY'] = 'Publicado por';
+$lang['es_ES']['BlogEntry.ss']['POSTEDON'] = 'en';
$lang['es_ES']['BlogEntry.ss']['TAGS'] = 'Etiquetas:';
+$lang['es_ES']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Retirar esta entrada';
$lang['es_ES']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Ver todas las publicaciones etiquetadas';
$lang['es_ES']['BlogEntry']['TS'] = 'Etiquetas (separados por comas)';
+$lang['es_ES']['BlogHolder']['HAVENTPERM'] = 'Escribir en el blog es una tarea del administrador. Por favor, identifÃcate.';
+$lang['es_ES']['BlogHolder']['PLURALNAME'] = 'Contenedores de Blog';
+$lang['es_ES']['BlogHolder']['POST'] = 'Entrada del blog';
+$lang['es_ES']['BlogHolder']['RSSFEED'] = 'RSS feed de este blog';
+$lang['es_ES']['BlogHolder']['SINGULARNAME'] = 'Contenedor de Blog';
+$lang['es_ES']['BlogHolder']['SJ'] = 'Asunto';
+$lang['es_ES']['BlogHolder']['SPUC'] = 'Por favor, separa las etiquetas mediante comas.';
+$lang['es_ES']['BlogHolder.ss']['NOENTRIES'] = 'No hay entradas';
+$lang['es_ES']['BlogHolder.ss']['VIEWINGTAGGED'] = 'Ver entrada etiquetadas como';
+$lang['es_ES']['BlogHolder']['SUCCONTENT'] = 'Felicitaciones, el módulo de blog de SilverStripe ha sido instalado correctamente. Esta entrada puede ser eliminada. Puedes configurar aspectos de tu blog (como los widgets mostrados en la barra lateral) en [url=admin]el CMS[/url].';
$lang['es_ES']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
+$lang['es_ES']['BlogHolder']['SUCTITLE'] = 'El módulo de blog de SilverStripe ha sido instalado correctamente';
$lang['es_ES']['BlogHolder']['TE'] = 'Por ejemplo: deporte, cine, tecnologÃa';
+$lang['es_ES']['BlogManagementWidget']['COMADM'] = 'Administración de comentarios';
$lang['es_ES']['BlogManagementWidget']['PLURALNAME'] = 'Widgets de gestión del Blog';
$lang['es_ES']['BlogManagementWidget']['SINGULARNAME'] = 'Widget de gestión del Blog';
$lang['es_ES']['BlogManagementWidget.ss']['LOGOUT'] = 'Salir';
+$lang['es_ES']['BlogManagementWidget.ss']['POSTNEW'] = 'Escribir una nueva entrada del blog';
+$lang['es_ES']['BlogManagementWidget']['UNM1'] = 'Tienes 1 comentario sin moderar';
+$lang['es_ES']['BlogManagementWidget']['UNMM'] = 'Tienes %i comentarios sin moderar';
$lang['es_ES']['BlogSummary.ss']['COMMENTS'] = 'Comentarios';
$lang['es_ES']['BlogSummary.ss']['POSTEDBY'] = 'Publicado por';
+$lang['es_ES']['BlogSummary.ss']['POSTEDON'] = 'en';
+$lang['es_ES']['BlogSummary.ss']['VIEWFULL'] = 'Ver completo el post titulado -';
+$lang['es_ES']['RSSWidget']['CT'] = 'TÃtulo personalizado para el feed';
+$lang['es_ES']['RSSWidget']['NTS'] = 'Número de registros para mostrar';
$lang['es_ES']['RSSWidget']['PLURALNAME'] = 'Widgets RSS';
$lang['es_ES']['RSSWidget']['SINGULARNAME'] = 'Widget RSS';
+$lang['es_ES']['RSSWidget']['URL'] = 'URL del RSS Feed';
$lang['es_ES']['SubscribeRSSWidget']['PLURALNAME'] = 'Suscribir a Widgets RSS';
$lang['es_ES']['SubscribeRSSWidget']['SINGULARNAME'] = 'Suscribir a Widget RSS';
$lang['es_ES']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Suscribir';
$lang['es_ES']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Suscribirse a este blog vÃa RSS';
+$lang['es_ES']['TagCloudWidget']['LIMIT'] = 'Limitar el número de etiquetas';
+$lang['es_ES']['TagCloudWidget']['PLURALNAME'] = 'Nube de Etiquetas de Widgets';
$lang['es_ES']['TagCloudWidget']['SBAL'] = 'alfabeto';
$lang['es_ES']['TagCloudWidget']['SBFREQ'] = 'frecuencia';
+$lang['es_ES']['TagCloudWidget']['SINGULARNAME'] = 'Nube de Etiquetas de Widget';
$lang['es_ES']['TagCloudWidget']['SORTBY'] = 'Ordenar por';
$lang['es_ES']['TagCloudWidget']['TILE'] = 'TÃtulo';
+$lang['es_ES']['TrackBackPing']['PLURALNAME'] = 'Notificaciones de Trackback';
+$lang['es_ES']['TrackBackPing']['SINGULARNAME'] = 'Notificación de Trackback';
?>
\ No newline at end of file
diff --git a/lang/es_MX.php b/lang/es_MX.php
index 31d04dc..2bb2f6a 100644
--- a/lang/es_MX.php
+++ b/lang/es_MX.php
@@ -2,11 +2,11 @@
/**
* Spanish (Mexico) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/et_EE.php b/lang/et_EE.php
index ad25fa7..5870825 100644
--- a/lang/et_EE.php
+++ b/lang/et_EE.php
@@ -2,11 +2,11 @@
/**
* Estonian (Estonia) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/fr_FR.php b/lang/fr_FR.php
index c424f1c..3b94edd 100644
--- a/lang/fr_FR.php
+++ b/lang/fr_FR.php
@@ -2,11 +2,11 @@
/**
* French (France) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -69,8 +69,10 @@ $lang['fr_FR']['SubscribeRSSWidget']['SINGULARNAME'] = 'Widget d\'abonnement RSS
$lang['fr_FR']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Souscrire';
$lang['fr_FR']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Souscrire à ce blog par RSS';
$lang['fr_FR']['TagCloudWidget']['LIMIT'] = 'Nombre limite des tags';
+$lang['fr_FR']['TagCloudWidget']['PLURALNAME'] = 'Widgets Nuage de Tags';
$lang['fr_FR']['TagCloudWidget']['SBAL'] = 'alphabet';
$lang['fr_FR']['TagCloudWidget']['SBFREQ'] = 'fréquence';
+$lang['fr_FR']['TagCloudWidget']['SINGULARNAME'] = 'Widget Nuage de Tags';
$lang['fr_FR']['TagCloudWidget']['SORTBY'] = 'Trier par';
$lang['fr_FR']['TagCloudWidget']['TILE'] = 'Titre';
diff --git a/lang/hr_HR.php b/lang/hr_HR.php
index cde02fb..b0d42dd 100644
--- a/lang/hr_HR.php
+++ b/lang/hr_HR.php
@@ -2,11 +2,11 @@
/**
* Croatian (Croatia) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/is_IS.php b/lang/is_IS.php
index f058f2f..1da4b68 100644
--- a/lang/is_IS.php
+++ b/lang/is_IS.php
@@ -2,11 +2,11 @@
/**
* Icelandic (Iceland) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -27,25 +27,29 @@ $lang['is_IS']['BlogEntry']['PLURALNAME'] = 'Blogg færslur';
$lang['is_IS']['BlogEntry']['SINGULARNAME'] = 'Blogg færsla';
$lang['is_IS']['BlogEntry.ss']['COMMENTS'] = 'Athugasemdir';
$lang['is_IS']['BlogEntry.ss']['EDITTHIS'] = 'Breyta þessari færslu';
-$lang['is_IS']['BlogEntry.ss']['POSTEDBY'] = 'Birt af';
+$lang['is_IS']['BlogEntry.ss']['POSTEDBY'] = 'Skrifað af';
$lang['is_IS']['BlogEntry.ss']['POSTEDON'] = 'á';
$lang['is_IS']['BlogEntry.ss']['TAGS'] = 'Tög:';
$lang['is_IS']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Hætta birtingu þessarar færslu';
$lang['is_IS']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Birta allar taggaðar færslur';
$lang['is_IS']['BlogEntry']['TS'] = 'Tög (komma til aðskilnaðar)';
$lang['is_IS']['BlogHolder']['HAVENTPERM'] = 'Birting bloggs er hlutverk stjórnanda. Vinsamlegast innskráðu þig.';
+$lang['is_IS']['BlogHolder']['PLURALNAME'] = 'Blogg umhverfi';
$lang['is_IS']['BlogHolder']['POST'] = 'Birta blogg færslu';
$lang['is_IS']['BlogHolder']['RSSFEED'] = 'RSS þjónusta fyrir þetta blogg';
+$lang['is_IS']['BlogHolder']['SINGULARNAME'] = 'Blogg umhverfi';
$lang['is_IS']['BlogHolder']['SJ'] = 'Málefni';
$lang['is_IS']['BlogHolder']['SPUC'] = 'Vinsamlegast notaðu kommu til að aðskilja tögin';
$lang['is_IS']['BlogHolder.ss']['NOENTRIES'] = 'Það eru engar blogg færslur';
$lang['is_IS']['BlogHolder.ss']['VIEWINGTAGGED'] = 'Skoða færslur sem eru taggaðar með';
$lang['is_IS']['BlogHolder']['SUCCONTENT'] = 'Til hamingju, uppsetningin á SilverStripe blogg einingunni tókst.
-Þessari blogg færslu er hægt að eyða á örugganhátt. Þú getur stillt útlit blogsins þÃns (svo sem widgets) i [url=admin] CMS[/url].';
+Þessari blogg færslu er hægt að eyða á örugganhátt. Þú getur stillt útlit blogsins þÃns (svo sem widgets) i [url=admin] kefinu[/url].';
$lang['is_IS']['BlogHolder']['SUCTAGS'] = 'silverstripe, blogg';
$lang['is_IS']['BlogHolder']['SUCTITLE'] = 'Uppsetning á SilverStripe blogg einingunni tókst';
$lang['is_IS']['BlogHolder']['TE'] = 'Til dæmis: Ãþróttir, persónulegt, vÃsindasögur';
$lang['is_IS']['BlogManagementWidget']['COMADM'] = 'Athugasemda stjórnun';
+$lang['is_IS']['BlogManagementWidget']['PLURALNAME'] = 'Blogg stjórnunar aukahlutur';
+$lang['is_IS']['BlogManagementWidget']['SINGULARNAME'] = 'Blogg stjórnunar aukahlutur';
$lang['is_IS']['BlogManagementWidget.ss']['LOGOUT'] = 'Útskrá';
$lang['is_IS']['BlogManagementWidget.ss']['POSTNEW'] = 'Skrifa nýja færslu';
$lang['is_IS']['BlogManagementWidget']['UNM1'] = 'Þú átt 1 óskoðaða athugasemd';
@@ -56,10 +60,18 @@ $lang['is_IS']['BlogSummary.ss']['POSTEDON'] = 'á';
$lang['is_IS']['BlogSummary.ss']['VIEWFULL'] = 'Skoða alla færslu -';
$lang['is_IS']['RSSWidget']['CT'] = 'Titill fyrir þjónustuna';
$lang['is_IS']['RSSWidget']['NTS'] = 'Fjöldi hluta til að sýna';
+$lang['is_IS']['RSSWidget']['PLURALNAME'] = 'RSS aukahlutur';
+$lang['is_IS']['RSSWidget']['SINGULARNAME'] = 'RSS aukahlutur';
$lang['is_IS']['RSSWidget']['URL'] = 'Slóð á RSS þjónustuna';
+$lang['is_IS']['SubscribeRSSWidget']['PLURALNAME'] = 'Ãskriftar RSS aukahlutur';
+$lang['is_IS']['SubscribeRSSWidget']['SINGULARNAME'] = 'Ãskriftar RSS aukahlutur';
+$lang['is_IS']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Gerast áskrifandi';
+$lang['is_IS']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Gerast áskrifandi að þessu bloggi à gegnum RSS';
$lang['is_IS']['TagCloudWidget']['LIMIT'] = 'Takmarka fjölda tag';
+$lang['is_IS']['TagCloudWidget']['PLURALNAME'] = 'Tag ský aukahlutur';
$lang['is_IS']['TagCloudWidget']['SBAL'] = 'stafróf';
$lang['is_IS']['TagCloudWidget']['SBFREQ'] = 'tÃðni';
+$lang['is_IS']['TagCloudWidget']['SINGULARNAME'] = 'Tag ský aukahlutur';
$lang['is_IS']['TagCloudWidget']['SORTBY'] = 'Raða eftir';
$lang['is_IS']['TagCloudWidget']['TILE'] = 'Titill';
diff --git a/lang/it_IT.php b/lang/it_IT.php
index c7469b5..3591dd8 100644
--- a/lang/it_IT.php
+++ b/lang/it_IT.php
@@ -2,11 +2,11 @@
/**
* Italian (Italy) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -18,11 +18,15 @@ if(array_key_exists('it_IT', $lang) && is_array($lang['it_IT'])) {
$lang['it_IT']['ArchiveWidget']['DispBY'] = 'Visualizzato da';
$lang['it_IT']['ArchiveWidget']['MONTH'] = 'mese';
+$lang['it_IT']['ArchiveWidget']['PLURALNAME'] = 'Widget Archiviazione';
+$lang['it_IT']['ArchiveWidget']['SINGULARNAME'] = 'Widget Archiviazione';
$lang['it_IT']['ArchiveWidget']['YEAR'] = 'anno';
$lang['it_IT']['BlogEntry']['AU'] = 'Autore';
$lang['it_IT']['BlogEntry']['BBH'] = 'Aiuto BBCode';
$lang['it_IT']['BlogEntry']['CN'] = 'Contenuto';
$lang['it_IT']['BlogEntry']['DT'] = 'Data';
+$lang['it_IT']['BlogEntry']['PLURALNAME'] = 'Registrazioni blog';
+$lang['it_IT']['BlogEntry']['SINGULARNAME'] = 'Registrazione blog';
$lang['it_IT']['BlogEntry.ss']['COMMENTS'] = 'Commenti';
$lang['it_IT']['BlogEntry.ss']['EDITTHIS'] = 'Modifica questo post';
$lang['it_IT']['BlogEntry.ss']['POSTEDBY'] = 'Inserito da';
@@ -32,8 +36,10 @@ $lang['it_IT']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Non pubblicare questo post';
$lang['it_IT']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Visualizza tutti i post con etichetta';
$lang['it_IT']['BlogEntry']['TS'] = 'Etichette (separate da virgola)';
$lang['it_IT']['BlogHolder']['HAVENTPERM'] = 'Scrivere nel blog è un\'attività dell\'amministratore. Accedi come amministratore.';
+$lang['it_IT']['BlogHolder']['PLURALNAME'] = 'Proprietari blog';
$lang['it_IT']['BlogHolder']['POST'] = 'Salva il post nel blog';
$lang['it_IT']['BlogHolder']['RSSFEED'] = 'RSS feed di questo blog';
+$lang['it_IT']['BlogHolder']['SINGULARNAME'] = 'Proprietario blog';
$lang['it_IT']['BlogHolder']['SJ'] = 'Soggetto';
$lang['it_IT']['BlogHolder']['SPUC'] = 'Per favore separa le etichette usando virgole.';
$lang['it_IT']['BlogHolder.ss']['NOENTRIES'] = 'Non ci sono voci nel blog';
@@ -43,6 +49,8 @@ $lang['it_IT']['BlogHolder']['SUCTAGS'] = 'silverstripe, blog';
$lang['it_IT']['BlogHolder']['SUCTITLE'] = 'Modulo blog SilverStripe installato correttamente';
$lang['it_IT']['BlogHolder']['TE'] = 'Ad esempio: sport, personale, fantascienza';
$lang['it_IT']['BlogManagementWidget']['COMADM'] = 'Amministrazione commenti';
+$lang['it_IT']['BlogManagementWidget']['PLURALNAME'] = 'Widget di amministrazione blog';
+$lang['it_IT']['BlogManagementWidget']['SINGULARNAME'] = 'Widget di amministrazione blog';
$lang['it_IT']['BlogManagementWidget.ss']['LOGOUT'] = 'Esci';
$lang['it_IT']['BlogManagementWidget.ss']['POSTNEW'] = 'Inserisci un nuovo post';
$lang['it_IT']['BlogManagementWidget']['UNM1'] = 'Hai 1 commento da moderare';
@@ -51,13 +59,25 @@ $lang['it_IT']['BlogSummary.ss']['COMMENTS'] = 'Commenti';
$lang['it_IT']['BlogSummary.ss']['POSTEDBY'] = 'Inserito da';
$lang['it_IT']['BlogSummary.ss']['POSTEDON'] = 'su';
$lang['it_IT']['BlogSummary.ss']['VIEWFULL'] = 'Visualizza post intitolato - ';
+$lang['it_IT']['BlogTree']['PLURALNAME'] = 'Alberi dei blog';
+$lang['it_IT']['BlogTree']['SINGULARNAME'] = 'Albero del blog';
$lang['it_IT']['RSSWidget']['CT'] = 'Titolo del feed';
$lang['it_IT']['RSSWidget']['NTS'] = 'Numero di argomenti da visualizzare';
+$lang['it_IT']['RSSWidget']['PLURALNAME'] = 'Widget RSS';
+$lang['it_IT']['RSSWidget']['SINGULARNAME'] = 'Widget RSS';
$lang['it_IT']['RSSWidget']['URL'] = 'URL per il Feed RSS';
+$lang['it_IT']['SubscribeRSSWidget']['PLURALNAME'] = 'Sottoscrivi Widget RSS';
+$lang['it_IT']['SubscribeRSSWidget']['SINGULARNAME'] = 'Sottoscrivi Widget RSS';
+$lang['it_IT']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Sottoscrivi';
+$lang['it_IT']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Sottoscrivi questo blog via RSS';
$lang['it_IT']['TagCloudWidget']['LIMIT'] = 'Limitare il numero dei tag a';
+$lang['it_IT']['TagCloudWidget']['PLURALNAME'] = 'Widget Nuvola di Tag';
$lang['it_IT']['TagCloudWidget']['SBAL'] = 'alfabeto';
$lang['it_IT']['TagCloudWidget']['SBFREQ'] = 'frequenza';
+$lang['it_IT']['TagCloudWidget']['SINGULARNAME'] = 'Widget Nuvola di Tag';
$lang['it_IT']['TagCloudWidget']['SORTBY'] = 'Ordina per';
$lang['it_IT']['TagCloudWidget']['TILE'] = 'Titolo';
+$lang['it_IT']['TrackBackPing']['PLURALNAME'] = 'Rileva Ping';
+$lang['it_IT']['TrackBackPing']['SINGULARNAME'] = 'Rileva Ping';
?>
\ No newline at end of file
diff --git a/lang/ms_MY.php b/lang/ms_MY.php
index 13312e7..b24eb12 100644
--- a/lang/ms_MY.php
+++ b/lang/ms_MY.php
@@ -2,11 +2,11 @@
/**
* Malay (Malaysia) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/nl_NL.php b/lang/nl_NL.php
index 4fa06df..294fe4a 100644
--- a/lang/nl_NL.php
+++ b/lang/nl_NL.php
@@ -2,11 +2,11 @@
/**
* Dutch (Netherlands) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -69,9 +69,13 @@ $lang['nl_NL']['SubscribeRSSWidget']['SINGULARNAME'] = 'Abonneer R S S Widget';
$lang['nl_NL']['SubscribeRSSWidget.ss']['SUBSCRIBETEXT'] = 'Inschrijven';
$lang['nl_NL']['SubscribeRSSWidget.ss']['SUBSCRIBETITLE'] = 'Inschrijven om dit weblog via RSS te volgen';
$lang['nl_NL']['TagCloudWidget']['LIMIT'] = 'Beperk aantal tags';
+$lang['nl_NL']['TagCloudWidget']['PLURALNAME'] = 'Tag Cloud Widgets';
$lang['nl_NL']['TagCloudWidget']['SBAL'] = 'alfabet';
$lang['nl_NL']['TagCloudWidget']['SBFREQ'] = 'frequentie';
+$lang['nl_NL']['TagCloudWidget']['SINGULARNAME'] = 'Tag Cloud Widget';
$lang['nl_NL']['TagCloudWidget']['SORTBY'] = 'Sorteer bij';
$lang['nl_NL']['TagCloudWidget']['TILE'] = 'Titel';
+$lang['nl_NL']['TrackBackPing']['PLURALNAME'] = 'Track Back Pings';
+$lang['nl_NL']['TrackBackPing']['SINGULARNAME'] = 'Track Back Ping';
?>
\ No newline at end of file
diff --git a/lang/pl_PL.php b/lang/pl_PL.php
index 187889c..b1c9e2e 100644
--- a/lang/pl_PL.php
+++ b/lang/pl_PL.php
@@ -2,11 +2,11 @@
/**
* Polish (Poland) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
@@ -23,17 +23,21 @@ $lang['pl_PL']['BlogEntry']['AU'] = 'Autor';
$lang['pl_PL']['BlogEntry']['BBH'] = 'Pomoc BBCode';
$lang['pl_PL']['BlogEntry']['CN'] = 'Zawartość';
$lang['pl_PL']['BlogEntry']['DT'] = 'Data';
+$lang['pl_PL']['BlogEntry']['PLURALNAME'] = 'Wpisy bloga';
+$lang['pl_PL']['BlogEntry']['SINGULARNAME'] = 'Wpis bloga';
$lang['pl_PL']['BlogEntry.ss']['COMMENTS'] = 'Komentarze';
$lang['pl_PL']['BlogEntry.ss']['EDITTHIS'] = 'Edytuj ten post';
$lang['pl_PL']['BlogEntry.ss']['POSTEDBY'] = 'Dodane przez';
-$lang['pl_PL']['BlogEntry.ss']['POSTEDON'] = 'w';
+$lang['pl_PL']['BlogEntry.ss']['POSTEDON'] = 'Opublikowano';
$lang['pl_PL']['BlogEntry.ss']['TAGS'] = 'Tagi:';
$lang['pl_PL']['BlogEntry.ss']['UNPUBLISHTHIS'] = 'Cofnij publikacjÄ™ tego postu';
$lang['pl_PL']['BlogEntry.ss']['VIEWALLPOSTTAGGED'] = 'Zobacz wszystkie posty otagowane jako';
$lang['pl_PL']['BlogEntry']['TS'] = 'Tagi (oddziel przecinkami)';
$lang['pl_PL']['BlogHolder']['HAVENTPERM'] = 'Tylko administrator może publikować wpisy na blogu. Zaloguj się.';
+$lang['pl_PL']['BlogHolder']['PLURALNAME'] = 'Blog Listy';
$lang['pl_PL']['BlogHolder']['POST'] = 'Publikuj wpis';
$lang['pl_PL']['BlogHolder']['RSSFEED'] = 'Subskrybuj wpisy na tym blogu przez RSS';
+$lang['pl_PL']['BlogHolder']['SINGULARNAME'] = 'Blog Lista';
$lang['pl_PL']['BlogHolder']['SJ'] = 'Temat';
$lang['pl_PL']['BlogHolder']['SPUC'] = 'Oddziel tagi używając przecinków.';
$lang['pl_PL']['BlogHolder.ss']['NOENTRIES'] = 'Nie ma żadnych wpisów na blogu';
@@ -49,11 +53,15 @@ $lang['pl_PL']['BlogManagementWidget']['UNM1'] = 'Masz 1 niesprawdzony komentarz
$lang['pl_PL']['BlogManagementWidget']['UNMM'] = 'Masz %i niesprawdzonych komentarzy';
$lang['pl_PL']['BlogSummary.ss']['COMMENTS'] = 'Komentarze';
$lang['pl_PL']['BlogSummary.ss']['POSTEDBY'] = 'Napisane przez';
-$lang['pl_PL']['BlogSummary.ss']['POSTEDON'] = 'w';
+$lang['pl_PL']['BlogSummary.ss']['POSTEDON'] = 'Opublikowano';
$lang['pl_PL']['BlogSummary.ss']['VIEWFULL'] = 'Zobacz pełny post zatytułowany - ';
$lang['pl_PL']['RSSWidget']['CT'] = 'Tytuł dla kanału';
$lang['pl_PL']['RSSWidget']['NTS'] = 'Ilość pokazywanych wpisów';
+$lang['pl_PL']['RSSWidget']['PLURALNAME'] = 'Widżety RSS';
+$lang['pl_PL']['RSSWidget']['SINGULARNAME'] = 'Widżet RSS';
$lang['pl_PL']['RSSWidget']['URL'] = 'URL RSS';
+$lang['pl_PL']['SubscribeRSSWidget']['PLURALNAME'] = 'Subksrybuj widżety RSS';
+$lang['pl_PL']['SubscribeRSSWidget']['SINGULARNAME'] = 'Subksrybuj widżet RSS';
$lang['pl_PL']['TagCloudWidget']['LIMIT'] = 'Limit tagów';
$lang['pl_PL']['TagCloudWidget']['SBAL'] = 'alfabetu';
$lang['pl_PL']['TagCloudWidget']['SBFREQ'] = 'częstości występowania';
diff --git a/lang/pt_PT.php b/lang/pt_PT.php
index 5e4c9bc..2cd2943 100644
--- a/lang/pt_PT.php
+++ b/lang/pt_PT.php
@@ -2,11 +2,11 @@
/**
* Portuguese (Portugal) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/ru_RU.php b/lang/ru_RU.php
index 11a5347..e6215c5 100644
--- a/lang/ru_RU.php
+++ b/lang/ru_RU.php
@@ -2,11 +2,11 @@
/**
* Russian (Russia) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/sr_RS.php b/lang/sr_RS.php
index e11b271..758d1e3 100644
--- a/lang/sr_RS.php
+++ b/lang/sr_RS.php
@@ -2,11 +2,11 @@
/**
* Serbian (Serbia) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
diff --git a/lang/tr_TR.php b/lang/tr_TR.php
index 24d4b57..23d9564 100644
--- a/lang/tr_TR.php
+++ b/lang/tr_TR.php
@@ -2,11 +2,11 @@
/**
* Turkish (Turkey) language pack
- * @package modules: blog
+ * @package blog
* @subpackage i18n
*/
-i18n::include_locale_file('modules: blog', 'en_US');
+i18n::include_locale_file('blog', 'en_US');
global $lang;
From a2b9e2f00cbc6c2f9602237098e43575829a1f49 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Wed, 18 Nov 2009 03:00:40 +0000
Subject: [PATCH 179/250] BUGFIX: using Controller::curr instead
Director::get_current_page to work with 2.3 and 2.4
---
code/BlogTree.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index c977ddc..a75f676 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -38,7 +38,9 @@ class BlogTree extends Page {
* - Otherwise, try and find a 'top-level' BlogTree
*/
static function current() {
- $page = Director::get_current_page();
+
+ $controller = Controller::curr();
+ if($controller) $page = $controller->data();
// If we _are_ a BlogTree, use us
if ($page instanceof BlogTree) return $page;
From 10d15e1dddb75345ea2ae52a8efcb5d900f8d574 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Mon, 30 Nov 2009 08:18:56 +0000
Subject: [PATCH 180/250] APICHANGE: Drop 2.3 support - 0.3 will be 2.4 only
---
code/ArchiveWidget.php | 49 +++++---------
code/BlogEntry.php | 13 ++--
code/BlogHolder.php | 17 ++---
code/BlogManagementWidget.php | 3 +-
code/BlogTree.php | 118 ++++++++--------------------------
code/RSSWidget.php | 1 +
code/SubscribeRSSWidget.php | 3 +-
code/TagCloudWidget.php | 4 +-
code/TrackBackDecorator.php | 1 -
9 files changed, 61 insertions(+), 148 deletions(-)
diff --git a/code/ArchiveWidget.php b/code/ArchiveWidget.php
index 0746d11..a423a49 100644
--- a/code/ArchiveWidget.php
+++ b/code/ArchiveWidget.php
@@ -6,10 +6,10 @@
* @package blog
*/
class ArchiveWidget extends Widget {
-
static $db = array(
'DisplayMode' => 'Varchar'
);
+
static $has_one = array();
static $has_many = array();
@@ -52,37 +52,19 @@ class ArchiveWidget extends Widget {
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
if($this->DisplayMode == 'month') {
- if(defined('DB::USE_ANSI_SQL')) {
- $sqlResults = DB::query("
- SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\"
- FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
- WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
- ORDER BY \"Year\" DESC, \"Month\" DESC;"
- );
- } else {
- $sqlResults = DB::query("
- SELECT DISTINCT MONTH(`Date`) AS `Month`, YEAR(`Date`) AS `Year`
- FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
- WHERE `ParentID` IN (" . implode(', ', $ids) . ")
- ORDER BY `Year` DESC, `Month` DESC;"
- );
- }
+ $sqlResults = DB::query("
+ SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\"
+ FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
+ WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
+ ORDER BY \"Year\" DESC, \"Month\" DESC;"
+ );
} else {
- if(defined('DB::USE_ANSI_SQL')) {
- $sqlResults = DB::query("
- SELECT DISTINCT YEAR(\"Date\") AS \"Year\"
- FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
- WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
- ORDER BY \"Year\" DESC"
- );
- } else {
- $sqlResults = DB::query("
- SELECT DISTINCT YEAR(`Date`) AS `Year`
- FROM `SiteTree$suffix` NATURAL JOIN `BlogEntry$suffix`
- WHERE `ParentID` in (".implode(', ',$ids).")
- ORDER BY `Year` DESC"
- );
- }
+ $sqlResults = DB::query("
+ SELECT DISTINCT YEAR(\"Date\") AS \"Year\"
+ FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
+ WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
+ ORDER BY \"Year\" DESC"
+ );
}
if($sqlResults) foreach($sqlResults as $sqlResult) {
@@ -111,6 +93,7 @@ class ArchiveWidget extends Widget {
}
return $results;
- }
-
+ }
}
+
+?>
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 07a685a..6688932 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -5,19 +5,18 @@
* @package blog
*/
class BlogEntry extends Page {
-
- static $default_parent = 'BlogHolder';
-
- static $can_be_root = false;
-
- static $icon = "blog/images/blogpage";
-
static $db = array(
"Date" => "Datetime",
"Author" => "Text",
"Tags" => "Text"
);
+ static $default_parent = 'BlogHolder';
+
+ static $can_be_root = false;
+
+ static $icon = "blog/images/blogpage";
+
static $has_one = array();
static $has_many = array();
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index b6a4512..f08a76b 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -12,7 +12,6 @@
* BlogHolders have a form on them for easy posting, and an owner that can post to them, BlogTrees don't
*/
class BlogHolder extends BlogTree implements PermissionProvider {
-
static $icon = "blog/images/blogholder";
static $db = array(
@@ -76,7 +75,6 @@ class BlogHolder extends BlogTree implements PermissionProvider {
*/
function IsOwner() {
return (Permission::check('BLOGMANAGEMENT') || Permission::check('ADMIN'));
- //return Permission::check('ADMIN') || (Member::currentUserID() == $this->OwnerID);
}
/**
@@ -118,20 +116,18 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
$blog->URLSegment = 'sample-blog-entry';
$blog->Tags = _t('BlogHolder.SUCTAGS',"silverstripe, blog");
- $blog->Content = _t('BlogHolder.SUCCONTENT',"Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog (such as the widgets displayed in the sidebar) in [url=admin]the CMS[/url].");
+ $blog->Content = _t('BlogHolder.SUCCONTENT',"Congratulations, the SilverStripe blog module has been successfully installed. This blog entry can be safely deleted. You can configure aspects of your blog (such as the widgets displayed in the sidebar) in the CMS .
");
$blog->Status = "Published";
$blog->ParentID = $blogholder->ID;
$blog->write();
$blog->publish("Stage", "Live");
- // 2.3/2.4 dual compatibility
- if(method_exists('DB', 'alteration_message')) DB::alteration_message("Blog page created","created");
+ DB::alteration_message("Blog page created","created");
}
}
}
class BlogHolder_Controller extends BlogTree_Controller {
-
static $allowed_actions = array(
'index',
'tag',
@@ -149,10 +145,10 @@ class BlogHolder_Controller extends BlogTree_Controller {
* TODO: this is an urgent fix to work with archive link (e.g. page_url/2009/04). Replace this with something better.
*/
function checkAccessAction($action) {
- if (preg_match('/[0-9]{4}/', $action))
- {
+ if(preg_match('/[0-9]{4}/', $action)) {
return true;
}
+
return parent::checkAccessAction($action);
}
@@ -217,14 +213,15 @@ class BlogHolder_Controller extends BlogTree_Controller {
} else {
$tagfield = new TextField('Tags');
}
+
$field = 'TextField';
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
$field = 'ReadonlyField';
}
$fields = new FieldSet(
new HiddenField("ID", "ID"),
- new TextField("Title",_t('BlogHolder.SJ', "Subject")),
- new $field("Author",_t('BlogEntry.AU'),$membername),
+ new TextField("Title", _t('BlogHolder.SJ', "Subject")),
+ new $field("Author", _t('BlogEntry.AU'), $membername),
$contentfield,
$tagfield,
new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
diff --git a/code/BlogManagementWidget.php b/code/BlogManagementWidget.php
index 9cafcf9..59682f2 100644
--- a/code/BlogManagementWidget.php
+++ b/code/BlogManagementWidget.php
@@ -4,7 +4,6 @@
* @package blog
*/
class BlogManagementWidget extends Widget implements PermissionProvider {
-
static $db = array();
static $has_one = array();
@@ -61,4 +60,4 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
}
}
-?>
\ No newline at end of file
+?>
diff --git a/code/BlogTree.php b/code/BlogTree.php
index a75f676..1c0dadb 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -46,23 +46,18 @@ class BlogTree extends Page {
if ($page instanceof BlogTree) return $page;
// Or, if we a a BlogEntry underneath a BlogTree, use our parent
- if ($page->is_a("BlogEntry")) {
+ if($page->is_a("BlogEntry")) {
$parent = $page->getParent();
- if ($parent instanceof BlogTree) return $parent;
+ if($parent instanceof BlogTree) return $parent;
}
// Try to find a top-level BlogTree
- if(defined('DB::USE_ANSI_SQL')) {
- $top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'");
- } else {
- $top = DataObject::get_one('BlogTree', 'ParentID = 0');
- }
-
- if ($top) return $top;
+ $top = DataObject::get_one('BlogTree', "\"ParentID\" = '0'");
+ if($top) return $top;
// Try to find any BlogTree that is not inside another BlogTree
foreach(DataObject::get('BlogTree') as $tree) {
- if (!($tree->getParent() instanceof BlogTree)) return $tree;
+ if(!($tree->getParent() instanceof BlogTree)) return $tree;
}
// This shouldn't be possible, but assuming the above fails, just return anything you can get
@@ -81,7 +76,7 @@ class BlogTree extends Page {
}
function SideBar() {
- if ($this->InheritSideBar && $this->getParent()) {
+ if($this->InheritSideBar && $this->getParent()) {
if (method_exists($this->getParent(), 'SideBar')) return $this->getParent()->SideBar();
}
@@ -124,12 +119,11 @@ class BlogTree extends Page {
public function loadDescendantBlogHolderIDListInto(&$idList) {
if ($children = $this->AllChildren()) {
foreach($children as $child) {
- if (in_array($child->ID, $idList)) continue;
+ if(in_array($child->ID, $idList)) continue;
- if ($child instanceof BlogHolder) {
+ if($child instanceof BlogHolder) {
$idList[] = $child->ID;
- }
- else if ($child instanceof BlogTree) {
+ } elseif($child instanceof BlogTree) {
$child->loadDescendantBlogHolderIDListInto($idList);
}
}
@@ -155,72 +149,47 @@ class BlogTree extends Page {
$tagCheck = '';
$dateCheck = '';
- if ($tag) {
+ if($tag) {
$SQL_tag = Convert::raw2sql($tag);
- if(defined('DB::USE_ANSI_SQL')) {
- $tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
- } else {
- $tagCheck = "AND `BlogEntry`.Tags LIKE '%$SQL_tag%'";
- }
+ $tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
}
- if ($date) {
+ if($date) {
if(strpos($date, '-')) {
$year = (int) substr($date, 0, strpos($date, '-'));
$month = (int) substr($date, strpos($date, '-') + 1);
if($year && $month) {
- if(defined('DB::USE_ANSI_SQL')) {
- $dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
- } else {
- $dateCheck = "AND MONTH(`BlogEntry`.Date) = $month AND YEAR(`BlogEntry`.Date) = $year";
- }
+ $dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
}
} else {
$year = (int) $date;
if($year) {
- if(defined('DB::USE_ANSI_SQL')) {
- $dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
- } else {
- $dateCheck = "AND YEAR(`BlogEntry`.Date) = $year";
- }
+ $dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
}
}
- }
- elseif ($this->LandingPageFreshness) {
- if(defined('DB::USE_ANSI_SQL')) {
- $dateCheck = "AND \"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
- } else {
- $dateCheck = "AND `BlogEntry`.Date > NOW() - INTERVAL " . $this->LandingPageFreshness;
- }
+ } elseif ($this->LandingPageFreshness) {
+ $dateCheck = "AND \"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
}
// Build a list of all IDs for BlogHolders that are children of us
$holderIDs = $this->BlogHolderIDs();
// If no BlogHolders, no BlogEntries. So return false
- if (empty($holderIDs)) return false;
+ if(empty($holderIDs)) return false;
// Otherwise, do the actual query
- if(defined('DB::USE_ANSI_SQL')) {
- $where = '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
- } else {
- $where = 'ParentID IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
- }
+ $where = '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
- if(defined('DB::USE_ANSI_SQL')) {
- $order = '"BlogEntry"."Date" DESC';
- } else {
- $order = '`BlogEntry`.`Date` DESC';
- }
+ $order = '"BlogEntry"."Date" DESC';
// By specifying a callback, you can alter the SQL, or sort on something other than date.
- if ($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit, $order);
+ if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit, $order);
else return DataObject::get('BlogEntry', $where, $order, '', $limit);
}
}
-class BlogURL {
+class BlogTree_URL {
static function tag() {
if (Director::urlParam('Action') == 'tag') return Director::urlParam('ID');
return '';
@@ -230,10 +199,9 @@ class BlogURL {
$year = Director::urlParam('Action');
$month = Director::urlParam('ID');
- if ($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
+ if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
return "$year-$month";
- }
- elseif (is_numeric($year)) {
+ } elseif (is_numeric($year)) {
return $year;
}
@@ -256,10 +224,10 @@ class BlogTree_Controller extends Page_Controller {
}
function BlogEntries($limit = null) {
- if ($limit === null) $limit = BlogTree::$default_entries_limit;
+ if($limit === null) $limit = BlogTree::$default_entries_limit;
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
- return $this->Entries("$start,$limit", BlogURL::tag(), BlogURL::date());
+ return $this->Entries("$start,$limit", BlogTree_URL::tag(), BlogTree_URL::date());
}
function IncludeBlogRSS() {
@@ -267,40 +235,6 @@ class BlogTree_Controller extends Page_Controller {
RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
}
- /*
- * @todo: It doesn't look like these are used. Remove if no-one complains - Hamish
-
- /**
- * Gets the archived blogs for a particular month or year, in the format /year/month/ eg: /2008/10/
- * /
- function showarchive() {
- $month = addslashes($this->urlParams['ID']);
- return array(
- "Children" => DataObject::get('SiteTree', "ParentID = $this->ID AND DATE_FORMAT(`BlogEntry`.`Date`, '%Y-%M') = '$month'"),
- );
- }
-
- function ArchiveMonths() {
- $months = DB::query("SELECT DISTINCT DATE_FORMAT(`BlogEntry`.`Date`, '%M') AS `Month`, DATE_FORMAT(`BlogEntry`.`Date`, '%Y') AS `Year` FROM `BlogEntry` ORDER BY `BlogEntry`.`Date` DESC");
- $output = new DataObjectSet();
- foreach($months as $month) {
- $month['Link'] = $this->Link() . "showarchive/$month[Year]-$month[Month]";
- $output->push(new ArrayData($month));
- }
-
- return $output;
- }
-
- function tag() {
- if (Director::urlParam('Action') == 'tag') {
- return array(
- 'Tag' => Convert::raw2xml(Director::urlParam('ID'))
- );
- }
- return array();
- }
- */
-
/**
* Get the rss feed for this blog holder's entries
*/
@@ -325,3 +259,5 @@ class BlogTree_Controller extends Page_Controller {
return parent::defaultAction($action);
}
}
+
+?>
diff --git a/code/RSSWidget.php b/code/RSSWidget.php
index 6578411..4dfd6fc 100644
--- a/code/RSSWidget.php
+++ b/code/RSSWidget.php
@@ -6,6 +6,7 @@ class RSSWidget extends Widget {
"RssUrl" => "Text",
"NumberToShow" => "Int"
);
+
static $has_one = array();
static $has_many = array();
diff --git a/code/SubscribeRSSWidget.php b/code/SubscribeRSSWidget.php
index f2725e2..74fec7b 100644
--- a/code/SubscribeRSSWidget.php
+++ b/code/SubscribeRSSWidget.php
@@ -26,7 +26,6 @@ class SubscribeRSSWidget extends Widget {
$container = BlogTree::current();
if ($container) return $container->Link() . 'rss';
}
-
}
-?>
\ No newline at end of file
+?>
diff --git a/code/TagCloudWidget.php b/code/TagCloudWidget.php
index 1bc7757..4e120db 100644
--- a/code/TagCloudWidget.php
+++ b/code/TagCloudWidget.php
@@ -101,7 +101,8 @@ class TagCloudWidget extends Widget {
foreach($allTags as $tag => $fields) {
$output->push(new ArrayData($fields));
}
- return $output;
+
+ return $output;
}
return;
@@ -137,5 +138,4 @@ class TagCloudWidget extends Widget {
}
-
?>
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index 73c1a1d..67dd5d8 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -49,5 +49,4 @@ class TrackBackDecorator extends DataObjectDecorator {
}
}
-
?>
From 67b159eab8939af9f95117e1d7fd5064600c8080 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Mon, 30 Nov 2009 08:20:46 +0000
Subject: [PATCH 181/250] APICHANGE: WYSIWYG editing by default
---
code/BlogEntry.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 6688932..c02e0f0 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -40,7 +40,7 @@ class BlogEntry extends Page {
* Is WYSIWYG editing allowed?
* @var boolean
*/
- static $allow_wysiwyg_editing = false;
+ static $allow_wysiwyg_editing = true;
/**
* Is WYSIWYG editing enabled?
From 5220e0673745451ad73140fddef3a0eed739e563 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Mon, 30 Nov 2009 11:04:26 +0000
Subject: [PATCH 182/250] FEATURE: Preliminary MetaWeblog support
---
_config.php | 4 +
code/BlogHolder.php | 1 +
code/MetaWeblogController.php | 106 +
code/{ => widgets}/ArchiveWidget.php | 0
code/{ => widgets}/BlogManagementWidget.php | 0
code/{ => widgets}/RSSWidget.php | 0
code/{ => widgets}/SubscribeRSSWidget.php | 0
code/{ => widgets}/TagCloudWidget.php | 0
thirdparty/xmlrpc/xmlrpc.php | 3718 +++++++++++++++++++
thirdparty/xmlrpc/xmlrpc_wrappers.php | 944 +++++
thirdparty/xmlrpc/xmlrpcs.php | 1198 ++++++
11 files changed, 5971 insertions(+)
create mode 100644 code/MetaWeblogController.php
rename code/{ => widgets}/ArchiveWidget.php (100%)
rename code/{ => widgets}/BlogManagementWidget.php (100%)
rename code/{ => widgets}/RSSWidget.php (100%)
rename code/{ => widgets}/SubscribeRSSWidget.php (100%)
rename code/{ => widgets}/TagCloudWidget.php (100%)
create mode 100644 thirdparty/xmlrpc/xmlrpc.php
create mode 100644 thirdparty/xmlrpc/xmlrpc_wrappers.php
create mode 100644 thirdparty/xmlrpc/xmlrpcs.php
diff --git a/_config.php b/_config.php
index 62a2de0..fb76338 100644
--- a/_config.php
+++ b/_config.php
@@ -1,3 +1,7 @@
'MetaWeblogController'
+));
+
?>
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index f08a76b..36e7e99 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -131,6 +131,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
'index',
'tag',
+ 'metaweblog',
'postblog' => 'BLOGMANAGEMENT',
'post' => 'BLOGMANAGEMENT',
'BlogEntryForm' => 'BLOGMANAGEMENT',
diff --git a/code/MetaWeblogController.php b/code/MetaWeblogController.php
new file mode 100644
index 0000000..0b4041e
--- /dev/null
+++ b/code/MetaWeblogController.php
@@ -0,0 +1,106 @@
+ array(
+ "function" => array($this, "getUsersBlogs")
+ ),
+ "metaWeblog.getRecentPosts" => array(
+ 'function' => array($this, 'getRecentPosts')
+ ),
+ 'metaWeblog.getCategories' => array(
+ 'function' => array($this, 'getCategories')
+ )
+ ), false);
+
+ // Use nice php functions, and call the service
+ $service->functions_parameters_type = 'phpvals';
+ $service->service();
+
+ // Tell SilverStripe not to try render a template
+ return false;
+ }
+
+ /**
+ * Get a list of BlogHolders the user has access to.
+ */
+ function getUsersBlogs($appkey, $username, $password) {
+ $member = MemberAuthenticator::authenticate(array(
+ 'Email' => $username,
+ 'Password' => $password,
+ ));
+
+ // TODO Throw approriate error.
+ if(!$member) die();
+
+ $blogholders = DataObject::get('BlogHolder');
+
+ $response = array();
+
+ foreach($blogholders as $bh) {
+ if(!$bh->canAddChildren($member)) continue;
+
+ $bgarr = array();
+ $bgarr['url'] = $bh->AbsoluteLink();
+ $bgarr['blogid'] = (int) $bh->ID;
+ $bgarr['blogname'] = $bh->Title;
+
+ $response[] = $bgarr;
+ }
+
+ return $response;
+ }
+
+ /**
+ * Get the most recent posts on a blog.
+ */
+ function getRecentPosts($blogid, $username, $password, $numberOfPosts) {
+ $member = MemberAuthenticator::authenticate(array(
+ 'Email' => $username,
+ 'Password' => $password,
+ ));
+
+ // TODO Throw approriate error.
+ if(!$member) die();
+
+ $posts = DataObject::get('BlogEntry', '"ParentID" = ' . (int) $blogid, '"Date" DESC');
+
+ $res = array();
+ $postsSoFar = 0;
+
+ foreach($posts as $post) {
+ if(!$post->canEdit($member)) continue;
+
+ $parr = array();
+
+ $parr['title'] = $post->Title;
+ $parr['link'] = $post->AbsoluteLink();
+ $parr['description'] = $post->Content;
+ $parr['postid'] = (int) $post->ID;
+
+ $res[] = $parr;
+
+ if(++$postsSoFar >= $numberOfPosts) break;
+ }
+
+ return $res;
+ }
+
+ function getCategories() {
+ //TODO dummy function
+ return array();
+ }
+}
+
+?>
diff --git a/code/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
similarity index 100%
rename from code/ArchiveWidget.php
rename to code/widgets/ArchiveWidget.php
diff --git a/code/BlogManagementWidget.php b/code/widgets/BlogManagementWidget.php
similarity index 100%
rename from code/BlogManagementWidget.php
rename to code/widgets/BlogManagementWidget.php
diff --git a/code/RSSWidget.php b/code/widgets/RSSWidget.php
similarity index 100%
rename from code/RSSWidget.php
rename to code/widgets/RSSWidget.php
diff --git a/code/SubscribeRSSWidget.php b/code/widgets/SubscribeRSSWidget.php
similarity index 100%
rename from code/SubscribeRSSWidget.php
rename to code/widgets/SubscribeRSSWidget.php
diff --git a/code/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
similarity index 100%
rename from code/TagCloudWidget.php
rename to code/widgets/TagCloudWidget.php
diff --git a/thirdparty/xmlrpc/xmlrpc.php b/thirdparty/xmlrpc/xmlrpc.php
new file mode 100644
index 0000000..21e29a0
--- /dev/null
+++ b/thirdparty/xmlrpc/xmlrpc.php
@@ -0,0 +1,3718 @@
+
+// $Id: xmlrpc.inc,v 1.174 2009/03/16 19:36:38 ggiunta Exp $
+
+// Copyright (c) 1999,2000,2002 Edd Dumbill.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// * Neither the name of the "XML-RPC for PHP" nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ if(!function_exists('xml_parser_create'))
+ {
+ // For PHP 4 onward, XML functionality is always compiled-in on windows:
+ // no more need to dl-open it. It might have been compiled out on *nix...
+ if(strtoupper(substr(PHP_OS, 0, 3) != 'WIN'))
+ {
+ dl('xml.so');
+ }
+ }
+
+ // Try to be backward compat with php < 4.2 (are we not being nice ?)
+ $phpversion = phpversion();
+ if($phpversion[0] == '4' && $phpversion[2] < 2)
+ {
+ // give an opportunity to user to specify where to include other files from
+ if(!defined('PHP_XMLRPC_COMPAT_DIR'))
+ {
+ define('PHP_XMLRPC_COMPAT_DIR',dirname(__FILE__).'/compat/');
+ }
+ if($phpversion[2] == '0')
+ {
+ if($phpversion[4] < 6)
+ {
+ include(PHP_XMLRPC_COMPAT_DIR.'is_callable.php');
+ }
+ include(PHP_XMLRPC_COMPAT_DIR.'is_scalar.php');
+ include(PHP_XMLRPC_COMPAT_DIR.'array_key_exists.php');
+ include(PHP_XMLRPC_COMPAT_DIR.'version_compare.php');
+ }
+ include(PHP_XMLRPC_COMPAT_DIR.'var_export.php');
+ include(PHP_XMLRPC_COMPAT_DIR.'is_a.php');
+ }
+
+ // G. Giunta 2005/01/29: declare global these variables,
+ // so that xmlrpc.inc will work even if included from within a function
+ // Milosch: 2005/08/07 - explicitly request these via $GLOBALS where used.
+ $GLOBALS['xmlrpcI4']='i4';
+ $GLOBALS['xmlrpcInt']='int';
+ $GLOBALS['xmlrpcBoolean']='boolean';
+ $GLOBALS['xmlrpcDouble']='double';
+ $GLOBALS['xmlrpcString']='string';
+ $GLOBALS['xmlrpcDateTime']='dateTime.iso8601';
+ $GLOBALS['xmlrpcBase64']='base64';
+ $GLOBALS['xmlrpcArray']='array';
+ $GLOBALS['xmlrpcStruct']='struct';
+ $GLOBALS['xmlrpcValue']='undefined';
+
+ $GLOBALS['xmlrpcTypes']=array(
+ $GLOBALS['xmlrpcI4'] => 1,
+ $GLOBALS['xmlrpcInt'] => 1,
+ $GLOBALS['xmlrpcBoolean'] => 1,
+ $GLOBALS['xmlrpcString'] => 1,
+ $GLOBALS['xmlrpcDouble'] => 1,
+ $GLOBALS['xmlrpcDateTime'] => 1,
+ $GLOBALS['xmlrpcBase64'] => 1,
+ $GLOBALS['xmlrpcArray'] => 2,
+ $GLOBALS['xmlrpcStruct'] => 3
+ );
+
+ $GLOBALS['xmlrpc_valid_parents'] = array(
+ 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
+ 'BOOLEAN' => array('VALUE'),
+ 'I4' => array('VALUE'),
+ 'INT' => array('VALUE'),
+ 'STRING' => array('VALUE'),
+ 'DOUBLE' => array('VALUE'),
+ 'DATETIME.ISO8601' => array('VALUE'),
+ 'BASE64' => array('VALUE'),
+ 'MEMBER' => array('STRUCT'),
+ 'NAME' => array('MEMBER'),
+ 'DATA' => array('ARRAY'),
+ 'ARRAY' => array('VALUE'),
+ 'STRUCT' => array('VALUE'),
+ 'PARAM' => array('PARAMS'),
+ 'METHODNAME' => array('METHODCALL'),
+ 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
+ 'FAULT' => array('METHODRESPONSE'),
+ 'NIL' => array('VALUE') // only used when extension activated
+ );
+
+ // define extra types for supporting NULL (useful for json or )
+ $GLOBALS['xmlrpcNull']='null';
+ $GLOBALS['xmlrpcTypes']['null']=1;
+
+ // Not in use anymore since 2.0. Shall we remove it?
+ /// @deprecated
+ $GLOBALS['xmlEntities']=array(
+ 'amp' => '&',
+ 'quot' => '"',
+ 'lt' => '<',
+ 'gt' => '>',
+ 'apos' => "'"
+ );
+
+ // tables used for transcoding different charsets into us-ascii xml
+
+ $GLOBALS['xml_iso88591_Entities']=array();
+ $GLOBALS['xml_iso88591_Entities']['in'] = array();
+ $GLOBALS['xml_iso88591_Entities']['out'] = array();
+ for ($i = 0; $i < 32; $i++)
+ {
+ $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
+ $GLOBALS['xml_iso88591_Entities']['out'][] = ''.$i.';';
+ }
+ for ($i = 160; $i < 256; $i++)
+ {
+ $GLOBALS['xml_iso88591_Entities']['in'][] = chr($i);
+ $GLOBALS['xml_iso88591_Entities']['out'][] = ''.$i.';';
+ }
+
+ /// @todo add to iso table the characters from cp_1252 range, i.e. 128 to 159?
+ /// These will NOT be present in true ISO-8859-1, but will save the unwary
+ /// windows user from sending junk (though no luck when reciving them...)
+ /*
+ $GLOBALS['xml_cp1252_Entities']=array();
+ for ($i = 128; $i < 160; $i++)
+ {
+ $GLOBALS['xml_cp1252_Entities']['in'][] = chr($i);
+ }
+ $GLOBALS['xml_cp1252_Entities']['out'] = array(
+ '€', '?', '‚', 'ƒ',
+ '„', '…', '†', '‡',
+ 'ˆ', '‰', 'Š', '‹',
+ 'Œ', '?', 'Ž', '?',
+ '?', '‘', '’', '“',
+ '”', '•', '–', '—',
+ '˜', '™', 'š', '›',
+ 'œ', '?', 'ž', 'Ÿ'
+ );
+ */
+
+ $GLOBALS['xmlrpcerr'] = array(
+ 'unknown_method'=>1,
+ 'invalid_return'=>2,
+ 'incorrect_params'=>3,
+ 'introspect_unknown'=>4,
+ 'http_error'=>5,
+ 'no_data'=>6,
+ 'no_ssl'=>7,
+ 'curl_fail'=>8,
+ 'invalid_request'=>15,
+ 'no_curl'=>16,
+ 'server_error'=>17,
+ 'multicall_error'=>18,
+ 'multicall_notstruct'=>9,
+ 'multicall_nomethod'=>10,
+ 'multicall_notstring'=>11,
+ 'multicall_recursion'=>12,
+ 'multicall_noparams'=>13,
+ 'multicall_notarray'=>14,
+
+ 'cannot_decompress'=>103,
+ 'decompress_fail'=>104,
+ 'dechunk_fail'=>105,
+ 'server_cannot_decompress'=>106,
+ 'server_decompress_fail'=>107
+ );
+
+ $GLOBALS['xmlrpcstr'] = array(
+ 'unknown_method'=>'Unknown method',
+ 'invalid_return'=>'Invalid return payload: enable debugging to examine incoming payload',
+ 'incorrect_params'=>'Incorrect parameters passed to method',
+ 'introspect_unknown'=>"Can't introspect: method unknown",
+ 'http_error'=>"Didn't receive 200 OK from remote server.",
+ 'no_data'=>'No data received from server.',
+ 'no_ssl'=>'No SSL support compiled in.',
+ 'curl_fail'=>'CURL error',
+ 'invalid_request'=>'Invalid request payload',
+ 'no_curl'=>'No CURL support compiled in.',
+ 'server_error'=>'Internal server error',
+ 'multicall_error'=>'Received from server invalid multicall response',
+ 'multicall_notstruct'=>'system.multicall expected struct',
+ 'multicall_nomethod'=>'missing methodName',
+ 'multicall_notstring'=>'methodName is not a string',
+ 'multicall_recursion'=>'recursive system.multicall forbidden',
+ 'multicall_noparams'=>'missing params',
+ 'multicall_notarray'=>'params is not an array',
+
+ 'cannot_decompress'=>'Received from server compressed HTTP and cannot decompress',
+ 'decompress_fail'=>'Received from server invalid compressed HTTP',
+ 'dechunk_fail'=>'Received from server invalid chunked HTTP',
+ 'server_cannot_decompress'=>'Received from client compressed HTTP request and cannot decompress',
+ 'server_decompress_fail'=>'Received from client invalid compressed HTTP request'
+ );
+
+ // The charset encoding used by the server for received messages and
+ // by the client for received responses when received charset cannot be determined
+ // or is not supported
+ $GLOBALS['xmlrpc_defencoding']='UTF-8';
+
+ // The encoding used internally by PHP.
+ // String values received as xml will be converted to this, and php strings will be converted to xml
+ // as if having been coded with this
+ $GLOBALS['xmlrpc_internalencoding']='ISO-8859-1';
+
+ $GLOBALS['xmlrpcName']='XML-RPC for PHP';
+ $GLOBALS['xmlrpcVersion']='2.2.2';
+
+ // let user errors start at 800
+ $GLOBALS['xmlrpcerruser']=800;
+ // let XML parse errors start at 100
+ $GLOBALS['xmlrpcerrxml']=100;
+
+ // formulate backslashes for escaping regexp
+ // Not in use anymore since 2.0. Shall we remove it?
+ /// @deprecated
+ $GLOBALS['xmlrpc_backslash']=chr(92).chr(92);
+
+ // set to TRUE to enable correct decoding of values
+ $GLOBALS['xmlrpc_null_extension']=false;
+
+ // used to store state during parsing
+ // quick explanation of components:
+ // ac - used to accumulate values
+ // isf - used to indicate a parsing fault (2) or xmlrpcresp fault (1)
+ // isf_reason - used for storing xmlrpcresp fault string
+ // lv - used to indicate "looking for a value": implements
+ // the logic to allow values with no types to be strings
+ // params - used to store parameters in method calls
+ // method - used to store method name
+ // stack - array with genealogy of xml elements names:
+ // used to validate nesting of xmlrpc elements
+ $GLOBALS['_xh']=null;
+
+ /**
+ * Convert a string to the correct XML representation in a target charset
+ * To help correct communication of non-ascii chars inside strings, regardless
+ * of the charset used when sending requests, parsing them, sending responses
+ * and parsing responses, an option is to convert all non-ascii chars present in the message
+ * into their equivalent 'charset entity'. Charset entities enumerated this way
+ * are independent of the charset encoding used to transmit them, and all XML
+ * parsers are bound to understand them.
+ * Note that in the std case we are not sending a charset encoding mime type
+ * along with http headers, so we are bound by RFC 3023 to emit strict us-ascii.
+ *
+ * @todo do a bit of basic benchmarking (strtr vs. str_replace)
+ * @todo make usage of iconv() or recode_string() or mb_string() where available
+ */
+ function xmlrpc_encode_entitites($data, $src_encoding='', $dest_encoding='')
+ {
+ if ($src_encoding == '')
+ {
+ // lame, but we know no better...
+ $src_encoding = $GLOBALS['xmlrpc_internalencoding'];
+ }
+
+ switch(strtoupper($src_encoding.'_'.$dest_encoding))
+ {
+ case 'ISO-8859-1_':
+ case 'ISO-8859-1_US-ASCII':
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data);
+ break;
+ case 'ISO-8859-1_UTF-8':
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ $escaped_data = utf8_encode($escaped_data);
+ break;
+ case 'ISO-8859-1_ISO-8859-1':
+ case 'US-ASCII_US-ASCII':
+ case 'US-ASCII_UTF-8':
+ case 'US-ASCII_':
+ case 'US-ASCII_ISO-8859-1':
+ case 'UTF-8_UTF-8':
+ //case 'CP1252_CP1252':
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ break;
+ case 'UTF-8_':
+ case 'UTF-8_US-ASCII':
+ case 'UTF-8_ISO-8859-1':
+ // NB: this will choke on invalid UTF-8, going most likely beyond EOF
+ $escaped_data = '';
+ // be kind to users creating string xmlrpcvals out of different php types
+ $data = (string) $data;
+ $ns = strlen ($data);
+ for ($nn = 0; $nn < $ns; $nn++)
+ {
+ $ch = $data[$nn];
+ $ii = ord($ch);
+ //1 7 0bbbbbbb (127)
+ if ($ii < 128)
+ {
+ /// @todo shall we replace this with a (supposedly) faster str_replace?
+ switch($ii){
+ case 34:
+ $escaped_data .= '"';
+ break;
+ case 38:
+ $escaped_data .= '&';
+ break;
+ case 39:
+ $escaped_data .= ''';
+ break;
+ case 60:
+ $escaped_data .= '<';
+ break;
+ case 62:
+ $escaped_data .= '>';
+ break;
+ default:
+ $escaped_data .= $ch;
+ } // switch
+ }
+ //2 11 110bbbbb 10bbbbbb (2047)
+ else if ($ii>>5 == 6)
+ {
+ $b1 = ($ii & 31);
+ $ii = ord($data[$nn+1]);
+ $b2 = ($ii & 63);
+ $ii = ($b1 * 64) + $b2;
+ $ent = sprintf ('%d;', $ii);
+ $escaped_data .= $ent;
+ $nn += 1;
+ }
+ //3 16 1110bbbb 10bbbbbb 10bbbbbb
+ else if ($ii>>4 == 14)
+ {
+ $b1 = ($ii & 15);
+ $ii = ord($data[$nn+1]);
+ $b2 = ($ii & 63);
+ $ii = ord($data[$nn+2]);
+ $b3 = ($ii & 63);
+ $ii = ((($b1 * 64) + $b2) * 64) + $b3;
+ $ent = sprintf ('%d;', $ii);
+ $escaped_data .= $ent;
+ $nn += 2;
+ }
+ //4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
+ else if ($ii>>3 == 30)
+ {
+ $b1 = ($ii & 7);
+ $ii = ord($data[$nn+1]);
+ $b2 = ($ii & 63);
+ $ii = ord($data[$nn+2]);
+ $b3 = ($ii & 63);
+ $ii = ord($data[$nn+3]);
+ $b4 = ($ii & 63);
+ $ii = ((((($b1 * 64) + $b2) * 64) + $b3) * 64) + $b4;
+ $ent = sprintf ('%d;', $ii);
+ $escaped_data .= $ent;
+ $nn += 3;
+ }
+ }
+ break;
+/*
+ case 'CP1252_':
+ case 'CP1252_US-ASCII':
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ $escaped_data = str_replace($GLOBALS['xml_iso88591_Entities']['in'], $GLOBALS['xml_iso88591_Entities']['out'], $escaped_data);
+ $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
+ break;
+ case 'CP1252_UTF-8':
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ /// @todo we could use real UTF8 chars here instead of xml entities... (note that utf_8 encode all allone will NOT convert them)
+ $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
+ $escaped_data = utf8_encode($escaped_data);
+ break;
+ case 'CP1252_ISO-8859-1':
+ $escaped_data = str_replace(array('&', '"', "'", '<', '>'), array('&', '"', ''', '<', '>'), $data);
+ // we might as well replave all funky chars with a '?' here, but we are kind and leave it to the receiving application layer to decide what to do with these weird entities...
+ $escaped_data = str_replace($GLOBALS['xml_cp1252_Entities']['in'], $GLOBALS['xml_cp1252_Entities']['out'], $escaped_data);
+ break;
+*/
+ default:
+ $escaped_data = '';
+ error_log("Converting from $src_encoding to $dest_encoding: not supported...");
+ }
+ return $escaped_data;
+ }
+
+ /// xml parser handler function for opening element tags
+ function xmlrpc_se($parser, $name, $attrs, $accept_single_vals=false)
+ {
+ // if invalid xmlrpc already detected, skip all processing
+ if ($GLOBALS['_xh']['isf'] < 2)
+ {
+ // check for correct element nesting
+ // top level element can only be of 2 types
+ /// @todo optimization creep: save this check into a bool variable, instead of using count() every time:
+ /// there is only a single top level element in xml anyway
+ if (count($GLOBALS['_xh']['stack']) == 0)
+ {
+ if ($name != 'METHODRESPONSE' && $name != 'METHODCALL' && (
+ $name != 'VALUE' && !$accept_single_vals))
+ {
+ $GLOBALS['_xh']['isf'] = 2;
+ $GLOBALS['_xh']['isf_reason'] = 'missing top level xmlrpc element';
+ return;
+ }
+ else
+ {
+ $GLOBALS['_xh']['rt'] = strtolower($name);
+ }
+ }
+ else
+ {
+ // not top level element: see if parent is OK
+ $parent = end($GLOBALS['_xh']['stack']);
+ if (!array_key_exists($name, $GLOBALS['xmlrpc_valid_parents']) || !in_array($parent, $GLOBALS['xmlrpc_valid_parents'][$name]))
+ {
+ $GLOBALS['_xh']['isf'] = 2;
+ $GLOBALS['_xh']['isf_reason'] = "xmlrpc element $name cannot be child of $parent";
+ return;
+ }
+ }
+
+ switch($name)
+ {
+ // optimize for speed switch cases: most common cases first
+ case 'VALUE':
+ /// @todo we could check for 2 VALUE elements inside a MEMBER or PARAM element
+ $GLOBALS['_xh']['vt']='value'; // indicator: no value found yet
+ $GLOBALS['_xh']['ac']='';
+ $GLOBALS['_xh']['lv']=1;
+ $GLOBALS['_xh']['php_class']=null;
+ break;
+ case 'I4':
+ case 'INT':
+ case 'STRING':
+ case 'BOOLEAN':
+ case 'DOUBLE':
+ case 'DATETIME.ISO8601':
+ case 'BASE64':
+ if ($GLOBALS['_xh']['vt']!='value')
+ {
+ //two data elements inside a value: an error occurred!
+ $GLOBALS['_xh']['isf'] = 2;
+ $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
+ return;
+ }
+ $GLOBALS['_xh']['ac']=''; // reset the accumulator
+ break;
+ case 'STRUCT':
+ case 'ARRAY':
+ if ($GLOBALS['_xh']['vt']!='value')
+ {
+ //two data elements inside a value: an error occurred!
+ $GLOBALS['_xh']['isf'] = 2;
+ $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
+ return;
+ }
+ // create an empty array to hold child values, and push it onto appropriate stack
+ $cur_val = array();
+ $cur_val['values'] = array();
+ $cur_val['type'] = $name;
+ // check for out-of-band information to rebuild php objs
+ // and in case it is found, save it
+ if (@isset($attrs['PHP_CLASS']))
+ {
+ $cur_val['php_class'] = $attrs['PHP_CLASS'];
+ }
+ $GLOBALS['_xh']['valuestack'][] = $cur_val;
+ $GLOBALS['_xh']['vt']='data'; // be prepared for a data element next
+ break;
+ case 'DATA':
+ if ($GLOBALS['_xh']['vt']!='data')
+ {
+ //two data elements inside a value: an error occurred!
+ $GLOBALS['_xh']['isf'] = 2;
+ $GLOBALS['_xh']['isf_reason'] = "found two data elements inside an array element";
+ return;
+ }
+ case 'METHODCALL':
+ case 'METHODRESPONSE':
+ case 'PARAMS':
+ // valid elements that add little to processing
+ break;
+ case 'METHODNAME':
+ case 'NAME':
+ /// @todo we could check for 2 NAME elements inside a MEMBER element
+ $GLOBALS['_xh']['ac']='';
+ break;
+ case 'FAULT':
+ $GLOBALS['_xh']['isf']=1;
+ break;
+ case 'MEMBER':
+ $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name']=''; // set member name to null, in case we do not find in the xml later on
+ //$GLOBALS['_xh']['ac']='';
+ // Drop trough intentionally
+ case 'PARAM':
+ // clear value type, so we can check later if no value has been passed for this param/member
+ $GLOBALS['_xh']['vt']=null;
+ break;
+ case 'NIL':
+ if ($GLOBALS['xmlrpc_null_extension'])
+ {
+ if ($GLOBALS['_xh']['vt']!='value')
+ {
+ //two data elements inside a value: an error occurred!
+ $GLOBALS['_xh']['isf'] = 2;
+ $GLOBALS['_xh']['isf_reason'] = "$name element following a {$GLOBALS['_xh']['vt']} element inside a single value";
+ return;
+ }
+ $GLOBALS['_xh']['ac']=''; // reset the accumulator
+ break;
+ }
+ // we do not support the extension, so
+ // drop through intentionally
+ default:
+ /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!!
+ $GLOBALS['_xh']['isf'] = 2;
+ $GLOBALS['_xh']['isf_reason'] = "found not-xmlrpc xml element $name";
+ break;
+ }
+
+ // Save current element name to stack, to validate nesting
+ $GLOBALS['_xh']['stack'][] = $name;
+
+ /// @todo optimization creep: move this inside the big switch() above
+ if($name!='VALUE')
+ {
+ $GLOBALS['_xh']['lv']=0;
+ }
+ }
+ }
+
+ /// Used in decoding xml chunks that might represent single xmlrpc values
+ function xmlrpc_se_any($parser, $name, $attrs)
+ {
+ xmlrpc_se($parser, $name, $attrs, true);
+ }
+
+ /// xml parser handler function for close element tags
+ function xmlrpc_ee($parser, $name, $rebuild_xmlrpcvals = true)
+ {
+ if ($GLOBALS['_xh']['isf'] < 2)
+ {
+ // push this element name from stack
+ // NB: if XML validates, correct opening/closing is guaranteed and
+ // we do not have to check for $name == $curr_elem.
+ // we also checked for proper nesting at start of elements...
+ $curr_elem = array_pop($GLOBALS['_xh']['stack']);
+
+ switch($name)
+ {
+ case 'VALUE':
+ // This if() detects if no scalar was inside
+ if ($GLOBALS['_xh']['vt']=='value')
+ {
+ $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
+ $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcString'];
+ }
+
+ if ($rebuild_xmlrpcvals)
+ {
+ // build the xmlrpc val out of the data received, and substitute it
+ $temp =& new xmlrpcval($GLOBALS['_xh']['value'], $GLOBALS['_xh']['vt']);
+ // in case we got info about underlying php class, save it
+ // in the object we're rebuilding
+ if (isset($GLOBALS['_xh']['php_class']))
+ $temp->_php_class = $GLOBALS['_xh']['php_class'];
+ // check if we are inside an array or struct:
+ // if value just built is inside an array, let's move it into array on the stack
+ $vscount = count($GLOBALS['_xh']['valuestack']);
+ if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
+ {
+ $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $temp;
+ }
+ else
+ {
+ $GLOBALS['_xh']['value'] = $temp;
+ }
+ }
+ else
+ {
+ /// @todo this needs to treat correctly php-serialized objects,
+ /// since std deserializing is done by php_xmlrpc_decode,
+ /// which we will not be calling...
+ if (isset($GLOBALS['_xh']['php_class']))
+ {
+ }
+
+ // check if we are inside an array or struct:
+ // if value just built is inside an array, let's move it into array on the stack
+ $vscount = count($GLOBALS['_xh']['valuestack']);
+ if ($vscount && $GLOBALS['_xh']['valuestack'][$vscount-1]['type']=='ARRAY')
+ {
+ $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][] = $GLOBALS['_xh']['value'];
+ }
+ }
+ break;
+ case 'BOOLEAN':
+ case 'I4':
+ case 'INT':
+ case 'STRING':
+ case 'DOUBLE':
+ case 'DATETIME.ISO8601':
+ case 'BASE64':
+ $GLOBALS['_xh']['vt']=strtolower($name);
+ /// @todo: optimization creep - remove the if/elseif cycle below
+ /// since the case() in which we are already did that
+ if ($name=='STRING')
+ {
+ $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
+ }
+ elseif ($name=='DATETIME.ISO8601')
+ {
+ if (!preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $GLOBALS['_xh']['ac']))
+ {
+ error_log('XML-RPC: invalid value received in DATETIME: '.$GLOBALS['_xh']['ac']);
+ }
+ $GLOBALS['_xh']['vt']=$GLOBALS['xmlrpcDateTime'];
+ $GLOBALS['_xh']['value']=$GLOBALS['_xh']['ac'];
+ }
+ elseif ($name=='BASE64')
+ {
+ /// @todo check for failure of base64 decoding / catch warnings
+ $GLOBALS['_xh']['value']=base64_decode($GLOBALS['_xh']['ac']);
+ }
+ elseif ($name=='BOOLEAN')
+ {
+ // special case here: we translate boolean 1 or 0 into PHP
+ // constants true or false.
+ // Strings 'true' and 'false' are accepted, even though the
+ // spec never mentions them (see eg. Blogger api docs)
+ // NB: this simple checks helps a lot sanitizing input, ie no
+ // security problems around here
+ if ($GLOBALS['_xh']['ac']=='1' || strcasecmp($GLOBALS['_xh']['ac'], 'true') == 0)
+ {
+ $GLOBALS['_xh']['value']=true;
+ }
+ else
+ {
+ // log if receiveing something strange, even though we set the value to false anyway
+ if ($GLOBALS['_xh']['ac']!='0' && strcasecmp($GLOBALS['_xh']['ac'], 'false') != 0)
+ error_log('XML-RPC: invalid value received in BOOLEAN: '.$GLOBALS['_xh']['ac']);
+ $GLOBALS['_xh']['value']=false;
+ }
+ }
+ elseif ($name=='DOUBLE')
+ {
+ // we have a DOUBLE
+ // we must check that only 0123456789-. are characters here
+ // NOTE: regexp could be much stricter than this...
+ if (!preg_match('/^[+-eE0123456789 \t.]+$/', $GLOBALS['_xh']['ac']))
+ {
+ /// @todo: find a better way of throwing an error than this!
+ error_log('XML-RPC: non numeric value received in DOUBLE: '.$GLOBALS['_xh']['ac']);
+ $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
+ }
+ else
+ {
+ // it's ok, add it on
+ $GLOBALS['_xh']['value']=(double)$GLOBALS['_xh']['ac'];
+ }
+ }
+ else
+ {
+ // we have an I4/INT
+ // we must check that only 0123456789- are characters here
+ if (!preg_match('/^[+-]?[0123456789 \t]+$/', $GLOBALS['_xh']['ac']))
+ {
+ /// @todo find a better way of throwing an error than this!
+ error_log('XML-RPC: non numeric value received in INT: '.$GLOBALS['_xh']['ac']);
+ $GLOBALS['_xh']['value']='ERROR_NON_NUMERIC_FOUND';
+ }
+ else
+ {
+ // it's ok, add it on
+ $GLOBALS['_xh']['value']=(int)$GLOBALS['_xh']['ac'];
+ }
+ }
+ //$GLOBALS['_xh']['ac']=''; // is this necessary?
+ $GLOBALS['_xh']['lv']=3; // indicate we've found a value
+ break;
+ case 'NAME':
+ $GLOBALS['_xh']['valuestack'][count($GLOBALS['_xh']['valuestack'])-1]['name'] = $GLOBALS['_xh']['ac'];
+ break;
+ case 'MEMBER':
+ //$GLOBALS['_xh']['ac']=''; // is this necessary?
+ // add to array in the stack the last element built,
+ // unless no VALUE was found
+ if ($GLOBALS['_xh']['vt'])
+ {
+ $vscount = count($GLOBALS['_xh']['valuestack']);
+ $GLOBALS['_xh']['valuestack'][$vscount-1]['values'][$GLOBALS['_xh']['valuestack'][$vscount-1]['name']] = $GLOBALS['_xh']['value'];
+ } else
+ error_log('XML-RPC: missing VALUE inside STRUCT in received xml');
+ break;
+ case 'DATA':
+ //$GLOBALS['_xh']['ac']=''; // is this necessary?
+ $GLOBALS['_xh']['vt']=null; // reset this to check for 2 data elements in a row - even if they're empty
+ break;
+ case 'STRUCT':
+ case 'ARRAY':
+ // fetch out of stack array of values, and promote it to current value
+ $curr_val = array_pop($GLOBALS['_xh']['valuestack']);
+ $GLOBALS['_xh']['value'] = $curr_val['values'];
+ $GLOBALS['_xh']['vt']=strtolower($name);
+ if (isset($curr_val['php_class']))
+ {
+ $GLOBALS['_xh']['php_class'] = $curr_val['php_class'];
+ }
+ break;
+ case 'PARAM':
+ // add to array of params the current value,
+ // unless no VALUE was found
+ if ($GLOBALS['_xh']['vt'])
+ {
+ $GLOBALS['_xh']['params'][]=$GLOBALS['_xh']['value'];
+ $GLOBALS['_xh']['pt'][]=$GLOBALS['_xh']['vt'];
+ }
+ else
+ error_log('XML-RPC: missing VALUE inside PARAM in received xml');
+ break;
+ case 'METHODNAME':
+ $GLOBALS['_xh']['method']=preg_replace('/^[\n\r\t ]+/', '', $GLOBALS['_xh']['ac']);
+ break;
+ case 'NIL':
+ if ($GLOBALS['xmlrpc_null_extension'])
+ {
+ $GLOBALS['_xh']['vt']='null';
+ $GLOBALS['_xh']['value']=null;
+ $GLOBALS['_xh']['lv']=3;
+ break;
+ }
+ // drop through intentionally if nil extension not enabled
+ case 'PARAMS':
+ case 'FAULT':
+ case 'METHODCALL':
+ case 'METHORESPONSE':
+ break;
+ default:
+ // End of INVALID ELEMENT!
+ // shall we add an assert here for unreachable code???
+ break;
+ }
+ }
+ }
+
+ /// Used in decoding xmlrpc requests/responses without rebuilding xmlrpc values
+ function xmlrpc_ee_fast($parser, $name)
+ {
+ xmlrpc_ee($parser, $name, false);
+ }
+
+ /// xml parser handler function for character data
+ function xmlrpc_cd($parser, $data)
+ {
+ // skip processing if xml fault already detected
+ if ($GLOBALS['_xh']['isf'] < 2)
+ {
+ // "lookforvalue==3" means that we've found an entire value
+ // and should discard any further character data
+ if($GLOBALS['_xh']['lv']!=3)
+ {
+ // G. Giunta 2006-08-23: useless change of 'lv' from 1 to 2
+ //if($GLOBALS['_xh']['lv']==1)
+ //{
+ // if we've found text and we're just in a then
+ // say we've found a value
+ //$GLOBALS['_xh']['lv']=2;
+ //}
+ // we always initialize the accumulator before starting parsing, anyway...
+ //if(!@isset($GLOBALS['_xh']['ac']))
+ //{
+ // $GLOBALS['_xh']['ac'] = '';
+ //}
+ $GLOBALS['_xh']['ac'].=$data;
+ }
+ }
+ }
+
+ /// xml parser handler function for 'other stuff', ie. not char data or
+ /// element start/end tag. In fact it only gets called on unknown entities...
+ function xmlrpc_dh($parser, $data)
+ {
+ // skip processing if xml fault already detected
+ if ($GLOBALS['_xh']['isf'] < 2)
+ {
+ if(substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
+ {
+ // G. Giunta 2006-08-25: useless change of 'lv' from 1 to 2
+ //if($GLOBALS['_xh']['lv']==1)
+ //{
+ // $GLOBALS['_xh']['lv']=2;
+ //}
+ $GLOBALS['_xh']['ac'].=$data;
+ }
+ }
+ return true;
+ }
+
+ class xmlrpc_client
+ {
+ var $path;
+ var $server;
+ var $port=0;
+ var $method='http';
+ var $errno;
+ var $errstr;
+ var $debug=0;
+ var $username='';
+ var $password='';
+ var $authtype=1;
+ var $cert='';
+ var $certpass='';
+ var $cacert='';
+ var $cacertdir='';
+ var $key='';
+ var $keypass='';
+ var $verifypeer=true;
+ var $verifyhost=1;
+ var $no_multicall=false;
+ var $proxy='';
+ var $proxyport=0;
+ var $proxy_user='';
+ var $proxy_pass='';
+ var $proxy_authtype=1;
+ var $cookies=array();
+ /**
+ * List of http compression methods accepted by the client for responses.
+ * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
+ *
+ * NNB: you can set it to any non-empty array for HTTP11 and HTTPS, since
+ * in those cases it will be up to CURL to decide the compression methods
+ * it supports. You might check for the presence of 'zlib' in the output of
+ * curl_version() to determine wheter compression is supported or not
+ */
+ var $accepted_compression = array();
+ /**
+ * Name of compression scheme to be used for sending requests.
+ * Either null, gzip or deflate
+ */
+ var $request_compression = '';
+ /**
+ * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
+ * http://curl.haxx.se/docs/faq.html#7.3)
+ */
+ var $xmlrpc_curl_handle = null;
+ /// Wheter to use persistent connections for http 1.1 and https
+ var $keepalive = false;
+ /// Charset encodings that can be decoded without problems by the client
+ var $accepted_charset_encodings = array();
+ /// Charset encoding to be used in serializing request. NULL = use ASCII
+ var $request_charset_encoding = '';
+ /**
+ * Decides the content of xmlrpcresp objects returned by calls to send()
+ * valid strings are 'xmlrpcvals', 'phpvals' or 'xml'
+ */
+ var $return_type = 'xmlrpcvals';
+
+ /**
+ * @param string $path either the complete server URL or the PATH part of the xmlrc server URL, e.g. /xmlrpc/server.php
+ * @param string $server the server name / ip address
+ * @param integer $port the port the server is listening on, defaults to 80 or 443 depending on protocol used
+ * @param string $method the http protocol variant: defaults to 'http', 'https' and 'http11' can be used if CURL is installed
+ */
+ function xmlrpc_client($path, $server='', $port='', $method='')
+ {
+ // allow user to specify all params in $path
+ if($server == '' and $port == '' and $method == '')
+ {
+ $parts = parse_url($path);
+ $server = $parts['host'];
+ $path = isset($parts['path']) ? $parts['path'] : '';
+ if(isset($parts['query']))
+ {
+ $path .= '?'.$parts['query'];
+ }
+ if(isset($parts['fragment']))
+ {
+ $path .= '#'.$parts['fragment'];
+ }
+ if(isset($parts['port']))
+ {
+ $port = $parts['port'];
+ }
+ if(isset($parts['scheme']))
+ {
+ $method = $parts['scheme'];
+ }
+ if(isset($parts['user']))
+ {
+ $this->username = $parts['user'];
+ }
+ if(isset($parts['pass']))
+ {
+ $this->password = $parts['pass'];
+ }
+ }
+ if($path == '' || $path[0] != '/')
+ {
+ $this->path='/'.$path;
+ }
+ else
+ {
+ $this->path=$path;
+ }
+ $this->server=$server;
+ if($port != '')
+ {
+ $this->port=$port;
+ }
+ if($method != '')
+ {
+ $this->method=$method;
+ }
+
+ // if ZLIB is enabled, let the client by default accept compressed responses
+ if(function_exists('gzinflate') || (
+ function_exists('curl_init') && (($info = curl_version()) &&
+ ((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
+ ))
+ {
+ $this->accepted_compression = array('gzip', 'deflate');
+ }
+
+ // keepalives: enabled by default ONLY for PHP >= 4.3.8
+ // (see http://curl.haxx.se/docs/faq.html#7.3)
+ if(version_compare(phpversion(), '4.3.8') >= 0)
+ {
+ $this->keepalive = true;
+ }
+
+ // by default the xml parser can support these 3 charset encodings
+ $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
+ }
+
+ /**
+ * Enables/disables the echoing to screen of the xmlrpc responses received
+ * @param integer $debug values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
+ * @access public
+ */
+ function setDebug($in)
+ {
+ $this->debug=$in;
+ }
+
+ /**
+ * Add some http BASIC AUTH credentials, used by the client to authenticate
+ * @param string $u username
+ * @param string $p password
+ * @param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth)
+ * @access public
+ */
+ function setCredentials($u, $p, $t=1)
+ {
+ $this->username=$u;
+ $this->password=$p;
+ $this->authtype=$t;
+ }
+
+ /**
+ * Add a client-side https certificate
+ * @param string $cert
+ * @param string $certpass
+ * @access public
+ */
+ function setCertificate($cert, $certpass)
+ {
+ $this->cert = $cert;
+ $this->certpass = $certpass;
+ }
+
+ /**
+ * Add a CA certificate to verify server with (see man page about
+ * CURLOPT_CAINFO for more details
+ * @param string $cacert certificate file name (or dir holding certificates)
+ * @param bool $is_dir set to true to indicate cacert is a dir. defaults to false
+ * @access public
+ */
+ function setCaCertificate($cacert, $is_dir=false)
+ {
+ if ($is_dir)
+ {
+ $this->cacertdir = $cacert;
+ }
+ else
+ {
+ $this->cacert = $cacert;
+ }
+ }
+
+ /**
+ * Set attributes for SSL communication: private SSL key
+ * NB: does not work in older php/curl installs
+ * Thanks to Daniel Convissor
+ * @param string $key The name of a file containing a private SSL key
+ * @param string $keypass The secret password needed to use the private SSL key
+ * @access public
+ */
+ function setKey($key, $keypass)
+ {
+ $this->key = $key;
+ $this->keypass = $keypass;
+ }
+
+ /**
+ * Set attributes for SSL communication: verify server certificate
+ * @param bool $i enable/disable verification of peer certificate
+ * @access public
+ */
+ function setSSLVerifyPeer($i)
+ {
+ $this->verifypeer = $i;
+ }
+
+ /**
+ * Set attributes for SSL communication: verify match of server cert w. hostname
+ * @param int $i
+ * @access public
+ */
+ function setSSLVerifyHost($i)
+ {
+ $this->verifyhost = $i;
+ }
+
+ /**
+ * Set proxy info
+ * @param string $proxyhost
+ * @param string $proxyport Defaults to 8080 for HTTP and 443 for HTTPS
+ * @param string $proxyusername Leave blank if proxy has public access
+ * @param string $proxypassword Leave blank if proxy has public access
+ * @param int $proxyauthtype set to constant CURLAUTH_NTLM to use NTLM auth with proxy
+ * @access public
+ */
+ function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1)
+ {
+ $this->proxy = $proxyhost;
+ $this->proxyport = $proxyport;
+ $this->proxy_user = $proxyusername;
+ $this->proxy_pass = $proxypassword;
+ $this->proxy_authtype = $proxyauthtype;
+ }
+
+ /**
+ * Enables/disables reception of compressed xmlrpc responses.
+ * Note that enabling reception of compressed responses merely adds some standard
+ * http headers to xmlrpc requests. It is up to the xmlrpc server to return
+ * compressed responses when receiving such requests.
+ * @param string $compmethod either 'gzip', 'deflate', 'any' or ''
+ * @access public
+ */
+ function setAcceptedCompression($compmethod)
+ {
+ if ($compmethod == 'any')
+ $this->accepted_compression = array('gzip', 'deflate');
+ else
+ $this->accepted_compression = array($compmethod);
+ }
+
+ /**
+ * Enables/disables http compression of xmlrpc request.
+ * Take care when sending compressed requests: servers might not support them
+ * (and automatic fallback to uncompressed requests is not yet implemented)
+ * @param string $compmethod either 'gzip', 'deflate' or ''
+ * @access public
+ */
+ function setRequestCompression($compmethod)
+ {
+ $this->request_compression = $compmethod;
+ }
+
+ /**
+ * Adds a cookie to list of cookies that will be sent to server.
+ * NB: setting any param but name and value will turn the cookie into a 'version 1' cookie:
+ * do not do it unless you know what you are doing
+ * @param string $name
+ * @param string $value
+ * @param string $path
+ * @param string $domain
+ * @param int $port
+ * @access public
+ *
+ * @todo check correctness of urlencoding cookie value (copied from php way of doing it...)
+ */
+ function setCookie($name, $value='', $path='', $domain='', $port=null)
+ {
+ $this->cookies[$name]['value'] = urlencode($value);
+ if ($path || $domain || $port)
+ {
+ $this->cookies[$name]['path'] = $path;
+ $this->cookies[$name]['domain'] = $domain;
+ $this->cookies[$name]['port'] = $port;
+ $this->cookies[$name]['version'] = 1;
+ }
+ else
+ {
+ $this->cookies[$name]['version'] = 0;
+ }
+ }
+
+ /**
+ * Send an xmlrpc request
+ * @param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request
+ * @param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply
+ * @param string $method if left unspecified, the http protocol chosen during creation of the object will be used
+ * @return xmlrpcresp
+ * @access public
+ */
+ function& send($msg, $timeout=0, $method='')
+ {
+ // if user deos not specify http protocol, use native method of this client
+ // (i.e. method set during call to constructor)
+ if($method == '')
+ {
+ $method = $this->method;
+ }
+
+ if(is_array($msg))
+ {
+ // $msg is an array of xmlrpcmsg's
+ $r = $this->multicall($msg, $timeout, $method);
+ return $r;
+ }
+ elseif(is_string($msg))
+ {
+ $n =& new xmlrpcmsg('');
+ $n->payload = $msg;
+ $msg = $n;
+ }
+
+ // where msg is an xmlrpcmsg
+ $msg->debug=$this->debug;
+
+ if($method == 'https')
+ {
+ $r =& $this->sendPayloadHTTPS(
+ $msg,
+ $this->server,
+ $this->port,
+ $timeout,
+ $this->username,
+ $this->password,
+ $this->authtype,
+ $this->cert,
+ $this->certpass,
+ $this->cacert,
+ $this->cacertdir,
+ $this->proxy,
+ $this->proxyport,
+ $this->proxy_user,
+ $this->proxy_pass,
+ $this->proxy_authtype,
+ $this->keepalive,
+ $this->key,
+ $this->keypass
+ );
+ }
+ elseif($method == 'http11')
+ {
+ $r =& $this->sendPayloadCURL(
+ $msg,
+ $this->server,
+ $this->port,
+ $timeout,
+ $this->username,
+ $this->password,
+ $this->authtype,
+ null,
+ null,
+ null,
+ null,
+ $this->proxy,
+ $this->proxyport,
+ $this->proxy_user,
+ $this->proxy_pass,
+ $this->proxy_authtype,
+ 'http',
+ $this->keepalive
+ );
+ }
+ else
+ {
+ $r =& $this->sendPayloadHTTP10(
+ $msg,
+ $this->server,
+ $this->port,
+ $timeout,
+ $this->username,
+ $this->password,
+ $this->authtype,
+ $this->proxy,
+ $this->proxyport,
+ $this->proxy_user,
+ $this->proxy_pass,
+ $this->proxy_authtype
+ );
+ }
+
+ return $r;
+ }
+
+ /**
+ * @access private
+ */
+ function &sendPayloadHTTP10($msg, $server, $port, $timeout=0,
+ $username='', $password='', $authtype=1, $proxyhost='',
+ $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1)
+ {
+ if($port==0)
+ {
+ $port=80;
+ }
+
+ // Only create the payload if it was not created previously
+ if(empty($msg->payload))
+ {
+ $msg->createPayload($this->request_charset_encoding);
+ }
+
+ $payload = $msg->payload;
+ // Deflate request body and set appropriate request headers
+ if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
+ {
+ if($this->request_compression == 'gzip')
+ {
+ $a = @gzencode($payload);
+ if($a)
+ {
+ $payload = $a;
+ $encoding_hdr = "Content-Encoding: gzip\r\n";
+ }
+ }
+ else
+ {
+ $a = @gzcompress($payload);
+ if($a)
+ {
+ $payload = $a;
+ $encoding_hdr = "Content-Encoding: deflate\r\n";
+ }
+ }
+ }
+ else
+ {
+ $encoding_hdr = '';
+ }
+
+ // thanks to Grant Rauscher for this
+ $credentials='';
+ if($username!='')
+ {
+ $credentials='Authorization: Basic ' . base64_encode($username . ':' . $password) . "\r\n";
+ if ($authtype != 1)
+ {
+ error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported with HTTP 1.0');
+ }
+ }
+
+ $accepted_encoding = '';
+ if(is_array($this->accepted_compression) && count($this->accepted_compression))
+ {
+ $accepted_encoding = 'Accept-Encoding: ' . implode(', ', $this->accepted_compression) . "\r\n";
+ }
+
+ $proxy_credentials = '';
+ if($proxyhost)
+ {
+ if($proxyport == 0)
+ {
+ $proxyport = 8080;
+ }
+ $connectserver = $proxyhost;
+ $connectport = $proxyport;
+ $uri = 'http://'.$server.':'.$port.$this->path;
+ if($proxyusername != '')
+ {
+ if ($proxyauthtype != 1)
+ {
+ error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported with HTTP 1.0');
+ }
+ $proxy_credentials = 'Proxy-Authorization: Basic ' . base64_encode($proxyusername.':'.$proxypassword) . "\r\n";
+ }
+ }
+ else
+ {
+ $connectserver = $server;
+ $connectport = $port;
+ $uri = $this->path;
+ }
+
+ // Cookie generation, as per rfc2965 (version 1 cookies) or
+ // netscape's rules (version 0 cookies)
+ $cookieheader='';
+ if (count($this->cookies))
+ {
+ $version = '';
+ foreach ($this->cookies as $name => $cookie)
+ {
+ if ($cookie['version'])
+ {
+ $version = ' $Version="' . $cookie['version'] . '";';
+ $cookieheader .= ' ' . $name . '="' . $cookie['value'] . '";';
+ if ($cookie['path'])
+ $cookieheader .= ' $Path="' . $cookie['path'] . '";';
+ if ($cookie['domain'])
+ $cookieheader .= ' $Domain="' . $cookie['domain'] . '";';
+ if ($cookie['port'])
+ $cookieheader .= ' $Port="' . $cookie['port'] . '";';
+ }
+ else
+ {
+ $cookieheader .= ' ' . $name . '=' . $cookie['value'] . ";";
+ }
+ }
+ $cookieheader = 'Cookie:' . $version . substr($cookieheader, 0, -1) . "\r\n";
+ }
+
+ $op= 'POST ' . $uri. " HTTP/1.0\r\n" .
+ 'User-Agent: ' . $GLOBALS['xmlrpcName'] . ' ' . $GLOBALS['xmlrpcVersion'] . "\r\n" .
+ 'Host: '. $server . ':' . $port . "\r\n" .
+ $credentials .
+ $proxy_credentials .
+ $accepted_encoding .
+ $encoding_hdr .
+ 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings) . "\r\n" .
+ $cookieheader .
+ 'Content-Type: ' . $msg->content_type . "\r\nContent-Length: " .
+ strlen($payload) . "\r\n\r\n" .
+ $payload;
+
+ if($this->debug > 1)
+ {
+ print "\n---SENDING---\n" . htmlentities($op) . "\n---END---\n ";
+ // let the client see this now in case http times out...
+ flush();
+ }
+
+ if($timeout>0)
+ {
+ $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr, $timeout);
+ }
+ else
+ {
+ $fp=@fsockopen($connectserver, $connectport, $this->errno, $this->errstr);
+ }
+ if($fp)
+ {
+ if($timeout>0 && function_exists('stream_set_timeout'))
+ {
+ stream_set_timeout($fp, $timeout);
+ }
+ }
+ else
+ {
+ $this->errstr='Connect error: '.$this->errstr;
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr . ' (' . $this->errno . ')');
+ return $r;
+ }
+
+ if(!fputs($fp, $op, strlen($op)))
+ {
+ fclose($fp);
+ $this->errstr='Write error';
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $this->errstr);
+ return $r;
+ }
+ else
+ {
+ // reset errno and errstr on succesful socket connection
+ $this->errstr = '';
+ }
+ // G. Giunta 2005/10/24: close socket before parsing.
+ // should yeld slightly better execution times, and make easier recursive calls (e.g. to follow http redirects)
+ $ipd='';
+ do
+ {
+ // shall we check for $data === FALSE?
+ // as per the manual, it signals an error
+ $ipd.=fread($fp, 32768);
+ } while(!feof($fp));
+ fclose($fp);
+ $r =& $msg->parseResponse($ipd, false, $this->return_type);
+ return $r;
+
+ }
+
+ /**
+ * @access private
+ */
+ function &sendPayloadHTTPS($msg, $server, $port, $timeout=0, $username='',
+ $password='', $authtype=1, $cert='',$certpass='', $cacert='', $cacertdir='',
+ $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1,
+ $keepalive=false, $key='', $keypass='')
+ {
+ $r =& $this->sendPayloadCURL($msg, $server, $port, $timeout, $username,
+ $password, $authtype, $cert, $certpass, $cacert, $cacertdir, $proxyhost, $proxyport,
+ $proxyusername, $proxypassword, $proxyauthtype, 'https', $keepalive, $key, $keypass);
+ return $r;
+ }
+
+ /**
+ * Contributed by Justin Miller
+ * Requires curl to be built into PHP
+ * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
+ * @access private
+ */
+ function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='',
+ $password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='',
+ $proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https',
+ $keepalive=false, $key='', $keypass='')
+ {
+ if(!function_exists('curl_init'))
+ {
+ $this->errstr='CURL unavailable on this install';
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']);
+ return $r;
+ }
+ if($method == 'https')
+ {
+ if(($info = curl_version()) &&
+ ((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version']))))
+ {
+ $this->errstr='SSL unavailable on this install';
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']);
+ return $r;
+ }
+ }
+
+ if($port == 0)
+ {
+ if($method == 'http')
+ {
+ $port = 80;
+ }
+ else
+ {
+ $port = 443;
+ }
+ }
+
+ // Only create the payload if it was not created previously
+ if(empty($msg->payload))
+ {
+ $msg->createPayload($this->request_charset_encoding);
+ }
+
+ // Deflate request body and set appropriate request headers
+ $payload = $msg->payload;
+ if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
+ {
+ if($this->request_compression == 'gzip')
+ {
+ $a = @gzencode($payload);
+ if($a)
+ {
+ $payload = $a;
+ $encoding_hdr = 'Content-Encoding: gzip';
+ }
+ }
+ else
+ {
+ $a = @gzcompress($payload);
+ if($a)
+ {
+ $payload = $a;
+ $encoding_hdr = 'Content-Encoding: deflate';
+ }
+ }
+ }
+ else
+ {
+ $encoding_hdr = '';
+ }
+
+ if($this->debug > 1)
+ {
+ print "\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n ";
+ // let the client see this now in case http times out...
+ flush();
+ }
+
+ if(!$keepalive || !$this->xmlrpc_curl_handle)
+ {
+ $curl = curl_init($method . '://' . $server . ':' . $port . $this->path);
+ if($keepalive)
+ {
+ $this->xmlrpc_curl_handle = $curl;
+ }
+ }
+ else
+ {
+ $curl = $this->xmlrpc_curl_handle;
+ }
+
+ // results into variable
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+
+ if($this->debug)
+ {
+ curl_setopt($curl, CURLOPT_VERBOSE, 1);
+ }
+ curl_setopt($curl, CURLOPT_USERAGENT, $GLOBALS['xmlrpcName'].' '.$GLOBALS['xmlrpcVersion']);
+ // required for XMLRPC: post the data
+ curl_setopt($curl, CURLOPT_POST, 1);
+ // the data
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
+
+ // return the header too
+ curl_setopt($curl, CURLOPT_HEADER, 1);
+
+ // will only work with PHP >= 5.0
+ // NB: if we set an empty string, CURL will add http header indicating
+ // ALL methods it is supporting. This is possibly a better option than
+ // letting the user tell what curl can / cannot do...
+ if(is_array($this->accepted_compression) && count($this->accepted_compression))
+ {
+ //curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression));
+ // empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
+ if (count($this->accepted_compression) == 1)
+ {
+ curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
+ }
+ else
+ curl_setopt($curl, CURLOPT_ENCODING, '');
+ }
+ // extra headers
+ $headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
+ // if no keepalive is wanted, let the server know it in advance
+ if(!$keepalive)
+ {
+ $headers[] = 'Connection: close';
+ }
+ // request compression header
+ if($encoding_hdr)
+ {
+ $headers[] = $encoding_hdr;
+ }
+
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+ // timeout is borked
+ if($timeout)
+ {
+ curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
+ }
+
+ if($username && $password)
+ {
+ curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
+ if (defined('CURLOPT_HTTPAUTH'))
+ {
+ curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype);
+ }
+ else if ($authtype != 1)
+ {
+ error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth is supported by the current PHP/curl install');
+ }
+ }
+
+ if($method == 'https')
+ {
+ // set cert file
+ if($cert)
+ {
+ curl_setopt($curl, CURLOPT_SSLCERT, $cert);
+ }
+ // set cert password
+ if($certpass)
+ {
+ curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass);
+ }
+ // whether to verify remote host's cert
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer);
+ // set ca certificates file/dir
+ if($cacert)
+ {
+ curl_setopt($curl, CURLOPT_CAINFO, $cacert);
+ }
+ if($cacertdir)
+ {
+ curl_setopt($curl, CURLOPT_CAPATH, $cacertdir);
+ }
+ // set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
+ if($key)
+ {
+ curl_setopt($curl, CURLOPT_SSLKEY, $key);
+ }
+ // set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
+ if($keypass)
+ {
+ curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass);
+ }
+ // whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost);
+ }
+
+ // proxy info
+ if($proxyhost)
+ {
+ if($proxyport == 0)
+ {
+ $proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080
+ }
+ curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport);
+ //curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport);
+ if($proxyusername)
+ {
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword);
+ if (defined('CURLOPT_PROXYAUTH'))
+ {
+ curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype);
+ }
+ else if ($proxyauthtype != 1)
+ {
+ error_log('XML-RPC: xmlrpc_client::send: warning. Only Basic auth to proxy is supported by the current PHP/curl install');
+ }
+ }
+ }
+
+ // NB: should we build cookie http headers by hand rather than let CURL do it?
+ // the following code does not honour 'expires', 'path' and 'domain' cookie attributes
+ // set to client obj the the user...
+ if (count($this->cookies))
+ {
+ $cookieheader = '';
+ foreach ($this->cookies as $name => $cookie)
+ {
+ $cookieheader .= $name . '=' . $cookie['value'] . '; ';
+ }
+ curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2));
+ }
+
+ $result = curl_exec($curl);
+
+ if ($this->debug > 1)
+ {
+ print "\n---CURL INFO---\n";
+ foreach(curl_getinfo($curl) as $name => $val)
+ print $name . ': ' . htmlentities($val). "\n";
+ print "---END---\n ";
+ }
+
+ if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'?
+ {
+ $this->errstr='no response';
+ $resp=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl));
+ curl_close($curl);
+ if($keepalive)
+ {
+ $this->xmlrpc_curl_handle = null;
+ }
+ }
+ else
+ {
+ if(!$keepalive)
+ {
+ curl_close($curl);
+ }
+ $resp =& $msg->parseResponse($result, true, $this->return_type);
+ }
+ return $resp;
+ }
+
+ /**
+ * Send an array of request messages and return an array of responses.
+ * Unless $this->no_multicall has been set to true, it will try first
+ * to use one single xmlrpc call to server method system.multicall, and
+ * revert to sending many successive calls in case of failure.
+ * This failure is also stored in $this->no_multicall for subsequent calls.
+ * Unfortunately, there is no server error code universally used to denote
+ * the fact that multicall is unsupported, so there is no way to reliably
+ * distinguish between that and a temporary failure.
+ * If you are sure that server supports multicall and do not want to
+ * fallback to using many single calls, set the fourth parameter to FALSE.
+ *
+ * NB: trying to shoehorn extra functionality into existing syntax has resulted
+ * in pretty much convoluted code...
+ *
+ * @param array $msgs an array of xmlrpcmsg objects
+ * @param integer $timeout connection timeout (in seconds)
+ * @param string $method the http protocol variant to be used
+ * @param boolean fallback When true, upon receiveing an error during multicall, multiple single calls will be attempted
+ * @return array
+ * @access public
+ */
+ function multicall($msgs, $timeout=0, $method='', $fallback=true)
+ {
+ if ($method == '')
+ {
+ $method = $this->method;
+ }
+ if(!$this->no_multicall)
+ {
+ $results = $this->_try_multicall($msgs, $timeout, $method);
+ if(is_array($results))
+ {
+ // System.multicall succeeded
+ return $results;
+ }
+ else
+ {
+ // either system.multicall is unsupported by server,
+ // or call failed for some other reason.
+ if ($fallback)
+ {
+ // Don't try it next time...
+ $this->no_multicall = true;
+ }
+ else
+ {
+ if (is_a($results, 'xmlrpcresp'))
+ {
+ $result = $results;
+ }
+ else
+ {
+ $result =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['multicall_error'], $GLOBALS['xmlrpcstr']['multicall_error']);
+ }
+ }
+ }
+ }
+ else
+ {
+ // override fallback, in case careless user tries to do two
+ // opposite things at the same time
+ $fallback = true;
+ }
+
+ $results = array();
+ if ($fallback)
+ {
+ // system.multicall is (probably) unsupported by server:
+ // emulate multicall via multiple requests
+ foreach($msgs as $msg)
+ {
+ $results[] =& $this->send($msg, $timeout, $method);
+ }
+ }
+ else
+ {
+ // user does NOT want to fallback on many single calls:
+ // since we should always return an array of responses,
+ // return an array with the same error repeated n times
+ foreach($msgs as $msg)
+ {
+ $results[] = $result;
+ }
+ }
+ return $results;
+ }
+
+ /**
+ * Attempt to boxcar $msgs via system.multicall.
+ * Returns either an array of xmlrpcreponses, an xmlrpc error response
+ * or false (when received response does not respect valid multicall syntax)
+ * @access private
+ */
+ function _try_multicall($msgs, $timeout, $method)
+ {
+ // Construct multicall message
+ $calls = array();
+ foreach($msgs as $msg)
+ {
+ $call['methodName'] =& new xmlrpcval($msg->method(),'string');
+ $numParams = $msg->getNumParams();
+ $params = array();
+ for($i = 0; $i < $numParams; $i++)
+ {
+ $params[$i] = $msg->getParam($i);
+ }
+ $call['params'] =& new xmlrpcval($params, 'array');
+ $calls[] =& new xmlrpcval($call, 'struct');
+ }
+ $multicall =& new xmlrpcmsg('system.multicall');
+ $multicall->addParam(new xmlrpcval($calls, 'array'));
+
+ // Attempt RPC call
+ $result =& $this->send($multicall, $timeout, $method);
+
+ if($result->faultCode() != 0)
+ {
+ // call to system.multicall failed
+ return $result;
+ }
+
+ // Unpack responses.
+ $rets = $result->value();
+
+ if ($this->return_type == 'xml')
+ {
+ return $rets;
+ }
+ else if ($this->return_type == 'phpvals')
+ {
+ ///@todo test this code branch...
+ $rets = $result->value();
+ if(!is_array($rets))
+ {
+ return false; // bad return type from system.multicall
+ }
+ $numRets = count($rets);
+ if($numRets != count($msgs))
+ {
+ return false; // wrong number of return values.
+ }
+
+ $response = array();
+ for($i = 0; $i < $numRets; $i++)
+ {
+ $val = $rets[$i];
+ if (!is_array($val)) {
+ return false;
+ }
+ switch(count($val))
+ {
+ case 1:
+ if(!isset($val[0]))
+ {
+ return false; // Bad value
+ }
+ // Normal return value
+ $response[$i] =& new xmlrpcresp($val[0], 0, '', 'phpvals');
+ break;
+ case 2:
+ /// @todo remove usage of @: it is apparently quite slow
+ $code = @$val['faultCode'];
+ if(!is_int($code))
+ {
+ return false;
+ }
+ $str = @$val['faultString'];
+ if(!is_string($str))
+ {
+ return false;
+ }
+ $response[$i] =& new xmlrpcresp(0, $code, $str);
+ break;
+ default:
+ return false;
+ }
+ }
+ return $response;
+ }
+ else // return type == 'xmlrpcvals'
+ {
+ $rets = $result->value();
+ if($rets->kindOf() != 'array')
+ {
+ return false; // bad return type from system.multicall
+ }
+ $numRets = $rets->arraysize();
+ if($numRets != count($msgs))
+ {
+ return false; // wrong number of return values.
+ }
+
+ $response = array();
+ for($i = 0; $i < $numRets; $i++)
+ {
+ $val = $rets->arraymem($i);
+ switch($val->kindOf())
+ {
+ case 'array':
+ if($val->arraysize() != 1)
+ {
+ return false; // Bad value
+ }
+ // Normal return value
+ $response[$i] =& new xmlrpcresp($val->arraymem(0));
+ break;
+ case 'struct':
+ $code = $val->structmem('faultCode');
+ if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int')
+ {
+ return false;
+ }
+ $str = $val->structmem('faultString');
+ if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string')
+ {
+ return false;
+ }
+ $response[$i] =& new xmlrpcresp(0, $code->scalarval(), $str->scalarval());
+ break;
+ default:
+ return false;
+ }
+ }
+ return $response;
+ }
+ }
+ } // end class xmlrpc_client
+
+ class xmlrpcresp
+ {
+ var $val = 0;
+ var $valtyp;
+ var $errno = 0;
+ var $errstr = '';
+ var $payload;
+ var $hdrs = array();
+ var $_cookies = array();
+ var $content_type = 'text/xml';
+ var $raw_data = '';
+
+ /**
+ * @param mixed $val either an xmlrpcval obj, a php value or the xml serialization of an xmlrpcval (a string)
+ * @param integer $fcode set it to anything but 0 to create an error response
+ * @param string $fstr the error string, in case of an error response
+ * @param string $valtyp either 'xmlrpcvals', 'phpvals' or 'xml'
+ *
+ * @todo add check that $val / $fcode / $fstr is of correct type???
+ * NB: as of now we do not do it, since it might be either an xmlrpcval or a plain
+ * php val, or a complete xml chunk, depending on usage of xmlrpc_client::send() inside which creator is called...
+ */
+ function xmlrpcresp($val, $fcode = 0, $fstr = '', $valtyp='')
+ {
+ if($fcode != 0)
+ {
+ // error response
+ $this->errno = $fcode;
+ $this->errstr = $fstr;
+ //$this->errstr = htmlspecialchars($fstr); // XXX: encoding probably shouldn't be done here; fix later.
+ }
+ else
+ {
+ // successful response
+ $this->val = $val;
+ if ($valtyp == '')
+ {
+ // user did not declare type of response value: try to guess it
+ if (is_object($this->val) && is_a($this->val, 'xmlrpcval'))
+ {
+ $this->valtyp = 'xmlrpcvals';
+ }
+ else if (is_string($this->val))
+ {
+ $this->valtyp = 'xml';
+
+ }
+ else
+ {
+ $this->valtyp = 'phpvals';
+ }
+ }
+ else
+ {
+ // user declares type of resp value: believe him
+ $this->valtyp = $valtyp;
+ }
+ }
+ }
+
+ /**
+ * Returns the error code of the response.
+ * @return integer the error code of this response (0 for not-error responses)
+ * @access public
+ */
+ function faultCode()
+ {
+ return $this->errno;
+ }
+
+ /**
+ * Returns the error code of the response.
+ * @return string the error string of this response ('' for not-error responses)
+ * @access public
+ */
+ function faultString()
+ {
+ return $this->errstr;
+ }
+
+ /**
+ * Returns the value received by the server.
+ * @return mixed the xmlrpcval object returned by the server. Might be an xml string or php value if the response has been created by specially configured xmlrpc_client objects
+ * @access public
+ */
+ function value()
+ {
+ return $this->val;
+ }
+
+ /**
+ * Returns an array with the cookies received from the server.
+ * Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 = $val2, ...)
+ * with attributes being e.g. 'expires', 'path', domain'.
+ * NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past)
+ * are still present in the array. It is up to the user-defined code to decide
+ * how to use the received cookies, and wheter they have to be sent back with the next
+ * request to the server (using xmlrpc_client::setCookie) or not
+ * @return array array of cookies received from the server
+ * @access public
+ */
+ function cookies()
+ {
+ return $this->_cookies;
+ }
+
+ /**
+ * Returns xml representation of the response. XML prologue not included
+ * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
+ * @return string the xml representation of the response
+ * @access public
+ */
+ function serialize($charset_encoding='')
+ {
+ if ($charset_encoding != '')
+ $this->content_type = 'text/xml; charset=' . $charset_encoding;
+ else
+ $this->content_type = 'text/xml';
+ $result = "\n";
+ if($this->errno)
+ {
+ // G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients
+ // by xml-encoding non ascii chars
+ $result .= "\n" .
+"\nfaultCode \n" . $this->errno .
+" \n \n\nfaultString \n" .
+xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . " \n \n" .
+" \n \n ";
+ }
+ else
+ {
+ if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval'))
+ {
+ if (is_string($this->val) && $this->valtyp == 'xml')
+ {
+ $result .= "\n \n" .
+ $this->val .
+ "\n ";
+ }
+ else
+ {
+ /// @todo try to build something serializable?
+ die('cannot serialize xmlrpcresp objects whose content is native php values');
+ }
+ }
+ else
+ {
+ $result .= "\n \n" .
+ $this->val->serialize($charset_encoding) .
+ "\n ";
+ }
+ }
+ $result .= "\n ";
+ $this->payload = $result;
+ return $result;
+ }
+ }
+
+ class xmlrpcmsg
+ {
+ var $payload;
+ var $methodname;
+ var $params=array();
+ var $debug=0;
+ var $content_type = 'text/xml';
+
+ /**
+ * @param string $meth the name of the method to invoke
+ * @param array $pars array of parameters to be paased to the method (xmlrpcval objects)
+ */
+ function xmlrpcmsg($meth, $pars=0)
+ {
+ $this->methodname=$meth;
+ if(is_array($pars) && count($pars)>0)
+ {
+ for($i=0; $iaddParam($pars[$i]);
+ }
+ }
+ }
+
+ /**
+ * @access private
+ */
+ function xml_header($charset_encoding='')
+ {
+ if ($charset_encoding != '')
+ {
+ return "\n\n";
+ }
+ else
+ {
+ return "\n\n";
+ }
+ }
+
+ /**
+ * @access private
+ */
+ function xml_footer()
+ {
+ return ' ';
+ }
+
+ /**
+ * @access private
+ */
+ function kindOf()
+ {
+ return 'msg';
+ }
+
+ /**
+ * @access private
+ */
+ function createPayload($charset_encoding='')
+ {
+ if ($charset_encoding != '')
+ $this->content_type = 'text/xml; charset=' . $charset_encoding;
+ else
+ $this->content_type = 'text/xml';
+ $this->payload=$this->xml_header($charset_encoding);
+ $this->payload.='' . $this->methodname . " \n";
+ $this->payload.="\n";
+ for($i=0; $iparams); $i++)
+ {
+ $p=$this->params[$i];
+ $this->payload.=" \n" . $p->serialize($charset_encoding) .
+ "\n";
+ }
+ $this->payload.=" \n";
+ $this->payload.=$this->xml_footer();
+ }
+
+ /**
+ * Gets/sets the xmlrpc method to be invoked
+ * @param string $meth the method to be set (leave empty not to set it)
+ * @return string the method that will be invoked
+ * @access public
+ */
+ function method($meth='')
+ {
+ if($meth!='')
+ {
+ $this->methodname=$meth;
+ }
+ return $this->methodname;
+ }
+
+ /**
+ * Returns xml representation of the message. XML prologue included
+ * @return string the xml representation of the message, xml prologue included
+ * @access public
+ */
+ function serialize($charset_encoding='')
+ {
+ $this->createPayload($charset_encoding);
+ return $this->payload;
+ }
+
+ /**
+ * Add a parameter to the list of parameters to be used upon method invocation
+ * @param xmlrpcval $par
+ * @return boolean false on failure
+ * @access public
+ */
+ function addParam($par)
+ {
+ // add check: do not add to self params which are not xmlrpcvals
+ if(is_object($par) && is_a($par, 'xmlrpcval'))
+ {
+ $this->params[]=$par;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Returns the nth parameter in the message. The index zero-based.
+ * @param integer $i the index of the parameter to fetch (zero based)
+ * @return xmlrpcval the i-th parameter
+ * @access public
+ */
+ function getParam($i) { return $this->params[$i]; }
+
+ /**
+ * Returns the number of parameters in the messge.
+ * @return integer the number of parameters currently set
+ * @access public
+ */
+ function getNumParams() { return count($this->params); }
+
+ /**
+ * Given an open file handle, read all data available and parse it as axmlrpc response.
+ * NB: the file handle is not closed by this function.
+ * NNB: might have trouble in rare cases to work on network streams, as we
+ * check for a read of 0 bytes instead of feof($fp).
+ * But since checking for feof(null) returns false, we would risk an
+ * infinite loop in that case, because we cannot trust the caller
+ * to give us a valid pointer to an open file...
+ * @access public
+ * @return xmlrpcresp
+ * @todo add 2nd & 3rd param to be passed to ParseResponse() ???
+ */
+ function &parseResponseFile($fp)
+ {
+ $ipd='';
+ while($data=fread($fp, 32768))
+ {
+ $ipd.=$data;
+ }
+ //fclose($fp);
+ $r =& $this->parseResponse($ipd);
+ return $r;
+ }
+
+ /**
+ * Parses HTTP headers and separates them from data.
+ * @access private
+ */
+ function &parseResponseHeaders(&$data, $headers_processed=false)
+ {
+ // Support "web-proxy-tunelling" connections for https through proxies
+ if(preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data))
+ {
+ // Look for CR/LF or simple LF as line separator,
+ // (even though it is not valid http)
+ $pos = strpos($data,"\r\n\r\n");
+ if($pos || is_int($pos))
+ {
+ $bd = $pos+4;
+ }
+ else
+ {
+ $pos = strpos($data,"\n\n");
+ if($pos || is_int($pos))
+ {
+ $bd = $pos+2;
+ }
+ else
+ {
+ // No separation between response headers and body: fault?
+ $bd = 0;
+ }
+ }
+ if ($bd)
+ {
+ // this filters out all http headers from proxy.
+ // maybe we could take them into account, too?
+ $data = substr($data, $bd);
+ }
+ else
+ {
+ error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTPS via proxy error, tunnel connection possibly failed');
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (HTTPS via proxy error, tunnel connection possibly failed)');
+ return $r;
+ }
+ }
+
+ // Strip HTTP 1.1 100 Continue header if present
+ while(preg_match('/^HTTP\/1\.1 1[0-9]{2} /', $data))
+ {
+ $pos = strpos($data, 'HTTP', 12);
+ // server sent a Continue header without any (valid) content following...
+ // give the client a chance to know it
+ if(!$pos && !is_int($pos)) // works fine in php 3, 4 and 5
+ {
+ break;
+ }
+ $data = substr($data, $pos);
+ }
+ if(!preg_match('/^HTTP\/[0-9.]+ 200 /', $data))
+ {
+ $errstr= substr($data, 0, strpos($data, "\n")-1);
+ error_log('XML-RPC: xmlrpcmsg::parseResponse: HTTP error, got response: ' .$errstr);
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['http_error'], $GLOBALS['xmlrpcstr']['http_error']. ' (' . $errstr . ')');
+ return $r;
+ }
+
+ $GLOBALS['_xh']['headers'] = array();
+ $GLOBALS['_xh']['cookies'] = array();
+
+ // be tolerant to usage of \n instead of \r\n to separate headers and data
+ // (even though it is not valid http)
+ $pos = strpos($data,"\r\n\r\n");
+ if($pos || is_int($pos))
+ {
+ $bd = $pos+4;
+ }
+ else
+ {
+ $pos = strpos($data,"\n\n");
+ if($pos || is_int($pos))
+ {
+ $bd = $pos+2;
+ }
+ else
+ {
+ // No separation between response headers and body: fault?
+ // we could take some action here instead of going on...
+ $bd = 0;
+ }
+ }
+ // be tolerant to line endings, and extra empty lines
+ $ar = split("\r?\n", trim(substr($data, 0, $pos)));
+ while(list(,$line) = @each($ar))
+ {
+ // take care of multi-line headers and cookies
+ $arr = explode(':',$line,2);
+ if(count($arr) > 1)
+ {
+ $header_name = strtolower(trim($arr[0]));
+ /// @todo some other headers (the ones that allow a CSV list of values)
+ /// do allow many values to be passed using multiple header lines.
+ /// We should add content to $GLOBALS['_xh']['headers'][$header_name]
+ /// instead of replacing it for those...
+ if ($header_name == 'set-cookie' || $header_name == 'set-cookie2')
+ {
+ if ($header_name == 'set-cookie2')
+ {
+ // version 2 cookies:
+ // there could be many cookies on one line, comma separated
+ $cookies = explode(',', $arr[1]);
+ }
+ else
+ {
+ $cookies = array($arr[1]);
+ }
+ foreach ($cookies as $cookie)
+ {
+ // glue together all received cookies, using a comma to separate them
+ // (same as php does with getallheaders())
+ if (isset($GLOBALS['_xh']['headers'][$header_name]))
+ $GLOBALS['_xh']['headers'][$header_name] .= ', ' . trim($cookie);
+ else
+ $GLOBALS['_xh']['headers'][$header_name] = trim($cookie);
+ // parse cookie attributes, in case user wants to correctly honour them
+ // feature creep: only allow rfc-compliant cookie attributes?
+ // @todo support for server sending multiple time cookie with same name, but using different PATHs
+ $cookie = explode(';', $cookie);
+ foreach ($cookie as $pos => $val)
+ {
+ $val = explode('=', $val, 2);
+ $tag = trim($val[0]);
+ $val = trim(@$val[1]);
+ /// @todo with version 1 cookies, we should strip leading and trailing " chars
+ if ($pos == 0)
+ {
+ $cookiename = $tag;
+ $GLOBALS['_xh']['cookies'][$tag] = array();
+ $GLOBALS['_xh']['cookies'][$cookiename]['value'] = urldecode($val);
+ }
+ else
+ {
+ if ($tag != 'value')
+ {
+ $GLOBALS['_xh']['cookies'][$cookiename][$tag] = $val;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ $GLOBALS['_xh']['headers'][$header_name] = trim($arr[1]);
+ }
+ }
+ elseif(isset($header_name))
+ {
+ /// @todo version1 cookies might span multiple lines, thus breaking the parsing above
+ $GLOBALS['_xh']['headers'][$header_name] .= ' ' . trim($line);
+ }
+ }
+
+ $data = substr($data, $bd);
+
+ if($this->debug && count($GLOBALS['_xh']['headers']))
+ {
+ print '';
+ foreach($GLOBALS['_xh']['headers'] as $header => $value)
+ {
+ print htmlentities("HEADER: $header: $value\n");
+ }
+ foreach($GLOBALS['_xh']['cookies'] as $header => $value)
+ {
+ print htmlentities("COOKIE: $header={$value['value']}\n");
+ }
+ print " \n";
+ }
+
+ // if CURL was used for the call, http headers have been processed,
+ // and dechunking + reinflating have been carried out
+ if(!$headers_processed)
+ {
+ // Decode chunked encoding sent by http 1.1 servers
+ if(isset($GLOBALS['_xh']['headers']['transfer-encoding']) && $GLOBALS['_xh']['headers']['transfer-encoding'] == 'chunked')
+ {
+ if(!$data = decode_chunked($data))
+ {
+ error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to rebuild the chunked data received from server');
+ $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['dechunk_fail'], $GLOBALS['xmlrpcstr']['dechunk_fail']);
+ return $r;
+ }
+ }
+
+ // Decode gzip-compressed stuff
+ // code shamelessly inspired from nusoap library by Dietrich Ayala
+ if(isset($GLOBALS['_xh']['headers']['content-encoding']))
+ {
+ $GLOBALS['_xh']['headers']['content-encoding'] = str_replace('x-', '', $GLOBALS['_xh']['headers']['content-encoding']);
+ if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' || $GLOBALS['_xh']['headers']['content-encoding'] == 'gzip')
+ {
+ // if decoding works, use it. else assume data wasn't gzencoded
+ if(function_exists('gzinflate'))
+ {
+ if($GLOBALS['_xh']['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data))
+ {
+ $data = $degzdata;
+ if($this->debug)
+ print "---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END--- ";
+ }
+ elseif($GLOBALS['_xh']['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
+ {
+ $data = $degzdata;
+ if($this->debug)
+ print "---INFLATED RESPONSE---[".strlen($data)." chars]---\n" . htmlentities($data) . "\n---END--- ";
+ }
+ else
+ {
+ error_log('XML-RPC: xmlrpcmsg::parseResponse: errors occurred when trying to decode the deflated data received from server');
+ $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['decompress_fail'], $GLOBALS['xmlrpcstr']['decompress_fail']);
+ return $r;
+ }
+ }
+ else
+ {
+ error_log('XML-RPC: xmlrpcmsg::parseResponse: the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
+ $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['cannot_decompress'], $GLOBALS['xmlrpcstr']['cannot_decompress']);
+ return $r;
+ }
+ }
+ }
+ } // end of 'if needed, de-chunk, re-inflate response'
+
+ // real stupid hack to avoid PHP 4 complaining about returning NULL by ref
+ $r = null;
+ $r =& $r;
+ return $r;
+ }
+
+ /**
+ * Parse the xmlrpc response contained in the string $data and return an xmlrpcresp object.
+ * @param string $data the xmlrpc response, eventually including http headers
+ * @param bool $headers_processed when true prevents parsing HTTP headers for interpretation of content-encoding and consequent decoding
+ * @param string $return_type decides return type, i.e. content of response->value(). Either 'xmlrpcvals', 'xml' or 'phpvals'
+ * @return xmlrpcresp
+ * @access public
+ */
+ function &parseResponse($data='', $headers_processed=false, $return_type='xmlrpcvals')
+ {
+ if($this->debug)
+ {
+ //by maHo, replaced htmlspecialchars with htmlentities
+ print "---GOT---\n" . htmlentities($data) . "\n---END---\n ";
+ }
+
+ if($data == '')
+ {
+ error_log('XML-RPC: xmlrpcmsg::parseResponse: no response received from server.');
+ $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_data'], $GLOBALS['xmlrpcstr']['no_data']);
+ return $r;
+ }
+
+ $GLOBALS['_xh']=array();
+
+ $raw_data = $data;
+ // parse the HTTP headers of the response, if present, and separate them from data
+ if(substr($data, 0, 4) == 'HTTP')
+ {
+ $r =& $this->parseResponseHeaders($data, $headers_processed);
+ if ($r)
+ {
+ // failed processing of HTTP response headers
+ // save into response obj the full payload received, for debugging
+ $r->raw_data = $data;
+ return $r;
+ }
+ }
+ else
+ {
+ $GLOBALS['_xh']['headers'] = array();
+ $GLOBALS['_xh']['cookies'] = array();
+ }
+
+ if($this->debug)
+ {
+ $start = strpos($data, '', $start);
+ $comments = substr($data, $start, $end-$start);
+ print "---SERVER DEBUG INFO (DECODED) ---\n\t".htmlentities(str_replace("\n", "\n\t", base64_decode($comments)))."\n---END---\n ";
+ }
+ }
+
+ // be tolerant of extra whitespace in response body
+ $data = trim($data);
+
+ /// @todo return an error msg if $data=='' ?
+
+ // be tolerant of junk after methodResponse (e.g. javascript ads automatically inserted by free hosts)
+ // idea from Luca Mariano originally in PEARified version of the lib
+ $bd = false;
+ // Poor man's version of strrpos for php 4...
+ $pos = strpos($data, '');
+ while($pos || is_int($pos))
+ {
+ $bd = $pos+17;
+ $pos = strpos($data, '', $bd);
+ }
+ if($bd)
+ {
+ $data = substr($data, 0, $bd);
+ }
+
+ // if user wants back raw xml, give it to him
+ if ($return_type == 'xml')
+ {
+ $r =& new xmlrpcresp($data, 0, '', 'xml');
+ $r->hdrs = $GLOBALS['_xh']['headers'];
+ $r->_cookies = $GLOBALS['_xh']['cookies'];
+ $r->raw_data = $raw_data;
+ return $r;
+ }
+
+ // try to 'guestimate' the character encoding of the received response
+ $resp_encoding = guess_encoding(@$GLOBALS['_xh']['headers']['content-type'], $data);
+
+ $GLOBALS['_xh']['ac']='';
+ //$GLOBALS['_xh']['qt']=''; //unused...
+ $GLOBALS['_xh']['stack'] = array();
+ $GLOBALS['_xh']['valuestack'] = array();
+ $GLOBALS['_xh']['isf']=0; // 0 = OK, 1 for xmlrpc fault responses, 2 = invalid xmlrpc
+ $GLOBALS['_xh']['isf_reason']='';
+ $GLOBALS['_xh']['rt']=''; // 'methodcall or 'methodresponse'
+
+ // if response charset encoding is not known / supported, try to use
+ // the default encoding and parse the xml anyway, but log a warning...
+ if (!in_array($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
+ // the following code might be better for mb_string enabled installs, but
+ // makes the lib about 200% slower...
+ //if (!is_valid_charset($resp_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
+ {
+ error_log('XML-RPC: xmlrpcmsg::parseResponse: invalid charset encoding of received response: '.$resp_encoding);
+ $resp_encoding = $GLOBALS['xmlrpc_defencoding'];
+ }
+ $parser = xml_parser_create($resp_encoding);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell
+ // the xml parser to give us back data in the expected charset.
+ // What if internal encoding is not in one of the 3 allowed?
+ // we use the broadest one, ie. utf8
+ // This allows to send data which is native in various charset,
+ // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding
+ if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
+ {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
+ }
+ else
+ {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
+ }
+
+ if ($return_type == 'phpvals')
+ {
+ xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
+ }
+ else
+ {
+ xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
+ }
+
+ xml_set_character_data_handler($parser, 'xmlrpc_cd');
+ xml_set_default_handler($parser, 'xmlrpc_dh');
+
+ // first error check: xml not well formed
+ if(!xml_parse($parser, $data, count($data)))
+ {
+ // thanks to Peter Kocks
+ if((xml_get_current_line_number($parser)) == 1)
+ {
+ $errstr = 'XML error at line 1, check URL';
+ }
+ else
+ {
+ $errstr = sprintf('XML error: %s at line %d, column %d',
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser), xml_get_current_column_number($parser));
+ }
+ error_log($errstr);
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'], $GLOBALS['xmlrpcstr']['invalid_return'].' ('.$errstr.')');
+ xml_parser_free($parser);
+ if($this->debug)
+ {
+ print $errstr;
+ }
+ $r->hdrs = $GLOBALS['_xh']['headers'];
+ $r->_cookies = $GLOBALS['_xh']['cookies'];
+ $r->raw_data = $raw_data;
+ return $r;
+ }
+ xml_parser_free($parser);
+ // second error check: xml well formed but not xml-rpc compliant
+ if ($GLOBALS['_xh']['isf'] > 1)
+ {
+ if ($this->debug)
+ {
+ /// @todo echo something for user?
+ }
+
+ $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'],
+ $GLOBALS['xmlrpcstr']['invalid_return'] . ' ' . $GLOBALS['_xh']['isf_reason']);
+ }
+ // third error check: parsing of the response has somehow gone boink.
+ // NB: shall we omit this check, since we trust the parsing code?
+ elseif ($return_type == 'xmlrpcvals' && !is_object($GLOBALS['_xh']['value']))
+ {
+ // something odd has happened
+ // and it's time to generate a client side error
+ // indicating something odd went on
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_return'],
+ $GLOBALS['xmlrpcstr']['invalid_return']);
+ }
+ else
+ {
+ if ($this->debug)
+ {
+ print "---PARSED---\n";
+ // somehow htmlentities chokes on var_export, and some full html string...
+ //print htmlentitites(var_export($GLOBALS['_xh']['value'], true));
+ print htmlspecialchars(var_export($GLOBALS['_xh']['value'], true));
+ print "\n---END--- ";
+ }
+
+ // note that using =& will raise an error if $GLOBALS['_xh']['st'] does not generate an object.
+ $v =& $GLOBALS['_xh']['value'];
+
+ if($GLOBALS['_xh']['isf'])
+ {
+ /// @todo we should test here if server sent an int and a string,
+ /// and/or coerce them into such...
+ if ($return_type == 'xmlrpcvals')
+ {
+ $errno_v = $v->structmem('faultCode');
+ $errstr_v = $v->structmem('faultString');
+ $errno = $errno_v->scalarval();
+ $errstr = $errstr_v->scalarval();
+ }
+ else
+ {
+ $errno = $v['faultCode'];
+ $errstr = $v['faultString'];
+ }
+
+ if($errno == 0)
+ {
+ // FAULT returned, errno needs to reflect that
+ $errno = -1;
+ }
+
+ $r =& new xmlrpcresp(0, $errno, $errstr);
+ }
+ else
+ {
+ $r=&new xmlrpcresp($v, 0, '', $return_type);
+ }
+ }
+
+ $r->hdrs = $GLOBALS['_xh']['headers'];
+ $r->_cookies = $GLOBALS['_xh']['cookies'];
+ $r->raw_data = $raw_data;
+ return $r;
+ }
+ }
+
+ class xmlrpcval
+ {
+ var $me=array();
+ var $mytype=0;
+ var $_php_class=null;
+
+ /**
+ * @param mixed $val
+ * @param string $type any valid xmlrpc type name (lowercase). If null, 'string' is assumed
+ */
+ function xmlrpcval($val=-1, $type='')
+ {
+ /// @todo: optimization creep - do not call addXX, do it all inline.
+ /// downside: booleans will not be coerced anymore
+ if($val!==-1 || $type!='')
+ {
+ // optimization creep: inlined all work done by constructor
+ switch($type)
+ {
+ case '':
+ $this->mytype=1;
+ $this->me['string']=$val;
+ break;
+ case 'i4':
+ case 'int':
+ case 'double':
+ case 'string':
+ case 'boolean':
+ case 'dateTime.iso8601':
+ case 'base64':
+ case 'null':
+ $this->mytype=1;
+ $this->me[$type]=$val;
+ break;
+ case 'array':
+ $this->mytype=2;
+ $this->me['array']=$val;
+ break;
+ case 'struct':
+ $this->mytype=3;
+ $this->me['struct']=$val;
+ break;
+ default:
+ error_log("XML-RPC: xmlrpcval::xmlrpcval: not a known type ($type)");
+ }
+ /*if($type=='')
+ {
+ $type='string';
+ }
+ if($GLOBALS['xmlrpcTypes'][$type]==1)
+ {
+ $this->addScalar($val,$type);
+ }
+ elseif($GLOBALS['xmlrpcTypes'][$type]==2)
+ {
+ $this->addArray($val);
+ }
+ elseif($GLOBALS['xmlrpcTypes'][$type]==3)
+ {
+ $this->addStruct($val);
+ }*/
+ }
+ }
+
+ /**
+ * Add a single php value to an (unitialized) xmlrpcval
+ * @param mixed $val
+ * @param string $type
+ * @return int 1 or 0 on failure
+ */
+ function addScalar($val, $type='string')
+ {
+ $typeof=@$GLOBALS['xmlrpcTypes'][$type];
+ if($typeof!=1)
+ {
+ error_log("XML-RPC: xmlrpcval::addScalar: not a scalar type ($type)");
+ return 0;
+ }
+
+ // coerce booleans into correct values
+ // NB: we should iether do it for datetimes, integers and doubles, too,
+ // or just plain remove this check, implemnted on booleans only...
+ if($type==$GLOBALS['xmlrpcBoolean'])
+ {
+ if(strcasecmp($val,'true')==0 || $val==1 || ($val==true && strcasecmp($val,'false')))
+ {
+ $val=true;
+ }
+ else
+ {
+ $val=false;
+ }
+ }
+
+ switch($this->mytype)
+ {
+ case 1:
+ error_log('XML-RPC: xmlrpcval::addScalar: scalar xmlrpcval can have only one value');
+ return 0;
+ case 3:
+ error_log('XML-RPC: xmlrpcval::addScalar: cannot add anonymous scalar to struct xmlrpcval');
+ return 0;
+ case 2:
+ // we're adding a scalar value to an array here
+ //$ar=$this->me['array'];
+ //$ar[]=&new xmlrpcval($val, $type);
+ //$this->me['array']=$ar;
+ // Faster (?) avoid all the costly array-copy-by-val done here...
+ $this->me['array'][]=&new xmlrpcval($val, $type);
+ return 1;
+ default:
+ // a scalar, so set the value and remember we're scalar
+ $this->me[$type]=$val;
+ $this->mytype=$typeof;
+ return 1;
+ }
+ }
+
+ /**
+ * Add an array of xmlrpcval objects to an xmlrpcval
+ * @param array $vals
+ * @return int 1 or 0 on failure
+ * @access public
+ *
+ * @todo add some checking for $vals to be an array of xmlrpcvals?
+ */
+ function addArray($vals)
+ {
+ if($this->mytype==0)
+ {
+ $this->mytype=$GLOBALS['xmlrpcTypes']['array'];
+ $this->me['array']=$vals;
+ return 1;
+ }
+ elseif($this->mytype==2)
+ {
+ // we're adding to an array here
+ $this->me['array'] = array_merge($this->me['array'], $vals);
+ return 1;
+ }
+ else
+ {
+ error_log('XML-RPC: xmlrpcval::addArray: already initialized as a [' . $this->kindOf() . ']');
+ return 0;
+ }
+ }
+
+ /**
+ * Add an array of named xmlrpcval objects to an xmlrpcval
+ * @param array $vals
+ * @return int 1 or 0 on failure
+ * @access public
+ *
+ * @todo add some checking for $vals to be an array?
+ */
+ function addStruct($vals)
+ {
+ if($this->mytype==0)
+ {
+ $this->mytype=$GLOBALS['xmlrpcTypes']['struct'];
+ $this->me['struct']=$vals;
+ return 1;
+ }
+ elseif($this->mytype==3)
+ {
+ // we're adding to a struct here
+ $this->me['struct'] = array_merge($this->me['struct'], $vals);
+ return 1;
+ }
+ else
+ {
+ error_log('XML-RPC: xmlrpcval::addStruct: already initialized as a [' . $this->kindOf() . ']');
+ return 0;
+ }
+ }
+
+ // poor man's version of print_r ???
+ // DEPRECATED!
+ function dump($ar)
+ {
+ foreach($ar as $key => $val)
+ {
+ echo "$key => $val ";
+ if($key == 'array')
+ {
+ while(list($key2, $val2) = each($val))
+ {
+ echo "-- $key2 => $val2 ";
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns a string containing "struct", "array" or "scalar" describing the base type of the value
+ * @return string
+ * @access public
+ */
+ function kindOf()
+ {
+ switch($this->mytype)
+ {
+ case 3:
+ return 'struct';
+ break;
+ case 2:
+ return 'array';
+ break;
+ case 1:
+ return 'scalar';
+ break;
+ default:
+ return 'undef';
+ }
+ }
+
+ /**
+ * @access private
+ */
+ function serializedata($typ, $val, $charset_encoding='')
+ {
+ $rs='';
+ switch(@$GLOBALS['xmlrpcTypes'][$typ])
+ {
+ case 1:
+ switch($typ)
+ {
+ case $GLOBALS['xmlrpcBase64']:
+ $rs.="<${typ}>" . base64_encode($val) . "${typ}>";
+ break;
+ case $GLOBALS['xmlrpcBoolean']:
+ $rs.="<${typ}>" . ($val ? '1' : '0') . "${typ}>";
+ break;
+ case $GLOBALS['xmlrpcString']:
+ // G. Giunta 2005/2/13: do NOT use htmlentities, since
+ // it will produce named html entities, which are invalid xml
+ $rs.="<${typ}>" . xmlrpc_encode_entitites($val, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding). "${typ}>";
+ break;
+ case $GLOBALS['xmlrpcInt']:
+ case $GLOBALS['xmlrpcI4']:
+ $rs.="<${typ}>".(int)$val."${typ}>";
+ break;
+ case $GLOBALS['xmlrpcDouble']:
+ // avoid using standard conversion of float to string because it is locale-dependent,
+ // and also because the xmlrpc spec forbids exponential notation
+ // sprintf('%F') would be most likely ok but it is only available since PHP 4.3.10 and PHP 5.0.3.
+ // The code below tries its best at keeping max precision while avoiding exp notation,
+ // but there is of course no limit in the number of decimal places to be used...
+ $rs.="<${typ}>".preg_replace('/\\.?0+$/','',number_format((double)$val, 128, '.', ''))."${typ}>";
+ break;
+ case $GLOBALS['xmlrpcNull']:
+ $rs.=" ";
+ break;
+ default:
+ // no standard type value should arrive here, but provide a possibility
+ // for xmlrpcvals of unknown type...
+ $rs.="<${typ}>${val}${typ}>";
+ }
+ break;
+ case 3:
+ // struct
+ if ($this->_php_class)
+ {
+ $rs.='\n";
+ }
+ else
+ {
+ $rs.="\n";
+ }
+ foreach($val as $key2 => $val2)
+ {
+ $rs.=''.xmlrpc_encode_entitites($key2, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)." \n";
+ //$rs.=$this->serializeval($val2);
+ $rs.=$val2->serialize($charset_encoding);
+ $rs.=" \n";
+ }
+ $rs.=' ';
+ break;
+ case 2:
+ // array
+ $rs.="\n\n";
+ for($i=0; $iserializeval($val[$i]);
+ $rs.=$val[$i]->serialize($charset_encoding);
+ }
+ $rs.=" \n ";
+ break;
+ default:
+ break;
+ }
+ return $rs;
+ }
+
+ /**
+ * Returns xml representation of the value. XML prologue not included
+ * @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
+ * @return string
+ * @access public
+ */
+ function serialize($charset_encoding='')
+ {
+ // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
+ //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
+ //{
+ reset($this->me);
+ list($typ, $val) = each($this->me);
+ return '' . $this->serializedata($typ, $val, $charset_encoding) . " \n";
+ //}
+ }
+
+ // DEPRECATED
+ function serializeval($o)
+ {
+ // add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
+ //if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
+ //{
+ $ar=$o->me;
+ reset($ar);
+ list($typ, $val) = each($ar);
+ return '' . $this->serializedata($typ, $val) . " \n";
+ //}
+ }
+
+ /**
+ * Checks wheter a struct member with a given name is present.
+ * Works only on xmlrpcvals of type struct.
+ * @param string $m the name of the struct member to be looked up
+ * @return boolean
+ * @access public
+ */
+ function structmemexists($m)
+ {
+ return array_key_exists($m, $this->me['struct']);
+ }
+
+ /**
+ * Returns the value of a given struct member (an xmlrpcval object in itself).
+ * Will raise a php warning if struct member of given name does not exist
+ * @param string $m the name of the struct member to be looked up
+ * @return xmlrpcval
+ * @access public
+ */
+ function structmem($m)
+ {
+ return $this->me['struct'][$m];
+ }
+
+ /**
+ * Reset internal pointer for xmlrpcvals of type struct.
+ * @access public
+ */
+ function structreset()
+ {
+ reset($this->me['struct']);
+ }
+
+ /**
+ * Return next member element for xmlrpcvals of type struct.
+ * @return xmlrpcval
+ * @access public
+ */
+ function structeach()
+ {
+ return each($this->me['struct']);
+ }
+
+ // DEPRECATED! this code looks like it is very fragile and has not been fixed
+ // for a long long time. Shall we remove it for 2.0?
+ function getval()
+ {
+ // UNSTABLE
+ reset($this->me);
+ list($a,$b)=each($this->me);
+ // contributed by I Sofer, 2001-03-24
+ // add support for nested arrays to scalarval
+ // i've created a new method here, so as to
+ // preserve back compatibility
+
+ if(is_array($b))
+ {
+ @reset($b);
+ while(list($id,$cont) = @each($b))
+ {
+ $b[$id] = $cont->scalarval();
+ }
+ }
+
+ // add support for structures directly encoding php objects
+ if(is_object($b))
+ {
+ $t = get_object_vars($b);
+ @reset($t);
+ while(list($id,$cont) = @each($t))
+ {
+ $t[$id] = $cont->scalarval();
+ }
+ @reset($t);
+ while(list($id,$cont) = @each($t))
+ {
+ @$b->$id = $cont;
+ }
+ }
+ // end contrib
+ return $b;
+ }
+
+ /**
+ * Returns the value of a scalar xmlrpcval
+ * @return mixed
+ * @access public
+ */
+ function scalarval()
+ {
+ reset($this->me);
+ list(,$b)=each($this->me);
+ return $b;
+ }
+
+ /**
+ * Returns the type of the xmlrpcval.
+ * For integers, 'int' is always returned in place of 'i4'
+ * @return string
+ * @access public
+ */
+ function scalartyp()
+ {
+ reset($this->me);
+ list($a,)=each($this->me);
+ if($a==$GLOBALS['xmlrpcI4'])
+ {
+ $a=$GLOBALS['xmlrpcInt'];
+ }
+ return $a;
+ }
+
+ /**
+ * Returns the m-th member of an xmlrpcval of struct type
+ * @param integer $m the index of the value to be retrieved (zero based)
+ * @return xmlrpcval
+ * @access public
+ */
+ function arraymem($m)
+ {
+ return $this->me['array'][$m];
+ }
+
+ /**
+ * Returns the number of members in an xmlrpcval of array type
+ * @return integer
+ * @access public
+ */
+ function arraysize()
+ {
+ return count($this->me['array']);
+ }
+
+ /**
+ * Returns the number of members in an xmlrpcval of struct type
+ * @return integer
+ * @access public
+ */
+ function structsize()
+ {
+ return count($this->me['struct']);
+ }
+ }
+
+
+ // date helpers
+
+ /**
+ * Given a timestamp, return the corresponding ISO8601 encoded string.
+ *
+ * Really, timezones ought to be supported
+ * but the XML-RPC spec says:
+ *
+ * "Don't assume a timezone. It should be specified by the server in its
+ * documentation what assumptions it makes about timezones."
+ *
+ * These routines always assume localtime unless
+ * $utc is set to 1, in which case UTC is assumed
+ * and an adjustment for locale is made when encoding
+ *
+ * @param int $timet (timestamp)
+ * @param int $utc (0 or 1)
+ * @return string
+ */
+ function iso8601_encode($timet, $utc=0)
+ {
+ if(!$utc)
+ {
+ $t=strftime("%Y%m%dT%H:%M:%S", $timet);
+ }
+ else
+ {
+ if(function_exists('gmstrftime'))
+ {
+ // gmstrftime doesn't exist in some versions
+ // of PHP
+ $t=gmstrftime("%Y%m%dT%H:%M:%S", $timet);
+ }
+ else
+ {
+ $t=strftime("%Y%m%dT%H:%M:%S", $timet-date('Z'));
+ }
+ }
+ return $t;
+ }
+
+ /**
+ * Given an ISO8601 date string, return a timet in the localtime, or UTC
+ * @param string $idate
+ * @param int $utc either 0 or 1
+ * @return int (datetime)
+ */
+ function iso8601_decode($idate, $utc=0)
+ {
+ $t=0;
+ if(preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $idate, $regs))
+ {
+ if($utc)
+ {
+ $t=gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ }
+ else
+ {
+ $t=mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ }
+ }
+ return $t;
+ }
+
+ /**
+ * Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types.
+ *
+ * Works with xmlrpc message objects as input, too.
+ *
+ * Given proper options parameter, can rebuild generic php object instances
+ * (provided those have been encoded to xmlrpc format using a corresponding
+ * option in php_xmlrpc_encode())
+ * PLEASE NOTE that rebuilding php objects involves calling their constructor function.
+ * This means that the remote communication end can decide which php code will
+ * get executed on your server, leaving the door possibly open to 'php-injection'
+ * style of attacks (provided you have some classes defined on your server that
+ * might wreak havoc if instances are built outside an appropriate context).
+ * Make sure you trust the remote server/client before eanbling this!
+ *
+ * @author Dan Libby (dan@libby.com)
+ *
+ * @param xmlrpcval $xmlrpc_val
+ * @param array $options if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects
+ * @return mixed
+ */
+ function php_xmlrpc_decode($xmlrpc_val, $options=array())
+ {
+ switch($xmlrpc_val->kindOf())
+ {
+ case 'scalar':
+ if (in_array('extension_api', $options))
+ {
+ reset($xmlrpc_val->me);
+ list($typ,$val) = each($xmlrpc_val->me);
+ switch ($typ)
+ {
+ case 'dateTime.iso8601':
+ $xmlrpc_val->scalar = $val;
+ $xmlrpc_val->xmlrpc_type = 'datetime';
+ $xmlrpc_val->timestamp = iso8601_decode($val);
+ return $xmlrpc_val;
+ case 'base64':
+ $xmlrpc_val->scalar = $val;
+ $xmlrpc_val->type = $typ;
+ return $xmlrpc_val;
+ default:
+ return $xmlrpc_val->scalarval();
+ }
+ }
+ return $xmlrpc_val->scalarval();
+ case 'array':
+ $size = $xmlrpc_val->arraysize();
+ $arr = array();
+ for($i = 0; $i < $size; $i++)
+ {
+ $arr[] = php_xmlrpc_decode($xmlrpc_val->arraymem($i), $options);
+ }
+ return $arr;
+ case 'struct':
+ $xmlrpc_val->structreset();
+ // If user said so, try to rebuild php objects for specific struct vals.
+ /// @todo should we raise a warning for class not found?
+ // shall we check for proper subclass of xmlrpcval instead of
+ // presence of _php_class to detect what we can do?
+ if (in_array('decode_php_objs', $options) && $xmlrpc_val->_php_class != ''
+ && class_exists($xmlrpc_val->_php_class))
+ {
+ $obj = @new $xmlrpc_val->_php_class;
+ while(list($key,$value)=$xmlrpc_val->structeach())
+ {
+ $obj->$key = php_xmlrpc_decode($value, $options);
+ }
+ return $obj;
+ }
+ else
+ {
+ $arr = array();
+ while(list($key,$value)=$xmlrpc_val->structeach())
+ {
+ $arr[$key] = php_xmlrpc_decode($value, $options);
+ }
+ return $arr;
+ }
+ case 'msg':
+ $paramcount = $xmlrpc_val->getNumParams();
+ $arr = array();
+ for($i = 0; $i < $paramcount; $i++)
+ {
+ $arr[] = php_xmlrpc_decode($xmlrpc_val->getParam($i));
+ }
+ return $arr;
+ }
+ }
+
+ // This constant left here only for historical reasons...
+ // it was used to decide if we have to define xmlrpc_encode on our own, but
+ // we do not do it anymore
+ if(function_exists('xmlrpc_decode'))
+ {
+ define('XMLRPC_EPI_ENABLED','1');
+ }
+ else
+ {
+ define('XMLRPC_EPI_ENABLED','0');
+ }
+
+ /**
+ * Takes native php types and encodes them into xmlrpc PHP object format.
+ * It will not re-encode xmlrpcval objects.
+ *
+ * Feature creep -- could support more types via optional type argument
+ * (string => datetime support has been added, ??? => base64 not yet)
+ *
+ * If given a proper options parameter, php object instances will be encoded
+ * into 'special' xmlrpc values, that can later be decoded into php objects
+ * by calling php_xmlrpc_decode() with a corresponding option
+ *
+ * @author Dan Libby (dan@libby.com)
+ *
+ * @param mixed $php_val the value to be converted into an xmlrpcval object
+ * @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api'
+ * @return xmlrpcval
+ */
+ function &php_xmlrpc_encode($php_val, $options=array())
+ {
+ $type = gettype($php_val);
+ switch($type)
+ {
+ case 'string':
+ if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val))
+ $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
+ else
+ $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
+ break;
+ case 'integer':
+ $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']);
+ break;
+ case 'double':
+ $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcDouble']);
+ break;
+ //
+ // Add support for encoding/decoding of booleans, since they are supported in PHP
+ case 'boolean':
+ $xmlrpc_val =& new xmlrpcval($php_val, $GLOBALS['xmlrpcBoolean']);
+ break;
+ //
+ case 'array':
+ // PHP arrays can be encoded to either xmlrpc structs or arrays,
+ // depending on wheter they are hashes or plain 0..n integer indexed
+ // A shorter one-liner would be
+ // $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1));
+ // but execution time skyrockets!
+ $j = 0;
+ $arr = array();
+ $ko = false;
+ foreach($php_val as $key => $val)
+ {
+ $arr[$key] =& php_xmlrpc_encode($val, $options);
+ if(!$ko && $key !== $j)
+ {
+ $ko = true;
+ }
+ $j++;
+ }
+ if($ko)
+ {
+ $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
+ }
+ else
+ {
+ $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcArray']);
+ }
+ break;
+ case 'object':
+ if(is_a($php_val, 'xmlrpcval'))
+ {
+ $xmlrpc_val = $php_val;
+ }
+ else
+ {
+ $arr = array();
+ while(list($k,$v) = each($php_val))
+ {
+ $arr[$k] = php_xmlrpc_encode($v, $options);
+ }
+ $xmlrpc_val =& new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
+ if (in_array('encode_php_objs', $options))
+ {
+ // let's save original class name into xmlrpcval:
+ // might be useful later on...
+ $xmlrpc_val->_php_class = get_class($php_val);
+ }
+ }
+ break;
+ case 'NULL':
+ if (in_array('extension_api', $options))
+ {
+ $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcString']);
+ }
+ if (in_array('null_extension', $options))
+ {
+ $xmlrpc_val =& new xmlrpcval('', $GLOBALS['xmlrpcNull']);
+ }
+ else
+ {
+ $xmlrpc_val =& new xmlrpcval();
+ }
+ break;
+ case 'resource':
+ if (in_array('extension_api', $options))
+ {
+ $xmlrpc_val =& new xmlrpcval((int)$php_val, $GLOBALS['xmlrpcInt']);
+ }
+ else
+ {
+ $xmlrpc_val =& new xmlrpcval();
+ }
+ // catch "user function", "unknown type"
+ default:
+ // giancarlo pinerolo
+ // it has to return
+ // an empty object in case, not a boolean.
+ $xmlrpc_val =& new xmlrpcval();
+ break;
+ }
+ return $xmlrpc_val;
+ }
+
+ /**
+ * Convert the xml representation of a method response, method request or single
+ * xmlrpc value into the appropriate object (a.k.a. deserialize)
+ * @param string $xml_val
+ * @param array $options
+ * @return mixed false on error, or an instance of either xmlrpcval, xmlrpcmsg or xmlrpcresp
+ */
+ function php_xmlrpc_decode_xml($xml_val, $options=array())
+ {
+ $GLOBALS['_xh'] = array();
+ $GLOBALS['_xh']['ac'] = '';
+ $GLOBALS['_xh']['stack'] = array();
+ $GLOBALS['_xh']['valuestack'] = array();
+ $GLOBALS['_xh']['params'] = array();
+ $GLOBALS['_xh']['pt'] = array();
+ $GLOBALS['_xh']['isf'] = 0;
+ $GLOBALS['_xh']['isf_reason'] = '';
+ $GLOBALS['_xh']['method'] = false;
+ $GLOBALS['_xh']['rt'] = '';
+ /// @todo 'guestimate' encoding
+ $parser = xml_parser_create();
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ // What if internal encoding is not in one of the 3 allowed?
+ // we use the broadest one, ie. utf8!
+ if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
+ {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
+ }
+ else
+ {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
+ }
+ xml_set_element_handler($parser, 'xmlrpc_se_any', 'xmlrpc_ee');
+ xml_set_character_data_handler($parser, 'xmlrpc_cd');
+ xml_set_default_handler($parser, 'xmlrpc_dh');
+ if(!xml_parse($parser, $xml_val, 1))
+ {
+ $errstr = sprintf('XML error: %s at line %d, column %d',
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser), xml_get_current_column_number($parser));
+ error_log($errstr);
+ xml_parser_free($parser);
+ return false;
+ }
+ xml_parser_free($parser);
+ if ($GLOBALS['_xh']['isf'] > 1) // test that $GLOBALS['_xh']['value'] is an obj, too???
+ {
+ error_log($GLOBALS['_xh']['isf_reason']);
+ return false;
+ }
+ switch ($GLOBALS['_xh']['rt'])
+ {
+ case 'methodresponse':
+ $v =& $GLOBALS['_xh']['value'];
+ if ($GLOBALS['_xh']['isf'] == 1)
+ {
+ $vc = $v->structmem('faultCode');
+ $vs = $v->structmem('faultString');
+ $r =& new xmlrpcresp(0, $vc->scalarval(), $vs->scalarval());
+ }
+ else
+ {
+ $r =& new xmlrpcresp($v);
+ }
+ return $r;
+ case 'methodcall':
+ $m =& new xmlrpcmsg($GLOBALS['_xh']['method']);
+ for($i=0; $i < count($GLOBALS['_xh']['params']); $i++)
+ {
+ $m->addParam($GLOBALS['_xh']['params'][$i]);
+ }
+ return $m;
+ case 'value':
+ return $GLOBALS['_xh']['value'];
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * decode a string that is encoded w/ "chunked" transfer encoding
+ * as defined in rfc2068 par. 19.4.6
+ * code shamelessly stolen from nusoap library by Dietrich Ayala
+ *
+ * @param string $buffer the string to be decoded
+ * @return string
+ */
+ function decode_chunked($buffer)
+ {
+ // length := 0
+ $length = 0;
+ $new = '';
+
+ // read chunk-size, chunk-extension (if any) and crlf
+ // get the position of the linebreak
+ $chunkend = strpos($buffer,"\r\n") + 2;
+ $temp = substr($buffer,0,$chunkend);
+ $chunk_size = hexdec( trim($temp) );
+ $chunkstart = $chunkend;
+ while($chunk_size > 0)
+ {
+ $chunkend = strpos($buffer, "\r\n", $chunkstart + $chunk_size);
+
+ // just in case we got a broken connection
+ if($chunkend == false)
+ {
+ $chunk = substr($buffer,$chunkstart);
+ // append chunk-data to entity-body
+ $new .= $chunk;
+ $length += strlen($chunk);
+ break;
+ }
+
+ // read chunk-data and crlf
+ $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
+ // append chunk-data to entity-body
+ $new .= $chunk;
+ // length := length + chunk-size
+ $length += strlen($chunk);
+ // read chunk-size and crlf
+ $chunkstart = $chunkend + 2;
+
+ $chunkend = strpos($buffer,"\r\n",$chunkstart)+2;
+ if($chunkend == false)
+ {
+ break; //just in case we got a broken connection
+ }
+ $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
+ $chunk_size = hexdec( trim($temp) );
+ $chunkstart = $chunkend;
+ }
+ return $new;
+ }
+
+ /**
+ * xml charset encoding guessing helper function.
+ * Tries to determine the charset encoding of an XML chunk received over HTTP.
+ * NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type,
+ * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of unconforming (legacy?) clients/servers,
+ * which will be most probably using UTF-8 anyway...
+ *
+ * @param string $httpheaders the http Content-type header
+ * @param string $xmlchunk xml content buffer
+ * @param string $encoding_prefs comma separated list of character encodings to be used as default (when mb extension is enabled)
+ *
+ * @todo explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!!
+ */
+ function guess_encoding($httpheader='', $xmlchunk='', $encoding_prefs=null)
+ {
+ // discussion: see http://www.yale.edu/pclt/encoding/
+ // 1 - test if encoding is specified in HTTP HEADERS
+
+ //Details:
+ // LWS: (\13\10)?( |\t)+
+ // token: (any char but excluded stuff)+
+ // quoted string: " (any char but double quotes and cointrol chars)* "
+ // header: Content-type = ...; charset=value(; ...)*
+ // where value is of type token, no LWS allowed between 'charset' and value
+ // Note: we do not check for invalid chars in VALUE:
+ // this had better be done using pure ereg as below
+ // Note 2: we might be removing whitespace/tabs that ought to be left in if
+ // the received charset is a quoted string. But nobody uses such charset names...
+
+ /// @todo this test will pass if ANY header has charset specification, not only Content-Type. Fix it?
+ $matches = array();
+ if(preg_match('/;\s*charset\s*=([^;]+)/i', $httpheader, $matches))
+ {
+ return strtoupper(trim($matches[1], " \t\""));
+ }
+
+ // 2 - scan the first bytes of the data for a UTF-16 (or other) BOM pattern
+ // (source: http://www.w3.org/TR/2000/REC-xml-20001006)
+ // NOTE: actually, according to the spec, even if we find the BOM and determine
+ // an encoding, we should check if there is an encoding specified
+ // in the xml declaration, and verify if they match.
+ /// @todo implement check as described above?
+ /// @todo implement check for first bytes of string even without a BOM? (It sure looks harder than for cases WITH a BOM)
+ if(preg_match('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\x00\x00\xFF\xFE|\xFE\xFF\x00\x00)/', $xmlchunk))
+ {
+ return 'UCS-4';
+ }
+ elseif(preg_match('/^(\xFE\xFF|\xFF\xFE)/', $xmlchunk))
+ {
+ return 'UTF-16';
+ }
+ elseif(preg_match('/^(\xEF\xBB\xBF)/', $xmlchunk))
+ {
+ return 'UTF-8';
+ }
+
+ // 3 - test if encoding is specified in the xml declaration
+ // Details:
+ // SPACE: (#x20 | #x9 | #xD | #xA)+ === [ \x9\xD\xA]+
+ // EQ: SPACE?=SPACE? === [ \x9\xD\xA]*=[ \x9\xD\xA]*
+ if (preg_match('/^<\?xml\s+version\s*=\s*'. "((?:\"[a-zA-Z0-9_.:-]+\")|(?:'[a-zA-Z0-9_.:-]+'))".
+ '\s+encoding\s*=\s*' . "((?:\"[A-Za-z][A-Za-z0-9._-]*\")|(?:'[A-Za-z][A-Za-z0-9._-]*'))/",
+ $xmlchunk, $matches))
+ {
+ return strtoupper(substr($matches[2], 1, -1));
+ }
+
+ // 4 - if mbstring is available, let it do the guesswork
+ // NB: we favour finding an encoding that is compatible with what we can process
+ if(extension_loaded('mbstring'))
+ {
+ if($encoding_prefs)
+ {
+ $enc = mb_detect_encoding($xmlchunk, $encoding_prefs);
+ }
+ else
+ {
+ $enc = mb_detect_encoding($xmlchunk);
+ }
+ // NB: mb_detect likes to call it ascii, xml parser likes to call it US_ASCII...
+ // IANA also likes better US-ASCII, so go with it
+ if($enc == 'ASCII')
+ {
+ $enc = 'US-'.$enc;
+ }
+ return $enc;
+ }
+ else
+ {
+ // no encoding specified: as per HTTP1.1 assume it is iso-8859-1?
+ // Both RFC 2616 (HTTP 1.1) and 1945 (HTTP 1.0) clearly state that for text/xxx content types
+ // this should be the standard. And we should be getting text/xml as request and response.
+ // BUT we have to be backward compatible with the lib, which always used UTF-8 as default...
+ return $GLOBALS['xmlrpc_defencoding'];
+ }
+ }
+
+ /**
+ * Checks if a given charset encoding is present in a list of encodings or
+ * if it is a valid subset of any encoding in the list
+ * @param string $encoding charset to be tested
+ * @param mixed $validlist comma separated list of valid charsets (or array of charsets)
+ */
+ function is_valid_charset($encoding, $validlist)
+ {
+ $charset_supersets = array(
+ 'US-ASCII' => array ('ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4',
+ 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8',
+ 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-11', 'ISO-8859-12',
+ 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'UTF-8',
+ 'EUC-JP', 'EUC-', 'EUC-KR', 'EUC-CN')
+ );
+ if (is_string($validlist))
+ $validlist = explode(',', $validlist);
+ if (@in_array(strtoupper($encoding), $validlist))
+ return true;
+ else
+ {
+ if (array_key_exists($encoding, $charset_supersets))
+ foreach ($validlist as $allowed)
+ if (in_array($allowed, $charset_supersets[$encoding]))
+ return true;
+ return false;
+ }
+ }
+
+?>
\ No newline at end of file
diff --git a/thirdparty/xmlrpc/xmlrpc_wrappers.php b/thirdparty/xmlrpc/xmlrpc_wrappers.php
new file mode 100644
index 0000000..cb0c6e8
--- /dev/null
+++ b/thirdparty/xmlrpc/xmlrpc_wrappers.php
@@ -0,0 +1,944 @@
+' . $funcname[1];
+ }
+ $exists = method_exists($funcname[0], $funcname[1]);
+ }
+ else
+ {
+ $plainfuncname = $funcname;
+ $exists = function_exists($funcname);
+ }
+
+ if(!$exists)
+ {
+ error_log('XML-RPC: function to be wrapped is not defined: '.$plainfuncname);
+ return false;
+ }
+ else
+ {
+ // determine name of new php function
+ if($newfuncname == '')
+ {
+ if(is_array($funcname))
+ {
+ if(is_string($funcname[0]))
+ $xmlrpcfuncname = "{$prefix}_".implode('_', $funcname);
+ else
+ $xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1];
+ }
+ else
+ {
+ $xmlrpcfuncname = "{$prefix}_$funcname";
+ }
+ }
+ else
+ {
+ $xmlrpcfuncname = $newfuncname;
+ }
+ while($buildit && function_exists($xmlrpcfuncname))
+ {
+ $xmlrpcfuncname .= 'x';
+ }
+
+ // start to introspect PHP code
+ if(is_array($funcname))
+ {
+ $func =& new ReflectionMethod($funcname[0], $funcname[1]);
+ if($func->isPrivate())
+ {
+ error_log('XML-RPC: method to be wrapped is private: '.$plainfuncname);
+ return false;
+ }
+ if($func->isProtected())
+ {
+ error_log('XML-RPC: method to be wrapped is protected: '.$plainfuncname);
+ return false;
+ }
+ if($func->isConstructor())
+ {
+ error_log('XML-RPC: method to be wrapped is the constructor: '.$plainfuncname);
+ return false;
+ }
+ if($func->isDestructor())
+ {
+ error_log('XML-RPC: method to be wrapped is the destructor: '.$plainfuncname);
+ return false;
+ }
+ if($func->isAbstract())
+ {
+ error_log('XML-RPC: method to be wrapped is abstract: '.$plainfuncname);
+ return false;
+ }
+ /// @todo add more checks for static vs. nonstatic?
+ }
+ else
+ {
+ $func =& new ReflectionFunction($funcname);
+ }
+ if($func->isInternal())
+ {
+ // Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs
+ // instead of getparameters to fully reflect internal php functions ?
+ error_log('XML-RPC: function to be wrapped is internal: '.$plainfuncname);
+ return false;
+ }
+
+ // retrieve parameter names, types and description from javadoc comments
+
+ // function description
+ $desc = '';
+ // type of return val: by default 'any'
+ $returns = $GLOBALS['xmlrpcValue'];
+ // desc of return val
+ $returnsDocs = '';
+ // type + name of function parameters
+ $paramDocs = array();
+
+ $docs = $func->getDocComment();
+ if($docs != '')
+ {
+ $docs = explode("\n", $docs);
+ $i = 0;
+ foreach($docs as $doc)
+ {
+ $doc = trim($doc, " \r\t/*");
+ if(strlen($doc) && strpos($doc, '@') !== 0 && !$i)
+ {
+ if($desc)
+ {
+ $desc .= "\n";
+ }
+ $desc .= $doc;
+ }
+ elseif(strpos($doc, '@param') === 0)
+ {
+ // syntax: @param type [$name] desc
+ if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches))
+ {
+ if(strpos($matches[1], '|'))
+ {
+ //$paramDocs[$i]['type'] = explode('|', $matches[1]);
+ $paramDocs[$i]['type'] = 'mixed';
+ }
+ else
+ {
+ $paramDocs[$i]['type'] = $matches[1];
+ }
+ $paramDocs[$i]['name'] = trim($matches[2]);
+ $paramDocs[$i]['doc'] = $matches[3];
+ }
+ $i++;
+ }
+ elseif(strpos($doc, '@return') === 0)
+ {
+ // syntax: @return type desc
+ //$returns = preg_split('/\s+/', $doc);
+ if(preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches))
+ {
+ $returns = php_2_xmlrpc_type($matches[1]);
+ if(isset($matches[2]))
+ {
+ $returnsDocs = $matches[2];
+ }
+ }
+ }
+ }
+ }
+
+ // execute introspection of actual function prototype
+ $params = array();
+ $i = 0;
+ foreach($func->getParameters() as $paramobj)
+ {
+ $params[$i] = array();
+ $params[$i]['name'] = '$'.$paramobj->getName();
+ $params[$i]['isoptional'] = $paramobj->isOptional();
+ $i++;
+ }
+
+
+ // start building of PHP code to be eval'd
+ $innercode = '';
+ $i = 0;
+ $parsvariations = array();
+ $pars = array();
+ $pnum = count($params);
+ foreach($params as $param)
+ {
+ if (isset($paramDocs[$i]['name']) && $paramDocs[$i]['name'] && strtolower($paramDocs[$i]['name']) != strtolower($param['name']))
+ {
+ // param name from phpdoc info does not match param definition!
+ $paramDocs[$i]['type'] = 'mixed';
+ }
+
+ if($param['isoptional'])
+ {
+ // this particular parameter is optional. save as valid previous list of parameters
+ $innercode .= "if (\$paramcount > $i) {\n";
+ $parsvariations[] = $pars;
+ }
+ $innercode .= "\$p$i = \$msg->getParam($i);\n";
+ if ($decode_php_objects)
+ {
+ $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i, array('decode_php_objs'));\n";
+ }
+ else
+ {
+ $innercode .= "if (\$p{$i}->kindOf() == 'scalar') \$p$i = \$p{$i}->scalarval(); else \$p$i = php_{$prefix}_decode(\$p$i);\n";
+ }
+
+ $pars[] = "\$p$i";
+ $i++;
+ if($param['isoptional'])
+ {
+ $innercode .= "}\n";
+ }
+ if($i == $pnum)
+ {
+ // last allowed parameters combination
+ $parsvariations[] = $pars;
+ }
+ }
+
+ $sigs = array();
+ $psigs = array();
+ if(count($parsvariations) == 0)
+ {
+ // only known good synopsis = no parameters
+ $parsvariations[] = array();
+ $minpars = 0;
+ }
+ else
+ {
+ $minpars = count($parsvariations[0]);
+ }
+
+ if($minpars)
+ {
+ // add to code the check for min params number
+ // NB: this check needs to be done BEFORE decoding param values
+ $innercode = "\$paramcount = \$msg->getNumParams();\n" .
+ "if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n" . $innercode;
+ }
+ else
+ {
+ $innercode = "\$paramcount = \$msg->getNumParams();\n" . $innercode;
+ }
+
+ $innercode .= "\$np = false;\n";
+ // since there are no closures in php, if we are given an object instance,
+ // we store a pointer to it in a global var...
+ if ( is_array($funcname) && is_object($funcname[0]) )
+ {
+ $GLOBALS['xmlrpcWPFObjHolder'][$xmlrpcfuncname] =& $funcname[0];
+ $innercode .= "\$obj =& \$GLOBALS['xmlrpcWPFObjHolder']['$xmlrpcfuncname'];\n";
+ $realfuncname = '$obj->'.$funcname[1];
+ }
+ else
+ {
+ $realfuncname = $plainfuncname;
+ }
+ foreach($parsvariations as $pars)
+ {
+ $innercode .= "if (\$paramcount == " . count($pars) . ") \$retval = {$catch_warnings}$realfuncname(" . implode(',', $pars) . "); else\n";
+ // build a 'generic' signature (only use an appropriate return type)
+ $sig = array($returns);
+ $psig = array($returnsDocs);
+ for($i=0; $i < count($pars); $i++)
+ {
+ if (isset($paramDocs[$i]['type']))
+ {
+ $sig[] = php_2_xmlrpc_type($paramDocs[$i]['type']);
+ }
+ else
+ {
+ $sig[] = $GLOBALS['xmlrpcValue'];
+ }
+ $psig[] = isset($paramDocs[$i]['doc']) ? $paramDocs[$i]['doc'] : '';
+ }
+ $sigs[] = $sig;
+ $psigs[] = $psig;
+ }
+ $innercode .= "\$np = true;\n";
+ $innercode .= "if (\$np) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}'); else {\n";
+ //$innercode .= "if (\$_xmlrpcs_error_occurred) return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']user, \$_xmlrpcs_error_occurred); else\n";
+ $innercode .= "if (is_a(\$retval, '{$prefix}resp')) return \$retval; else\n";
+ if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64'])
+ {
+ $innercode .= "return new {$prefix}resp(new {$prefix}val(\$retval, '$returns'));";
+ }
+ else
+ {
+ if ($encode_php_objects)
+ $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval, array('encode_php_objs')));\n";
+ else
+ $innercode .= "return new {$prefix}resp(php_{$prefix}_encode(\$retval));\n";
+ }
+ // shall we exclude functions returning by ref?
+ // if($func->returnsReference())
+ // return false;
+ $code = "function $xmlrpcfuncname(\$msg) {\n" . $innercode . "}\n}";
+ //print_r($code);
+ if ($buildit)
+ {
+ $allOK = 0;
+ eval($code.'$allOK=1;');
+ // alternative
+ //$xmlrpcfuncname = create_function('$m', $innercode);
+
+ if(!$allOK)
+ {
+ error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap php function '.$plainfuncname);
+ return false;
+ }
+ }
+
+ /// @todo examine if $paramDocs matches $parsvariations and build array for
+ /// usage as method signature, plus put together a nice string for docs
+
+ $ret = array('function' => $xmlrpcfuncname, 'signature' => $sigs, 'docstring' => $desc, 'signature_docs' => $psigs, 'source' => $code);
+ return $ret;
+ }
+ }
+
+ /**
+ * Given a user-defined PHP class or php object, map its methods onto a list of
+ * PHP 'wrapper' functions that can be exposed as xmlrpc methods from an xmlrpc_server
+ * object and called from remote clients (as well as their corresponding signature info).
+ *
+ * @param mixed $classname the name of the class whose methods are to be exposed as xmlrpc methods, or an object instance of that class
+ * @param array $extra_options see the docs for wrap_php_method for more options
+ * string method_type 'static', 'nonstatic', 'all' and 'auto' (default); the latter will switch between static and non-static depending on wheter $classname is a class name or object instance
+ * @return array or false on failure
+ *
+ * @todo get_class_methods will return both static and non-static methods.
+ * we have to differentiate the action, depending on wheter we recived a class name or object
+ */
+ function wrap_php_class($classname, $extra_options=array())
+ {
+ $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : '';
+ $methodtype = isset($extra_options['method_type']) ? $extra_options['method_type'] : 'auto';
+
+ if(version_compare(phpversion(), '5.0.3') == -1)
+ {
+ // up to php 5.0.3 some useful reflection methods were missing
+ error_log('XML-RPC: cannot not wrap php functions unless running php version bigger than 5.0.3');
+ return false;
+ }
+
+ $result = array();
+ $mlist = get_class_methods($classname);
+ foreach($mlist as $mname)
+ {
+ if ($methodfilter == '' || preg_match($methodfilter, $mname))
+ {
+ // echo $mlist."\n";
+ $func =& new ReflectionMethod($classname, $mname);
+ if(!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract())
+ {
+ if(($func->isStatic && ($methodtype == 'all' || $methodtype == 'static' || ($methodtype == 'auto' && is_string($classname)))) ||
+ (!$func->isStatic && ($methodtype == 'all' || $methodtype == 'nonstatic' || ($methodtype == 'auto' && is_object($classname)))))
+ {
+ $methodwrap = wrap_php_function(array($classname, $mname), '', $extra_options);
+ if ( $methodwrap )
+ {
+ $result[$methodwrap['function']] = $methodwrap['function'];
+ }
+ }
+ }
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Given an xmlrpc client and a method name, register a php wrapper function
+ * that will call it and return results using native php types for both
+ * params and results. The generated php function will return an xmlrpcresp
+ * oject for failed xmlrpc calls
+ *
+ * Known limitations:
+ * - server must support system.methodsignature for the wanted xmlrpc method
+ * - for methods that expose many signatures, only one can be picked (we
+ * could in priciple check if signatures differ only by number of params
+ * and not by type, but it would be more complication than we can spare time)
+ * - nested xmlrpc params: the caller of the generated php function has to
+ * encode on its own the params passed to the php function if these are structs
+ * or arrays whose (sub)members include values of type datetime or base64
+ *
+ * Notes: the connection properties of the given client will be copied
+ * and reused for the connection used during the call to the generated
+ * php function.
+ * Calling the generated php function 'might' be slow: a new xmlrpc client
+ * is created on every invocation and an xmlrpc-connection opened+closed.
+ * An extra 'debug' param is appended to param list of xmlrpc method, useful
+ * for debugging purposes.
+ *
+ * @param xmlrpc_client $client an xmlrpc client set up correctly to communicate with target server
+ * @param string $methodname the xmlrpc method to be mapped to a php function
+ * @param array $extra_options array of options that specify conversion details. valid ptions include
+ * integer signum the index of the method signature to use in mapping (if method exposes many sigs)
+ * integer timeout timeout (in secs) to be used when executing function/calling remote method
+ * string protocol 'http' (default), 'http11' or 'https'
+ * string new_function_name the name of php function to create. If unsepcified, lib will pick an appropriate name
+ * string return_source if true return php code w. function definition instead fo function name
+ * bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects
+ * bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers ---
+ * mixed return_on_fault a php value to be returned when the xmlrpc call fails/returns a fault response (by default the xmlrpcresp object is returned in this case). If a string is used, '%faultCode%' and '%faultString%' tokens will be substituted with actual error values
+ * bool debug set it to 1 or 2 to see debug results of querying server for method synopsis
+ * @return string the name of the generated php function (or false) - OR AN ARRAY...
+ */
+ function wrap_xmlrpc_method($client, $methodname, $extra_options=0, $timeout=0, $protocol='', $newfuncname='')
+ {
+ // mind numbing: let caller use sane calling convention (as per javadoc, 3 params),
+ // OR the 2.0 calling convention (no options) - we really love backward compat, don't we?
+ if (!is_array($extra_options))
+ {
+ $signum = $extra_options;
+ $extra_options = array();
+ }
+ else
+ {
+ $signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0;
+ $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0;
+ $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : '';
+ $newfuncname = isset($extra_options['new_function_name']) ? $extra_options['new_function_name'] : '';
+ }
+ //$encode_php_objects = in_array('encode_php_objects', $extra_options);
+ //$verbatim_client_copy = in_array('simple_client_copy', $extra_options) ? 1 :
+ // in_array('build_class_code', $extra_options) ? 2 : 0;
+
+ $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false;
+ $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false;
+ $simple_client_copy = isset($extra_options['simple_client_copy']) ? (int)($extra_options['simple_client_copy']) : 0;
+ $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true;
+ $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc';
+ if (isset($extra_options['return_on_fault']))
+ {
+ $decode_fault = true;
+ $fault_response = $extra_options['return_on_fault'];
+ }
+ else
+ {
+ $decode_fault = false;
+ $fault_response = '';
+ }
+ $debug = isset($extra_options['debug']) ? ($extra_options['debug']) : 0;
+
+ $msgclass = $prefix.'msg';
+ $valclass = $prefix.'val';
+ $decodefunc = 'php_'.$prefix.'_decode';
+
+ $msg =& new $msgclass('system.methodSignature');
+ $msg->addparam(new $valclass($methodname));
+ $client->setDebug($debug);
+ $response =& $client->send($msg, $timeout, $protocol);
+ if($response->faultCode())
+ {
+ error_log('XML-RPC: could not retrieve method signature from remote server for method '.$methodname);
+ return false;
+ }
+ else
+ {
+ $msig = $response->value();
+ if ($client->return_type != 'phpvals')
+ {
+ $msig = $decodefunc($msig);
+ }
+ if(!is_array($msig) || count($msig) <= $signum)
+ {
+ error_log('XML-RPC: could not retrieve method signature nr.'.$signum.' from remote server for method '.$methodname);
+ return false;
+ }
+ else
+ {
+ // pick a suitable name for the new function, avoiding collisions
+ if($newfuncname != '')
+ {
+ $xmlrpcfuncname = $newfuncname;
+ }
+ else
+ {
+ // take care to insure that methodname is translated to valid
+ // php function name
+ $xmlrpcfuncname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
+ array('_', ''), $methodname);
+ }
+ while($buildit && function_exists($xmlrpcfuncname))
+ {
+ $xmlrpcfuncname .= 'x';
+ }
+
+ $msig = $msig[$signum];
+ $mdesc = '';
+ // if in 'offline' mode, get method description too.
+ // in online mode, favour speed of operation
+ if(!$buildit)
+ {
+ $msg =& new $msgclass('system.methodHelp');
+ $msg->addparam(new $valclass($methodname));
+ $response =& $client->send($msg, $timeout, $protocol);
+ if (!$response->faultCode())
+ {
+ $mdesc = $response->value();
+ if ($client->return_type != 'phpvals')
+ {
+ $mdesc = $mdesc->scalarval();
+ }
+ }
+ }
+
+ $results = build_remote_method_wrapper_code($client, $methodname,
+ $xmlrpcfuncname, $msig, $mdesc, $timeout, $protocol, $simple_client_copy,
+ $prefix, $decode_php_objects, $encode_php_objects, $decode_fault,
+ $fault_response);
+
+ //print_r($code);
+ if ($buildit)
+ {
+ $allOK = 0;
+ eval($results['source'].'$allOK=1;');
+ // alternative
+ //$xmlrpcfuncname = create_function('$m', $innercode);
+ if($allOK)
+ {
+ return $xmlrpcfuncname;
+ }
+ else
+ {
+ error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap remote method '.$methodname);
+ return false;
+ }
+ }
+ else
+ {
+ $results['function'] = $xmlrpcfuncname;
+ return $results;
+ }
+ }
+ }
+ }
+
+ /**
+ * Similar to wrap_xmlrpc_method, but will generate a php class that wraps
+ * all xmlrpc methods exposed by the remote server as own methods.
+ * For more details see wrap_xmlrpc_method.
+ * @param xmlrpc_client $client the client obj all set to query the desired server
+ * @param array $extra_options list of options for wrapped code
+ * @return mixed false on error, the name of the created class if all ok or an array with code, class name and comments (if the appropriatevoption is set in extra_options)
+ */
+ function wrap_xmlrpc_server($client, $extra_options=array())
+ {
+ $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : '';
+ //$signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0;
+ $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0;
+ $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : '';
+ $newclassname = isset($extra_options['new_class_name']) ? $extra_options['new_class_name'] : '';
+ $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false;
+ $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false;
+ $verbatim_client_copy = isset($extra_options['simple_client_copy']) ? !($extra_options['simple_client_copy']) : true;
+ $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true;
+ $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc';
+
+ $msgclass = $prefix.'msg';
+ //$valclass = $prefix.'val';
+ $decodefunc = 'php_'.$prefix.'_decode';
+
+ $msg =& new $msgclass('system.listMethods');
+ $response =& $client->send($msg, $timeout, $protocol);
+ if($response->faultCode())
+ {
+ error_log('XML-RPC: could not retrieve method list from remote server');
+ return false;
+ }
+ else
+ {
+ $mlist = $response->value();
+ if ($client->return_type != 'phpvals')
+ {
+ $mlist = $decodefunc($mlist);
+ }
+ if(!is_array($mlist) || !count($mlist))
+ {
+ error_log('XML-RPC: could not retrieve meaningful method list from remote server');
+ return false;
+ }
+ else
+ {
+ // pick a suitable name for the new function, avoiding collisions
+ if($newclassname != '')
+ {
+ $xmlrpcclassname = $newclassname;
+ }
+ else
+ {
+ $xmlrpcclassname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
+ array('_', ''), $client->server).'_client';
+ }
+ while($buildit && class_exists($xmlrpcclassname))
+ {
+ $xmlrpcclassname .= 'x';
+ }
+
+ /// @todo add function setdebug() to new class, to enable/disable debugging
+ $source = "class $xmlrpcclassname\n{\nvar \$client;\n\n";
+ $source .= "function $xmlrpcclassname()\n{\n";
+ $source .= build_client_wrapper_code($client, $verbatim_client_copy, $prefix);
+ $source .= "\$this->client =& \$client;\n}\n\n";
+ $opts = array('simple_client_copy' => 2, 'return_source' => true,
+ 'timeout' => $timeout, 'protocol' => $protocol,
+ 'encode_php_objs' => $encode_php_objects, 'prefix' => $prefix,
+ 'decode_php_objs' => $decode_php_objects
+ );
+ /// @todo build javadoc for class definition, too
+ foreach($mlist as $mname)
+ {
+ if ($methodfilter == '' || preg_match($methodfilter, $mname))
+ {
+ $opts['new_function_name'] = preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'),
+ array('_', ''), $mname);
+ $methodwrap = wrap_xmlrpc_method($client, $mname, $opts);
+ if ($methodwrap)
+ {
+ if (!$buildit)
+ {
+ $source .= $methodwrap['docstring'];
+ }
+ $source .= $methodwrap['source']."\n";
+ }
+ else
+ {
+ error_log('XML-RPC: will not create class method to wrap remote method '.$mname);
+ }
+ }
+ }
+ $source .= "}\n";
+ if ($buildit)
+ {
+ $allOK = 0;
+ eval($source.'$allOK=1;');
+ // alternative
+ //$xmlrpcfuncname = create_function('$m', $innercode);
+ if($allOK)
+ {
+ return $xmlrpcclassname;
+ }
+ else
+ {
+ error_log('XML-RPC: could not create class '.$xmlrpcclassname.' to wrap remote server '.$client->server);
+ return false;
+ }
+ }
+ else
+ {
+ return array('class' => $xmlrpcclassname, 'code' => $source, 'docstring' => '');
+ }
+ }
+ }
+ }
+
+ /**
+ * Given the necessary info, build php code that creates a new function to
+ * invoke a remote xmlrpc method.
+ * Take care that no full checking of input parameters is done to ensure that
+ * valid php code is emitted.
+ * Note: real spaghetti code follows...
+ * @access private
+ */
+ function build_remote_method_wrapper_code($client, $methodname, $xmlrpcfuncname,
+ $msig, $mdesc='', $timeout=0, $protocol='', $client_copy_mode=0, $prefix='xmlrpc',
+ $decode_php_objects=false, $encode_php_objects=false, $decode_fault=false,
+ $fault_response='')
+ {
+ $code = "function $xmlrpcfuncname (";
+ if ($client_copy_mode < 2)
+ {
+ // client copy mode 0 or 1 == partial / full client copy in emitted code
+ $innercode = build_client_wrapper_code($client, $client_copy_mode, $prefix);
+ $innercode .= "\$client->setDebug(\$debug);\n";
+ $this_ = '';
+ }
+ else
+ {
+ // client copy mode 2 == no client copy in emitted code
+ $innercode = '';
+ $this_ = 'this->';
+ }
+ $innercode .= "\$msg =& new {$prefix}msg('$methodname');\n";
+
+ if ($mdesc != '')
+ {
+ // take care that PHP comment is not terminated unwillingly by method description
+ $mdesc = "/**\n* ".str_replace('*/', '* /', $mdesc)."\n";
+ }
+ else
+ {
+ $mdesc = "/**\nFunction $xmlrpcfuncname\n";
+ }
+
+ // param parsing
+ $plist = array();
+ $pcount = count($msig);
+ for($i = 1; $i < $pcount; $i++)
+ {
+ $plist[] = "\$p$i";
+ $ptype = $msig[$i];
+ if($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' ||
+ $ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null')
+ {
+ // only build directly xmlrpcvals when type is known and scalar
+ $innercode .= "\$p$i =& new {$prefix}val(\$p$i, '$ptype');\n";
+ }
+ else
+ {
+ if ($encode_php_objects)
+ {
+ $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i, array('encode_php_objs'));\n";
+ }
+ else
+ {
+ $innercode .= "\$p$i =& php_{$prefix}_encode(\$p$i);\n";
+ }
+ }
+ $innercode .= "\$msg->addparam(\$p$i);\n";
+ $mdesc .= '* @param '.xmlrpc_2_php_type($ptype)." \$p$i\n";
+ }
+ if ($client_copy_mode < 2)
+ {
+ $plist[] = '$debug=0';
+ $mdesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
+ }
+ $plist = implode(', ', $plist);
+ $mdesc .= '* @return '.xmlrpc_2_php_type($msig[0])." (or an {$prefix}resp obj instance if call fails)\n*/\n";
+
+ $innercode .= "\$res =& \${$this_}client->send(\$msg, $timeout, '$protocol');\n";
+ if ($decode_fault)
+ {
+ if (is_string($fault_response) && ((strpos($fault_response, '%faultCode%') !== false) || (strpos($fault_response, '%faultString%') !== false)))
+ {
+ $respcode = "str_replace(array('%faultCode%', '%faultString%'), array(\$res->faultCode(), \$res->faultString()), '".str_replace("'", "''", $fault_response)."')";
+ }
+ else
+ {
+ $respcode = var_export($fault_response, true);
+ }
+ }
+ else
+ {
+ $respcode = '$res';
+ }
+ if ($decode_php_objects)
+ {
+ $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value(), array('decode_php_objs'));";
+ }
+ else
+ {
+ $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value());";
+ }
+
+ $code = $code . $plist. ") {\n" . $innercode . "\n}\n";
+
+ return array('source' => $code, 'docstring' => $mdesc);
+ }
+
+ /**
+ * Given necessary info, generate php code that will rebuild a client object
+ * Take care that no full checking of input parameters is done to ensure that
+ * valid php code is emitted.
+ * @access private
+ */
+ function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc')
+ {
+ $code = "\$client =& new {$prefix}_client('".str_replace("'", "\'", $client->path).
+ "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n";
+
+ // copy all client fields to the client that will be generated runtime
+ // (this provides for future expansion or subclassing of client obj)
+ if ($verbatim_client_copy)
+ {
+ foreach($client as $fld => $val)
+ {
+ if($fld != 'debug' && $fld != 'return_type')
+ {
+ $val = var_export($val, true);
+ $code .= "\$client->$fld = $val;\n";
+ }
+ }
+ }
+ // only make sure that client always returns the correct data type
+ $code .= "\$client->return_type = '{$prefix}vals';\n";
+ //$code .= "\$client->setDebug(\$debug);\n";
+ return $code;
+ }
+?>
\ No newline at end of file
diff --git a/thirdparty/xmlrpc/xmlrpcs.php b/thirdparty/xmlrpc/xmlrpcs.php
new file mode 100644
index 0000000..a089ca5
--- /dev/null
+++ b/thirdparty/xmlrpc/xmlrpcs.php
@@ -0,0 +1,1198 @@
+
+// $Id: xmlrpcs.inc,v 1.71 2008/10/29 23:41:28 ggiunta Exp $
+
+// Copyright (c) 1999,2000,2002 Edd Dumbill.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// * Neither the name of the "XML-RPC for PHP" nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+// OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ // XML RPC Server class
+ // requires: xmlrpc.inc
+
+ $GLOBALS['xmlrpcs_capabilities'] = array(
+ // xmlrpc spec: always supported
+ 'xmlrpc' => new xmlrpcval(array(
+ 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/spec', 'string'),
+ 'specVersion' => new xmlrpcval(1, 'int')
+ ), 'struct'),
+ // if we support system.xxx functions, we always support multicall, too...
+ // Note that, as of 2006/09/17, the following URL does not respond anymore
+ 'system.multicall' => new xmlrpcval(array(
+ 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/discuss/msgReader$1208', 'string'),
+ 'specVersion' => new xmlrpcval(1, 'int')
+ ), 'struct'),
+ // introspection: version 2! we support 'mixed', too
+ 'introspection' => new xmlrpcval(array(
+ 'specUrl' => new xmlrpcval('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 'string'),
+ 'specVersion' => new xmlrpcval(2, 'int')
+ ), 'struct')
+ );
+
+ /* Functions that implement system.XXX methods of xmlrpc servers */
+ $_xmlrpcs_getCapabilities_sig=array(array($GLOBALS['xmlrpcStruct']));
+ $_xmlrpcs_getCapabilities_doc='This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to';
+ $_xmlrpcs_getCapabilities_sdoc=array(array('list of capabilities, described as structs with a version number and url for the spec'));
+ function _xmlrpcs_getCapabilities($server, $m=null)
+ {
+ $outAr = $GLOBALS['xmlrpcs_capabilities'];
+ // NIL extension
+ if ($GLOBALS['xmlrpc_null_extension']) {
+ $outAr['nil'] = new xmlrpcval(array(
+ 'specUrl' => new xmlrpcval('http://www.ontosys.com/xml-rpc/extensions.php', 'string'),
+ 'specVersion' => new xmlrpcval(1, 'int')
+ ), 'struct');
+ }
+ return new xmlrpcresp(new xmlrpcval($outAr, 'struct'));
+ }
+
+ // listMethods: signature was either a string, or nothing.
+ // The useless string variant has been removed
+ $_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray']));
+ $_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch';
+ $_xmlrpcs_listMethods_sdoc=array(array('list of method names'));
+ function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing
+ {
+
+ $outAr=array();
+ foreach($server->dmap as $key => $val)
+ {
+ $outAr[]=&new xmlrpcval($key, 'string');
+ }
+ if($server->allow_system_funcs)
+ {
+ foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val)
+ {
+ $outAr[]=&new xmlrpcval($key, 'string');
+ }
+ }
+ return new xmlrpcresp(new xmlrpcval($outAr, 'array'));
+ }
+
+ $_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString']));
+ $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
+ $_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described'));
+ function _xmlrpcs_methodSignature($server, $m)
+ {
+ // let accept as parameter both an xmlrpcval or string
+ if (is_object($m))
+ {
+ $methName=$m->getParam(0);
+ $methName=$methName->scalarval();
+ }
+ else
+ {
+ $methName=$m;
+ }
+ if(strpos($methName, "system.") === 0)
+ {
+ $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1;
+ }
+ else
+ {
+ $dmap=$server->dmap; $sysCall=0;
+ }
+ if(isset($dmap[$methName]))
+ {
+ if(isset($dmap[$methName]['signature']))
+ {
+ $sigs=array();
+ foreach($dmap[$methName]['signature'] as $inSig)
+ {
+ $cursig=array();
+ foreach($inSig as $sig)
+ {
+ $cursig[]=&new xmlrpcval($sig, 'string');
+ }
+ $sigs[]=&new xmlrpcval($cursig, 'array');
+ }
+ $r=&new xmlrpcresp(new xmlrpcval($sigs, 'array'));
+ }
+ else
+ {
+ // NB: according to the official docs, we should be returning a
+ // "none-array" here, which means not-an-array
+ $r=&new xmlrpcresp(new xmlrpcval('undef', 'string'));
+ }
+ }
+ else
+ {
+ $r=&new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']);
+ }
+ return $r;
+ }
+
+ $_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString']));
+ $_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string';
+ $_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described'));
+ function _xmlrpcs_methodHelp($server, $m)
+ {
+ // let accept as parameter both an xmlrpcval or string
+ if (is_object($m))
+ {
+ $methName=$m->getParam(0);
+ $methName=$methName->scalarval();
+ }
+ else
+ {
+ $methName=$m;
+ }
+ if(strpos($methName, "system.") === 0)
+ {
+ $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1;
+ }
+ else
+ {
+ $dmap=$server->dmap; $sysCall=0;
+ }
+ if(isset($dmap[$methName]))
+ {
+ if(isset($dmap[$methName]['docstring']))
+ {
+ $r=&new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string');
+ }
+ else
+ {
+ $r=&new xmlrpcresp(new xmlrpcval('', 'string'));
+ }
+ }
+ else
+ {
+ $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']);
+ }
+ return $r;
+ }
+
+ $_xmlrpcs_multicall_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcArray']));
+ $_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details';
+ $_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"'));
+ function _xmlrpcs_multicall_error($err)
+ {
+ if(is_string($err))
+ {
+ $str = $GLOBALS['xmlrpcstr']["multicall_${err}"];
+ $code = $GLOBALS['xmlrpcerr']["multicall_${err}"];
+ }
+ else
+ {
+ $code = $err->faultCode();
+ $str = $err->faultString();
+ }
+ $struct = array();
+ $struct['faultCode'] =& new xmlrpcval($code, 'int');
+ $struct['faultString'] =& new xmlrpcval($str, 'string');
+ return new xmlrpcval($struct, 'struct');
+ }
+
+ function _xmlrpcs_multicall_do_call($server, $call)
+ {
+ if($call->kindOf() != 'struct')
+ {
+ return _xmlrpcs_multicall_error('notstruct');
+ }
+ $methName = @$call->structmem('methodName');
+ if(!$methName)
+ {
+ return _xmlrpcs_multicall_error('nomethod');
+ }
+ if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string')
+ {
+ return _xmlrpcs_multicall_error('notstring');
+ }
+ if($methName->scalarval() == 'system.multicall')
+ {
+ return _xmlrpcs_multicall_error('recursion');
+ }
+
+ $params = @$call->structmem('params');
+ if(!$params)
+ {
+ return _xmlrpcs_multicall_error('noparams');
+ }
+ if($params->kindOf() != 'array')
+ {
+ return _xmlrpcs_multicall_error('notarray');
+ }
+ $numParams = $params->arraysize();
+
+ $msg =& new xmlrpcmsg($methName->scalarval());
+ for($i = 0; $i < $numParams; $i++)
+ {
+ if(!$msg->addParam($params->arraymem($i)))
+ {
+ $i++;
+ return _xmlrpcs_multicall_error(new xmlrpcresp(0,
+ $GLOBALS['xmlrpcerr']['incorrect_params'],
+ $GLOBALS['xmlrpcstr']['incorrect_params'] . ": probable xml error in param " . $i));
+ }
+ }
+
+ $result = $server->execute($msg);
+
+ if($result->faultCode() != 0)
+ {
+ return _xmlrpcs_multicall_error($result); // Method returned fault.
+ }
+
+ return new xmlrpcval(array($result->value()), 'array');
+ }
+
+ function _xmlrpcs_multicall_do_call_phpvals($server, $call)
+ {
+ if(!is_array($call))
+ {
+ return _xmlrpcs_multicall_error('notstruct');
+ }
+ if(!array_key_exists('methodName', $call))
+ {
+ return _xmlrpcs_multicall_error('nomethod');
+ }
+ if (!is_string($call['methodName']))
+ {
+ return _xmlrpcs_multicall_error('notstring');
+ }
+ if($call['methodName'] == 'system.multicall')
+ {
+ return _xmlrpcs_multicall_error('recursion');
+ }
+ if(!array_key_exists('params', $call))
+ {
+ return _xmlrpcs_multicall_error('noparams');
+ }
+ if(!is_array($call['params']))
+ {
+ return _xmlrpcs_multicall_error('notarray');
+ }
+
+ // this is a real dirty and simplistic hack, since we might have received a
+ // base64 or datetime values, but they will be listed as strings here...
+ $numParams = count($call['params']);
+ $pt = array();
+ foreach($call['params'] as $val)
+ $pt[] = php_2_xmlrpc_type(gettype($val));
+
+ $result = $server->execute($call['methodName'], $call['params'], $pt);
+
+ if($result->faultCode() != 0)
+ {
+ return _xmlrpcs_multicall_error($result); // Method returned fault.
+ }
+
+ return new xmlrpcval(array($result->value()), 'array');
+ }
+
+ function _xmlrpcs_multicall($server, $m)
+ {
+ $result = array();
+ // let accept a plain list of php parameters, beside a single xmlrpc msg object
+ if (is_object($m))
+ {
+ $calls = $m->getParam(0);
+ $numCalls = $calls->arraysize();
+ for($i = 0; $i < $numCalls; $i++)
+ {
+ $call = $calls->arraymem($i);
+ $result[$i] = _xmlrpcs_multicall_do_call($server, $call);
+ }
+ }
+ else
+ {
+ $numCalls=count($m);
+ for($i = 0; $i < $numCalls; $i++)
+ {
+ $result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]);
+ }
+ }
+
+ return new xmlrpcresp(new xmlrpcval($result, 'array'));
+ }
+
+ $GLOBALS['_xmlrpcs_dmap']=array(
+ 'system.listMethods' => array(
+ 'function' => '_xmlrpcs_listMethods',
+ 'signature' => $_xmlrpcs_listMethods_sig,
+ 'docstring' => $_xmlrpcs_listMethods_doc,
+ 'signature_docs' => $_xmlrpcs_listMethods_sdoc),
+ 'system.methodHelp' => array(
+ 'function' => '_xmlrpcs_methodHelp',
+ 'signature' => $_xmlrpcs_methodHelp_sig,
+ 'docstring' => $_xmlrpcs_methodHelp_doc,
+ 'signature_docs' => $_xmlrpcs_methodHelp_sdoc),
+ 'system.methodSignature' => array(
+ 'function' => '_xmlrpcs_methodSignature',
+ 'signature' => $_xmlrpcs_methodSignature_sig,
+ 'docstring' => $_xmlrpcs_methodSignature_doc,
+ 'signature_docs' => $_xmlrpcs_methodSignature_sdoc),
+ 'system.multicall' => array(
+ 'function' => '_xmlrpcs_multicall',
+ 'signature' => $_xmlrpcs_multicall_sig,
+ 'docstring' => $_xmlrpcs_multicall_doc,
+ 'signature_docs' => $_xmlrpcs_multicall_sdoc),
+ 'system.getCapabilities' => array(
+ 'function' => '_xmlrpcs_getCapabilities',
+ 'signature' => $_xmlrpcs_getCapabilities_sig,
+ 'docstring' => $_xmlrpcs_getCapabilities_doc,
+ 'signature_docs' => $_xmlrpcs_getCapabilities_sdoc)
+ );
+
+ $GLOBALS['_xmlrpcs_occurred_errors'] = '';
+ $GLOBALS['_xmlrpcs_prev_ehandler'] = '';
+ /**
+ * Error handler used to track errors that occur during server-side execution of PHP code.
+ * This allows to report back to the client whether an internal error has occurred or not
+ * using an xmlrpc response object, instead of letting the client deal with the html junk
+ * that a PHP execution error on the server generally entails.
+ *
+ * NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors.
+ *
+ */
+ function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null)
+ {
+ // obey the @ protocol
+ if (error_reporting() == 0)
+ return;
+
+ //if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING)
+ if($errcode != 2048) // do not use E_STRICT by name, since on PHP 4 it will not be defined
+ {
+ $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n";
+ }
+ // Try to avoid as much as possible disruption to the previous error handling
+ // mechanism in place
+ if($GLOBALS['_xmlrpcs_prev_ehandler'] == '')
+ {
+ // The previous error handler was the default: all we should do is log error
+ // to the default error log (if level high enough)
+ if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode))
+ {
+ error_log($errstring);
+ }
+ }
+ else
+ {
+ // Pass control on to previous error handler, trying to avoid loops...
+ if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler')
+ {
+ // NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers
+ if(is_array($GLOBALS['_xmlrpcs_prev_ehandler']))
+ {
+ // the following works both with static class methods and plain object methods as error handler
+ call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context));
+ }
+ else
+ {
+ $GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context);
+ }
+ }
+ }
+ }
+
+ $GLOBALS['_xmlrpc_debuginfo']='';
+
+ /**
+ * Add a string to the debug info that can be later seralized by the server
+ * as part of the response message.
+ * Note that for best compatbility, the debug string should be encoded using
+ * the $GLOBALS['xmlrpc_internalencoding'] character set.
+ * @param string $m
+ * @access public
+ */
+ function xmlrpc_debugmsg($m)
+ {
+ $GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n";
+ }
+
+ class xmlrpc_server
+ {
+ /// array defining php functions exposed as xmlrpc methods by this server
+ var $dmap=array();
+ /**
+ * Defines how functions in dmap will be invokde: either using an xmlrpc msg object
+ * or plain php values.
+ * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals'
+ */
+ var $functions_parameters_type='xmlrpcvals';
+ /// controls wether the server is going to echo debugging messages back to the client as comments in response body. valid values: 0,1,2,3
+ var $debug = 1;
+ /**
+ * When set to true, it will enable HTTP compression of the response, in case
+ * the client has declared its support for compression in the request.
+ */
+ var $compress_response = false;
+ /**
+ * List of http compression methods accepted by the server for requests.
+ * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
+ */
+ var $accepted_compression = array();
+ /// shall we serve calls to system.* methods?
+ var $allow_system_funcs = true;
+ /// list of charset encodings natively accepted for requests
+ var $accepted_charset_encodings = array();
+ /**
+ * charset encoding to be used for response.
+ * NB: if we can, we will convert the generated response from internal_encoding to the intended one.
+ * can be: a supported xml encoding (only UTF-8 and ISO-8859-1 at present, unless mbstring is enabled),
+ * null (leave unspecified in response, convert output stream to US_ASCII),
+ * 'default' (use xmlrpc library default as specified in xmlrpc.inc, convert output stream if needed),
+ * or 'auto' (use client-specified charset encoding or same as request if request headers do not specify it (unless request is US-ASCII: then use library default anyway).
+ * NB: pretty dangerous if you accept every charset and do not have mbstring enabled)
+ */
+ var $response_charset_encoding = '';
+ /// storage for internal debug info
+ var $debug_info = '';
+ /// extra data passed at runtime to method handling functions. Used only by EPI layer
+ var $user_data = null;
+
+ /**
+ * @param array $dispmap the dispatch map withd efinition of exposed services
+ * @param boolean $servicenow set to false to prevent the server from runnung upon construction
+ */
+ function xmlrpc_server($dispMap=null, $serviceNow=true)
+ {
+ // if ZLIB is enabled, let the server by default accept compressed requests,
+ // and compress responses sent to clients that support them
+ if(function_exists('gzinflate'))
+ {
+ $this->accepted_compression = array('gzip', 'deflate');
+ $this->compress_response = true;
+ }
+
+ // by default the xml parser can support these 3 charset encodings
+ $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
+
+ // dispMap is a dispatch array of methods
+ // mapped to function names and signatures
+ // if a method
+ // doesn't appear in the map then an unknown
+ // method error is generated
+ /* milosch - changed to make passing dispMap optional.
+ * instead, you can use the class add_to_map() function
+ * to add functions manually (borrowed from SOAPX4)
+ */
+ if($dispMap)
+ {
+ $this->dmap = $dispMap;
+ if($serviceNow)
+ {
+ $this->service();
+ }
+ }
+ }
+
+ /**
+ * Set debug level of server.
+ * @param integer $in debug lvl: determines info added to xmlrpc responses (as xml comments)
+ * 0 = no debug info,
+ * 1 = msgs set from user with debugmsg(),
+ * 2 = add complete xmlrpc request (headers and body),
+ * 3 = add also all processing warnings happened during method processing
+ * (NB: this involves setting a custom error handler, and might interfere
+ * with the standard processing of the php function exposed as method. In
+ * particular, triggering an USER_ERROR level error will not halt script
+ * execution anymore, but just end up logged in the xmlrpc response)
+ * Note that info added at elevel 2 and 3 will be base64 encoded
+ * @access public
+ */
+ function setDebug($in)
+ {
+ $this->debug=$in;
+ }
+
+ /**
+ * Return a string with the serialized representation of all debug info
+ * @param string $charset_encoding the target charset encoding for the serialization
+ * @return string an XML comment (or two)
+ */
+ function serializeDebug($charset_encoding='')
+ {
+ // Tough encoding problem: which internal charset should we assume for debug info?
+ // It might contain a copy of raw data received from client, ie with unknown encoding,
+ // intermixed with php generated data and user generated data...
+ // so we split it: system debug is base 64 encoded,
+ // user debug info should be encoded by the end user using the INTERNAL_ENCODING
+ $out = '';
+ if ($this->debug_info != '')
+ {
+ $out .= "\n";
+ }
+ if($GLOBALS['_xmlrpc_debuginfo']!='')
+ {
+
+ $out .= "\n";
+ // NB: a better solution MIGHT be to use CDATA, but we need to insert it
+ // into return payload AFTER the beginning tag
+ //$out .= "', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n";
+ }
+ return $out;
+ }
+
+ /**
+ * Execute the xmlrpc request, printing the response
+ * @param string $data the request body. If null, the http POST request will be examined
+ * @return xmlrpcresp the response object (usually not used by caller...)
+ * @access public
+ */
+ function service($data=null, $return_payload=false)
+ {
+ if ($data === null)
+ {
+ // workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA
+ $ver = phpversion();
+ if ($ver[0] >= 5)
+ {
+ $data = file_get_contents('php://input');
+ }
+ else
+ {
+ $data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
+ }
+ }
+ $raw_data = $data;
+
+ // reset internal debug info
+ $this->debug_info = '';
+
+ // Echo back what we received, before parsing it
+ if($this->debug > 1)
+ {
+ $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++");
+ }
+
+ $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding);
+ if (!$r)
+ {
+ $r=$this->parseRequest($data, $req_charset);
+ }
+
+ // save full body of request into response, for more debugging usages
+ $r->raw_data = $raw_data;
+
+ if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors'])
+ {
+ $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
+ $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++");
+ }
+
+ $payload=$this->xml_header($resp_charset);
+ if($this->debug > 0)
+ {
+ $payload = $payload . $this->serializeDebug($resp_charset);
+ }
+
+ // G. Giunta 2006-01-27: do not create response serialization if it has
+ // already happened. Helps building json magic
+ if (empty($r->payload))
+ {
+ $r->serialize($resp_charset);
+ }
+ $payload = $payload . $r->payload;
+
+ if ($return_payload)
+ {
+ return $payload;
+ }
+
+ // if we get a warning/error that has output some text before here, then we cannot
+ // add a new header. We cannot say we are sending xml, either...
+ if(!headers_sent())
+ {
+ header('Content-Type: '.$r->content_type);
+ // we do not know if client actually told us an accepted charset, but if he did
+ // we have to tell him what we did
+ header("Vary: Accept-Charset");
+
+ // http compression of output: only
+ // if we can do it, and we want to do it, and client asked us to,
+ // and php ini settings do not force it already
+ $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler');
+ if($this->compress_response && function_exists('gzencode') && $resp_encoding != ''
+ && $php_no_self_compress)
+ {
+ if(strpos($resp_encoding, 'gzip') !== false)
+ {
+ $payload = gzencode($payload);
+ header("Content-Encoding: gzip");
+ header("Vary: Accept-Encoding");
+ }
+ elseif (strpos($resp_encoding, 'deflate') !== false)
+ {
+ $payload = gzcompress($payload);
+ header("Content-Encoding: deflate");
+ header("Vary: Accept-Encoding");
+ }
+ }
+
+ // do not ouput content-length header if php is compressing output for us:
+ // it will mess up measurements
+ if($php_no_self_compress)
+ {
+ header('Content-Length: ' . (int)strlen($payload));
+ }
+ }
+ else
+ {
+ error_log('XML-RPC: xmlrpc_server::service: http headers already sent before response is fully generated. Check for php warning or error messages');
+ }
+
+ print $payload;
+
+ // return request, in case subclasses want it
+ return $r;
+ }
+
+ /**
+ * Add a method to the dispatch map
+ * @param string $methodname the name with which the method will be made available
+ * @param string $function the php function that will get invoked
+ * @param array $sig the array of valid method signatures
+ * @param string $doc method documentation
+ * @param array $sigdoc the array of valid method signatures docs (one string per param, one for return type)
+ * @access public
+ */
+ function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false)
+ {
+ $this->dmap[$methodname] = array(
+ 'function' => $function,
+ 'docstring' => $doc
+ );
+ if ($sig)
+ {
+ $this->dmap[$methodname]['signature'] = $sig;
+ }
+ if ($sigdoc)
+ {
+ $this->dmap[$methodname]['signature_docs'] = $sigdoc;
+ }
+ }
+
+ /**
+ * Verify type and number of parameters received against a list of known signatures
+ * @param array $in array of either xmlrpcval objects or xmlrpc type definitions
+ * @param array $sig array of known signatures to match against
+ * @access private
+ */
+ function verifySignature($in, $sig)
+ {
+ // check each possible signature in turn
+ if (is_object($in))
+ {
+ $numParams = $in->getNumParams();
+ }
+ else
+ {
+ $numParams = count($in);
+ }
+ foreach($sig as $cursig)
+ {
+ if(count($cursig)==$numParams+1)
+ {
+ $itsOK=1;
+ for($n=0; $n<$numParams; $n++)
+ {
+ if (is_object($in))
+ {
+ $p=$in->getParam($n);
+ if($p->kindOf() == 'scalar')
+ {
+ $pt=$p->scalartyp();
+ }
+ else
+ {
+ $pt=$p->kindOf();
+ }
+ }
+ else
+ {
+ $pt= $in[$n] == 'i4' ? 'int' : $in[$n]; // dispatch maps never use i4...
+ }
+
+ // param index is $n+1, as first member of sig is return type
+ if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue'])
+ {
+ $itsOK=0;
+ $pno=$n+1;
+ $wanted=$cursig[$n+1];
+ $got=$pt;
+ break;
+ }
+ }
+ if($itsOK)
+ {
+ return array(1,'');
+ }
+ }
+ }
+ if(isset($wanted))
+ {
+ return array(0, "Wanted ${wanted}, got ${got} at param ${pno}");
+ }
+ else
+ {
+ return array(0, "No method signature matches number of parameters");
+ }
+ }
+
+ /**
+ * Parse http headers received along with xmlrpc request. If needed, inflate request
+ * @return null on success or an xmlrpcresp
+ * @access private
+ */
+ function parseRequestHeaders(&$data, &$req_encoding, &$resp_encoding, &$resp_compression)
+ {
+ // Play nice to PHP 4.0.x: superglobals were not yet invented...
+ if(!isset($_SERVER))
+ {
+ $_SERVER = $GLOBALS['HTTP_SERVER_VARS'];
+ }
+
+ if($this->debug > 1)
+ {
+ if(function_exists('getallheaders'))
+ {
+ $this->debugmsg(''); // empty line
+ foreach(getallheaders() as $name => $val)
+ {
+ $this->debugmsg("HEADER: $name: $val");
+ }
+ }
+
+ }
+
+ if(isset($_SERVER['HTTP_CONTENT_ENCODING']))
+ {
+ $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']);
+ }
+ else
+ {
+ $content_encoding = '';
+ }
+
+ // check if request body has been compressed and decompress it
+ if($content_encoding != '' && strlen($data))
+ {
+ if($content_encoding == 'deflate' || $content_encoding == 'gzip')
+ {
+ // if decoding works, use it. else assume data wasn't gzencoded
+ if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression))
+ {
+ if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data))
+ {
+ $data = $degzdata;
+ if($this->debug > 1)
+ {
+ $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
+ }
+ }
+ elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10)))
+ {
+ $data = $degzdata;
+ if($this->debug > 1)
+ $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++");
+ }
+ else
+ {
+ $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_decompress_fail'], $GLOBALS['xmlrpcstr']['server_decompress_fail']);
+ return $r;
+ }
+ }
+ else
+ {
+ //error_log('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
+ $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_cannot_decompress'], $GLOBALS['xmlrpcstr']['server_cannot_decompress']);
+ return $r;
+ }
+ }
+ }
+
+ // check if client specified accepted charsets, and if we know how to fulfill
+ // the request
+ if ($this->response_charset_encoding == 'auto')
+ {
+ $resp_encoding = '';
+ if (isset($_SERVER['HTTP_ACCEPT_CHARSET']))
+ {
+ // here we should check if we can match the client-requested encoding
+ // with the encodings we know we can generate.
+ /// @todo we should parse q=0.x preferences instead of getting first charset specified...
+ $client_accepted_charsets = explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET']));
+ // Give preference to internal encoding
+ $known_charsets = array($GLOBALS['xmlrpc_internalencoding'], 'UTF-8', 'ISO-8859-1', 'US-ASCII');
+ foreach ($known_charsets as $charset)
+ {
+ foreach ($client_accepted_charsets as $accepted)
+ if (strpos($accepted, $charset) === 0)
+ {
+ $resp_encoding = $charset;
+ break;
+ }
+ if ($resp_encoding)
+ break;
+ }
+ }
+ }
+ else
+ {
+ $resp_encoding = $this->response_charset_encoding;
+ }
+
+ if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
+ {
+ $resp_compression = $_SERVER['HTTP_ACCEPT_ENCODING'];
+ }
+ else
+ {
+ $resp_compression = '';
+ }
+
+ // 'guestimate' request encoding
+ /// @todo check if mbstring is enabled and automagic input conversion is on: it might mingle with this check???
+ $req_encoding = guess_encoding(isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '',
+ $data);
+
+ return null;
+ }
+
+ /**
+ * Parse an xml chunk containing an xmlrpc request and execute the corresponding
+ * php function registered with the server
+ * @param string $data the xml request
+ * @param string $req_encoding (optional) the charset encoding of the xml request
+ * @return xmlrpcresp
+ * @access private
+ */
+ function parseRequest($data, $req_encoding='')
+ {
+ // 2005/05/07 commented and moved into caller function code
+ //if($data=='')
+ //{
+ // $data=$GLOBALS['HTTP_RAW_POST_DATA'];
+ //}
+
+ // G. Giunta 2005/02/13: we do NOT expect to receive html entities
+ // so we do not try to convert them into xml character entities
+ //$data = xmlrpc_html_entity_xlate($data);
+
+ $GLOBALS['_xh']=array();
+ $GLOBALS['_xh']['ac']='';
+ $GLOBALS['_xh']['stack']=array();
+ $GLOBALS['_xh']['valuestack'] = array();
+ $GLOBALS['_xh']['params']=array();
+ $GLOBALS['_xh']['pt']=array();
+ $GLOBALS['_xh']['isf']=0;
+ $GLOBALS['_xh']['isf_reason']='';
+ $GLOBALS['_xh']['method']=false; // so we can check later if we got a methodname or not
+ $GLOBALS['_xh']['rt']='';
+
+ // decompose incoming XML into request structure
+ if ($req_encoding != '')
+ {
+ if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
+ // the following code might be better for mb_string enabled installs, but
+ // makes the lib about 200% slower...
+ //if (!is_valid_charset($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
+ {
+ error_log('XML-RPC: xmlrpc_server::parseRequest: invalid charset encoding of received request: '.$req_encoding);
+ $req_encoding = $GLOBALS['xmlrpc_defencoding'];
+ }
+ /// @BUG this will fail on PHP 5 if charset is not specified in the xml prologue,
+ // the encoding is not UTF8 and there are non-ascii chars in the text...
+ /// @todo use an ampty string for php 5 ???
+ $parser = xml_parser_create($req_encoding);
+ }
+ else
+ {
+ $parser = xml_parser_create();
+ }
+
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
+ // G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell
+ // the xml parser to give us back data in the expected charset
+ // What if internal encoding is not in one of the 3 allowed?
+ // we use the broadest one, ie. utf8
+ // This allows to send data which is native in various charset,
+ // by extending xmlrpc_encode_entitites() and setting xmlrpc_internalencoding
+ if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII')))
+ {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
+ }
+ else
+ {
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']);
+ }
+
+ if ($this->functions_parameters_type != 'xmlrpcvals')
+ xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast');
+ else
+ xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
+ xml_set_character_data_handler($parser, 'xmlrpc_cd');
+ xml_set_default_handler($parser, 'xmlrpc_dh');
+ if(!xml_parse($parser, $data, 1))
+ {
+ // return XML error as a faultCode
+ $r=&new xmlrpcresp(0,
+ $GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser),
+ sprintf('XML error: %s at line %d, column %d',
+ xml_error_string(xml_get_error_code($parser)),
+ xml_get_current_line_number($parser), xml_get_current_column_number($parser)));
+ xml_parser_free($parser);
+ }
+ elseif ($GLOBALS['_xh']['isf'])
+ {
+ xml_parser_free($parser);
+ $r=&new xmlrpcresp(0,
+ $GLOBALS['xmlrpcerr']['invalid_request'],
+ $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']);
+ }
+ else
+ {
+ xml_parser_free($parser);
+ if ($this->functions_parameters_type != 'xmlrpcvals')
+ {
+ if($this->debug > 1)
+ {
+ $this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++");
+ }
+ $r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt']);
+ }
+ else
+ {
+ // build an xmlrpcmsg object with data parsed from xml
+ $m=&new xmlrpcmsg($GLOBALS['_xh']['method']);
+ // now add parameters in
+ for($i=0; $iaddParam($GLOBALS['_xh']['params'][$i]);
+ }
+
+ if($this->debug > 1)
+ {
+ $this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++");
+ }
+ $r = $this->execute($m);
+ }
+ }
+ return $r;
+ }
+
+ /**
+ * Execute a method invoked by the client, checking parameters used
+ * @param mixed $m either an xmlrpcmsg obj or a method name
+ * @param array $params array with method parameters as php types (if m is method name only)
+ * @param array $paramtypes array with xmlrpc types of method parameters (if m is method name only)
+ * @return xmlrpcresp
+ * @access private
+ */
+ function execute($m, $params=null, $paramtypes=null)
+ {
+ if (is_object($m))
+ {
+ $methName = $m->method();
+ }
+ else
+ {
+ $methName = $m;
+ }
+ $sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0);
+ $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap;
+
+ if(!isset($dmap[$methName]['function']))
+ {
+ // No such method
+ return new xmlrpcresp(0,
+ $GLOBALS['xmlrpcerr']['unknown_method'],
+ $GLOBALS['xmlrpcstr']['unknown_method']);
+ }
+
+ // Check signature
+ if(isset($dmap[$methName]['signature']))
+ {
+ $sig = $dmap[$methName]['signature'];
+ if (is_object($m))
+ {
+ list($ok, $errstr) = $this->verifySignature($m, $sig);
+ }
+ else
+ {
+ list($ok, $errstr) = $this->verifySignature($paramtypes, $sig);
+ }
+ if(!$ok)
+ {
+ // Didn't match.
+ return new xmlrpcresp(
+ 0,
+ $GLOBALS['xmlrpcerr']['incorrect_params'],
+ $GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}"
+ );
+ }
+ }
+
+ $func = $dmap[$methName]['function'];
+ // let the 'class::function' syntax be accepted in dispatch maps
+ if(is_string($func) && strpos($func, '::'))
+ {
+ $func = explode('::', $func);
+ }
+ // verify that function to be invoked is in fact callable
+ if(!is_callable($func))
+ {
+ error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler is not callable");
+ return new xmlrpcresp(
+ 0,
+ $GLOBALS['xmlrpcerr']['server_error'],
+ $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method"
+ );
+ }
+
+ // If debug level is 3, we should catch all errors generated during
+ // processing of user function, and log them as part of response
+ if($this->debug > 2)
+ {
+ $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler');
+ }
+ if (is_object($m))
+ {
+ if($sysCall)
+ {
+ $r = call_user_func($func, $this, $m);
+ }
+ else
+ {
+ $r = call_user_func($func, $m);
+ }
+ if (!is_a($r, 'xmlrpcresp'))
+ {
+ error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler does not return an xmlrpcresp object");
+ if (is_a($r, 'xmlrpcval'))
+ {
+ $r =& new xmlrpcresp($r);
+ }
+ else
+ {
+ $r =& new xmlrpcresp(
+ 0,
+ $GLOBALS['xmlrpcerr']['server_error'],
+ $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object"
+ );
+ }
+ }
+ }
+ else
+ {
+ // call a 'plain php' function
+ if($sysCall)
+ {
+ array_unshift($params, $this);
+ $r = call_user_func_array($func, $params);
+ }
+ else
+ {
+ // 3rd API convention for method-handling functions: EPI-style
+ if ($this->functions_parameters_type == 'epivals')
+ {
+ $r = call_user_func_array($func, array($methName, $params, $this->user_data));
+ // mimic EPI behaviour: if we get an array that looks like an error, make it
+ // an eror response
+ if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r))
+ {
+ $r =& new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']);
+ }
+ else
+ {
+ // functions using EPI api should NOT return resp objects,
+ // so make sure we encode the return type correctly
+ $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api')));
+ }
+ }
+ else
+ {
+ $r = call_user_func_array($func, $params);
+ }
+ }
+ // the return type can be either an xmlrpcresp object or a plain php value...
+ if (!is_a($r, 'xmlrpcresp'))
+ {
+ // what should we assume here about automatic encoding of datetimes
+ // and php classes instances???
+ $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('auto_dates')));
+ }
+ }
+ if($this->debug > 2)
+ {
+ // note: restore the error handler we found before calling the
+ // user func, even if it has been changed inside the func itself
+ if($GLOBALS['_xmlrpcs_prev_ehandler'])
+ {
+ set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']);
+ }
+ else
+ {
+ restore_error_handler();
+ }
+ }
+ return $r;
+ }
+
+ /**
+ * add a string to the 'internal debug message' (separate from 'user debug message')
+ * @param string $strings
+ * @access private
+ */
+ function debugmsg($string)
+ {
+ $this->debug_info .= $string."\n";
+ }
+
+ /**
+ * @access private
+ */
+ function xml_header($charset_encoding='')
+ {
+ if ($charset_encoding != '')
+ {
+ return "\n";
+ }
+ else
+ {
+ return "\n";
+ }
+ }
+
+ /**
+ * A debugging routine: just echoes back the input packet as a string value
+ * DEPRECATED!
+ */
+ function echoInput()
+ {
+ $r=&new xmlrpcresp(new xmlrpcval( "'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string'));
+ print $r->serialize();
+ }
+ }
+?>
\ No newline at end of file
From 5dbbcaeaf1291f8259b7a3cd42efa6c0487afd43 Mon Sep 17 00:00:00 2001
From: Luke Hudson
Date: Tue, 8 Dec 2009 22:58:18 +0000
Subject: [PATCH 183/250] BUGFIX: Extend URL length from 50 to 2048 chars
---
code/TrackBackPing.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/code/TrackBackPing.php b/code/TrackBackPing.php
index a38771a..0ebec77 100644
--- a/code/TrackBackPing.php
+++ b/code/TrackBackPing.php
@@ -4,7 +4,9 @@ class TrackBackPing extends DataObject {
static $db = array(
'Title' => 'Varchar',
'Excerpt' => 'Text',
- 'Url' => 'Varchar',
+ // 2083 is URL-length limit for IE, AFAIK.
+ // see: http://www.boutell.com/newfaq/misc/urllength.html
+ 'Url' => 'Varchar(2048)',
'BlogName' => 'Varchar'
);
From e52171bf75d34ccf3e15e720414a7ed4fece99b5 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Thu, 17 Dec 2009 08:00:34 +0000
Subject: [PATCH 184/250] Allow extending of blog holder fields
---
code/BlogHolder.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 36e7e99..74aa094 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -28,12 +28,16 @@ class BlogHolder extends BlogTree implements PermissionProvider {
);
function getCMSFields() {
+ SiteTree::disableCMSFieldsExtensions();
$fields = parent::getCMSFields();
+ SiteTree::enableCMSFieldsExtensions();
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', DataObject::get('Member')->toDropDownMap('ID', 'Name', 'None')));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
+ $this->extend('updateCMSFields', $fields);
+
return $fields;
}
From a7f024bc45edd95328ff053062c03b3696b016a2 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Sun, 20 Dec 2009 00:31:24 +0000
Subject: [PATCH 185/250] Use "date" for archives, using numbers directly
causes too many problems
---
code/BlogHolder.php | 12 +-----------
code/BlogTree.php | 20 +++++++++++---------
code/widgets/ArchiveWidget.php | 4 ++--
3 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 74aa094..ee825f7 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -135,6 +135,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
static $allowed_actions = array(
'index',
'tag',
+ 'date',
'metaweblog',
'postblog' => 'BLOGMANAGEMENT',
'post' => 'BLOGMANAGEMENT',
@@ -145,17 +146,6 @@ class BlogHolder_Controller extends BlogTree_Controller {
parent::init();
Requirements::themedCSS("bbcodehelp");
}
-
- /**
- * TODO: this is an urgent fix to work with archive link (e.g. page_url/2009/04). Replace this with something better.
- */
- function checkAccessAction($action) {
- if(preg_match('/[0-9]{4}/', $action)) {
- return true;
- }
-
- return parent::checkAccessAction($action);
- }
/**
* Return list of usable tags for help
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 1c0dadb..72d3eb0 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -196,16 +196,18 @@ class BlogTree_URL {
}
static function date() {
- $year = Director::urlParam('Action');
- $month = Director::urlParam('ID');
-
- if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
- return "$year-$month";
- } elseif (is_numeric($year)) {
- return $year;
+ if(Director::urlParam('Action') == 'date') {
+ $year = Director::urlParam('ID');
+ $month = Director::urlParam('OtherID');
+
+ if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
+ return "$year-$month";
+ } elseif (is_numeric($year)) {
+ return $year;
+ }
+
+ return '';
}
-
- return '';
}
}
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index a423a49..583526f 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -81,9 +81,9 @@ class ArchiveWidget extends Widget {
));
if($isMonthDisplay) {
- $link = $container->Link($sqlResult['Year']) . '/' . sprintf("%'02d", $monthVal);
+ $link = $container->Link('date') . '/' . $sqlResult['Year'] . '/' . sprintf("%'02d", $monthVal);
} else {
- $link = $container->Link($sqlResult['Year']);
+ $link = $container->Link('date') . '/' . $sqlResult['Year'];
}
$results->push(new ArrayData(array(
From eb1dc8019e856ddb15d2b5ec7e0104c2003b4a76 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Tue, 22 Dec 2009 02:58:33 +0000
Subject: [PATCH 186/250] MINOR: correct the path to SimplePie include
---
code/widgets/RSSWidget.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/widgets/RSSWidget.php b/code/widgets/RSSWidget.php
index 4dfd6fc..12f913c 100644
--- a/code/widgets/RSSWidget.php
+++ b/code/widgets/RSSWidget.php
@@ -58,7 +58,7 @@ class RSSWidget extends Widget {
return $output;
}
- include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/SimplePie.php'));
+ include_once(Director::getAbsFile(SAPPHIRE_DIR . '/thirdparty/simplepie/simplepie.inc'));
$t1 = microtime(true);
$feed = new SimplePie($this->AbsoluteRssUrl, TEMP_FOLDER);
From 1d2c96b6de04435e1b8252fad7b4765c668174e3 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Tue, 22 Dec 2009 20:55:23 +0000
Subject: [PATCH 187/250] BUGFIX Limiting BlogHolder->LandingPageFreshness to
requests without a controller action only. Controller actions are not
regarded as the "landing page", as they cause other views like 'tags' or
'rss', which shouldn't be filtered
---
code/BlogTree.php | 29 ++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 72d3eb0..16da62f 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -143,9 +143,10 @@ class BlogTree extends Page {
* @param string tag Only get blog entries with this tag
* @param string date Only get blog entries on this date - either a year, or a year-month eg '2008' or '2008-02'
* @param callback retrieveCallback A function to call with pagetype, filter and limit for custom blog sorting or filtering
+ * @param string $where
* @return DataObjectSet
*/
- public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null) {
+ public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null, $filter = '') {
$tagCheck = '';
$dateCheck = '';
@@ -153,7 +154,7 @@ class BlogTree extends Page {
$SQL_tag = Convert::raw2sql($tag);
$tagCheck = "AND \"BlogEntry\".\"Tags\" LIKE '%$SQL_tag%'";
}
-
+
if($date) {
if(strpos($date, '-')) {
$year = (int) substr($date, 0, strpos($date, '-'));
@@ -168,10 +169,8 @@ class BlogTree extends Page {
$dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
}
}
- } elseif ($this->LandingPageFreshness) {
- $dateCheck = "AND \"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
}
-
+
// Build a list of all IDs for BlogHolders that are children of us
$holderIDs = $this->BlogHolderIDs();
@@ -179,13 +178,14 @@ class BlogTree extends Page {
if(empty($holderIDs)) return false;
// Otherwise, do the actual query
- $where = '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
+ if($filter) $filter .= ' AND ';
+ $filter .= '"ParentID" IN (' . implode(',', $holderIDs) . ") $tagCheck $dateCheck";
$order = '"BlogEntry"."Date" DESC';
// By specifying a callback, you can alter the SQL, or sort on something other than date.
- if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $where, $limit, $order);
- else return DataObject::get('BlogEntry', $where, $order, '', $limit);
+ if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $filter, $limit, $order);
+ else return DataObject::get('BlogEntry', $filter, $order, '', $limit);
}
}
@@ -227,9 +227,16 @@ class BlogTree_Controller extends Page_Controller {
function BlogEntries($limit = null) {
if($limit === null) $limit = BlogTree::$default_entries_limit;
-
+
+ // only use freshness if no action is present (might be displaying tags or rss)
+ if ($this->LandingPageFreshness && !$this->request->param('Action')) {
+ $filter = "\"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
+ } else {
+ $filter = '';
+ }
+
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
- return $this->Entries("$start,$limit", BlogTree_URL::tag(), BlogTree_URL::date());
+ return $this->Entries("$start,$limit", BlogTree_URL::tag(), BlogTree_URL::date(), null, $filter);
}
function IncludeBlogRSS() {
@@ -262,4 +269,4 @@ class BlogTree_Controller extends Page_Controller {
}
}
-?>
+?>
\ No newline at end of file
From b2802248d5313ab87a8384539f5184c9e53b5f19 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Wed, 13 Jan 2010 01:05:34 +0000
Subject: [PATCH 188/250] BUGFIX: Remove test that is no longer needed
---
tests/BlogHolderTest.php | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/tests/BlogHolderTest.php b/tests/BlogHolderTest.php
index 1941258..9d6b653 100644
--- a/tests/BlogHolderTest.php
+++ b/tests/BlogHolderTest.php
@@ -53,18 +53,7 @@ class BlogHolderTest extends SapphireTest {
$this->assertContains($entry->URLSegment, $expectedEntries);
}
}
-
- function testcheckAccessAction() {
- $blogHolder = new BlogHolder_Controller();
- $this->assertTrue($blogHolder->checkAccessAction('2009'));
- $this->assertTrue($blogHolder->checkAccessAction('0001'));
- $this->assertTrue($blogHolder->checkAccessAction('12345'));
-
- $this->assertFalse($blogHolder->checkAccessAction('209'));
- $this->assertFalse($blogHolder->checkAccessAction('123A'));
- $this->assertFalse($blogHolder->checkAccessAction('ab01a'));
- }
}
?>
From 05bc46acacfe71e56fbe84cdf86689420013843b Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Fri, 22 Jan 2010 02:02:35 +0000
Subject: [PATCH 189/250] MINOR: renames BlogHolder.ss to BlogTree.ss so that
blog tree will have a template while the template still applies to blog
holder
---
templates/Layout/{BlogHolder.ss => BlogTree.ss} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename templates/Layout/{BlogHolder.ss => BlogTree.ss} (100%)
diff --git a/templates/Layout/BlogHolder.ss b/templates/Layout/BlogTree.ss
similarity index 100%
rename from templates/Layout/BlogHolder.ss
rename to templates/Layout/BlogTree.ss
From aa32a6a55d3b275acc91aee2df03fbe3dd0814c8 Mon Sep 17 00:00:00 2001
From: Andreas Piening
Date: Mon, 1 Feb 2010 05:27:18 +0000
Subject: [PATCH 190/250] MINOR: substituted proprietary SQL datetime operation
---
code/BlogTree.php | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 16da62f..d6b81e3 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -159,14 +159,22 @@ class BlogTree extends Page {
if(strpos($date, '-')) {
$year = (int) substr($date, 0, strpos($date, '-'));
$month = (int) substr($date, strpos($date, '-') + 1);
-
+
if($year && $month) {
- $dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
+ if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
+ $dateCheck = 'AND ' . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%m') . " * 1 = $month AND " . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%Y') . " = '$year'";
+ } else {
+ $dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
+ }
}
} else {
$year = (int) $date;
if($year) {
- $dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
+ if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
+ $dateCheck = "AND " . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%Y') . " = '$year'";
+ } else {
+ $dateCheck = "AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
+ }
}
}
}
From 2a9ea56c39417c085f0397bde8c0e01b65776bcc Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Tue, 2 Feb 2010 00:26:17 +0000
Subject: [PATCH 191/250] MINOR: revert r97442
---
templates/Layout/{BlogTree.ss => BlogHolder.ss} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename templates/Layout/{BlogTree.ss => BlogHolder.ss} (100%)
diff --git a/templates/Layout/BlogTree.ss b/templates/Layout/BlogHolder.ss
similarity index 100%
rename from templates/Layout/BlogTree.ss
rename to templates/Layout/BlogHolder.ss
From 54b1c070493dff372090253e8c128bbfe8b87226 Mon Sep 17 00:00:00 2001
From: Andreas Piening
Date: Tue, 2 Feb 2010 04:27:06 +0000
Subject: [PATCH 192/250] MINOR: added datetime helper function
---
code/widgets/ArchiveWidget.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index 583526f..1f4e65c 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -51,16 +51,18 @@ class ArchiveWidget extends Widget {
$stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
+ $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') . ' * 1' : 'MONTH("Date")';
+ $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
if($this->DisplayMode == 'month') {
$sqlResults = DB::query("
- SELECT DISTINCT MONTH(\"Date\") AS \"Month\", YEAR(\"Date\") AS \"Year\"
+ SELECT DISTINCT $monthclause AS \"Month\", $yearclause AS \"Year\"
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
ORDER BY \"Year\" DESC, \"Month\" DESC;"
);
} else {
$sqlResults = DB::query("
- SELECT DISTINCT YEAR(\"Date\") AS \"Year\"
+ SELECT DISTINCT $yearclause AS \"Year\"
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
ORDER BY \"Year\" DESC"
From 0bf95f21c3cfc411b16e3ca372198aa4da12bcf3 Mon Sep 17 00:00:00 2001
From: Andrew O'Neil
Date: Fri, 12 Feb 2010 23:47:43 +0000
Subject: [PATCH 193/250] BUGFIX: Sometimes link doesnt work correctly
---
code/BlogEntry.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index c02e0f0..6f5c0d1 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -100,10 +100,12 @@ class BlogEntry extends Page {
$tags = split(" *, *", trim($this->Tags));
$output = new DataObjectSet();
+ $link = $this->getParent() ? $this->getParent()->Link('tag') : '';
+
foreach($tags as $tag) {
$output->push(new ArrayData(array(
'Tag' => $tag,
- 'Link' => $this->getParent()->Link('tag') . '/' . urlencode($tag),
+ 'Link' => $link . '/' . urlencode($tag),
'URLTag' => urlencode($tag)
)));
}
From e45daff36eb458b6994119298f68f026c2b03d64 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Wed, 17 Feb 2010 05:04:17 +0000
Subject: [PATCH 194/250] ENHANCEMENT Adjusted BlogEntry to new DatetimeField
API replacing PopupDateTimeField
---
code/BlogEntry.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 6f5c0d1..10499aa 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -77,7 +77,9 @@ class BlogEntry extends Page {
$fields->addFieldToTab("Root.Content.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20));
}
- $fields->addFieldToTab("Root.Content.Main", new PopupDateTimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
+ $fields->addFieldToTab("Root.Content.Main", $dateField = new DatetimeField("Date", _t("BlogEntry.DT", "Date")),"Content");
+ $dateField->getDateField()->setConfig('showcalendar', true);
+ $dateField->getTimeField()->setConfig('showdropdown', true);
$fields->addFieldToTab("Root.Content.Main", new TextField("Author", _t("BlogEntry.AU", "Author"), $firstName),"Content");
if(!self::$allow_wysiwyg_editing) {
From 3198619d0b6d0af100ef5cbedccd7cd3a0846c50 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Thu, 25 Feb 2010 04:24:22 +0000
Subject: [PATCH 195/250] ENHANCEMENT Blog widgets now respect updateCMSFields
- related to r99929
---
code/widgets/ArchiveWidget.php | 6 +++++-
code/widgets/RSSWidget.php | 6 +++++-
code/widgets/TagCloudWidget.php | 6 +++++-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index 1f4e65c..db633e8 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -29,7 +29,7 @@ class ArchiveWidget extends Widget {
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
function getCMSFields() {
- return new FieldSet(
+ $fields = new FieldSet(
new OptionsetField(
'DisplayMode',
_t('ArchiveWidget.DispBY', 'Display by'),
@@ -39,6 +39,10 @@ class ArchiveWidget extends Widget {
)
)
);
+
+ $this->extend('updateCMSFields', $fields);
+
+ return $fields;
}
function Dates() {
diff --git a/code/widgets/RSSWidget.php b/code/widgets/RSSWidget.php
index 12f913c..5209c42 100644
--- a/code/widgets/RSSWidget.php
+++ b/code/widgets/RSSWidget.php
@@ -40,11 +40,15 @@ class RSSWidget extends Widget {
}
function getCMSFields() {
- return new FieldSet(
+ $fields = new FieldSet(
new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
new TextField("RssUrl", _t('RSSWidget.URL', "URL of the other page's RSS feed. Please make sure this URL points to an RSS feed.")),
new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show"))
);
+
+ $this->extend('updateCMSFields', $fields);
+
+ return $fields;
}
function Title() {
return ($this->RSSTitle) ? $this->RSSTitle : 'RSS Feed';
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index 4e120db..2fe130a 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -27,11 +27,15 @@ class TagCloudWidget extends Widget {
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
function getCMSFields() {
- return new FieldSet(
+ $fields = new FieldSet(
new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
new TextField("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")),
new OptionsetField("Sortby",_t("TagCloudWidget.SORTBY","Sort by"),array("alphabet"=>_t("TagCloudWidget.SBAL", "alphabet"),"frequency"=>_t("TagCloudWidget.SBFREQ", "frequency")))
);
+
+ $this->extend('updateCMSFields', $fields);
+
+ return $fields;
}
function Title() {
From c23b49323f31060093d589d659fc6a63224509a6 Mon Sep 17 00:00:00 2001
From: Geoff Munn
Date: Mon, 8 Mar 2010 22:08:21 +0000
Subject: [PATCH 196/250] BUG FIX: month calculation system fixed to be
database-agnostic
---
code/widgets/ArchiveWidget.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index db633e8..1186fb7 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -55,11 +55,12 @@ class ArchiveWidget extends Widget {
$stage = Versioned::current_stage();
$suffix = (!$stage || $stage == 'Stage') ? "" : "_$stage";
- $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') . ' * 1' : 'MONTH("Date")';
- $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
+ $monthclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%m') : 'MONTH("Date")';
+ $yearclause = method_exists(DB::getConn(), 'formattedDatetimeClause') ? DB::getConn()->formattedDatetimeClause('"Date"', '%Y') : 'YEAR("Date")';
+
if($this->DisplayMode == 'month') {
$sqlResults = DB::query("
- SELECT DISTINCT $monthclause AS \"Month\", $yearclause AS \"Year\"
+ SELECT DISTINCT CAST($monthclause AS " . DB::getConn()->dbDataType('unsigned integer') . ") AS \"Month\", $yearclause AS \"Year\"
FROM \"SiteTree$suffix\" INNER JOIN \"BlogEntry$suffix\" ON \"SiteTree$suffix\".\"ID\" = \"BlogEntry$suffix\".\"ID\"
WHERE \"ParentID\" IN (" . implode(', ', $ids) . ")
ORDER BY \"Year\" DESC, \"Month\" DESC;"
From 5d2019f2467a58aebfe8680f4c84c5b4a54cdde4 Mon Sep 17 00:00:00 2001
From: Geoff Munn
Date: Thu, 11 Mar 2010 20:47:59 +0000
Subject: [PATCH 197/250] BUG FIX: table and column names quoted properly
---
code/widgets/BlogManagementWidget.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/widgets/BlogManagementWidget.php b/code/widgets/BlogManagementWidget.php
index 59682f2..2547eb9 100644
--- a/code/widgets/BlogManagementWidget.php
+++ b/code/widgets/BlogManagementWidget.php
@@ -21,7 +21,7 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
function CommentText() {
- $unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
+ $unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
if($unmoderatedcount == 1) {
return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment");
} else if($unmoderatedcount > 1) {
@@ -35,7 +35,7 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
if(!Permission::check('BLOGMANAGEMENT')) {
return false;
}
- $unmoderatedcount = DB::query("SELECT COUNT(*) FROM PageComment WHERE NeedsModeration=1")->value();
+ $unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
if($unmoderatedcount > 0) {
return "admin/comments/unmoderated";
From c31bb7e6b6ec071609219a07c9069c74d8bfcb0a Mon Sep 17 00:00:00 2001
From: Tom Rix
Date: Fri, 19 Mar 2010 00:15:41 +0000
Subject: [PATCH 198/250] MINOR improve test coverage
---
code/BlogTree.php | 11 ++++--
tests/BlogTreeTest.php | 78 ++++++++++++++++++++++++++++++++++++++++++
tests/BlogTreeTest.yml | 8 +++++
3 files changed, 94 insertions(+), 3 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index d6b81e3..9d67d6b 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -36,11 +36,16 @@ class BlogTree extends Page {
* - If this page is a BlogTree, use that
* - If this page is a BlogEntry, use the parent Holder
* - Otherwise, try and find a 'top-level' BlogTree
+ *
+ * @param $page allows you to force a specific page, otherwise,
+ * uses current
*/
- static function current() {
+ static function current($page = null) {
- $controller = Controller::curr();
- if($controller) $page = $controller->data();
+ if (!$page) {
+ $controller = Controller::curr();
+ if($controller) $page = $controller->data();
+ }
// If we _are_ a BlogTree, use us
if ($page instanceof BlogTree) return $page;
diff --git a/tests/BlogTreeTest.php b/tests/BlogTreeTest.php
index 69daa82..cdf1485 100644
--- a/tests/BlogTreeTest.php
+++ b/tests/BlogTreeTest.php
@@ -21,10 +21,88 @@ class BlogTreeTest extends SapphireTest {
$node = $this->objFromFixture('BlogTree', 'levelba');
$this->assertEquals($node->Entries()->Count(), 1);
+
+ $this->assertTrue($node->getCMSFields() instanceof FieldSet);
}
+ function testEntriesByMonth() {
+ $node = $this->objFromFixture('BlogTree', 'root');
+
+ $entries = $node->Entries('', '', '2008-01');
+ $this->assertEquals($entries->Count(), 2);
+ $expectedEntries = array(
+ 'test-post-2',
+ 'test-post-3'
+ );
+
+ foreach($entries as $entry) {
+ $this->assertContains($entry->URLSegment, $expectedEntries);
+ }
+ }
+ function textEntriesByYear() {
+ $node = $this->objFromFixture('BlogTree', 'root');
+
+ $entries = $node->Entries('', '', '2008');
+ $this->assertEquals($entries->Count(), 2);
+ $expectedEntries = array(
+ 'test-post-2',
+ 'test-post-3'
+ );
+
+ foreach($entries as $entry) {
+ $this->assertContains($entry->URLSegment, $expectedEntries);
+ }
+ }
+ function testEntriesByTag() {
+ $node = $this->objFromFixture('BlogTree', 'root');
+
+ $entries = $node->Entries('', 'tag3', '');
+ $this->assertEquals($entries->Count(), 2);
+ $expectedEntries = array(
+ 'test-post-2',
+ 'test-post-3'
+ );
+
+ foreach($entries as $entry) {
+ $this->assertContains($entry->URLSegment, $expectedEntries);
+ }
+ }
+
+ function testLandingPageFreshness() {
+ $node = $this->objFromFixture('BlogTree', 'root');
+ $this->assertEquals($node->LandingPageFreshness, '7 DAYS');
+ $node = $this->objFromFixture('BlogTree', 'levela');
+ $this->assertEquals($node->LandingPageFreshness, '2 DAYS');
+ $node = $this->objFromFixture('BlogTree', 'levelb');
+ $this->assertEquals($node->LandingPageFreshness, '7 DAYS');
+ }
+
+ function testGettingAssociatedBlogTree() {
+ $this->assertEquals(BlogTree::current($this->objFromFixture('BlogTree', 'root'))->Title, 'Root BlogTree');
+ $this->assertEquals(BlogTree::current($this->objFromFixture('BlogHolder', 'levelaa_blog2'))->Title, 'Level AA Blog 2');
+ $this->assertEquals(BlogTree::current($this->objFromFixture('BlogEntry', 'testpost3'))->Title, 'Level BA Blog');
+ }
+
+ function testGettingBlogHolderIDs() {
+ $node = $this->objFromFixture('BlogTree', 'root');
+
+ $expectedIds = array();
+ $expectedIds[] = $this->objFromFixture('BlogHolder', 'levelaa_blog1')->ID;
+ $expectedIds[] = $this->objFromFixture('BlogHolder', 'levelaa_blog2')->ID;
+ $expectedIds[] = $this->objFromFixture('BlogHolder', 'levelab_blog')->ID;
+ $expectedIds[] = $this->objFromFixture('BlogHolder', 'levelba_blog')->ID;
+
+ foreach($node->BlogHolderIDs() as $holderId) {
+ $this->assertContains($holderId, $expectedIds);
+ }
+ $this->assertEquals(count($node->BlogHolderIDs()), count($expectedIds));
+ }
+
+ function testBlogTreeURLFuctions() {
+
+ }
}
?>
diff --git a/tests/BlogTreeTest.yml b/tests/BlogTreeTest.yml
index 3112d40..b66730d 100644
--- a/tests/BlogTreeTest.yml
+++ b/tests/BlogTreeTest.yml
@@ -1,12 +1,17 @@
BlogTree:
root:
Title: Root BlogTree
+ LandingPageFreshness: 7 DAYS
+ otherroot:
+ Title: Other root BlogTree
levela:
Title: Level A
Parent: =>BlogTree.root
+ LandingPageFreshness: 2 DAYS
levelb:
Title: Level B
Parent: =>BlogTree.root
+ LandingPageFreshness: INHERIT
levelaa:
Title: Level AA
Parent: =>BlogTree.levela
@@ -17,9 +22,12 @@ BlogTree:
Title: Level BA
Parent: =>BlogTree.levelb
BlogHolder:
+ otherroot_holder:
+ Title: other root holder
levelaa_blog1:
Title: Level AA Blog 1
Parent: =>BlogTree.levelaa
+ LandingPageFreshness: 1 DAY
levelaa_blog2:
Title: Level AA Blog 2
Parent: =>BlogTree.levelaa
From 7ca1e3447626223d4632c7b02390ad5fa41500bc Mon Sep 17 00:00:00 2001
From: Geoff Munn
Date: Wed, 31 Mar 2010 23:14:52 +0000
Subject: [PATCH 199/250] BUGFIX: columns quoted properly
---
tests/BlogHolderFunctionalTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
index c8b56d4..d737038 100644
--- a/tests/BlogHolderFunctionalTest.php
+++ b/tests/BlogHolderFunctionalTest.php
@@ -31,7 +31,7 @@ class BlogHolderFunctionalTest extends FunctionalTest {
'SecurityID' => $securityID
);
$response = $this->post('blog/BlogEntryForm', $data);
- $this->assertFalse(DataObject::get_one('BlogEntry', sprintf("Title = 'Disallowed'")));
+ $this->assertFalse(DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Disallowed'")));
// with login
$blogEditor = $this->objFromFixture('Member', 'blog_editor');
@@ -47,6 +47,6 @@ class BlogHolderFunctionalTest extends FunctionalTest {
);
$response = $this->post('blog/BlogEntryForm', $data);
- $this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("Title = 'Allowed'")));
+ $this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
}
}
\ No newline at end of file
From 4c91dff9b2d969ad5a7d5d446a4ca3d6816836eb Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Wed, 28 Apr 2010 11:17:22 +0000
Subject: [PATCH 200/250] MINOR Fixed BlogHolderFunctionalTest to work with
nested urls
---
tests/BlogHolderFunctionalTest.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
index d737038..934c524 100644
--- a/tests/BlogHolderFunctionalTest.php
+++ b/tests/BlogHolderFunctionalTest.php
@@ -19,7 +19,7 @@ class BlogHolderFunctionalTest extends FunctionalTest {
function testFrontendBlogPostRequiresPermission() {
// get valid SecurityID (from comments form, would usually be copy/pasted)
$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
- $response = $this->get($blogEntry->URLSegment);
+ $response = $this->get($blogEntry->Link());
$securityID = Session::get('SecurityID');
// without login
@@ -37,7 +37,6 @@ class BlogHolderFunctionalTest extends FunctionalTest {
$blogEditor = $this->objFromFixture('Member', 'blog_editor');
$this->session()->inst_set('loggedInAs', $blogEditor->ID);
Permission::flush_permission_cache();
-
$data = array(
'Title'=>'Allowed',
'Author'=>'Allowed',
From 85854034093d2aedf3439a2d931c0df44bfd1589 Mon Sep 17 00:00:00 2001
From: Sam Minnee
Date: Wed, 28 Apr 2010 11:40:25 +0000
Subject: [PATCH 201/250] MINOR Fixed BlogHolderFunctionalTest links
---
tests/BlogHolderFunctionalTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
index 934c524..e229e0e 100644
--- a/tests/BlogHolderFunctionalTest.php
+++ b/tests/BlogHolderFunctionalTest.php
@@ -19,7 +19,7 @@ class BlogHolderFunctionalTest extends FunctionalTest {
function testFrontendBlogPostRequiresPermission() {
// get valid SecurityID (from comments form, would usually be copy/pasted)
$blogEntry = $this->objFromFixture('BlogEntry', 'entry1');
- $response = $this->get($blogEntry->Link());
+ $response = $this->get($blogEntry->RelativeLink());
$securityID = Session::get('SecurityID');
// without login
@@ -48,4 +48,4 @@ class BlogHolderFunctionalTest extends FunctionalTest {
$this->assertType('BlogEntry', DataObject::get_one('BlogEntry', sprintf("\"Title\" = 'Allowed'")));
}
-}
\ No newline at end of file
+}
From 23e817fe6b7ffea27ddb84804125be9a23c8f845 Mon Sep 17 00:00:00 2001
From: Geoff Munn
Date: Thu, 29 Apr 2010 22:39:40 +0000
Subject: [PATCH 202/250] BUG FIX: date checks now database agnostic
---
code/BlogTree.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 9d67d6b..b88bed8 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -167,7 +167,8 @@ class BlogTree extends Page {
if($year && $month) {
if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
- $dateCheck = 'AND ' . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%m') . " * 1 = $month AND " . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%Y') . " = '$year'";
+ $db_date=DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%m');
+ $dateCheck = "AND CAST($db_date AS " . DB::getConn()->dbDataType('unsigned integer') . ") = $month AND " . DB::getConn()->formattedDatetimeClause('"BlogEntry"."Date"', '%Y') . " = '$year'";
} else {
$dateCheck = "AND MONTH(\"BlogEntry\".\"Date\") = '$month' AND YEAR(\"BlogEntry\".\"Date\") = '$year'";
}
From d38dc82be56038d96fb4bbb4a3e952f446540bb5 Mon Sep 17 00:00:00 2001
From: Felipe Skroski
Date: Wed, 12 May 2010 23:08:05 +0000
Subject: [PATCH 203/250] blog theme
---
templates/ArchiveWidget.ss | 1 +
templates/Includes/BlogSummary.ss | 42 ++++++++++++++--------
templates/Layout/BlogHolder.ss | 58 ++++++++++++++++++++-----------
3 files changed, 67 insertions(+), 34 deletions(-)
diff --git a/templates/ArchiveWidget.ss b/templates/ArchiveWidget.ss
index 198fc53..b69382c 100644
--- a/templates/ArchiveWidget.ss
+++ b/templates/ArchiveWidget.ss
@@ -1,3 +1,4 @@
+Dates
<% if DisplayMode == month %>
<% control Dates %>
diff --git a/templates/Includes/BlogSummary.ss b/templates/Includes/BlogSummary.ss
index 07a149c..e71fdef 100644
--- a/templates/Includes/BlogSummary.ss
+++ b/templates/Includes/BlogSummary.ss
@@ -1,14 +1,28 @@
-
-
-
<% _t('POSTEDBY', 'Posted by') %> $Author.XML <% _t('POSTEDON', 'on') %> $Date.Long | $Comments.Count <% _t('COMMENTS', 'Comments') %>
- <% if TagsCollection %>
-
- Tags:
- <% control TagsCollection %>
- $Tag <% if Last %><% else %>,<% end_if %>
- <% end_control %>
-
- <% end_if %>
- $ParagraphSummary
-
| Read the full post
-
+
\ No newline at end of file
diff --git a/templates/Layout/BlogHolder.ss b/templates/Layout/BlogHolder.ss
index d0d3eec..66beb53 100644
--- a/templates/Layout/BlogHolder.ss
+++ b/templates/Layout/BlogHolder.ss
@@ -1,21 +1,39 @@
-<% include BlogSideBar %>
-
-
-
- <% include BreadCrumbs %>
-
- <% if Tag %>
-
<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'
- <% end_if %>
-
- <% if BlogEntries %>
- <% control BlogEntries %>
- <% include BlogSummary %>
- <% end_control %>
- <% else %>
-
<% _t('NOENTRIES', 'There are no blog entries') %>
- <% end_if %>
-
- <% include BlogPagination %>
-
+
+
+
+
+
+ <% include PageTitle %>
+
+
+
+ <% if Tag %>
+
<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'
+ <% end_if %>
+
+ <% if BlogEntries %>
+ <% control BlogEntries %>
+ <% include BlogSummary %>
+ <% end_control %>
+ <% else %>
+
<% _t('NOENTRIES', 'There are no blog entries') %>
+ <% end_if %>
+ <% include BlogPagination %>
+ <% include BlogSideBar %>
+ <% include BreadCrumbs %>
+
+
+ <% control ContentElements %>
+
+ $ContentReplaceIcon
+
+ <% end_control %>
+
+
+
\ No newline at end of file
From aebe342ddd19c6726d65ff783936aefdcf65bb02 Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Thu, 13 May 2010 03:33:03 +0000
Subject: [PATCH 204/250] Reverted previous commit by fskroski
---
templates/ArchiveWidget.ss | 1 -
templates/Includes/BlogSummary.ss | 42 +++++++++----------------
templates/Layout/BlogHolder.ss | 52 ++++++++++---------------------
3 files changed, 31 insertions(+), 64 deletions(-)
diff --git a/templates/ArchiveWidget.ss b/templates/ArchiveWidget.ss
index b69382c..198fc53 100644
--- a/templates/ArchiveWidget.ss
+++ b/templates/ArchiveWidget.ss
@@ -1,4 +1,3 @@
-Dates
<% if DisplayMode == month %>
<% control Dates %>
diff --git a/templates/Includes/BlogSummary.ss b/templates/Includes/BlogSummary.ss
index e71fdef..07a149c 100644
--- a/templates/Includes/BlogSummary.ss
+++ b/templates/Includes/BlogSummary.ss
@@ -1,28 +1,14 @@
-
\ No newline at end of file
+
+
+
<% _t('POSTEDBY', 'Posted by') %> $Author.XML <% _t('POSTEDON', 'on') %> $Date.Long | $Comments.Count <% _t('COMMENTS', 'Comments') %>
+ <% if TagsCollection %>
+
+ Tags:
+ <% control TagsCollection %>
+ $Tag <% if Last %><% else %>,<% end_if %>
+ <% end_control %>
+
+ <% end_if %>
+ $ParagraphSummary
+
| Read the full post
+
diff --git a/templates/Layout/BlogHolder.ss b/templates/Layout/BlogHolder.ss
index 66beb53..d0d3eec 100644
--- a/templates/Layout/BlogHolder.ss
+++ b/templates/Layout/BlogHolder.ss
@@ -1,39 +1,21 @@
-
+<% include BlogSideBar %>
-
+
-
- <% include PageTitle %>
-
-
-
- <% if Tag %>
-
<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'
- <% end_if %>
-
- <% if BlogEntries %>
- <% control BlogEntries %>
- <% include BlogSummary %>
- <% end_control %>
- <% else %>
-
<% _t('NOENTRIES', 'There are no blog entries') %>
- <% end_if %>
- <% include BlogPagination %>
- <% include BlogSideBar %>
- <% include BreadCrumbs %>
-
-
- <% control ContentElements %>
-
- $ContentReplaceIcon
-
+ <% include BreadCrumbs %>
+
+ <% if Tag %>
+
<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'
+ <% end_if %>
+
+ <% if BlogEntries %>
+ <% control BlogEntries %>
+ <% include BlogSummary %>
<% end_control %>
+ <% else %>
+
<% _t('NOENTRIES', 'There are no blog entries') %>
+ <% end_if %>
-
-
\ No newline at end of file
+ <% include BlogPagination %>
+
+
From 3864a78ab59d39ed625ef16413905398517b1604 Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Sun, 16 May 2010 01:10:24 +0000
Subject: [PATCH 205/250] FEATURE: added NextBlogEntry() and
PreviousBlogEntry() functions to allow getting the next / previous posts by
date in the template using $NextBlogEntry and $PreviousBlogEntry respectively
---
code/BlogEntry.php | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 10499aa..def075d 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -188,9 +188,39 @@ class BlogEntry extends Page {
static function allow_wysiwyg_editing() {
self::$allow_wysiwyg_editing = true;
}
+
+
+ /**
+ * Get the previous blog entry from this section of blog pages.
+ *
+ * @return BlogEntry
+ */
+ function PreviousBlogEntry() {
+ return DataObject::get_one(
+ 'BlogEntry',
+ "\"SiteTree\".\"ParentID\" = '$this->ParentID' AND \"BlogEntry\".\"Date\" < '$this->Date'",
+ true,
+ 'Date DESC'
+ );
+ }
+
+ /**
+ * Get the next blog entry from this section of blog pages.
+ *
+ * @return BlogEntry
+ */
+ function NextBlogEntry() {
+ return DataObject::get_one(
+ 'BlogEntry',
+ "\"SiteTree\".\"ParentID\" = '$this->ParentID' AND \"BlogEntry\".\"Date\" > '$this->Date'",
+ true,
+ 'Date ASC'
+ );
+ }
}
class BlogEntry_Controller extends Page_Controller {
+
static $allowed_actions = array(
'index',
'trackbackping',
From b066dce821d913c5bb5e268d5a552fb105572593 Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Sun, 16 May 2010 02:38:19 +0000
Subject: [PATCH 206/250] APICHANGE: removed BlogTree_URL class and its little
static children. Changed to SelectedTag and SelectedDate to allow to be
called in the template. SelectedDate now also returns a Date object rather
than a string. BUGFIX: fixed missing Viewing posts by date text and added a
viewing by post date text.
---
code/BlogTree.php | 74 ++++++++++++++++++++--------------
templates/Layout/BlogHolder.ss | 6 ++-
2 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index b88bed8..4aad0f9 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -203,29 +203,8 @@ class BlogTree extends Page {
}
}
-class BlogTree_URL {
- static function tag() {
- if (Director::urlParam('Action') == 'tag') return Director::urlParam('ID');
- return '';
- }
-
- static function date() {
- if(Director::urlParam('Action') == 'date') {
- $year = Director::urlParam('ID');
- $month = Director::urlParam('OtherID');
-
- if($month && is_numeric($month) && $month >= 1 && $month <= 12 && is_numeric($year)) {
- return "$year-$month";
- } elseif (is_numeric($year)) {
- return $year;
- }
-
- return '';
- }
- }
-}
-
class BlogTree_Controller extends Page_Controller {
+
static $allowed_actions = array(
'index',
'rss',
@@ -250,11 +229,16 @@ class BlogTree_Controller extends Page_Controller {
}
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
- return $this->Entries("$start,$limit", BlogTree_URL::tag(), BlogTree_URL::date(), null, $filter);
+
+ $date = $this->SelectedDate();
+
+ return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date->Format('Y-m') : '', null, $filter);
}
+ /**
+ * This will create a tag point to the RSS feed
+ */
function IncludeBlogRSS() {
- // This will create a tag point to the RSS feed
RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
}
@@ -274,13 +258,43 @@ class BlogTree_Controller extends Page_Controller {
$rss->outputToBrowser();
}
}
-
+
+ /**
+ * Protection against infinite loops when an RSS widget pointing to this page is added to this page
+ */
function defaultAction($action) {
- // Protection against infinite loops when an RSS widget pointing to this page is added to this page
if(stristr($_SERVER['HTTP_USER_AGENT'], 'SimplePie')) return $this->rss();
return parent::defaultAction($action);
- }
-}
-
-?>
\ No newline at end of file
+ }
+
+ /**
+ * Return the currently viewing tag used in the template as $Tag
+ *
+ * @return String
+ */
+ function SelectedTag() {
+ return (Director::urlParam('Action') == 'tag') ? Director::urlParam('ID') : '';
+ }
+
+ /**
+ * Return the selected date from the blog tree
+ *
+ * @return Date
+ */
+ function SelectedDate() {
+ if(Director::urlParam('Action') == 'date') {
+ $year = Director::urlParam('ID');
+ $month = Director::urlParam('OtherID');
+
+ if(is_numeric($year) && is_numeric($month) && $month < 13) {
+ $date = new Date();
+ $date->setValue($year .'-'. $month);
+
+ return $date;
+ }
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/templates/Layout/BlogHolder.ss b/templates/Layout/BlogHolder.ss
index d0d3eec..e8e7779 100644
--- a/templates/Layout/BlogHolder.ss
+++ b/templates/Layout/BlogHolder.ss
@@ -4,8 +4,10 @@
<% include BreadCrumbs %>
- <% if Tag %>
- <% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$Tag'
+ <% if SelectedTag %>
+ <% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'
+ <% else_if SelectedDate %>
+ <% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedDate.Month $SelectedDate.Year
<% end_if %>
<% if BlogEntries %>
From 3e952feefc86930866b9edf4f2ca08dba19daa76 Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Tue, 18 May 2010 03:21:08 +0000
Subject: [PATCH 207/250] BUGFIX: restored filtering by Author to the entries
function
---
code/BlogTree.php | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 4aad0f9..0d0860a 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -199,7 +199,8 @@ class BlogTree extends Page {
// By specifying a callback, you can alter the SQL, or sort on something other than date.
if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $filter, $limit, $order);
- else return DataObject::get('BlogEntry', $filter, $order, '', $limit);
+
+ return DataObject::get('BlogEntry', $filter, $order, '', $limit);
}
}
@@ -228,6 +229,21 @@ class BlogTree_Controller extends Page_Controller {
$filter = '';
}
+ // allow filtering by author field and some blogs have an authorID field which
+ // may allow filtering by id
+ if(isset($_GET['author']) && isset($_GET['authorID'])) {
+ $author = Convert::raw2sql($_GET['author']);
+ $id = Convert::raw2sql($_GET['authorID']);
+
+ $filter .= " \"BlogEntry\".\"Author\" LIKE '". $author . "' OR \"BlogEntry\".\"AuthorID\" = '". $id ."'";
+ }
+ else if(isset($_GET['author'])) {
+ $filter .= " \"BlogEntry\".\"Author\" LIKE '". Convert::raw2sql($_GET['author']) . "'";
+ }
+ else if(isset($_GET['authorID'])) {
+ $filter .= " \"BlogEntry\".\"AuthorID\" = '". Convert::raw2sql($_GET['authorID']). "'";
+ }
+
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
$date = $this->SelectedDate();
From d9d12dd62122954797273b52abcbefe181963871 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Mon, 24 May 2010 04:22:56 +0000
Subject: [PATCH 208/250] ENHANCEMENT: display only members of Administrators
and Blog Management groups in the blog holder's blog owners dropdown field
FEATURE: allow blog owner customisation
---
code/BlogHolder.php | 22 +++++++++++++++++++++-
tests/BlogHolderTest.php | 15 +++++++++++++++
tests/BlogTest.yml | 39 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index ee825f7..775ea45 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -28,18 +28,38 @@ class BlogHolder extends BlogTree implements PermissionProvider {
);
function getCMSFields() {
+ $blogOwners = $this->blogOwners();
+
SiteTree::disableCMSFieldsExtensions();
$fields = parent::getCMSFields();
SiteTree::enableCMSFieldsExtensions();
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
- $fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', DataObject::get('Member')->toDropDownMap('ID', 'Name', 'None')));
+ $fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->toDropDownMap('ID', 'Name', 'None')));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
$this->extend('updateCMSFields', $fields);
return $fields;
}
+
+ /**
+ * Get members who have BLOGMANAGEMENT and ADMIN permission
+ */
+ function blogOwners($sort = 'Name', $direction = "ASC") {
+ $adminMembers = Permission::get_members_by_permission('ADMIN');
+ $blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
+
+ if(!$adminMembers) $adminMembers = new DataObjectSet();
+ if(!$blogOwners) $blogOwners = new DataObjectSet();
+
+ $blogOwners->merge($adminMembers);
+ $blogOwners->sort($sort, $direction);
+
+ $this->extend('extendBlogOwners', $blogOwners);
+
+ return $blogOwners;
+ }
public function BlogHolderIDs() {
return array( $this->ID );
diff --git a/tests/BlogHolderTest.php b/tests/BlogHolderTest.php
index 9d6b653..05938a6 100644
--- a/tests/BlogHolderTest.php
+++ b/tests/BlogHolderTest.php
@@ -53,6 +53,21 @@ class BlogHolderTest extends SapphireTest {
$this->assertContains($entry->URLSegment, $expectedEntries);
}
}
+
+ function testBlogOwners() {
+ $mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
+ $actualMembers = array_values($mainblog->blogOwners()->toDropDownMap('ID', 'Name'));
+ $expectedMembers = array(
+ 'ADMIN User', // test default admin
+ 'Admin One',
+ 'Admin Two',
+ 'Blog Owner One',
+ 'Blog Owner Three',
+ 'Blog Owner Two',
+ );
+
+ $this->assertEquals($expectedMembers, $actualMembers);
+ }
}
diff --git a/tests/BlogTest.yml b/tests/BlogTest.yml
index 1d49fe6..c21bf5a 100644
--- a/tests/BlogTest.yml
+++ b/tests/BlogTest.yml
@@ -23,6 +23,43 @@ BlogEntry:
Date: 2008-01-17 18:45:00
Parent: =>BlogHolder.mainblog
Tags: tag1,tag2,tag3
-
+Permission:
+ admin:
+ Code: ADMIN
+ blogOwners:
+ Code: BLOGMANAGEMENT
+
+Group:
+ admin:
+ Title: Admin
+ Permissions: =>Permission.admin
+ blogOwners:
+ Title: Blog Owners
+ Permissions: =>Permission.blogOwners
+
+Member:
+ admin1:
+ Name: Admin One
+ Groups: =>Group.admin
+ admin2:
+ Name: Admin Two
+ Groups: =>Group.admin
+ blogOwner1:
+ Name: Blog Owner One
+ Groups: =>Group.blogOwners
+ blogOwner2:
+ Name: Blog Owner Two
+ Groups: =>Group.blogOwners
+ blogOwner3:
+ Name: Blog Owner Three
+ Groups: =>Group.admin, =>Group.blogOwners
+ noBody:
+ Name: No Body
+
+
+
+
+
+
From cd1e29c76018b5179d7ceb3cdcd0cf05e13259ba Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Mon, 24 May 2010 05:49:34 +0000
Subject: [PATCH 209/250] MINOR: add breadcrumbs Inlcude to blog template
---
templates/Includes/BreadCrumbs.ss | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 templates/Includes/BreadCrumbs.ss
diff --git a/templates/Includes/BreadCrumbs.ss b/templates/Includes/BreadCrumbs.ss
new file mode 100644
index 0000000..f83475a
--- /dev/null
+++ b/templates/Includes/BreadCrumbs.ss
@@ -0,0 +1,5 @@
+<% if Level(2) %>
+
+<% end_if %>
\ No newline at end of file
From c681ba376282d0345c20d610f340db9dd15999de Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Tue, 25 May 2010 22:10:46 +0000
Subject: [PATCH 210/250] BUGFIX: fixed link rewriting on summary page
---
code/BlogEntry.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index def075d..5aace46 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -11,6 +11,10 @@ class BlogEntry extends Page {
"Tags" => "Text"
);
+ static $casting = array(
+ 'ParagraphSummary' => 'HTMLText'
+ );
+
static $default_parent = 'BlogHolder';
static $can_be_root = false;
From 606d526627491d5bcb036e4770d7bdebce3115de Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 27 May 2010 21:38:24 +0000
Subject: [PATCH 211/250] BUGFIX: Deleted old js from BlogHolder ENHANCEMENT:
do not show blog management widget when not logged in (ticket #5561 thanks
ericdrex)
---
code/BlogHolder.php | 13 +++----------
code/widgets/BlogManagementWidget.php | 15 +++++++++------
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 775ea45..4baa508 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -183,7 +183,6 @@ class BlogHolder_Controller extends BlogTree_Controller {
*/
function post(){
if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
-
$page = $this->customise(array(
'Content' => false,
'Form' => $this->BlogEntryForm()
@@ -195,14 +194,9 @@ class BlogHolder_Controller extends BlogTree_Controller {
/**
* A simple form for creating blog entries
*/
- function BlogEntryForm() {
+ function BlogEntryForm() {
if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
-
- Requirements::javascript('jsparty/behaviour.js');
- Requirements::javascript('jsparty/prototype.js');
- Requirements::javascript('jsparty/scriptaculous/effects.js');
- Requirements::javascript('cms/javascript/PageCommentInterface.js');
- Requirements::javascript('blog/javascript/bbcodehelp.js');
+
$id = 0;
if(Director::urlParam('ID')) {
@@ -221,7 +215,6 @@ class BlogHolder_Controller extends BlogTree_Controller {
new LiteralField("BBCodeTags","".$codeparser->useable_tagsHTML()."
")
);
}
-
if(class_exists('TagField')) {
$tagfield = new TagField('Tags', null, null, 'BlogEntry');
$tagfield->setSeparator(', ');
@@ -242,7 +235,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
_t('BlogHolder.SPUC', "Please separate tags using commas.")." ")
);
-
+
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
$actions = new FieldSet($submitAction);
$validator = new RequiredFields('Title','Content');
diff --git a/code/widgets/BlogManagementWidget.php b/code/widgets/BlogManagementWidget.php
index 2547eb9..eb9f4ec 100644
--- a/code/widgets/BlogManagementWidget.php
+++ b/code/widgets/BlogManagementWidget.php
@@ -48,16 +48,19 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
return array("BLOGMANAGEMENT" => "Blog management");
}
- function WidgetHolder() {
- if(Permission::check("BLOGMANAGEMENT")) {
- return $this->renderWith("WidgetHolder");
- }
- }
+}
+class BlogManagementWidget_Controller extends Widget_Controller {
+
+ function WidgetHolder() {
+ if(Permission::check("BLOGMANAGEMENT")) {
+ return $this->renderWith("WidgetHolder");
+ }
+ }
+
function PostLink() {
$container = BlogTree::current();
if ($container) return $container->Link('post');
}
-
}
?>
From 5a5cdf1aaf13d9112850f62b954872860a7bbabb Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 27 May 2010 23:30:14 +0000
Subject: [PATCH 212/250] ENHANCEMENT: replaced deprecated
Director::urlParams() BUGFIX: tag working with nested urls
---
code/BlogHolder.php | 4 ++--
code/BlogTree.php | 11 ++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 4baa508..d297ee7 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -199,8 +199,8 @@ class BlogHolder_Controller extends BlogTree_Controller {
$id = 0;
- if(Director::urlParam('ID')) {
- $id = (int) Director::urlParam('ID');
+ if($this->request->latestParam('ID')) {
+ $id = (int) $this->request->latestParam('ID');
}
$codeparser = new BBCodeParser();
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 0d0860a..70e0aaa 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -152,6 +152,7 @@ class BlogTree extends Page {
* @return DataObjectSet
*/
public function Entries($limit = '', $tag = '', $date = '', $retrieveCallback = null, $filter = '') {
+
$tagCheck = '';
$dateCheck = '';
@@ -199,7 +200,7 @@ class BlogTree extends Page {
// By specifying a callback, you can alter the SQL, or sort on something other than date.
if($retrieveCallback) return call_user_func($retrieveCallback, 'BlogEntry', $filter, $limit, $order);
-
+
return DataObject::get('BlogEntry', $filter, $order, '', $limit);
}
}
@@ -290,7 +291,7 @@ class BlogTree_Controller extends Page_Controller {
* @return String
*/
function SelectedTag() {
- return (Director::urlParam('Action') == 'tag') ? Director::urlParam('ID') : '';
+ return ($this->request->latestParam('Action') == 'tag') ? $this->request->latestParam('ID') : '';
}
/**
@@ -299,9 +300,9 @@ class BlogTree_Controller extends Page_Controller {
* @return Date
*/
function SelectedDate() {
- if(Director::urlParam('Action') == 'date') {
- $year = Director::urlParam('ID');
- $month = Director::urlParam('OtherID');
+ if($this->request->latestParam('Action') == 'date') {
+ $year = $this->request->latestParam('ID');
+ $month = $this->request->latestParam('OtherID');
if(is_numeric($year) && is_numeric($month) && $month < 13) {
$date = new Date();
From 1d4d7c88a83d36f899225890a2cf6f85c437e254 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 27 May 2010 23:38:36 +0000
Subject: [PATCH 213/250] ENHANCEMENT: created BlogTree default template
---
templates/Layout/BlogTree.ss | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 templates/Layout/BlogTree.ss
diff --git a/templates/Layout/BlogTree.ss b/templates/Layout/BlogTree.ss
new file mode 100644
index 0000000..59ee03a
--- /dev/null
+++ b/templates/Layout/BlogTree.ss
@@ -0,0 +1,23 @@
+<% include BlogSideBar %>
+
+
+
+ <% include BreadCrumbs %>
+
+ <% if SelectedTag %>
+
<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'
+ <% else_if SelectedDate %>
+ <% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedDate.Month $SelectedDate.Year
+ <% end_if %>
+
+ <% if BlogEntries %>
+ <% control BlogEntries %>
+ <% include BlogSummary %>
+ <% end_control %>
+ <% else %>
+ <% _t('NOENTRIES', 'There are no blog entries') %>
+ <% end_if %>
+
+ <% include BlogPagination %>
+
+
\ No newline at end of file
From b48504f795181558ab9d325402e7422187b56287 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 27 May 2010 23:47:13 +0000
Subject: [PATCH 214/250] ENHANMENT: continue replacing deprecated
Director::urlParams()
---
code/BlogHolder.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index d297ee7..c458b0a 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -73,7 +73,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
* Only display the blog entries that have the specified tag
*/
function ShowTag() {
- if(Director::urlParam('Action') == 'tag') {
+ if($this->request->latestParam('Action') == 'tag') {
return Convert::raw2xml(Director::urlParam('ID'));
}
}
@@ -82,7 +82,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
* Check if url has "/post"
*/
function isPost() {
- return Director::urlParam('Action') == 'post';
+ return $this->request->latestParam('Action') == 'post';
}
/**
From b389d86f00dc2cdce782f82e5b7a800f8616a468 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Fri, 28 May 2010 01:38:19 +0000
Subject: [PATCH 215/250] ENHANCEMENT: Moved postblog (post in the front end)
to BlogTree, so it works in BlogTree
---
code/BlogHolder.php | 109 +---------------------------------------
code/BlogTree.php | 119 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 120 insertions(+), 108 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index c458b0a..3997cfb 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -174,114 +174,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
return BBCodeParser::usable_tags();
}
- function providePermissions() {
- return array("BLOGMANAGEMENT" => "Blog management");
- }
-
- /**
- * Post a new blog entry
- */
- function post(){
- if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
- $page = $this->customise(array(
- 'Content' => false,
- 'Form' => $this->BlogEntryForm()
- ));
-
- return $page->renderWith('Page');
- }
-
- /**
- * A simple form for creating blog entries
- */
- function BlogEntryForm() {
- if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
-
-
- $id = 0;
- if($this->request->latestParam('ID')) {
- $id = (int) $this->request->latestParam('ID');
- }
-
- $codeparser = new BBCodeParser();
- $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
-
- if(BlogEntry::$allow_wysiwyg_editing) {
- $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
- } else {
- $contentfield = new CompositeField(
- new LiteralField("BBCodeHelper",""._t("BlogEntry.BBH")."
" ),
- new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already
- new LiteralField("BBCodeTags","".$codeparser->useable_tagsHTML()."
")
- );
- }
- if(class_exists('TagField')) {
- $tagfield = new TagField('Tags', null, null, 'BlogEntry');
- $tagfield->setSeparator(', ');
- } else {
- $tagfield = new TextField('Tags');
- }
-
- $field = 'TextField';
- if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
- $field = 'ReadonlyField';
- }
- $fields = new FieldSet(
- new HiddenField("ID", "ID"),
- new TextField("Title", _t('BlogHolder.SJ', "Subject")),
- new $field("Author", _t('BlogEntry.AU'), $membername),
- $contentfield,
- $tagfield,
- new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
- _t('BlogHolder.SPUC', "Please separate tags using commas.")." ")
- );
-
- $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
- $actions = new FieldSet($submitAction);
- $validator = new RequiredFields('Title','Content');
-
- $form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
-
- if($id != 0) {
- $entry = DataObject::get_by_id('BlogEntry', $id);
- if($entry->IsOwner()) {
- $form->loadDataFrom($entry);
- $form->datafieldByName('BlogPost')->setValue($entry->Content);
- }
- } else {
- $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
- }
-
- return $form;
- }
-
- function postblog($data, $form) {
- if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
-
- Cookie::set("BlogHolder_Name", $data['Author']);
- $blogentry = false;
-
- if(isset($data['ID']) && $data['ID']) {
- $blogentry = DataObject::get_by_id("BlogEntry", $data['ID']);
- if(!$blogentry->IsOwner()) {
- unset($blogentry);
- }
- }
-
- if(!$blogentry) {
- $blogentry = new BlogEntry();
- }
-
- $form->saveInto($blogentry);
- $blogentry->ParentID = $this->ID;
- $blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
-
- $blogentry->Status = "Published";
- $blogentry->writeToStage("Stage");
- $blogentry->publish("Stage", "Live");
-
- Director::redirect($this->Link());
- }
+
}
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 70e0aaa..18ca075 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -210,6 +210,8 @@ class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
'index',
'rss',
+ 'post',
+ 'BlogEntryForm'
);
function init() {
@@ -314,4 +316,121 @@ class BlogTree_Controller extends Page_Controller {
return false;
}
+
+ function providePermissions() {
+ return array("BLOGMANAGEMENT" => "Blog management");
+ }
+
+ /**
+ * Post a new blog entry
+ */
+ function post(){
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+ $page = $this->customise(array(
+ 'Content' => false,
+ 'Form' => $this->BlogEntryForm()
+ ));
+
+ return $page->renderWith('Page');
+ }
+
+ /**
+ * A simple form for creating blog entries
+ */
+ function BlogEntryForm() {
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+
+
+ $id = 0;
+ if($this->request->latestParam('ID')) {
+ $id = (int) $this->request->latestParam('ID');
+ }
+
+ $codeparser = new BBCodeParser();
+ $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
+
+ if(BlogEntry::$allow_wysiwyg_editing) {
+ $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
+ } else {
+ $contentfield = new CompositeField(
+ new LiteralField("BBCodeHelper",""._t("BlogEntry.BBH")."
" ),
+ new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already
+ new LiteralField("BBCodeTags","".$codeparser->useable_tagsHTML()."
")
+ );
+ }
+ if(class_exists('TagField')) {
+ $tagfield = new TagField('Tags', null, null, 'BlogEntry');
+ $tagfield->setSeparator(', ');
+ } else {
+ $tagfield = new TextField('Tags');
+ }
+
+ $field = 'TextField';
+ if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
+ $field = 'ReadonlyField';
+ }
+ $fields = new FieldSet(
+ new HiddenField("ID", "ID"),
+ new TextField("Title", _t('BlogHolder.SJ', "Subject")),
+ new $field("Author", _t('BlogEntry.AU'), $membername),
+ $contentfield,
+ $tagfield,
+ new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
+ _t('BlogHolder.SPUC', "Please separate tags using commas.")." ")
+ );
+
+ $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
+ $actions = new FieldSet($submitAction);
+ $validator = new RequiredFields('Title','Content');
+
+ $form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
+
+ if($id != 0) {
+ $entry = DataObject::get_by_id('BlogEntry', $id);
+ if($entry->IsOwner()) {
+ $form->loadDataFrom($entry);
+ $form->datafieldByName('BlogPost')->setValue($entry->Content);
+ }
+ } else {
+ $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
+ }
+
+ return $form;
+ }
+
+ function postblog($data, $form) {
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+
+ Cookie::set("BlogHolder_Name", $data['Author']);
+ $blogentry = false;
+
+ if(isset($data['ID']) && $data['ID']) {
+ $blogentry = DataObject::get_by_id("BlogEntry", $data['ID']);
+ if(!$blogentry->IsOwner()) {
+ unset($blogentry);
+ }
+ }
+
+ if(!$blogentry) {
+ $blogentry = new BlogEntry();
+ }
+
+ $form->saveInto($blogentry);
+
+
+
+ if($this->ClassName == "BlogHolder") $parentID = $this->ID;
+ else{
+ $parentID = $this->BlogHolderIDs();
+ $parentID = $parentID[0];
+ }
+ $blogentry->ParentID = $this->ID;
+ $blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
+
+ $blogentry->Status = "Published";
+ $blogentry->writeToStage("Stage");
+ $blogentry->publish("Stage", "Live");
+
+ Director::redirect($this->Link());
+ }
}
\ No newline at end of file
From 1e96d253b439205955ba48f979289d39dd5f2ec4 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Fri, 28 May 2010 02:33:58 +0000
Subject: [PATCH 216/250] Reverted form to post entry to BlogHolder
ENHANCEMENT: added post as an allowed method on BlogTree
---
code/BlogHolder.php | 109 ++++++++++++++++++++++++++++++++++++++-
code/BlogTree.php | 122 +-------------------------------------------
2 files changed, 110 insertions(+), 121 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 3997cfb..c458b0a 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -174,7 +174,114 @@ class BlogHolder_Controller extends BlogTree_Controller {
return BBCodeParser::usable_tags();
}
-
+ function providePermissions() {
+ return array("BLOGMANAGEMENT" => "Blog management");
+ }
+
+ /**
+ * Post a new blog entry
+ */
+ function post(){
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+ $page = $this->customise(array(
+ 'Content' => false,
+ 'Form' => $this->BlogEntryForm()
+ ));
+
+ return $page->renderWith('Page');
+ }
+
+ /**
+ * A simple form for creating blog entries
+ */
+ function BlogEntryForm() {
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+
+
+ $id = 0;
+ if($this->request->latestParam('ID')) {
+ $id = (int) $this->request->latestParam('ID');
+ }
+
+ $codeparser = new BBCodeParser();
+ $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
+
+ if(BlogEntry::$allow_wysiwyg_editing) {
+ $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
+ } else {
+ $contentfield = new CompositeField(
+ new LiteralField("BBCodeHelper",""._t("BlogEntry.BBH")."
" ),
+ new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already
+ new LiteralField("BBCodeTags","".$codeparser->useable_tagsHTML()."
")
+ );
+ }
+ if(class_exists('TagField')) {
+ $tagfield = new TagField('Tags', null, null, 'BlogEntry');
+ $tagfield->setSeparator(', ');
+ } else {
+ $tagfield = new TextField('Tags');
+ }
+
+ $field = 'TextField';
+ if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
+ $field = 'ReadonlyField';
+ }
+ $fields = new FieldSet(
+ new HiddenField("ID", "ID"),
+ new TextField("Title", _t('BlogHolder.SJ', "Subject")),
+ new $field("Author", _t('BlogEntry.AU'), $membername),
+ $contentfield,
+ $tagfield,
+ new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
+ _t('BlogHolder.SPUC', "Please separate tags using commas.")." ")
+ );
+
+ $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
+ $actions = new FieldSet($submitAction);
+ $validator = new RequiredFields('Title','Content');
+
+ $form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
+
+ if($id != 0) {
+ $entry = DataObject::get_by_id('BlogEntry', $id);
+ if($entry->IsOwner()) {
+ $form->loadDataFrom($entry);
+ $form->datafieldByName('BlogPost')->setValue($entry->Content);
+ }
+ } else {
+ $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
+ }
+
+ return $form;
+ }
+
+ function postblog($data, $form) {
+ if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
+
+ Cookie::set("BlogHolder_Name", $data['Author']);
+ $blogentry = false;
+
+ if(isset($data['ID']) && $data['ID']) {
+ $blogentry = DataObject::get_by_id("BlogEntry", $data['ID']);
+ if(!$blogentry->IsOwner()) {
+ unset($blogentry);
+ }
+ }
+
+ if(!$blogentry) {
+ $blogentry = new BlogEntry();
+ }
+
+ $form->saveInto($blogentry);
+ $blogentry->ParentID = $this->ID;
+ $blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
+
+ $blogentry->Status = "Published";
+ $blogentry->writeToStage("Stage");
+ $blogentry->publish("Stage", "Live");
+
+ Director::redirect($this->Link());
+ }
}
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 18ca075..caa5e36 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -210,8 +210,7 @@ class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
'index',
'rss',
- 'post',
- 'BlogEntryForm'
+ 'tag'
);
function init() {
@@ -250,7 +249,7 @@ class BlogTree_Controller extends Page_Controller {
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
$date = $this->SelectedDate();
-
+
return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date->Format('Y-m') : '', null, $filter);
}
@@ -316,121 +315,4 @@ class BlogTree_Controller extends Page_Controller {
return false;
}
-
- function providePermissions() {
- return array("BLOGMANAGEMENT" => "Blog management");
- }
-
- /**
- * Post a new blog entry
- */
- function post(){
- if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
- $page = $this->customise(array(
- 'Content' => false,
- 'Form' => $this->BlogEntryForm()
- ));
-
- return $page->renderWith('Page');
- }
-
- /**
- * A simple form for creating blog entries
- */
- function BlogEntryForm() {
- if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
-
-
- $id = 0;
- if($this->request->latestParam('ID')) {
- $id = (int) $this->request->latestParam('ID');
- }
-
- $codeparser = new BBCodeParser();
- $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
-
- if(BlogEntry::$allow_wysiwyg_editing) {
- $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
- } else {
- $contentfield = new CompositeField(
- new LiteralField("BBCodeHelper",""._t("BlogEntry.BBH")."
" ),
- new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already
- new LiteralField("BBCodeTags","".$codeparser->useable_tagsHTML()."
")
- );
- }
- if(class_exists('TagField')) {
- $tagfield = new TagField('Tags', null, null, 'BlogEntry');
- $tagfield->setSeparator(', ');
- } else {
- $tagfield = new TextField('Tags');
- }
-
- $field = 'TextField';
- if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
- $field = 'ReadonlyField';
- }
- $fields = new FieldSet(
- new HiddenField("ID", "ID"),
- new TextField("Title", _t('BlogHolder.SJ', "Subject")),
- new $field("Author", _t('BlogEntry.AU'), $membername),
- $contentfield,
- $tagfield,
- new LiteralField("Tagsnote"," "._t('BlogHolder.TE', "For example: sport, personal, science fiction")." " .
- _t('BlogHolder.SPUC', "Please separate tags using commas.")." ")
- );
-
- $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
- $actions = new FieldSet($submitAction);
- $validator = new RequiredFields('Title','Content');
-
- $form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
-
- if($id != 0) {
- $entry = DataObject::get_by_id('BlogEntry', $id);
- if($entry->IsOwner()) {
- $form->loadDataFrom($entry);
- $form->datafieldByName('BlogPost')->setValue($entry->Content);
- }
- } else {
- $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
- }
-
- return $form;
- }
-
- function postblog($data, $form) {
- if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure();
-
- Cookie::set("BlogHolder_Name", $data['Author']);
- $blogentry = false;
-
- if(isset($data['ID']) && $data['ID']) {
- $blogentry = DataObject::get_by_id("BlogEntry", $data['ID']);
- if(!$blogentry->IsOwner()) {
- unset($blogentry);
- }
- }
-
- if(!$blogentry) {
- $blogentry = new BlogEntry();
- }
-
- $form->saveInto($blogentry);
-
-
-
- if($this->ClassName == "BlogHolder") $parentID = $this->ID;
- else{
- $parentID = $this->BlogHolderIDs();
- $parentID = $parentID[0];
- }
- $blogentry->ParentID = $this->ID;
- $blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
-
- $blogentry->Status = "Published";
- $blogentry->writeToStage("Stage");
- $blogentry->publish("Stage", "Live");
-
- Director::redirect($this->Link());
- }
}
\ No newline at end of file
From 8de8414c869099a24e5d7c89fcb29a66886fac71 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Fri, 28 May 2010 03:46:17 +0000
Subject: [PATCH 217/250] BUGFIX: postgres and sql server compatibility
---
code/BlogTree.php | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index caa5e36..135c43f 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -222,15 +222,20 @@ class BlogTree_Controller extends Page_Controller {
}
function BlogEntries($limit = null) {
+ require_once('Zend/Date.php');
+
if($limit === null) $limit = BlogTree::$default_entries_limit;
// only use freshness if no action is present (might be displaying tags or rss)
if ($this->LandingPageFreshness && !$this->request->param('Action')) {
- $filter = "\"BlogEntry\".\"Date\" > NOW() - INTERVAL " . $this->LandingPageFreshness;
+ $d = new Zend_Date(SS_Datetime::now()->getValue());
+ $d->sub($this->LandingPageFreshness);
+ $date = $d->toString('YYYY-MM-dd');
+
+ $filter = "\"BlogEntry\".\"Date\" > '$date'";
} else {
$filter = '';
}
-
// allow filtering by author field and some blogs have an authorID field which
// may allow filtering by id
if(isset($_GET['author']) && isset($_GET['authorID'])) {
From a71f4e6908ea31cc145f1187f00b5fe7cb62439f Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Fri, 28 May 2010 03:52:45 +0000
Subject: [PATCH 218/250] MINOR: update README
---
README | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/README b/README
index 4e582d7..b81ef97 100644
--- a/README
+++ b/README
@@ -3,11 +3,13 @@ Blog Module
####################################################
# Maintainer Contact
-Andrew O'Neil (Nickname: aoneil)
-
+Saophalkun Ponlu (Nickname: aoneil)
+
+Carlos Barberis
+
# Requirements
-SilverStripe minimum version 2.3.0
+SilverStripe minimum version 2.4.0
# Documentation
http://doc.silverstripe.com/doku.php?id=modules:blog
From fe2e69973003200da17869bc96953f6e225fbeba Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Wed, 16 Jun 2010 22:52:06 +0000
Subject: [PATCH 219/250] MINOR: merge r106597 from branch 0.4
---
code/BlogHolder.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index c458b0a..7de5558 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -273,8 +273,13 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
$form->saveInto($blogentry);
+
$blogentry->ParentID = $this->ID;
$blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
+
+ if(Object::hasExtension('Translatable')) {
+ $blogentry->Locale = $this->Locale;
+ }
$blogentry->Status = "Published";
$blogentry->writeToStage("Stage");
From 755787de5de5b6b3c9973cb6e3027cf6c1e793f2 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Thu, 17 Jun 2010 01:46:17 +0000
Subject: [PATCH 220/250] MINOR: subsequent fix to commit r106598
---
code/BlogHolder.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 7de5558..4c4b8f3 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -276,8 +276,8 @@ class BlogHolder_Controller extends BlogTree_Controller {
$blogentry->ParentID = $this->ID;
$blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
-
- if(Object::hasExtension('Translatable')) {
+
+ if(Object::has_extension($this->ClassName, 'Translatable')) {
$blogentry->Locale = $this->Locale;
}
From 1f706f6e734292ac708b4814a9b30714886d44c4 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Thu, 17 Jun 2010 06:05:37 +0000
Subject: [PATCH 221/250] BUGFIX: resolve wrong character parsing when posting
blog entry from the front-end
---
code/BlogHolder.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index 4c4b8f3..e4aff3a 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -273,9 +273,8 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
$form->saveInto($blogentry);
-
$blogentry->ParentID = $this->ID;
- $blogentry->Content = $form->datafieldByName('BlogPost')->dataValue();
+ $blogentry->Content = str_replace("\r\n", "\n", $form->datafieldByName('BlogPost')->dataValue());
if(Object::has_extension($this->ClassName, 'Translatable')) {
$blogentry->Locale = $this->Locale;
From 8b4b0f9ac6a65eeb3bd3dd8ef83aae8613ca2738 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Thu, 17 Jun 2010 23:19:56 +0000
Subject: [PATCH 222/250] ENHANCEMENT: create a template function,
BlogEntry::Content(), for consistency of template writing and enable using
text summary functionalities in template
---
code/BlogEntry.php | 64 ++++++++++++++++---------------
code/BlogTree.php | 2 +-
templates/Includes/BlogSummary.ss | 4 +-
templates/Layout/BlogEntry.ss | 9 ++---
tests/BlogEntryTest.php | 26 +++++++++++++
5 files changed, 66 insertions(+), 39 deletions(-)
create mode 100644 tests/BlogEntryTest.php
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 5aace46..97cffcc 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -11,10 +11,6 @@ class BlogEntry extends Page {
"Tags" => "Text"
);
- static $casting = array(
- 'ParagraphSummary' => 'HTMLText'
- );
-
static $default_parent = 'BlogHolder';
static $can_be_root = false;
@@ -46,16 +42,6 @@ class BlogEntry extends Page {
*/
static $allow_wysiwyg_editing = true;
- /**
- * Is WYSIWYG editing enabled?
- * Used in templates.
- *
- * @return boolean
- */
- public function IsWYSIWYGEnabled() {
- return self::$allow_wysiwyg_editing;
- }
-
/**
* Overload so that the default date is today.
*/
@@ -128,33 +114,49 @@ class BlogEntry extends Page {
return $this->getParent()->SideBar();
}
- /**
- * Get a bbcode parsed summary of the blog entry
- */
- function ParagraphSummary(){
+ function Content() {
if(self::$allow_wysiwyg_editing) {
- return $this->obj('Content')->FirstParagraph('html');
+ return $this->getField('Content');
} else {
$parser = new BBCodeParser($this->Content);
- $html = new HTMLText('Content');
- $html->setValue($parser->parse());
- return $html->FirstParagraph('html');
+ $content = new HTMLText('Content');
+ $content->value = $parser->parse();
+ return $content;
}
}
+ /**
+ * To be used by RSSFeed. If RSSFeed uses Content field, it doesn't pull in correctly parsed content.
+ */
+ function RSSContent() {
+ return $this->Content();
+ }
+
+ /**
+ * Get a bbcode parsed summary of the blog entry
+ * @deprecated
+ */
+ function ParagraphSummary(){
+ user_error("BlogEntry::ParagraphSummary() is deprecated; use BlogEntry::Content()", E_USER_NOTICE);
+
+ $val = $this->Content();
+ $content = $val;
+
+ if(!($content instanceof HTMLText)) {
+ $content = new HTMLText('Content');
+ $content->value = $val;
+ }
+
+ return $content->FirstParagraph('html');
+ }
+
/**
* Get the bbcode parsed content
+ * @deprecated
*/
function ParsedContent() {
- if(self::$allow_wysiwyg_editing) {
- return $this->obj('Content');
- } else {
- $parser = new BBCodeParser($this->Content);
- $content = new Text('Content');
- $content->value = $parser->parse();
-
- return $content;
- }
+ user_error("BlogEntry::ParsedContent() is deprecated; use BlogEntry::Content()", E_USER_NOTICE);
+ return $this->Content();
}
/**
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 135c43f..889b465 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -277,7 +277,7 @@ class BlogTree_Controller extends Page_Controller {
$entries = $this->Entries(20);
if($entries) {
- $rss = new RSSFeed($entries, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "ParsedContent");
+ $rss = new RSSFeed($entries, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "RSSContent");
$rss->outputToBrowser();
}
}
diff --git a/templates/Includes/BlogSummary.ss b/templates/Includes/BlogSummary.ss
index 07a149c..0be8d1b 100644
--- a/templates/Includes/BlogSummary.ss
+++ b/templates/Includes/BlogSummary.ss
@@ -9,6 +9,8 @@
<% end_control %>
<% end_if %>
- $ParagraphSummary
+
+ $Content.FirstParagraph(html)
+
| Read the full post
diff --git a/templates/Layout/BlogEntry.ss b/templates/Layout/BlogEntry.ss
index 524c538..5b116c5 100644
--- a/templates/Layout/BlogEntry.ss
+++ b/templates/Layout/BlogEntry.ss
@@ -13,12 +13,9 @@
<% end_control %>
<% end_if %>
- <% if IsWYSIWYGEnabled %>
- $Content
- <% else %>
- $ParsedContent
- <% end_if %>
-
+
+ $Content
+
<% if IsOwner %>
<% _t('EDITTHIS', 'Edit this post') %> | <% _t('UNPUBLISHTHIS', 'Unpublish this post') %>
<% end_if %>
diff --git a/tests/BlogEntryTest.php b/tests/BlogEntryTest.php
new file mode 100644
index 0000000..845d4e9
--- /dev/null
+++ b/tests/BlogEntryTest.php
@@ -0,0 +1,26 @@
+objFromFixture('BlogEntry', 'testpost');
+ $entry->Content = "[url=admin]the CMS[/url]";
+
+ $this->assertEquals('
the CMS
', $entry->Content()->value);
+ BlogEntry::$allow_wysiwyg_editing = $tmpFlag;
+ }
+
+ function testContent() {
+ $tmpFlag = BlogEntry::$allow_wysiwyg_editing;
+ BlogEntry::$allow_wysiwyg_editing = true;
+
+ $entry = $this->objFromFixture('BlogEntry', 'testpost');
+ $entry->Content = '
the CMS ';
+
+ $this->assertEquals('
the CMS ', $entry->Content());
+ BlogEntry::$allow_wysiwyg_editing = $tmpFlag;
+ }
+}
\ No newline at end of file
From dc879cb49fea4f8e029c31a101e2ef2d2a8319c5 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Sun, 20 Jun 2010 00:56:08 +0000
Subject: [PATCH 223/250] MINOR: add unit test for receiving trackback
---
tests/BlogEntryTest.php | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tests/BlogEntryTest.php b/tests/BlogEntryTest.php
index 845d4e9..22f0a7b 100644
--- a/tests/BlogEntryTest.php
+++ b/tests/BlogEntryTest.php
@@ -1,4 +1,8 @@
assertEquals('the CMS ', $entry->Content());
BlogEntry::$allow_wysiwyg_editing = $tmpFlag;
}
+
+ function testTrackback() {
+ $blog = $this->objFromFixture('BlogHolder', 'mainblog');
+ $blog->TrackBacksEnabled = true;
+ $blog->write();
+
+ $entry = $this->objFromFixture('BlogEntry', 'testpost');
+ $response = $entry->trackbackping();
+
+ $this->assertContains("1 ", $response);
+
+ $_POST['url'] = 'test trackback post url';
+ $_POST['title'] = 'test trackback post title';
+ $_POST['excerpt'] = 'test trackback post excerpt';
+ $_POST['blog_name'] = 'test trackback blog name';
+
+ $response = $entry->trackbackping();
+ $this->assertContains("0 ", $response);
+
+ $trackback = DataObject::get_one('TrackBackPing');
+ $this->assertEquals('test trackback post url', $trackback->Url);
+ $this->assertEquals('test trackback post title', $trackback->Title);
+ $this->assertEquals('test trackback post excerpt', $trackback->Excerpt);
+ $this->assertEquals('test trackback blog name', $trackback->BlogName);
+
+ unset($_POST);
+ }
}
\ No newline at end of file
From 68df5406157b655528469365382a24c313301fd9 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Tue, 22 Jun 2010 01:13:10 +0000
Subject: [PATCH 224/250] FEATURE: Add send trackback notification
---
code/BlogEntry.php | 1 -
code/TrackBackDecorator.php | 101 +++++++++++++++++++++++++++++++++-
tests/BlogEntryTest.php | 26 ---------
tests/BlogTrackbackTest.php | 107 ++++++++++++++++++++++++++++++++++++
4 files changed, 207 insertions(+), 28 deletions(-)
create mode 100644 tests/BlogTrackbackTest.php
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 97cffcc..4f137ee 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -265,4 +265,3 @@ class BlogEntry_Controller extends Page_Controller {
}
}
-?>
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index 67dd5d8..8bc2dec 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -1,13 +1,84 @@
array(
+ 'TrackbackURL' => 'Varchar(2048)',
+ 'PungTrackbackURL' => 'Varchar(2048)'
+ ),
'has_many' => array(
'TrackBacks' => 'TrackBackPing'
)
);
}
+
+ function updateCMSFields($fields) {
+ // Trackback URL field
+ if($this->owner->TrackBacksEnabled()) {
+ $fields->addFieldToTab("Root.Content.Main", new TextField("TrackbackURL", _t("BlogEntry.TRACKBACKURL", "Trackback URL")), "Content");
+ }
+ else {
+ $fields->addFieldToTab("Root.Content.Main", new ReadonlyField("TrackbackURLReadOnly", _t("BlogEntry.TRACKBACKURL", "Trackback URL"), _t("BlogEntry.TRACKBACKURL_DISABLED", "To use this feature, please check 'Enable TrackBacks' check box on the blog holder.")), "Content");
+ }
+ }
+
+ function onBeforePublish() {
+ $owner = $this->owner;
+
+ if(!empty($owner->TrackbackURL) && $owner->TrackBacksEnabled() && $owner->ShouldTrackbackNotify()) {
+
+ if($this->trackbackNotify()) {
+ $owner->PungTrackbackURL = $owner->TrackbackURL;
+ $owner->write();
+ }
+ }
+ }
+
+ /**
+ * Trackback notify the specified trackback url
+ * @param boolean | true on success, otherwise false
+ */
+ function trackbackNotify() {
+ $owner = $this->owner;
+
+ $content = new HTMLText('Content');
+ $content->setValue($owner->Content);
+ $excerpt = $content->FirstParagraph();
+
+ if($owner->Parent() && $owner->ParentID > 0) {
+ $blogName = $owner->Parent()->Title;
+ }
+ else {
+ $blogName = "";
+ }
+
+ $postData = array(
+ 'url' => $owner->AbsoluteLink(),
+ 'title' => $owner->Title,
+ 'excerpt' => $excerpt,
+ 'blog_name' => $blogName
+ );
+
+ $controller = Object::create(self::$trackback_server_class);
+ $response = $controller->request($owner->TrackbackURL, $postData);
+
+ if($response->getStatusCode() == '200' && stripos($response->getBody(), "0 ") !== false) {
+ return true;
+ }
+
+ return false;
+
+ }
+
+ function ShouldTrackbackNotify() {
+ return (trim($this->owner->TrackbackURL) != '' && $this->owner->TrackbackURL != $this->owner->PungTrackbackURL);
+ }
function updateMetaTags(&$tags) {
$tags .= $this->owner->renderWith('TrackBackRdf');
@@ -49,4 +120,32 @@ class TrackBackDecorator extends DataObjectDecorator {
}
}
+/**
+ * Example:
+ * $controller = Object::create('TrackbackHTTPClient');
+ * $response = $controller->request(new SS_HTTPRequest('POST', $url, null, $postData));
+ */
+class TrackbackHTTPServer {
+
+ function __construct() {}
+
+ /**
+ * @param string
+ * @param array
+ * @return SS_HTTPResponse
+ */
+ function request($url, $data) {
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+ $response = curl_exec($ch);
+ $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+
+ curl_close($ch);
+
+ return new SS_HTTPResponse($response, $statusCode);
+ }
+}
+
?>
diff --git a/tests/BlogEntryTest.php b/tests/BlogEntryTest.php
index 22f0a7b..b1a3411 100644
--- a/tests/BlogEntryTest.php
+++ b/tests/BlogEntryTest.php
@@ -28,30 +28,4 @@ class BlogEntryTest extends SapphireTest {
BlogEntry::$allow_wysiwyg_editing = $tmpFlag;
}
- function testTrackback() {
- $blog = $this->objFromFixture('BlogHolder', 'mainblog');
- $blog->TrackBacksEnabled = true;
- $blog->write();
-
- $entry = $this->objFromFixture('BlogEntry', 'testpost');
- $response = $entry->trackbackping();
-
- $this->assertContains("1 ", $response);
-
- $_POST['url'] = 'test trackback post url';
- $_POST['title'] = 'test trackback post title';
- $_POST['excerpt'] = 'test trackback post excerpt';
- $_POST['blog_name'] = 'test trackback blog name';
-
- $response = $entry->trackbackping();
- $this->assertContains("0 ", $response);
-
- $trackback = DataObject::get_one('TrackBackPing');
- $this->assertEquals('test trackback post url', $trackback->Url);
- $this->assertEquals('test trackback post title', $trackback->Title);
- $this->assertEquals('test trackback post excerpt', $trackback->Excerpt);
- $this->assertEquals('test trackback blog name', $trackback->BlogName);
-
- unset($_POST);
- }
}
\ No newline at end of file
diff --git a/tests/BlogTrackbackTest.php b/tests/BlogTrackbackTest.php
new file mode 100644
index 0000000..7fa6745
--- /dev/null
+++ b/tests/BlogTrackbackTest.php
@@ -0,0 +1,107 @@
+objFromFixture('BlogHolder', 'mainblog');
+ $blog->TrackBacksEnabled = true;
+ $blog->write();
+
+ $entry = $this->objFromFixture('BlogEntry', 'testpost');
+ $response = $entry->trackbackping();
+
+ $this->assertContains("1 ", $response);
+
+ $_POST['url'] = 'test trackback post url';
+ $_POST['title'] = 'test trackback post title';
+ $_POST['excerpt'] = 'test trackback post excerpt';
+ $_POST['blog_name'] = 'test trackback blog name';
+
+ $response = $entry->trackbackping();
+ $this->assertContains("0 ", $response);
+
+ $trackback = DataObject::get_one('TrackBackPing');
+ $this->assertEquals('test trackback post url', $trackback->Url);
+ $this->assertEquals('test trackback post title', $trackback->Title);
+ $this->assertEquals('test trackback post excerpt', $trackback->Excerpt);
+ $this->assertEquals('test trackback blog name', $trackback->BlogName);
+
+ unset($_POST);
+ }
+
+ function testShouldTrackbackNotify() {
+ $blog = $this->objFromFixture('BlogHolder', 'mainblog');
+ $blog->TrackBacksEnabled = true;
+
+ $entry = $this->objFromFixture('BlogEntry', 'testpost');
+ $this->assertFalse($entry->ShouldTrackbackNotify());
+
+ $entry = $this->objFromFixture('BlogEntry', 'testpost');
+ $entry->TrackbackURL = ' ';
+ $this->assertFalse($entry->ShouldTrackbackNotify());
+
+ $entry = $this->objFromFixture('BlogEntry', 'testpost');
+ $entry->TrackbackURL = 'someurl';
+ $this->assertTrue($entry->ShouldTrackbackNotify());
+ }
+
+ function testTrackbackNotify() {
+ $tmpServerClass = TrackBackDecorator::$trackback_server_class;
+ TrackBackDecorator::$trackback_server_class = "TestTrackbackHTTPServer";
+
+ $blog = $this->objFromFixture('BlogHolder', 'mainblog');
+ $blog->TrackBacksEnabled = true;
+
+ $entry = $this->objFromFixture('BlogEntry', 'testpost');
+ $entry->TrackbackURL = 'testGoodTrackbackURL';
+ $this->assertTrue($entry->trackbackNotify());
+
+ $entry->TrackbackURL = 'testBadTrackbackURL';
+ $this->assertFalse($entry->trackbackNotify());
+
+ $entry->TrackbackURL = 'testNonExistingTrackbackURL';
+ $this->assertFalse($entry->trackbackNotify());
+
+ TrackBackDecorator::$trackback_server_class = $tmpServerClass;
+ }
+}
+
+class TestTrackbackHTTPServer extends TrackbackHTTPServer implements TestOnly {
+
+ function request($url, $data) {
+ if($url == 'testGoodTrackbackURL') {
+ $response = $this->goodTrackback();
+ $statusCode = '200';
+ }
+ else if($url == 'testBadTrackbackURL') {
+ $response = $this->badTrackback();
+ $statusCode = '200';
+ }
+ else {
+ $response = $this->badTrackback();
+ $statusCode = '404';
+ }
+
+ return new SS_HTTPResponse($response, $statusCode);
+ }
+
+ private function goodTrackback() {
+ return "
+
+ 0
+
+ ";
+ }
+
+ private function badTrackback() {
+ return "
+
+ 1
+ Some error text
+ ";
+ }
+}
\ No newline at end of file
From 834b6d8f91ce9ebc47ad34e3e9b42475fb1333a6 Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Wed, 23 Jun 2010 05:50:02 +0000
Subject: [PATCH 225/250] ENHANCEMENT: Allow notifying multiple trackback urls
per blog entry APICHANGE: TrackBackDecorator::trackbackNotify() allow one
parameter APICHANGE: remove TrackBackDecorator::ShouldTrackbackNotify()
---
code/TrackBackDecorator.php | 67 ++++++++++++++++++----------------
code/TrackBackURL.php | 54 +++++++++++++++++++++++++++
tests/BlogTrackbackTest.php | 73 +++++++++++++++++++++++--------------
tests/BlogTrackbackTest.yml | 38 +++++++++++++++++++
4 files changed, 173 insertions(+), 59 deletions(-)
create mode 100644 code/TrackBackURL.php
create mode 100644 tests/BlogTrackbackTest.yml
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index 8bc2dec..5356fd9 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -1,6 +1,6 @@
array(
- 'TrackbackURL' => 'Varchar(2048)',
- 'PungTrackbackURL' => 'Varchar(2048)'
- ),
'has_many' => array(
+ 'TrackBackURLs' => 'TrackBackURL',
'TrackBacks' => 'TrackBackPing'
)
);
@@ -21,63 +18,67 @@ class TrackBackDecorator extends DataObjectDecorator {
function updateCMSFields($fields) {
// Trackback URL field
if($this->owner->TrackBacksEnabled()) {
- $fields->addFieldToTab("Root.Content.Main", new TextField("TrackbackURL", _t("BlogEntry.TRACKBACKURL", "Trackback URL")), "Content");
+ $trackbackURLTable = new ComplexTableField(
+ $this,
+ 'TrackBackURLs',
+ 'TrackBackURL',
+ array(
+ 'URL' => 'URL',
+ 'IsPung' => 'Pung?'
+ ),
+ 'getCMSFields_forPopup',
+ '',
+ 'ID'
+ );
+ $fields->addFieldToTab("Root.Content.Main", $trackbackURLTable);
}
else {
- $fields->addFieldToTab("Root.Content.Main", new ReadonlyField("TrackbackURLReadOnly", _t("BlogEntry.TRACKBACKURL", "Trackback URL"), _t("BlogEntry.TRACKBACKURL_DISABLED", "To use this feature, please check 'Enable TrackBacks' check box on the blog holder.")), "Content");
+ $fields->addFieldToTab("Root.Content.Main", new ReadonlyField("TrackBackURLsReadOnly", _t("BlogEntry.TrackbackURLs", "Trackback URLs"), _t("BlogEntry.TrackbackURLs_DISABLED", "To use this feature, please check 'Enable TrackBacks' check box on the blog holder.")));
}
}
function onBeforePublish() {
- $owner = $this->owner;
-
- if(!empty($owner->TrackbackURL) && $owner->TrackBacksEnabled() && $owner->ShouldTrackbackNotify()) {
-
- if($this->trackbackNotify()) {
- $owner->PungTrackbackURL = $owner->TrackbackURL;
- $owner->write();
+ if(!$this->owner->TrackBacksEnabled() && !$this->owner->TrackBackURLs()) return;
+
+ foreach($this->owner->TrackBackURLs() as $trackBackURL) {
+ if(!$trackBackURL->Pung && $this->trackbackNotify($trackBackURL->URL)) {
+ $trackBackURL->Pung = true;
+ $trackBackURL->write();
}
- }
+ }
}
/**
* Trackback notify the specified trackback url
* @param boolean | true on success, otherwise false
*/
- function trackbackNotify() {
- $owner = $this->owner;
-
+ function trackbackNotify($url) {
$content = new HTMLText('Content');
- $content->setValue($owner->Content);
+ $content->setValue($this->owner->Content);
$excerpt = $content->FirstParagraph();
-
- if($owner->Parent() && $owner->ParentID > 0) {
- $blogName = $owner->Parent()->Title;
+
+ if($this->owner->Parent() && $this->owner->ParentID > 0) {
+ $blogName = $this->owner->Parent()->Title;
}
else {
$blogName = "";
}
-
+
$postData = array(
- 'url' => $owner->AbsoluteLink(),
- 'title' => $owner->Title,
+ 'url' => $this->owner->AbsoluteLink(),
+ 'title' => $this->owner->Title,
'excerpt' => $excerpt,
'blog_name' => $blogName
);
-
+
$controller = Object::create(self::$trackback_server_class);
- $response = $controller->request($owner->TrackbackURL, $postData);
+ $response = $controller->request($url, $postData);
if($response->getStatusCode() == '200' && stripos($response->getBody(), "0 ") !== false) {
return true;
}
return false;
-
- }
-
- function ShouldTrackbackNotify() {
- return (trim($this->owner->TrackbackURL) != '' && $this->owner->TrackbackURL != $this->owner->PungTrackbackURL);
}
function updateMetaTags(&$tags) {
@@ -136,6 +137,8 @@ class TrackbackHTTPServer {
*/
function request($url, $data) {
$ch = curl_init($url);
+
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
diff --git a/code/TrackBackURL.php b/code/TrackBackURL.php
new file mode 100644
index 0000000..c2b112c
--- /dev/null
+++ b/code/TrackBackURL.php
@@ -0,0 +1,54 @@
+ 'Varchar(2048)',
+ 'Pung' => 'Boolean(0)'
+ );
+
+ static $has_one = array(
+ 'BlogEntry' => 'BlogEntry'
+ );
+
+ function getCMSFields_forPopup() {
+ return new FieldSet(
+ new TextField('URL'),
+ new ReadonlyField('Pung', 'Pung?')
+ );
+ }
+
+ /**
+ * Return a human-reable string indicate whether the url has been pung or not
+ * Also update the url if it's duplicate
+ * @return string - 'Yes' or 'No'
+ */
+ function IsPung() {
+ if($this->Pung) return _t('TrackBackULR.YES', 'Yes');
+
+ if($this->isDuplicate(true)) {
+ $this->Pung = true;
+ $this->write();
+
+ return _t('TrackBackULR.YES', 'Yes');
+ }
+
+ return _t('TrackBackULR.NO', 'No');
+ }
+
+ /**
+ * Check if there is a duplication, based on the associcated blog entry and the url.
+ * If onPung is set, it returns true only when the duplicated record that has Pung = true
+ * @param boolean
+ * @return boolean
+ */
+ function isDuplicate($onPung = false) {
+ $where = "\"BlogEntryID\" = {$this->BlogEntryID} AND \"URL\" = '{$this->URL}' AND TrackBackURL.ID <> {$this->ID}";
+ if($onPung) $where .= " AND Pung IS TRUE";
+
+ if(DataObject::get_one($this->ClassName, $where)) {
+ return true;
+ }
+
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/tests/BlogTrackbackTest.php b/tests/BlogTrackbackTest.php
index 7fa6745..cf9550e 100644
--- a/tests/BlogTrackbackTest.php
+++ b/tests/BlogTrackbackTest.php
@@ -4,7 +4,7 @@
* @subpackage tests
*/
class BlogTrackbackTest extends SapphireTest {
- static $fixture_file = 'blog/tests/BlogTest.yml';
+ static $fixture_file = 'blog/tests/BlogTrackbackTest.yml';
function testTrackback() {
$blog = $this->objFromFixture('BlogHolder', 'mainblog');
@@ -33,47 +33,66 @@ class BlogTrackbackTest extends SapphireTest {
unset($_POST);
}
- function testShouldTrackbackNotify() {
- $blog = $this->objFromFixture('BlogHolder', 'mainblog');
- $blog->TrackBacksEnabled = true;
-
- $entry = $this->objFromFixture('BlogEntry', 'testpost');
- $this->assertFalse($entry->ShouldTrackbackNotify());
-
- $entry = $this->objFromFixture('BlogEntry', 'testpost');
- $entry->TrackbackURL = ' ';
- $this->assertFalse($entry->ShouldTrackbackNotify());
-
- $entry = $this->objFromFixture('BlogEntry', 'testpost');
- $entry->TrackbackURL = 'someurl';
- $this->assertTrue($entry->ShouldTrackbackNotify());
- }
-
function testTrackbackNotify() {
$tmpServerClass = TrackBackDecorator::$trackback_server_class;
TrackBackDecorator::$trackback_server_class = "TestTrackbackHTTPServer";
-
+
$blog = $this->objFromFixture('BlogHolder', 'mainblog');
$blog->TrackBacksEnabled = true;
+ $blog->write();
$entry = $this->objFromFixture('BlogEntry', 'testpost');
- $entry->TrackbackURL = 'testGoodTrackbackURL';
- $this->assertTrue($entry->trackbackNotify());
-
- $entry->TrackbackURL = 'testBadTrackbackURL';
- $this->assertFalse($entry->trackbackNotify());
-
- $entry->TrackbackURL = 'testNonExistingTrackbackURL';
- $this->assertFalse($entry->trackbackNotify());
+ $this->assertTrue($entry->trackbackNotify('testGoodTrackbackURL'));
+ $this->assertFalse($entry->trackbackNotify('testBadTrackbackURL'));
+ $this->assertFalse($entry->trackbackNotify('testNonExistingTrackbackURL'));
TrackBackDecorator::$trackback_server_class = $tmpServerClass;
}
+
+ function testOnBeforePublish() {
+ $tmpServerClass = TrackBackDecorator::$trackback_server_class;
+ TrackBackDecorator::$trackback_server_class = "TestTrackbackHTTPServer";
+
+ $blog = $this->objFromFixture('BlogHolder', 'mainblog');
+ $blog->TrackBacksEnabled = true;
+ $blog->write();
+
+ $entry1 = $this->objFromFixture('BlogEntry', 'testpost');
+ $entry1->doPublish();
+ $this->assertEquals(2, $entry1->TrackBackURLs()->Count());
+ $this->assertEquals(array('testGoodTrackbackURL' => 1), $entry1->TrackBackURLs()->map('URL', 'Pung'));
+
+ $entry2 = $this->objFromFixture('BlogEntry', 'testpost2');
+ $entry2->doPublish();
+ $this->assertEquals(4, $entry2->TrackBackURLs()->Count());
+ $this->assertEquals(array('testBadTrackbackURL' => 0, 'testGoodTrackbackURL2' => 1, 'noneExistingURL' => 0, 'testGoodTrackbackURL3' => 1), $entry2->TrackBackURLs()->map('URL', 'Pung'));
+
+ TrackBackDecorator::$trackback_server_class = $tmpServerClass;
+ }
+
+ function testDuplicateIsTrackBackURL() {
+ $url1 = $this->objFromFixture('TrackBackURL', 'goodTrackBackURL1');
+ $urlDup = $this->objFromFixture('TrackBackURL', 'dupTrackBackURL');
+
+ $url2 = $this->objFromFixture('TrackBackURL', 'goodTrackBackURL2');
+ $this->assertFalse($url2->isDuplicate());
+ $this->assertFalse($url2->isDuplicate(true));
+
+ $this->assertTrue($urlDup->isDuplicate());
+ $this->assertFalse($urlDup->isDuplicate(true));
+
+ $url1->Pung = true;
+ $url1->write();
+ $this->assertTrue($urlDup->isDuplicate(true));
+
+
+ }
}
class TestTrackbackHTTPServer extends TrackbackHTTPServer implements TestOnly {
function request($url, $data) {
- if($url == 'testGoodTrackbackURL') {
+ if(in_array($url, array('testGoodTrackbackURL', 'testGoodTrackbackURL2', 'testGoodTrackbackURL3'))) {
$response = $this->goodTrackback();
$statusCode = '200';
}
diff --git a/tests/BlogTrackbackTest.yml b/tests/BlogTrackbackTest.yml
new file mode 100644
index 0000000..586b7b1
--- /dev/null
+++ b/tests/BlogTrackbackTest.yml
@@ -0,0 +1,38 @@
+TrackBackURL:
+ goodTrackBackURL1:
+ URL: testGoodTrackbackURL
+ goodTrackBackURL2:
+ URL: testGoodTrackbackURL2
+ goodTrackBackURL3:
+ URL: testGoodTrackbackURL3
+ badTrackBackURL:
+ URL: testBadTrackbackURL
+ noneTrackBackURL:
+ URL: noneExistingURL
+ dupTrackBackURL:
+ URL: testGoodTrackbackURL
+
+BlogHolder:
+ mainblog:
+ Title: Main Blog
+
+BlogEntry:
+ testpost:
+ Title: Test Post
+ URLSegment: test-post
+ Date: 2007-02-17 18:45:00
+ Parent: =>BlogHolder.mainblog
+ Tags: tag1,tag2
+ TrackBackURLs: =>TrackBackURL.goodTrackBackURL1, =>TrackBackURL.dupTrackBackURL
+ testpost2:
+ Title: Test Post 2
+ URLSegment: test-post-2
+ Parent: =>BlogHolder.mainblog
+ TrackBackURLs: =>TrackBackURL.badTrackBackURL,=>TrackBackURL.goodTrackBackURL2,=>TrackBackURL.noneTrackBackURL,=>TrackBackURL.goodTrackBackURL3
+
+
+
+
+
+
+
From 20ad8dfbbc8183fd64c28552e77e647976174825 Mon Sep 17 00:00:00 2001
From: Will Rossiter
Date: Sat, 26 Jun 2010 04:47:15 +0000
Subject: [PATCH 226/250] BUGFIX: getParent() may return null. Prevent calling
function on null (esp when running tests)
---
code/BlogEntry.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 4f137ee..53a9124 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -163,14 +163,14 @@ class BlogEntry extends Page {
* Link for editing this blog entry
*/
function EditURL() {
- return $this->getParent()->Link('post') . '/' . $this->ID . '/';
+ return ($this->getParent()) ? $this->getParent()->Link('post') . '/' . $this->ID . '/' : false;
}
/**
* Check to see if trackbacks are enabled.
*/
function TrackBacksEnabled() {
- return $this->getParent()->TrackBacksEnabled;
+ return ($this->getParent()) ? $this->getParent()->TrackBacksEnabled : false;
}
function trackbackping() {
From 3bf8ebc49c575407d562374fddb5e2bf0c155cc6 Mon Sep 17 00:00:00 2001
From: Andreas Piening
Date: Mon, 28 Jun 2010 00:30:10 +0000
Subject: [PATCH 227/250] MINOR: fixed malformed sql query
---
code/TrackBackURL.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/TrackBackURL.php b/code/TrackBackURL.php
index c2b112c..0959903 100644
--- a/code/TrackBackURL.php
+++ b/code/TrackBackURL.php
@@ -43,7 +43,7 @@ class TrackBackURL extends DataObject {
*/
function isDuplicate($onPung = false) {
$where = "\"BlogEntryID\" = {$this->BlogEntryID} AND \"URL\" = '{$this->URL}' AND TrackBackURL.ID <> {$this->ID}";
- if($onPung) $where .= " AND Pung IS TRUE";
+ if($onPung) $where .= " AND \"Pung\" = 1";
if(DataObject::get_one($this->ClassName, $where)) {
return true;
From d75c402999de9ad74378550ea8aafdb5a364be14 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Mon, 28 Jun 2010 01:10:17 +0000
Subject: [PATCH 228/250] MINOR Fixed TrackbackURL->isDuplicate() with ANSI
compliant SQL (see r106984 and r107129)
---
code/TrackBackURL.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/TrackBackURL.php b/code/TrackBackURL.php
index 0959903..7cf0903 100644
--- a/code/TrackBackURL.php
+++ b/code/TrackBackURL.php
@@ -42,7 +42,7 @@ class TrackBackURL extends DataObject {
* @return boolean
*/
function isDuplicate($onPung = false) {
- $where = "\"BlogEntryID\" = {$this->BlogEntryID} AND \"URL\" = '{$this->URL}' AND TrackBackURL.ID <> {$this->ID}";
+ $where = "\"BlogEntryID\" = {$this->BlogEntryID} AND \"URL\" = '{$this->URL}' AND \"TrackBackURL\".\"ID\" <> {$this->ID}";
if($onPung) $where .= " AND \"Pung\" = 1";
if(DataObject::get_one($this->ClassName, $where)) {
From 9cfd303ecf61fa334670b0973afcfa32257c56f6 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 1 Jul 2010 21:49:58 +0000
Subject: [PATCH 229/250] BUGFIX: Got rid of link to post new entry in the
front end on a BlogTree (method does not exist on BlogTree). Thanks smurkas
(#4692)
---
code/widgets/BlogManagementWidget.php | 2 +-
templates/BlogManagementWidget.ss | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/code/widgets/BlogManagementWidget.php b/code/widgets/BlogManagementWidget.php
index eb9f4ec..964d7bc 100644
--- a/code/widgets/BlogManagementWidget.php
+++ b/code/widgets/BlogManagementWidget.php
@@ -60,7 +60,7 @@ class BlogManagementWidget_Controller extends Widget_Controller {
function PostLink() {
$container = BlogTree::current();
- if ($container) return $container->Link('post');
+ return ($container && $container->ClassName != "BlogTree") ? $container->Link('post') : false;
}
}
?>
diff --git a/templates/BlogManagementWidget.ss b/templates/BlogManagementWidget.ss
index 29f4b4a..430d27b 100644
--- a/templates/BlogManagementWidget.ss
+++ b/templates/BlogManagementWidget.ss
@@ -1,5 +1,5 @@
From d491c442dcdfbb60ff51530398eb5f96cfa8f61a Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 1 Jul 2010 23:30:13 +0000
Subject: [PATCH 230/250] ENHANCEMENT: Added option to view archives just by
year (ticket #5667) ENHANCEMENT: added action on BlogTree
---
code/BlogTree.php | 26 +++++++++++++++++++++-----
templates/Layout/BlogHolder.ss | 2 +-
templates/Layout/BlogTree.ss | 2 +-
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 889b465..b6d4533 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -210,7 +210,8 @@ class BlogTree_Controller extends Page_Controller {
static $allowed_actions = array(
'index',
'rss',
- 'tag'
+ 'tag',
+ 'date'
);
function init() {
@@ -255,7 +256,7 @@ class BlogTree_Controller extends Page_Controller {
$date = $this->SelectedDate();
- return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date->Format('Y-m') : '', null, $filter);
+ return $this->Entries("$start,$limit", $this->SelectedTag(), ($date) ? $date : '', null, $filter);
}
/**
@@ -311,13 +312,28 @@ class BlogTree_Controller extends Page_Controller {
$month = $this->request->latestParam('OtherID');
if(is_numeric($year) && is_numeric($month) && $month < 13) {
- $date = new Date();
- $date->setValue($year .'-'. $month);
-
+
+ $date = $year .'-'. $month;
return $date;
+
+ } else {
+
+ if(is_numeric($year)) return $year;
}
}
return false;
}
+
+ function SelectedNiceDate(){
+ $date = $this->SelectedDate();
+
+ if(strpos($date, '-')) {
+ $date = explode("-",$date);
+ return date("F", mktime(0, 0, 0, $date[1], 1, date('Y'))). " " .date("Y", mktime(0, 0, 0, date('m'), 1, $date[0]));
+
+ } else {
+ return date("Y", mktime(0, 0, 0, date('m'), 1, $date));
+ }
+ }
}
\ No newline at end of file
diff --git a/templates/Layout/BlogHolder.ss b/templates/Layout/BlogHolder.ss
index e8e7779..0ce2595 100644
--- a/templates/Layout/BlogHolder.ss
+++ b/templates/Layout/BlogHolder.ss
@@ -7,7 +7,7 @@
<% if SelectedTag %>
<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'
<% else_if SelectedDate %>
- <% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedDate.Month $SelectedDate.Year
+ <% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedNiceDate
<% end_if %>
<% if BlogEntries %>
diff --git a/templates/Layout/BlogTree.ss b/templates/Layout/BlogTree.ss
index 59ee03a..8c64613 100644
--- a/templates/Layout/BlogTree.ss
+++ b/templates/Layout/BlogTree.ss
@@ -7,7 +7,7 @@
<% if SelectedTag %>
<% _t('VIEWINGTAGGED', 'Viewing entries tagged with') %> '$SelectedTag'
<% else_if SelectedDate %>
- <% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedDate.Month $SelectedDate.Year
+ <% _t('VIEWINGPOSTEDIN', 'Viewing entries posted in') %> $SelectedNiceDate
<% end_if %>
<% if BlogEntries %>
From d7bb8a6d74e44c8c6c92c67a499b6d3a4d897660 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Tue, 3 Aug 2010 00:44:30 +0000
Subject: [PATCH 231/250] BUGFIX: Fixed front end post entry form validation
and its test
---
code/BlogHolder.php | 2 +-
tests/BlogHolderFunctionalTest.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index e4aff3a..b50d830 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -238,7 +238,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
$actions = new FieldSet($submitAction);
- $validator = new RequiredFields('Title','Content');
+ $validator = new RequiredFields('Title','BlogPost');
$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
diff --git a/tests/BlogHolderFunctionalTest.php b/tests/BlogHolderFunctionalTest.php
index e229e0e..2367074 100644
--- a/tests/BlogHolderFunctionalTest.php
+++ b/tests/BlogHolderFunctionalTest.php
@@ -26,7 +26,7 @@ class BlogHolderFunctionalTest extends FunctionalTest {
$data = array(
'Title'=>'Disallowed',
'Author'=>'Disallowed',
- 'Content'=>'Disallowed',
+ 'BlogPost'=>'Disallowed',
'action_postblog' => 'Post blog entry',
'SecurityID' => $securityID
);
@@ -40,7 +40,7 @@ class BlogHolderFunctionalTest extends FunctionalTest {
$data = array(
'Title'=>'Allowed',
'Author'=>'Allowed',
- 'Content'=>'Allowed',
+ 'BlogPost'=>'Allowed',
'action_postblog' => 'Post blog entry',
'SecurityID' => $securityID
);
From 92c09ee62fb62bc99bcc0080f57a6dbef19a0d0f Mon Sep 17 00:00:00 2001
From: Paul Clarke
Date: Sun, 22 Aug 2010 23:26:49 +0000
Subject: [PATCH 232/250] Blog styling
---
css/tagcloud.css | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/css/tagcloud.css b/css/tagcloud.css
index 464952f..3fb67e0 100644
--- a/css/tagcloud.css
+++ b/css/tagcloud.css
@@ -1,6 +1,6 @@
-.tagcloud .not-popular { font-size: 1em; }
-.tagcloud .not-very-popular { font-size: 1.3em; }
-.tagcloud .somewhat-popular { font-size: 1.6em; }
-.tagcloud .popular { font-size: 1.9em; }
-.tagcloud .very-popular { font-size: 2.2em; }
-.tagcloud .ultra-popular { font-size: 2.5em; }
\ No newline at end of file
+.tagcloud .not-popular { font-size: .9em; }
+.tagcloud .not-very-popular { font-size: 1em; }
+.tagcloud .somewhat-popular { font-size: 1.3em; }
+.tagcloud .popular { font-size: 1.6em; }
+.tagcloud .very-popular { font-size: 1.9em; }
+.tagcloud .ultra-popular { font-size: 2.2em; }
\ No newline at end of file
From 3593f03f7e793ba42cea45af046a5bf4143dcfde Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Sun, 3 Oct 2010 20:02:43 +0000
Subject: [PATCH 233/250] BUGFIX Fixed XSS vulnerability in BlogTree when
filtering by tags
---
code/BlogTree.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index b6d4533..01ad118 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -298,7 +298,7 @@ class BlogTree_Controller extends Page_Controller {
* @return String
*/
function SelectedTag() {
- return ($this->request->latestParam('Action') == 'tag') ? $this->request->latestParam('ID') : '';
+ return ($this->request->latestParam('Action') == 'tag') ? Convert::raw2xml($this->request->latestParam('ID')) : '';
}
/**
From 1a6bb1482c7b3d0d05e9fad887b382f865e98180 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Thu, 7 Oct 2010 22:31:04 +0000
Subject: [PATCH 234/250] BUGFIX: TagCloudWidget uses themedCSS instead css
(ticket 6059, thanks artyom)
---
code/widgets/TagCloudWidget.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index 2fe130a..ed51693 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -43,7 +43,7 @@ class TagCloudWidget extends Widget {
}
function TagsCollection() {
- Requirements::css("blog/css/tagcloud.css");
+ Requirements::themedCSS("tagcloud");
$allTags = array();
$max = 0;
From 438feba01e6941deb1eff15c38e08418ac2e18ab Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Fri, 8 Oct 2010 03:28:11 +0000
Subject: [PATCH 235/250] BUGFIX: TagCloudWidget sorts by frecuency even with
limit equal 0, see ticket 6060
---
code/widgets/TagCloudWidget.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index ed51693..4a2874a 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -64,13 +64,13 @@ class TagCloudWidget extends Widget {
if($allTags) {
//TODO: move some or all of the sorts to the database for more efficiency
- if($this->Limit > 0){
- uasort($allTags, array($this, "column_sort_by_popularity")); //sort by popularity
- $allTags = array_slice($allTags, 0, $this->Limit,true);
- }
- if($this->Sortby == "alphabet"){
+ if($this->Limit > 0) $allTags = array_slice($allTags, 0, $this->Limit, true);
+
+ if($this->Sortby == "alphabet"){
$this->natksort($allTags);
- }
+ } else{
+ uasort($allTags, array($this, "column_sort_by_popularity")); // sort by frequency
+ }
$sizes = array();
foreach ($allTags as $tag => $count) $sizes[$count] = true;
@@ -79,7 +79,7 @@ class TagCloudWidget extends Widget {
$numsizes = count($sizes)-1; //Work out the number of different sizes
$buckets = count(self::$popularities)-1;
- // If there are more frequencies then buckets, divide frequencies into buckets
+ // If there are more frequencies than buckets, divide frequencies into buckets
if ($numsizes > $buckets) {
$numsizes = $buckets;
}
From eb527139547052c5289ca368d32d4af2ff33834a Mon Sep 17 00:00:00 2001
From: Saophalkun Ponlu
Date: Fri, 10 Dec 2010 03:20:26 +0000
Subject: [PATCH 236/250] MINOR: Allow decorating db and cms fields of widgets
in one decorator. Thanks to smurkas
---
code/widgets/ArchiveWidget.php | 20 ++++++++++++--------
code/widgets/RSSWidget.php | 12 ++++++++----
code/widgets/TagCloudWidget.php | 12 ++++++++----
3 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index 1186fb7..77b2c7b 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -29,15 +29,19 @@ class ArchiveWidget extends Widget {
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
function getCMSFields() {
- $fields = new FieldSet(
- new OptionsetField(
- 'DisplayMode',
- _t('ArchiveWidget.DispBY', 'Display by'),
- array(
- 'month' => _t('ArchiveWidget.MONTH', 'month'),
- 'year' => _t('ArchiveWidget.YEAR', 'year')
+ $fields = parent::getCMSFields();
+
+ $fields->merge(
+ new FieldSet(
+ new OptionsetField(
+ 'DisplayMode',
+ _t('ArchiveWidget.DispBY', 'Display by'),
+ array(
+ 'month' => _t('ArchiveWidget.MONTH', 'month'),
+ 'year' => _t('ArchiveWidget.YEAR', 'year')
+ )
)
- )
+ )
);
$this->extend('updateCMSFields', $fields);
diff --git a/code/widgets/RSSWidget.php b/code/widgets/RSSWidget.php
index 5209c42..17f8bc9 100644
--- a/code/widgets/RSSWidget.php
+++ b/code/widgets/RSSWidget.php
@@ -40,10 +40,14 @@ class RSSWidget extends Widget {
}
function getCMSFields() {
- $fields = new FieldSet(
- new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
- new TextField("RssUrl", _t('RSSWidget.URL', "URL of the other page's RSS feed. Please make sure this URL points to an RSS feed.")),
- new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show"))
+ $fields = parent::getCMSFields();
+
+ $fields->merge(
+ new FieldSet(
+ new TextField("RSSTitle", _t('RSSWidget.CT', "Custom title for the feed")),
+ new TextField("RssUrl", _t('RSSWidget.URL', "URL of the other page's RSS feed. Please make sure this URL points to an RSS feed.")),
+ new NumericField("NumberToShow", _t('RSSWidget.NTS', "Number of Items to show"))
+ )
);
$this->extend('updateCMSFields', $fields);
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index 4a2874a..960c007 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -27,10 +27,14 @@ class TagCloudWidget extends Widget {
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
function getCMSFields() {
- $fields = new FieldSet(
- new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
- new TextField("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")),
- new OptionsetField("Sortby",_t("TagCloudWidget.SORTBY","Sort by"),array("alphabet"=>_t("TagCloudWidget.SBAL", "alphabet"),"frequency"=>_t("TagCloudWidget.SBFREQ", "frequency")))
+ $fields = parent::getCMSFields();
+
+ $fields->merge(
+ new FieldSet(
+ new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
+ new TextField("Limit", _t("TagCloudWidget.LIMIT", "Limit number of tags")),
+ new OptionsetField("Sortby",_t("TagCloudWidget.SORTBY","Sort by"),array("alphabet"=>_t("TagCloudWidget.SBAL", "alphabet"),"frequency"=>_t("TagCloudWidget.SBFREQ", "frequency")))
+ )
);
$this->extend('updateCMSFields', $fields);
From 66f7263f8ad8caaa20ba2b9a66934de146ae5620 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Thu, 16 Dec 2010 01:36:08 +0000
Subject: [PATCH 237/250] MINOR Added BlogEntry_Controller->PageComments() as a
temporary workaround to avoid deprecation warnings from new 'comments' module
---
code/BlogEntry.php | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 53a9124..b81ab42 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -263,5 +263,16 @@ class BlogEntry_Controller extends Page_Controller {
Director::redirect($this->getParent()->Link());
}
}
+
+ /**
+ * Temporary workaround for compatibility with 'comments' module
+ * (has been extracted from sapphire/trunk in 12/2010).
+ *
+ * @return Form
+ */
+ function PageComments() {
+ if($this->hasMethod('CommentsForm')) return $this->CommentsForm();
+ else return parent::PageComments();
+ }
}
From c4dde4bccd7f6ef8eb230f146e87bd04dcf43cc9 Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Tue, 11 Jan 2011 22:15:52 +0000
Subject: [PATCH 238/250] MINOR: Show in menus is true now by default
---
code/BlogEntry.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index b81ab42..1a7671e 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -27,7 +27,7 @@ class BlogEntry extends Page {
static $defaults = array(
"ProvideComments" => true,
- 'ShowInMenus' => false
+ 'ShowInMenus' => true
);
static $extensions = array(
From 40a52b8cfdaca10c872936412bd69a206d6fc15b Mon Sep 17 00:00:00 2001
From: Carlos Barberis
Date: Tue, 11 Jan 2011 22:18:26 +0000
Subject: [PATCH 239/250] MINOR: reverted show in menus true by default
---
code/BlogEntry.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 1a7671e..b81ab42 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -27,7 +27,7 @@ class BlogEntry extends Page {
static $defaults = array(
"ProvideComments" => true,
- 'ShowInMenus' => true
+ 'ShowInMenus' => false
);
static $extensions = array(
From c3415b66971e45881cec633e725b49430a654a0f Mon Sep 17 00:00:00 2001
From: phalkun
Date: Fri, 14 Jan 2011 14:07:54 +1300
Subject: [PATCH 240/250] MINOR: Move documentation from
http://doc.silverstripe.org MINOR: Update README to Markdown format
---
README | 17 -----------------
README.md | 18 ++++++++++++++++++
docs/Install.md | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 17 deletions(-)
delete mode 100644 README
create mode 100644 README.md
create mode 100644 docs/Install.md
diff --git a/README b/README
deleted file mode 100644
index b81ef97..0000000
--- a/README
+++ /dev/null
@@ -1,17 +0,0 @@
-####################################################
-Blog Module
-####################################################
-
-# Maintainer Contact
-Saophalkun Ponlu (Nickname: aoneil)
-
-Carlos Barberis
-
-
-# Requirements
-SilverStripe minimum version 2.4.0
-
-# Documentation
-http://doc.silverstripe.com/doku.php?id=modules:blog
-
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b8be84a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,18 @@
+# Blog Module
+
+## Maintainer Contact
+
+- Saophalkun Ponlu
+- Carlos Barberis
+
+## Requirements
+
+SilverStripe minimum version 2.4.0
+
+## Installation
+
+See docs/Install.md
+
+## Usage
+
+See doc/Install.md
diff --git a/docs/Install.md b/docs/Install.md
new file mode 100644
index 0000000..a7faed3
--- /dev/null
+++ b/docs/Install.md
@@ -0,0 +1,45 @@
+# Blog Module
+
+## Introduction
+
+The blog module allows you to post blogs on your SilverStripe. It includes the ability to post blogs using a site front-end form. Blogs are summarised on the blog holder page type, with more detail viewable when a specific blog is clicked.
+
+## Feature Overview
+
+- Front-end blog post form
+- Posts allow bbcode
+- RSS feed for blog and also feeds for comments on posts
+- Easily customizable
+- Tag cloud widget
+- Archive widget
+- Blog management widget
+- RSS widget (will likely move in future)
+
+## Page types
+
+We have chosen to go with the following page types to include with the blog module:
+
+- **BlogTree** This is a holder of BlogHolder. If your site has only one blog holder, you won't need this page type.
+- **BlogHolder** The BlogHolder shows BlogEntries, and provides a way to search etc.It would also contain methods to post new blogs.
+- BlogEntry: This is simply an entry/post for the blog.
+
+## View Archived Blogs
+
+Blog archives can be viewed by `year/month` by appending the year, followed by a forward slash, then the numerical month, to the end of the BlogHolder URL. Alternately, just the year can be appended to view entries for that year.
+
+for example:
+
+- `mysite/blog/2007/6` would show blog entries for June 2007
+- `mysite/blog/2007` would show blog entries for 2007
+
+## Comments and Spam Protection
+
+See [PageComment](http://doc.silverstripe.org/pagecomment).
+
+## Widgets
+
+See [Widgets](http://doc.silverstripe.org/widgets).
+
+## Working with the theme
+
+The blog comes set up to use the `\themes\blackcandy_blog\` directory by default. See [themes](http://doc.silverstripe.org/themes).
From 2cd7216f2ad9e8363de9d486178cb145925fb7de Mon Sep 17 00:00:00 2001
From: Fred Condo
Date: Mon, 17 Jan 2011 13:02:45 +0100
Subject: [PATCH 241/250] BUGFIX: #6118 Remove Debug::log call.
---
code/MetaWeblogController.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/code/MetaWeblogController.php b/code/MetaWeblogController.php
index 0b4041e..f890a75 100644
--- a/code/MetaWeblogController.php
+++ b/code/MetaWeblogController.php
@@ -9,7 +9,6 @@ require_once(BASE_PATH . '/blog/thirdparty/xmlrpc/xmlrpc_wrappers.php');
*/
class MetaWeblogController extends Controller {
function index($request) {
- Debug::log(Debug::text($request));
// Create an xmlrpc server, and set up the method calls
$service = new xmlrpc_server(array(
From e2f088e1e80e61a412c1e8d4cdec2bff6e7b0c12 Mon Sep 17 00:00:00 2001
From: phalkunz
Date: Thu, 20 Jan 2011 13:38:28 +1300
Subject: [PATCH 242/250] MINOR: Blog tag now supports multibyte chars in the
front-end. Thanks to hex0id.
---
code/widgets/TagCloudWidget.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index 960c007..ed1bbe0 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -57,7 +57,7 @@ class TagCloudWidget extends Widget {
if($entries) {
foreach($entries as $entry) {
- $theseTags = split(" *, *", strtolower(trim($entry->Tags)));
+ $theseTags = split(" *, *", mb_strtolower(trim($entry->Tags)));
foreach($theseTags as $tag) {
if($tag != "") {
$allTags[$tag] = isset($allTags[$tag]) ? $allTags[$tag] + 1 : 1; //getting the count into key => value map
From db45cb9b49f859de3af74b7830fd366df3db3840 Mon Sep 17 00:00:00 2001
From: phalkunz
Date: Fri, 21 Jan 2011 15:48:47 +1300
Subject: [PATCH 243/250] MINOR: Make use of Link()'s parameter
---
code/BlogTree.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 01ad118..4d2533c 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -263,7 +263,7 @@ class BlogTree_Controller extends Page_Controller {
* This will create a tag point to the RSS feed
*/
function IncludeBlogRSS() {
- RSSFeed::linkToFeed($this->Link() . "rss", _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
+ RSSFeed::linkToFeed($this->Link('rss'), _t('BlogHolder.RSSFEED',"RSS feed of these blogs"));
}
/**
From 8ccd23db5a55bb6b62a3838ae0c88e123cd1ddbe Mon Sep 17 00:00:00 2001
From: phalkunz
Date: Fri, 21 Jan 2011 15:49:36 +1300
Subject: [PATCH 244/250] MINOR: Fix RSS validator warning. Thanks to tim.
---
code/BlogTree.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 4d2533c..30d2ce4 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -278,7 +278,7 @@ class BlogTree_Controller extends Page_Controller {
$entries = $this->Entries(20);
if($entries) {
- $rss = new RSSFeed($entries, $this->Link(), ($blogName ? $blogName : $altBlogName), "", "Title", "RSSContent");
+ $rss = new RSSFeed($entries, $this->Link('rss'), ($blogName ? $blogName : $altBlogName), "", "Title", "RSSContent");
$rss->outputToBrowser();
}
}
From eef7d57b80cac4e70be01fb2f7cf36abd5b073b4 Mon Sep 17 00:00:00 2001
From: Ingo Schommer
Date: Sat, 12 Feb 2011 12:54:06 +1300
Subject: [PATCH 245/250] MINOR Migrated content from doc.ss.org
---
README.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 72 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index b8be84a..1d5e528 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,81 @@
# Blog Module
-## Maintainer Contact
+## Introduction
-- Saophalkun Ponlu
-- Carlos Barberis
+The blog module allows you to post blogs on your SilverStripe. It includes the ability to post blogs using a site front-end form. Blogs are summarised on the blog holder page type, with more detail viewable when a specific blog is clicked.
-## Requirements
+## Maintainer Contact ##
-SilverStripe minimum version 2.4.0
+ * Saophalkun Ponlu (phalkunz at silverstripe dot com)
+ * Carlos Barberis (carlos at silverstripe dot com)
-## Installation
+## Feature Overview
-See docs/Install.md
+* Front-end blog post form
+* Posts allow bbcode
+* RSS feed for blog and also feeds for comments on posts
+* Easily customizable
+* Tag cloud widget
+* Archive widget
+* Blog management widget
+* RSS widget (will likely move in future)
-## Usage
+## Configuration Options
-See doc/Install.md
+### Use WYSIWYG editing instead of bbcode
+
+Out of the box the blog module uses bbcode, just like the forum module. If you want to go back to using the standard page editing toolbar you need to add the following code to your mysite/_config.php file
+
+ :::php
+ BlogEntry::allow_wysiwyg_editing();
+
+
+## Page types
+
+We have chosen to go with the following page types to include with the blog module:
+
+* BlogHolder: The BlogHolder shows BlogEntrys, and provides a way to search etc.It would also contain methods to post new blogs.
+
+* BlogEntry: This is simply an entry/post for the blog.
+
+
+## Simple form for adding a post
+
+There is a blog management widget, that includes a link "Post new blog entry", which takes the user to [site/CurrentBlogHolder]/post (this is a good url to bookmark if you will be using it to blog regularly). This shows a blog entry form, which requires a subject and some content at the least. Clicking "Post blog entry" takes the user back to the blog. A login form will show if the user is not logged in. The entered author name is stored in a cookie. Initially the shown name will be the user's name.
+
+#### BBcode support
+
+* BBCode can be entered into the form.
+
+* A bbcode tags help box shows when the "BBCode help" link is clicked. Javascript is required for this to work.
+
+See [:PEAR:BBCodeParser](/PEAR/BBCodeParser) for more details.
+
+#### Modifying the blog entry form
+
+You may want to add or remove certain fields from the blog entry form. This can be done in **BlogHolder.php**. You will need to modify the $fields FieldSet object in the BlogEntryForm function. [tutorial 3](tutorial/3-forms#creating_the_form) shows you how to do this.
+
+You will likely need to play around with the form and associated css to get the form looking how you want it.
+
+## View Archived Blogs
+
+Blog archives can be viewed by year/month by appending the year, followed by a forward slash, then the numerical month, to the end of the blogholder URL. Alternately, just the year can be appended to view entries for that year.
+
+for example: mysite/blog/2007/6 would show blog entries for June 2007
+
+or: mysite/blog/2007 would show blog entries for 2007
+
+## Comments and Spam Protection
+
+See [:pagecomment](/pagecomment) for creating Askimet-protected comments for every page.
+
+## Widgets
+
+See [widgets](/widgets)
+
+
+## Working with the theme
+
+The blog comes set up to use the `\themes\blackcandy_blog\` directory by default.
+
+ * See [:themes](/themes)
\ No newline at end of file
From 1ed87c004e93dd18d8e7fbe0e36a3c14b2d6f525 Mon Sep 17 00:00:00 2001
From: John Clarke
Date: Thu, 5 May 2011 10:59:10 +0200
Subject: [PATCH 246/250] BUGFIX: support for legacy installations for the date
based blog entry listing using slashes rather than dashes. PATCH via
jcinteractive. (#5)
---
code/BlogTree.php | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 30d2ce4..758d828 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -162,9 +162,17 @@ class BlogTree extends Page {
}
if($date) {
- if(strpos($date, '-')) {
- $year = (int) substr($date, 0, strpos($date, '-'));
- $month = (int) substr($date, strpos($date, '-') + 1);
+ // Some systems still use the / seperator for date presentation
+ if( strpos($date, '-') ) $seperator = '-';
+ elseif( strpos($date, '/') ) $seperator = '/';
+
+ if(isset($seperator) && !empty($seperator)) {
+ // The 2 in the explode argument will tell it to only create 2 elements
+ // i.e. in this instance the $year and $month fields respectively
+ list($year,$month) = explode( $seperator, $date, 2);
+
+ $year = (int)$year;
+ $month = (int)$month;
if($year && $month) {
if(method_exists(DB::getConn(), 'formattedDatetimeClause')) {
From 9796265e7cfb53e63e69ffbc848f2a435621602d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabian=20Gra=C3=9Fl?=
Date: Sun, 8 Jan 2012 15:03:00 +0100
Subject: [PATCH 247/250] Use SS_Datetime instead of Datetime. Allows the usage
of Object::useCustomClass('SS_Datetime', 'LocalDatetime');
---
code/BlogEntry.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index b81ab42..b4138b5 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -6,7 +6,7 @@
*/
class BlogEntry extends Page {
static $db = array(
- "Date" => "Datetime",
+ "Date" => "SS_Datetime",
"Author" => "Text",
"Tags" => "Text"
);
From 836f745ef3bbd4e5e287760975adb60502346e0a Mon Sep 17 00:00:00 2001
From: Matt Gunn
Date: Sat, 24 Mar 2012 13:36:45 +1300
Subject: [PATCH 248/250] fixing for ss3 (parentid)
---
code/BlogEntry.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index b4138b5..862b07c 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -31,9 +31,7 @@ class BlogEntry extends Page {
);
static $extensions = array(
- 'Hierarchy',
- 'TrackBackDecorator',
- "Versioned('Stage', 'Live')"
+ 'TrackBackDecorator'
);
/**
From 8b58156211b0ede5e0dd72e577df4d2870b95373 Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Thu, 12 Apr 2012 13:53:32 +1200
Subject: [PATCH 249/250] BUGFIX Initial fixes to support at least building the
blog module on SS3
---
code/BlogEntry.php | 11 +++++------
code/BlogHolder.php | 30 ++++++++++++++----------------
code/BlogTree.php | 6 +++---
code/TrackBackDecorator.php | 6 +++---
code/widgets/ArchiveWidget.php | 4 ++--
code/widgets/RSSWidget.php | 4 ++--
code/widgets/TagCloudWidget.php | 6 +++---
tests/BlogTrackbackTest.php | 4 ++--
8 files changed, 34 insertions(+), 37 deletions(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index 862b07c..f882b50 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -49,7 +49,7 @@ class BlogEntry extends Page {
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
}
- function getCMSFields() {
+ function getCMSFields($params = null) {
Requirements::javascript('blog/javascript/bbcodehelp.js');
Requirements::themedCSS('bbcodehelp');
@@ -57,7 +57,7 @@ class BlogEntry extends Page {
$codeparser = new BBCodeParser();
SiteTree::disableCMSFieldsExtensions();
- $fields = parent::getCMSFields();
+ $fields = parent::getCMSFields($params);
SiteTree::enableCMSFieldsExtensions();
if(!self::$allow_wysiwyg_editing) {
@@ -87,8 +87,8 @@ class BlogEntry extends Page {
* Returns the tags added to this blog entry
*/
function TagsCollection() {
- $tags = split(" *, *", trim($this->Tags));
- $output = new DataObjectSet();
+ $tags = preg_split('/ *, */', trim($this->Tags));
+ $output = new ArrayList();
$link = $this->getParent() ? $this->getParent()->Link('tag') : '';
@@ -270,7 +270,6 @@ class BlogEntry_Controller extends Page_Controller {
*/
function PageComments() {
if($this->hasMethod('CommentsForm')) return $this->CommentsForm();
- else return parent::PageComments();
}
-
+
}
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index b50d830..d0053a3 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -27,15 +27,15 @@ class BlogHolder extends BlogTree implements PermissionProvider {
'BlogEntry'
);
- function getCMSFields() {
+ function getCMSFields($params = null) {
$blogOwners = $this->blogOwners();
SiteTree::disableCMSFieldsExtensions();
- $fields = parent::getCMSFields();
+ $fields = parent::getCMSFields($params);
SiteTree::enableCMSFieldsExtensions();
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
- $fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->toDropDownMap('ID', 'Name', 'None')));
+ $fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->map('ID', 'Name')));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
$this->extend('updateCMSFields', $fields);
@@ -49,15 +49,15 @@ class BlogHolder extends BlogTree implements PermissionProvider {
function blogOwners($sort = 'Name', $direction = "ASC") {
$adminMembers = Permission::get_members_by_permission('ADMIN');
$blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
-
- if(!$adminMembers) $adminMembers = new DataObjectSet();
- if(!$blogOwners) $blogOwners = new DataObjectSet();
-
+
+ if(!$adminMembers) $adminMembers = new ArrayList();
+ if(!$blogOwners) $blogOwners = new ArrayList();
+
$blogOwners->merge($adminMembers);
$blogOwners->sort($sort, $direction);
-
+
$this->extend('extendBlogOwners', $blogOwners);
-
+
return $blogOwners;
}
@@ -204,7 +204,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
$codeparser = new BBCodeParser();
- $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
+ $membername = Member::currentUser() ? Member::currentUser()->getName() : "";
if(BlogEntry::$allow_wysiwyg_editing) {
$contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
@@ -226,7 +226,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
$field = 'ReadonlyField';
}
- $fields = new FieldSet(
+ $fields = new FieldList(
new HiddenField("ID", "ID"),
new TextField("Title", _t('BlogHolder.SJ', "Subject")),
new $field("Author", _t('BlogEntry.AU'), $membername),
@@ -237,7 +237,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
);
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
- $actions = new FieldSet($submitAction);
+ $actions = new FieldList($submitAction);
$validator = new RequiredFields('Title','BlogPost');
$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
@@ -246,7 +246,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
$entry = DataObject::get_by_id('BlogEntry', $id);
if($entry->IsOwner()) {
$form->loadDataFrom($entry);
- $form->datafieldByName('BlogPost')->setValue($entry->Content);
+ $form->Fields()->dataFieldByName('BlogPost')->setValue($entry->Content);
}
} else {
$form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
@@ -274,7 +274,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
$form->saveInto($blogentry);
$blogentry->ParentID = $this->ID;
- $blogentry->Content = str_replace("\r\n", "\n", $form->datafieldByName('BlogPost')->dataValue());
+ $blogentry->Content = str_replace("\r\n", "\n", $form->Fields()->dataFieldByName('BlogPost')->dataValue());
if(Object::has_extension($this->ClassName, 'Translatable')) {
$blogentry->Locale = $this->Locale;
@@ -288,5 +288,3 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
}
-
-?>
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 758d828..9ba3dff 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -93,8 +93,8 @@ class BlogTree extends Page {
/* ----------- CMS CONTROL -------------- */
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
$fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
"" => "All entries",
@@ -344,4 +344,4 @@ class BlogTree_Controller extends Page_Controller {
return date("Y", mktime(0, 0, 0, date('m'), 1, $date));
}
}
-}
\ No newline at end of file
+}
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index 5356fd9..57a71a5 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -2,11 +2,11 @@
/**
* Add trackback (receive and send) feature blog entry
*/
-class TrackBackDecorator extends DataObjectDecorator {
+class TrackBackDecorator extends DataExtension {
static $trackback_server_class = 'TrackbackHTTPServer';
- function extraStatics() {
+ function extraStatics($class = null, $extension = null) {
return array(
'has_many' => array(
'TrackBackURLs' => 'TrackBackURL',
@@ -15,7 +15,7 @@ class TrackBackDecorator extends DataObjectDecorator {
);
}
- function updateCMSFields($fields) {
+ function updateCMSFields(FieldList $fields) {
// Trackback URL field
if($this->owner->TrackBacksEnabled()) {
$trackbackURLTable = new ComplexTableField(
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index 77b2c7b..9dfb3f5 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -28,8 +28,8 @@ class ArchiveWidget extends Widget {
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
$fields->merge(
new FieldSet(
diff --git a/code/widgets/RSSWidget.php b/code/widgets/RSSWidget.php
index 17f8bc9..4640bbf 100644
--- a/code/widgets/RSSWidget.php
+++ b/code/widgets/RSSWidget.php
@@ -39,8 +39,8 @@ class RSSWidget extends Widget {
}
}
- function getCMSFields() {
- $fields = parent::getCMSFields();
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
$fields->merge(
new FieldSet(
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index ed1bbe0..7d47a1c 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -26,9 +26,9 @@ class TagCloudWidget extends Widget {
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
- function getCMSFields() {
- $fields = parent::getCMSFields();
-
+ function getCMSFields($params = null) {
+ $fields = parent::getCMSFields($params);
+
$fields->merge(
new FieldSet(
new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
diff --git a/tests/BlogTrackbackTest.php b/tests/BlogTrackbackTest.php
index cf9550e..4a3e53c 100644
--- a/tests/BlogTrackbackTest.php
+++ b/tests/BlogTrackbackTest.php
@@ -60,7 +60,7 @@ class BlogTrackbackTest extends SapphireTest {
$entry1 = $this->objFromFixture('BlogEntry', 'testpost');
$entry1->doPublish();
$this->assertEquals(2, $entry1->TrackBackURLs()->Count());
- $this->assertEquals(array('testGoodTrackbackURL' => 1), $entry1->TrackBackURLs()->map('URL', 'Pung'));
+ $this->assertEquals(array('testGoodTrackbackURL' => 1), $entry1->TrackBackURLs()->map('URL', 'Pung')->toArray());
$entry2 = $this->objFromFixture('BlogEntry', 'testpost2');
$entry2->doPublish();
@@ -123,4 +123,4 @@ class TestTrackbackHTTPServer extends TrackbackHTTPServer implements TestOnly {
Some error text
";
}
-}
\ No newline at end of file
+}
From 90a0e80667ceb37dde25a7c2c811b07e46ee33fd Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Sat, 14 Apr 2012 11:08:18 +1200
Subject: [PATCH 250/250] Revert "BUGFIX Initial fixes to support at least
building the blog module on SS3"
This reverts commit 8b58156211b0ede5e0dd72e577df4d2870b95373.
---
code/BlogEntry.php | 11 ++++++-----
code/BlogHolder.php | 30 ++++++++++++++++--------------
code/BlogTree.php | 6 +++---
code/TrackBackDecorator.php | 6 +++---
code/widgets/ArchiveWidget.php | 4 ++--
code/widgets/RSSWidget.php | 4 ++--
code/widgets/TagCloudWidget.php | 6 +++---
tests/BlogTrackbackTest.php | 4 ++--
8 files changed, 37 insertions(+), 34 deletions(-)
diff --git a/code/BlogEntry.php b/code/BlogEntry.php
index f882b50..862b07c 100644
--- a/code/BlogEntry.php
+++ b/code/BlogEntry.php
@@ -49,7 +49,7 @@ class BlogEntry extends Page {
$this->setField('Date', date('Y-m-d H:i:s', strtotime('now')));
}
- function getCMSFields($params = null) {
+ function getCMSFields() {
Requirements::javascript('blog/javascript/bbcodehelp.js');
Requirements::themedCSS('bbcodehelp');
@@ -57,7 +57,7 @@ class BlogEntry extends Page {
$codeparser = new BBCodeParser();
SiteTree::disableCMSFieldsExtensions();
- $fields = parent::getCMSFields($params);
+ $fields = parent::getCMSFields();
SiteTree::enableCMSFieldsExtensions();
if(!self::$allow_wysiwyg_editing) {
@@ -87,8 +87,8 @@ class BlogEntry extends Page {
* Returns the tags added to this blog entry
*/
function TagsCollection() {
- $tags = preg_split('/ *, */', trim($this->Tags));
- $output = new ArrayList();
+ $tags = split(" *, *", trim($this->Tags));
+ $output = new DataObjectSet();
$link = $this->getParent() ? $this->getParent()->Link('tag') : '';
@@ -270,6 +270,7 @@ class BlogEntry_Controller extends Page_Controller {
*/
function PageComments() {
if($this->hasMethod('CommentsForm')) return $this->CommentsForm();
+ else return parent::PageComments();
}
-
+
}
diff --git a/code/BlogHolder.php b/code/BlogHolder.php
index d0053a3..b50d830 100644
--- a/code/BlogHolder.php
+++ b/code/BlogHolder.php
@@ -27,15 +27,15 @@ class BlogHolder extends BlogTree implements PermissionProvider {
'BlogEntry'
);
- function getCMSFields($params = null) {
+ function getCMSFields() {
$blogOwners = $this->blogOwners();
SiteTree::disableCMSFieldsExtensions();
- $fields = parent::getCMSFields($params);
+ $fields = parent::getCMSFields();
SiteTree::enableCMSFieldsExtensions();
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'));
- $fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->map('ID', 'Name')));
+ $fields->addFieldToTab('Root.Content.Main', new DropdownField('OwnerID', 'Blog owner', $blogOwners->toDropDownMap('ID', 'Name', 'None')));
$fields->addFieldToTab('Root.Content.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'));
$this->extend('updateCMSFields', $fields);
@@ -49,15 +49,15 @@ class BlogHolder extends BlogTree implements PermissionProvider {
function blogOwners($sort = 'Name', $direction = "ASC") {
$adminMembers = Permission::get_members_by_permission('ADMIN');
$blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
-
- if(!$adminMembers) $adminMembers = new ArrayList();
- if(!$blogOwners) $blogOwners = new ArrayList();
-
+
+ if(!$adminMembers) $adminMembers = new DataObjectSet();
+ if(!$blogOwners) $blogOwners = new DataObjectSet();
+
$blogOwners->merge($adminMembers);
$blogOwners->sort($sort, $direction);
-
+
$this->extend('extendBlogOwners', $blogOwners);
-
+
return $blogOwners;
}
@@ -204,7 +204,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
$codeparser = new BBCodeParser();
- $membername = Member::currentUser() ? Member::currentUser()->getName() : "";
+ $membername = Member::currentMember() ? Member::currentMember()->getName() : "";
if(BlogEntry::$allow_wysiwyg_editing) {
$contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN"));
@@ -226,7 +226,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
if(!$this->AllowCustomAuthors && !Permission::check('ADMIN')) {
$field = 'ReadonlyField';
}
- $fields = new FieldList(
+ $fields = new FieldSet(
new HiddenField("ID", "ID"),
new TextField("Title", _t('BlogHolder.SJ', "Subject")),
new $field("Author", _t('BlogEntry.AU'), $membername),
@@ -237,7 +237,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
);
$submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry'));
- $actions = new FieldList($submitAction);
+ $actions = new FieldSet($submitAction);
$validator = new RequiredFields('Title','BlogPost');
$form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator);
@@ -246,7 +246,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
$entry = DataObject::get_by_id('BlogEntry', $id);
if($entry->IsOwner()) {
$form->loadDataFrom($entry);
- $form->Fields()->dataFieldByName('BlogPost')->setValue($entry->Content);
+ $form->datafieldByName('BlogPost')->setValue($entry->Content);
}
} else {
$form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name")));
@@ -274,7 +274,7 @@ class BlogHolder_Controller extends BlogTree_Controller {
$form->saveInto($blogentry);
$blogentry->ParentID = $this->ID;
- $blogentry->Content = str_replace("\r\n", "\n", $form->Fields()->dataFieldByName('BlogPost')->dataValue());
+ $blogentry->Content = str_replace("\r\n", "\n", $form->datafieldByName('BlogPost')->dataValue());
if(Object::has_extension($this->ClassName, 'Translatable')) {
$blogentry->Locale = $this->Locale;
@@ -288,3 +288,5 @@ class BlogHolder_Controller extends BlogTree_Controller {
}
}
+
+?>
diff --git a/code/BlogTree.php b/code/BlogTree.php
index 9ba3dff..758d828 100644
--- a/code/BlogTree.php
+++ b/code/BlogTree.php
@@ -93,8 +93,8 @@ class BlogTree extends Page {
/* ----------- CMS CONTROL -------------- */
- function getCMSFields($params = null) {
- $fields = parent::getCMSFields($params);
+ function getCMSFields() {
+ $fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new TextField("Name", "Name of blog"));
$fields->addFieldToTab('Root.Content.Main', new DropdownField('LandingPageFreshness', 'When you first open the blog, how many entries should I show', array(
"" => "All entries",
@@ -344,4 +344,4 @@ class BlogTree_Controller extends Page_Controller {
return date("Y", mktime(0, 0, 0, date('m'), 1, $date));
}
}
-}
+}
\ No newline at end of file
diff --git a/code/TrackBackDecorator.php b/code/TrackBackDecorator.php
index 57a71a5..5356fd9 100644
--- a/code/TrackBackDecorator.php
+++ b/code/TrackBackDecorator.php
@@ -2,11 +2,11 @@
/**
* Add trackback (receive and send) feature blog entry
*/
-class TrackBackDecorator extends DataExtension {
+class TrackBackDecorator extends DataObjectDecorator {
static $trackback_server_class = 'TrackbackHTTPServer';
- function extraStatics($class = null, $extension = null) {
+ function extraStatics() {
return array(
'has_many' => array(
'TrackBackURLs' => 'TrackBackURL',
@@ -15,7 +15,7 @@ class TrackBackDecorator extends DataExtension {
);
}
- function updateCMSFields(FieldList $fields) {
+ function updateCMSFields($fields) {
// Trackback URL field
if($this->owner->TrackBacksEnabled()) {
$trackbackURLTable = new ComplexTableField(
diff --git a/code/widgets/ArchiveWidget.php b/code/widgets/ArchiveWidget.php
index 9dfb3f5..77b2c7b 100644
--- a/code/widgets/ArchiveWidget.php
+++ b/code/widgets/ArchiveWidget.php
@@ -28,8 +28,8 @@ class ArchiveWidget extends Widget {
static $description = 'Show a list of months or years in which there are blog posts, and provide links to them.';
- function getCMSFields($params = null) {
- $fields = parent::getCMSFields($params);
+ function getCMSFields() {
+ $fields = parent::getCMSFields();
$fields->merge(
new FieldSet(
diff --git a/code/widgets/RSSWidget.php b/code/widgets/RSSWidget.php
index 4640bbf..17f8bc9 100644
--- a/code/widgets/RSSWidget.php
+++ b/code/widgets/RSSWidget.php
@@ -39,8 +39,8 @@ class RSSWidget extends Widget {
}
}
- function getCMSFields($params = null) {
- $fields = parent::getCMSFields($params);
+ function getCMSFields() {
+ $fields = parent::getCMSFields();
$fields->merge(
new FieldSet(
diff --git a/code/widgets/TagCloudWidget.php b/code/widgets/TagCloudWidget.php
index 7d47a1c..ed1bbe0 100644
--- a/code/widgets/TagCloudWidget.php
+++ b/code/widgets/TagCloudWidget.php
@@ -26,9 +26,9 @@ class TagCloudWidget extends Widget {
static $popularities = array( 'not-popular', 'not-very-popular', 'somewhat-popular', 'popular', 'very-popular', 'ultra-popular' );
- function getCMSFields($params = null) {
- $fields = parent::getCMSFields($params);
-
+ function getCMSFields() {
+ $fields = parent::getCMSFields();
+
$fields->merge(
new FieldSet(
new TextField("Title", _t("TagCloudWidget.TILE", "Title")),
diff --git a/tests/BlogTrackbackTest.php b/tests/BlogTrackbackTest.php
index 4a3e53c..cf9550e 100644
--- a/tests/BlogTrackbackTest.php
+++ b/tests/BlogTrackbackTest.php
@@ -60,7 +60,7 @@ class BlogTrackbackTest extends SapphireTest {
$entry1 = $this->objFromFixture('BlogEntry', 'testpost');
$entry1->doPublish();
$this->assertEquals(2, $entry1->TrackBackURLs()->Count());
- $this->assertEquals(array('testGoodTrackbackURL' => 1), $entry1->TrackBackURLs()->map('URL', 'Pung')->toArray());
+ $this->assertEquals(array('testGoodTrackbackURL' => 1), $entry1->TrackBackURLs()->map('URL', 'Pung'));
$entry2 = $this->objFromFixture('BlogEntry', 'testpost2');
$entry2->doPublish();
@@ -123,4 +123,4 @@ class TestTrackbackHTTPServer extends TrackbackHTTPServer implements TestOnly {
Some error text
";
}
-}
+}
\ No newline at end of file