diff --git a/INSTALL.txt b/INSTALL.txt
new file mode 100644
index 000000000..ec9372e84
--- /dev/null
+++ b/INSTALL.txt
@@ -0,0 +1,18 @@
+*********************
+* Install Using Git *
+*********************
+
+To install all addons using git, cd into your top level Friendica directory and
+
+git clone https://github.com/friendica/friendica-addons.git addon
+
+This will clone the entire repository in a directory called addon. They can now be activated in the plugins section of your admin panel.
+
+********************
+* Install Manually *
+********************
+
+1. Download the archive (AddonName.tgz) containing the addon you want to install.
+2. Unzip the contents of the archive to your harddrive.
+3. Upload the extracted directory and all it's contents to /path/to/friendica/addon. You will need to create the addon directory if this is the first addon you have installed.
+4. Activate the addon in the plugins section of your admin panel.
diff --git a/altpager.tgz b/altpager.tgz
new file mode 100644
index 000000000..fbfd55949
Binary files /dev/null and b/altpager.tgz differ
diff --git a/altpager/altpager.php b/altpager/altpager.php
index 65f9c0d83..c6f537bd4 100755
--- a/altpager/altpager.php
+++ b/altpager/altpager.php
@@ -61,6 +61,10 @@ function altpager_settings(&$a,&$s) {
if(! local_user())
return;
+ $global = get_config("alt_pager", "global");
+ if($global == 1)
+ return;
+
/* Add our stylesheet to the page so we can make our settings look nice */
$a->page['htmlhead'] .= ' ' . "\r\n";
@@ -87,3 +91,19 @@ function altpager_settings(&$a,&$s) {
$s .= '
";
switch ($dbstatus) {
- case 1:
- $tables = dav_get_update_statements(1);
+ case 1: case 2:
+ $tables = dav_get_update_statements($dbstatus);
foreach ($tables as $t) $o .= escape_tags($t . ";\n\n");
break;
default:
diff --git a/dav/wdcal.css b/dav/friendica/wdcal.css
similarity index 100%
rename from dav/wdcal.css
rename to dav/friendica/wdcal.css
diff --git a/dav/sabre-vobject/.travis.yml b/dav/sabre-vobject/.travis.yml
new file mode 100644
index 000000000..aca128bc8
--- /dev/null
+++ b/dav/sabre-vobject/.travis.yml
@@ -0,0 +1,8 @@
+language: php
+php:
+ - 5.3
+ - 5.4
+
+script: phpunit --configuration tests/phpunit.xml
+
+before_script: composer install
diff --git a/dav/sabre-vobject/ChangeLog b/dav/sabre-vobject/ChangeLog
new file mode 100644
index 000000000..0f26abbbc
--- /dev/null
+++ b/dav/sabre-vobject/ChangeLog
@@ -0,0 +1,7 @@
+2.0.0-stable (2012-08-08)
+ * VObject is now a separate project from SabreDAV. See the SabreDAV
+ changelog for version information before 2.0.
+ * New: VObject library now uses PHP 5.3 namespaces.
+ * New: It's possible to specify lists of parameters when constructing
+ properties.
+ * New: made it easier to construct the FreeBusyGenerator.
diff --git a/dav/sabre-vobject/LICENSE b/dav/sabre-vobject/LICENSE
new file mode 100644
index 000000000..8e09aec68
--- /dev/null
+++ b/dav/sabre-vobject/LICENSE
@@ -0,0 +1,27 @@
+Copyright (C) 2007-2012 Rooftop Solutions.
+
+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 Sabre 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 COPYRIGHT OWNER 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.
diff --git a/dav/sabre-vobject/README.md b/dav/sabre-vobject/README.md
new file mode 100644
index 000000000..13107039f
--- /dev/null
+++ b/dav/sabre-vobject/README.md
@@ -0,0 +1,388 @@
+# SabreTooth VObject library
+
+[![Build Status](https://secure.travis-ci.org/evert/sabre-vobject.png?branch=master)](http://travis-ci.org/evert/sabre-vobject)
+
+The VObject library allows you to easily parse and manipulate [iCalendar](https://tools.ietf.org/html/rfc5545)
+and [vCard](https://tools.ietf.org/html/rfc6350) objects using PHP.
+The goal of the VObject library is to create a very complete library, with an easy to use API.
+
+This project is a spin-off from [SabreDAV](http://code.google.com/p/sabredav/), where it has
+been used for several years. The VObject library has 100% unittest coverage.
+
+# Installation
+
+VObject requires PHP 5.3, and should be installed using composer.
+The general composer instructions can be found on the [composer website](http://getcomposer.org/doc/00-intro.md composer website).
+
+After that, just declare the vobject dependency as follows:
+
+```
+"require" : {
+ "sabre/vobject" : "dev-master"
+}
+```
+
+Then, run `composer.phar update` and you should be good. As soon as the first release is out, you should switch `dev-master` to `2.0.*` though.
+
+# Usage
+
+## Parsing
+
+For our example, we will be using the following vcard:
+
+```
+BEGIN:VCARD
+VERSION:3.0
+PRODID:-//Sabre//Sabre VObject 2.0//EN
+N:Planck;Max;;;
+FN:Max Planck
+EMAIL;TYPE=WORK:mplanck@example.org
+item1.TEL;TYPE=CELL:(+49)3144435678
+item1.X-ABLabel:Private cell
+item2.TEL;TYPE=WORK:(+49)5554564744
+item2.X-ABLabel:Work
+END:VCARD
+```
+
+
+If we want to just print out Max' full name, you can just use property access:
+
+
+```php
+
+use Sabre\VObject;
+
+$card = VObject\Reader::read($data);
+echo $card->FN;
+
+```
+
+## Changing properties
+
+Creating properties is pretty similar. If we like to add his birthday, we just
+set the property:
+
+```php
+
+$card->BDAY = '1858-04-23';
+
+```
+
+Note that in the previous example, we're actually updating any existing BDAY that
+may already exist. If we want to add a new property, without overwriting the previous
+we can do this with the `add` method.
+
+```php
+
+$card->add('EMAIL','max@example.org');
+
+```
+
+## Parameters
+
+If we want to also specify that this is max' home email addresses, we can do this with
+a third parameter:
+
+```
+
+$card->add('EMAIL', 'max@example'org', array('type' => 'HOME'));
+
+```
+
+If we want to read out all the email addresses and their type, this would look something
+like this:
+
+```
+foreach($card->EMAIL as $email) {
+
+ echo $email['TYPE'], ' - ', $email;
+
+}
+```
+
+## Groups
+
+In our example, you can see that the TEL properties are prefixed. These are 'groups' and
+allow you to group multiple related properties together. The group can be any user-defined
+name.
+
+This particular example as generated by the OS X addressbook, which uses the `X-ABLabel`
+to allow the user to specify custom labels for properties. OS X addressbook uses groups
+to tie the label to the property.
+
+The VObject library simply ignores the group if you don't specify it, so this will work:
+
+```php
+
+foreach($card->TEL as $tel) {
+ echo $tel, "\n";
+}
+```
+
+But if you would like to target a specific group + property, this is possible too:
+
+```php
+
+echo $card->{'ITEM1.TEL'};
+
+```
+
+So if you would like to show all the phone numbers, along with their custom label, the
+following syntax is used:
+
+```
+foreach($card->TEL as $tel) {
+
+ echo $card->{$tel->group . '.X-ABLABEL'}, ": ";
+ echo $tel, "\n";
+
+}
+```
+
+## Serializing / Saving
+
+If you want to generate your updated VObject, you can simply call the serialize() method.
+
+```
+
+echo $card->serialize();
+
+```
+
+## Components
+
+iCalendar, unlike vCards always have sub-components. Where vCards are often just a flat
+list, iCalendar objects tend to have a tree-like structure. For the following paragraphs,
+we will use the following object as the example:
+
+```
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Sabre//Sabre VObject 2.0//EN
+BEGIN:VEVENT
+SUMMARY:Curiosity landing
+DTSTART:20120806T051439Z
+LOCATION:Mars
+END:VEVENT
+END:VCALENDAR
+```
+
+Since events, tasks and journals are always in a sub component, this is also how we
+access them.
+
+```php
+
+use Sabre\VObject;
+
+$calendar = VObject\Reader::read($data);
+echo $calendar->VEVENT->SUMMARY;
+
+```
+
+Adding components to a calendar is done with a factory method:
+
+```php
+
+$event = VObject\Component::create('VEVENT');
+$calendar->add($event);
+
+$event->SUMMARY = 'Curiosity launch';
+$event->DTSTART = '20111126T150202Z';
+$event->LOCATION = 'Cape Carnival';
+
+```
+
+By the way.. cloning also works as expected, as the entire structure is cloned along with it:
+
+```php
+
+$clonedEvent = clone $calendar->VEVENT[0];
+$calendar->add($clonedEvent);
+
+```
+
+## Date and time handling
+
+If you ever had to deal with iCalendar timezones, you know it can be complicated.
+The way timezones are specified is flawed, which is something I may write an essay about some
+day. VObject does its best to determine the correct timezone. Many standard formats
+have been tested and verified, and special code has been implemented for special-casing
+microsoft generated timezone information, and others.
+
+To get a real php `DateTime` object, you can request this as follows:
+
+```
+$event = $calendar->VEVENT;
+$start = $event->DTSTART->getDateTime();
+echo $start->format(\DateTime::W3C);
+```
+
+To set the property with a DateTime object, you can use the following syntax:
+
+```
+$dateTime = new \DateTime('2012-08-07 23:53:00', new DateTimeZone('Europe/Amsterdam'));
+$event->DTSTART->setDateTime($dateTime, VObject\Property\DateTime::DATE);
+```
+
+The second argument specifies the type of date you're setting. The following three
+options exist:
+
+1. `LOCAL` This is a floating time, with no timezone information. This basically specifies that the event happens in whatever the timezone's currently in. This would be encoded as `DTSTART;VALUE=DATE-TIME:20120807235300`
+2. `UTC` This specifies that the time should be encoded as a UTC time. This is encoded as `DTSTART;VALUE=DATE-TIME:20120807205300Z`. Note the extra Z and the fact that it's two hours 'earlier'.
+3. `LOCALTZ` specifies that it's supposed to be encoded in its local timezone. For example `DTSTART;VALUE=DATE-TIME;TZID=Europe/Amsterdam:20120807235300`.
+4. `DATE` This is a date-only, and does not contain the time. In this case this would be encoded as `DTSTART;VALUE=DATE:20120807`.
+
+A few important notes:
+
+* When a `TZID` is specified, there should also be a matching `VTIMEZONE` object with all the timezone information. VObject cannot currently automatically embed this. However, in reality other clients seem to do fine without this information. Yet, for completeness, this will be added in the future.
+* As mentioned, the timezone-determination process may sometimes fail. Report any issues you find, and I'll be quick to add workarounds!
+
+## Recurrence rules
+
+Recurrence rules allow events to recur, for example for a weekly meeting, or an anniversary.
+This is done with the `RRULE` property. The `RRULE` property allows for a LOT of different
+rules. VObject only implements the ones that actually appear in calendar software.
+
+To read more about `RRULE` and all the options, check out [RFC5545](https://tools.ietf.org/html/rfc5545#section-3.8.5).
+VObject supports the following options:
+
+1. `UNTIL` for an end date.
+2. `INTERVAL` for for example "every 2 days".
+3. `COUNT` to stop recurring after x items.
+4. `FREQ=DAILY` to recur every day, and `BYDAY` to limit it to certain days.
+5. `FREQ=WEEKLY` to recur every week, `BYDAY` to expand this to multiple weekdays in every week and `WKST` to specify on which day the week starts.
+6. `FREQ=MONTHLY` to recur every month, `BYMONTHDAY` to expand this to certain days in a month, `BYDAY` to expand it to certain weekdays occuring in a month, and `BYSETPOS` to limit the last two expansions.
+7. `FREQ=YEARLY` to recur every year, `BYMONTH` to expand that to certain months in a year, and `BYDAY` and `BYWEEKDAY` to expand the `BYMONTH` rule even further.
+
+VObject supports the `EXDATE` property for exclusions, but not yet the `RDATE` and `EXRULE`
+properties. If you're interested in this, please file a github issue, as this will put it
+on my radar.
+
+This is a bit of a complex subject to go in excruciating detail. The
+[RFC](https://tools.ietf.org/html/rfc5545#section-3.8.5) has a lot of examples though.
+
+The hard part is not to write the RRULE, it is to expand them. The most complex and
+hard-to-read code is hidden in this component. Dragons be here.
+
+So, if we have a meeting every 2nd monday of the month, this would be specified as such:
+
+```
+BEGIN:VCALENDAR
+ VERSION:2.0
+ BEGIN:VEVENT
+ UID:1102c450-e0d7-11e1-9b23-0800200c9a66
+ DTSTART:20120109T140000Z
+ RRULE:FREQ=MONTHLY;BYDAY=MO;BYSETPOS=2
+ END:VEVENT
+END:VCALENDAR
+```
+
+Note that normally it's not allowed to indent the object like this, but it does make
+it easier to read. This is also the first time I added in a UID, which is required
+for all VEVENT, VTODO and VJOURNAL objects!
+
+To figure out all the meetings for this year, we can use the following syntax:
+
+```php
+use Sabre\VObject;
+
+$calendar = VObject\Reader::read($data);
+$calendar->expand(new DateTime('2012-01-01'), new DateTime('2012-12-31'));
+```
+
+What the expand method does, is look at its inner events, and expand the recurring
+rule. Our calendar now contains 12 events. The first will have its RRULE stripped,
+and every subsequent VEVENT has the correct meeting date and a `RECURRENCE-ID` set.
+
+This results in something like this:
+
+```
+BEGIN:VCALENDAR
+ VERSION:2.0
+ BEGIN:VEVENT
+ UID:1102c450-e0d7-11e1-9b23-0800200c9a66
+ DTSTART:20120109T140000Z
+ END:VEVENT
+ BEGIN:VEVENT
+ UID:1102c450-e0d7-11e1-9b23-0800200c9a66
+ RECURRENCE-ID:20120213T140000Z
+ DTSTART:20120213T140000Z
+ END:VEVENT
+ BEGIN:VEVENT
+ UID:1102c450-e0d7-11e1-9b23-0800200c9a66
+ RECURRENCE-ID:20120312T140000Z
+ DTSTART:20120312T140000Z
+ END:VEVENT
+ ..etc..
+END:VCALENDAR
+```
+
+To show the list of dates, we would do this as such:
+
+```
+foreach($calendar->VEVENT as $event) {
+ echo $event->DTSTART->getDateTime()->format(\DateTime::ATOM);
+}
+```
+
+In a recurring event, single instances can also be overriden. VObject also takes these
+into consideration. The reason we needed to specify a start and end-date, is because
+some recurrence rules can be 'never ending'.
+
+You should make sure you pick a sane date-range. Because if you pick a 50 year
+time-range, for a daily recurring event; this would result in over 18K objects.
+
+# Free-busy report generation
+
+Some calendaring software can make use of FREEBUSY reports to show when people are
+available.
+
+You can automatically generate these reports from calendars using the `FreeBusyGenerator`.
+
+Example based on our last event:
+
+```
+
+// We're giving it the calendar object. It's also possible to specify multiple objects,
+// by setting them as an array.
+//
+// We must also specify a start and end date, because recurring events are expanded.
+$fbGenerator = new VObject\FreeBusyGenerator(
+ new DateTime('2012-01-01'),
+ new DateTime('2012-12-31'),
+ $calendar
+);
+
+// Grabbing the report
+$freebusy = $fbGenerator->result();
+
+// The freebusy report is another VCALENDAR object, so we can serialize it as usual:
+echo $freebusy->serialize();
+```
+
+The output of this script will look like this:
+
+```
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Sabre//Sabre VObject 2.0//EN
+CALSCALE:GREGORIAN
+BEGIN:VFREEBUSY
+DTSTART;VALUE=DATE-TIME:20111231T230000Z
+DTEND;VALUE=DATE-TIME:20111231T230000Z
+DTSTAMP;VALUE=DATE-TIME:20120808T131628Z
+FREEBUSY;FBTYPE=BUSY:20120109T140000Z/20120109T140000Z
+FREEBUSY;FBTYPE=BUSY:20120213T140000Z/20120213T140000Z
+FREEBUSY;FBTYPE=BUSY:20120312T140000Z/20120312T140000Z
+FREEBUSY;FBTYPE=BUSY:20120409T140000Z/20120409T140000Z
+FREEBUSY;FBTYPE=BUSY:20120514T140000Z/20120514T140000Z
+FREEBUSY;FBTYPE=BUSY:20120611T140000Z/20120611T140000Z
+FREEBUSY;FBTYPE=BUSY:20120709T140000Z/20120709T140000Z
+FREEBUSY;FBTYPE=BUSY:20120813T140000Z/20120813T140000Z
+FREEBUSY;FBTYPE=BUSY:20120910T140000Z/20120910T140000Z
+FREEBUSY;FBTYPE=BUSY:20121008T140000Z/20121008T140000Z
+FREEBUSY;FBTYPE=BUSY:20121112T140000Z/20121112T140000Z
+FREEBUSY;FBTYPE=BUSY:20121210T140000Z/20121210T140000Z
+END:VFREEBUSY
+END:VCALENDAR
+```
diff --git a/dav/sabre-vobject/composer.json b/dav/sabre-vobject/composer.json
new file mode 100644
index 000000000..9ecdf4558
--- /dev/null
+++ b/dav/sabre-vobject/composer.json
@@ -0,0 +1,27 @@
+{
+ "name": "sabre/vobject",
+ "description" : "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects",
+ "keywords" : [ "VObject", "iCalendar", "vCard" ],
+ "homepage" : "https://github.com/evert/sabre-vobject",
+ "license" : "BSD-3-Clause",
+ "require" : {
+ "php" : ">=5.3.1"
+ },
+ "authors" : [
+ {
+ "name" : "Evert Pot",
+ "email" : "evert@rooftopsolutions.nl",
+ "homepage" : "http://www.rooftopsolutions.nl/",
+ "role" : "Developer"
+ }
+ ],
+ "support" : {
+ "forum" : "https://groups.google.com/group/sabredav-discuss",
+ "source" : "https://github.com/evert/sabre-vobject"
+ },
+ "autoload" : {
+ "psr-0" : {
+ "Sabre\\VObject" : "lib/"
+ }
+ }
+}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component.php b/dav/sabre-vobject/lib/Sabre/VObject/Component.php
similarity index 79%
rename from dav/SabreDAV/lib/Sabre/VObject/Component.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Component.php
index ced593848..d17cb895e 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Component.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Component.php
@@ -1,5 +1,7 @@
'Sabre_VObject_Component_VCalendar',
- 'VEVENT' => 'Sabre_VObject_Component_VEvent',
- 'VTODO' => 'Sabre_VObject_Component_VTodo',
- 'VJOURNAL' => 'Sabre_VObject_Component_VJournal',
- 'VALARM' => 'Sabre_VObject_Component_VAlarm',
+ 'VALARM' => 'Sabre\\VObject\\Component\\VAlarm',
+ 'VCALENDAR' => 'Sabre\\VObject\\Component\\VCalendar',
+ 'VCARD' => 'Sabre\\VObject\\Component\\VCard',
+ 'VEVENT' => 'Sabre\\VObject\\Component\\VEvent',
+ 'VJOURNAL' => 'Sabre\\VObject\\Component\\VJournal',
+ 'VTODO' => 'Sabre\\VObject\\Component\\VTodo',
);
/**
@@ -50,7 +56,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
*
* @param string $name
* @param string $value
- * @return Sabre_VObject_Component
+ * @return Component
*/
static public function create($name, $value = null) {
@@ -71,9 +77,9 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
* be overridden with the iterator argument
*
* @param string $name
- * @param Sabre_VObject_ElementList $iterator
+ * @param ElementList $iterator
*/
- public function __construct($name, Sabre_VObject_ElementList $iterator = null) {
+ public function __construct($name, ElementList $iterator = null) {
$this->name = strtoupper($name);
if (!is_null($iterator)) $this->iterator = $iterator;
@@ -100,12 +106,13 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
* preserve the original relative order of elements.
*
* @param int $key
- * @param Sabre_VObject $array
+ * @param array $array
* @return int
*/
$sortScore = function($key, $array) {
- if ($array[$key] instanceof Sabre_VObject_Component) {
+ if ($array[$key] instanceof Component) {
+
// We want to encode VTIMEZONE first, this is a personal
// preference.
if ($array[$key]->name === 'VTIMEZONE') {
@@ -118,7 +125,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
} else {
// Properties get encoded first
// VCARD version 4.0 wants the VERSION property to appear first
- if ($array[$key] instanceof Sabre_VObject_Property) {
+ if ($array[$key] instanceof Property) {
if ($array[$key]->name === 'VERSION') {
$score=100000000;
return $score+$key;
@@ -129,7 +136,6 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
}
}
}
- next($children);
};
@@ -157,8 +163,8 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
*
* You can call this method with the following syntaxes:
*
- * add(Sabre_VObject_Element $element)
- * add(string $name, $value)
+ * add(Element $element)
+ * add(string $name, $value, array $parameters = array())
*
* The first version adds an Element
* The second adds a property as a string.
@@ -167,26 +173,26 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
* @param mixed $itemValue
* @return void
*/
- public function add($item, $itemValue = null) {
+ public function add($item, $itemValue = null, array $parameters = array()) {
- if ($item instanceof Sabre_VObject_Element) {
+ if ($item instanceof Element) {
if (!is_null($itemValue)) {
- throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject');
+ throw new \InvalidArgumentException('The second argument must not be specified, when passing a VObject');
}
$item->parent = $this;
$this->children[] = $item;
} elseif(is_string($item)) {
if (!is_scalar($itemValue)) {
- throw new InvalidArgumentException('The second argument must be scalar');
+ throw new \InvalidArgumentException('The second argument must be scalar');
}
- $item = Sabre_VObject_Property::create($item,$itemValue);
+ $item = Property::create($item,$itemValue, $parameters);
$item->parent = $this;
$this->children[] = $item;
} else {
- throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string');
+ throw new \InvalidArgumentException('The first argument must either be a \\Sabre\\VObject\\Element or a string');
}
@@ -195,11 +201,11 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
/**
* Returns an iterable list of children
*
- * @return Sabre_VObject_ElementList
+ * @return ElementList
*/
public function children() {
- return new Sabre_VObject_ElementList($this->children);
+ return new ElementList($this->children);
}
@@ -232,7 +238,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
if (
strtoupper($child->name) === $name &&
- (is_null($group) || ( $child instanceof Sabre_VObject_Property && strtoupper($child->group) === $group))
+ (is_null($group) || ( $child instanceof Property && strtoupper($child->group) === $group))
) {
$result[$key] = $child;
@@ -255,7 +261,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
$result = array();
foreach($this->children as $child) {
- if ($child instanceof Sabre_VObject_Component) {
+ if ($child instanceof Component) {
$result[] = $child;
}
}
@@ -266,6 +272,11 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
/**
* Validates the node for correctness.
+ *
+ * The following options are supported:
+ * - Component::REPAIR - If something is broken, and automatic repair may
+ * be attempted.
+ *
* An array is returned with warnings.
*
* Every item in the array has the following properties:
@@ -273,9 +284,10 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
* * message - (human readable message)
* * node - (reference to the offending node)
*
+ * @param int $options
* @return array
*/
- public function validate() {
+ public function validate($options = 0) {
$result = array();
foreach($this->children as $child) {
@@ -294,7 +306,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
* null is returned.
*
* @param string $name
- * @return Sabre_VObject_Property
+ * @return Property
*/
public function __get($name) {
@@ -303,8 +315,8 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
return null;
} else {
$firstMatch = current($matches);
- /** @var $firstMatch Sabre_VObject_Property */
- $firstMatch->setIterator(new Sabre_VObject_ElementList(array_values($matches)));
+ /** @var $firstMatch Property */
+ $firstMatch->setIterator(new ElementList(array_values($matches)));
return $firstMatch;
}
@@ -326,7 +338,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
/**
* Using the setter method you can add properties or subcomponents
*
- * You can either pass a Sabre_VObject_Component, Sabre_VObject_Property
+ * You can either pass a Component, Property
* object, or a string to automatically create a Property.
*
* If the item already exists, it will be removed. If you want to add
@@ -341,7 +353,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
$matches = $this->select($name);
$overWrite = count($matches)?key($matches):null;
- if ($value instanceof Sabre_VObject_Component || $value instanceof Sabre_VObject_Property) {
+ if ($value instanceof Component || $value instanceof Property) {
$value->parent = $this;
if (!is_null($overWrite)) {
$this->children[$overWrite] = $value;
@@ -349,7 +361,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
$this->children[] = $value;
}
} elseif (is_scalar($value)) {
- $property = Sabre_VObject_Property::create($name,$value);
+ $property = Property::create($name,$value);
$property->parent = $this;
if (!is_null($overWrite)) {
$this->children[$overWrite] = $property;
@@ -357,7 +369,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
$this->children[] = $property;
}
} else {
- throw new InvalidArgumentException('You must pass a Sabre_VObject_Component, Sabre_VObject_Property or scalar type');
+ throw new \InvalidArgumentException('You must pass a \\Sabre\\VObject\\Component, \\Sabre\\VObject\\Property or scalar type');
}
}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VAlarm.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php
similarity index 79%
rename from dav/SabreDAV/lib/Sabre/VObject/Component/VAlarm.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php
index 1d1dd69d5..6bf7f5a2e 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Component/VAlarm.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php
@@ -1,17 +1,18 @@
TRIGGER;
if(!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') {
- $triggerDuration = Sabre_VObject_DateTimeParser::parseDuration($this->TRIGGER);
+ $triggerDuration = VObject\DateTimeParser::parseDuration($this->TRIGGER);
$related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START';
$parentComponent = $this->parent;
@@ -37,7 +38,7 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component {
} elseif ($parentComponent->name === 'VEVENT') {
$endProp = 'DTEND';
} else {
- throw new Sabre_DAV_Exception('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT');
+ throw new \LogicException('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT');
}
if (isset($parentComponent->$endProp)) {
@@ -45,7 +46,7 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component {
$effectiveTrigger->add($triggerDuration);
} elseif (isset($parentComponent->DURATION)) {
$effectiveTrigger = clone $parentComponent->DTSTART->getDateTime();
- $duration = Sabre_VObject_DateTimeParser::parseDuration($parentComponent->DURATION);
+ $duration = VObject\DateTimeParser::parseDuration($parentComponent->DURATION);
$effectiveTrigger->add($duration);
$effectiveTrigger->add($triggerDuration);
} else {
@@ -67,22 +68,22 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component {
* The rules used to determine if an event falls within the specified
* time-range is based on the CalDAV specification.
*
- * @param DateTime $start
- * @param DateTime $end
+ * @param \DateTime $start
+ * @param \DateTime $end
* @return bool
*/
- public function isInTimeRange(DateTime $start, DateTime $end) {
+ public function isInTimeRange(\DateTime $start, \DateTime $end) {
$effectiveTrigger = $this->getEffectiveTriggerTime();
if (isset($this->DURATION)) {
- $duration = Sabre_VObject_DateTimeParser::parseDuration($this->DURATION);
+ $duration = VObject\DateTimeParser::parseDuration($this->DURATION);
$repeat = (string)$this->repeat;
if (!$repeat) {
$repeat = 1;
}
- $period = new DatePeriod($effectiveTrigger, $duration, (int)$repeat);
+ $period = new \DatePeriod($effectiveTrigger, $duration, (int)$repeat);
foreach($period as $occurrence) {
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VCalendar.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php
similarity index 90%
rename from dav/SabreDAV/lib/Sabre/VObject/Component/VCalendar.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php
index 35dd90f23..73f2f6d34 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Component/VCalendar.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php
@@ -1,17 +1,19 @@
children as $component) {
- if (!$component instanceof Sabre_VObject_Component)
+ if (!$component instanceof VObject\Component)
continue;
if (isset($component->{'RECURRENCE-ID'}))
@@ -69,7 +71,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component {
* @param DateTime $end
* @return void
*/
- public function expand(DateTime $start, DateTime $end) {
+ public function expand(\DateTime $start, \DateTime $end) {
$newEvents = array();
@@ -91,10 +93,10 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component {
$uid = (string)$vevent->uid;
if (!$uid) {
- throw new LogicException('Event did not have a UID!');
+ throw new \LogicException('Event did not have a UID!');
}
- $it = new Sabre_VObject_RecurrenceIterator($this, $vevent->uid);
+ $it = new VObject\RecurrenceIterator($this, $vevent->uid);
$it->fastForward($start);
while($it->valid() && $it->getDTStart() < $end) {
@@ -114,9 +116,9 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component {
foreach($newEvents as $newEvent) {
foreach($newEvent->children as $child) {
- if ($child instanceof Sabre_VObject_Property_DateTime &&
- $child->getDateType() == Sabre_VObject_Property_DateTime::LOCALTZ) {
- $child->setDateTime($child->getDateTime(),Sabre_VObject_Property_DateTime::UTC);
+ if ($child instanceof VObject\Property\DateTime &&
+ $child->getDateType() == VObject\Property\DateTime::LOCALTZ) {
+ $child->setDateTime($child->getDateTime(),VObject\Property\DateTime::UTC);
}
}
@@ -140,6 +142,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component {
*
* @return array
*/
+ /*
public function validate() {
$warnings = array();
@@ -198,7 +201,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component {
);
$componentsFound = 0;
foreach($this->children as $child) {
- if($child instanceof Sabre_VObject_Component) {
+ if($child instanceof Component) {
$componentsFound++;
if (!in_array($child->name, $allowedComponents)) {
$warnings[] = array(
@@ -208,7 +211,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component {
);
}
}
- if ($child instanceof Sabre_VObject_Property) {
+ if ($child instanceof Property) {
if (!in_array($child->name, $allowedProperties)) {
$warnings[] = array(
'level' => 2,
@@ -233,6 +236,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component {
);
}
+ */
}
diff --git a/dav/sabre-vobject/lib/Sabre/VObject/Component/VCard.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCard.php
new file mode 100644
index 000000000..002c4db2b
--- /dev/null
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCard.php
@@ -0,0 +1,105 @@
+select('VERSION');
+ if (count($version)!==1) {
+ $warnings[] = array(
+ 'level' => 1,
+ 'message' => 'The VERSION property must appear in the VCARD component exactly 1 time',
+ 'node' => $this,
+ );
+ if ($options & self::REPAIR) {
+ $this->VERSION = self::DEFAULT_VERSION;
+ }
+ } else {
+ $version = (string)$this->VERSION;
+ if ($version!=='2.1' && $version!=='3.0' && $version!=='4.0') {
+ $warnings[] = array(
+ 'level' => 1,
+ 'message' => 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.',
+ 'node' => $this,
+ );
+ if ($options & self::REPAIR) {
+ $this->VERSION = '4.0';
+ }
+ }
+
+ }
+ $version = $this->select('FN');
+ if (count($version)!==1) {
+ $warnings[] = array(
+ 'level' => 1,
+ 'message' => 'The FN property must appear in the VCARD component exactly 1 time',
+ 'node' => $this,
+ );
+ if (($options & self::REPAIR) && count($version) === 0) {
+ // We're going to try to see if we can use the contents of the
+ // N property.
+ if (isset($this->N)) {
+ $value = explode(';', (string)$this->N);
+ if (isset($value[1]) && $value[1]) {
+ $this->FN = $value[1] . ' ' . $value[0];
+ } else {
+ $this->FN = $value[0];
+ }
+
+ // Otherwise, the ORG property may work
+ } elseif (isset($this->ORG)) {
+ $this->FN = (string)$this->ORG;
+ }
+
+ }
+ }
+
+ return array_merge(
+ parent::validate($options),
+ $warnings
+ );
+
+ }
+
+}
+
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VEvent.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VEvent.php
similarity index 64%
rename from dav/SabreDAV/lib/Sabre/VObject/Component/VEvent.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VEvent.php
index 684f5f5a7..9d10966e2 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Component/VEvent.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VEvent.php
@@ -1,17 +1,18 @@
RRULE) {
- $it = new Sabre_VObject_RecurrenceIterator($this);
+ $it = new VObject\RecurrenceIterator($this);
$it->fastForward($start);
// We fast-forwarded to a spot where the end-time of the
@@ -42,18 +43,19 @@ class Sabre_VObject_Component_VEvent extends Sabre_VObject_Component {
$effectiveStart = $this->DTSTART->getDateTime();
if (isset($this->DTEND)) {
+
+ // The DTEND property is considered non inclusive. So for a 3 day
+ // event in july, dtstart and dtend would have to be July 1st and
+ // July 4th respectively.
+ //
+ // See:
+ // http://tools.ietf.org/html/rfc5545#page-54
$effectiveEnd = $this->DTEND->getDateTime();
- // If this was an all-day event, we should just increase the
- // end-date by 1. Otherwise the event will last until the second
- // the date changed, by increasing this by 1 day the event lasts
- // all of the last day as well.
- if ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) {
- $effectiveEnd->modify('+1 day');
- }
+
} elseif (isset($this->DURATION)) {
$effectiveEnd = clone $effectiveStart;
- $effectiveEnd->add( Sabre_VObject_DateTimeParser::parseDuration($this->DURATION) );
- } elseif ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) {
+ $effectiveEnd->add( VObject\DateTimeParser::parseDuration($this->DURATION) );
+ } elseif ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) {
$effectiveEnd = clone $effectiveStart;
$effectiveEnd->modify('+1 day');
} else {
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VJournal.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VJournal.php
similarity index 79%
rename from dav/SabreDAV/lib/Sabre/VObject/Component/VJournal.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VJournal.php
index 6d3949289..f104a1f66 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Component/VJournal.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VJournal.php
@@ -1,17 +1,19 @@
DTSTART)?$this->DTSTART->getDateTime():null;
if ($dtstart) {
$effectiveEnd = clone $dtstart;
- if ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) {
+ if ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) {
$effectiveEnd->modify('+1 day');
}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VTodo.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VTodo.php
similarity index 87%
rename from dav/SabreDAV/lib/Sabre/VObject/Component/VTodo.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VTodo.php
index 2fb6654ed..5f879aea4 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Component/VTodo.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VTodo.php
@@ -1,17 +1,19 @@
DTSTART)?$this->DTSTART->getDateTime():null;
- $duration = isset($this->DURATION)?Sabre_VObject_DateTimeParser::parseDuration($this->DURATION):null;
+ $duration = isset($this->DURATION)?VObject\DateTimeParser::parseDuration($this->DURATION):null;
$due = isset($this->DUE)?$this->DUE->getDateTime():null;
$completed = isset($this->COMPLETED)?$this->COMPLETED->getDateTime():null;
$created = isset($this->CREATED)?$this->CREATED->getDateTime():null;
diff --git a/dav/SabreDAV/lib/Sabre/VObject/DateTimeParser.php b/dav/sabre-vobject/lib/Sabre/VObject/DateTimeParser.php
similarity index 83%
rename from dav/SabreDAV/lib/Sabre/VObject/DateTimeParser.php
rename to dav/sabre-vobject/lib/Sabre/VObject/DateTimeParser.php
index 23a4bb699..0ef8460dd 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/DateTimeParser.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/DateTimeParser.php
@@ -1,18 +1,18 @@
setTimeZone(new DateTimeZone('UTC'));
+ $date->setTimeZone(new \DateTimeZone('UTC'));
return $date;
}
@@ -57,10 +57,10 @@ class Sabre_VObject_DateTimeParser {
$result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])$/',$date,$matches);
if (!$result) {
- throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar date value is incorrect: ' . $date);
+ throw new \LogicException('The supplied iCalendar date value is incorrect: ' . $date);
}
- $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new DateTimeZone('UTC'));
+ $date = new \DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new \DateTimeZone('UTC'));
return $date;
}
@@ -79,7 +79,7 @@ class Sabre_VObject_DateTimeParser {
$result = preg_match('/^(?P\+|-)?P((?P\d+)W)?((?P\d+)D)?(T((?P\d+)H)?((?P\d+)M)?((?P\d+)S)?)?$/', $duration, $matches);
if (!$result) {
- throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar duration value is incorrect: ' . $duration);
+ throw new \LogicException('The supplied iCalendar duration value is incorrect: ' . $duration);
}
if (!$asString) {
@@ -128,7 +128,7 @@ class Sabre_VObject_DateTimeParser {
if ($duration==='P') {
$duration = 'PT0S';
}
- $iv = new DateInterval($duration);
+ $iv = new \DateInterval($duration);
if ($invert) $iv->invert = true;
return $iv;
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Element.php b/dav/sabre-vobject/lib/Sabre/VObject/Element.php
similarity index 73%
rename from dav/SabreDAV/lib/Sabre/VObject/Element.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Element.php
index e20ff0b35..151ae76ad 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Element.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Element.php
@@ -1,15 +1,15 @@
vevent where there's multiple VEVENT objects.
*
- * @package Sabre
- * @subpackage VObject
* @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
* @author Evert Pot (http://www.rooftopsolutions.nl/)
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
*/
-class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess {
+class ElementList implements \Iterator, \Countable, \ArrayAccess {
/**
* Inner elements
@@ -44,7 +44,7 @@ class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess {
/**
* Returns current item in iteration
*
- * @return Sabre_VObject_Element
+ * @return Element
*/
public function current() {
@@ -149,7 +149,7 @@ class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess {
*/
public function offsetSet($offset,$value) {
- throw new LogicException('You can not add new objects to an ElementList');
+ throw new \LogicException('You can not add new objects to an ElementList');
}
@@ -163,7 +163,7 @@ class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess {
*/
public function offsetUnset($offset) {
- throw new LogicException('You can not remove objects from an ElementList');
+ throw new \LogicException('You can not remove objects from an ElementList');
}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/FreeBusyGenerator.php b/dav/sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php
similarity index 74%
rename from dav/SabreDAV/lib/Sabre/VObject/FreeBusyGenerator.php
rename to dav/sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php
index 1c96a64a0..bfb89b018 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/FreeBusyGenerator.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php
@@ -1,5 +1,7 @@
setTimeRange($start, $end);
+ }
+
+ if ($objects) {
+ $this->setObjects($objects);
+ }
+
+ }
+
/**
* Sets the VCALENDAR object.
*
@@ -54,10 +77,10 @@ class Sabre_VObject_FreeBusyGenerator {
*
* The VFREEBUSY object will be automatically added though.
*
- * @param Sabre_VObject_Component $vcalendar
+ * @param Component $vcalendar
* @return void
*/
- public function setBaseObject(Sabre_VObject_Component $vcalendar) {
+ public function setBaseObject(Component $vcalendar) {
$this->baseObject = $vcalendar;
@@ -66,22 +89,28 @@ class Sabre_VObject_FreeBusyGenerator {
/**
* Sets the input objects
*
- * Every object must either be a string or a Sabre_VObject_Component.
+ * You must either specify a valendar object as a strong, or as the parse
+ * Component.
+ * It's also possible to specify multiple objects as an array.
*
- * @param array $objects
+ * @param mixed $objects
* @return void
*/
- public function setObjects(array $objects) {
+ public function setObjects($objects) {
+
+ if (!is_array($objects)) {
+ $objects = array($objects);
+ }
$this->objects = array();
foreach($objects as $object) {
if (is_string($object)) {
- $this->objects[] = Sabre_VObject_Reader::read($object);
- } elseif ($object instanceof Sabre_VObject_Component) {
+ $this->objects[] = Reader::read($object);
+ } elseif ($object instanceof Component) {
$this->objects[] = $object;
} else {
- throw new InvalidArgumentException('You can only pass strings or Sabre_VObject_Component arguments to setObjects');
+ throw new \InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component arguments to setObjects');
}
}
@@ -97,7 +126,7 @@ class Sabre_VObject_FreeBusyGenerator {
* @param DateTime $end
* @return void
*/
- public function setTimeRange(DateTime $start = null, DateTime $end = null) {
+ public function setTimeRange(\DateTime $start = null, \DateTime $end = null) {
$this->start = $start;
$this->end = $end;
@@ -108,7 +137,7 @@ class Sabre_VObject_FreeBusyGenerator {
* Parses the input data and returns a correct VFREEBUSY object, wrapped in
* a VCALENDAR.
*
- * @return Sabre_VObject_Component
+ * @return Component
*/
public function getResult() {
@@ -140,7 +169,7 @@ class Sabre_VObject_FreeBusyGenerator {
if ($component->RRULE) {
- $iterator = new Sabre_VObject_RecurrenceIterator($object, (string)$component->uid);
+ $iterator = new RecurrenceIterator($object, (string)$component->uid);
if ($this->start) {
$iterator->fastForward($this->start);
}
@@ -172,10 +201,10 @@ class Sabre_VObject_FreeBusyGenerator {
if (isset($component->DTEND)) {
$endTime = $component->DTEND->getDateTime();
} elseif (isset($component->DURATION)) {
- $duration = Sabre_VObject_DateTimeParser::parseDuration((string)$component->DURATION);
+ $duration = DateTimeParser::parseDuration((string)$component->DURATION);
$endTime = clone $startTime;
$endTime->add($duration);
- } elseif ($component->DTSTART->getDateType() === Sabre_VObject_Property_DateTime::DATE) {
+ } elseif ($component->DTSTART->getDateType() === Property\DateTime::DATE) {
$endTime = clone $startTime;
$endTime->modify('+1 day');
} else {
@@ -212,14 +241,14 @@ class Sabre_VObject_FreeBusyGenerator {
$values = explode(',', $freebusy);
foreach($values as $value) {
list($startTime, $endTime) = explode('/', $value);
- $startTime = Sabre_VObject_DateTimeParser::parseDateTime($startTime);
+ $startTime = DateTimeParser::parseDateTime($startTime);
if (substr($endTime,0,1)==='P' || substr($endTime,0,2)==='-P') {
- $duration = Sabre_VObject_DateTimeParser::parseDuration($endTime);
+ $duration = DateTimeParser::parseDuration($endTime);
$endTime = clone $startTime;
$endTime->add($duration);
} else {
- $endTime = Sabre_VObject_DateTimeParser::parseDateTime($endTime);
+ $endTime = DateTimeParser::parseDateTime($endTime);
}
if($this->start && $this->start > $endTime) continue;
@@ -248,39 +277,35 @@ class Sabre_VObject_FreeBusyGenerator {
if ($this->baseObject) {
$calendar = $this->baseObject;
} else {
- $calendar = new Sabre_VObject_Component('VCALENDAR');
+ $calendar = new Component('VCALENDAR');
$calendar->version = '2.0';
- if (Sabre_DAV_Server::$exposeVersion) {
- $calendar->prodid = '-//SabreDAV//Sabre VObject ' . Sabre_VObject_Version::VERSION . '//EN';
- } else {
- $calendar->prodid = '-//SabreDAV//Sabre VObject//EN';
- }
+ $calendar->prodid = '-//Sabre//Sabre VObject ' . Version::VERSION . '//EN';
$calendar->calscale = 'GREGORIAN';
}
- $vfreebusy = new Sabre_VObject_Component('VFREEBUSY');
+ $vfreebusy = new Component('VFREEBUSY');
$calendar->add($vfreebusy);
if ($this->start) {
- $dtstart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtstart->setDateTime($this->start,Sabre_VObject_Property_DateTime::UTC);
+ $dtstart = new Property\DateTime('DTSTART');
+ $dtstart->setDateTime($this->start,Property\DateTime::UTC);
$vfreebusy->add($dtstart);
}
if ($this->end) {
- $dtend = new Sabre_VObject_Property_DateTime('DTEND');
- $dtend->setDateTime($this->start,Sabre_VObject_Property_DateTime::UTC);
+ $dtend = new Property\DateTime('DTEND');
+ $dtend->setDateTime($this->start,Property\DateTime::UTC);
$vfreebusy->add($dtend);
}
- $dtstamp = new Sabre_VObject_Property_DateTime('DTSTAMP');
- $dtstamp->setDateTime(new DateTime('now'), Sabre_VObject_Property_DateTime::UTC);
+ $dtstamp = new Property\DateTime('DTSTAMP');
+ $dtstamp->setDateTime(new \DateTime('now'), Property\DateTime::UTC);
$vfreebusy->add($dtstamp);
foreach($busyTimes as $busyTime) {
- $busyTime[0]->setTimeZone(new DateTimeZone('UTC'));
- $busyTime[1]->setTimeZone(new DateTimeZone('UTC'));
+ $busyTime[0]->setTimeZone(new \DateTimeZone('UTC'));
+ $busyTime[1]->setTimeZone(new \DateTimeZone('UTC'));
- $prop = new Sabre_VObject_Property(
+ $prop = new Property(
'FREEBUSY',
$busyTime[0]->format('Ymd\\THis\\Z') . '/' . $busyTime[1]->format('Ymd\\THis\\Z')
);
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Node.php b/dav/sabre-vobject/lib/Sabre/VObject/Node.php
similarity index 87%
rename from dav/SabreDAV/lib/Sabre/VObject/Node.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Node.php
index 6c8319f76..88d1d8c35 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Node.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Node.php
@@ -1,15 +1,15 @@
iterator))
return $this->iterator;
- return new Sabre_VObject_ElementList(array($this));
+ return new ElementList(array($this));
}
@@ -70,10 +70,10 @@ abstract class Sabre_VObject_Node implements IteratorAggregate, ArrayAccess, Cou
*
* Note that this is not actually part of the iterator interface
*
- * @param Sabre_VObject_ElementList $iterator
+ * @param ElementList $iterator
* @return void
*/
- public function setIterator(Sabre_VObject_ElementList $iterator) {
+ public function setIterator(ElementList $iterator) {
$this->iterator = $iterator;
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Parameter.php b/dav/sabre-vobject/lib/Sabre/VObject/Parameter.php
similarity index 93%
rename from dav/SabreDAV/lib/Sabre/VObject/Parameter.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Parameter.php
index 2e39af5f7..0355b0a0f 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Parameter.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Parameter.php
@@ -1,5 +1,7 @@
'Sabre_VObject_Property_DateTime',
- 'CREATED' => 'Sabre_VObject_Property_DateTime',
- 'DTEND' => 'Sabre_VObject_Property_DateTime',
- 'DTSTAMP' => 'Sabre_VObject_Property_DateTime',
- 'DTSTART' => 'Sabre_VObject_Property_DateTime',
- 'DUE' => 'Sabre_VObject_Property_DateTime',
- 'EXDATE' => 'Sabre_VObject_Property_MultiDateTime',
- 'LAST-MODIFIED' => 'Sabre_VObject_Property_DateTime',
- 'RECURRENCE-ID' => 'Sabre_VObject_Property_DateTime',
- 'TRIGGER' => 'Sabre_VObject_Property_DateTime',
+ 'COMPLETED' => 'Sabre\\VObject\\Property\\DateTime',
+ 'CREATED' => 'Sabre\\VObject\\Property\\DateTime',
+ 'DTEND' => 'Sabre\\VObject\\Property\\DateTime',
+ 'DTSTAMP' => 'Sabre\\VObject\\Property\\DateTime',
+ 'DTSTART' => 'Sabre\\VObject\\Property\\DateTime',
+ 'DUE' => 'Sabre\\VObject\\Property\\DateTime',
+ 'EXDATE' => 'Sabre\\VObject\\Property\\MultiDateTime',
+ 'LAST-MODIFIED' => 'Sabre\\VObject\\Property\\DateTime',
+ 'RECURRENCE-ID' => 'Sabre\\VObject\\Property\\DateTime',
+ 'TRIGGER' => 'Sabre\\VObject\\Property\\DateTime',
);
/**
* Creates the new property by name, but in addition will also see if
* there's a class mapped to the property name.
*
+ * Parameters can be specified with the optional third argument. Parameters
+ * must be a key->value map of the parameter name, and value. If the value
+ * is specified as an array, it is assumed that multiple parameters with
+ * the same name should be added.
+ *
* @param string $name
* @param string $value
- * @return Sabre_VObject_Property
+ * @param array $parameters
+ * @return Property
*/
- static public function create($name, $value = null) {
+ static public function create($name, $value = null, array $parameters = array()) {
$name = strtoupper($name);
$shortName = $name;
@@ -87,9 +93,9 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
}
if (isset(self::$classMap[$shortName])) {
- return new self::$classMap[$shortName]($name, $value);
+ return new self::$classMap[$shortName]($name, $value, $parameters);
} else {
- return new self($name, $value);
+ return new self($name, $value, $parameters);
}
}
@@ -97,14 +103,16 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
/**
* Creates a new property object
*
- * By default this object will iterate over its own children, but this can
- * be overridden with the iterator argument
+ * Parameters can be specified with the optional third argument. Parameters
+ * must be a key->value map of the parameter name, and value. If the value
+ * is specified as an array, it is assumed that multiple parameters with
+ * the same name should be added.
*
* @param string $name
* @param string $value
- * @param Sabre_VObject_ElementList $iterator
+ * @param array $parameters
*/
- public function __construct($name, $value = null, $iterator = null) {
+ public function __construct($name, $value = null, array $parameters = array()) {
$name = strtoupper($name);
$group = null;
@@ -113,13 +121,22 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
}
$this->name = $name;
$this->group = $group;
- if (!is_null($iterator)) $this->iterator = $iterator;
$this->setValue($value);
+ foreach($parameters as $paramName => $paramValues) {
+
+ if (!is_array($paramValues)) {
+ $paramValues = array($paramValues);
+ }
+
+ foreach($paramValues as $paramValue) {
+ $this->add($paramName, $paramValue);
+ }
+
+ }
+
}
-
-
/**
* Updates the internal value
*
@@ -180,7 +197,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
*
* You can call this method with the following syntaxes:
*
- * add(Sabre_VObject_Parameter $element)
+ * add(Parameter $element)
* add(string $name, $value)
*
* The first version adds an Parameter
@@ -192,24 +209,24 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
*/
public function add($item, $itemValue = null) {
- if ($item instanceof Sabre_VObject_Parameter) {
+ if ($item instanceof Parameter) {
if (!is_null($itemValue)) {
- throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject');
+ throw new \InvalidArgumentException('The second argument must not be specified, when passing a VObject');
}
$item->parent = $this;
$this->parameters[] = $item;
} elseif(is_string($item)) {
if (!is_scalar($itemValue) && !is_null($itemValue)) {
- throw new InvalidArgumentException('The second argument must be scalar');
+ throw new \InvalidArgumentException('The second argument must be scalar');
}
- $parameter = new Sabre_VObject_Parameter($item,$itemValue);
+ $parameter = new Parameter($item,$itemValue);
$parameter->parent = $this;
$this->parameters[] = $parameter;
} else {
- throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string');
+ throw new \InvalidArgumentException('The first argument must either be a Element or a string');
}
@@ -240,7 +257,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
* Returns a parameter, or parameter list.
*
* @param string $name
- * @return Sabre_VObject_Element
+ * @return Element
*/
public function offsetGet($name) {
@@ -258,7 +275,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
} elseif (count($result)===1) {
return $result[0];
} else {
- $result[0]->setIterator(new Sabre_VObject_ElementList($result));
+ $result[0]->setIterator(new ElementList($result));
return $result[0];
}
@@ -277,21 +294,21 @@ class Sabre_VObject_Property extends Sabre_VObject_Element {
if (is_scalar($value)) {
if (!is_string($name))
- throw new InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.');
+ throw new \InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.');
$this->offsetUnset($name);
- $parameter = new Sabre_VObject_Parameter($name, $value);
+ $parameter = new Parameter($name, $value);
$parameter->parent = $this;
$this->parameters[] = $parameter;
- } elseif ($value instanceof Sabre_VObject_Parameter) {
+ } elseif ($value instanceof Parameter) {
if (!is_null($name))
- throw new InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a Sabre_VObject_Parameter. Add using $array[]=$parameterObject.');
+ throw new \InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a \\Sabre\\VObject\\Parameter. Add using $array[]=$parameterObject.');
$value->parent = $this;
$this->parameters[] = $value;
} else {
- throw new InvalidArgumentException('You can only add parameters to the property object');
+ throw new \InvalidArgumentException('You can only add parameters to the property object');
}
}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Property/DateTime.php b/dav/sabre-vobject/lib/Sabre/VObject/Property/DateTime.php
similarity index 79%
rename from dav/SabreDAV/lib/Sabre/VObject/Property/DateTime.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Property/DateTime.php
index ff2c867a3..556cd441d 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Property/DateTime.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Property/DateTime.php
@@ -1,5 +1,9 @@
offsetSet('VALUE','DATE-TIME');
break;
case self::UTC :
- $dt->setTimeZone(new DateTimeZone('UTC'));
+ $dt->setTimeZone(new \DateTimeZone('UTC'));
$this->setValue($dt->format('Ymd\\THis\\Z'));
$this->offsetUnset('VALUE');
$this->offsetUnset('TZID');
@@ -93,7 +95,7 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property {
$this->offsetSet('VALUE','DATE');
break;
default :
- throw new InvalidArgumentException('You must pass a valid dateType constant');
+ throw new \InvalidArgumentException('You must pass a valid dateType constant');
}
$this->dateTime = $dt;
@@ -106,7 +108,7 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property {
*
* If no value was set, this method returns null.
*
- * @return DateTime|null
+ * @return \DateTime|null
*/
public function getDateTime() {
@@ -152,11 +154,11 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property {
*
* @param string|null $propertyValue The string to parse (yymmdd or
* ymmddThhmmss, etc..)
- * @param Sabre_VObject_Property|null $property The instance of the
+ * @param \Sabre\VObject\Property|null $property The instance of the
* property we're parsing.
* @return array
*/
- static public function parseData($propertyValue, Sabre_VObject_Property $property = null) {
+ static public function parseData($propertyValue, VObject\Property $property = null) {
if (is_null($propertyValue)) {
return array(null, null);
@@ -167,14 +169,14 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property {
$regex = "/^$date(T$time(?PZ)?)?$/";
if (!preg_match($regex, $propertyValue, $matches)) {
- throw new InvalidArgumentException($propertyValue . ' is not a valid DateTime or Date string');
+ throw new \InvalidArgumentException($propertyValue . ' is not a valid \DateTime or Date string');
}
if (!isset($matches['hour'])) {
// Date-only
return array(
self::DATE,
- new DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00'),
+ new \DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00', new \DateTimeZone('UTC')),
);
}
@@ -187,8 +189,8 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property {
$matches['second'];
if (isset($matches['isutc'])) {
- $dt = new DateTime($dateStr,new DateTimeZone('UTC'));
- $dt->setTimeZone(new DateTimeZone('UTC'));
+ $dt = new \DateTime($dateStr,new \DateTimeZone('UTC'));
+ $dt->setTimeZone(new \DateTimeZone('UTC'));
return array(
self::UTC,
$dt
@@ -198,9 +200,12 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property {
// Finding the timezone.
$tzid = $property['TZID'];
if (!$tzid) {
+ // This was a floating time string. This implies we use the
+ // timezone from date_default_timezone_set / date.timezone ini
+ // setting.
return array(
self::LOCAL,
- new DateTime($dateStr)
+ new \DateTime($dateStr)
);
}
@@ -210,12 +215,12 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property {
$root = $root->parent;
}
if ($root->name === 'VCALENDAR') {
- $tz = Sabre_VObject_TimeZoneUtil::getTimeZone((string)$tzid, $root);
+ $tz = VObject\TimeZoneUtil::getTimeZone((string)$tzid, $root);
} else {
- $tz = Sabre_VObject_TimeZoneUtil::getTimeZone((string)$tzid);
+ $tz = VObject\TimeZoneUtil::getTimeZone((string)$tzid);
}
- $dt = new DateTime($dateStr, $tz);
+ $dt = new \DateTime($dateStr, $tz);
$dt->setTimeZone($tz);
return array(
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Property/MultiDateTime.php b/dav/sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php
similarity index 80%
rename from dav/SabreDAV/lib/Sabre/VObject/Property/MultiDateTime.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php
index ae53ab6a6..629ef4a13 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Property/MultiDateTime.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php
@@ -1,5 +1,9 @@
offsetUnset('VALUE');
$this->offsetUnset('TZID');
switch($dateType) {
- case Sabre_VObject_Property_DateTime::LOCAL :
+ case DateTime::LOCAL :
$val = array();
foreach($dt as $i) {
$val[] = $i->format('Ymd\\THis');
@@ -62,16 +64,16 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property {
$this->setValue(implode(',',$val));
$this->offsetSet('VALUE','DATE-TIME');
break;
- case Sabre_VObject_Property_DateTime::UTC :
+ case DateTime::UTC :
$val = array();
foreach($dt as $i) {
- $i->setTimeZone(new DateTimeZone('UTC'));
+ $i->setTimeZone(new \DateTimeZone('UTC'));
$val[] = $i->format('Ymd\\THis\\Z');
}
$this->setValue(implode(',',$val));
$this->offsetSet('VALUE','DATE-TIME');
break;
- case Sabre_VObject_Property_DateTime::LOCALTZ :
+ case DateTime::LOCALTZ :
$val = array();
foreach($dt as $i) {
$val[] = $i->format('Ymd\\THis');
@@ -80,7 +82,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property {
$this->offsetSet('VALUE','DATE-TIME');
$this->offsetSet('TZID', $dt[0]->getTimeZone()->getName());
break;
- case Sabre_VObject_Property_DateTime::DATE :
+ case DateTime::DATE :
$val = array();
foreach($dt as $i) {
$val[] = $i->format('Ymd');
@@ -89,7 +91,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property {
$this->offsetSet('VALUE','DATE');
break;
default :
- throw new InvalidArgumentException('You must pass a valid dateType constant');
+ throw new \InvalidArgumentException('You must pass a valid dateType constant');
}
$this->dateTimes = $dt;
@@ -121,7 +123,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property {
list(
$type,
$dt
- ) = Sabre_VObject_Property_DateTime::parseData($val, $this);
+ ) = DateTime::parseData($val, $this);
$dts[] = $dt;
$this->dateType = $type;
}
@@ -154,7 +156,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property {
list(
$type,
$dt
- ) = Sabre_VObject_Property_DateTime::parseData($val, $this);
+ ) = DateTime::parseData($val, $this);
$dts[] = $dt;
$this->dateType = $type;
}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Reader.php b/dav/sabre-vobject/lib/Sabre/VObject/Reader.php
similarity index 83%
rename from dav/SabreDAV/lib/Sabre/VObject/Reader.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Reader.php
index eea73fa3d..8fed7e275 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Reader.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Reader.php
@@ -1,5 +1,7 @@
name) {
- throw new Sabre_VObject_ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"');
+ throw new ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"');
}
next($lines);
@@ -107,7 +107,7 @@ class Sabre_VObject_Reader {
$result = preg_match($regex,$line,$matches);
if (!$result) {
- throw new Sabre_VObject_ParseException('Invalid VObject, line ' . ($lineNr+1) . ' did not follow the icalendar/vcard format');
+ throw new ParseException('Invalid VObject, line ' . ($lineNr+1) . ' did not follow the icalendar/vcard format');
}
$propertyName = strtoupper($matches['name']);
@@ -119,7 +119,7 @@ class Sabre_VObject_Reader {
}
}, $matches['value']);
- $obj = Sabre_VObject_Property::create($propertyName, $propertyValue);
+ $obj = Property::create($propertyName, $propertyValue);
if ($matches['parameters']) {
@@ -137,7 +137,7 @@ class Sabre_VObject_Reader {
/**
* Reads a parameter list from a property
*
- * This method returns an array of Sabre_VObject_Parameter
+ * This method returns an array of Parameter
*
* @param string $parameters
* @return array
@@ -171,7 +171,7 @@ class Sabre_VObject_Reader {
}
}, $value);
- $params[] = new Sabre_VObject_Parameter($match['paramName'], $value);
+ $params[] = new Parameter($match['paramName'], $value);
}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/RecurrenceIterator.php b/dav/sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php
similarity index 96%
rename from dav/SabreDAV/lib/Sabre/VObject/RecurrenceIterator.php
rename to dav/sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php
index 7ccd2049b..374b16e83 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/RecurrenceIterator.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php
@@ -1,5 +1,7 @@
name === 'VCALENDAR') {
- throw new InvalidArgumentException('If you pass a VCALENDAR object, you must pass a uid argument as well');
+ throw new \InvalidArgumentException('If you pass a VCALENDAR object, you must pass a uid argument as well');
}
$components = array($vcal);
$uid = (string)$vcal->uid;
@@ -325,7 +325,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator {
}
}
if (!$this->baseEvent) {
- throw new InvalidArgumentException('Could not find a base event with uid: ' . $uid);
+ throw new \InvalidArgumentException('Could not find a base event with uid: ' . $uid);
}
$this->startDate = clone $this->baseEvent->DTSTART->getDateTime();
@@ -336,8 +336,8 @@ class Sabre_VObject_RecurrenceIterator implements Iterator {
} else {
$this->endDate = clone $this->startDate;
if (isset($this->baseEvent->DURATION)) {
- $this->endDate->add(Sabre_VObject_DateTimeParser::parse($this->baseEvent->DURATION->value));
- } elseif ($this->baseEvent->DTSTART->getDateType()===Sabre_VObject_Property_DateTime::DATE) {
+ $this->endDate->add(DateTimeParser::parse($this->baseEvent->DURATION->value));
+ } elseif ($this->baseEvent->DTSTART->getDateType()===Property\DateTime::DATE) {
$this->endDate->modify('+1 day');
}
}
@@ -362,14 +362,14 @@ class Sabre_VObject_RecurrenceIterator implements Iterator {
strtolower($value),
array('secondly','minutely','hourly','daily','weekly','monthly','yearly')
)) {
- throw new InvalidArgumentException('Unknown value for FREQ=' . strtoupper($value));
+ throw new \InvalidArgumentException('Unknown value for FREQ=' . strtoupper($value));
}
$this->frequency = strtolower($value);
break;
case 'UNTIL' :
- $this->until = Sabre_VObject_DateTimeParser::parse($value);
+ $this->until = DateTimeParser::parse($value);
break;
case 'COUNT' :
@@ -431,7 +431,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator {
foreach(explode(',', (string)$exDate) as $exceptionDate) {
$this->exceptionDates[] =
- Sabre_VObject_DateTimeParser::parse($exceptionDate, $this->startDate->getTimeZone());
+ DateTimeParser::parse($exceptionDate, $this->startDate->getTimeZone());
}
@@ -489,7 +489,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator {
*
* This method always returns a cloned instance.
*
- * @return Sabre_VObject_Component_VEvent
+ * @return Component\VEvent
*/
public function getEventObject() {
@@ -565,7 +565,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator {
* @param DateTime $dt
* @return void
*/
- public function fastForward(DateTime $dt) {
+ public function fastForward(\DateTime $dt) {
while($this->valid() && $this->getDTEnd() <= $dt) {
$this->next();
diff --git a/dav/SabreDAV/lib/Sabre/VObject/TimeZoneUtil.php b/dav/sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php
similarity index 96%
rename from dav/SabreDAV/lib/Sabre/VObject/TimeZoneUtil.php
rename to dav/sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php
index 276288aaa..8e01210b0 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/TimeZoneUtil.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php
@@ -1,18 +1,18 @@
{'X-LIC-LOCATION'})) {
try {
- return new DateTimeZone($vtimezone->{'X-LIC-LOCATION'});
+ return new \DateTimeZone($vtimezone->{'X-LIC-LOCATION'});
} catch (\Exception $e) {
}
@@ -332,7 +332,7 @@ class Sabre_VObject_TimeZoneUtil {
// answer for.
if (isset($vtimezone->{'X-MICROSOFT-CDO-TZID'})) {
if (isset(self::$microsoftExchangeMap[(int)$vtimezone->{'X-MICROSOFT-CDO-TZID'}->value])) {
- return new DateTimeZone(self::$microsoftExchangeMap[(int)$vtimezone->{'X-MICROSOFT-CDO-TZID'}->value]);
+ return new \DateTimeZone(self::$microsoftExchangeMap[(int)$vtimezone->{'X-MICROSOFT-CDO-TZID'}->value]);
}
}
}
@@ -342,7 +342,7 @@ class Sabre_VObject_TimeZoneUtil {
}
// If we got all the way here, we default to UTC.
- return new DateTimeZone(date_default_timezone_get());
+ return new \DateTimeZone(date_default_timezone_get());
}
diff --git a/dav/SabreDAV/lib/Sabre/VObject/Version.php b/dav/sabre-vobject/lib/Sabre/VObject/Version.php
similarity index 81%
rename from dav/SabreDAV/lib/Sabre/VObject/Version.php
rename to dav/sabre-vobject/lib/Sabre/VObject/Version.php
index 9ee03d871..a35c852e1 100644
--- a/dav/SabreDAV/lib/Sabre/VObject/Version.php
+++ b/dav/sabre-vobject/lib/Sabre/VObject/Version.php
@@ -1,20 +1,20 @@
assertEquals($outcome, $valarm->isInTimeRange($start, $end));
@@ -16,7 +21,7 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
$tests = array();
// Hard date and time
- $valarm1 = Sabre_VObject_Component::create('VALARM');
+ $valarm1 = Component::create('VALARM');
$valarm1->TRIGGER = '20120312T130000Z';
$valarm1->TRIGGER['VALUE'] = 'DATE-TIME';
@@ -24,11 +29,11 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
$tests[] = array($valarm1, new DateTime('2012-03-01 01:00:00'), new DateTime('2012-03-10 01:00:00'), false);
// Relation to start time of event
- $valarm2 = Sabre_VObject_Component::create('VALARM');
+ $valarm2 = Component::create('VALARM');
$valarm2->TRIGGER = '-P1D';
$valarm2->TRIGGER['VALUE'] = 'DURATION';
- $vevent2 = Sabre_VObject_Component::create('VEVENT');
+ $vevent2 = Component::create('VEVENT');
$vevent2->DTSTART = '20120313T130000Z';
$vevent2->add($valarm2);
@@ -36,12 +41,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
$tests[] = array($valarm2, new DateTime('2012-03-01 01:00:00'), new DateTime('2012-03-10 01:00:00'), false);
// Relation to end time of event
- $valarm3 = Sabre_VObject_Component::create('VALARM');
+ $valarm3 = Component::create('VALARM');
$valarm3->TRIGGER = '-P1D';
$valarm3->TRIGGER['VALUE'] = 'DURATION';
$valarm3->TRIGGER['RELATED']= 'END';
- $vevent3 = Sabre_VObject_Component::create('VEVENT');
+ $vevent3 = Component::create('VEVENT');
$vevent3->DTSTART = '20120301T130000Z';
$vevent3->DTEND = '20120401T130000Z';
$vevent3->add($valarm3);
@@ -50,12 +55,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
$tests[] = array($valarm3, new DateTime('2012-03-25 01:00:00'), new DateTime('2012-04-05 01:00:00'), true);
// Relation to end time of todo
- $valarm4 = Sabre_VObject_Component::create('VALARM');
+ $valarm4 = Component::create('VALARM');
$valarm4->TRIGGER = '-P1D';
$valarm4->TRIGGER['VALUE'] = 'DURATION';
$valarm4->TRIGGER['RELATED']= 'END';
- $vtodo4 = Sabre_VObject_Component::create('VTODO');
+ $vtodo4 = Component::create('VTODO');
$vtodo4->DTSTART = '20120301T130000Z';
$vtodo4->DUE = '20120401T130000Z';
$vtodo4->add($valarm4);
@@ -64,25 +69,25 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
$tests[] = array($valarm4, new DateTime('2012-03-25 01:00:00'), new DateTime('2012-04-05 01:00:00'), true);
// Relation to start time of event + repeat
- $valarm5 = Sabre_VObject_Component::create('VALARM');
+ $valarm5 = Component::create('VALARM');
$valarm5->TRIGGER = '-P1D';
$valarm5->TRIGGER['VALUE'] = 'DURATION';
$valarm5->REPEAT = 10;
$valarm5->DURATION = 'P1D';
- $vevent5 = Sabre_VObject_Component::create('VEVENT');
+ $vevent5 = Component::create('VEVENT');
$vevent5->DTSTART = '20120301T130000Z';
$vevent5->add($valarm5);
$tests[] = array($valarm5, new DateTime('2012-03-09 01:00:00'), new DateTime('2012-03-10 01:00:00'), true);
// Relation to start time of event + duration, but no repeat
- $valarm6 = Sabre_VObject_Component::create('VALARM');
+ $valarm6 = Component::create('VALARM');
$valarm6->TRIGGER = '-P1D';
$valarm6->TRIGGER['VALUE'] = 'DURATION';
$valarm6->DURATION = 'P1D';
- $vevent6 = Sabre_VObject_Component::create('VEVENT');
+ $vevent6 = Component::create('VEVENT');
$vevent6->DTSTART = '20120313T130000Z';
$vevent6->add($valarm6);
@@ -91,12 +96,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
// Relation to end time of event (DURATION instead of DTEND)
- $valarm7 = Sabre_VObject_Component::create('VALARM');
+ $valarm7 = Component::create('VALARM');
$valarm7->TRIGGER = '-P1D';
$valarm7->TRIGGER['VALUE'] = 'DURATION';
$valarm7->TRIGGER['RELATED']= 'END';
- $vevent7 = Sabre_VObject_Component::create('VEVENT');
+ $vevent7 = Component::create('VEVENT');
$vevent7->DTSTART = '20120301T130000Z';
$vevent7->DURATION = 'P30D';
$vevent7->add($valarm7);
@@ -105,12 +110,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
$tests[] = array($valarm7, new DateTime('2012-03-25 01:00:00'), new DateTime('2012-04-05 01:00:00'), true);
// Relation to end time of event (No DTEND or DURATION)
- $valarm7 = Sabre_VObject_Component::create('VALARM');
+ $valarm7 = Component::create('VALARM');
$valarm7->TRIGGER = '-P1D';
$valarm7->TRIGGER['VALUE'] = 'DURATION';
$valarm7->TRIGGER['RELATED']= 'END';
- $vevent7 = Sabre_VObject_Component::create('VEVENT');
+ $vevent7 = Component::create('VEVENT');
$vevent7->DTSTART = '20120301T130000Z';
$vevent7->add($valarm7);
@@ -122,15 +127,15 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase {
}
/**
- * @expectedException Sabre_DAV_Exception
+ * @expectedException LogicException
*/
public function testInTimeRangeInvalidComponent() {
- $valarm = Sabre_VObject_Component::create('VALARM');
+ $valarm = Component::create('VALARM');
$valarm->TRIGGER = '-P1D';
$valarm->TRIGGER['RELATED'] = 'END';
- $vjournal = Sabre_VObject_Component::create('VJOURNAL');
+ $vjournal = Component::create('VJOURNAL');
$vjournal->add($valarm);
$valarm->isInTimeRange(new DateTime('2012-02-25 01:00:00'), new DateTime('2012-03-05 01:00:00'));
diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VCalendarTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCalendarTest.php
similarity index 90%
rename from dav/SabreDAV/tests/Sabre/VObject/Component/VCalendarTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/Component/VCalendarTest.php
index b1b503b4d..1d7e0c603 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/Component/VCalendarTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCalendarTest.php
@@ -1,20 +1,24 @@
expand(
- new DateTime('2011-12-01'),
- new DateTime('2011-12-31')
+ new \DateTime('2011-12-01'),
+ new \DateTime('2011-12-31')
);
// This will normalize the output
- $output = Sabre_VObject_Reader::read($output)->serialize();
+ $output = VObject\Reader::read($output)->serialize();
$this->assertEquals($output, $vcal->serialize());
@@ -229,10 +233,10 @@ DTSTART;VALUE=DATE:20111202
END:VEVENT
END:VCALENDAR
';
- $vcal = Sabre_VObject_Reader::read($input);
+ $vcal = VObject\Reader::read($input);
$vcal->expand(
- new DateTime('2011-12-01'),
- new DateTime('2011-12-31')
+ new \DateTime('2011-12-01'),
+ new \DateTime('2011-12-31')
);
}
diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php
new file mode 100644
index 000000000..584a007d9
--- /dev/null
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php
@@ -0,0 +1,100 @@
+validate();
+
+ $warnMsg = array();
+ foreach($warnings as $warning) {
+ $warnMsg[] = $warning['message'];
+ }
+
+ $this->assertEquals($expectedWarnings, $warnMsg);
+
+ $vcard->validate(VObject\Component::REPAIR);
+
+ $this->assertEquals(
+ $expectedRepairedOutput,
+ $vcard->serialize()
+ );
+
+ }
+
+ public function validateData() {
+
+ $tests = array();
+
+ // Correct
+ $tests[] = array(
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
+ array(),
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
+ );
+
+ // No VERSION
+ $tests[] = array(
+ "BEGIN:VCARD\r\nFN:John Doe\r\nEND:VCARD\r\n",
+ array(
+ 'The VERSION property must appear in the VCARD component exactly 1 time',
+ ),
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
+ );
+
+ // Unknown version
+ $tests[] = array(
+ "BEGIN:VCARD\r\nVERSION:2.2\r\nFN:John Doe\r\nEND:VCARD\r\n",
+ array(
+ 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.',
+ ),
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n",
+ );
+
+ // No FN
+ $tests[] = array(
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n",
+ array(
+ 'The FN property must appear in the VCARD component exactly 1 time',
+ ),
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n",
+ );
+ // No FN, N fallback
+ $tests[] = array(
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nEND:VCARD\r\n",
+ array(
+ 'The FN property must appear in the VCARD component exactly 1 time',
+ ),
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nFN:John Doe\r\nEND:VCARD\r\n",
+ );
+ // No FN, N fallback, no first name
+ $tests[] = array(
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nEND:VCARD\r\n",
+ array(
+ 'The FN property must appear in the VCARD component exactly 1 time',
+ ),
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nFN:Doe\r\nEND:VCARD\r\n",
+ );
+
+ // No FN, ORG fallback
+ $tests[] = array(
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nORG:Acme Co.\r\nEND:VCARD\r\n",
+ array(
+ 'The FN property must appear in the VCARD component exactly 1 time',
+ ),
+ "BEGIN:VCARD\r\nVERSION:4.0\r\nORG:Acme Co.\r\nFN:Acme Co.\r\nEND:VCARD\r\n",
+ );
+ return $tests;
+
+ }
+
+}
diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VEventTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VEventTest.php
new file mode 100644
index 000000000..616da4ac7
--- /dev/null
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VEventTest.php
@@ -0,0 +1,74 @@
+assertEquals($outcome, $vevent->isInTimeRange($start, $end));
+
+ }
+
+ public function timeRangeTestData() {
+
+ $tests = array();
+
+ $vevent = new VEvent('VEVENT');
+ $vevent->DTSTART = '20111223T120000Z';
+ $tests[] = array($vevent, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vevent, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vevent2 = clone $vevent;
+ $vevent2->DTEND = '20111225T120000Z';
+ $tests[] = array($vevent2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vevent2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vevent3 = clone $vevent;
+ $vevent3->DURATION = 'P1D';
+ $tests[] = array($vevent3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vevent3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vevent4 = clone $vevent;
+ $vevent4->DTSTART = '20111225';
+ $vevent4->DTSTART['VALUE'] = 'DATE';
+ $tests[] = array($vevent4, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vevent4, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+ // Event with no end date should be treated as lasting the entire day.
+ $tests[] = array($vevent4, new \DateTime('2011-12-25 16:00:00'), new \DateTime('2011-12-25 17:00:00'), true);
+
+
+ $vevent5 = clone $vevent;
+ $vevent5->DURATION = 'P1D';
+ $vevent5->RRULE = 'FREQ=YEARLY';
+ $tests[] = array($vevent5, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vevent5, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+ $tests[] = array($vevent5, new \DateTime('2013-12-01'), new \DateTime('2013-12-31'), true);
+
+ $vevent6 = clone $vevent;
+ $vevent6->DTSTART = '20111225';
+ $vevent6->DTSTART['VALUE'] = 'DATE';
+ $vevent6->DTEND = '20111225';
+ $vevent6->DTEND['VALUE'] = 'DATE';
+
+ $tests[] = array($vevent6, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vevent6, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ // Added this test to ensure that recurrence rules with no DTEND also
+ // get checked for the entire day.
+ $vevent7 = clone $vevent;
+ $vevent7->DTSTART = '20120101';
+ $vevent7->DTSTART['VALUE'] = 'DATE';
+ $vevent7->RRULE = 'FREQ=MONTHLY';
+ $tests[] = array($vevent7, new \DateTime('2012-02-01 15:00:00'), new \DateTime('2012-02-02'), true);
+ return $tests;
+
+ }
+
+}
+
diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VJournalTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VJournalTest.php
new file mode 100644
index 000000000..46ecb992b
--- /dev/null
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VJournalTest.php
@@ -0,0 +1,41 @@
+assertEquals($outcome, $vtodo->isInTimeRange($start, $end));
+
+ }
+
+ public function timeRangeTestData() {
+
+ $tests = array();
+
+ $vjournal = Component::create('VJOURNAL');
+ $vjournal->DTSTART = '20111223T120000Z';
+ $tests[] = array($vjournal, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vjournal, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vjournal2 = Component::create('VJOURNAL');
+ $vjournal2->DTSTART = '20111223';
+ $vjournal2->DTSTART['VALUE'] = 'DATE';
+ $tests[] = array($vjournal2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vjournal2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vjournal3 = Component::create('VJOURNAL');
+ $tests[] = array($vjournal3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), false);
+ $tests[] = array($vjournal3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ return $tests;
+ }
+
+}
+
diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VTodoTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VTodoTest.php
new file mode 100644
index 000000000..a84da5cdf
--- /dev/null
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VTodoTest.php
@@ -0,0 +1,67 @@
+assertEquals($outcome, $vtodo->isInTimeRange($start, $end));
+
+ }
+
+ public function timeRangeTestData() {
+
+ $tests = array();
+
+ $vtodo = Component::create('VTODO');
+ $vtodo->DTSTART = '20111223T120000Z';
+ $tests[] = array($vtodo, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vtodo2 = clone $vtodo;
+ $vtodo2->DURATION = 'P1D';
+ $tests[] = array($vtodo2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vtodo3 = clone $vtodo;
+ $vtodo3->DUE = '20111225';
+ $tests[] = array($vtodo3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vtodo4 = Component::create('VTODO');
+ $vtodo4->DUE = '20111225';
+ $tests[] = array($vtodo4, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo4, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vtodo5 = Component::create('VTODO');
+ $vtodo5->COMPLETED = '20111225';
+ $tests[] = array($vtodo5, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo5, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vtodo6 = Component::create('VTODO');
+ $vtodo6->CREATED = '20111225';
+ $tests[] = array($vtodo6, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo6, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vtodo7 = Component::create('VTODO');
+ $vtodo7->CREATED = '20111225';
+ $vtodo7->COMPLETED = '20111226';
+ $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
+
+ $vtodo7 = Component::create('VTODO');
+ $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
+ $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), true);
+
+ return $tests;
+
+ }
+
+}
+
diff --git a/dav/SabreDAV/tests/Sabre/VObject/ComponentTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ComponentTest.php
similarity index 65%
rename from dav/SabreDAV/tests/Sabre/VObject/ComponentTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/ComponentTest.php
index 42f836dbd..07000bda0 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/ComponentTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/ComponentTest.php
@@ -1,22 +1,24 @@
children[] = $sub;
- $sub = new Sabre_VObject_Component('VTODO');
+ $sub = new Component('VTODO');
$comp->children[] = $sub;
$count = 0;
foreach($comp->children() as $key=>$subcomponent) {
$count++;
- $this->assertInstanceOf('Sabre_VObject_Component',$subcomponent);
+ $this->assertInstanceOf('Sabre\\VObject\\Component',$subcomponent);
}
$this->assertEquals(2,$count);
@@ -26,16 +28,16 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testMagicGet() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
- $sub = new Sabre_VObject_Component('VEVENT');
+ $sub = new Component('VEVENT');
$comp->children[] = $sub;
- $sub = new Sabre_VObject_Component('VTODO');
+ $sub = new Component('VTODO');
$comp->children[] = $sub;
$event = $comp->vevent;
- $this->assertInstanceOf('Sabre_VObject_Component', $event);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $event);
$this->assertEquals('VEVENT', $event->name);
$this->assertInternalType('null', $comp->vjournal);
@@ -44,15 +46,15 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testMagicGetGroups() {
- $comp = new Sabre_VObject_Component('VCARD');
+ $comp = new Component('VCARD');
- $sub = new Sabre_VObject_Property('GROUP1.EMAIL','1@1.com');
+ $sub = new Property('GROUP1.EMAIL','1@1.com');
$comp->children[] = $sub;
- $sub = new Sabre_VObject_Property('GROUP2.EMAIL','2@2.com');
+ $sub = new Property('GROUP2.EMAIL','2@2.com');
$comp->children[] = $sub;
- $sub = new Sabre_VObject_Property('EMAIL','3@3.com');
+ $sub = new Property('EMAIL','3@3.com');
$comp->children[] = $sub;
$emails = $comp->email;
@@ -70,12 +72,12 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testMagicIsset() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
- $sub = new Sabre_VObject_Component('VEVENT');
+ $sub = new Component('VEVENT');
$comp->children[] = $sub;
- $sub = new Sabre_VObject_Component('VTODO');
+ $sub = new Component('VTODO');
$comp->children[] = $sub;
$this->assertTrue(isset($comp->vevent));
@@ -86,10 +88,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testMagicSetScalar() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$comp->myProp = 'myValue';
- $this->assertInstanceOf('Sabre_VObject_Property',$comp->MYPROP);
+ $this->assertInstanceOf('Sabre\\VObject\\Property',$comp->MYPROP);
$this->assertEquals('myValue',$comp->MYPROP->value);
@@ -97,22 +99,22 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testMagicSetScalarTwice() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$comp->myProp = 'myValue';
$comp->myProp = 'myValue';
$this->assertEquals(1,count($comp->children));
- $this->assertInstanceOf('Sabre_VObject_Property',$comp->MYPROP);
+ $this->assertInstanceOf('Sabre\\VObject\\Property',$comp->MYPROP);
$this->assertEquals('myValue',$comp->MYPROP->value);
}
function testMagicSetComponent() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
// Note that 'myProp' is ignored here.
- $comp->myProp = new Sabre_VObject_Component('VEVENT');
+ $comp->myProp = new Component('VEVENT');
$this->assertEquals(1, count($comp->children));
@@ -122,10 +124,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testMagicSetTwice() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
- $comp->VEVENT = new Sabre_VObject_Component('VEVENT');
- $comp->VEVENT = new Sabre_VObject_Component('VEVENT');
+ $comp->VEVENT = new Component('VEVENT');
+ $comp->VEVENT = new Component('VEVENT');
$this->assertEquals(1, count($comp->children));
@@ -135,9 +137,9 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testArrayAccessGet() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
- $event = new Sabre_VObject_Component('VEVENT');
+ $event = new Component('VEVENT');
$event->summary = 'Event 1';
$comp->add($event);
@@ -148,16 +150,16 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
$comp->add($event2);
$this->assertEquals(2,count($comp->children()));
- $this->assertTrue($comp->vevent[1] instanceof Sabre_VObject_Component);
+ $this->assertTrue($comp->vevent[1] instanceof Component);
$this->assertEquals('Event 2', (string)$comp->vevent[1]->summary);
}
function testArrayAccessExists() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
- $event = new Sabre_VObject_Component('VEVENT');
+ $event = new Component('VEVENT');
$event->summary = 'Event 1';
$comp->add($event);
@@ -177,7 +179,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
*/
function testArrayAccessSet() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$comp['hey'] = 'hi there';
}
@@ -186,30 +188,51 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
*/
function testArrayAccessUnset() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
unset($comp[0]);
}
function testAddScalar() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$comp->add('myprop','value');
$this->assertEquals(1, count($comp->children));
- $this->assertTrue($comp->children[0] instanceof Sabre_VObject_Property);
+ $this->assertTrue($comp->children[0] instanceof Property);
$this->assertEquals('MYPROP',$comp->children[0]->name);
$this->assertEquals('value',$comp->children[0]->value);
}
+ function testAddScalarParams() {
+
+ $comp = Component::create('VCALENDAR');
+
+ $comp->add('myprop','value',array('param1'=>'value1'));
+
+ $this->assertEquals(1, count($comp->children));
+
+ $this->assertTrue($comp->children[0] instanceof Property);
+ $this->assertEquals('MYPROP',$comp->children[0]->name);
+ $this->assertEquals('value',$comp->children[0]->value);
+
+ $this->assertEquals(1, count($comp->children[0]->parameters));
+
+ $this->assertTrue($comp->children[0]->parameters[0] instanceof Parameter);
+ $this->assertEquals('PARAM1',$comp->children[0]->parameters[0]->name);
+ $this->assertEquals('value1',$comp->children[0]->parameters[0]->value);
+
+ }
+
+
function testAddComponent() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
- $comp->add(new Sabre_VObject_Component('VEVENT'));
+ $comp->add(new Component('VEVENT'));
$this->assertEquals(1, count($comp->children));
@@ -219,10 +242,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testAddComponentTwice() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
- $comp->add(new Sabre_VObject_Component('VEVENT'));
- $comp->add(new Sabre_VObject_Component('VEVENT'));
+ $comp->add(new Component('VEVENT'));
+ $comp->add(new Component('VEVENT'));
$this->assertEquals(2, count($comp->children));
@@ -235,8 +258,8 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
*/
function testAddArgFail() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
- $comp->add(new Sabre_VObject_Component('VEVENT'),'hello');
+ $comp = new Component('VCALENDAR');
+ $comp->add(new Component('VEVENT'),'hello');
}
@@ -245,7 +268,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
*/
function testAddArgFail2() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$comp->add(array());
}
@@ -255,7 +278,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
*/
function testAddArgFail3() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$comp->add('hello',array());
}
@@ -265,10 +288,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
*/
function testMagicSetInvalid() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
// Note that 'myProp' is ignored here.
- $comp->myProp = new StdClass();
+ $comp->myProp = new \StdClass();
$this->assertEquals(1, count($comp->children));
@@ -278,8 +301,8 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testMagicUnset() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
- $comp->add(new Sabre_VObject_Component('VEVENT'));
+ $comp = new Component('VCALENDAR');
+ $comp->add(new Component('VEVENT'));
unset($comp->vevent);
@@ -290,34 +313,34 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testCount() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$this->assertEquals(1,$comp->count());
}
function testChildren() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
// Note that 'myProp' is ignored here.
$comp->children = array(
- new Sabre_VObject_Component('VEVENT'),
- new Sabre_VObject_Component('VTODO')
+ new Component('VEVENT'),
+ new Component('VTODO')
);
$r = $comp->children();
- $this->assertTrue($r instanceof Sabre_VObject_ElementList);
+ $this->assertTrue($r instanceof ElementList);
$this->assertEquals(2,count($r));
}
function testGetComponents() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
// Note that 'myProp' is ignored here.
$comp->children = array(
- new Sabre_VObject_Property('FOO','BAR'),
- new Sabre_VObject_Component('VTODO')
+ new Property('FOO','BAR'),
+ new Component('VTODO')
);
$r = $comp->getComponents();
@@ -328,17 +351,17 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testSerialize() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$this->assertEquals("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", $comp->serialize());
}
function testSerializeChildren() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
+ $comp = new Component('VCALENDAR');
$comp->children = array(
- new Sabre_VObject_Component('VEVENT'),
- new Sabre_VObject_Component('VTODO')
+ new Component('VEVENT'),
+ new Component('VTODO')
);
$str = $comp->serialize();
@@ -349,11 +372,11 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
function testSerializeOrderCompAndProp() {
- $comp = new Sabre_VObject_Component('VCALENDAR');
- $comp->add(new Sabre_VObject_Component('VEVENT'));
+ $comp = new Component('VCALENDAR');
+ $comp->add(new Component('VEVENT'));
$comp->add('PROP1','BLABLA');
$comp->add('VERSION','2.0');
- $comp->add(new Sabre_VObject_Component('VTIMEZONE'));
+ $comp->add(new Component('VTIMEZONE'));
$str = $comp->serialize();
@@ -365,7 +388,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase {
$prop4s=array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10');
- $comp = new Sabre_VObject_Component('VCARD');
+ $comp = new Component('VCARD');
$comp->__set('SOMEPROP','FOO');
$comp->__set('ANOTHERPROP','FOO');
$comp->__set('THIRDPROP','FOO');
diff --git a/dav/sabre-vobject/tests/Sabre/VObject/DateTimeParserTest.php b/dav/sabre-vobject/tests/Sabre/VObject/DateTimeParserTest.php
new file mode 100644
index 000000000..463e7bcc2
--- /dev/null
+++ b/dav/sabre-vobject/tests/Sabre/VObject/DateTimeParserTest.php
@@ -0,0 +1,121 @@
+assertEquals('+1 weeks', DateTimeParser::parseDuration('P1W',true));
+ $this->assertEquals('+5 days', DateTimeParser::parseDuration('P5D',true));
+ $this->assertEquals('+5 days 3 hours 50 minutes 12 seconds', DateTimeParser::parseDuration('P5DT3H50M12S',true));
+ $this->assertEquals('-1 weeks 50 minutes', DateTimeParser::parseDuration('-P1WT50M',true));
+ $this->assertEquals('+50 days 3 hours 2 seconds', DateTimeParser::parseDuration('+P50DT3H2S',true));
+ $this->assertEquals(new DateInterval('PT0S'), DateTimeParser::parseDuration('PT0S'));
+
+ }
+
+ function testParseICalendarDurationDateInterval() {
+
+ $expected = new DateInterval('P7D');
+ $this->assertEquals($expected, DateTimeParser::parseDuration('P1W'));
+ $this->assertEquals($expected, DateTimeParser::parse('P1W'));
+
+ $expected = new DateInterval('PT3M');
+ $expected->invert = true;
+ $this->assertEquals($expected, DateTimeParser::parseDuration('-PT3M'));
+
+ }
+
+ /**
+ * @expectedException LogicException
+ */
+ function testParseICalendarDurationFail() {
+
+ DateTimeParser::parseDuration('P1X',true);
+
+ }
+
+ function testParseICalendarDateTime() {
+
+ $dateTime = DateTimeParser::parseDateTime('20100316T141405');
+
+ $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC'));
+
+ $this->assertEquals($compare, $dateTime);
+
+ }
+
+ /**
+ * @depends testParseICalendarDateTime
+ * @expectedException LogicException
+ */
+ function testParseICalendarDateTimeBadFormat() {
+
+ $dateTime = DateTimeParser::parseDateTime('20100316T141405 ');
+
+ }
+
+ /**
+ * @depends testParseICalendarDateTime
+ */
+ function testParseICalendarDateTimeUTC() {
+
+ $dateTime = DateTimeParser::parseDateTime('20100316T141405Z');
+
+ $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC'));
+ $this->assertEquals($compare, $dateTime);
+
+ }
+
+ /**
+ * @depends testParseICalendarDateTime
+ */
+ function testParseICalendarDateTimeUTC2() {
+
+ $dateTime = DateTimeParser::parseDateTime('20101211T160000Z');
+
+ $compare = new DateTime('2010-12-11 16:00:00',new DateTimeZone('UTC'));
+ $this->assertEquals($compare, $dateTime);
+
+ }
+
+ /**
+ * @depends testParseICalendarDateTime
+ */
+ function testParseICalendarDateTimeCustomTimeZone() {
+
+ $dateTime = DateTimeParser::parseDateTime('20100316T141405', new DateTimeZone('Europe/Amsterdam'));
+
+ $compare = new DateTime('2010-03-16 13:14:05',new DateTimeZone('UTC'));
+ $this->assertEquals($compare, $dateTime);
+
+ }
+
+ function testParseICalendarDate() {
+
+ $dateTime = DateTimeParser::parseDate('20100316');
+
+ $expected = new DateTime('2010-03-16 00:00:00',new DateTimeZone('UTC'));
+
+ $this->assertEquals($expected, $dateTime);
+
+ $dateTime = DateTimeParser::parse('20100316');
+ $this->assertEquals($expected, $dateTime);
+
+ }
+
+ /**
+ * @depends testParseICalendarDate
+ * @expectedException LogicException
+ */
+ function testParseICalendarDateBadFormat() {
+
+ $dateTime = DateTimeParser::parseDate('20100316T141405');
+
+ }
+}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/ElementListTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ElementListTest.php
similarity index 55%
rename from dav/SabreDAV/tests/Sabre/VObject/ElementListTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/ElementListTest.php
index 5bc8b43c5..84e1bcbe9 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/ElementListTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/ElementListTest.php
@@ -1,10 +1,12 @@
$subcomponent) {
$count++;
- $this->assertInstanceOf('Sabre_VObject_Component',$subcomponent);
+ $this->assertInstanceOf('Sabre\\VObject\\Component',$subcomponent);
}
$this->assertEquals(3,$count);
diff --git a/dav/SabreDAV/tests/Sabre/VObject/EmClientTest.php b/dav/sabre-vobject/tests/Sabre/VObject/EmClientTest.php
similarity index 81%
rename from dav/SabreDAV/tests/Sabre/VObject/EmClientTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/EmClientTest.php
index 69330230f..69d410fe7 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/EmClientTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/EmClientTest.php
@@ -1,6 +1,8 @@
VEVENT->DTSTART->getDateTime();
- $this->assertEquals(new DateTime('2011-10-08 19:30:00', new DateTimeZone('America/Chicago')), $dt);
+ $this->assertEquals(new \DateTime('2011-10-08 19:30:00', new \DateTimeZone('America/Chicago')), $dt);
}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/FreeBusyGeneratorTest.php b/dav/sabre-vobject/tests/Sabre/VObject/FreeBusyGeneratorTest.php
similarity index 81%
rename from dav/SabreDAV/tests/Sabre/VObject/FreeBusyGeneratorTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/FreeBusyGeneratorTest.php
index d84f5a489..1f79e0a47 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/FreeBusyGeneratorTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/FreeBusyGeneratorTest.php
@@ -1,6 +1,8 @@
setObjects($this->getInput());
- $gen->setTimeRange(
- new DateTime('20110101T110000Z'),
- new DateTime('20110103T110000Z')
+ $gen = new FreeBusyGenerator(
+ new \DateTime('20110101T110000Z', new \DateTimeZone('UTC')),
+ new \DateTime('20110103T110000Z', new \DateTimeZone('UTC')),
+ $this->getInput()
);
$result = $gen->getResult();
@@ -216,10 +217,10 @@ ICS;
function testGeneratorBaseObject() {
- $obj = new Sabre_VObject_Component('VCALENDAR');
+ $obj = new Component('VCALENDAR');
$obj->METHOD = 'PUBLISH';
- $gen = new Sabre_VObject_FreeBusyGenerator();
+ $gen = new FreeBusyGenerator();
$gen->setObjects(array());
$gen->setBaseObject($obj);
@@ -227,20 +228,6 @@ ICS;
$this->assertEquals('PUBLISH', $result->METHOD->value);
- }
- function testGeneratorNoVersion() {
-
- $v = Sabre_DAV_Server::$exposeVersion;
- Sabre_DAV_Server::$exposeVersion = false;
-
- $gen = new Sabre_VObject_FreeBusyGenerator();
- $gen->setObjects(array());
-
- $result = $gen->getResult();
- Sabre_DAV_Server::$exposeVersion = $v;
-
- $this->assertFalse(strpos($result->PRODID->value, Sabre_VObject_Version::VERSION));
-
}
/**
@@ -248,8 +235,11 @@ ICS;
*/
function testInvalidArg() {
- $gen = new Sabre_VObject_FreeBusyGenerator();
- $gen->setObjects(array(new StdClass()));
+ $gen = new FreeBusyGenerator(
+ new \DateTime('2012-01-01'),
+ new \DateTime('2012-12-31'),
+ new \StdClass()
+ );
}
diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Issue153Test.php b/dav/sabre-vobject/tests/Sabre/VObject/Issue153Test.php
new file mode 100644
index 000000000..1cc14c161
--- /dev/null
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Issue153Test.php
@@ -0,0 +1,14 @@
+assertEquals('Test Benutzer', (string)$obj->fn);
+
+ }
+
+}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/Issue154Test.php b/dav/sabre-vobject/tests/Sabre/VObject/Issue154Test.php
similarity index 81%
rename from dav/SabreDAV/tests/Sabre/VObject/Issue154Test.php
rename to dav/sabre-vobject/tests/Sabre/VObject/Issue154Test.php
index f5136be12..ed9c7c3f4 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/Issue154Test.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Issue154Test.php
@@ -1,10 +1,12 @@
VERSION = '3.0';
$vcard->PHOTO = base64_encode('random_stuff');
$vcard->PHOTO->add('BASE64',null);
diff --git a/dav/SabreDAV/tests/Sabre/VObject/ParameterTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ParameterTest.php
similarity index 60%
rename from dav/SabreDAV/tests/Sabre/VObject/ParameterTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/ParameterTest.php
index ea3099718..150830459 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/ParameterTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/ParameterTest.php
@@ -1,10 +1,12 @@
assertEquals('NAME',$param->name);
$this->assertEquals('value',$param->value);
@@ -12,7 +14,7 @@ class Sabre_VObject_ParameterTest extends PHPUnit_Framework_TestCase {
function testCastToString() {
- $param = new Sabre_VObject_Parameter('name','value');
+ $param = new Parameter('name','value');
$this->assertEquals('value',$param->__toString());
$this->assertEquals('value',(string)$param);
diff --git a/dav/SabreDAV/tests/Sabre/VObject/Property/DateTimeTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Property/DateTimeTest.php
similarity index 58%
rename from dav/SabreDAV/tests/Sabre/VObject/Property/DateTimeTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/Property/DateTimeTest.php
index d6a9830d3..9dc7e8610 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/Property/DateTimeTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Property/DateTimeTest.php
@@ -1,14 +1,17 @@
setTimeZone($tz);
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
+ $elem = new DateTime('DTSTART');
$elem->setDateTime($dt);
$this->assertEquals('19850704T013000', $elem->value);
@@ -19,12 +22,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
function testSetDateTimeLOCAL() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt = new DateTime('1985-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt = new \DateTime('1985-07-04 01:30:00', $tz);
$dt->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
- $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::LOCAL);
+ $elem = new DateTime('DTSTART');
+ $elem->setDateTime($dt, DateTime::LOCAL);
$this->assertEquals('19850704T013000', $elem->value);
$this->assertNull($elem['TZID']);
@@ -34,12 +37,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
function testSetDateTimeUTC() {
- $tz = new DateTimeZone('GMT');
- $dt = new DateTime('1985-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('GMT');
+ $dt = new \DateTime('1985-07-04 01:30:00', $tz);
$dt->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
- $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::UTC);
+ $elem = new DateTime('DTSTART');
+ $elem->setDateTime($dt, DateTime::UTC);
$this->assertEquals('19850704T013000Z', $elem->value);
$this->assertNull($elem['TZID']);
@@ -49,12 +52,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
function testSetDateTimeLOCALTZ() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt = new DateTime('1985-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt = new \DateTime('1985-07-04 01:30:00', $tz);
$dt->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
- $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::LOCALTZ);
+ $elem = new DateTime('DTSTART');
+ $elem->setDateTime($dt, DateTime::LOCALTZ);
$this->assertEquals('19850704T013000', $elem->value);
$this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']);
@@ -64,12 +67,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
function testSetDateTimeDATE() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt = new DateTime('1985-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt = new \DateTime('1985-07-04 01:30:00', $tz);
$dt->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
- $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::DATE);
+ $elem = new DateTime('DTSTART');
+ $elem->setDateTime($dt, DateTime::DATE);
$this->assertEquals('19850704', $elem->value);
$this->assertNull($elem['TZID']);
@@ -82,22 +85,22 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
*/
function testSetDateTimeInvalid() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt = new DateTime('1985-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt = new \DateTime('1985-07-04 01:30:00', $tz);
$dt->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
+ $elem = new DateTime('DTSTART');
$elem->setDateTime($dt, 7);
}
function testGetDateTimeCached() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt = new DateTime('1985-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt = new \DateTime('1985-07-04 01:30:00', $tz);
$dt->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
+ $elem = new DateTime('DTSTART');
$elem->setDateTime($dt);
$this->assertEquals($elem->getDateTime(), $dt);
@@ -106,7 +109,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
function testGetDateTimeDateNULL() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART');
+ $elem = new DateTime('DTSTART');
$dt = $elem->getDateTime();
$this->assertNull($dt);
@@ -116,42 +119,42 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
function testGetDateTimeDateDATE() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704');
+ $elem = new DateTime('DTSTART','19850704');
$dt = $elem->getDateTime();
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 00:00:00', $dt->format('Y-m-d H:i:s'));
- $this->assertEquals(Sabre_VObject_Property_DateTime::DATE, $elem->getDateType());
+ $this->assertEquals(DateTime::DATE, $elem->getDateType());
}
function testGetDateTimeDateLOCAL() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000');
+ $elem = new DateTime('DTSTART','19850704T013000');
$dt = $elem->getDateTime();
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
- $this->assertEquals(Sabre_VObject_Property_DateTime::LOCAL, $elem->getDateType());
+ $this->assertEquals(DateTime::LOCAL, $elem->getDateType());
}
function testGetDateTimeDateUTC() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000Z');
+ $elem = new DateTime('DTSTART','19850704T013000Z');
$dt = $elem->getDateTime();
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
$this->assertEquals('UTC', $dt->getTimeZone()->getName());
- $this->assertEquals(Sabre_VObject_Property_DateTime::UTC, $elem->getDateType());
+ $this->assertEquals(DateTime::UTC, $elem->getDateType());
}
function testGetDateTimeDateLOCALTZ() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000');
+ $elem = new DateTime('DTSTART','19850704T013000');
$elem['TZID'] = 'Europe/Amsterdam';
$dt = $elem->getDateTime();
@@ -159,7 +162,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
$this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName());
- $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType());
+ $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType());
}
@@ -168,25 +171,25 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
*/
function testGetDateTimeDateInvalid() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','bla');
+ $elem = new DateTime('DTSTART','bla');
$dt = $elem->getDateTime();
}
function testGetDateTimeWeirdTZ() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000');
+ $elem = new DateTime('DTSTART','19850704T013000');
$elem['TZID'] = '/freeassociation.sourceforge.net/Tzfile/Europe/Amsterdam';
- $event = new Sabre_VObject_Component('VEVENT');
+ $event = new Component('VEVENT');
$event->add($elem);
- $timezone = new Sabre_VObject_Component('VTIMEZONE');
+ $timezone = new Component('VTIMEZONE');
$timezone->TZID = '/freeassociation.sourceforge.net/Tzfile/Europe/Amsterdam';
$timezone->{'X-LIC-LOCATION'} = 'Europe/Amsterdam';
- $calendar = new Sabre_VObject_Component('VCALENDAR');
+ $calendar = new Component('VCALENDAR');
$calendar->add($event);
$calendar->add($timezone);
@@ -195,7 +198,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
$this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName());
- $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType());
+ $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType());
}
@@ -204,18 +207,18 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
$default = date_default_timezone_get();
date_default_timezone_set('Canada/Eastern');
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000');
+ $elem = new DateTime('DTSTART','19850704T013000');
$elem['TZID'] = 'Moon';
- $event = new Sabre_VObject_Component('VEVENT');
+ $event = new Component('VEVENT');
$event->add($elem);
- $timezone = new Sabre_VObject_Component('VTIMEZONE');
+ $timezone = new Component('VTIMEZONE');
$timezone->TZID = 'Moon';
$timezone->{'X-LIC-LOCATION'} = 'Moon';
- $calendar = new Sabre_VObject_Component('VCALENDAR');
+ $calendar = new Component('VCALENDAR');
$calendar->add($event);
$calendar->add($timezone);
@@ -224,7 +227,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase {
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
$this->assertEquals('Canada/Eastern', $dt->getTimeZone()->getName());
- $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType());
+ $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType());
date_default_timezone_set($default);
}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/Property/MultiDateTimeTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Property/MultiDateTimeTest.php
similarity index 55%
rename from dav/SabreDAV/tests/Sabre/VObject/Property/MultiDateTimeTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/Property/MultiDateTimeTest.php
index 4d70ed3d7..eae3e2bb2 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/Property/MultiDateTimeTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/Property/MultiDateTimeTest.php
@@ -1,16 +1,18 @@
setTimeZone($tz);
$dt2->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
+ $elem = new MultiDateTime('DTSTART');
$elem->setDateTimes(array($dt1,$dt2));
$this->assertEquals('19850704T013000,19860704T013000', $elem->value);
@@ -21,14 +23,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
function testSetDateTimeLOCAL() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt1 = new DateTime('1985-07-04 01:30:00', $tz);
- $dt2 = new DateTime('1986-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt1 = new \DateTime('1985-07-04 01:30:00', $tz);
+ $dt2 = new \DateTime('1986-07-04 01:30:00', $tz);
$dt1->setTimeZone($tz);
$dt2->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
- $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::LOCAL);
+ $elem = new MultiDateTime('DTSTART');
+ $elem->setDateTimes(array($dt1,$dt2), DateTime::LOCAL);
$this->assertEquals('19850704T013000,19860704T013000', $elem->value);
$this->assertNull($elem['TZID']);
@@ -38,14 +40,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
function testSetDateTimeUTC() {
- $tz = new DateTimeZone('GMT');
- $dt1 = new DateTime('1985-07-04 01:30:00', $tz);
- $dt2 = new DateTime('1986-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('GMT');
+ $dt1 = new \DateTime('1985-07-04 01:30:00', $tz);
+ $dt2 = new \DateTime('1986-07-04 01:30:00', $tz);
$dt1->setTimeZone($tz);
$dt2->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
- $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::UTC);
+ $elem = new MultiDateTime('DTSTART');
+ $elem->setDateTimes(array($dt1,$dt2), DateTime::UTC);
$this->assertEquals('19850704T013000Z,19860704T013000Z', $elem->value);
$this->assertNull($elem['TZID']);
@@ -55,14 +57,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
function testSetDateTimeLOCALTZ() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt1 = new DateTime('1985-07-04 01:30:00', $tz);
- $dt2 = new DateTime('1986-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt1 = new \DateTime('1985-07-04 01:30:00', $tz);
+ $dt2 = new \DateTime('1986-07-04 01:30:00', $tz);
$dt1->setTimeZone($tz);
$dt2->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
- $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::LOCALTZ);
+ $elem = new MultiDateTime('DTSTART');
+ $elem->setDateTimes(array($dt1,$dt2), DateTime::LOCALTZ);
$this->assertEquals('19850704T013000,19860704T013000', $elem->value);
$this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']);
@@ -72,14 +74,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
function testSetDateTimeDATE() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt1 = new datetime('1985-07-04 01:30:00', $tz);
- $dt2 = new datetime('1986-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt1 = new \DateTime('1985-07-04 01:30:00', $tz);
+ $dt2 = new \DateTime('1986-07-04 01:30:00', $tz);
$dt1->settimezone($tz);
$dt2->settimezone($tz);
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
- $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::DATE);
+ $elem = new MultiDateTime('DTSTART');
+ $elem->setDateTimes(array($dt1,$dt2), DateTime::DATE);
$this->assertEquals('19850704,19860704', $elem->value);
$this->assertNull($elem['TZID']);
@@ -92,24 +94,24 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
*/
function testSetDateTimeInvalid() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt = new DateTime('1985-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt = new \DateTime('1985-07-04 01:30:00', $tz);
$dt->setTimeZone($tz);
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
+ $elem = new MultiDateTime('DTSTART');
$elem->setDateTimes(array($dt), 7);
}
function testGetDateTimeCached() {
- $tz = new DateTimeZone('Europe/Amsterdam');
- $dt1 = new datetime('1985-07-04 01:30:00', $tz);
- $dt2 = new datetime('1986-07-04 01:30:00', $tz);
+ $tz = new \DateTimeZone('Europe/Amsterdam');
+ $dt1 = new \DateTime('1985-07-04 01:30:00', $tz);
+ $dt2 = new \DateTime('1986-07-04 01:30:00', $tz);
$dt1->settimezone($tz);
$dt2->settimezone($tz);
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
+ $elem = new MultiDateTime('DTSTART');
$elem->setDateTimes(array($dt1,$dt2));
$this->assertEquals($elem->getDateTimes(), array($dt1,$dt2));
@@ -118,7 +120,7 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
function testGetDateTimeDateNULL() {
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
+ $elem = new MultiDateTime('DTSTART');
$dt = $elem->getDateTimes();
$this->assertNull($dt);
@@ -128,20 +130,20 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
function testGetDateTimeDateDATE() {
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART','19850704,19860704');
+ $elem = new MultiDateTime('DTSTART','19850704,19860704');
$dt = $elem->getDateTimes();
$this->assertEquals('1985-07-04 00:00:00', $dt[0]->format('Y-m-d H:i:s'));
$this->assertEquals('1986-07-04 00:00:00', $dt[1]->format('Y-m-d H:i:s'));
- $this->assertEquals(Sabre_VObject_Property_DateTime::DATE, $elem->getDateType());
+ $this->assertEquals(DateTime::DATE, $elem->getDateType());
}
function testGetDateTimeDateDATEReverse() {
- $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART','19850704,19860704');
+ $elem = new MultiDateTime('DTSTART','19850704,19860704');
- $this->assertEquals(Sabre_VObject_Property_DateTime::DATE, $elem->getDateType());
+ $this->assertEquals(DateTime::DATE, $elem->getDateType());
$dt = $elem->getDateTimes();
$this->assertEquals('1985-07-04 00:00:00', $dt[0]->format('Y-m-d H:i:s'));
@@ -152,30 +154,30 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
function testGetDateTimeDateLOCAL() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000');
+ $elem = new DateTime('DTSTART','19850704T013000');
$dt = $elem->getDateTime();
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
- $this->assertEquals(Sabre_VObject_Property_DateTime::LOCAL, $elem->getDateType());
+ $this->assertEquals(DateTime::LOCAL, $elem->getDateType());
}
function testGetDateTimeDateUTC() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000Z');
+ $elem = new DateTime('DTSTART','19850704T013000Z');
$dt = $elem->getDateTime();
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
$this->assertEquals('UTC', $dt->getTimeZone()->getName());
- $this->assertEquals(Sabre_VObject_Property_DateTime::UTC, $elem->getDateType());
+ $this->assertEquals(DateTime::UTC, $elem->getDateType());
}
function testGetDateTimeDateLOCALTZ() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000');
+ $elem = new DateTime('DTSTART','19850704T013000');
$elem['TZID'] = 'Europe/Amsterdam';
$dt = $elem->getDateTime();
@@ -183,7 +185,7 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
$this->assertInstanceOf('DateTime', $dt);
$this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s'));
$this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName());
- $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType());
+ $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType());
}
@@ -192,7 +194,7 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas
*/
function testGetDateTimeDateInvalid() {
- $elem = new Sabre_VObject_Property_DateTime('DTSTART','bla');
+ $elem = new DateTime('DTSTART','bla');
$dt = $elem->getDateTime();
}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/PropertyTest.php b/dav/sabre-vobject/tests/Sabre/VObject/PropertyTest.php
similarity index 57%
rename from dav/SabreDAV/tests/Sabre/VObject/PropertyTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/PropertyTest.php
index 40fb1468a..201646bb9 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/PropertyTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/PropertyTest.php
@@ -1,10 +1,12 @@
assertEquals('PROPNAME', $property->name);
$this->assertEquals('propvalue', $property->value);
$this->assertEquals('propvalue', $property->__toString());
@@ -14,8 +16,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testParameterExists() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $property->parameters[] = new Parameter('paramname','paramvalue');
$this->assertTrue(isset($property['PARAMNAME']));
$this->assertTrue(isset($property['paramname']));
@@ -25,17 +27,17 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testParameterGet() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $property->parameters[] = new Parameter('paramname','paramvalue');
- $this->assertInstanceOf('Sabre_VObject_Parameter',$property['paramname']);
+ $this->assertInstanceOf('Sabre\\VObject\\Parameter',$property['paramname']);
}
public function testParameterNotExists() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $property->parameters[] = new Parameter('paramname','paramvalue');
$this->assertInternalType('null',$property['foo']);
@@ -43,22 +45,22 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testParameterMultiple() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue');
- $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $property->parameters[] = new Parameter('paramname','paramvalue');
+ $property->parameters[] = new Parameter('paramname','paramvalue');
- $this->assertInstanceOf('Sabre_VObject_Parameter',$property['paramname']);
+ $this->assertInstanceOf('Sabre\\VObject\\Parameter',$property['paramname']);
$this->assertEquals(2,count($property['paramname']));
}
public function testSetParameterAsString() {
- $property = new Sabre_VObject_Property('propname','propvalue');
+ $property = new Property('propname','propvalue');
$property['paramname'] = 'paramvalue';
$this->assertEquals(1,count($property->parameters));
- $this->assertInstanceOf('Sabre_VObject_Parameter', $property->parameters[0]);
+ $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property->parameters[0]);
$this->assertEquals('PARAMNAME',$property->parameters[0]->name);
$this->assertEquals('paramvalue',$property->parameters[0]->value);
@@ -69,15 +71,15 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
*/
public function testSetParameterAsStringNoKey() {
- $property = new Sabre_VObject_Property('propname','propvalue');
+ $property = new Property('propname','propvalue');
$property[] = 'paramvalue';
}
public function testSetParameterObject() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $param = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $param = new Parameter('paramname','paramvalue');
$property[] = $param;
@@ -91,8 +93,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
*/
public function testSetParameterObjectWithKey() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $param = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $param = new Parameter('paramname','paramvalue');
$property['key'] = $param;
@@ -104,15 +106,15 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
*/
public function testSetParameterObjectRandomObject() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $property[] = new StdClass();
+ $property = new Property('propname','propvalue');
+ $property[] = new \StdClass();
}
public function testUnsetParameter() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $param = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $param = new Parameter('paramname','paramvalue');
$property->parameters[] = $param;
unset($property['PARAMNAME']);
@@ -122,8 +124,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testParamCount() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $param = new Sabre_VObject_Parameter('paramname','paramvalue');
+ $property = new Property('propname','propvalue');
+ $param = new Parameter('paramname','paramvalue');
$property->parameters[] = $param;
$property->parameters[] = clone $param;
@@ -133,7 +135,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testSerialize() {
- $property = new Sabre_VObject_Property('propname','propvalue');
+ $property = new Property('propname','propvalue');
$this->assertEquals("PROPNAME:propvalue\r\n",$property->serialize());
@@ -141,9 +143,9 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testSerializeParam() {
- $property = new Sabre_VObject_Property('propname','propvalue');
- $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue');
- $property->parameters[] = new Sabre_VObject_Parameter('paramname2','paramvalue2');
+ $property = new Property('propname','propvalue');
+ $property->parameters[] = new Parameter('paramname','paramvalue');
+ $property->parameters[] = new Parameter('paramname2','paramvalue2');
$this->assertEquals("PROPNAME;PARAMNAME=paramvalue;PARAMNAME2=paramvalue2:propvalue\r\n",$property->serialize());
@@ -151,7 +153,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testSerializeNewLine() {
- $property = new Sabre_VObject_Property('propname',"line1\nline2");
+ $property = new Property('propname',"line1\nline2");
$this->assertEquals("PROPNAME:line1\\nline2\r\n",$property->serialize());
@@ -160,7 +162,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testSerializeLongLine() {
$value = str_repeat('!',200);
- $property = new Sabre_VObject_Property('propname',$value);
+ $property = new Property('propname',$value);
$expected = "PROPNAME:" . str_repeat('!',66) . "\r\n " . str_repeat('!',74) . "\r\n " . str_repeat('!',60) . "\r\n";
@@ -171,7 +173,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testSerializeUTF8LineFold() {
$value = str_repeat('!',65) . "\xc3\xa4bla"; // inserted umlaut-a
- $property = new Sabre_VObject_Property('propname', $value);
+ $property = new Property('propname', $value);
$expected = "PROPNAME:" . str_repeat('!',65) . "\r\n \xc3\xa4bla\r\n";
$this->assertEquals($expected, $property->serialize());
@@ -179,8 +181,9 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testGetIterator() {
- $it = new Sabre_VObject_ElementList(array());
- $property = new Sabre_VObject_Property('propname','propvalue', $it);
+ $it = new ElementList(array());
+ $property = new Property('propname','propvalue');
+ $property->setIterator($it);
$this->assertEquals($it,$property->getIterator());
}
@@ -188,22 +191,22 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
public function testGetIteratorDefault() {
- $property = new Sabre_VObject_Property('propname','propvalue');
+ $property = new Property('propname','propvalue');
$it = $property->getIterator();
- $this->assertTrue($it instanceof Sabre_VObject_ElementList);
+ $this->assertTrue($it instanceof ElementList);
$this->assertEquals(1,count($it));
}
function testAddScalar() {
- $property = new Sabre_VObject_Property('EMAIL');
+ $property = new Property('EMAIL');
$property->add('myparam','value');
$this->assertEquals(1, count($property->parameters));
- $this->assertTrue($property->parameters[0] instanceof Sabre_VObject_Parameter);
+ $this->assertTrue($property->parameters[0] instanceof Parameter);
$this->assertEquals('MYPARAM',$property->parameters[0]->name);
$this->assertEquals('value',$property->parameters[0]->value);
@@ -211,9 +214,9 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
function testAddParameter() {
- $prop = new Sabre_VObject_Property('EMAIL');
+ $prop = new Property('EMAIL');
- $prop->add(new Sabre_VObject_Parameter('MYPARAM','value'));
+ $prop->add(new Parameter('MYPARAM','value'));
$this->assertEquals(1, count($prop->parameters));
$this->assertEquals('MYPARAM',$prop['myparam']->name);
@@ -222,10 +225,10 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
function testAddParameterTwice() {
- $prop = new Sabre_VObject_Property('EMAIL');
+ $prop = new Property('EMAIL');
- $prop->add(new Sabre_VObject_Parameter('MYPARAM', 'value1'));
- $prop->add(new Sabre_VObject_Parameter('MYPARAM', 'value2'));
+ $prop->add(new Parameter('MYPARAM', 'value1'));
+ $prop->add(new Parameter('MYPARAM', 'value2'));
$this->assertEquals(2, count($prop->parameters));
@@ -238,8 +241,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
*/
function testAddArgFail() {
- $prop = new Sabre_VObject_Property('EMAIL');
- $prop->add(new Sabre_VObject_Parameter('MPARAM'),'hello');
+ $prop = new Property('EMAIL');
+ $prop->add(new Parameter('MPARAM'),'hello');
}
@@ -248,7 +251,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
*/
function testAddArgFail2() {
- $property = new Sabre_VObject_Property('EMAIL','value');
+ $property = new Property('EMAIL','value');
$property->add(array());
}
@@ -258,14 +261,14 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
*/
function testAddArgFail3() {
- $property = new Sabre_VObject_Property('EMAIL','value');
+ $property = new Property('EMAIL','value');
$property->add('hello',array());
}
function testClone() {
- $property = new Sabre_VObject_Property('EMAIL','value');
+ $property = new Property('EMAIL','value');
$property['FOO'] = 'BAR';
$property2 = clone $property;
@@ -275,4 +278,16 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase {
}
+ function testCreateParams() {
+
+ $property = Property::create('X-PROP', 'value', array(
+ 'param1' => 'value1',
+ 'param2' => array('value2', 'value3')
+ ));
+
+ $this->assertEquals(1, count($property['PARAM1']));
+ $this->assertEquals(2, count($property['PARAM2']));
+
+ }
+
}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/ReaderTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ReaderTest.php
similarity index 70%
rename from dav/SabreDAV/tests/Sabre/VObject/ReaderTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/ReaderTest.php
index a87651cdc..998ff6204 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/ReaderTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/ReaderTest.php
@@ -1,14 +1,16 @@
assertInstanceOf('Sabre_VObject_Component', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
$this->assertEquals('VCALENDAR', $result->name);
$this->assertEquals(0, count($result->children));
@@ -18,9 +20,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
$data = "BEGIN:VCALENDAR\nEND:VCALENDAR";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Component', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
$this->assertEquals('VCALENDAR', $result->name);
$this->assertEquals(0, count($result->children));
@@ -30,9 +32,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
$data = "BEGIN:VCALENDAR\rEND:VCALENDAR";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Component', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
$this->assertEquals('VCALENDAR', $result->name);
$this->assertEquals(0, count($result->children));
@@ -42,31 +44,31 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
$data = "BEGIN:\r\n\tVCALENDAR\r\nE\r\n ND:VCALENDAR";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Component', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
$this->assertEquals('VCALENDAR', $result->name);
$this->assertEquals(0, count($result->children));
}
/**
- * @expectedException Sabre_VObject_ParseException
+ * @expectedException Sabre\VObject\ParseException
*/
function testReadCorruptComponent() {
$data = "BEGIN:VCALENDAR\r\nEND:FOO";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
}
function testReadProperty() {
$data = "PROPNAME:propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue', $result->value);
@@ -75,9 +77,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadPropertyWithNewLine() {
$data = 'PROPNAME:Line1\\nLine2\\NLine3\\\\Not the 4th line!';
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals("Line1\nLine2\nLine3\\Not the 4th line!", $result->value);
@@ -86,9 +88,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadMappedProperty() {
$data = "DTSTART:20110529";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property_DateTime', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property\\DateTime', $result);
$this->assertEquals('DTSTART', $result->name);
$this->assertEquals('20110529', $result->value);
@@ -97,9 +99,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadMappedPropertyGrouped() {
$data = "foo.DTSTART:20110529";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property_DateTime', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property\\DateTime', $result);
$this->assertEquals('DTSTART', $result->name);
$this->assertEquals('20110529', $result->value);
@@ -107,12 +109,12 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
/**
- * @expectedException Sabre_VObject_ParseException
+ * @expectedException Sabre\VObject\ParseException
*/
function testReadBrokenLine() {
$data = "PROPNAME;propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
}
@@ -124,12 +126,12 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
"END:VCALENDAR"
);
- $result = Sabre_VObject_Reader::read(implode("\r\n",$data));
+ $result = Reader::read(implode("\r\n",$data));
- $this->assertInstanceOf('Sabre_VObject_Component', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
$this->assertEquals('VCALENDAR', $result->name);
$this->assertEquals(1, count($result->children));
- $this->assertInstanceOf('Sabre_VObject_Property', $result->children[0]);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result->children[0]);
$this->assertEquals('PROPNAME', $result->children[0]->name);
$this->assertEquals('propValue', $result->children[0]->value);
@@ -146,15 +148,15 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
"END:VCALENDAR"
);
- $result = Sabre_VObject_Reader::read(implode("\r\n",$data));
+ $result = Reader::read(implode("\r\n",$data));
- $this->assertInstanceOf('Sabre_VObject_Component', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result);
$this->assertEquals('VCALENDAR', $result->name);
$this->assertEquals(1, count($result->children));
- $this->assertInstanceOf('Sabre_VObject_Component', $result->children[0]);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result->children[0]);
$this->assertEquals('VTIMEZONE', $result->children[0]->name);
$this->assertEquals(1, count($result->children[0]->children));
- $this->assertInstanceOf('Sabre_VObject_Component', $result->children[0]->children[0]);
+ $this->assertInstanceOf('Sabre\\VObject\\Component', $result->children[0]->children[0]);
$this->assertEquals('DAYLIGHT', $result->children[0]->children[0]->name);
@@ -163,9 +165,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadPropertyParameter() {
$data = "PROPNAME;PARAMNAME=paramvalue:propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue', $result->value);
$this->assertEquals(1, count($result->parameters));
@@ -177,9 +179,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadPropertyNoValue() {
$data = "PROPNAME;PARAMNAME:propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue', $result->value);
$this->assertEquals(1, count($result->parameters));
@@ -191,9 +193,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadPropertyParameterExtraColon() {
$data = "PROPNAME;PARAMNAME=paramvalue:propValue:anotherrandomstring";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue:anotherrandomstring', $result->value);
$this->assertEquals(1, count($result->parameters));
@@ -205,9 +207,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadProperty2Parameters() {
$data = "PROPNAME;PARAMNAME=paramvalue;PARAMNAME2=paramvalue2:propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue', $result->value);
$this->assertEquals(2, count($result->parameters));
@@ -221,9 +223,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadPropertyParameterQuoted() {
$data = "PROPNAME;PARAMNAME=\"paramvalue\":propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue', $result->value);
$this->assertEquals(1, count($result->parameters));
@@ -234,9 +236,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadPropertyParameterNewLines() {
$data = "PROPNAME;PARAMNAME=paramvalue1\\nvalue2\\\\nvalue3:propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue', $result->value);
@@ -249,9 +251,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase {
function testReadPropertyParameterQuotedColon() {
$data = "PROPNAME;PARAMNAME=\"param:value\":propValue";
- $result = Sabre_VObject_Reader::read($data);
+ $result = Reader::read($data);
- $this->assertInstanceOf('Sabre_VObject_Property', $result);
+ $this->assertInstanceOf('Sabre\\VObject\\Property', $result);
$this->assertEquals('PROPNAME', $result->name);
$this->assertEquals('propValue', $result->value);
$this->assertEquals(1, count($result->parameters));
diff --git a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php
similarity index 75%
rename from dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php
index 75972c2a0..ffcb6ee71 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php
@@ -1,6 +1,8 @@
VEVENT->UID);
+ $vObject = Reader::read($ics);
+ $it = new RecurrenceIterator($vObject, (string)$vObject->VEVENT->UID);
while($it->valid()) {
$it->next();
diff --git a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php
similarity index 83%
rename from dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php
index 150625095..3976388be 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php
@@ -1,6 +1,11 @@
DTSTART = '20090420T180000Z';
$ev->RRULE = 'FREQ=WEEKLY;BYDAY=MO;UNTIL=20090704T205959Z;INTERVAL=1';
@@ -21,7 +26,7 @@ class Sabre_VObject_RecurrenceIteratorInfiniteLoopProblemTest extends PHPUnit_Fr
*/
function testYearlyByMonthLoop() {
- $ev = Sabre_VObject_Component::create('VEVENT');
+ $ev = Component::create('VEVENT');
$ev->UID = 'uuid';
$ev->DTSTART = '20120101T154500';
$ev->DTSTART['TZID'] = 'Europe/Berlin';
@@ -35,10 +40,10 @@ class Sabre_VObject_RecurrenceIteratorInfiniteLoopProblemTest extends PHPUnit_Fr
// The BYDAY part expands this to every day of the month, but the
// BYSETPOS limits this to only the 1st day of the month. Very crazy
// way to specify this, and could have certainly been a lot easier.
- $cal = Sabre_VObject_Component::create('VCALENDAR');
+ $cal = Component::create('VCALENDAR');
$cal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($cal,'uuid');
+ $it = new RecurrenceIterator($cal,'uuid');
$it->fastForward(new DateTime('2012-01-29 23:00:00', new DateTimeZone('UTC')));
$collect = array();
diff --git a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorTest.php b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorTest.php
similarity index 75%
rename from dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorTest.php
index 0bb42bb87..c79ac689c 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorTest.php
@@ -1,21 +1,26 @@
UID = 'bla';
$ev->RRULE = 'FREQ=DAILY;BYHOUR=10;BYMINUTE=5;BYSECOND=16;BYWEEKNO=32;BYYEARDAY=100,200';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-10-07'),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals(array(10), $it->byHour);
$this->assertEquals(array(5), $it->byMinute);
@@ -31,17 +36,17 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testInvalidFreq() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->RRULE = 'FREQ=SMONTHLY;INTERVAL=3;UNTIL=20111025T000000Z';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-10-07'),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
}
@@ -50,8 +55,8 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testVCalendarNoUID() {
- $vcal = new Sabre_VObject_Component('VCALENDAR');
- $it = new Sabre_VObject_RecurrenceIterator($vcal);
+ $vcal = new Component('VCALENDAR');
+ $it = new RecurrenceIterator($vcal);
}
@@ -60,8 +65,8 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testVCalendarInvalidUID() {
- $vcal = new Sabre_VObject_Component('VCALENDAR');
- $it = new Sabre_VObject_RecurrenceIterator($vcal,'foo');
+ $vcal = new Component('VCALENDAR');
+ $it = new RecurrenceIterator($vcal,'foo');
}
@@ -70,18 +75,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testDaily() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=DAILY;INTERVAL=3;UNTIL=20111025T000000Z';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,$ev->uid);
+ $it = new RecurrenceIterator($vcal,$ev->uid);
$this->assertEquals('daily', $it->frequency);
$this->assertEquals(3, $it->interval);
@@ -121,17 +126,17 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testNoRRULE() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,$ev->uid);
+ $it = new RecurrenceIterator($vcal,$ev->uid);
$this->assertEquals('daily', $it->frequency);
$this->assertEquals(1, $it->interval);
@@ -164,18 +169,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testDailyByDay() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=DAILY;INTERVAL=2;BYDAY=TU,WE,FR';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('daily', $it->frequency);
$this->assertEquals(2, $it->interval);
@@ -220,18 +225,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testWeekly() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;COUNT=10';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('weekly', $it->frequency);
$this->assertEquals(2, $it->interval);
@@ -274,18 +279,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testWeeklyByDay() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,FR;WKST=SU';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('weekly', $it->frequency);
$this->assertEquals(2, $it->interval);
@@ -331,18 +336,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testMonthly() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=MONTHLY;INTERVAL=3;COUNT=5';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-12-05'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-12-05', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('monthly', $it->frequency);
$this->assertEquals(3, $it->interval);
@@ -380,18 +385,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testMonthlyEndOfMonth() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=MONTHLY;INTERVAL=2;COUNT=12';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-12-31'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-12-31', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('monthly', $it->frequency);
$this->assertEquals(2, $it->interval);
@@ -436,18 +441,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testMonthlyByMonthDay() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=MONTHLY;INTERVAL=5;COUNT=9;BYMONTHDAY=1,31,-7';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-01-01'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-01-01', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('monthly', $it->frequency);
$this->assertEquals(5, $it->interval);
@@ -489,18 +494,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testMonthlyByDay() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=MONTHLY;INTERVAL=2;COUNT=16;BYDAY=MO,-2TU,+1WE,3TH';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-01-03'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-01-03', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('monthly', $it->frequency);
$this->assertEquals(2, $it->interval);
@@ -549,18 +554,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testMonthlyByDayByMonthDay() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=MONTHLY;COUNT=10;BYDAY=MO;BYMONTHDAY=1';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-08-01'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-08-01', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('monthly', $it->frequency);
$this->assertEquals(1, $it->interval);
@@ -604,18 +609,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testMonthlyByDayBySetPos() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=MONTHLY;COUNT=10;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=1,-1';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-01-03'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-01-03', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('monthly', $it->frequency);
$this->assertEquals(1, $it->interval);
@@ -659,18 +664,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testYearly() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=YEARLY;COUNT=10;INTERVAL=3';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-01-01'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-01-01', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('yearly', $it->frequency);
$this->assertEquals(3, $it->interval);
@@ -712,18 +717,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testYearlyLeapYear() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=YEARLY;COUNT=3';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2012-02-29'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2012-02-29', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('yearly', $it->frequency);
$this->assertEquals(3, $it->count);
@@ -757,18 +762,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testYearlyByMonth() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=4;BYMONTH=4,10';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-04-07'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-04-07', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('yearly', $it->frequency);
$this->assertEquals(4, $it->interval);
@@ -809,18 +814,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testYearlyByMonthByDay() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=5;BYMONTH=4,10;BYDAY=1MO,-1SU';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-04-04'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-04-04', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('yearly', $it->frequency);
$this->assertEquals(5, $it->interval);
@@ -862,22 +867,22 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testFastForward() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=5;BYMONTH=4,10;BYDAY=1MO,-1SU';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
- $dtStart->setDateTime(new DateTime('2011-04-04'),Sabre_VObject_Property_DateTime::UTC);
+ $dtStart = new Property\DateTime('DTSTART');
+ $dtStart->setDateTime(new DateTime('2011-04-04', new DateTimeZone('UTC')),Property\DateTime::UTC);
$ev->add($dtStart);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
// The idea is that we're fast-forwarding too far in the future, so
// there will be no results left.
- $it->fastForward(new DateTime('2020-05-05'));
+ $it->fastForward(new DateTime('2020-05-05', new DateTimeZone('UTC')));
$max = 20;
$result = array();
@@ -901,27 +906,27 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testComplexExclusions() {
- $ev = new Sabre_VObject_Component('VEVENT');
+ $ev = new Component('VEVENT');
$ev->UID = 'bla';
$ev->RRULE = 'FREQ=YEARLY;COUNT=10';
- $dtStart = new Sabre_VObject_Property_DateTime('DTSTART');
+ $dtStart = new Property\DateTime('DTSTART');
$tz = new DateTimeZone('Canada/Eastern');
- $dtStart->setDateTime(new DateTime('2011-01-01 13:50:20', $tz),Sabre_VObject_Property_DateTime::LOCALTZ);
+ $dtStart->setDateTime(new DateTime('2011-01-01 13:50:20', $tz),Property\DateTime::LOCALTZ);
- $exDate1 = new Sabre_VObject_Property_MultiDateTime('EXDATE');
- $exDate1->setDateTimes(array(new DateTime('2012-01-01 13:50:20', $tz), new DateTime('2014-01-01 13:50:20', $tz)), Sabre_VObject_Property_DateTime::LOCALTZ);
- $exDate2 = new Sabre_VObject_Property_MultiDateTime('EXDATE');
- $exDate2->setDateTimes(array(new DateTime('2016-01-01 13:50:20', $tz)), Sabre_VObject_Property_DateTime::LOCALTZ);
+ $exDate1 = new Property\MultiDateTime('EXDATE');
+ $exDate1->setDateTimes(array(new DateTime('2012-01-01 13:50:20', $tz), new DateTime('2014-01-01 13:50:20', $tz)), Property\DateTime::LOCALTZ);
+ $exDate2 = new Property\MultiDateTime('EXDATE');
+ $exDate2->setDateTimes(array(new DateTime('2016-01-01 13:50:20', $tz)), Property\DateTime::LOCALTZ);
$ev->add($dtStart);
$ev->add($exDate1);
$ev->add($exDate2);
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
$vcal->add($ev);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid);
+ $it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertEquals('yearly', $it->frequency);
$this->assertEquals(1, $it->interval);
@@ -958,9 +963,9 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testOverridenEvent() {
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
- $ev1 = Sabre_VObject_Component::create('VEVENT');
+ $ev1 = Component::create('VEVENT');
$ev1->UID = 'overridden';
$ev1->RRULE = 'FREQ=DAILY;COUNT=10';
$ev1->DTSTART = '20120107T120000Z';
@@ -969,7 +974,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
$vcal->add($ev1);
// ev2 overrides an event, and puts it on 2pm instead.
- $ev2 = Sabre_VObject_Component::create('VEVENT');
+ $ev2 = Component::create('VEVENT');
$ev2->UID = 'overridden';
$ev2->{'RECURRENCE-ID'} = '20120110T120000Z';
$ev2->DTSTART = '20120110T140000Z';
@@ -978,7 +983,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
$vcal->add($ev2);
// ev3 overrides an event, and puts it 2 days and 2 hours later
- $ev3 = Sabre_VObject_Component::create('VEVENT');
+ $ev3 = Component::create('VEVENT');
$ev3->UID = 'overridden';
$ev3->{'RECURRENCE-ID'} = '20120113T120000Z';
$ev3->DTSTART = '20120115T140000Z';
@@ -986,7 +991,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
$vcal->add($ev3);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,'overridden');
+ $it = new RecurrenceIterator($vcal,'overridden');
$dates = array();
$summaries = array();
@@ -1032,9 +1037,9 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testOverridenEvent2() {
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
- $ev1 = Sabre_VObject_Component::create('VEVENT');
+ $ev1 = Component::create('VEVENT');
$ev1->UID = 'overridden';
$ev1->RRULE = 'FREQ=WEEKLY;COUNT=3';
$ev1->DTSTART = '20120112T120000Z';
@@ -1043,7 +1048,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
$vcal->add($ev1);
// ev2 overrides an event, and puts it 6 days earlier instead.
- $ev2 = Sabre_VObject_Component::create('VEVENT');
+ $ev2 = Component::create('VEVENT');
$ev2->UID = 'overridden';
$ev2->{'RECURRENCE-ID'} = '20120119T120000Z';
$ev2->DTSTART = '20120113T120000Z';
@@ -1051,7 +1056,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
$vcal->add($ev2);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,'overridden');
+ $it = new RecurrenceIterator($vcal,'overridden');
$dates = array();
$summaries = array();
@@ -1084,9 +1089,9 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
*/
function testOverridenEventNoValuesExpected() {
- $vcal = Sabre_VObject_Component::create('VCALENDAR');
+ $vcal = Component::create('VCALENDAR');
- $ev1 = Sabre_VObject_Component::create('VEVENT');
+ $ev1 = Component::create('VEVENT');
$ev1->UID = 'overridden';
$ev1->RRULE = 'FREQ=WEEKLY;COUNT=3';
$ev1->DTSTART = '20120124T120000Z';
@@ -1095,7 +1100,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
$vcal->add($ev1);
// ev2 overrides an event, and puts it 6 days earlier instead.
- $ev2 = Sabre_VObject_Component::create('VEVENT');
+ $ev2 = Component::create('VEVENT');
$ev2->UID = 'overridden';
$ev2->{'RECURRENCE-ID'} = '20120131T120000Z';
$ev2->DTSTART = '20120125T120000Z';
@@ -1103,7 +1108,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase {
$vcal->add($ev2);
- $it = new Sabre_VObject_RecurrenceIterator($vcal,'overridden');
+ $it = new RecurrenceIterator($vcal,'overridden');
$dates = array();
$summaries = array();
diff --git a/dav/SabreDAV/tests/Sabre/VObject/TimeZoneUtilTest.php b/dav/sabre-vobject/tests/Sabre/VObject/TimeZoneUtilTest.php
similarity index 76%
rename from dav/SabreDAV/tests/Sabre/VObject/TimeZoneUtilTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/TimeZoneUtilTest.php
index be8cd49c3..1f13ccbc3 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/TimeZoneUtilTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/TimeZoneUtilTest.php
@@ -1,13 +1,15 @@
assertEquals(new DateTimeZone('Europe/Sarajevo'), $tz);
+ $this->assertEquals(new \DateTimeZone('Europe/Sarajevo'), $tz);
}
@@ -99,16 +101,16 @@ END:VEVENT
END:VCALENDAR
HI;
- $tz = Sabre_VObject_TimeZoneUtil::getTimeZone('foo', Sabre_VObject_Reader::read($vobj));
+ $tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj));
- $this->assertEquals(new DateTimeZone(date_default_timezone_get()), $tz);
+ $this->assertEquals(new \DateTimeZone(date_default_timezone_get()), $tz);
}
function testWindowsTimeZone() {
- $tz = Sabre_VObject_TimeZoneUtil::getTimeZone('Eastern Standard Time');
- $this->assertEquals(new DateTimeZone('America/New_York'), $tz);
+ $tz = TimeZoneUtil::getTimeZone('Eastern Standard Time');
+ $this->assertEquals(new \DateTimeZone('America/New_York'), $tz);
}
@@ -144,9 +146,9 @@ UID:040000008200E00074C5B7101A82E0080000000010DA091DC31BCD01000000000000000
END:VEVENT
END:VCALENDAR
HI;
- $tz = Sabre_VObject_TimeZoneUtil::getTimeZone('foo', Sabre_VObject_Reader::read($vobj));
+ $tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj));
- $this->assertEquals(new DateTimeZone(date_default_timezone_get()), $tz);
+ $this->assertEquals(new \DateTimeZone(date_default_timezone_get()), $tz);
}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/VersionTest.php b/dav/sabre-vobject/tests/Sabre/VObject/VersionTest.php
similarity index 53%
rename from dav/SabreDAV/tests/Sabre/VObject/VersionTest.php
rename to dav/sabre-vobject/tests/Sabre/VObject/VersionTest.php
index ea2a4b284..ae6855e85 100644
--- a/dav/SabreDAV/tests/Sabre/VObject/VersionTest.php
+++ b/dav/sabre-vobject/tests/Sabre/VObject/VersionTest.php
@@ -1,13 +1,15 @@
assertEquals(-1, version_compare('0.9.0',$v));
- $s = Sabre_VObject_Version::STABILITY;
+ $s = Version::STABILITY;
$this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable');
}
diff --git a/dav/SabreDAV/tests/Sabre/VObject/issue153.vcf b/dav/sabre-vobject/tests/Sabre/VObject/issue153.vcf
similarity index 100%
rename from dav/SabreDAV/tests/Sabre/VObject/issue153.vcf
rename to dav/sabre-vobject/tests/Sabre/VObject/issue153.vcf
diff --git a/dav/sabre-vobject/tests/bootstrap.php b/dav/sabre-vobject/tests/bootstrap.php
new file mode 100644
index 000000000..ee071ea75
--- /dev/null
+++ b/dav/sabre-vobject/tests/bootstrap.php
@@ -0,0 +1,4 @@
+
+
+ Sabre/
+
+
+
+
+ ../lib/
+
+
+
diff --git a/dav/timepicker/index.htm b/dav/timepicker/index.htm
index 4f7d6f4da..e6babf7dc 100644
--- a/dav/timepicker/index.htm
+++ b/dav/timepicker/index.htm
@@ -24,7 +24,7 @@
}
-
+
-
diff --git a/editplain.tgz b/editplain.tgz
index be8131774..0f2b95d0e 100644
Binary files a/editplain.tgz and b/editplain.tgz differ
diff --git a/editplain/editplain.php b/editplain/editplain.php
index 7d91c2952..966e2d8fd 100755
--- a/editplain/editplain.php
+++ b/editplain/editplain.php
@@ -1,7 +1,7 @@
*
diff --git a/facebook.tgz b/facebook.tgz
index ff920dc60..6bf8f7a99 100644
Binary files a/facebook.tgz and b/facebook.tgz differ
diff --git a/facebook/facebook.php b/facebook/facebook.php
index 6786febbb..f977bef90 100644
--- a/facebook/facebook.php
+++ b/facebook/facebook.php
@@ -1242,8 +1242,12 @@ function facebook_post_local(&$a,&$b) {
$fb_enable = (($fb_post && x($_REQUEST,'facebook_enable')) ? intval($_REQUEST['facebook_enable']) : 0);
// if API is used, default to the chosen settings
- if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default')))
- $fb_enable = 1;
+ // but allow a specific override
+
+ if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default'))) {
+ if(! x($_REQUEST,'facebook_enable'))
+ $fb_enable = 1;
+ }
if(! $fb_enable)
return;
diff --git a/fbpost.tgz b/fbpost.tgz
new file mode 100644
index 000000000..ecf933d8e
Binary files /dev/null and b/fbpost.tgz differ
diff --git a/fbpost/README.md b/fbpost/README.md
new file mode 100644
index 000000000..c214360a8
--- /dev/null
+++ b/fbpost/README.md
@@ -0,0 +1,18 @@
+Installing the Friendica/Facebook connector
+
+Detailed instructions how to use this plugin can be found at
+the [How to: Friendica's Facebook Connector](https://github.com/friendica/friendica/wiki/How-to:-Friendica%E2%80%99s-Facebook-connector) page.
+
+Vidoes and embeds will not be posted if there is no other content. Links
+and images will be converted to a format suitable for the Facebook API and
+long posts truncated - with a link to view the full post.
+
+Facebook contacts will not be able to view private photos, as they are not able to
+authenticate to your site to establish identity. We will address this
+in a future release.
+
+This addon will only post your entries to your Facebook account but won't fetch
+content from there.
+
+Info: please make sure that you understand all aspects due to Friendica's
+default licence which is: [MIT License](https://github.com/friendica/friendica/blob/master/LICENSE)
diff --git a/fbpost/fbpost.css b/fbpost/fbpost.css
new file mode 100644
index 000000000..224d27bd2
--- /dev/null
+++ b/fbpost/fbpost.css
@@ -0,0 +1,13 @@
+
+#fbpost-enable-wrapper {
+ margin-top: 20px;
+}
+
+#fbpost-disable-wrapper {
+ margin-top: 20px;
+}
+
+#fbpost-post-default-form input {
+ margin-top: 20px;
+ margin-right: 20px;
+}
\ No newline at end of file
diff --git a/fbpost/fbpost.php b/fbpost/fbpost.php
new file mode 100644
index 000000000..ab49c3033
--- /dev/null
+++ b/fbpost/fbpost.php
@@ -0,0 +1,967 @@
+
+ * Author: Tobias Hößl
+ *
+ */
+
+/**
+ * Installing the Friendica/Facebook connector
+ *
+ * Detailed instructions how to use this plugin can be found at
+ * https://github.com/friendica/friendica/wiki/How-to:-Friendica%E2%80%99s-Facebook-connector
+ *
+ * Vidoes and embeds will not be posted if there is no other content. Links
+ * and images will be converted to a format suitable for the Facebook API and
+ * long posts truncated - with a link to view the full post.
+ *
+ * Facebook contacts will not be able to view private photos, as they are not able to
+ * authenticate to your site to establish identity. We will address this
+ * in a future release.
+ */
+
+
+require_once('include/security.php');
+
+function fbpost_install() {
+ register_hook('post_local', 'addon/fbpost/fbpost.php', 'fbpost_post_local');
+ register_hook('notifier_normal', 'addon/fbpost/fbpost.php', 'fbpost_post_hook');
+ register_hook('jot_networks', 'addon/fbpost/fbpost.php', 'fbpost_jot_nets');
+ register_hook('connector_settings', 'addon/fbpost/fbpost.php', 'fbpost_plugin_settings');
+ register_hook('enotify', 'addon/fbpost/fbpost.php', 'fbpost_enotify');
+ register_hook('queue_predeliver', 'addon/fbpost/fbpost.php', 'fbpost_queue_hook');
+}
+
+
+function fbpost_uninstall() {
+ unregister_hook('post_local', 'addon/fbpost/fbpost.php', 'fbpost_post_local');
+ unregister_hook('notifier_normal', 'addon/fbpost/fbpost.php', 'fbpost_post_hook');
+ unregister_hook('jot_networks', 'addon/fbpost/fbpost.php', 'fbpost_jot_nets');
+ unregister_hook('connector_settings', 'addon/fbpost/fbpost.php', 'fbpost_plugin_settings');
+ unregister_hook('enotify', 'addon/fbpost/fbpost.php', 'fbpost_enotify');
+ unregister_hook('queue_predeliver', 'addon/fbpost/fbpost.php', 'fbpost_queue_hook');
+
+
+}
+
+
+/* declare the fbpost_module function so that /fbpost url requests will land here */
+
+function fbpost_module() {}
+
+
+
+// If a->argv[1] is a nickname, this is a callback from Facebook oauth requests.
+// If $_REQUEST["realtime_cb"] is set, this is a callback from the Real-Time Updates API
+
+/**
+ * @param App $a
+ */
+function fbpost_init(&$a) {
+
+ if($a->argc != 2)
+ return;
+
+ $nick = $a->argv[1];
+
+ if(strlen($nick))
+ $r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
+ dbesc($nick)
+ );
+ if(!(isset($r) && count($r)))
+ return;
+
+ $uid = $r[0]['uid'];
+ $auth_code = (x($_GET, 'code') ? $_GET['code'] : '');
+ $error = (x($_GET, 'error_description') ? $_GET['error_description'] : '');
+
+
+ if($error)
+ logger('fbpost_init: Error: ' . $error);
+
+ if($auth_code && $uid) {
+
+ $appid = get_config('facebook','appid');
+ $appsecret = get_config('facebook', 'appsecret');
+
+ $x = fetch_url('https://graph.facebook.com/oauth/access_token?client_id='
+ . $appid . '&client_secret=' . $appsecret . '&redirect_uri='
+ . urlencode($a->get_baseurl() . '/fbpost/' . $nick)
+ . '&code=' . $auth_code);
+
+ logger('fbpost_init: returned access token: ' . $x, LOGGER_DATA);
+
+ if(strpos($x,'access_token=') !== false) {
+ $token = str_replace('access_token=', '', $x);
+ if(strpos($token,'&') !== false)
+ $token = substr($token,0,strpos($token,'&'));
+ set_pconfig($uid,'facebook','access_token',$token);
+ set_pconfig($uid,'facebook','post','1');
+ fbpost_get_self($uid);
+ }
+
+ }
+
+}
+
+
+/**
+ * @param int $uid
+ */
+function fbpost_get_self($uid) {
+ $access_token = get_pconfig($uid,'facebook','access_token');
+ if(! $access_token)
+ return;
+ $s = fetch_url('https://graph.facebook.com/me/?access_token=' . $access_token);
+ if($s) {
+ $j = json_decode($s);
+ set_pconfig($uid,'facebook','self_id',(string) $j->id);
+ }
+}
+
+
+// This is the POST method to the facebook settings page
+// Content is posted to Facebook in the function facebook_post_hook()
+
+/**
+ * @param App $a
+ */
+function fbpost_post(&$a) {
+
+ $uid = local_user();
+ if($uid){
+
+
+ $fb_limited = get_config('facebook','crestrict');
+
+
+ $value = ((x($_POST,'post_by_default')) ? intval($_POST['post_by_default']) : 0);
+ set_pconfig($uid,'facebook','post_by_default', $value);
+
+ $value = ((x($_POST,'suppress_view_on_friendica')) ? intval($_POST['suppress_view_on_friendica']) : 0);
+ set_pconfig($uid,'facebook','suppress_view_on_friendica', $value);
+
+ $value = ((x($_POST,'post_to_page')) ? $_POST['post_to_page'] : "0-0");
+ $values = explode("-", $value);
+ set_pconfig($uid,'facebook','post_to_page', $values[0]);
+ set_pconfig($uid,'facebook','page_access_token', $values[1]);
+
+ info( t('Settings updated.') . EOL);
+ }
+
+ return;
+}
+
+// Facebook settings form
+
+/**
+ * @param App $a
+ * @return string
+ */
+function fbpost_content(&$a) {
+
+ if(! local_user()) {
+ notice( t('Permission denied.') . EOL);
+ return '';
+ }
+
+
+ if(! service_class_allows(local_user(),'facebook_connect')) {
+ notice( t('Permission denied.') . EOL);
+ return upgrade_bool_message();
+ }
+
+
+ if($a->argc > 1 && $a->argv[1] === 'remove') {
+ del_pconfig(local_user(),'facebook','post');
+ info( t('Facebook Post disabled') . EOL);
+ }
+
+ $o = '';
+
+ $fb_installed = false;
+ if (get_pconfig(local_user(),'facebook','post')) {
+ $access_token = get_pconfig(local_user(),'facebook','access_token');
+ if ($access_token) {
+ $s = fetch_url('https://graph.facebook.com/me/feed?access_token=' . $access_token);
+ if($s) {
+ $j = json_decode($s);
+ if (isset($j->data)) $fb_installed = true;
+ }
+ }
+ }
+
+ $appid = get_config('facebook','appid');
+
+ if(! $appid) {
+ notice( t('Facebook API key is missing.') . EOL);
+ return '';
+ }
+
+ $a->page['htmlhead'] .= ' ' . "\r\n";
+
+ $o .= '' . t('Facebook Post') . ' ';
+
+ if(! $fb_installed) {
+ $o .= '';
+ }
+
+ if($fb_installed) {
+ $o .= '';
+
+ $o .= '';
+
+ $o .= '';
+
+ }
+
+ return $o;
+}
+
+/**
+ * @param App $a
+ * @param null|object $b
+ */
+function fbpost_plugin_settings(&$a,&$b) {
+
+ $b .= '';
+
+}
+
+
+/**
+ * @param App $a
+ * @param null|object $o
+ */
+function fbpost_plugin_admin(&$a, &$o){
+
+
+ $o = ' ';
+
+ $o .= '' . t('Facebook API Key') . ' ';
+
+ $appid = get_config('facebook', 'appid' );
+ $appsecret = get_config('facebook', 'appsecret' );
+
+ $ret1 = q("SELECT `v` FROM `config` WHERE `cat` = 'facebook' AND `k` = 'appid' LIMIT 1");
+ $ret2 = q("SELECT `v` FROM `config` WHERE `cat` = 'facebook' AND `k` = 'appsecret' LIMIT 1");
+ if ((count($ret1) > 0 && $ret1[0]['v'] != $appid) || (count($ret2) > 0 && $ret2[0]['v'] != $appsecret)) $o .= t('Error: it appears that you have specified the App-ID and -Secret in your .htconfig.php file. As long as they are specified there, they cannot be set using this form. ');
+
+ $o .= '' . t('App-ID / API-Key') . ' ';
+ $o .= '' . t('Application secret') . ' ';
+
+ $o .= ' ';
+
+}
+
+/**
+ * @param App $a
+ */
+
+function fbpost_plugin_admin_post(&$a){
+ check_form_security_token_redirectOnErr('/admin/plugins/fbpost', 'fbsave');
+
+ if (x($_REQUEST,'fb_save_keys')) {
+ set_config('facebook', 'appid', $_REQUEST['appid']);
+ set_config('facebook', 'appsecret', $_REQUEST['appsecret']);
+
+ info(t('The new values have been saved.'));
+ }
+
+}
+
+/**
+ * @param App $a
+ * @param object $b
+ * @return mixed
+ */
+function fbpost_jot_nets(&$a,&$b) {
+ if(! local_user())
+ return;
+
+ $fb_post = get_pconfig(local_user(),'facebook','post');
+ if(intval($fb_post) == 1) {
+ $fb_defpost = get_pconfig(local_user(),'facebook','post_by_default');
+ $selected = ((intval($fb_defpost) == 1) ? ' checked="checked" ' : '');
+ $b .= ' '
+ . t('Post to Facebook') . '
';
+ }
+}
+
+function fbpost_ShareAttributes($match) {
+
+ $attributes = $match[1];
+
+ $author = "";
+ preg_match("/author='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $matches[1];
+
+ preg_match('/author="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $matches[1];
+
+ $headline = '";
+
+ //$text = " ".$headline."".$match[2]." ";
+ $text = "\n\t".$match[2].":\t";
+
+ return($text);
+}
+
+
+/**
+ * @param App $a
+ * @param object $b
+ * @return mixed
+ */
+function fbpost_post_hook(&$a,&$b) {
+
+
+ if($b['deleted'] || ($b['created'] !== $b['edited']))
+ return;
+
+ /**
+ * Post to Facebook stream
+ */
+
+ require_once('include/group.php');
+ require_once('include/html2plain.php');
+
+ logger('Facebook post');
+
+ $reply = false;
+ $likes = false;
+
+ $deny_arr = array();
+ $allow_arr = array();
+
+ $toplevel = (($b['id'] == $b['parent']) ? true : false);
+
+
+ $linking = ((get_pconfig($b['uid'],'facebook','no_linking')) ? 0 : 1);
+
+ if((! $toplevel) && ($linking)) {
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($b['parent']),
+ intval($b['uid'])
+ );
+ if(count($r) && substr($r[0]['uri'],0,4) === 'fb::')
+ $reply = substr($r[0]['uri'],4);
+ elseif(count($r) && substr($r[0]['extid'],0,4) === 'fb::')
+ $reply = substr($r[0]['extid'],4);
+ else
+ return;
+
+ $u = q("SELECT * FROM user where uid = %d limit 1",
+ intval($b['uid'])
+ );
+ if(! count($u))
+ return;
+
+ // only accept comments from the item owner. Other contacts are unknown to FB.
+
+ if(! link_compare($b['author-link'], $a->get_baseurl() . '/profile/' . $u[0]['nickname']))
+ return;
+
+
+ logger('facebook reply id=' . $reply);
+ }
+
+ if(strstr($b['postopts'],'facebook') || ($b['private']) || ($reply)) {
+
+ if($b['private'] && $reply === false) {
+ $allow_people = expand_acl($b['allow_cid']);
+ $allow_groups = expand_groups(expand_acl($b['allow_gid']));
+ $deny_people = expand_acl($b['deny_cid']);
+ $deny_groups = expand_groups(expand_acl($b['deny_gid']));
+
+ $recipients = array_unique(array_merge($allow_people,$allow_groups));
+ $deny = array_unique(array_merge($deny_people,$deny_groups));
+
+ $allow_str = dbesc(implode(', ',$recipients));
+ if($allow_str) {
+ $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $allow_str ) AND `network` = 'face'");
+ if(count($r))
+ foreach($r as $rr)
+ $allow_arr[] = $rr['notify'];
+ }
+
+ $deny_str = dbesc(implode(', ',$deny));
+ if($deny_str) {
+ $r = q("SELECT `notify` FROM `contact` WHERE `id` IN ( $deny_str ) AND `network` = 'face'");
+ if(count($r))
+ foreach($r as $rr)
+ $deny_arr[] = $rr['notify'];
+ }
+
+ if(count($deny_arr) && (! count($allow_arr))) {
+
+ // One or more FB folks were denied access but nobody on FB was specifically allowed access.
+ // This might cause the post to be open to public on Facebook, but only to selected members
+ // on another network. Since this could potentially leak a post to somebody who was denied,
+ // we will skip posting it to Facebook with a slightly vague but relevant message that will
+ // hopefully lead somebody to this code comment for a better explanation of what went wrong.
+
+ notice( t('Post to Facebook cancelled because of multi-network access permission conflict.') . EOL);
+ return;
+ }
+
+
+ // if it's a private message but no Facebook members are allowed or denied, skip Facebook post
+
+ if((! count($allow_arr)) && (! count($deny_arr)))
+ return;
+ }
+
+ if($b['verb'] == ACTIVITY_LIKE)
+ $likes = true;
+
+
+ $appid = get_config('facebook', 'appid' );
+ $secret = get_config('facebook', 'appsecret' );
+
+ if($appid && $secret) {
+
+ logger('facebook: have appid+secret');
+
+ $fb_token = get_pconfig($b['uid'],'facebook','access_token');
+
+
+ // post to facebook if it's a public post and we've ticked the 'post to Facebook' box,
+ // or it's a private message with facebook participants
+ // or it's a reply or likes action to an existing facebook post
+
+ if($fb_token && ($toplevel || $b['private'] || $reply)) {
+ logger('facebook: able to post');
+ require_once('library/facebook.php');
+ require_once('include/bbcode.php');
+
+ $msg = $b['body'];
+
+ logger('Facebook post: original msg=' . $msg, LOGGER_DATA);
+
+ // make links readable before we strip the code
+
+ // unless it's a dislike - just send the text as a comment
+
+ // if($b['verb'] == ACTIVITY_DISLIKE)
+ // $msg = trim(strip_tags(bbcode($msg)));
+
+ // Old code
+ /*$search_str = $a->get_baseurl() . '/search';
+
+ if(preg_match("/\[url=(.*?)\](.*?)\[\/url\]/is",$msg,$matches)) {
+
+ // don't use hashtags for message link
+
+ if(strpos($matches[2],$search_str) === false) {
+ $link = $matches[1];
+ if(substr($matches[2],0,5) != '[img]')
+ $linkname = $matches[2];
+ }
+ }
+
+ // strip tag links to avoid link clutter, this really should be
+ // configurable because we're losing information
+
+ $msg = preg_replace("/\#\[url=(.*?)\](.*?)\[\/url\]/is",'#$2',$msg);
+
+ // provide the link separately for normal links
+ $msg = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/is",'$2 $1',$msg);
+
+ if(preg_match("/\[img\](.*?)\[\/img\]/is",$msg,$matches))
+ $image = $matches[1];
+
+ $msg = preg_replace("/\[img\](.*?)\[\/img\]/is", t('Image: ') . '$1', $msg);
+
+ if((strpos($link,z_root()) !== false) && (! $image))
+ $image = $a->get_baseurl() . '/images/friendica-64.jpg';
+
+ $msg = trim(strip_tags(bbcode($msg)));*/
+
+ // New code
+
+ // Looking for the first image
+ $image = '';
+ if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$b['body'],$matches))
+ $image = $matches[3];
+
+ if ($image == '')
+ if(preg_match("/\[img\](.*?)\[\/img\]/is",$b['body'],$matches))
+ $image = $matches[1];
+
+ // When saved into the database the content is sent through htmlspecialchars
+ // That means that we have to decode all image-urls
+ $image = htmlspecialchars_decode($image);
+
+ // Checking for a bookmark element
+ $body = $b['body'];
+ if (strpos($body, "[bookmark") !== false) {
+ // splitting the text in two parts:
+ // before and after the bookmark
+ $pos = strpos($body, "[bookmark");
+ $body1 = substr($body, 0, $pos);
+ $body2 = substr($body, $pos);
+
+ // Removing the bookmark and all quotes after the bookmark
+ // they are mostly only the content after the bookmark.
+ $body2 = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",'',$body2);
+ $body2 = preg_replace("/\[quote\=([^\]]*)\](.*?)\[\/quote\]/ism",'',$body2);
+ $body2 = preg_replace("/\[quote\](.*?)\[\/quote\]/ism",'',$body2);
+
+ $body = $body1.$body2;
+ }
+
+ // Convert recycle signs
+ $body = str_replace("\t", " ", $body);
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body);
+ // recycle 2 (Test)
+ $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
+ $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n\t$2:\t", $body);
+
+ // share element
+ $body = preg_replace_callback("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]/ism","fbpost_ShareAttributes", $body);
+
+ $bodyparts = explode("\t", $body);
+ // Doesn't help with multiple repeats - the problem has to be solved later
+ if (sizeof($bodyparts) == 3) {
+ $html = bbcode($bodyparts[2], false, false);
+ $test = trim(html2plain($html, 0, true));
+
+ if (trim($bodyparts[0]) == "")
+ $body = trim($bodyparts[2]);
+ else if (trim($test) == "")
+ $body = trim($bodyparts[0]);
+ else
+ $body = trim($bodyparts[0])."\n\n".trim($bodyparts[1])."[quote]".trim($bodyparts[2])."[/quote]";
+ } else
+ $body = str_replace("\t", "", $body);
+
+ // At first convert the text to html
+ $html = bbcode($body, false, false);
+
+ // Then convert it to plain text
+ $msg = trim($b['title']." \n\n".html2plain($html, 0, true));
+
+ // Removing useless spaces
+ if (substr($msg, -2) == "«")
+ $msg = trim(substr($msg, 0, -2))."«";
+
+ $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
+
+ // Removing multiple newlines
+ while (strpos($msg, "\n\n\n") !== false)
+ $msg = str_replace("\n\n\n", "\n\n", $msg);
+
+ // add any attachments as text urls
+ $arr = explode(',',$b['attach']);
+
+ if(count($arr)) {
+ $msg .= "\n";
+ foreach($arr as $r) {
+ $matches = false;
+ $cnt = preg_match('|\[attach\]href=\"(.*?)\" size=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
+ if($cnt) {
+ $msg .= "\n".$matches[1];
+ }
+ }
+ }
+
+ $link = '';
+ $linkname = '';
+ // look for bookmark-bbcode and handle it with priority
+ if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches)) {
+ $link = $matches[1];
+ $linkname = $matches[2];
+ }
+
+ // If there is no bookmark element then take the first link
+ if ($link == '') {
+ $links = collecturls($html);
+ if (sizeof($links) > 0) {
+ reset($links);
+ $link = current($links);
+ }
+ }
+
+ // Remove trailing and leading spaces
+ $msg = trim($msg);
+
+
+ // Fallback - if message is empty
+ if(!strlen($msg))
+ $msg = $linkname;
+
+ if(!strlen($msg))
+ $msg = $link;
+
+ if(!strlen($msg))
+ $msg = $image;
+
+ // If there is nothing to post then exit
+ if(!strlen($msg))
+ return;
+
+ logger('Facebook post: msg=' . $msg, LOGGER_DATA);
+
+ $video = "";
+
+ if($likes) {
+ $postvars = array('access_token' => $fb_token);
+ } else {
+ // message, picture, link, name, caption, description, source, place, tags
+ if(trim($link) != "")
+ if (@exif_imagetype($link) != 0) {
+ $image = $link;
+ $link = "";
+ }
+
+ $postvars = array(
+ 'access_token' => $fb_token,
+ 'message' => $msg
+ );
+ if(trim($image) != "")
+ $postvars['picture'] = $image;
+
+ if(trim($link) != "") {
+ $postvars['link'] = $link;
+
+ if ((stristr($link,'youtube')) || (stristr($link,'youtu.be')) || (stristr($link,'vimeo'))) {
+ $video = $link;
+ }
+ }
+ if(trim($linkname) != "")
+ $postvars['name'] = $linkname;
+ }
+
+ if(($b['private']) && ($toplevel)) {
+ $postvars['privacy'] = '{"value": "CUSTOM", "friends": "SOME_FRIENDS"';
+ if(count($allow_arr))
+ $postvars['privacy'] .= ',"allow": "' . implode(',',$allow_arr) . '"';
+ if(count($deny_arr))
+ $postvars['privacy'] .= ',"deny": "' . implode(',',$deny_arr) . '"';
+ $postvars['privacy'] .= '}';
+
+ }
+
+ $post_to_page = get_pconfig($b['uid'],'facebook','post_to_page');
+ $page_access_token = get_pconfig($b['uid'],'facebook','page_access_token');
+ if ((intval($post_to_page) != 0) and ($page_access_token != ""))
+ $target = $post_to_page;
+ else
+ $target = "me";
+
+ if($reply) {
+ $url = 'https://graph.facebook.com/' . $reply . '/' . (($likes) ? 'likes' : 'comments');
+ } else if (($video != "") or (($image == "") and ($link != ""))) {
+ // If it is a link to a video or a link without a preview picture then post it as a link
+ if ($video != "")
+ $link = $video;
+
+ $postvars = array(
+ 'access_token' => $fb_token,
+ 'link' => $link,
+ );
+ if ($msg != $video)
+ $postvars['message'] = $msg;
+
+ $url = 'https://graph.facebook.com/'.$target.'/links';
+ } else if (($link == "") and ($image != "")) {
+ // If it is only an image without a page link then post this image as a photo
+ $postvars = array(
+ 'access_token' => $fb_token,
+ 'url' => $image,
+ );
+ if ($msg != $image)
+ $postvars['message'] = $msg;
+
+ $url = 'https://graph.facebook.com/'.$target.'/photos';
+ } else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
+ $url = 'https://graph.facebook.com/'.$target.'/feed';
+ if (!get_pconfig($b['uid'],'facebook','suppress_view_on_friendica') and $b['plink'])
+ $postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
+ } else {
+ // if its only a message and a subject and the message is larger than 500 characters then post it as note
+ $postvars = array(
+ 'access_token' => $fb_token,
+ 'message' => bbcode($b['body'], false, false),
+ 'subject' => $b['title'],
+ );
+ $url = 'https://graph.facebook.com/'.$target.'/notes';
+ }
+
+ // Post to page?
+ if (!$reply and ($target != "me") and $page_access_token)
+ $postvars['access_token'] = $page_access_token;
+
+ logger('facebook: post to ' . $url);
+ logger('facebook: postvars: ' . print_r($postvars,true));
+
+ // "test_mode" prevents anything from actually being posted.
+ // Otherwise, let's do it.
+
+ if(! get_config('facebook','test_mode')) {
+ $x = post_url($url, $postvars);
+ logger('Facebook post returns: ' . $x, LOGGER_DEBUG);
+
+ $retj = json_decode($x);
+ if($retj->id) {
+ q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc('fb::' . $retj->id),
+ intval($b['id'])
+ );
+ }
+ else {
+ if(! $likes) {
+ $s = serialize(array('url' => $url, 'item' => $b['id'], 'post' => $postvars));
+ require_once('include/queue_fn.php');
+ add_to_queue($a->contact,NETWORK_FACEBOOK,$s);
+ notice( t('Facebook post failed. Queued for retry.') . EOL);
+ }
+
+ if (isset($retj->error) && $retj->error->type == "OAuthException" && $retj->error->code == 190) {
+ logger('Facebook session has expired due to changed password.', LOGGER_DEBUG);
+
+ $last_notification = get_pconfig($b['uid'], 'facebook', 'session_expired_mailsent');
+ if (!$last_notification || $last_notification < (time() - FACEBOOK_SESSION_ERR_NOTIFICATION_INTERVAL)) {
+ require_once('include/enotify.php');
+
+ $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($b['uid']) );
+ notification(array(
+ 'uid' => $b['uid'],
+ 'type' => NOTIFY_SYSTEM,
+ 'system_type' => 'facebook_connection_invalid',
+ 'language' => $r[0]['language'],
+ 'to_name' => $r[0]['username'],
+ 'to_email' => $r[0]['email'],
+ 'source_name' => t('Administrator'),
+ 'source_link' => $a->config["system"]["url"],
+ 'source_photo' => $a->config["system"]["url"] . '/images/person-80.jpg',
+ ));
+
+ set_pconfig($b['uid'], 'facebook', 'session_expired_mailsent', time());
+ } else logger('Facebook: No notification, as the last one was sent on ' . $last_notification, LOGGER_DEBUG);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/**
+ * @param App $app
+ * @param object $data
+ */
+function fbpost_enotify(&$app, &$data) {
+ if (x($data, 'params') && $data['params']['type'] == NOTIFY_SYSTEM && x($data['params'], 'system_type') && $data['params']['system_type'] == 'facebook_connection_invalid') {
+ $data['itemlink'] = '/facebook';
+ $data['epreamble'] = $data['preamble'] = t('Your Facebook connection became invalid. Please Re-authenticate.');
+ $data['subject'] = t('Facebook connection became invalid');
+ $data['body'] = sprintf( t("Hi %1\$s,\n\nThe connection between your accounts on %2\$s and Facebook became invalid. This usually happens after you change your Facebook-password. To enable the connection again, you have to %3\$sre-authenticate the Facebook-connector%4\$s."), $data['params']['to_name'], "[url=" . $app->config["system"]["url"] . "]" . $app->config["sitename"] . "[/url]", "[url=" . $app->config["system"]["url"] . "/facebook]", "[/url]");
+ }
+}
+
+/**
+ * @param App $a
+ * @param object $b
+ */
+function fbpost_post_local(&$a,&$b) {
+
+ // Figure out if Facebook posting is enabled for this post and file it in 'postopts'
+ // where we will discover it during background delivery.
+
+ // This can only be triggered by a local user posting to their own wall.
+
+ if((local_user()) && (local_user() == $b['uid'])) {
+
+ $fb_post = intval(get_pconfig(local_user(),'facebook','post'));
+ $fb_enable = (($fb_post && x($_REQUEST,'facebook_enable')) ? intval($_REQUEST['facebook_enable']) : 0);
+
+ // if API is used, default to the chosen settings
+ // but allow a specific override
+
+ if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'facebook','post_by_default'))) {
+ if(! x($_REQUEST,'facebook_enable'))
+ $fb_enable = 1;
+ }
+
+ if(! $fb_enable)
+ return;
+
+ if(strlen($b['postopts']))
+ $b['postopts'] .= ',';
+ $b['postopts'] .= 'facebook';
+ }
+}
+
+
+/**
+ * @param App $a
+ * @param object $b
+ */
+function fbpost_queue_hook(&$a,&$b) {
+
+ $qi = q("SELECT * FROM `queue` WHERE `network` = '%s'",
+ dbesc(NETWORK_FACEBOOK)
+ );
+ if(! count($qi))
+ return;
+
+ require_once('include/queue_fn.php');
+
+ foreach($qi as $x) {
+ if($x['network'] !== NETWORK_FACEBOOK)
+ continue;
+
+ logger('facebook_queue: run');
+
+ $r = q("SELECT `user`.* FROM `user` LEFT JOIN `contact` on `contact`.`uid` = `user`.`uid`
+ WHERE `contact`.`self` = 1 AND `contact`.`id` = %d LIMIT 1",
+ intval($x['cid'])
+ );
+ if(! count($r))
+ continue;
+
+ $user = $r[0];
+
+ $appid = get_config('facebook', 'appid' );
+ $secret = get_config('facebook', 'appsecret' );
+
+ if($appid && $secret) {
+ $fb_post = intval(get_pconfig($user['uid'],'facebook','post'));
+ $fb_token = get_pconfig($user['uid'],'facebook','access_token');
+
+ if($fb_post && $fb_token) {
+ logger('facebook_queue: able to post');
+ require_once('library/facebook.php');
+
+ $z = unserialize($x['content']);
+ $item = $z['item'];
+ $j = post_url($z['url'],$z['post']);
+
+ $retj = json_decode($j);
+ if($retj->id) {
+ q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc('fb::' . $retj->id),
+ intval($item)
+ );
+ logger('facebook_queue: success: ' . $j);
+ remove_queue_item($x['id']);
+ }
+ else {
+ logger('facebook_queue: failed: ' . $j);
+ update_queue_time($x['id']);
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * @return bool|string
+ */
+function fbpost_get_app_access_token() {
+
+ $acc_token = get_config('facebook','app_access_token');
+
+ if ($acc_token !== false) return $acc_token;
+
+ $appid = get_config('facebook','appid');
+ $appsecret = get_config('facebook', 'appsecret');
+
+ if ($appid === false || $appsecret === false) {
+ logger('fb_get_app_access_token: appid and/or appsecret not set', LOGGER_DEBUG);
+ return false;
+ }
+ logger('https://graph.facebook.com/oauth/access_token?client_id=' . $appid . '&client_secret=' . $appsecret . '&grant_type=client_credentials', LOGGER_DATA);
+ $x = fetch_url('https://graph.facebook.com/oauth/access_token?client_id=' . $appid . '&client_secret=' . $appsecret . '&grant_type=client_credentials');
+
+ if(strpos($x,'access_token=') !== false) {
+ logger('fb_get_app_access_token: returned access token: ' . $x, LOGGER_DATA);
+
+ $token = str_replace('access_token=', '', $x);
+ if(strpos($token,'&') !== false)
+ $token = substr($token,0,strpos($token,'&'));
+
+ if ($token == "") {
+ logger('fb_get_app_access_token: empty token: ' . $x, LOGGER_DEBUG);
+ return false;
+ }
+ set_config('facebook','app_access_token',$token);
+ return $token;
+ } else {
+ logger('fb_get_app_access_token: response did not contain an access_token: ' . $x, LOGGER_DATA);
+ return false;
+ }
+}
+
diff --git a/fortunate.tgz b/fortunate.tgz
new file mode 100644
index 000000000..a2dd39d92
Binary files /dev/null and b/fortunate.tgz differ
diff --git a/fortunate/README b/fortunate/README
new file mode 100644
index 000000000..8297cf417
--- /dev/null
+++ b/fortunate/README
@@ -0,0 +1,7 @@
+This addon requires a fortune server. You may use the DB supplied here to create one.
+
+gunzip the fortunate.sql.gz and import into your database.
+Copy cookie.php to the top level Friendica directory.
+Edit fortunate.php and change FORTUNATE_SERVER definition to your hostname. Change the http in that file to https if your server doesn't support http.
+
+Many additional options are available if you examine cookie.php - a clever developer can provide a settings page to tailor this to one's liking. Also several languages are supported, and it would be convenient to set this to the current Friendica language if that is amongst those supported.
\ No newline at end of file
diff --git a/fortunate/cookie.php b/fortunate/cookie.php
new file mode 100644
index 000000000..0acfa2302
--- /dev/null
+++ b/fortunate/cookie.php
@@ -0,0 +1,349 @@
+real_escape_string($_GET['lang']);
+
+if(strlen($_GET['pattern']))
+ $pattern = @$db->real_escape_string(urldecode($_GET['pattern']));
+
+if(strlen($_GET['regex']))
+ $regex = @$db->real_escape_string(urldecode($_GET['regex']));
+
+if(strlen($_GET['db']))
+ $table = @$db->real_escape_string(urldecode($_GET['db']));
+else
+ $table = '';
+
+if($length < 0)
+ $length = 0;
+if($numlines < 0)
+ $numlines = 0;
+
+function do_query($table,$length,$numlines,$adult,$cat,$limit,$lang,$pattern,$regex,$equal) {
+ global $db;
+ $rnd = mt_rand();
+ $r = array();
+
+ $typesql = (($table) ? " WHERE `category` = '$table' " : " WHERE 1 ");
+ $lengthsql = (($length) ? " AND LENGTH(`text`) < $length " : "" );
+
+ if($adult == 2)
+ $adultsql = " AND offensive = 1 ";
+ elseif($adult == 1)
+ $adultsql = "";
+ else
+ $adultsql = " AND offensive = 0 ";
+
+
+ if($numlines)
+ $lengthsql .=
+ " AND (LENGTH(`text`) - LENGTH(REPLACE(`text`,\"\n\",\"\"))) <= $numlines ";
+
+ $langsql = " AND lang = '$lang' ";
+
+ $patsql = '';
+ if(strlen($pattern))
+ $patsql = " AND MATCH text AGAINST ('$pattern' IN BOOLEAN MODE) ";
+
+ $regexsql = '';
+ if(strlen($regex))
+ $regexsql = " AND text REGEXP '$regex' ";
+
+ $eqsql = '';
+
+ if($equal) {
+ $catsavail = array();
+ $res = @$db->query("SELECT DISTINCT ( `category` ) FROM `fortune`
+ $typesql
+ $adultsql
+ $lengthsql
+ $langsql
+ $patsql
+ $regexsql ");
+ if($res->num_rows) {
+ while($x = $res->fetch_array(MYSQL_ASSOC))
+ $catsavail[] = $x['category'];
+
+ $eqsql = " AND `category` = '"
+ . $catsavail[mt_rand(0,$res->num_rows - 1)] . "' ";
+ }
+ }
+
+ $result = @$db->query("SELECT `text`, `category` FROM `fortune`
+ $typesql
+ $adultsql
+ $lengthsql
+ $langsql
+ $patsql
+ $regexsql
+ $eqsql
+ ORDER BY RAND($rnd)
+ LIMIT $limit");
+
+ if($result->num_rows) {
+ while($x = $result->fetch_array(MYSQL_ASSOC))
+ $r[] = fortune_to_html($x['text'])
+ .(($cat) ? " [{$x['category']}] " : "");
+ }
+ return $r;
+}
+
+
+function do_stats($table,$length,$numlines,$adult,$cat,$limit,$lang,$pattern,$regex,$equal) {
+ global $db;
+ $rnd = mt_rand();
+ $r = array();
+
+ $typesql = (($table) ? " WHERE `category` = '$table' " : " WHERE 1 ");
+ $lengthsql = (($length) ? " AND LENGTH(`text`) < $length " : "" );
+
+ if($adult == 2)
+ $adultsql = " AND offensive = 1 ";
+ elseif($adult == 1)
+ $adultsql = "";
+ else
+ $adultsql = " AND offensive = 0 ";
+
+
+ if($numlines)
+ $lengthsql .=
+ " AND (LENGTH(`text`) - LENGTH(REPLACE(`text`,\"\n\",\"\"))) <= $numlines ";
+
+ $langsql = " AND lang = '$lang' ";
+
+ $patsql = '';
+ if(strlen($pattern))
+ $patsql = " AND MATCH text AGAINST ('$pattern' IN BOOLEAN MODE) ";
+
+ $regexsql = '';
+ if(strlen($regex))
+ $regexsql = " AND text REGEXP '$regex' ";
+
+ $eqsql = '';
+
+ $result = @$db->query("SELECT `text`, `category` FROM `fortune`
+ $typesql
+ $adultsql
+ $lengthsql
+ $langsql
+ $patsql
+ $regexsql
+ $eqsql");
+
+
+ echo ' ' . $result->num_rows . ' matching quotations. ';
+
+
+ $res = @$db->query("SELECT DISTINCT ( `category` ) FROM `fortune`
+ $typesql
+ $adultsql
+ $lengthsql
+ $langsql
+ $patsql
+ $regexsql ");
+ if($res->num_rows) {
+ echo ' Matching Databases: ';
+ while($x = $res->fetch_array(MYSQL_ASSOC))
+ echo $x['category'].' ';
+
+ }
+ else
+ echo ' No matching databases using those search parameters - please refine your options. ';
+
+
+}
+
+
+function fortune_to_html($s) {
+
+ // First pass - escape all the HTML entities, and while we're at it
+ // get rid of any MS-DOS end-of-line characters and expand tabs to
+ // 8 non-breaking spaces, and translate linefeeds to .
+ // We also get rid of ^G which used to sound the terminal beep or bell
+ // on ASCII terminals and were humourous in some fortunes.
+ // We could map these to autoplay a short sound file but browser support
+ // is still sketchy and then there's the issue of where to locate the
+ // URL, and a lot of people find autoplay sounds downright annoying.
+ // So for now, just remove them.
+
+ $s = str_replace(
+ array("&",
+ "<",
+ ">",
+ '"',
+ "\007",
+ "\t",
+ "\r",
+ "\n"),
+
+ array("&",
+ "<",
+ ">",
+ """,
+ "",
+ " ",
+ "",
+ " "),
+ $s);
+ // Replace pseudo diacritics
+ // These were used to produce accented characters. For instance an accented
+ // e would have been encoded by '^He - the backspace moving the cursor
+ // backward so both the single quote and the e would appear in the same
+ // character position. Umlauts were quite clever - they used a double quote
+ // as the accent mark over a normal character.
+
+ $s = preg_replace("/'\010([a-zA-Z])/","&\\1acute;",$s);
+ $s = preg_replace("/\"\010([a-zA-Z])/","&\\1uml;",$s);
+ $s = preg_replace("/\`\010([a-zA-Z])/","&\\1grave;",$s);
+ $s = preg_replace("/\^\010([a-zA-Z])/","&\\1circ;",$s);
+ $s = preg_replace("/\~\010([a-zA-Z])/","&\\1tilde;",$s);
+
+ // Ignore multiple underlines for the same character. These were
+ // most useful when sent to a line printer back in the day as it
+ // would type over the same character a number of times making it
+ // much darker (e.g. bold). I think there are only one or two
+ // instances of this in the current (2008) fortune cookie database.
+
+ $s = preg_replace("/(_\010)+/","_\010",$s);
+ // Map the characters which sit underneath a backspace.
+ // If you can come up with a regex to do all of the following
+ // madness - be my guest.
+ // It's not as simple as you think. We need to take something
+ // that has been backspaced over an arbitrary number of times
+ // and wrap a forward looking matching number of characters in
+ // HTML, whilst deciding if it's intended as an underline or
+ // strikeout sequence.
+
+ // Essentially we produce a string of '1' and '0' characters
+ // the same length as the source text.
+ // Any position which is marked '1' has been backspaced over.
+
+ $cursor = 0;
+ $dst = $s;
+ $bs_found = false;
+ for($x = 0; $x < strlen($s); $x ++) {
+ if($s[$x] == "\010" && $cursor) {
+ $bs_found = true;
+ $cursor --;
+ $dst[$cursor] = '1';
+ $dst[$x] = '0';
+ $continue;
+ }
+ else {
+ if($bs_found) {
+ $bs_found = false;
+ $cursor = $x;
+ }
+ $dst[$cursor] = '0';
+ $cursor ++;
+ }
+
+ }
+
+ $out = '';
+ $strike = false;
+ $bold = false;
+
+ // Underline sequence, convert to bold to avoid confusion with links.
+ // These were generally used for emphasis so it's a reasonable choice.
+ // Please note that this logic will fail if there is an underline sequence
+ // and also a strikeout sequence in the same fortune.
+
+ if(strstr($s,"_\010")) {
+ $len = 0;
+ for($x = 0; $x < strlen($s); $x ++) {
+ if($dst[$x] == '1') {
+ $len ++;
+ $bold = true;
+ }
+ else {
+ if($bold) {
+ $out .= '';
+ while($s[$x] == "\010")
+ $x ++;
+ $out .= substr($s,$x,$len);
+ $out .= ' ';
+ $x = $x + $len - 1;
+ $len = 0;
+ $bold = false;
+ }
+ else
+ $out .= $s[$x];
+ }
+ }
+ }
+
+ // These aren't seen very often these days - simulation of
+ // backspace/replace. You could occasionally see the original text
+ // on slower terminals before it got replaced. Once modems reached
+ // 4800/9600 baud in the late 70's and early 80's the effect was
+ // mostly lost - but if you find a really old fortune file you might
+ // encounter a few of these.
+
+ else {
+ for($x = 0; $x < strlen($s); $x ++) {
+ if($dst[$x] == '1') {
+ if($strike)
+ $out .= $s[$x];
+ else
+ $out .= ''.$s[$x];
+ $strike = true;
+ }
+ else {
+ if($strike)
+ $out .= ' ';
+ $strike = false;
+ $out .= $s[$x];
+ }
+ }
+ }
+
+ // Many of the underline sequences are also wrapped in asterisks,
+ // which was yet another way of marking ASCII as 'bold'.
+ // So if it's an underline sequence, and there are asterisks
+ // on both ends, strip the asterisks as we've already emboldened the text.
+
+ $out = preg_replace('/\*([^<]*<\/strong>)\*/',"\\1",$out);
+
+ // Finally, remove the backspace characters which we don't need anymore.
+
+ return str_replace("\010","",$out);
+}
+
+$result1 = do_query($table,$length,$numlines,$adult,$cat,1,$lang,$pattern,$regex,$equal);
+
+if(count($result1))
+ echo $result1[0];
+
+if($stats)
+ do_stats($table,$length,$numlines,$adult,$cat,1,$lang,$pattern,$regex,$equal);
+
+
diff --git a/fortunate/fortunate.css b/fortunate/fortunate.css
new file mode 100644
index 000000000..61813b7d7
--- /dev/null
+++ b/fortunate/fortunate.css
@@ -0,0 +1,7 @@
+.fortunate {
+ margin-top: 25px;
+ margin-left: 100px;
+ margin-bottom: 25px;
+ color: #000088;
+ font-size: 14px;
+}
\ No newline at end of file
diff --git a/fortunate/fortunate.php b/fortunate/fortunate.php
new file mode 100644
index 000000000..427d620c2
--- /dev/null
+++ b/fortunate/fortunate.php
@@ -0,0 +1,35 @@
+
+ */
+
+// IMPORTANT: SET THIS to your fortunate server
+
+define ('FORTUNATE_SERVER', 'hostname.com');
+
+function fortunate_install() {
+ register_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
+ if(FORTUNATE_SERVER == 'hostname.com' && is_site_admin()) {
+ notice('Fortunate plugin requires configuration. See README');
+ }
+}
+
+function fortunate_uninstall() {
+ unregister_hook('page_end', 'addon/fortunate/fortunate.php', 'fortunate_fetch');
+}
+
+
+function fortunate_fetch(&$a,&$b) {
+
+ $a->page['htmlhead'] .= ' ' . "\r\n";
+
+ if(FORTUNATE_SERVER != 'hostname.com') {
+ $s = fetch_url('http://' . FORTUNATE_SERVER . '/cookie.php?numlines=2&equal=1&rand=' . mt_rand());
+ $b .= '' . $s . '
';
+ }
+}
+
diff --git a/fortunate/fortunemod.sql.gz b/fortunate/fortunemod.sql.gz
new file mode 100644
index 000000000..2ce0e557f
Binary files /dev/null and b/fortunate/fortunemod.sql.gz differ
diff --git a/forumdirectory.tgz b/forumdirectory.tgz
new file mode 100644
index 000000000..249cd2264
Binary files /dev/null and b/forumdirectory.tgz differ
diff --git a/forumdirectory/forumdirectory.css b/forumdirectory/forumdirectory.css
new file mode 100644
index 000000000..c3c848569
--- /dev/null
+++ b/forumdirectory/forumdirectory.css
@@ -0,0 +1,67 @@
+
+section .forumdirectory-item dl {
+ height: auto;
+ overflow: auto;
+}
+
+section .forumdirectory-item dt {
+ float: left;
+ margin-left: 0px;
+ text-align: right;
+ color: #999;
+}
+section .forumdirectory-item dd {
+ float: left;
+ margin-left: 5px;
+}
+.forumdirectory-profile-wrapper {
+ float: left;
+ /*max-height: 178px; */
+ overflow: hidden;
+ width: 500px;
+ margin: 0px 20px;
+}
+.forumdirectory-copy-wrapper {
+ float: left;
+ overflow: hidden;
+}
+
+.forumdirectory-item {
+ float: left;
+ width: 800px;
+ /* height: 200px; */
+ box-shadow: 8px 8px 4px #000;
+ margin-top: 30px;
+ border: solid 1px #222;
+}
+section .forumdirectory-photo-wrapper {
+ float: left;
+ height: 200px;
+ width: 165px;
+}
+
+.forumcontact-name {
+ font-size: 18px;
+ font-weight: bold;
+ margin-bottom: -3px;
+ text-align: left;
+}
+
+.page-type {
+ font-size: 10px;
+ font-style: italic;
+}
+.directory-detailscolumn-wrapper {
+ float: left;
+ width: 305px;
+ margin-right: 10px;
+}
+.directory-profile-wrapper dl {
+ margin-top: 3px;
+ margin-bottom: 3px;
+}
+.directory-profile-title {
+ font-weight: bold;
+ margin-bottom: 3px;
+ font-size: 14px;
+}
diff --git a/forumdirectory/forumdirectory.php b/forumdirectory/forumdirectory.php
new file mode 100644
index 000000000..0d7fbee80
--- /dev/null
+++ b/forumdirectory/forumdirectory.php
@@ -0,0 +1,206 @@
+
+*/
+
+function forumdirectory_install() {
+register_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
+}
+
+function forumdirectory_uninstall() {
+unregister_hook('app_menu', 'addon/forumdirectory/forumdirectory.php', 'forumdirectory_app_menu');
+}
+
+function forumdirectory_module() {
+return;
+}
+
+function forumdirectory_app_menu($a,&$b) {
+$b['app_menu'][] = '';
+}
+
+function forumdirectory_init(&$a) {
+ $a->page['htmlhead'] .= ' ';
+
+ $a->set_pager_itemspage(60);
+
+ if(local_user()) {
+ require_once('include/contact_widgets.php');
+
+ $a->page['aside'] .= findpeople_widget();
+
+ }
+ else
+ unset($_SESSION['theme']);
+
+
+}
+
+
+function forumdirectory_post(&$a) {
+ if(x($_POST,'search'))
+ $a->data['search'] = $_POST['search'];
+}
+
+
+
+function forumdirectory_content(&$a) {
+
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ notice( t('Public access denied.') . EOL);
+ return;
+ }
+
+ $o = '';
+ nav_set_selected('directory');
+
+ if(x($a->data,'search'))
+ $search = notags(trim($a->data['search']));
+ else
+ $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
+
+ $tpl = get_markup_template('directory_header.tpl');
+
+ $globaldir = '';
+ $gdirpath = dirname(get_config('system','directory_submit_url'));
+ if(strlen($gdirpath)) {
+ $globaldir = '';
+ }
+
+ $admin = '';
+
+ $o .= replace_macros($tpl, array(
+ '$search' => $search,
+ '$globaldir' => $globaldir,
+ '$desc' => t('Find on this site'),
+ '$admin' => $admin,
+ '$finding' => (strlen($search) ? '' . t('Finding: ') . "'" . $search . "'" . ' ' : ""),
+ '$sitedir' => t('Site Directory'),
+ '$submit' => t('Find')
+ ));
+
+ if($search)
+ $search = dbesc($search);
+ $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, `user`.`nickname`, `pdesc`, `locality`,`region`,`country-name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
+
+ $publish = ((get_config('system','publish_all')) ? '' : " AND `publish` = 1 " );
+
+
+ $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra ");
+ if(count($r))
+ $a->set_pager_total($r[0]['total']);
+
+ $order = " ORDER BY `name` ASC ";
+
+
+ $r = q("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 AND `page-flags` = 2 $sql_extra $order LIMIT %d , %d ",
+ intval($a->pager['start']),
+ intval($a->pager['itemspage'])
+ );
+ if(count($r)) {
+
+ if(in_array('small', $a->argv))
+ $photo = 'thumb';
+ else
+ $photo = 'photo';
+
+ foreach($r as $rr) {
+
+
+ $profile_link = $a->get_baseurl() . '/profile/' . ((strlen($rr['nickname'])) ? $rr['nickname'] : $rr['profile_uid']);
+
+ $pdesc = (($rr['pdesc']) ? $rr['pdesc'] . ' ' : '');
+
+ $details = '';
+ if(strlen($rr['locality']))
+ $details .= $rr['locality'];
+ if(strlen($rr['region'])) {
+ if(strlen($rr['locality']))
+ $details .= ', ';
+ $details .= $rr['region'];
+ }
+ if(strlen($rr['country-name'])) {
+ if(strlen($details))
+ $details .= ', ';
+ $details .= $rr['country-name'];
+ }
+ if(strlen($rr['dob'])) {
+ if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
+ $details .= ' ' . t('Age: ') . $years ;
+ }
+ if(strlen($rr['gender']))
+ $details .= ' ' . t('Gender: ') . $rr['gender'];
+
+ if($rr['page-flags'] == PAGE_NORMAL)
+ $page_type = "Personal Profile";
+ if($rr['page-flags'] == PAGE_SOAPBOX)
+ $page_type = "Fan Page";
+ if($rr['page-flags'] == PAGE_COMMUNITY)
+ $page_type = "Community Forum";
+ if($rr['page-flags'] == PAGE_FREELOVE)
+ $page_type = "Open Forum";
+ if($rr['page-flags'] == PAGE_PRVGROUP)
+ $page_type = "Private Group";
+
+ $profile = $rr;
+
+ if((x($profile,'address') == 1)
+ || (x($profile,'locality') == 1)
+ || (x($profile,'region') == 1)
+ || (x($profile,'postal-code') == 1)
+ || (x($profile,'country-name') == 1))
+ $location = t('Location:');
+
+ $gender = ((x($profile,'gender') == 1) ? t('Gender:') : False);
+
+ $marital = ((x($profile,'marital') == 1) ? t('Status:') : False);
+
+ $homepage = ((x($profile,'homepage') == 1) ? t('Homepage:') : False);
+
+ $about = ((x($profile,'about') == 1) ? t('About:') : False);
+
+# $tpl = file_get_contents( dirname(__file__).'/forumdirectory_item.tpl');
+ $tpl = get_markup_template( 'forumdirectory_item.tpl', 'addon/forumdirectory/' );
+
+ $entry = replace_macros($tpl,array(
+ '$id' => $rr['id'],
+ '$profile-link' => $profile_link,
+ '$photo' => $a->get_cached_avatar_image($rr[$photo]),
+ '$alt-text' => $rr['name'],
+ '$name' => $rr['name'],
+ '$details' => $pdesc . $details,
+ '$page-type' => $page_type,
+ '$profile' => $profile,
+ '$location' => template_escape($location),
+ '$gender' => $gender,
+ '$pdesc' => $pdesc,
+ '$marital' => $marital,
+ '$homepage' => $homepage,
+ '$about' => $about,
+
+ ));
+
+ $arr = array('contact' => $rr, 'entry' => $entry);
+
+ call_hooks('directory_item', $arr);
+
+ unset($profile);
+ unset($location);
+
+ $o .= $entry;
+
+ }
+
+ $o .= "
\r\n";
+ $o .= paginate($a);
+
+ }
+ else
+ info( t("No entries \x28some entries may be hidden\x29.") . EOL);
+
+ return $o;
+}
diff --git a/forumdirectory/view/forumdirectory_item.tpl b/forumdirectory/view/forumdirectory_item.tpl
new file mode 100755
index 000000000..3b24d25f2
--- /dev/null
+++ b/forumdirectory/view/forumdirectory_item.tpl
@@ -0,0 +1,42 @@
+
+
+
+
+
$name
+
$page-type
+ {{ if $pdesc }}
$profile.pdesc
{{ endif }}
+
+
+ {{ if $location }}
+
$location
+
+ {{ if $profile.address }}$profile.address
{{ endif }}
+
+ $profile.locality {{ if $profile.locality }}, {{ endif }}
+ $profile.region
+ $profile.postal-code
+
+ {{ if $profile.country-name }}$profile.country-name {{ endif }}
+
+
+ {{ endif }}
+
+ {{ if $gender }}
$gender $profile.gender {{ endif }}
+
+
+ {{ if $marital }}
♥ $marital$profile.marital {{ endif }}
+
+ {{ if $homepage }}
$homepage $profile.homepage {{ endif }}
+
+
+
+ {{ if $about }}
$about $profile.about {{ endif }}
+
+
+
diff --git a/forumdirectory/view/smarty3/forumdirectory_item.tpl b/forumdirectory/view/smarty3/forumdirectory_item.tpl
new file mode 100644
index 000000000..540a5aeae
--- /dev/null
+++ b/forumdirectory/view/smarty3/forumdirectory_item.tpl
@@ -0,0 +1,42 @@
+
+
+
+
+
{{$name}}
+
{{$page}}-type
+ {{if $pdesc}}
{{$profile.pdesc}}
{{/if}}
+
+
+ {{if $location}}
+
{{$location}}
+
+ {{if $profile.address}}{{$profile.address}}
{{/if}}
+
+ {{$profile.locality}} {{if $profile.locality}}, {{/if}}
+ {{$profile.region}}
+ {{$profile.postal-code}}
+
+ {{if $profile.country-name}}{{$profile.country-name}} {{/if}}
+
+
+ {{/if}}
+
+ {{if $gender}}
{{$gender}} {{$profile.gender}} {{/if}}
+
+
+ {{if $marital}}
♥ {{$marital}}{{$profile.marital}} {{/if}}
+
+ {{if $homepage}}
{{$homepage}} {{$profile.homepage}} {{/if}}
+
+
+
+ {{if $about}}
{{$about}} {{$profile.about}} {{/if}}
+
+
+
diff --git a/forumlist.tgz b/forumlist.tgz
new file mode 100644
index 000000000..1f303145a
Binary files /dev/null and b/forumlist.tgz differ
diff --git a/forumlist/forumlist.css b/forumlist/forumlist.css
new file mode 100644
index 000000000..18c8e1682
--- /dev/null
+++ b/forumlist/forumlist.css
@@ -0,0 +1,22 @@
+
+#hide-forum-list {
+ opacity: 0.3;
+ filter:alpha(opacity=30);
+}
+
+#hide-forum-list:hover {
+ opacity: 1.0;
+ filter:alpha(opacity=100);
+}
+
+
+#forumlist-settings-label, #forumlist-random-label, #forumlist-profile-label, #forumlist-network-label {
+ float: left;
+ width: 200px;
+ margin-bottom: 25px;
+}
+
+#forumlist-max-forumlists, #forumlist-random, #forumlist-profile, #forumlist-network {
+ float: left;
+}
+
diff --git a/forumlist/forumlist.php b/forumlist/forumlist.php
new file mode 100644
index 000000000..377524629
--- /dev/null
+++ b/forumlist/forumlist.php
@@ -0,0 +1,182 @@
+
+ * based on pages plugin by
+ * Author: Michael Vogel
+ *
+ */
+
+function forumlist_install() {
+ register_hook('network_mod_init', 'addon/forumlist/forumlist.php', 'forumlist_network_mod_init');
+ register_hook('plugin_settings', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings');
+ register_hook('plugin_settings_post', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings_post');
+ register_hook('profile_advanced', 'addon/forumlist/forumlist.php', 'forumlist_profile_advanced');
+
+}
+
+function forumlist_uninstall() {
+ unregister_hook('network_mod_init', 'addon/forumlist/forumlist.php', 'forumlist_network_mod_init');
+ unregister_hook('plugin_settings', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings');
+ unregister_hook('plugin_settings_post', 'addon/forumlist/forumlist.php', 'forumlist_plugin_settings_post');
+ unregister_hook('profile_advanced', 'addon/forumlist/forumlist.php', 'forumlist_profile_advanced');
+
+}
+
+
+function forumlist_getpage($uid,$showhidden = true,$randomise = false, $showprivate = false) {
+
+
+ $forumlist = array();
+
+ $order = (($showhidden) ? '' : " and hidden = 0 ");
+ $order .= (($randomise) ? ' order by rand() ' : ' order by name asc ');
+ $select = "`forum` = 1";
+ if ($showprivate) {
+ $select = "( `forum` = 1 OR `prv` = 1 )";
+ }
+
+ $contacts = q("SELECT `contact`.`id`, `contact`.`url`, `contact`.`name`, `contact`.`micro` from contact
+ WHERE `network`= 'dfrn' AND $select AND `uid` = %d
+ and blocked = 0 and hidden = 0 and pending = 0 and archive = 0
+ $order ",
+ intval($uid)
+ );
+
+ // Look if the profile is a community page
+ foreach($contacts as $contact) {
+ $forumlist[] = array("url"=>$contact["url"], "name"=>$contact["name"], "id"=>$contact["id"], "micro"=>$contact['micro']);
+ }
+ return($forumlist);
+}
+
+function forumlist_network_mod_init($a,$b) {
+
+ if(! intval(get_pconfig(local_user(),'forumlist','show_on_network')))
+ return;
+
+ $a->page['htmlhead'] .= ' ' . "\r\n";
+
+ $forumlist = '";
+ if (sizeof($contacts) > 0)
+ $a->page['aside'] = $forumlist . $a->page['aside'];
+}
+
+
+function forumlist_profile_advanced($a,&$b) {
+ $a->page['htmlhead'] .= ' ' . "\r\n";
+
+ $profile = intval(get_pconfig($a->profile['profile_uid'],'forumlist','show_on_profile'));
+ if(! $profile)
+ return;
+
+ $forumlist = '
+
'.t("Forums:").'
+
';
+
+ // place holder in case somebody wants configurability
+ $show_total = 9999;
+
+ $randomise = true;
+
+ $contacts = forumlist_getpage($a->user['uid'],false,$randomise,false);
+
+ $total_shown = 0;
+ $more = false;
+
+ foreach($contacts as $contact) {
+ $forumlist .= micropro($contact,false,'forumlist-profile-advanced');
+ $total_shown ++;
+ if($total_shown == $show_total)
+ break;
+ }
+ $forumlist .= '
';
+
+ if(count($contacts) > 0)
+ $b .= $forumlist;
+
+}
+
+
+
+function forumlist_plugin_settings_post($a,$post) {
+ if(! local_user() || (! x($_POST,'forumlist-settings-submit')))
+ return;
+// set_pconfig(local_user(),'forumlist','max_forumlists',intval($_POST['forumlist_max_forumlists']));
+ set_pconfig(local_user(),'forumlist','randomise',intval($_POST['forumlist_random']));
+ set_pconfig(local_user(),'forumlist','show_on_profile',intval($_POST['forumlist_profile']));
+ set_pconfig(local_user(),'forumlist','show_on_network',intval($_POST['forumlist_network']));
+
+ info( t('Forumlist settings updated.') . EOL);
+}
+
+
+function forumlist_plugin_settings(&$a,&$s) {
+
+ if(! local_user())
+ return;
+
+ /* Add our stylesheet to the forumlist so we can make our settings look nice */
+
+ $a->page['htmlhead'] .= ' ' . "\r\n";
+
+ /* Get the current state of our config variable */
+
+ $randomise = intval(get_pconfig(local_user(),'forumlist','randomise'));
+ $randomise_checked = (($randomise) ? ' checked="checked" ' : '');
+
+ $profile = intval(get_pconfig(local_user(),'forumlist','show_on_profile'));
+ $profile_checked = (($profile) ? ' checked="checked" ' : '');
+
+ $network = intval(get_pconfig(local_user(),'forumlist','show_on_network'));
+ $network_checked = (($network) ? ' checked="checked" ' : '');
+
+
+ /* Add some HTML to the existing form */
+
+ $s .= '';
+ $s .= '
' . t('Forumlist Settings') . ' ';
+ $s .= '
';
+ $s .= '
' . t('Randomise forum list') . ' ';
+ $s .= '
';
+ $s .= '
';
+ $s .= '
' . t('Show forums on profile page') . ' ';
+ $s .= '
';
+ $s .= '
';
+ $s .= '
' . t('Show forums on network page') . ' ';
+ $s .= '
';
+ $s .= '
';
+
+ $s .= '
';
+
+ /* provide a submit button */
+
+ $s .= '
';
+
+}
+
+
diff --git a/fromapp.tgz b/fromapp.tgz
new file mode 100644
index 000000000..30d84e905
Binary files /dev/null and b/fromapp.tgz differ
diff --git a/fromapp/fromapp.css b/fromapp/fromapp.css
new file mode 100644
index 000000000..422624a1d
--- /dev/null
+++ b/fromapp/fromapp.css
@@ -0,0 +1,14 @@
+
+
+
+#fromapp-label, #fromapp-force-label {
+ float: left;
+ width: 200px;
+ margin-bottom: 25px;
+}
+
+#fromapp-input, #fromapp-force {
+ float: left;
+}
+
+
diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php
new file mode 100644
index 000000000..9a9fa12ba
--- /dev/null
+++ b/fromapp/fromapp.php
@@ -0,0 +1,101 @@
+page['htmlhead'] .= ' ' . "\r\n";
+
+ /* Get the current state of our config variable */
+
+ $fromapp = get_pconfig(local_user(),'fromapp','app');
+ if($fromapp === false)
+ $fromapp = '';
+
+ $force = intval(get_pconfig(local_user(),'fromapp','force'));
+
+ $force_enabled = (($force) ? ' checked="checked" ' : '');
+
+
+ /* Add some HTML to the existing form */
+
+ $s .= '';
+ $s .= '
' . t('FromApp Settings') . ' ';
+ $s .= '
';
+ $s .= '
' . t('The application name you would like to show your posts originating from.') . ' ';
+ $s .= '
';
+ $s .= '
';
+
+ $s .= '
' . t('Use this application name even if another application was used.') . ' ';
+ $s .= '
';
+
+ $s .= '
';
+
+ /* provide a submit button */
+
+ $s .= '
';
+
+}
+
+function fromapp_post_hook(&$a,&$item) {
+ if(! local_user())
+ return;
+
+ if(local_user() != $item['uid'])
+ return;
+
+ $app = get_pconfig(local_user(), 'fromapp', 'app');
+ $force = intval(get_pconfig(local_user(), 'fromapp','force'));
+
+ if(($app === false) || (! strlen($app)))
+ return;
+
+ if(strlen(trim($item['app'])) && (! $force))
+ return;
+
+ $apps = explode(',',$app);
+ $item['app'] = trim($apps[mt_rand(0,count($apps)-1)]);
+ return;
+
+}
\ No newline at end of file
diff --git a/fromgplus.tgz b/fromgplus.tgz
new file mode 100644
index 000000000..0a402b765
Binary files /dev/null and b/fromgplus.tgz differ
diff --git a/fromgplus/README b/fromgplus/README
index cecbb2b9d..82a29f663 100644
--- a/fromgplus/README
+++ b/fromgplus/README
@@ -1 +1,15 @@
-This extension is a preparation of the upcoming import of items via Google+
+This extension fetches messages from a Google+ account and reshares it.
+
+You have to place the following config values in your .htconfig.php:
+
+$a->config['fromgplus']['key'] = "your key";
+$a->config['fromgplus']['poll_interval'] = 10;
+
+You need an API key for "Simple API Access".
+
+- You go to https://code.google.com/apis/console/
+- Then you go to "Services" and activate "Google+ API".
+- After that you go to "API Access".
+- At the bottom of the page you see "Simple API Access".
+
+The value after "API key:" is the key that you need.
diff --git a/fromgplus/fromgplus.php b/fromgplus/fromgplus.php
index 88d2622ff..f7841300f 100644
--- a/fromgplus/fromgplus.php
+++ b/fromgplus/fromgplus.php
@@ -1,20 +1,24 @@
*
*/
+define('FROMGPLUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
+
function fromgplus_install() {
register_hook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
register_hook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
+ register_hook('cron', 'addon/fromgplus/fromgplus.php', 'fromgplus_cron');
}
function fromgplus_uninstall() {
unregister_hook('plugin_settings', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings');
unregister_hook('plugin_settings_post', 'addon/fromgplus/fromgplus.php', 'fromgplus_addon_settings_post');
+ unregister_hook('cron', 'addon/fromgplus/fromgplus.php', 'fromgplus_cron');
}
function fromgplus_addon_settings(&$a,&$s) {
@@ -55,129 +59,324 @@ function fromgplus_addon_settings_post(&$a,&$b) {
info( t('Google+ Import Settings saved.') . EOL);
}
}
-/*
-function html2bbcode($html) {
+
+function fromgplus_cron($a,$b) {
+ $last = get_config('fromgplus','last_poll');
+
+ $poll_interval = intval(get_config('fromgplus','poll_interval'));
+ if(! $poll_interval)
+ $poll_interval = FROMGPLUS_DEFAULT_POLL_INTERVAL;
+
+ if($last) {
+ $next = $last + ($poll_interval * 60);
+ if($next > time()) {
+ logger('fromgplus: poll intervall not reached');
+ return;
+ }
+ }
+
+ logger('fromgplus: cron_start');
+
+ $r = q("SELECT * FROM `pconfig` WHERE `cat` = 'fromgplus' AND `k` = 'enable' AND `v` = '1' ORDER BY RAND() ");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $account = get_pconfig($rr['uid'],'fromgplus','account');
+ if ($account) {
+ logger('fromgplus: fetching for user '.$rr['uid']);
+ fromgplus_fetch($a, $rr['uid']);
+ }
+ }
+ }
+
+ logger('fromgplus: cron_end');
+
+ set_config('fromgplus','last_poll', time());
+}
+
+function fromgplus_post($a, $uid, $source, $body, $location) {
+
+ //$uid = 2;
+
+ $body = trim($body);
+
+ if (substr($body, 0, 3) == "[b]") {
+ $pos = strpos($body, "[/b]");
+ $title = substr($body, 3, $pos-3);
+ $body = trim(substr($body, $pos+4));
+ } else
+ $title = "";
+
+ $_SESSION['authenticated'] = true;
+ $_SESSION['uid'] = $uid;
+
+ $_REQUEST['type'] = 'wall';
+ $_REQUEST['api_source'] = true;
+
+ $_REQUEST['profile_uid'] = $uid;
+ $_REQUEST['source'] = $source;
+
+ // $_REQUEST['verb']
+ // $_REQUEST['parent']
+ // $_REQUEST['parent_uri']
+
+ $_REQUEST['title'] = $title;
+ $_REQUEST['body'] = $body;
+ $_REQUEST['location'] = $location;
+
+ logger('fromgplus: posting for user '.$uid);
+
+ require_once('mod/item.php');
+ //print_r($_REQUEST);
+ item_post($a);
+}
+
+function fromgplus_html2bbcode($html) {
$bbcode = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
- $bbcode = str_replace(array("\n"), array(""), $bbcode);
- $bbcode = str_replace(array("", " "), array("[b]", "[/b]"), $bbcode);
- $bbcode = str_replace(array("", " "), array("[i]", "[/i]"), $bbcode);
- $bbcode = str_replace(array("", " "), array("[s]", "[/s]"), $bbcode);
- $bbcode = str_replace(array(" "), array("\n"), $bbcode);
+ $bbcode = str_ireplace(array("\n"), array(""), $bbcode);
+ $bbcode = str_ireplace(array("", " "), array("[b]", "[/b]"), $bbcode);
+ $bbcode = str_ireplace(array("", " "), array("[i]", "[/i]"), $bbcode);
+ $bbcode = str_ireplace(array("", " "), array("[s]", "[/s]"), $bbcode);
+ $bbcode = str_ireplace(array(" "), array("\n"), $bbcode);
+ $bbcode = str_ireplace(array(" "), array("\n"), $bbcode);
+ $bbcode = str_ireplace(array(" "), array("\n"), $bbcode);
$bbcode = trim(strip_tags($bbcode));
return($bbcode);
}
-function friendicapost($post) {
- global $friendica;
+function fromgplus_parse_query($var)
+ {
+ /**
+ * Use this function to parse out the query array element from
+ * the output of parse_url().
+ */
+ $var = parse_url($var, PHP_URL_QUERY);
+ $var = html_entity_decode($var);
+ $var = explode('&', $var);
+ $arr = array();
- $api = new Statusnet($friendica["user"], $friendica["pw"], "GooglePlus", $friendica["server"]);
- $ret = $api->updateStatus($post);
- $api->endSession();
+ foreach($var as $val) {
+ $x = explode('=', $val);
+ $arr[$x[0]] = $x[1];
+ }
+ unset($val, $x, $var);
+ return $arr;
}
-function handleattachments($item) {
+function fromgplus_cleanupgoogleproxy($fullImage, $image) {
+
+ $preview = "/w".$fullImage->width."-h".$fullImage->height."/";
+ $preview2 = "/w".$fullImage->width."-h".$fullImage->height."-p/";
+ $fullImage = str_replace(array($preview, $preview2), array("/", "/"), $fullImage->url);
+
+ $preview = "/w".$image->width."-h".$image->height."/";
+ $preview2 = "/w".$image->width."-h".$image->height."-p/";
+ $image = str_replace(array($preview, $preview2), array("/", "/"), $image->url);
+
+ $cleaned = array();
+
+ $queryvar = fromgplus_parse_query($fullImage);
+ if ($queryvar['url'] != "")
+ $cleaned["full"] = urldecode($queryvar['url']);
+ else
+ $cleaned["full"] = $fullImage;
+ if (@exif_imagetype($cleaned["full"]) == 0)
+ $cleaned["full"] = "";
+
+ $queryvar = fromgplus_parse_query($image);
+ if ($queryvar['url'] != "")
+ $cleaned["preview"] = urldecode($queryvar['url']);
+ else
+ $cleaned["preview"] = $image;
+ if (@exif_imagetype($cleaned["preview"]) == 0)
+ $cleaned["preview"] = "";
+
+ if ($cleaned["full"] == "") {
+ $cleaned["full"] = $cleaned["preview"];
+ $cleaned["preview"] = "";
+ }
+
+ if ($cleaned["full"] == $cleaned["preview"])
+ $cleaned["preview"] = "";
+
+ if ($cleaned["full"] == "")
+ if (@exif_imagetype($fullImage) != 0)
+ $cleaned["full"] = $fullImage;
+
+ if ($cleaned["full"] == "")
+ if (@exif_imagetype($image) != 0)
+ $cleaned["full"] = $fullImage;
+
+ return($cleaned);
+}
+
+function fromgplus_handleattachments($item) {
$post = "";
+ $quote = "";
foreach ($item->object->attachments as $attachment) {
switch($attachment->objectType) {
case "video":
- //$post .= "\n\n[url=".$attachment->url."]".
- // "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n";
- $post .= "\n\n[bookmark=".$attachment->url."]".html2bbcode($attachment->displayName)."[/bookmark]\n";
+ $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
- //if (strpos($attachment->embed->url, "youtube.com"))
- // $post .= "[youtube]".$attachment->url."[/youtube]\n";
- //else
- /// $post .= "[url=".$attachment->url."][img]".$attachment->image->url."[/img][/url]\n";
+ /*$images = cleanupgoogleproxy($attachment->fullImage, $attachment->image);
+ if ($images["preview"] != "")
+ $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
+ elseif ($images["full"] != "")
+ $post .= "\n[img]".$images["full"]."[/img]\n";*/
- ///$post .= "[quote]".trim(html2bbcode($attachment->content))."[/quote]";
break;
case "article":
- //$post .= "\n\n[url=".$attachment->url."]".
- // "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n";
- $post .= "\n\n[bookmark=".$attachment->url."]".html2bbcode($attachment->displayName)."[/bookmark]\n";
- $post .= "[quote]".trim(html2bbcode($attachment->content))."[/quote]";
+ $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
+
+ $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
+ if ($images["preview"] != "")
+ $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
+ elseif ($images["full"] != "")
+ $post .= "\n[img]".$images["full"]."[/img]\n";
+
+ //$post .= "[quote]".trim(fromgplus_html2bbcode($attachment->content))."[/quote]";
+ $quote = trim(fromgplus_html2bbcode($attachment->content));
+ if ($quote != "")
+ $quote = "\n[quote]".$quote."[/quote]";
break;
case "photo":
- //$post .= "\n\n[url=".$attachment->fullImage->url."]".
- // "[img]".$attachment->fullImage->url."[/img][/url]\n";
- $post .= "\n\n[img]".$attachment->fullImage->url."[/img]\n";
+ $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
+ if ($images["preview"] != "")
+ $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
+ elseif ($images["full"] != "")
+ $post .= "\n[img]".$images["full"]."[/img]\n";
+
if ($attachment->displayName != "")
- $post .= html2bbcode($attachment->displayName)."\n";
+ $post .= fromgplus_html2bbcode($attachment->displayName)."\n";
break;
case "photo-album":
- $post .= "\n\n[url=".$attachment->url."]".
- "[size=large][b]".html2bbcode($attachment->displayName)."[/b][/size][/url]\n";
+ $post .= "\n\n[bookmark=".$attachment->url."]".fromgplus_html2bbcode($attachment->displayName)."[/bookmark]\n";
+
+ $images = fromgplus_cleanupgoogleproxy($attachment->fullImage, $attachment->image);
+ if ($images["preview"] != "")
+ $post .= "\n[url=".$images["full"]."][img]".$images["preview"]."[/img][/url]\n";
+ elseif ($images["full"] != "")
+ $post .= "\n[img]".$images["full"]."[/img]\n";
+
break;
- default:
- print_r($attachment);
- die();
+ case "album":
+ foreach($attachment->thumbnails as $thumb) {
+ $preview = "/w".$thumb->image->width."-h".$thumb->image->height."/";
+ $preview2 = "/w".$thumb->image->width."-h".$thumb->image->height."-p/";
+ $image = str_replace(array($preview, $preview2), array("/", "/"), $thumb->image->url);
+
+ $post .= "\n[url=".$thumb->url."][img]".$image."[/img][/url]\n";
+ }
break;
+ //default:
+ // die($attachment->objectType);
}
}
- return($post);
+ return($post.$quote);
}
-$result =
-file_get_contents("https://www.googleapis.com/plus/v1/people/".$google["id"]."/activities/public?alt=json&pp=1&key=".$google["key"]."&maxResults=".$google["maxfetch"]);
-$activities = json_decode($result);
+function fromgplus_fetch($a, $uid) {
+ $maxfetch = 20;
-$state = array("lastid"=>'');
-if (file_exists($statefile))
- $state = unserialize(file_get_contents($statefile));
+ $account = get_pconfig($uid,'fromgplus','account');
+ $key = get_config('fromgplus','key');
-$lastid = "";
+ $result = fetch_url("https://www.googleapis.com/plus/v1/people/".$account."/activities/public?alt=json&pp=1&key=".$key."&maxResults=".$maxfetch);
+ //$result = file_get_contents("google.txt");
+ //file_put_contents("google.txt", $result);
-foreach($activities->items as $item) {
- if ($item->id == $state["lastid"])
- break;
+ $activities = json_decode($result);
- if ($lastid == "")
- $lastid = $item->id;
+ $initiallastdate = get_pconfig($uid,'fromgplus','lastdate');
- switch($item->object->objectType) {
- case "note":
- $post = html2bbcode($item->object->content);
+ $lastdate = 0;
- if (is_array($item->object->attachments))
- $post .= handleattachments($item);
- friendicapost($post);
- break;
+ $reversed = array_reverse($activities->items);
- case "activity":
- $post = html2bbcode($item->annotation)."\n";
- //$post .= html2bbcode("♲ ");
- $post .= html2bbcode("♻ ");
- $post .= "[url=".$item->object->actor->url."]".$item->object->actor->displayName."[/url]";
- $post .= " \n";
- //$post .= "[quote]";
+ foreach($reversed as $item) {
+ if (strtotime($item->published) <= $initiallastdate)
+ continue;
- $post .= html2bbcode($item->object->content);
+ if ($lastdate < strtotime($item->published))
+ $lastdate = strtotime($item->published);
- if (is_array($item->object->attachments))
- $post .= "\n".trim(handleattachments($item));
+ if ($item->access->description == "Public")
+ switch($item->object->objectType) {
+ case "note":
+ $post = fromgplus_html2bbcode($item->object->content);
- //$post .= "[/quote]";
+ if (is_array($item->object->attachments))
+ $post .= fromgplus_handleattachments($item);
- friendicapost($post);
- break;
+ // geocode, placeName
+ if (isset($item->address))
+ $location = $item->address;
+ else
+ $location = "";
- default:
- print_r($item);
- die();
- break;
+ fromgplus_post($a, $uid, $item->provider->title, $post, $location);
+
+ break;
+
+ case "activity":
+ $post = fromgplus_html2bbcode($item->annotation)."\n";
+
+ if (intval(get_config('system','new_share'))) {
+ $post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName).
+ "' profile='".$item->object->actor->url.
+ "' avatar='".$item->object->actor->image->url.
+ "' link='".$item->object->url."']";
+
+ $post .= fromgplus_html2bbcode($item->object->content);
+
+ if (is_array($item->object->attachments))
+ $post .= "\n".trim(fromgplus_handleattachments($item));
+
+ $post .= "[/share]";
+ } else {
+ $post .= fromgplus_html2bbcode("♲");
+ $post .= " [url=".$item->object->actor->url."]".$item->object->actor->displayName."[/url] \n";
+ $post .= fromgplus_html2bbcode($item->object->content);
+
+ if (is_array($item->object->attachments))
+ $post .= "\n".trim(fromgplus_handleattachments($item));
+ }
+
+ if (isset($item->address))
+ $location = $item->address;
+ else
+ $location = "";
+
+ fromgplus_post($a, $uid, $item->provider->title, $post, $location);
+ break;
+ }
}
+ if ($lastdate != 0)
+ set_pconfig($uid,'fromgplus','lastdate', $lastdate);
}
-if ($lastid != "") {
- $state['lastid'] = $lastid;
- file_put_contents($statefile, serialize($state));
+/*
+// Test
+require_once("boot.php");
+
+if(@is_null($a)) {
+ $a = new App;
}
+
+if(@is_null($db)) {
+ @include(".htconfig.php");
+ require_once("include/dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+};
+
+$test = array();
+fromgplus_cron($a, $test);
*/
diff --git a/gravatar.tgz b/gravatar.tgz
index 25106f265..561c4aaec 100644
Binary files a/gravatar.tgz and b/gravatar.tgz differ
diff --git a/gravatar/gravatar.php b/gravatar/gravatar.php
index fc5358eb4..12a8e44f2 100644
--- a/gravatar/gravatar.php
+++ b/gravatar/gravatar.php
@@ -55,7 +55,7 @@ function gravatar_lookup($a, &$b) {
* Display admin settings for this addon
*/
function gravatar_plugin_admin (&$a, &$o) {
- $t = file_get_contents( dirname(__file__)."/admin.tpl");
+ $t = get_markup_template( "admin.tpl", "addon/gravatar/" );
$default_avatar = get_config('gravatar', 'default_img');
$rating = get_config('gravatar', 'rating');
diff --git a/gravatar/admin.tpl b/gravatar/view/admin.tpl
similarity index 100%
rename from gravatar/admin.tpl
rename to gravatar/view/admin.tpl
diff --git a/gravatar/view/smarty3/admin.tpl b/gravatar/view/smarty3/admin.tpl
new file mode 100644
index 000000000..5dfd4488e
--- /dev/null
+++ b/gravatar/view/smarty3/admin.tpl
@@ -0,0 +1,3 @@
+{{include file="field_select.tpl" field=$default_avatar}}
+{{include file="field_select.tpl" field=$rating}}
+
diff --git a/group_text.tgz b/group_text.tgz
new file mode 100644
index 000000000..5dca3140f
Binary files /dev/null and b/group_text.tgz differ
diff --git a/group_text/group_text.php b/group_text/group_text.php
index 151ff0ae9..5ec5c9c2a 100755
--- a/group_text/group_text.php
+++ b/group_text/group_text.php
@@ -43,7 +43,7 @@ function group_text_settings_post($a,$post) {
return;
set_pconfig(local_user(),'system','groupedit_image_limit',intval($_POST['group_text']));
- info( t('Editplain settings updated.') . EOL);
+ info( t('Group Text settings updated.') . EOL);
}
diff --git a/impressum.tgz b/impressum.tgz
index d87f17f71..b47b625cf 100755
Binary files a/impressum.tgz and b/impressum.tgz differ
diff --git a/impressum/impressum.php b/impressum/impressum.php
index a4e7199c9..3c1106c9a 100755
--- a/impressum/impressum.php
+++ b/impressum/impressum.php
@@ -29,6 +29,7 @@ function impressum_footer($a, &$b) {
$text = bbcode(get_config('impressum','footer_text'), true);
if (! $text == '') {
$a->page['htmlhead'] .= ' ';
+ $b .= '
';
$b .= '';
}
}
@@ -77,7 +78,7 @@ function impressum_plugin_admin_post (&$a) {
info( t('Settings updated.'). EOL );
}
function impressum_plugin_admin (&$a, &$o) {
- $t = file_get_contents( dirname(__file__). "/admin.tpl" );
+ $t = get_markup_template( "admin.tpl", "addon/impressum/" );
$o = replace_macros($t, array(
'$submit' => t('Submit'),
'$owner' => array('owner', t('Site Owner'), get_config('impressum','owner'), t('The page operators name.')),
diff --git a/impressum/admin.tpl b/impressum/view/admin.tpl
old mode 100755
new mode 100644
similarity index 100%
rename from impressum/admin.tpl
rename to impressum/view/admin.tpl
diff --git a/impressum/view/smarty3/admin.tpl b/impressum/view/smarty3/admin.tpl
new file mode 100644
index 000000000..80b678241
--- /dev/null
+++ b/impressum/view/smarty3/admin.tpl
@@ -0,0 +1,7 @@
+{{include file="field_input.tpl" field=$owner}}
+{{include file="field_input.tpl" field=$ownerprofile}}
+{{include file="field_textarea.tpl" field=$postal}}
+{{include file="field_textarea.tpl" field=$notes}}
+{{include file="field_input.tpl" field=$email}}
+{{include file="field_textarea.tpl" field=$footer_text}}
+
diff --git a/irc.tgz b/irc.tgz
index a43cde7ed..af216a43d 100644
Binary files a/irc.tgz and b/irc.tgz differ
diff --git a/irc/irc.php b/irc/irc.php
index 50eddb8cc..bd7444a9e 100644
--- a/irc/irc.php
+++ b/irc/irc.php
@@ -110,7 +110,7 @@ function irc_content(&$a) {
$o .= <<< EOT
IRC chat
A beginner's guide to using IRC. [en]
-
+
EOT;
return $o;
diff --git a/jappixmini.tgz b/jappixmini.tgz
index 212bb25e6..56d6dfa18 100644
Binary files a/jappixmini.tgz and b/jappixmini.tgz differ
diff --git a/jappixmini/jappixmini.php b/jappixmini/jappixmini.php
index 5d6f8446a..69c58e94c 100644
--- a/jappixmini/jappixmini.php
+++ b/jappixmini/jappixmini.php
@@ -3,7 +3,7 @@
/**
* Name: jappixmini
* Description: Provides a Facebook-like chat using Jappix Mini
-* Version: 1.0
+* Version: 1.0.1
* Author: leberwurscht
*
*/
@@ -221,6 +221,8 @@ function jappixmini_settings(&$a, &$s) {
$activate = get_pconfig(local_user(),'jappixmini','activate');
$activate = intval($activate) ? ' checked="checked"' : '';
+ $dontinsertchat = get_pconfig(local_user(),'jappixmini','dontinsertchat');
+ $insertchat = !(intval($dontinsertchat) ? ' checked="checked"' : '');
$username = get_pconfig(local_user(),'jappixmini','username');
$username = htmlentities($username);
@@ -261,46 +263,49 @@ function jappixmini_settings(&$a, &$s) {
$s .= '';
- $s .= '
Jappix Mini addon settings ';
+ $s .= '
'.t('Jappix Mini addon settings').' ';
$s .= '
';
- $s .= '
Activate addon ';
+ $s .= '
'.t('Activate addon').' ';
$s .= '
';
$s .= '
';
- $s .= '
Jabber username ';
+ $s .= '
'.t('Do not insert the Jappixmini Chat-Widget into the webinterface').' ';
+ $s .= '
';
+ $s .= '
';
+ $s .= '
'.t('Jabber username').' ';
$s .= '
';
$s .= '
';
- $s .= '
Jabber server ';
+ $s .= '
'.t('Jabber server').' ';
$s .= '
';
$s .= '
';
- $s .= '
Jabber BOSH host ';
+ $s .= '
'.t('Jabber BOSH host').' ';
$s .= '
';
$s .= '
';
- $s .= '
Jabber password ';
+ $s .= '
'.t('Jabber password').' ';
$s .= '
';
$s .= '
';
$s .= '
';
$onchange = "document.getElementById('jappixmini-friendica-password').disabled = !this.checked;jappixmini_set_password();";
- $s .= '
Encrypt Jabber password with Friendica password (recommended) ';
+ $s .= '
'.t('Encrypt Jabber password with Friendica password (recommended)').' ';
$s .= '
';
$s .= '
';
- $s .= '
Friendica password ';
+ $s .= '
'.t('Friendica password').' ';
$s .= '
';
$s .= '
';
- $s .= '
Approve subscription requests from Friendica contacts automatically ';
+ $s .= '
'.t('Approve subscription requests from Friendica contacts automatically').' ';
$s .= '
';
$s .= '
';
- $s .= '
Subscribe to Friendica contacts automatically ';
+ $s .= '
'.t('Subscribe to Friendica contacts automatically').' ';
$s .= '
';
$s .= '
';
- $s .= '
Purge internal list of jabber addresses of contacts ';
+ $s .= '
'.t('Purge internal list of jabber addresses of contacts').' ';
$s .= '
';
$s .= '
';
if ($info_text) $s .= '
Configuration help:
'.$info_text.'
';
$s .= '
Status:
Addon knows '.$address_cnt.' Jabber addresses of '.$contact_cnt.' Friendica contacts (takes some time, usually 10 minutes, to update).
';
$s .= '
';
- $s .= '
';
+ $s .= '
';
$s .= '
';
$s .= '
';
@@ -379,6 +384,7 @@ function jappixmini_settings_post(&$a,&$b) {
set_pconfig($uid,'jappixmini','autosubscribe',intval($b['jappixmini-autosubscribe']));
set_pconfig($uid,'jappixmini','autoapprove',intval($b['jappixmini-autoapprove']));
set_pconfig($uid,'jappixmini','activate',intval($b['jappixmini-activate']));
+ set_pconfig($uid,'jappixmini','dontinsertchat',intval($b['jappixmini-dont-insertchat']));
set_pconfig($uid,'jappixmini','encrypt',$encrypt);
info( 'Jappix Mini settings saved.' );
@@ -395,7 +401,8 @@ function jappixmini_script(&$a,&$s) {
if(! local_user()) return;
$activate = get_pconfig(local_user(),'jappixmini','activate');
- if (!$activate) return;
+ $dontinsertchat = get_pconfig(local_user(), 'jappixmini','dontinsertchat');
+ if (!$activate or $dontinsertchat) return;
$a->page['htmlhead'] .= ''."\r\n";
$a->page['htmlhead'] .= ''."\r\n";
diff --git a/js_upload.tgz b/js_upload.tgz
index 7b684103e..5a415de7d 100755
Binary files a/js_upload.tgz and b/js_upload.tgz differ
diff --git a/js_upload/js_upload.php b/js_upload/js_upload.php
index 3ba5f9c4d..148fde313 100755
--- a/js_upload/js_upload.php
+++ b/js_upload/js_upload.php
@@ -196,7 +196,13 @@ class qqUploadedFileXhr {
*/
function save() {
$input = fopen("php://input", "r");
- $this->pathnm = tempnam(sys_get_temp_dir(),'frn');
+
+ $upload_dir = get_config('system','tempdir');
+ if(! $upload_dir)
+ $upload_dir = sys_get_temp_dir();
+
+ $this->pathnm = tempnam($upload_dir,'frn');
+
$temp = fopen($this->pathnm,"w");
$realSize = stream_copy_to_stream($input, $temp);
diff --git a/libravatar.tgz b/libravatar.tgz
index 0405af9bd..d61f63baf 100644
Binary files a/libravatar.tgz and b/libravatar.tgz differ
diff --git a/libravatar/libravatar.php b/libravatar/libravatar.php
index 08ed6d00b..8cbf1e980 100644
--- a/libravatar/libravatar.php
+++ b/libravatar/libravatar.php
@@ -60,7 +60,7 @@ function libravatar_lookup($a, &$b) {
* Display admin settings for this addon
*/
function libravatar_plugin_admin (&$a, &$o) {
- $t = file_get_contents( dirname(__file__)."/admin.tpl");
+ $t = get_markup_template( "admin.tpl", "addon/libravatar" );
$default_avatar = get_config('libravatar', 'default_img');
diff --git a/libravatar/admin.tpl b/libravatar/view/admin.tpl
similarity index 100%
rename from libravatar/admin.tpl
rename to libravatar/view/admin.tpl
diff --git a/libravatar/view/smarty3/admin.tpl b/libravatar/view/smarty3/admin.tpl
new file mode 100644
index 000000000..ee958287a
--- /dev/null
+++ b/libravatar/view/smarty3/admin.tpl
@@ -0,0 +1,2 @@
+{{include file="field_select.tpl" field=$default_avatar}}
+
diff --git a/ljpost.tgz b/ljpost.tgz
index 840e2ee2a..db0165854 100644
Binary files a/ljpost.tgz and b/ljpost.tgz differ
diff --git a/ljpost/ljpost.css b/ljpost/ljpost.css
index 2087d3f05..e0494c5c4 100755
--- a/ljpost/ljpost.css
+++ b/ljpost/ljpost.css
@@ -1,6 +1,5 @@
#ljpost-enable-label, #ljpost-username-label, #ljpost-password-label, #ljpost-bydefault-label {
-<<<<<<< HEAD
float: left;
width: 200px;
margin-top: 10px;
@@ -15,18 +14,3 @@
margin-top: 15px;
}
-=======
-float: left;
-width: 200px;
-margin-top: 10px;
-}
-
-#ljpost-checkbox, #ljpost-username, #ljpost-password, #ljpost-bydefault {
-float: left;
-margin-top: 10px;
-}
-
-#ljpost-submit {
-margin-top: 15px;
-}
->>>>>>> 99d9fddb6af9e872266666038447771e42ce13b4
diff --git a/mathjax.tgz b/mathjax.tgz
index bb591e1d3..a340aee47 100644
Binary files a/mathjax.tgz and b/mathjax.tgz differ
diff --git a/mathjax/mathjax.php b/mathjax/mathjax.php
index 7105772ba..e57d69bf5 100644
--- a/mathjax/mathjax.php
+++ b/mathjax/mathjax.php
@@ -66,11 +66,12 @@ function mathjax_plugin_admin_post (&$a) {
info( t('Settings updated.'). EOL);
}
function mathjax_plugin_admin (&$a, &$o) {
- $t = file_get_contents( dirname(__file__)."/admin.tpl");
- if (get_config('mathjax','baseurl','') == '') {
- set_config('mathjax','baseurl','http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
- }
- $o = replace_macros( $t, array(
+ $t = get_markup_template( "admin.tpl", "addon/mathjax/" );
+ if (get_config('mathjax','baseurl','') == '') {
+ set_config('mathjax','baseurl','http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML');
+ }
+
+ $o = replace_macros( $t, array(
'$baseurl' => array('baseurl', t('MathJax Base URL'), get_config('mathjax','baseurl' ), t('The URL for the javascript file that should be included to use MathJax. Can be either the MathJax CDN or another installation of MathJax.')),
- ));
+ ));
}
diff --git a/mathjax/admin.tpl b/mathjax/view/admin.tpl
similarity index 100%
rename from mathjax/admin.tpl
rename to mathjax/view/admin.tpl
diff --git a/mathjax/view/smarty3/admin.tpl b/mathjax/view/smarty3/admin.tpl
new file mode 100644
index 000000000..f6ec03e0d
--- /dev/null
+++ b/mathjax/view/smarty3/admin.tpl
@@ -0,0 +1,2 @@
+{{include file="field_input.tpl" field=$baseurl}}
+
diff --git a/morepokes.tgz b/morepokes.tgz
new file mode 100644
index 000000000..7999b719f
Binary files /dev/null and b/morepokes.tgz differ
diff --git a/morepokes/morepokes.php b/morepokes/morepokes.php
index bdbd7dcf3..717643ec1 100644
--- a/morepokes/morepokes.php
+++ b/morepokes/morepokes.php
@@ -19,9 +19,8 @@ function morepokes_poke_verbs($a,&$b) {
$b['bitchslap'] = array('bitchslapped', t('bitchslap'), t('bitchslapped'));
$b['shag'] = array('shag', t('shag'), t('shagged'));
$b['somethingobscenelybiological'] = array('something obscenely biological', t('do something obscenely biological to'), t('did something obscenely biological to'));
- $b['newpokefeature'] = array('pointed out the new poke feature to', t('point out the new poke feature to'), t('pointed out the new poke feature to'));
+ $b['newpokefeature'] = array('pointed out the poke feature to', t('point out the poke feature to'), t('pointed out the poke feature to'));
$b['declareundyinglove'] = array('declared undying love for', t('declare undying love for'), t('declared undying love for'));
- $b['setfireto'] = array('set fire to', t('set fire to'), t('set fire to'));
$b['patent'] = array('patented', t('patent'), t('patented'));
$b['strokebeard'] = array('stroked their beard at', t('stroke beard'), t('stroked their beard at'));
$b['bemoan'] = array('bemoaned the declining standards of modern secondary and tertiary education to', t('bemoan the declining standards of modern secondary and tertiary education to'), t('bemoans the declining standards of modern secondary and tertiary education to'));
@@ -35,4 +34,4 @@ function morepokes_poke_verbs($a,&$b) {
$b['giggleandfawn'] = array('giggled and fawned at', t('giggle and fawn at'), t('giggled and fawned at'));
$b['doubt'] = array('doubted', t('doubt'), t('doubted'));
$b['glare'] = array('glared at', t('glare'), t('glared at'));
-;}
\ No newline at end of file
+;}
diff --git a/nsfw.tgz b/nsfw.tgz
index 73870dc3f..a35ec568c 100755
Binary files a/nsfw.tgz and b/nsfw.tgz differ
diff --git a/nsfw/nsfw.php b/nsfw/nsfw.php
index 60ab45813..96e1a9bf8 100755
--- a/nsfw/nsfw.php
+++ b/nsfw/nsfw.php
@@ -24,6 +24,37 @@ function nsfw_uninstall() {
}
+// This function isn't perfect and isn't trying to preserve the html structure - it's just a
+// quick and dirty filter to pull out embedded photo blobs because 'nsfw' seems to come up
+// inside them quite often. We don't need anything fancy, just pull out the data blob so we can
+// check against the rest of the body.
+
+function nsfw_extract_photos($body) {
+
+ $new_body = '';
+
+ $img_start = strpos($body,'src="data:');
+ $img_end = (($img_start !== false) ? strpos(substr($body,$img_start),'>') : false);
+
+ $cnt = 0;
+
+ while($img_end !== false) {
+ $img_end += $img_start;
+ $new_body = $new_body . substr($body,0,$img_start);
+
+ $cnt ++;
+ $body = substr($body,0,$img_end);
+
+ $img_start = strpos($body,'src="data:');
+ $img_end = (($img_start !== false) ? strpos(substr($body,$img_start),'>') : false);
+
+ }
+
+ if(! $cnt)
+ return $body;
+
+ return $new_body;
+}
@@ -77,6 +108,7 @@ function nsfw_addon_settings_post(&$a,&$b) {
function nsfw_prepare_body(&$a,&$b) {
+
$words = null;
if(get_pconfig(local_user(),'nsfw','disable'))
return;
@@ -93,19 +125,22 @@ function nsfw_prepare_body(&$a,&$b) {
$found = false;
if(count($arr)) {
+
+ $body = nsfw_extract_photos($b['html']);
+
foreach($arr as $word) {
$word = trim($word);
if(! strlen($word)) {
continue;
}
if(strpos($word,'/') === 0) {
- if(preg_match($word,$b['html'])) {
+ if(preg_match($word,$body)) {
$found = true;
break;
}
}
else {
- if(stristr($b['html'],$word)) {
+ if(stristr($body,$word)) {
$found = true;
break;
}
@@ -115,6 +150,7 @@ function nsfw_prepare_body(&$a,&$b) {
}
}
}
+
}
if($found) {
$rnd = random_string(8);
diff --git a/openstreetmap.tgz b/openstreetmap.tgz
index 34f4bd6b1..967b56017 100644
Binary files a/openstreetmap.tgz and b/openstreetmap.tgz differ
diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php
index fda29905d..cb9abcd7d 100755
--- a/openstreetmap/openstreetmap.php
+++ b/openstreetmap/openstreetmap.php
@@ -58,7 +58,7 @@ function openstreetmap_location($a, &$item) {
function openstreetmap_plugin_admin (&$a, &$o) {
- $t = file_get_contents( dirname(__file__)."/admin.tpl");
+ $t = get_markup_template( "admin.tpl", "addon/openstreetmap/" );
$tmsserver = get_config('openstreetmap','tmsserver');
if(! $tmsserver)
$tmsserver = 'http://openstreetmap.org';
diff --git a/openstreetmap/admin.tpl b/openstreetmap/view/admin.tpl
similarity index 100%
rename from openstreetmap/admin.tpl
rename to openstreetmap/view/admin.tpl
diff --git a/openstreetmap/view/smarty3/admin.tpl b/openstreetmap/view/smarty3/admin.tpl
new file mode 100644
index 000000000..6ee07174b
--- /dev/null
+++ b/openstreetmap/view/smarty3/admin.tpl
@@ -0,0 +1,3 @@
+{{include file="field_input.tpl" field=$tmsserver}}
+{{include file="field_input.tpl" field=$zoom}}
+
diff --git a/page.tgz b/page.tgz
index d300a3e2d..c9610e28b 100644
Binary files a/page.tgz and b/page.tgz differ
diff --git a/page/page.php b/page/page.php
index 3f0f04190..21a83e16d 100755
--- a/page/page.php
+++ b/page/page.php
@@ -1,7 +1,7 @@
* based on pages plugin by
@@ -38,6 +38,7 @@ function page_getpage($uid,$showhidden = true,$randomise = false) {
$contacts = q("SELECT `id`, `url`, `name`, `micro` FROM `contact`
WHERE `network`= 'dfrn' AND `forum` = 1 AND `uid` = %d
+ and blocked = 0 and hidden = 0 and pending = 0 and archive = 0
$order ",
intval($uid)
);
diff --git a/piwik.tgz b/piwik.tgz
index a1fc2ecd2..a5bd437aa 100755
Binary files a/piwik.tgz and b/piwik.tgz differ
diff --git a/piwik/piwik.php b/piwik/piwik.php
index 3e0d718ff..3501b2c8c 100755
--- a/piwik/piwik.php
+++ b/piwik/piwik.php
@@ -65,9 +65,9 @@ function piwik_analytics($a,&$b) {
*/
if ($async) {
$a->page['htmlhead'] .= " \r\n\r\n";
- $b .= " \r\n
\r\n
";
+ $b .= " \r\n
\r\n
";
} else {
- $b .= " \r\n \r\n\r\n
\r\n
";
+ $b .= " \r\n \r\n\r\n
\r\n
";
}
/*
@@ -84,7 +84,7 @@ function piwik_analytics($a,&$b) {
}
}
function piwik_plugin_admin (&$a, &$o) {
- $t = file_get_contents( dirname(__file__)."/admin.tpl");
+ $t = get_markup_template( "admin.tpl", "addon/piwik/" );
$o = replace_macros( $t, array(
'$submit' => t('Submit'),
'$baseurl' => array('baseurl', t('Piwik Base URL'), get_config('piwik','baseurl' ), t('Absolute path to your Piwik installation. (without protocol (http/s), with trailing slash)')),
diff --git a/piwik/admin.tpl b/piwik/view/admin.tpl
old mode 100755
new mode 100644
similarity index 100%
rename from piwik/admin.tpl
rename to piwik/view/admin.tpl
diff --git a/piwik/view/smarty3/admin.tpl b/piwik/view/smarty3/admin.tpl
new file mode 100644
index 000000000..bfe04aa31
--- /dev/null
+++ b/piwik/view/smarty3/admin.tpl
@@ -0,0 +1,5 @@
+{{include file="field_input.tpl" field=$baseurl}}
+{{include file="field_input.tpl" field=$siteid}}
+{{include file="field_checkbox.tpl" field=$optout}}
+{{include file="field_checkbox.tpl" field=$async}}
+
diff --git a/privacy_image_cache.tgz b/privacy_image_cache.tgz
index 5b29cebc4..b0690fc2b 100644
Binary files a/privacy_image_cache.tgz and b/privacy_image_cache.tgz differ
diff --git a/privacy_image_cache/privacy_image_cache.php b/privacy_image_cache/privacy_image_cache.php
index 8c68ef9a4..3be426208 100644
--- a/privacy_image_cache/privacy_image_cache.php
+++ b/privacy_image_cache/privacy_image_cache.php
@@ -30,42 +30,76 @@ function privacy_image_cache_uninstall() {
function privacy_image_cache_module() {}
-
function privacy_image_cache_init() {
- global $a;
+ global $a, $_SERVER;
- if ($a->config["system"]["db_log"] != "")
- $stamp1 = microtime(true);
+ if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
+ header('HTTP/1.1 304 Not Modified');
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
+ header('Etag: '.$_SERVER['HTTP_IF_NONE_MATCH']);
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
+ header("Cache-Control: max-age=31536000");
+ if(function_exists('header_remove')) {
+ header_remove('Last-Modified');
+ header_remove('Expires');
+ header_remove('Cache-Control');
+ }
+ exit;
+ }
+
+ //if ($a->config["system"]["db_log"] != "")
+ // $stamp1 = microtime(true);
if(function_exists('header_remove')) {
header_remove('Pragma');
header_remove('pragma');
}
+ $thumb = false;
+
+ // Look for filename in the arguments
+ if (isset($a->argv[1]) OR isset($a->argv[2])) {
+ if (isset($a->argv[2]))
+ $url = $a->argv[2];
+ else
+ $url = $a->argv[1];
+
+ $pos = strrpos($url, "==.");
+ if ($pos)
+ $url = substr($url, 0, $pos+2);
+
+ $url = base64_decode(strtr($url, '-_', '+/'), true);
+ if ($url)
+ $_REQUEST['url'] = $url;
+
+ $thumb = (isset($a->argv[3]) and ($a->argv[3] == "thumb"));
+ }
+
$urlhash = 'pic:' . sha1($_REQUEST['url']);
// Double encoded url - happens with Diaspora
$urlhash2 = 'pic:' . sha1(urldecode($_REQUEST['url']));
- $cache = get_config('system','itemcache');
- if (($cache != '') and is_dir($cache)) {
- $cachefile = $cache."/".hash("md5", $_REQUEST['url']);
+ $cachefile = get_cachefile(hash("md5", $_REQUEST['url']));
+ if ($cachefile != '') {
if (file_exists($cachefile)) {
$img_str = file_get_contents($cachefile);
$mime = image_type_to_mime_type(exif_imagetype($cachefile));
header("Content-type: $mime");
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
- header("Cache-Control: max-age=" . (3600*24));
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
+ header('Etag: "'.md5($img_str).'"');
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
+ header("Cache-Control: max-age=31536000");
echo $img_str;
- if ($a->config["system"]["db_log"] != "") {
- $stamp2 = microtime(true);
- $duration = round($stamp2-$stamp1, 3);
- if ($duration > $a->config["system"]["db_loglimit"])
- @file_put_contents($a->config["system"]["db_log"], $duration."\t".strlen($img_str)."\t".$_REQUEST['url']."\n", FILE_APPEND);
- }
+ //if ($a->config["system"]["db_log"] != "") {
+ // $stamp2 = microtime(true);
+ // $duration = round($stamp2-$stamp1, 3);
+ // if ($duration > $a->config["system"]["db_loglimit"])
+ // @file_put_contents($a->config["system"]["db_log"], $duration."\t".strlen($img_str)."\t".$_REQUEST['url']."\n", FILE_APPEND);
+ //}
killme();
}
@@ -73,27 +107,21 @@ function privacy_image_cache_init() {
require_once("Photo.php");
+ $valid = true;
+
$r = q("SELECT * FROM `photo` WHERE `resource-id` in ('%s', '%s') LIMIT 1", $urlhash, $urlhash2);
if (count($r)) {
$img_str = $r[0]['data'];
$mime = $r[0]["desc"];
if ($mime == "") $mime = "image/jpeg";
- // Test
- //if ($mime == "image/jpeg") {
- // $img = new Photo($img_str);
- // if($img->is_valid()) {
- // $img->scaleImage(1000);
- // $img_str = $img->imageString();
- // }
- //}
} else {
// It shouldn't happen but it does - spaces in URL
$_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']);
$img_str = fetch_url($_REQUEST['url'],true);
- $tempfile = tempnam("", "cache");
+ $tempfile = tempnam(get_config("system","temppath"), "cache");
file_put_contents($tempfile, $img_str);
$mime = image_type_to_mime_type(exif_imagetype($tempfile));
unlink($tempfile);
@@ -102,6 +130,13 @@ function privacy_image_cache_init() {
if ((substr($a->get_curl_code(), 0, 1) == "4") or (!$img_str)) {
$img_str = file_get_contents("images/blank.png");
$mime = "image/png";
+ $cachefile = ""; // Clear the cachefile so that the dummy isn't stored
+ $valid = false;
+ $img = new Photo($img_str);
+ if($img->is_valid()) {
+ $img->scaleImage(1);
+ $img_str = $img->imageString();
+ }
//} else if (substr($img_str, 0, 6) == "GIF89a") {
} else if ($mime != "image/jpeg") {
$image = @imagecreatefromstring($img_str);
@@ -129,45 +164,83 @@ function privacy_image_cache_init() {
$img = new Photo($img_str);
if($img->is_valid()) {
$img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
- //$img->scaleImage(1000); // Test
+ if ($thumb)
+ $img->scaleImage(200); // Test
$img_str = $img->imageString();
}
$mime = "image/jpeg";
}
}
- // Writing in cachefile
- if (isset($cachefile) && ($cachefile != '') and (exif_imagetype($cachefile) > 0))
+
+ // If there is a real existing directory then put the cache file there
+ // advantage: real file access is really fast
+ // Otherwise write in cachefile
+ if ($valid AND is_dir($_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache"))
+ file_put_contents($_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache/".privacy_image_cache_cachename($_REQUEST['url'], true), $img_str);
+ elseif ($cachefile != '')
file_put_contents($cachefile, $img_str);
header("Content-type: $mime");
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + (3600*24)) . " GMT");
- header("Cache-Control: max-age=" . (3600*24));
+
+ // Only output the cache headers when the file is valid
+ if ($valid) {
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
+ header('Etag: "'.md5($img_str).'"');
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + (31536000)) . " GMT");
+ header("Cache-Control: max-age=31536000");
+ }
echo $img_str;
- if ($a->config["system"]["db_log"] != "") {
- $stamp2 = microtime(true);
- $duration = round($stamp2-$stamp1, 3);
- if ($duration > $a->config["system"]["db_loglimit"])
- @file_put_contents($a->config["system"]["db_log"], $duration."\t".strlen($img_str)."\t".$_REQUEST['url']."\n", FILE_APPEND);
- }
+ //if ($a->config["system"]["db_log"] != "") {
+ // $stamp2 = microtime(true);
+ // $duration = round($stamp2-$stamp1, 3);
+ // if ($duration > $a->config["system"]["db_loglimit"])
+ // @file_put_contents($a->config["system"]["db_log"], $duration."\t".strlen($img_str)."\t".$_REQUEST['url']."\n", FILE_APPEND);
+ //}
killme();
}
+function privacy_image_cache_cachename($url, $writemode = false) {
+ global $_SERVER;
+
+ $basepath = $_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache";
+
+ $path = substr(hash("md5", $url), 0, 2);
+
+ if (is_dir($basepath) and $writemode)
+ if (!is_dir($basepath."/".$path)) {
+ mkdir($basepath."/".$path);
+ chmod($basepath."/".$path, 0777);
+ }
+
+ $path .= "/".strtr(base64_encode($url), '+/', '-_');
+
+ return($path);
+}
+
/**
* @param $url string
* @return boolean
*/
function privacy_image_cache_is_local_image($url) {
- if ($url[0] == '/') return true;
+ if ($url[0] == '/') return true;
+
if (strtolower(substr($url, 0, 5)) == "data:") return true;
+ // Check if the cached path would be longer than 255 characters - apache doesn't like it
+ if (is_dir($_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache")) {
+ $cachedurl = get_app()->get_baseurl()."/privacy_image_cache/". privacy_image_cache_cachename($url);
+ if (strlen($url) > 255)
+ return true;
+ }
+
// links normalised - bug #431
- $baseurl = normalise_link(get_app()->get_baseurl());
+ $baseurl = normalise_link(get_app()->get_baseurl());
$url = normalise_link($url);
- return (substr($url, 0, strlen($baseurl)) == $baseurl);
+ return (substr($url, 0, strlen($baseurl)) == $baseurl);
}
/**
@@ -179,7 +252,9 @@ function privacy_image_cache_img_cb($matches) {
if (privacy_image_cache_is_local_image($matches[2]))
return $matches[1] . $matches[2] . $matches[3];
- return $matches[1] . get_app()->get_baseurl() . "/privacy_image_cache/?url=" . addslashes(rawurlencode(htmlspecialchars_decode($matches[2]))) . $matches[3];
+ //return $matches[1] . get_app()->get_baseurl() . "/privacy_image_cache/?url=" . addslashes(rawurlencode(htmlspecialchars_decode($matches[2]))) . $matches[3];
+
+ return $matches[1].get_app()->get_baseurl()."/privacy_image_cache/". privacy_image_cache_cachename(htmlspecialchars_decode($matches[2])).$matches[3];
}
/**
@@ -207,9 +282,14 @@ function privacy_image_cache_bbcode_hook(&$a, &$o) {
function privacy_image_cache_display_item_hook(&$a, &$o) {
if (isset($o["output"])) {
if (isset($o["output"]["thumb"]) && !privacy_image_cache_is_local_image($o["output"]["thumb"]))
- $o["output"]["thumb"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["output"]["thumb"])));
+ $o["output"]["thumb"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($o["output"]["thumb"]);
+ //$o["output"]["thumb"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["output"]["thumb"])));
if (isset($o["output"]["author-avatar"]) && !privacy_image_cache_is_local_image($o["output"]["author-avatar"]))
- $o["output"]["author-avatar"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["output"]["author-avatar"])));
+ $o["output"]["author-avatar"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($o["output"]["author-avatar"]);
+ //$o["output"]["author-avatar"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["output"]["author-avatar"])));
+ if (isset($o["output"]["owner-avatar"]) && !privacy_image_cache_is_local_image($o["output"]["owner-avatar"]))
+ $o["output"]["owner-avatar"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($o["output"]["owner-avatar"]);
+ //$o["output"]["owner-avatar"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["output"]["owner-avatar"])));
}
}
@@ -220,7 +300,8 @@ function privacy_image_cache_display_item_hook(&$a, &$o) {
*/
function privacy_image_cache_ping_xmlize_hook(&$a, &$o) {
if ($o["photo"] != "" && !privacy_image_cache_is_local_image($o["photo"]))
- $o["photo"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["photo"])));
+ $o["photo"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($o["photo"]);
+ //$o["photo"] = $a->get_baseurl() . "/privacy_image_cache/?url=" . escape_tags(addslashes(rawurlencode($o["photo"])));
}
@@ -239,6 +320,8 @@ function privacy_image_cache_cron(&$a = null, &$b = null) {
logger("Purging old Cache of the Privacy Image Cache", LOGGER_DEBUG);
q('DELETE FROM `photo` WHERE `uid` = 0 AND `resource-id` LIKE "pic:%%" AND `created` < NOW() - INTERVAL %d SECOND', $cachetime);
set_config('pi_cache', 'last_delete', $time);
+
+ clear_cache($a->get_basepath(), $a->get_basepath()."/privacy_image_cache");
}
diff --git a/randplace.tgz b/randplace.tgz
index 7ab5f0db9..bdad8bafb 100755
Binary files a/randplace.tgz and b/randplace.tgz differ
diff --git a/remote_permissions.tgz b/remote_permissions.tgz
new file mode 100644
index 000000000..fef4f39bf
Binary files /dev/null and b/remote_permissions.tgz differ
diff --git a/remote_permissions/README.md b/remote_permissions/README.md
new file mode 100644
index 000000000..b9e385825
--- /dev/null
+++ b/remote_permissions/README.md
@@ -0,0 +1,8 @@
+The Remote Permissions plugin enables recipients of private posts to see who else has received the post. This can be beneficial on community servers where people may want to modify the way they speak depending on who can see their comments to the post.
+
+Note that since Friendica is federated, the local hub may have posts that originated elsewhere. In that case, the plugin has no way of knowing all the recipients of the post, and it must settle for finding out who else can see it on the local hub.
+
+The hub admin can specify one of two behaviors for this plugin:
+
+* **Global:** every private post on the local hub will show all recipients (or at least the ones it can discover) of the post to any other users on the local hub
+* **Individual:** only private posts from those users on the local hub who "opt-in" will show the post recipients. None of the private posts that originated elsewhere will show even partial lists of post recipients
diff --git a/remote_permissions/remote_permissions.php b/remote_permissions/remote_permissions.php
new file mode 100644
index 000000000..8955130f8
--- /dev/null
+++ b/remote_permissions/remote_permissions.php
@@ -0,0 +1,207 @@
+
+ *
+ */
+
+
+function remote_permissions_install() {
+ register_hook('lockview_content', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_content');
+ register_hook('plugin_settings', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings');
+ register_hook('plugin_settings_post', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings_post');
+}
+
+function remote_permissions_uninstall() {
+ unregister_hook('lockview_content', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_content');
+ unregister_hook('plugin_settings', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings');
+ unregister_hook('plugin_settings_post', 'addon/remote_permissions/remote_permissions.php', 'remote_permissions_settings_post');
+}
+
+function remote_permissions_settings(&$a,&$o) {
+
+ if(! local_user())
+ return;
+
+ $global = get_config("remote_perms", "global");
+ if($global == 1)
+ return;
+
+ /* Add our stylesheet to the page so we can make our settings look nice */
+
+ $a->page['htmlhead'] .= ' ' . "\r\n";
+
+ /* Get the current state of our config variable */
+
+ $remote_perms = get_pconfig(local_user(),'remote_perms','show');
+
+ /* Add some HTML to the existing form */
+
+// $t = file_get_contents("addon/remote_permissions/settings.tpl" );
+ $t = get_markup_template("settings.tpl", "addon/remote_permissions/" );
+ $o .= replace_macros($t, array(
+ '$remote_perms_title' => t('Remote Permissions Settings'),
+ '$remote_perms_label' => t('Allow recipients of your private posts to see the other recipients of the posts'),
+ '$checked' => (($remote_perms == 1) ? 'checked="checked"' : ''),
+ '$submit' => t('Submit')
+ ));
+
+}
+
+function remote_permissions_settings_post($a,$post) {
+ if(! local_user() || (! x($_POST,'remote-perms-submit')))
+ return;
+
+ set_pconfig(local_user(),'remote_perms','show',intval($_POST['remote-perms']));
+ info( t('Remote Permissions settings updated.') . EOL);
+}
+
+function remote_permissions_content($a, $item_copy) {
+
+ if($item_copy['uid'] != local_user())
+ return;
+
+ if(get_config('remote_perms','global') == 0) {
+ // Admin has set Individual choice. We need to find
+ // the original poster. First, get the contact's info
+ $r = q("SELECT nick, url FROM contact WHERE id = %d LIMIT 1",
+ intval($item_copy['contact-id'])
+ );
+ if(! $r)
+ return;
+
+ // Find out if the contact lives here
+ $baseurl = $a->get_baseurl();
+ $baseurl = substr($baseurl, strpos($baseurl, '://') + 3);
+ if(strpos($r[0]['url'], $baseurl) === false)
+ return;
+
+ // The contact lives here. Get his/her user info
+ $nick = $r[0]['nick'];
+ $r = q("SELECT uid FROM user WHERE nickname = '%s' LIMIT 1",
+ dbesc($nick)
+ );
+ if(! $r)
+ return;
+
+ if(get_pconfig($r[0]['uid'],'remote_perms','show') == 0)
+ return;
+ }
+
+ if(($item_copy['private'] == 1) && (! strlen($item_copy['allow_cid'])) && (! strlen($item_copy['allow_gid']))
+ && (! strlen($item_copy['deny_cid'])) && (! strlen($item_copy['deny_gid']))) {
+
+ $allow_names = array();
+
+ // Check for the original post here -- that's the only way
+ // to definitely get all of the recipients
+
+ if($item_copy['uri'] === $item_copy['parent-uri']) {
+ // Lockview for a top-level post
+ $r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s' AND type = 'wall' LIMIT 1",
+ dbesc($item_copy['uri'])
+ );
+ }
+ else {
+ // Lockview for a comment
+ $r = q("SELECT allow_cid, allow_gid, deny_cid, deny_gid FROM item WHERE uri = '%s'
+ AND parent = ( SELECT id FROM item WHERE uri = '%s' AND type = 'wall' ) LIMIT 1",
+ dbesc($item_copy['uri']),
+ dbesc($item_copy['parent-uri'])
+ );
+ }
+ if($r) {
+
+ $item = $r[0];
+
+ $allowed_users = expand_acl($item['allow_cid']);
+ $allowed_groups = expand_acl($item['allow_gid']);
+ $deny_users = expand_acl($item['deny_cid']);
+ $deny_groups = expand_acl($item['deny_gid']);
+
+ $o = t('Visible to:') . ' ';
+ $allow = array();
+ $deny = array();
+
+ if(count($allowed_groups)) {
+ $r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
+ dbesc(implode(', ', $allowed_groups))
+ );
+ foreach($r as $rr)
+ $allow[] = $rr['contact-id'];
+ }
+ $allow = array_unique($allow + $allowed_users);
+
+ if(count($deny_groups)) {
+ $r = q("SELECT DISTINCT `contact-id` FROM group_member WHERE gid IN ( %s )",
+ dbesc(implode(', ', $deny_groups))
+ );
+ foreach($r as $rr)
+ $deny[] = $rr['contact-id'];
+ }
+ $deny = $deny + $deny_users;
+
+ if($allow)
+ {
+ $r = q("SELECT name FROM contact WHERE id IN ( %s )",
+ dbesc(implode(', ', array_diff($allow, $deny)))
+ );
+ foreach($r as $rr)
+ $allow_names[] = $rr['name'];
+ }
+ }
+ else {
+ // We don't have the original post. Let's try for the next best thing:
+ // checking who else has the post on our own server. Note that comments
+ // that were sent to Diaspora and were relayed to others on our server
+ // will have different URIs than the original. We can match the GUID for
+ // those
+ $r = q("SELECT `uid` FROM item WHERE uri = '%s' OR guid = '%s'",
+ dbesc($item_copy['uri']),
+ dbesc($item_copy['guid'])
+ );
+ if(! $r)
+ return;
+
+ $allow = array();
+ foreach($r as $rr)
+ $allow[] = $rr['uid'];
+
+ $r = q("SELECT username FROM user WHERE uid IN ( %s )",
+ dbesc(implode(', ', $allow))
+ );
+ if(! $r)
+ return;
+
+ $o = t('Visible to') . ' (' . t('may only be a partial list') . '): ';
+
+ foreach($r as $rr)
+ $allow_names[] = $rr['username'];
+ }
+
+ // Sort the names alphabetically, case-insensitive
+ natcasesort($allow_names);
+ echo $o . implode(', ', $allow_names);
+ killme();
+ }
+
+ return;
+}
+
+function remote_permissions_plugin_admin(&$a, &$o){
+ $t = get_markup_template( "admin.tpl", "addon/remote_permissions/" );
+ $o = replace_macros($t, array(
+ '$submit' => t('Submit'),
+ '$global' => array('remotepermschoice', t('Global'), 1, t('The posts of every user on this server show the post recipients'), get_config('remote_perms', 'global') == 1),
+ '$individual' => array('remotepermschoice', t('Individual'), 2, t('Each user chooses whether his/her posts show the post recipients'), get_config('remote_perms', 'global') == 0)
+ ));
+}
+
+function remote_permissions_plugin_admin_post(&$a){
+ $choice = ((x($_POST,'remotepermschoice')) ? notags(trim($_POST['remotepermschoice'])) : '');
+ set_config('remote_perms','global',($choice == 1 ? 1 : 0));
+ info( t('Settings updated.'). EOL );
+}
+
diff --git a/remote_permissions/settings.css b/remote_permissions/settings.css
new file mode 100644
index 000000000..ef6051d2f
--- /dev/null
+++ b/remote_permissions/settings.css
@@ -0,0 +1,16 @@
+
+
+
+#remote-perms-label {
+ float: left;
+ width: 200px;
+ margin-bottom: 25px;
+ margin-right: 20px;
+ text-align: justify;
+}
+
+#remote-perms {
+ float: left;
+}
+
+
diff --git a/remote_permissions/view/admin.tpl b/remote_permissions/view/admin.tpl
new file mode 100644
index 000000000..605588084
--- /dev/null
+++ b/remote_permissions/view/admin.tpl
@@ -0,0 +1,3 @@
+{{ inc field_radio.tpl with $field=$global }}{{ endinc }}
+{{ inc field_radio.tpl with $field=$individual }}{{ endinc }}
+
diff --git a/remote_permissions/view/settings.tpl b/remote_permissions/view/settings.tpl
new file mode 100644
index 000000000..9fd98957f
--- /dev/null
+++ b/remote_permissions/view/settings.tpl
@@ -0,0 +1,8 @@
+
+
$remote_perms_title
+
+ $remote_perms_label
+
+
+
+
diff --git a/remote_permissions/view/smarty3/admin.tpl b/remote_permissions/view/smarty3/admin.tpl
new file mode 100644
index 000000000..e67afd737
--- /dev/null
+++ b/remote_permissions/view/smarty3/admin.tpl
@@ -0,0 +1,3 @@
+{{include file="field_radio.tpl" field=$global}}
+{{include file="field_radio.tpl" field=$individual}}
+
diff --git a/remote_permissions/view/smarty3/settings.tpl b/remote_permissions/view/smarty3/settings.tpl
new file mode 100644
index 000000000..df89a32e5
--- /dev/null
+++ b/remote_permissions/view/smarty3/settings.tpl
@@ -0,0 +1,8 @@
+
+
{{$remote_perms_title}}
+
+ {{$remote_perms_label}}
+
+
+
+
diff --git a/smiley_pack.tgz b/smiley_pack.tgz
index 8c184414c..2efe63322 100644
Binary files a/smiley_pack.tgz and b/smiley_pack.tgz differ
diff --git a/smiley_pack/icons/food/birthdaycake.gif b/smiley_pack/icons/food/birthdaycake.gif
new file mode 100644
index 000000000..30ebceb35
Binary files /dev/null and b/smiley_pack/icons/food/birthdaycake.gif differ
diff --git a/smiley_pack/smiley_pack.php b/smiley_pack/smiley_pack.php
index 4623ded5a..4d49b7c02 100644
--- a/smiley_pack/smiley_pack.php
+++ b/smiley_pack/smiley_pack.php
@@ -370,6 +370,9 @@ function smiley_pack_smilies(&$a,&$b) {
$b['texts'][] = ':fryegg';
$b['icons'][] = ' ';
+ $b['texts'][] = ':birthdaycake';
+ $b['icons'][] = ' ';
+
#Happy smileys
$b['texts'][] = ':cloud9';
diff --git a/sniper.tgz b/sniper.tgz
index fa75b3e40..fba75c15b 100755
Binary files a/sniper.tgz and b/sniper.tgz differ
diff --git a/statusnet.tgz b/statusnet.tgz
index c171f2c38..9801af556 100755
Binary files a/statusnet.tgz and b/statusnet.tgz differ
diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php
index 46b3f03f5..4781fcc25 100755
--- a/statusnet/statusnet.php
+++ b/statusnet/statusnet.php
@@ -404,6 +404,113 @@ function short_link($url) {
return $slinky->short();
} };
+function statusnet_shortenmsg($b, $max_char) {
+ require_once("include/bbcode.php");
+ require_once("include/html2plain.php");
+
+ // Looking for the first image
+ $image = '';
+ if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$b['body'],$matches))
+ $image = $matches[3];
+
+ if ($image == '')
+ if(preg_match("/\[img\](.*?)\[\/img\]/is",$b['body'],$matches))
+ $image = $matches[1];
+
+ $multipleimages = (strpos($b['body'], "[img") != strrpos($b['body'], "[img"));
+
+ // When saved into the database the content is sent through htmlspecialchars
+ // That means that we have to decode all image-urls
+ $image = htmlspecialchars_decode($image);
+
+ $body = $b["body"];
+ if ($b["title"] != "")
+ $body = $b["title"]."\n\n".$body;
+
+ // remove the recycle signs and the names since they aren't helpful on twitter
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body);
+ // recycle 2 (Test)
+ $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
+ $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body);
+
+ // remove the share element
+ $body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body);
+
+ // At first convert the text to html
+ $html = bbcode($body, false, false);
+
+ // Then convert it to plain text
+ //$msg = trim($b['title']." \n\n".html2plain($html, 0, true));
+ $msg = trim(html2plain($html, 0, true));
+ $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
+
+ // Removing multiple newlines
+ while (strpos($msg, "\n\n\n") !== false)
+ $msg = str_replace("\n\n\n", "\n\n", $msg);
+
+ // Removing multiple spaces
+ while (strpos($msg, " ") !== false)
+ $msg = str_replace(" ", " ", $msg);
+
+ // Removing URLs
+ $msg = preg_replace('/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', "", $msg);
+
+ $msg = trim($msg);
+
+ $link = '';
+ // look for bookmark-bbcode and handle it with priority
+ if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches))
+ $link = $matches[1];
+
+ $multiplelinks = (strpos($b['body'], "[bookmark") != strrpos($b['body'], "[bookmark"));
+
+ // If there is no bookmark element then take the first link
+ if ($link == '') {
+ $links = collecturls($html);
+ if (sizeof($links) > 0) {
+ reset($links);
+ $link = current($links);
+ }
+ $multiplelinks = (sizeof($links) > 1);
+ }
+
+ $msglink = "";
+ if ($multiplelinks)
+ $msglink = $b["plink"];
+ else if ($link != "")
+ $msglink = $link;
+ else if ($multipleimages)
+ $msglink = $b["plink"];
+ else if ($image != "")
+ $msglink = $image;
+
+ if (($msglink == "") and strlen($msg) > $max_char)
+ $msglink = $b["plink"];
+
+ if (strlen($msglink) > 20)
+ $msglink = short_link($msglink);
+
+ if (strlen(trim($msg." ".$msglink)) > $max_char) {
+ $msg = substr($msg, 0, $max_char - (strlen($msglink)));
+ $lastchar = substr($msg, -1);
+ $msg = substr($msg, 0, -1);
+ $pos = strrpos($msg, "\n");
+ if ($pos > 0)
+ $msg = substr($msg, 0, $pos);
+ else if ($lastchar != "\n")
+ $msg = substr($msg, 0, -3)."...";
+ }
+ $msg = str_replace("\n", " ", $msg);
+
+ // Removing multiple spaces - again
+ while (strpos($msg, " ") !== false)
+ $msg = str_replace(" ", " ", $msg);
+
+ return(array("msg"=>trim($msg." ".$msglink), "image"=>$image));
+}
+
function statusnet_post_hook(&$a,&$b) {
/**
@@ -433,88 +540,108 @@ function statusnet_post_hook(&$a,&$b) {
// we can later send to StatusNet. This way we can "gain" some
// information during shortening of potential links but do not
// shorten all the links in a 200000 character long essay.
- if (! $b['title']=='') {
- $tmp = $b['title'].": \n".$b['body'];
-// $tmp = substr($tmp, 0, 4*$max_char);
- } else {
- $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char);
- }
- // if [url=bla][img]blub.png[/img][/url] get blub.png
- $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp);
- // preserve links to images, videos and audios
- $tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp);
- $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?video(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?youtube(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?vimeo(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp);
- $linksenabled = get_pconfig($b['uid'],'statusnet','post_taglinks');
- // if a #tag is linked, don't send the [url] over to SN
- // that is, don't send if the option is not set in the
- // connector settings
- if ($linksenabled=='0') {
- // #-tags
- $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
- // @-mentions
- $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
- // recycle 1
- $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
- $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
- // recycle 2 (test)
- $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
- $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
- }
- // preserve links to webpages
- $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
- $tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);
- // find all http or https links in the body of the entry and
- // apply the shortener if the link is longer then 20 characters
- if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) {
- preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls );
- foreach ($allurls as $url) {
- foreach ($url as $u) {
- if (strlen($u)>20) {
- $sl = short_link($u);
- $tmp = str_replace( $u, $sl, $tmp );
- }
- }
- }
- }
- // ok, all the links we want to send out are save, now strip
- // away the remaining bbcode
- //$msg = strip_tags(bbcode($tmp, false, false));
- $msg = bbcode($tmp, false, false);
- $msg = str_replace(array(' ',' '),"\n",$msg);
- $msg = strip_tags($msg);
- // quotes not working - let's try this
- $msg = html_entity_decode($msg);
+ $tempfile = "";
+ $intelligent_shortening = get_config('statusnet','intelligent_shortening');
+ if (!$intelligent_shortening) {
+ if (! $b['title']=='') {
+ $tmp = $b['title'].": \n".$b['body'];
+ // $tmp = substr($tmp, 0, 4*$max_char);
+ } else {
+ $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char);
+ }
+ // if [url=bla][img]blub.png[/img][/url] get blub.png
+ $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp);
+ // preserve links to images, videos and audios
+ $tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp);
+ $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?video(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?youtube(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?vimeo(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp);
+ $linksenabled = get_pconfig($b['uid'],'statusnet','post_taglinks');
+ // if a #tag is linked, don't send the [url] over to SN
+ // that is, don't send if the option is not set in the
+ // connector settings
+ if ($linksenabled=='0') {
+ // #-tags
+ $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+ // @-mentions
+ $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ // recycle 2 (test)
+ $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ }
+ // preserve links to webpages
+ $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
+ $tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);
+ // find all http or https links in the body of the entry and
+ // apply the shortener if the link is longer then 20 characters
+ if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) {
+ preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls );
+ foreach ($allurls as $url) {
+ foreach ($url as $u) {
+ if (strlen($u)>20) {
+ $sl = short_link($u);
+ $tmp = str_replace( $u, $sl, $tmp );
+ }
+ }
+ }
+ }
+ // ok, all the links we want to send out are save, now strip
+ // away the remaining bbcode
+ //$msg = strip_tags(bbcode($tmp, false, false));
+ $msg = bbcode($tmp, false, false);
+ $msg = str_replace(array(' ',' '),"\n",$msg);
+ $msg = strip_tags($msg);
- if (( strlen($msg) > $max_char) && $max_char > 0) {
- $shortlink = short_link( $b['plink'] );
- // the new message will be shortened such that "... $shortlink"
- // will fit into the character limit
- $msg = nl2br(substr($msg, 0, $max_char-strlen($shortlink)-4));
- $msg = str_replace(array(' ',' '),' ',$msg);
- $e = explode(' ', $msg);
- // remove the last word from the cut down message to
- // avoid sending cut words to the MicroBlog
- array_pop($e);
- $msg = implode(' ', $e);
- $msg .= '... ' . $shortlink;
+ // quotes not working - let's try this
+ $msg = html_entity_decode($msg);
+
+ if (( strlen($msg) > $max_char) && $max_char > 0) {
+ $shortlink = short_link( $b['plink'] );
+ // the new message will be shortened such that "... $shortlink"
+ // will fit into the character limit
+ $msg = nl2br(substr($msg, 0, $max_char-strlen($shortlink)-4));
+ $msg = str_replace(array(' ',' '),' ',$msg);
+ $e = explode(' ', $msg);
+ // remove the last word from the cut down message to
+ // avoid sending cut words to the MicroBlog
+ array_pop($e);
+ $msg = implode(' ', $e);
+ $msg .= '... ' . $shortlink;
+ }
+
+ $msg = trim($msg);
+ $postdata = array('status' => $msg);
+ } else {
+ $msgarr = statusnet_shortenmsg($b, $max_char);
+ $msg = $msgarr["msg"];
+ $image = $msgarr["image"];
+ if ($image != "") {
+ $imagedata = file_get_contents($image);
+ $tempfile = tempnam(get_config("system","temppath"), "upload");
+ file_put_contents($tempfile, $imagedata);
+ $postdata = array("status"=>$msg, "media"=>"@".$tempfile);
+ } else
+ $postdata = array("status"=>$msg);
}
- $msg = trim($msg);
-
// and now dent it :-)
if(strlen($msg)) {
- $result = $dent->post('statuses/update', array('status' => $msg));
+ //$result = $dent->post('statuses/update', array('status' => $msg));
+ $result = $dent->post('statuses/update', $postdata);
logger('statusnet_post send, result: ' . print_r($result, true).
- "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b));
+ "\nmessage: ".$msg, LOGGER_DEBUG."\nOriginal post: ".print_r($b, true)."\nPost Data: ".print_r($postdata, true));
if ($result->error) {
logger('Send to StatusNet failed: "' . $result->error . '"');
}
}
+ if ($tempfile != "")
+ unlink($tempfile);
}
}
@@ -571,7 +698,7 @@ function statusnet_plugin_admin(&$a, &$o){
);
- $t = file_get_contents( dirname(__file__). "/admin.tpl" );
+ $t = get_markup_template( "admin.tpl", "addon/statusnet/" );
$o = replace_macros($t, array(
'$submit' => t('Submit'),
diff --git a/statusnet/admin.tpl b/statusnet/view/admin.tpl
old mode 100755
new mode 100644
similarity index 100%
rename from statusnet/admin.tpl
rename to statusnet/view/admin.tpl
diff --git a/statusnet/view/smarty3/admin.tpl b/statusnet/view/smarty3/admin.tpl
new file mode 100644
index 000000000..e2a8408f8
--- /dev/null
+++ b/statusnet/view/smarty3/admin.tpl
@@ -0,0 +1,16 @@
+{{foreach $sites as $s}}
+ {{include file="field_input.tpl" field=$s.sitename}}
+ {{include file="field_input.tpl" field=$s.apiurl}}
+ {{include file="field_input.tpl" field=$s.secret}}
+ {{include file="field_input.tpl" field=$s.key}}
+ {{if $s.delete}}
+ {{include file="field_checkbox.tpl" field=$s.delete}}
+
+ {{else}}
+ Fill this form to add a new site
+ {{/if}}
+
+{{/foreach}}
+
+
+
diff --git a/tumblr.tgz b/tumblr.tgz
index fe0389554..b4f6ff9b7 100755
Binary files a/tumblr.tgz and b/tumblr.tgz differ
diff --git a/tumblr/README b/tumblr/README
new file mode 100644
index 000000000..62d7fd045
--- /dev/null
+++ b/tumblr/README
@@ -0,0 +1,9 @@
+Define in your .htconfig.php:
+$a->config['tumblr']['consumer_key'] = "your-consumer-key";
+$a->config['tumblr']['consumer_secret'] = "your-consumer-secret";
+
+You can get it here:
+http://www.tumblr.com/oauth/apps
+
+Tumblr-OAuth-Library:
+https://groups.google.com/d/msg/tumblr-api/g6SeIBWvsnE/gnWqT9jFSlEJ
diff --git a/tumblr/tumblr.php b/tumblr/tumblr.php
index eeb51348b..4bbae8e6c 100755
--- a/tumblr/tumblr.php
+++ b/tumblr/tumblr.php
@@ -7,6 +7,9 @@
* Author: Mike Macgirvin
*/
+require_once('library/OAuth1.php');
+require_once('addon/tumblr/tumblroauth/tumblroauth.php');
+
function tumblr_install() {
register_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
register_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
@@ -23,6 +26,125 @@ function tumblr_uninstall() {
unregister_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
}
+function tumblr_module() {}
+
+function tumblr_content(&$a) {
+
+ if(! local_user()) {
+ notice( t('Permission denied.') . EOL);
+ return '';
+ }
+
+ if (isset($a->argv[1]))
+ switch ($a->argv[1]) {
+ case "connect":
+ $o = tumblr_connect($a);
+ break;
+ case "callback":
+ $o = tumblr_callback($a);
+ break;
+ default:
+ $o = print_r($a->argv, true);
+ break;
+ }
+ else
+ $o = tumblr_connect($a);
+
+ return $o;
+}
+
+function tumblr_connect($a) {
+ // Start a session. This is necessary to hold on to a few keys the callback script will also need
+ session_start();
+
+ // Include the TumblrOAuth library
+ //require_once('addon/tumblr/tumblroauth/tumblroauth.php');
+
+ // Define the needed keys
+ $consumer_key = get_config('tumblr','consumer_key');
+ $consumer_secret = get_config('tumblr','consumer_secret');
+
+ // The callback URL is the script that gets called after the user authenticates with tumblr
+ // In this example, it would be the included callback.php
+ $callback_url = $a->get_baseurl()."/tumblr/callback";
+
+ // Let's begin. First we need a Request Token. The request token is required to send the user
+ // to Tumblr's login page.
+
+ // Create a new instance of the TumblrOAuth library. For this step, all we need to give the library is our
+ // Consumer Key and Consumer Secret
+ $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret);
+
+ // Ask Tumblr for a Request Token. Specify the Callback URL here too (although this should be optional)
+ $request_token = $tum_oauth->getRequestToken($callback_url);
+
+ // Store the request token and Request Token Secret as out callback.php script will need this
+ $_SESSION['request_token'] = $token = $request_token['oauth_token'];
+ $_SESSION['request_token_secret'] = $request_token['oauth_token_secret'];
+
+ // Check the HTTP Code. It should be a 200 (OK), if it's anything else then something didn't work.
+ switch ($tum_oauth->http_code) {
+ case 200:
+ // Ask Tumblr to give us a special address to their login page
+ $url = $tum_oauth->getAuthorizeURL($token);
+
+ // Redirect the user to the login URL given to us by Tumblr
+ header('Location: ' . $url);
+
+ // That's it for our side. The user is sent to a Tumblr Login page and
+ // asked to authroize our app. After that, Tumblr sends the user back to
+ // our Callback URL (callback.php) along with some information we need to get
+ // an access token.
+
+ break;
+ default:
+ // Give an error message
+ $o = 'Could not connect to Tumblr. Refresh the page or try again later.';
+ }
+ return($o);
+}
+
+function tumblr_callback($a) {
+
+ // Start a session, load the library
+ session_start();
+ //require_once('addon/tumblr/tumblroauth/tumblroauth.php');
+
+ // Define the needed keys
+ $consumer_key = get_config('tumblr','consumer_key');
+ $consumer_secret = get_config('tumblr','consumer_secret');
+
+ // Once the user approves your app at Tumblr, they are sent back to this script.
+ // This script is passed two parameters in the URL, oauth_token (our Request Token)
+ // and oauth_verifier (Key that we need to get Access Token).
+ // We'll also need out Request Token Secret, which we stored in a session.
+
+ // Create instance of TumblrOAuth.
+ // It'll need our Consumer Key and Secret as well as our Request Token and Secret
+ $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $_SESSION['request_token'], $_SESSION['request_token_secret']);
+
+ // Ok, let's get an Access Token. We'll need to pass along our oauth_verifier which was given to us in the URL.
+ $access_token = $tum_oauth->getAccessToken($_REQUEST['oauth_verifier']);
+
+ // We're done with the Request Token and Secret so let's remove those.
+ unset($_SESSION['request_token']);
+ unset($_SESSION['request_token_secret']);
+
+ // Make sure nothing went wrong.
+ if (200 == $tum_oauth->http_code) {
+ // good to go
+ } else {
+ return('Unable to authenticate');
+ }
+
+ // What's next? Now that we have an Access Token and Secret, we can make an API call.
+ set_pconfig(local_user(), "tumblr", "oauth_token", $access_token['oauth_token']);
+ set_pconfig(local_user(), "tumblr", "oauth_token_secret", $access_token['oauth_token_secret']);
+
+ $o = t("You are now authenticated to tumblr.");
+ $o .= ''.t("return to the connector page").' ';
+ return($o);
+}
function tumblr_jot_nets(&$a,&$b) {
if(! local_user())
@@ -57,34 +179,55 @@ function tumblr_settings(&$a,&$s) {
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
- $tmbl_username = get_pconfig(local_user(), 'tumblr', 'tumblr_username');
- $tmbl_password = get_pconfig(local_user(), 'tumblr', 'tumblr_password');
-
-
/* Add some HTML to the existing form */
$s .= '';
$s .= '
' . t('Tumblr Post Settings') . ' ';
+
+ $s .= '
';
+
$s .= '
';
$s .= '' . t('Enable Tumblr Post Plugin') . ' ';
$s .= ' ';
$s .= '
';
- $s .= '
';
- $s .= '' . t('Tumblr login') . ' ';
- $s .= ' ';
- $s .= '
';
-
- $s .= '
';
- $s .= '' . t('Tumblr password') . ' ';
- $s .= ' ';
- $s .= '
';
-
$s .= '
';
$s .= '' . t('Post to Tumblr by default') . ' ';
$s .= ' ';
$s .= '
';
+ $oauth_token = get_pconfig(local_user(), "tumblr", "oauth_token");
+ $oauth_token_secret = get_pconfig(local_user(), "tumblr", "oauth_token_secret");
+
+ $s .= '
';
+ if (($oauth_token != "") and ($oauth_token_secret != "")) {
+
+ $page = get_pconfig(local_user(),'tumblr','page');
+ $consumer_key = get_config('tumblr','consumer_key');
+ $consumer_secret = get_config('tumblr','consumer_secret');
+
+ $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
+
+ $userinfo = $tum_oauth->get('user/info');
+
+ $blogs = array();
+
+ $s .= t("Post to page:")."";
+ foreach($userinfo->response->user->blogs as $blog) {
+ $blogurl = substr(str_replace(array("http://", "https://"), array("", ""), $blog->url), 0, -1);
+ if ($page == $blogurl)
+ $s .= "".$blogurl." ";
+ else
+ $s .= "".$blogurl." ";
+ }
+
+ $s .= " ";
+ } else
+ $s .= t("You are not authenticated to tumblr");
+ $s .= '
';
+
/* provide a submit button */
$s .= '
';
@@ -97,9 +240,8 @@ function tumblr_settings_post(&$a,&$b) {
if(x($_POST,'tumblr-submit')) {
set_pconfig(local_user(),'tumblr','post',intval($_POST['tumblr']));
+ set_pconfig(local_user(),'tumblr','page',$_POST['tumblr_page']);
set_pconfig(local_user(),'tumblr','post_by_default',intval($_POST['tumblr_bydefault']));
- set_pconfig(local_user(),'tumblr','tumblr_username',trim($_POST['tumblr_username']));
- set_pconfig(local_user(),'tumblr','tumblr_password',trim($_POST['tumblr_password']));
}
@@ -147,12 +289,12 @@ function tumblr_send(&$a,&$b) {
if($b['parent'] != $b['id'])
return;
+ $oauth_token = get_pconfig($b['uid'], "tumblr", "oauth_token");
+ $oauth_token_secret = get_pconfig($b['uid'], "tumblr", "oauth_token_secret");
+ $page = get_pconfig($b['uid'], "tumblr", "page");
+ $tmbl_blog = 'blog/'.$page.'/post';
- $tmbl_username = get_pconfig($b['uid'],'tumblr','tumblr_username');
- $tmbl_password = get_pconfig($b['uid'],'tumblr','tumblr_password');
- $tmbl_blog = 'http://www.tumblr.com/api/write';
-
- if($tmbl_username && $tmbl_password && $tmbl_blog) {
+ if($oauth_token && $oauth_token_secret && $tmbl_blog) {
require_once('include/bbcode.php');
@@ -193,10 +335,8 @@ function tumblr_send(&$a,&$b) {
}
$params = array(
- 'email' => $tmbl_username,
- 'password' => $tmbl_password,
'format' => 'html',
- 'generator' => 'Friendica',
+ 'tweet' => 'off',
'tags' => $tags);
if (($link != '') and $video) {
@@ -209,17 +349,25 @@ function tumblr_send(&$a,&$b) {
$params['caption'] = bbcode($body, false, false);
} else if (($link != '') and !$video) {
$params['type'] = "link";
- $params['name'] = $title;
+ $params['title'] = $title;
$params['url'] = $link;
$params['description'] = bbcode($b["body"], false, false);
} else {
- $params['type'] = "regular";
+ $params['type'] = "text";
$params['title'] = $title;
$params['body'] = bbcode($b['body'], false, false);
}
- $x = post_url($tmbl_blog,$params);
- $ret_code = $a->get_curl_code();
+ $consumer_key = get_config('tumblr','consumer_key');
+ $consumer_secret = get_config('tumblr','consumer_secret');
+
+ $tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
+
+ // Make an API call with the TumblrOAuth instance.
+ $x = $tum_oauth->post($tmbl_blog,$params);
+
+ $ret_code = $tum_oauth->http_code;
+
if($ret_code == 201)
logger('tumblr_send: success');
elseif($ret_code == 403)
diff --git a/tumblr/tumblroauth/OAuth.php b/tumblr/tumblroauth/OAuth.php
new file mode 100644
index 000000000..982aaa5db
--- /dev/null
+++ b/tumblr/tumblroauth/OAuth.php
@@ -0,0 +1,874 @@
+key = $key;
+ $this->secret = $secret;
+ $this->callback_url = $callback_url;
+ }
+
+ function __toString() {
+ return "OAuthConsumer[key=$this->key,secret=$this->secret]";
+ }
+}
+
+class OAuthToken {
+ // access tokens and request tokens
+ public $key;
+ public $secret;
+
+ /**
+ * key = the token
+ * secret = the token secret
+ */
+ function __construct($key, $secret) {
+ $this->key = $key;
+ $this->secret = $secret;
+ }
+
+ /**
+ * generates the basic string serialization of a token that a server
+ * would respond to request_token and access_token calls with
+ */
+ function to_string() {
+ return "oauth_token=" .
+ OAuthUtil::urlencode_rfc3986($this->key) .
+ "&oauth_token_secret=" .
+ OAuthUtil::urlencode_rfc3986($this->secret);
+ }
+
+ function __toString() {
+ return $this->to_string();
+ }
+}
+
+/**
+ * A class for implementing a Signature Method
+ * See section 9 ("Signing Requests") in the spec
+ */
+abstract class OAuthSignatureMethod {
+ /**
+ * Needs to return the name of the Signature Method (ie HMAC-SHA1)
+ * @return string
+ */
+ abstract public function get_name();
+
+ /**
+ * Build up the signature
+ * NOTE: The output of this function MUST NOT be urlencoded.
+ * the encoding is handled in OAuthRequest when the final
+ * request is serialized
+ * @param OAuthRequest $request
+ * @param OAuthConsumer $consumer
+ * @param OAuthToken $token
+ * @return string
+ */
+ abstract public function build_signature($request, $consumer, $token);
+
+ /**
+ * Verifies that a given signature is correct
+ * @param OAuthRequest $request
+ * @param OAuthConsumer $consumer
+ * @param OAuthToken $token
+ * @param string $signature
+ * @return bool
+ */
+ public function check_signature($request, $consumer, $token, $signature) {
+ $built = $this->build_signature($request, $consumer, $token);
+ return $built == $signature;
+ }
+}
+
+/**
+ * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
+ * where the Signature Base String is the text and the key is the concatenated values (each first
+ * encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
+ * character (ASCII code 38) even if empty.
+ * - Chapter 9.2 ("HMAC-SHA1")
+ */
+class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
+ function get_name() {
+ return "HMAC-SHA1";
+ }
+
+ public function build_signature($request, $consumer, $token) {
+ $base_string = $request->get_signature_base_string();
+ $request->base_string = $base_string;
+
+ $key_parts = array(
+ $consumer->secret,
+ ($token) ? $token->secret : ""
+ );
+
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
+ $key = implode('&', $key_parts);
+
+ return base64_encode(hash_hmac('sha1', $base_string, $key, true));
+ }
+}
+
+/**
+ * The PLAINTEXT method does not provide any security protection and SHOULD only be used
+ * over a secure channel such as HTTPS. It does not use the Signature Base String.
+ * - Chapter 9.4 ("PLAINTEXT")
+ */
+class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
+ public function get_name() {
+ return "PLAINTEXT";
+ }
+
+ /**
+ * oauth_signature is set to the concatenated encoded values of the Consumer Secret and
+ * Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
+ * empty. The result MUST be encoded again.
+ * - Chapter 9.4.1 ("Generating Signatures")
+ *
+ * Please note that the second encoding MUST NOT happen in the SignatureMethod, as
+ * OAuthRequest handles this!
+ */
+ public function build_signature($request, $consumer, $token) {
+ $key_parts = array(
+ $consumer->secret,
+ ($token) ? $token->secret : ""
+ );
+
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
+ $key = implode('&', $key_parts);
+ $request->base_string = $key;
+
+ return $key;
+ }
+}
+
+/**
+ * The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
+ * [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
+ * EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
+ * verified way to the Service Provider, in a manner which is beyond the scope of this
+ * specification.
+ * - Chapter 9.3 ("RSA-SHA1")
+ */
+abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
+ public function get_name() {
+ return "RSA-SHA1";
+ }
+
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
+ // (2) fetch via http using a url provided by the requester
+ // (3) some sort of specific discovery code based on request
+ //
+ // Either way should return a string representation of the certificate
+ protected abstract function fetch_public_cert(&$request);
+
+ // Up to the SP to implement this lookup of keys. Possible ideas are:
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
+ //
+ // Either way should return a string representation of the certificate
+ protected abstract function fetch_private_cert(&$request);
+
+ public function build_signature($request, $consumer, $token) {
+ $base_string = $request->get_signature_base_string();
+ $request->base_string = $base_string;
+
+ // Fetch the private key cert based on the request
+ $cert = $this->fetch_private_cert($request);
+
+ // Pull the private key ID from the certificate
+ $privatekeyid = openssl_get_privatekey($cert);
+
+ // Sign using the key
+ $ok = openssl_sign($base_string, $signature, $privatekeyid);
+
+ // Release the key resource
+ openssl_free_key($privatekeyid);
+
+ return base64_encode($signature);
+ }
+
+ public function check_signature($request, $consumer, $token, $signature) {
+ $decoded_sig = base64_decode($signature);
+
+ $base_string = $request->get_signature_base_string();
+
+ // Fetch the public key cert based on the request
+ $cert = $this->fetch_public_cert($request);
+
+ // Pull the public key ID from the certificate
+ $publickeyid = openssl_get_publickey($cert);
+
+ // Check the computed signature against the one passed in the query
+ $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
+
+ // Release the key resource
+ openssl_free_key($publickeyid);
+
+ return $ok == 1;
+ }
+}
+
+class OAuthRequest {
+ private $parameters;
+ private $http_method;
+ private $http_url;
+ // for debug purposes
+ public $base_string;
+ public static $version = '1.0';
+ public static $POST_INPUT = 'php://input';
+
+ function __construct($http_method, $http_url, $parameters=NULL) {
+ @$parameters or $parameters = array();
+ $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
+ $this->parameters = $parameters;
+ $this->http_method = $http_method;
+ $this->http_url = $http_url;
+ }
+
+
+ /**
+ * attempt to build up a request from what was passed to the server
+ */
+ public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
+ $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
+ ? 'http'
+ : 'https';
+ @$http_url or $http_url = $scheme .
+ '://' . $_SERVER['HTTP_HOST'] .
+ ':' .
+ $_SERVER['SERVER_PORT'] .
+ $_SERVER['REQUEST_URI'];
+ @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
+
+ // We weren't handed any parameters, so let's find the ones relevant to
+ // this request.
+ // If you run XML-RPC or similar you should use this to provide your own
+ // parsed parameter-list
+ if (!$parameters) {
+ // Find request headers
+ $request_headers = OAuthUtil::get_headers();
+
+ // Parse the query-string to find GET parameters
+ $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
+
+ // It's a POST request of the proper content-type, so parse POST
+ // parameters and add those overriding any duplicates from GET
+ if ($http_method == "POST"
+ && @strstr($request_headers["Content-Type"],
+ "application/x-www-form-urlencoded")
+ ) {
+ $post_data = OAuthUtil::parse_parameters(
+ file_get_contents(self::$POST_INPUT)
+ );
+ $parameters = array_merge($parameters, $post_data);
+ }
+
+ // We have a Authorization-header with OAuth data. Parse the header
+ // and add those overriding any duplicates from GET or POST
+ if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
+ $header_parameters = OAuthUtil::split_header(
+ $request_headers['Authorization']
+ );
+ $parameters = array_merge($parameters, $header_parameters);
+ }
+
+ }
+
+ return new OAuthRequest($http_method, $http_url, $parameters);
+ }
+
+ /**
+ * pretty much a helper function to set up the request
+ */
+ public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
+ @$parameters or $parameters = array();
+ $defaults = array("oauth_version" => OAuthRequest::$version,
+ "oauth_nonce" => OAuthRequest::generate_nonce(),
+ "oauth_timestamp" => OAuthRequest::generate_timestamp(),
+ "oauth_consumer_key" => $consumer->key);
+ if ($token)
+ $defaults['oauth_token'] = $token->key;
+
+ $parameters = array_merge($defaults, $parameters);
+
+ return new OAuthRequest($http_method, $http_url, $parameters);
+ }
+
+ public function set_parameter($name, $value, $allow_duplicates = true) {
+ if ($allow_duplicates && isset($this->parameters[$name])) {
+ // We have already added parameter(s) with this name, so add to the list
+ if (is_scalar($this->parameters[$name])) {
+ // This is the first duplicate, so transform scalar (string)
+ // into an array so we can add the duplicates
+ $this->parameters[$name] = array($this->parameters[$name]);
+ }
+
+ $this->parameters[$name][] = $value;
+ } else {
+ $this->parameters[$name] = $value;
+ }
+ }
+
+ public function get_parameter($name) {
+ return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
+ }
+
+ public function get_parameters() {
+ return $this->parameters;
+ }
+
+ public function unset_parameter($name) {
+ unset($this->parameters[$name]);
+ }
+
+ /**
+ * The request parameters, sorted and concatenated into a normalized string.
+ * @return string
+ */
+ public function get_signable_parameters() {
+ // Grab all parameters
+ $params = $this->parameters;
+
+ // Remove oauth_signature if present
+ // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
+ if (isset($params['oauth_signature'])) {
+ unset($params['oauth_signature']);
+ }
+
+ return OAuthUtil::build_http_query($params);
+ }
+
+ /**
+ * Returns the base string of this request
+ *
+ * The base string defined as the method, the url
+ * and the parameters (normalized), each urlencoded
+ * and the concated with &.
+ */
+ public function get_signature_base_string() {
+ $parts = array(
+ $this->get_normalized_http_method(),
+ $this->get_normalized_http_url(),
+ $this->get_signable_parameters()
+ );
+
+ $parts = OAuthUtil::urlencode_rfc3986($parts);
+
+ return implode('&', $parts);
+ }
+
+ /**
+ * just uppercases the http method
+ */
+ public function get_normalized_http_method() {
+ return strtoupper($this->http_method);
+ }
+
+ /**
+ * parses the url and rebuilds it to be
+ * scheme://host/path
+ */
+ public function get_normalized_http_url() {
+ $parts = parse_url($this->http_url);
+
+ $port = @$parts['port'];
+ $scheme = $parts['scheme'];
+ $host = $parts['host'];
+ $path = @$parts['path'];
+
+ $port or $port = ($scheme == 'https') ? '443' : '80';
+
+ if (($scheme == 'https' && $port != '443')
+ || ($scheme == 'http' && $port != '80')) {
+ $host = "$host:$port";
+ }
+ return "$scheme://$host$path";
+ }
+
+ /**
+ * builds a url usable for a GET request
+ */
+ public function to_url() {
+ $post_data = $this->to_postdata();
+ $out = $this->get_normalized_http_url();
+ if ($post_data) {
+ $out .= '?'.$post_data;
+ }
+ return $out;
+ }
+
+ /**
+ * builds the data one would send in a POST request
+ */
+ public function to_postdata() {
+ return OAuthUtil::build_http_query($this->parameters);
+ }
+
+ /**
+ * builds the Authorization: header
+ */
+ public function to_header($realm=null) {
+ $first = true;
+ if($realm) {
+ $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
+ $first = false;
+ } else
+ $out = 'Authorization: OAuth';
+
+ $total = array();
+ foreach ($this->parameters as $k => $v) {
+ if (substr($k, 0, 5) != "oauth") continue;
+ if (is_array($v)) {
+ throw new OAuthException('Arrays not supported in headers');
+ }
+ $out .= ($first) ? ' ' : ',';
+ $out .= OAuthUtil::urlencode_rfc3986($k) .
+ '="' .
+ OAuthUtil::urlencode_rfc3986($v) .
+ '"';
+ $first = false;
+ }
+ return $out;
+ }
+
+ public function __toString() {
+ return $this->to_url();
+ }
+
+
+ public function sign_request($signature_method, $consumer, $token) {
+ $this->set_parameter(
+ "oauth_signature_method",
+ $signature_method->get_name(),
+ false
+ );
+ $signature = $this->build_signature($signature_method, $consumer, $token);
+ $this->set_parameter("oauth_signature", $signature, false);
+ }
+
+ public function build_signature($signature_method, $consumer, $token) {
+ $signature = $signature_method->build_signature($this, $consumer, $token);
+ return $signature;
+ }
+
+ /**
+ * util function: current timestamp
+ */
+ private static function generate_timestamp() {
+ return time();
+ }
+
+ /**
+ * util function: current nonce
+ */
+ private static function generate_nonce() {
+ $mt = microtime();
+ $rand = mt_rand();
+
+ return md5($mt . $rand); // md5s look nicer than numbers
+ }
+}
+
+class OAuthServer {
+ protected $timestamp_threshold = 300; // in seconds, five minutes
+ protected $version = '1.0'; // hi blaine
+ protected $signature_methods = array();
+
+ protected $data_store;
+
+ function __construct($data_store) {
+ $this->data_store = $data_store;
+ }
+
+ public function add_signature_method($signature_method) {
+ $this->signature_methods[$signature_method->get_name()] =
+ $signature_method;
+ }
+
+ // high level functions
+
+ /**
+ * process a request_token request
+ * returns the request token on success
+ */
+ public function fetch_request_token(&$request) {
+ $this->get_version($request);
+
+ $consumer = $this->get_consumer($request);
+
+ // no token required for the initial token request
+ $token = NULL;
+
+ $this->check_signature($request, $consumer, $token);
+
+ // Rev A change
+ $callback = $request->get_parameter('oauth_callback');
+ $new_token = $this->data_store->new_request_token($consumer, $callback);
+
+ return $new_token;
+ }
+
+ /**
+ * process an access_token request
+ * returns the access token on success
+ */
+ public function fetch_access_token(&$request) {
+ $this->get_version($request);
+
+ $consumer = $this->get_consumer($request);
+
+ // requires authorized request token
+ $token = $this->get_token($request, $consumer, "request");
+
+ $this->check_signature($request, $consumer, $token);
+
+ // Rev A change
+ $verifier = $request->get_parameter('oauth_verifier');
+ $new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
+
+ return $new_token;
+ }
+
+ /**
+ * verify an api call, checks all the parameters
+ */
+ public function verify_request(&$request) {
+ $this->get_version($request);
+ $consumer = $this->get_consumer($request);
+ $token = $this->get_token($request, $consumer, "access");
+ $this->check_signature($request, $consumer, $token);
+ return array($consumer, $token);
+ }
+
+ // Internals from here
+ /**
+ * version 1
+ */
+ private function get_version(&$request) {
+ $version = $request->get_parameter("oauth_version");
+ if (!$version) {
+ // Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
+ // Chapter 7.0 ("Accessing Protected Ressources")
+ $version = '1.0';
+ }
+ if ($version !== $this->version) {
+ throw new OAuthException("OAuth version '$version' not supported");
+ }
+ return $version;
+ }
+
+ /**
+ * figure out the signature with some defaults
+ */
+ private function get_signature_method(&$request) {
+ $signature_method =
+ @$request->get_parameter("oauth_signature_method");
+
+ if (!$signature_method) {
+ // According to chapter 7 ("Accessing Protected Ressources") the signature-method
+ // parameter is required, and we can't just fallback to PLAINTEXT
+ throw new OAuthException('No signature method parameter. This parameter is required');
+ }
+
+ if (!in_array($signature_method,
+ array_keys($this->signature_methods))) {
+ throw new OAuthException(
+ "Signature method '$signature_method' not supported " .
+ "try one of the following: " .
+ implode(", ", array_keys($this->signature_methods))
+ );
+ }
+ return $this->signature_methods[$signature_method];
+ }
+
+ /**
+ * try to find the consumer for the provided request's consumer key
+ */
+ private function get_consumer(&$request) {
+ $consumer_key = @$request->get_parameter("oauth_consumer_key");
+ if (!$consumer_key) {
+ throw new OAuthException("Invalid consumer key");
+ }
+
+ $consumer = $this->data_store->lookup_consumer($consumer_key);
+ if (!$consumer) {
+ throw new OAuthException("Invalid consumer");
+ }
+
+ return $consumer;
+ }
+
+ /**
+ * try to find the token for the provided request's token key
+ */
+ private function get_token(&$request, $consumer, $token_type="access") {
+ $token_field = @$request->get_parameter('oauth_token');
+ $token = $this->data_store->lookup_token(
+ $consumer, $token_type, $token_field
+ );
+ if (!$token) {
+ throw new OAuthException("Invalid $token_type token: $token_field");
+ }
+ return $token;
+ }
+
+ /**
+ * all-in-one function to check the signature on a request
+ * should guess the signature method appropriately
+ */
+ private function check_signature(&$request, $consumer, $token) {
+ // this should probably be in a different method
+ $timestamp = @$request->get_parameter('oauth_timestamp');
+ $nonce = @$request->get_parameter('oauth_nonce');
+
+ $this->check_timestamp($timestamp);
+ $this->check_nonce($consumer, $token, $nonce, $timestamp);
+
+ $signature_method = $this->get_signature_method($request);
+
+ $signature = $request->get_parameter('oauth_signature');
+ $valid_sig = $signature_method->check_signature(
+ $request,
+ $consumer,
+ $token,
+ $signature
+ );
+
+ if (!$valid_sig) {
+ throw new OAuthException("Invalid signature");
+ }
+ }
+
+ /**
+ * check that the timestamp is new enough
+ */
+ private function check_timestamp($timestamp) {
+ if( ! $timestamp )
+ throw new OAuthException(
+ 'Missing timestamp parameter. The parameter is required'
+ );
+
+ // verify that timestamp is recentish
+ $now = time();
+ if (abs($now - $timestamp) > $this->timestamp_threshold) {
+ throw new OAuthException(
+ "Expired timestamp, yours $timestamp, ours $now"
+ );
+ }
+ }
+
+ /**
+ * check that the nonce is not repeated
+ */
+ private function check_nonce($consumer, $token, $nonce, $timestamp) {
+ if( ! $nonce )
+ throw new OAuthException(
+ 'Missing nonce parameter. The parameter is required'
+ );
+
+ // verify that the nonce is uniqueish
+ $found = $this->data_store->lookup_nonce(
+ $consumer,
+ $token,
+ $nonce,
+ $timestamp
+ );
+ if ($found) {
+ throw new OAuthException("Nonce already used: $nonce");
+ }
+ }
+
+}
+
+class OAuthDataStore {
+ function lookup_consumer($consumer_key) {
+ // implement me
+ }
+
+ function lookup_token($consumer, $token_type, $token) {
+ // implement me
+ }
+
+ function lookup_nonce($consumer, $token, $nonce, $timestamp) {
+ // implement me
+ }
+
+ function new_request_token($consumer, $callback = null) {
+ // return a new token attached to this consumer
+ }
+
+ function new_access_token($token, $consumer, $verifier = null) {
+ // return a new access token attached to this consumer
+ // for the user associated with this token if the request token
+ // is authorized
+ // should also invalidate the request token
+ }
+
+}
+
+class OAuthUtil {
+ public static function urlencode_rfc3986($input) {
+ if (is_array($input)) {
+ return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
+ } else if (is_scalar($input)) {
+ return str_replace(
+ '+',
+ ' ',
+ str_replace('%7E', '~', rawurlencode($input))
+ );
+ } else {
+ return '';
+ }
+}
+
+
+ // This decode function isn't taking into consideration the above
+ // modifications to the encoding process. However, this method doesn't
+ // seem to be used anywhere so leaving it as is.
+ public static function urldecode_rfc3986($string) {
+ return urldecode($string);
+ }
+
+ // Utility function for turning the Authorization: header into
+ // parameters, has to do some unescaping
+ // Can filter out any non-oauth parameters if needed (default behaviour)
+ public static function split_header($header, $only_allow_oauth_parameters = true) {
+ $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
+ $offset = 0;
+ $params = array();
+ while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
+ $match = $matches[0];
+ $header_name = $matches[2][0];
+ $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
+ if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
+ $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
+ }
+ $offset = $match[1] + strlen($match[0]);
+ }
+
+ if (isset($params['realm'])) {
+ unset($params['realm']);
+ }
+
+ return $params;
+ }
+
+ // helper to try to sort out headers for people who aren't running apache
+ public static function get_headers() {
+ if (function_exists('apache_request_headers')) {
+ // we need this to get the actual Authorization: header
+ // because apache tends to tell us it doesn't exist
+ $headers = apache_request_headers();
+
+ // sanitize the output of apache_request_headers because
+ // we always want the keys to be Cased-Like-This and arh()
+ // returns the headers in the same case as they are in the
+ // request
+ $out = array();
+ foreach( $headers AS $key => $value ) {
+ $key = str_replace(
+ " ",
+ "-",
+ ucwords(strtolower(str_replace("-", " ", $key)))
+ );
+ $out[$key] = $value;
+ }
+ } else {
+ // otherwise we don't have apache and are just going to have to hope
+ // that $_SERVER actually contains what we need
+ $out = array();
+ if( isset($_SERVER['CONTENT_TYPE']) )
+ $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
+ if( isset($_ENV['CONTENT_TYPE']) )
+ $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
+
+ foreach ($_SERVER as $key => $value) {
+ if (substr($key, 0, 5) == "HTTP_") {
+ // this is chaos, basically it is just there to capitalize the first
+ // letter of every word that is not an initial HTTP and strip HTTP
+ // code from przemek
+ $key = str_replace(
+ " ",
+ "-",
+ ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
+ );
+ $out[$key] = $value;
+ }
+ }
+ }
+ return $out;
+ }
+
+ // This function takes a input like a=b&a=c&d=e and returns the parsed
+ // parameters like this
+ // array('a' => array('b','c'), 'd' => 'e')
+ public static function parse_parameters( $input ) {
+ if (!isset($input) || !$input) return array();
+
+ $pairs = explode('&', $input);
+
+ $parsed_parameters = array();
+ foreach ($pairs as $pair) {
+ $split = explode('=', $pair, 2);
+ $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
+ $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
+
+ if (isset($parsed_parameters[$parameter])) {
+ // We have already recieved parameter(s) with this name, so add to the list
+ // of parameters with this name
+
+ if (is_scalar($parsed_parameters[$parameter])) {
+ // This is the first duplicate, so transform scalar (string) into an array
+ // so we can add the duplicates
+ $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
+ }
+
+ $parsed_parameters[$parameter][] = $value;
+ } else {
+ $parsed_parameters[$parameter] = $value;
+ }
+ }
+ return $parsed_parameters;
+ }
+
+ public static function build_http_query($params) {
+ if (!$params) return '';
+
+ // Urlencode both keys and values
+ $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
+ $values = OAuthUtil::urlencode_rfc3986(array_values($params));
+ $params = array_combine($keys, $values);
+
+ // Parameters are sorted by name, using lexicographical byte value ordering.
+ // Ref: Spec: 9.1.1 (1)
+ uksort($params, 'strcmp');
+
+ $pairs = array();
+ foreach ($params as $parameter => $value) {
+ if (is_array($value)) {
+ // If two or more parameters share the same name, they are sorted by their value
+ // Ref: Spec: 9.1.1 (1)
+ natsort($value);
+ foreach ($value as $duplicate_value) {
+ $pairs[] = $parameter . '=' . $duplicate_value;
+ }
+ } else {
+ $pairs[] = $parameter . '=' . $value;
+ }
+ }
+ // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
+ // Each name-value pair is separated by an '&' character (ASCII code 38)
+ return implode('&', $pairs);
+ }
+}
+
+?>
diff --git a/tumblr/tumblroauth/tumblroauth.php b/tumblr/tumblroauth/tumblroauth.php
new file mode 100644
index 000000000..3c6f13c12
--- /dev/null
+++ b/tumblr/tumblroauth/tumblroauth.php
@@ -0,0 +1,245 @@
+http_status; }
+ function lastAPICall() { return $this->last_api_call; }
+
+ /**
+ * construct TumblrOAuth object
+ */
+ function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
+ $this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
+ $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
+ if (!empty($oauth_token) && !empty($oauth_token_secret)) {
+ $this->token = new OAuthConsumer($oauth_token, $oauth_token_secret);
+ } else {
+ $this->token = NULL;
+ }
+ }
+
+
+ /**
+ * Get a request_token from Tumblr
+ *
+ * @returns a key/value array containing oauth_token and oauth_token_secret
+ */
+ function getRequestToken($oauth_callback = NULL) {
+ $parameters = array();
+ if (!empty($oauth_callback)) {
+ $parameters['oauth_callback'] = $oauth_callback;
+ }
+ $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
+ $token = OAuthUtil::parse_parameters($request);
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
+ return $token;
+ }
+
+ /**
+ * Get the authorize URL
+ *
+ * @returns a string
+ */
+ function getAuthorizeURL($token, $sign_in_with_tumblr = TRUE) {
+ if (is_array($token)) {
+ $token = $token['oauth_token'];
+ }
+ if (empty($sign_in_with_tumblr)) {
+ return $this->authorizeURL() . "?oauth_token={$token}";
+ } else {
+ return $this->authenticateURL() . "?oauth_token={$token}";
+ }
+ }
+
+ /**
+ * Exchange request token and secret for an access token and
+ * secret, to sign API calls.
+ *
+ * @returns array("oauth_token" => "the-access-token",
+ * "oauth_token_secret" => "the-access-secret",
+ * "user_id" => "9436992",
+ * "screen_name" => "abraham")
+ */
+ function getAccessToken($oauth_verifier = FALSE) {
+ $parameters = array();
+ if (!empty($oauth_verifier)) {
+ $parameters['oauth_verifier'] = $oauth_verifier;
+ }
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
+ $token = OAuthUtil::parse_parameters($request);
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
+ return $token;
+ }
+
+ /**
+ * One time exchange of username and password for access token and secret.
+ *
+ * @returns array("oauth_token" => "the-access-token",
+ * "oauth_token_secret" => "the-access-secret",
+ * "user_id" => "9436992",
+ * "screen_name" => "abraham",
+ * "x_auth_expires" => "0")
+ */
+ function getXAuthToken($username, $password) {
+ $parameters = array();
+ $parameters['x_auth_username'] = $username;
+ $parameters['x_auth_password'] = $password;
+ $parameters['x_auth_mode'] = 'client_auth';
+ $request = $this->oAuthRequest($this->accessTokenURL(), 'POST', $parameters);
+ $token = OAuthUtil::parse_parameters($request);
+ $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
+ return $token;
+ }
+
+ /**
+ * GET wrapper for oAuthRequest.
+ */
+ function get($url, $parameters = array()) {
+ $response = $this->oAuthRequest($url, 'GET', $parameters);
+ if ($this->format === 'json' && $this->decode_json) {
+ return json_decode($response);
+ }
+ return $response;
+ }
+
+ /**
+ * POST wrapper for oAuthRequest.
+ */
+ function post($url, $parameters = array()) {
+ $response = $this->oAuthRequest($url, 'POST', $parameters);
+ if ($this->format === 'json' && $this->decode_json) {
+ return json_decode($response);
+ }
+ return $response;
+ }
+
+ /**
+ * DELETE wrapper for oAuthReqeust.
+ */
+ function delete($url, $parameters = array()) {
+ $response = $this->oAuthRequest($url, 'DELETE', $parameters);
+ if ($this->format === 'json' && $this->decode_json) {
+ return json_decode($response);
+ }
+ return $response;
+ }
+
+ /**
+ * Format and sign an OAuth / API request
+ */
+ function oAuthRequest($url, $method, $parameters) {
+ if (strrpos($url, 'https://') !== 0 && strrpos($url, 'http://') !== 0) {
+ $url = "{$this->host}{$url}";
+ }
+ $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
+ $request->sign_request($this->sha1_method, $this->consumer, $this->token);
+ switch ($method) {
+ case 'GET':
+ return $this->http($request->to_url(), 'GET');
+ default:
+ return $this->http($request->get_normalized_http_url(), $method, $request->to_postdata());
+ }
+ }
+
+ /**
+ * Make an HTTP request
+ *
+ * @return API results
+ */
+ function http($url, $method, $postfields = NULL) {
+ $this->http_info = array();
+ $ci = curl_init();
+ /* Curl settings */
+ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
+ curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
+ curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
+ curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
+ curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
+ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
+ curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
+ curl_setopt($ci, CURLOPT_HEADER, FALSE);
+
+ switch ($method) {
+ case 'POST':
+ curl_setopt($ci, CURLOPT_POST, TRUE);
+ if (!empty($postfields)) {
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
+ }
+ break;
+ case 'DELETE':
+ curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
+ if (!empty($postfields)) {
+ $url = "{$url}?{$postfields}";
+ }
+ }
+
+ curl_setopt($ci, CURLOPT_URL, $url);
+ $response = curl_exec($ci);
+ $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
+ $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
+ $this->url = $url;
+ curl_close ($ci);
+ return $response;
+ }
+
+ /**
+ * Get the header info to store.
+ */
+ function getHeader($ch, $header) {
+ $i = strpos($header, ':');
+ if (!empty($i)) {
+ $key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
+ $value = trim(substr($header, $i + 2));
+ $this->http_header[$key] = $value;
+ }
+ return strlen($header);
+ }
+}
diff --git a/twitter.tgz b/twitter.tgz
index beeea2bee..0505830c0 100755
Binary files a/twitter.tgz and b/twitter.tgz differ
diff --git a/twitter/twitter.php b/twitter/twitter.php
index 5fd053fa7..6cb2d9cd8 100755
--- a/twitter/twitter.php
+++ b/twitter/twitter.php
@@ -261,6 +261,115 @@ function short_link ($url) {
return $slinky->short();
} };
+function twitter_shortenmsg($b) {
+ require_once("include/bbcode.php");
+ require_once("include/html2plain.php");
+
+ $max_char = 140;
+
+ // Looking for the first image
+ $image = '';
+ if(preg_match("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/is",$b['body'],$matches))
+ $image = $matches[3];
+
+ if ($image == '')
+ if(preg_match("/\[img\](.*?)\[\/img\]/is",$b['body'],$matches))
+ $image = $matches[1];
+
+ $multipleimages = (strpos($b['body'], "[img") != strrpos($b['body'], "[img"));
+
+ // When saved into the database the content is sent through htmlspecialchars
+ // That means that we have to decode all image-urls
+ $image = htmlspecialchars_decode($image);
+
+ $body = $b["body"];
+ if ($b["title"] != "")
+ $body = $b["title"]."\n\n".$body;
+
+ // remove the recycle signs and the names since they aren't helpful on twitter
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body);
+ // recycle 2 (Test)
+ $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
+ $body = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', "\n", $body);
+
+ // remove the share element
+ $body = preg_replace("/\[share(.*?)\](.*?)\[\/share\]/ism","\n\n$2\n\n",$body);
+
+ // At first convert the text to html
+ $html = bbcode($body, false, false);
+
+ // Then convert it to plain text
+ //$msg = trim($b['title']." \n\n".html2plain($html, 0, true));
+ $msg = trim(html2plain($html, 0, true));
+ $msg = html_entity_decode($msg,ENT_QUOTES,'UTF-8');
+
+ // Removing multiple newlines
+ while (strpos($msg, "\n\n\n") !== false)
+ $msg = str_replace("\n\n\n", "\n\n", $msg);
+
+ // Removing multiple spaces
+ while (strpos($msg, " ") !== false)
+ $msg = str_replace(" ", " ", $msg);
+
+ // Removing URLs
+ $msg = preg_replace('/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', "", $msg);
+
+ $msg = trim($msg);
+
+ $link = '';
+ // look for bookmark-bbcode and handle it with priority
+ if(preg_match("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/is",$b['body'],$matches))
+ $link = $matches[1];
+
+ $multiplelinks = (strpos($b['body'], "[bookmark") != strrpos($b['body'], "[bookmark"));
+
+ // If there is no bookmark element then take the first link
+ if ($link == '') {
+ $links = collecturls($html);
+ if (sizeof($links) > 0) {
+ reset($links);
+ $link = current($links);
+ }
+ $multiplelinks = (sizeof($links) > 1);
+ }
+
+ $msglink = "";
+ if ($multiplelinks)
+ $msglink = $b["plink"];
+ else if ($link != "")
+ $msglink = $link;
+ else if ($multipleimages)
+ $msglink = $b["plink"];
+ else if ($image != "")
+ $msglink = $image;
+
+ if (($msglink == "") and strlen($msg) > $max_char)
+ $msglink = $b["plink"];
+
+ if (strlen($msglink) > 20)
+ $msglink = short_link($msglink);
+
+ if (strlen(trim($msg." ".$msglink)) > $max_char) {
+ $msg = substr($msg, 0, $max_char - (strlen($msglink)));
+ $lastchar = substr($msg, -1);
+ $msg = substr($msg, 0, -1);
+ $pos = strrpos($msg, "\n");
+ if ($pos > 0)
+ $msg = substr($msg, 0, $pos);
+ else if ($lastchar != "\n")
+ $msg = substr($msg, 0, -3)."...";
+ }
+ $msg = str_replace("\n", " ", $msg);
+
+ // Removing multiple spaces - again
+ while (strpos($msg, " ") !== false)
+ $msg = str_replace(" ", " ", $msg);
+
+ return(trim($msg." ".$msglink));
+}
+
function twitter_post_hook(&$a,&$b) {
/**
@@ -294,81 +403,87 @@ function twitter_post_hook(&$a,&$b) {
$tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
// in theory max char is 140 but T. uses t.co to make links
// longer so we give them 10 characters extra
- $max_char = 130; // max. length for a tweet
- // we will only work with up to two times the length of the dent
- // we can later send to Twitter. This way we can "gain" some
- // information during shortening of potential links but do not
- // shorten all the links in a 200000 character long essay.
- if (! $b['title']=='') {
- $tmp = $b['title'] . ' : '. $b['body'];
-// $tmp = substr($tmp, 0, 4*$max_char);
- } else {
- $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char);
- }
- // if [url=bla][img]blub.png[/img][/url] get blub.png
- $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp);
- // preserve links to images, videos and audios
- $tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp);
- $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?video(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?youtube(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?vimeo(\\s+.*?\]|\])/i', '', $tmp);
- $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp);
- $linksenabled = get_pconfig($b['uid'],'twitter','post_taglinks');
- // if a #tag is linked, don't send the [url] over to SN
- // that is, don't send if the option is not set in the
- // connector settings
- if ($linksenabled=='0') {
- // #-tags
- $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
- // @-mentions
- $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
- // recycle 1
- $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
- $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
- // recycle 2 (Test)
- $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
- $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
- }
- $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
- $tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);
- // find all http or https links in the body of the entry and
- // apply the shortener if the link is longer then 20 characters
- if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) {
- preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls );
- foreach ($allurls as $url) {
- foreach ($url as $u) {
- if (strlen($u)>20) {
- $sl = short_link($u);
- $tmp = str_replace( $u, $sl, $tmp );
- }
- }
- }
- }
- // ok, all the links we want to send out are save, now strip
- // away the remaining bbcode
- //$msg = strip_tags(bbcode($tmp, false, false));
- $msg = bbcode($tmp, false, false);
- $msg = str_replace(array(' ',' '),"\n",$msg);
- $msg = strip_tags($msg);
- // quotes not working - let's try this
- $msg = html_entity_decode($msg);
- if (( strlen($msg) > $max_char) && $max_char > 0) {
- $shortlink = short_link( $b['plink'] );
- // the new message will be shortened such that "... $shortlink"
- // will fit into the character limit
- $msg = nl2br(substr($msg, 0, $max_char-strlen($shortlink)-4));
- $msg = str_replace(array(' ',' '),' ',$msg);
- $e = explode(' ', $msg);
- // remove the last word from the cut down message to
- // avoid sending cut words to the MicroBlog
- array_pop($e);
- $msg = implode(' ', $e);
- $msg .= '... ' . $shortlink;
- }
+ $intelligent_shortening = get_config('twitter','intelligent_shortening');
- $msg = trim($msg);
+ if (!$intelligent_shortening) {
+ $max_char = 130; // max. length for a tweet
+ // we will only work with up to two times the length of the dent
+ // we can later send to Twitter. This way we can "gain" some
+ // information during shortening of potential links but do not
+ // shorten all the links in a 200000 character long essay.
+ if (! $b['title']=='') {
+ $tmp = $b['title'] . ' : '. $b['body'];
+ // $tmp = substr($tmp, 0, 4*$max_char);
+ } else {
+ $tmp = $b['body']; // substr($b['body'], 0, 3*$max_char);
+ }
+ // if [url=bla][img]blub.png[/img][/url] get blub.png
+ $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\]\[img\](\\w+.*?)\\[\\/img\]\\[\\/url\]/i', '$2', $tmp);
+ // preserve links to images, videos and audios
+ $tmp = preg_replace( '/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism', '$3', $tmp);
+ $tmp = preg_replace( '/\[\\/?img(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?video(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?youtube(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?vimeo(\\s+.*?\]|\])/i', '', $tmp);
+ $tmp = preg_replace( '/\[\\/?audio(\\s+.*?\]|\])/i', '', $tmp);
+ $linksenabled = get_pconfig($b['uid'],'twitter','post_taglinks');
+ // if a #tag is linked, don't send the [url] over to SN
+ // that is, don't send if the option is not set in the
+ // connector settings
+ if ($linksenabled=='0') {
+ // #-tags
+ $tmp = preg_replace( '/#\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '#$2', $tmp);
+ // @-mentions
+ $tmp = preg_replace( '/@\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', '@$2', $tmp);
+ // recycle 1
+ $recycle = html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ // recycle 2 (Test)
+ $recycle = html_entity_decode("◌ ", ENT_QUOTES, 'UTF-8');
+ $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
+ }
+ $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
+ $tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);
+ // find all http or https links in the body of the entry and
+ // apply the shortener if the link is longer then 20 characters
+ if (( strlen($tmp)>$max_char ) && ( $max_char > 0 )) {
+ preg_match_all ( '/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/i', $tmp, $allurls );
+ foreach ($allurls as $url) {
+ foreach ($url as $u) {
+ if (strlen($u)>20) {
+ $sl = short_link($u);
+ $tmp = str_replace( $u, $sl, $tmp );
+ }
+ }
+ }
+ }
+ // ok, all the links we want to send out are save, now strip
+ // away the remaining bbcode
+ //$msg = strip_tags(bbcode($tmp, false, false));
+ $msg = bbcode($tmp, false, false);
+ $msg = str_replace(array(' ',' '),"\n",$msg);
+ $msg = strip_tags($msg);
+
+ // quotes not working - let's try this
+ $msg = html_entity_decode($msg);
+ if (( strlen($msg) > $max_char) && $max_char > 0) {
+ $shortlink = short_link( $b['plink'] );
+ // the new message will be shortened such that "... $shortlink"
+ // will fit into the character limit
+ $msg = nl2br(substr($msg, 0, $max_char-strlen($shortlink)-4));
+ $msg = str_replace(array(' ',' '),' ',$msg);
+ $e = explode(' ', $msg);
+ // remove the last word from the cut down message to
+ // avoid sending cut words to the MicroBlog
+ array_pop($e);
+ $msg = implode(' ', $e);
+ $msg .= '... ' . $shortlink;
+ }
+
+ $msg = trim($msg);
+ } else
+ $msg = twitter_shortenmsg($b);
// and now tweet it :-)
if(strlen($msg)) {
@@ -389,8 +504,14 @@ function twitter_plugin_admin_post(&$a){
info( t('Settings updated.'). EOL );
}
function twitter_plugin_admin(&$a, &$o){
- $t = file_get_contents( dirname(__file__). "/admin.tpl" );
- $o = replace_macros($t, array(
+ $t = get_markup_template( "admin.tpl", "addon/twitter/" );
+
+ $includes = array(
+ '$field_input' => 'field_input.tpl',
+ );
+ $includes = set_template_includes($a->theme['template_engine'], $includes);
+
+ $o = replace_macros($t, $includes + array(
'$submit' => t('Submit'),
// name, label, value, help, [extra values]
'$consumerkey' => array('consumerkey', t('Consumer key'), get_config('twitter', 'consumerkey' ), ''),
diff --git a/twitter/admin.tpl b/twitter/view/admin.tpl
old mode 100755
new mode 100644
similarity index 100%
rename from twitter/admin.tpl
rename to twitter/view/admin.tpl
diff --git a/twitter/view/smarty3/admin.tpl b/twitter/view/smarty3/admin.tpl
new file mode 100644
index 000000000..9efcb0656
--- /dev/null
+++ b/twitter/view/smarty3/admin.tpl
@@ -0,0 +1,3 @@
+{{include file="field_input.tpl" field=$consumerkey}}
+{{include file="field_input.tpl" field=$consumersecret}}
+
diff --git a/uhremotestorage.tgz b/uhremotestorage.tgz
index 4aa58096d..7a758b00d 100755
Binary files a/uhremotestorage.tgz and b/uhremotestorage.tgz differ
diff --git a/uhremotestorage/uhremotestorage.php b/uhremotestorage/uhremotestorage.php
index a2a8cc3dd..85d6b13e8 100755
--- a/uhremotestorage/uhremotestorage.php
+++ b/uhremotestorage/uhremotestorage.php
@@ -78,7 +78,7 @@ function uhremotestorage_settings($a, &$s){
'Dropbox' => 'Dropbox',
);
*/
- $tpl = file_get_contents(dirname(__file__)."/settings.tpl");
+ $tpl = get_markup_template("settings.tpl", "addon/uhremotestorage/");
$s .= replace_macros($tpl, array(
'$title' => 'Unhosted remote storage',
'$desc' => sprintf( t('Allow to use your friendica id (%s) to connecto to external unhosted-enabled storage (like ownCloud). See RemoteStorage WebFinger '), $uid ),
diff --git a/uhremotestorage/settings.tpl b/uhremotestorage/view/settings.tpl
old mode 100755
new mode 100644
similarity index 100%
rename from uhremotestorage/settings.tpl
rename to uhremotestorage/view/settings.tpl
diff --git a/uhremotestorage/view/smarty3/settings.tpl b/uhremotestorage/view/smarty3/settings.tpl
new file mode 100644
index 000000000..9a0a55f33
--- /dev/null
+++ b/uhremotestorage/view/smarty3/settings.tpl
@@ -0,0 +1,9 @@
+
+
{{$title}}
+
{{$desc}}
+ {{include file="field_input.tpl" field=$url}}
+ {{include file="field_input.tpl" field=$auth}}
+ {{include file="field_select.tpl" field=$api}}
+
+
+
diff --git a/widgets.tgz b/widgets.tgz
index f3b185783..d89204f59 100755
Binary files a/widgets.tgz and b/widgets.tgz differ
diff --git a/widgets/settings.tpl b/widgets/view/settings.tpl
similarity index 100%
rename from widgets/settings.tpl
rename to widgets/view/settings.tpl
diff --git a/widgets/view/smarty3/settings.tpl b/widgets/view/smarty3/settings.tpl
new file mode 100644
index 000000000..017fa1200
--- /dev/null
+++ b/widgets/view/smarty3/settings.tpl
@@ -0,0 +1,19 @@
+
+
{{$title}}
+
+ {{$label}}
+ {{$key}}
+
+
+
+
+
+
+
{{$widgets_h}}
+
+ {{foreach $widgets as $w}}
+ {{$w.1}}
+ {{/foreach}}
+
+
+
diff --git a/widgets/view/smarty3/widget_like.tpl b/widgets/view/smarty3/widget_like.tpl
new file mode 100644
index 000000000..ad5295754
--- /dev/null
+++ b/widgets/view/smarty3/widget_like.tpl
@@ -0,0 +1,3 @@
+
+{{$like}}
+{{$dislike}}
diff --git a/widgets/widget_like.tpl b/widgets/view/widget_like.tpl
similarity index 100%
rename from widgets/widget_like.tpl
rename to widgets/view/widget_like.tpl
diff --git a/widgets/widget_like.php b/widgets/widget_like.php
index 649d4a767..8f356da97 100755
--- a/widgets/widget_like.php
+++ b/widgets/widget_like.php
@@ -52,7 +52,8 @@ function like_widget_content(&$a, $conf){
$o = "";
- $t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
+# $t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
+ $t = get_markup_template("widget_like.tpl", "addon/widgets/");
$o .= replace_macros($t, array(
'$like' => $likes,
'$strlike' => sprintf( tt("%d person likes this", "%d people like this", $likes), $likes),
diff --git a/widgets/widgets.php b/widgets/widgets.php
index 47a6e48a6..72534ce3b 100755
--- a/widgets/widgets.php
+++ b/widgets/widgets.php
@@ -51,7 +51,8 @@ function widgets_settings(&$a,&$o) {
- $t = file_get_contents( dirname(__file__). "/settings.tpl" );
+# $t = file_get_contents( dirname(__file__). "/settings.tpl" );
+ $t = get_markup_template("settings.tpl", "addon/widgets/");
$o .= replace_macros($t, array(
'$submit' => t('Generate new key'),
'$baseurl' => $a->get_baseurl(),