Fix various compatibility issues with PHP 8
This commit is contained in:
committed by
Frédéric Guillot
parent
f5bb55bdb8
commit
4bf3b0d459
56
vendor/composer/autoload_classmap.php
vendored
56
vendor/composer/autoload_classmap.php
vendored
@@ -10,34 +10,34 @@ return array(
|
||||
'Base32\\Base32' => $vendorDir . '/christian-riesen/base32/src/Base32.php',
|
||||
'Base32\\Base32Hex' => $vendorDir . '/christian-riesen/base32/src/Base32Hex.php',
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'Eluceo\\iCal\\Component' => $vendorDir . '/eluceo/ical/src/Component.php',
|
||||
'Eluceo\\iCal\\Component\\Alarm' => $vendorDir . '/eluceo/ical/src/Component/Alarm.php',
|
||||
'Eluceo\\iCal\\Component\\Calendar' => $vendorDir . '/eluceo/ical/src/Component/Calendar.php',
|
||||
'Eluceo\\iCal\\Component\\Event' => $vendorDir . '/eluceo/ical/src/Component/Event.php',
|
||||
'Eluceo\\iCal\\Component\\Timezone' => $vendorDir . '/eluceo/ical/src/Component/Timezone.php',
|
||||
'Eluceo\\iCal\\Component\\TimezoneRule' => $vendorDir . '/eluceo/ical/src/Component/TimezoneRule.php',
|
||||
'Eluceo\\iCal\\ParameterBag' => $vendorDir . '/eluceo/ical/src/ParameterBag.php',
|
||||
'Eluceo\\iCal\\Property' => $vendorDir . '/eluceo/ical/src/Property.php',
|
||||
'Eluceo\\iCal\\PropertyBag' => $vendorDir . '/eluceo/ical/src/PropertyBag.php',
|
||||
'Eluceo\\iCal\\Property\\ArrayValue' => $vendorDir . '/eluceo/ical/src/Property/ArrayValue.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimeProperty' => $vendorDir . '/eluceo/ical/src/Property/DateTimeProperty.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimesProperty' => $vendorDir . '/eluceo/ical/src/Property/DateTimesProperty.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attachment' => $vendorDir . '/eluceo/ical/src/Property/Event/Attachment.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attendees' => $vendorDir . '/eluceo/ical/src/Property/Event/Attendees.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Geo' => $vendorDir . '/eluceo/ical/src/Property/Event/Geo.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Organizer' => $vendorDir . '/eluceo/ical/src/Property/Event/Organizer.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceId' => $vendorDir . '/eluceo/ical/src/Property/Event/RecurrenceId.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceRule' => $vendorDir . '/eluceo/ical/src/Property/Event/RecurrenceRule.php',
|
||||
'Eluceo\\iCal\\Property\\RawStringValue' => $vendorDir . '/eluceo/ical/src/Property/RawStringValue.php',
|
||||
'Eluceo\\iCal\\Property\\StringValue' => $vendorDir . '/eluceo/ical/src/Property/StringValue.php',
|
||||
'Eluceo\\iCal\\Property\\ValueInterface' => $vendorDir . '/eluceo/ical/src/Property/ValueInterface.php',
|
||||
'Eluceo\\iCal\\Util\\ComponentUtil' => $vendorDir . '/eluceo/ical/src/Util/ComponentUtil.php',
|
||||
'Eluceo\\iCal\\Util\\DateUtil' => $vendorDir . '/eluceo/ical/src/Util/DateUtil.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilder' => $vendorDir . '/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilderInterface' => $vendorDir . '/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilderInterface.php',
|
||||
'Gregwar\\Captcha\\ImageFileHandler' => $vendorDir . '/gregwar/captcha/src/Gregwar/Captcha/ImageFileHandler.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilder' => $vendorDir . '/gregwar/captcha/src/Gregwar/Captcha/PhraseBuilder.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilderInterface' => $vendorDir . '/gregwar/captcha/src/Gregwar/Captcha/PhraseBuilderInterface.php',
|
||||
'Eluceo\\iCal\\Component' => $baseDir . '/libs/ical/Component.php',
|
||||
'Eluceo\\iCal\\Component\\Alarm' => $baseDir . '/libs/ical/Component/Alarm.php',
|
||||
'Eluceo\\iCal\\Component\\Calendar' => $baseDir . '/libs/ical/Component/Calendar.php',
|
||||
'Eluceo\\iCal\\Component\\Event' => $baseDir . '/libs/ical/Component/Event.php',
|
||||
'Eluceo\\iCal\\Component\\Timezone' => $baseDir . '/libs/ical/Component/Timezone.php',
|
||||
'Eluceo\\iCal\\Component\\TimezoneRule' => $baseDir . '/libs/ical/Component/TimezoneRule.php',
|
||||
'Eluceo\\iCal\\ParameterBag' => $baseDir . '/libs/ical/ParameterBag.php',
|
||||
'Eluceo\\iCal\\Property' => $baseDir . '/libs/ical/Property.php',
|
||||
'Eluceo\\iCal\\PropertyBag' => $baseDir . '/libs/ical/PropertyBag.php',
|
||||
'Eluceo\\iCal\\Property\\ArrayValue' => $baseDir . '/libs/ical/Property/ArrayValue.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimeProperty' => $baseDir . '/libs/ical/Property/DateTimeProperty.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimesProperty' => $baseDir . '/libs/ical/Property/DateTimesProperty.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attachment' => $baseDir . '/libs/ical/Property/Event/Attachment.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attendees' => $baseDir . '/libs/ical/Property/Event/Attendees.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Geo' => $baseDir . '/libs/ical/Property/Event/Geo.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Organizer' => $baseDir . '/libs/ical/Property/Event/Organizer.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceId' => $baseDir . '/libs/ical/Property/Event/RecurrenceId.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceRule' => $baseDir . '/libs/ical/Property/Event/RecurrenceRule.php',
|
||||
'Eluceo\\iCal\\Property\\RawStringValue' => $baseDir . '/libs/ical/Property/RawStringValue.php',
|
||||
'Eluceo\\iCal\\Property\\StringValue' => $baseDir . '/libs/ical/Property/StringValue.php',
|
||||
'Eluceo\\iCal\\Property\\ValueInterface' => $baseDir . '/libs/ical/Property/ValueInterface.php',
|
||||
'Eluceo\\iCal\\Util\\ComponentUtil' => $baseDir . '/libs/ical/Util/ComponentUtil.php',
|
||||
'Eluceo\\iCal\\Util\\DateUtil' => $baseDir . '/libs/ical/Util/DateUtil.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilder' => $baseDir . '/libs/Captcha/CaptchaBuilder.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilderInterface' => $baseDir . '/libs/Captcha/CaptchaBuilderInterface.php',
|
||||
'Gregwar\\Captcha\\ImageFileHandler' => $baseDir . '/libs/Captcha/ImageFileHandler.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilder' => $baseDir . '/libs/Captcha/PhraseBuilder.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilderInterface' => $baseDir . '/libs/Captcha/PhraseBuilderInterface.php',
|
||||
'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
|
||||
'JsonRPC\\Client' => $baseDir . '/libs/jsonrpc/src/JsonRPC/Client.php',
|
||||
'JsonRPC\\Exception\\AccessDeniedException' => $baseDir . '/libs/jsonrpc/src/JsonRPC/Exception/AccessDeniedException.php',
|
||||
|
||||
2
vendor/composer/autoload_files.php
vendored
2
vendor/composer/autoload_files.php
vendored
@@ -10,6 +10,6 @@ return array(
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php',
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php',
|
||||
'2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
|
||||
'8a67f3044590529ed0a5e02f9cc9c90b' => $baseDir . '/app/functions.php',
|
||||
'dda285bdc738399c7167126cf41c82cb' => $baseDir . '/libs/swiftmailer/swift_required.php',
|
||||
);
|
||||
|
||||
4
vendor/composer/autoload_psr4.php
vendored
4
vendor/composer/autoload_psr4.php
vendored
@@ -19,7 +19,7 @@ return array(
|
||||
'MatthiasMullie\\PathConverter\\' => array($baseDir . '/libs/path-converter/src'),
|
||||
'MatthiasMullie\\Minify\\' => array($baseDir . '/libs/minify/src'),
|
||||
'Kanboard\\' => array($baseDir . '/app'),
|
||||
'Gregwar\\' => array($vendorDir . '/gregwar/captcha/src/Gregwar'),
|
||||
'Eluceo\\iCal\\' => array($vendorDir . '/eluceo/ical/src'),
|
||||
'Gregwar\\' => array($baseDir . '/libs'),
|
||||
'Eluceo\\iCal\\' => array($baseDir . '/libs/ical'),
|
||||
'Base32\\' => array($vendorDir . '/christian-riesen/base32/src'),
|
||||
);
|
||||
|
||||
62
vendor/composer/autoload_static.php
vendored
62
vendor/composer/autoload_static.php
vendored
@@ -11,8 +11,8 @@ class ComposerStaticInit80f59a55e693f3d5493bcaaa968d1851
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php',
|
||||
'2c102faa651ef8ea5874edb585946bce' => __DIR__ . '/..' . '/swiftmailer/swiftmailer/lib/swift_required.php',
|
||||
'8a67f3044590529ed0a5e02f9cc9c90b' => __DIR__ . '/../..' . '/app/functions.php',
|
||||
'dda285bdc738399c7167126cf41c82cb' => __DIR__ . '/../..' . '/libs/swiftmailer/swift_required.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
@@ -110,11 +110,11 @@ class ComposerStaticInit80f59a55e693f3d5493bcaaa968d1851
|
||||
),
|
||||
'Gregwar\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/gregwar/captcha/src/Gregwar',
|
||||
0 => __DIR__ . '/../..' . '/libs',
|
||||
),
|
||||
'Eluceo\\iCal\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/eluceo/ical/src',
|
||||
0 => __DIR__ . '/../..' . '/libs/ical',
|
||||
),
|
||||
'Base32\\' =>
|
||||
array (
|
||||
@@ -174,34 +174,34 @@ class ComposerStaticInit80f59a55e693f3d5493bcaaa968d1851
|
||||
'Base32\\Base32' => __DIR__ . '/..' . '/christian-riesen/base32/src/Base32.php',
|
||||
'Base32\\Base32Hex' => __DIR__ . '/..' . '/christian-riesen/base32/src/Base32Hex.php',
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'Eluceo\\iCal\\Component' => __DIR__ . '/..' . '/eluceo/ical/src/Component.php',
|
||||
'Eluceo\\iCal\\Component\\Alarm' => __DIR__ . '/..' . '/eluceo/ical/src/Component/Alarm.php',
|
||||
'Eluceo\\iCal\\Component\\Calendar' => __DIR__ . '/..' . '/eluceo/ical/src/Component/Calendar.php',
|
||||
'Eluceo\\iCal\\Component\\Event' => __DIR__ . '/..' . '/eluceo/ical/src/Component/Event.php',
|
||||
'Eluceo\\iCal\\Component\\Timezone' => __DIR__ . '/..' . '/eluceo/ical/src/Component/Timezone.php',
|
||||
'Eluceo\\iCal\\Component\\TimezoneRule' => __DIR__ . '/..' . '/eluceo/ical/src/Component/TimezoneRule.php',
|
||||
'Eluceo\\iCal\\ParameterBag' => __DIR__ . '/..' . '/eluceo/ical/src/ParameterBag.php',
|
||||
'Eluceo\\iCal\\Property' => __DIR__ . '/..' . '/eluceo/ical/src/Property.php',
|
||||
'Eluceo\\iCal\\PropertyBag' => __DIR__ . '/..' . '/eluceo/ical/src/PropertyBag.php',
|
||||
'Eluceo\\iCal\\Property\\ArrayValue' => __DIR__ . '/..' . '/eluceo/ical/src/Property/ArrayValue.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimeProperty' => __DIR__ . '/..' . '/eluceo/ical/src/Property/DateTimeProperty.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimesProperty' => __DIR__ . '/..' . '/eluceo/ical/src/Property/DateTimesProperty.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attachment' => __DIR__ . '/..' . '/eluceo/ical/src/Property/Event/Attachment.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attendees' => __DIR__ . '/..' . '/eluceo/ical/src/Property/Event/Attendees.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Geo' => __DIR__ . '/..' . '/eluceo/ical/src/Property/Event/Geo.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Organizer' => __DIR__ . '/..' . '/eluceo/ical/src/Property/Event/Organizer.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceId' => __DIR__ . '/..' . '/eluceo/ical/src/Property/Event/RecurrenceId.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceRule' => __DIR__ . '/..' . '/eluceo/ical/src/Property/Event/RecurrenceRule.php',
|
||||
'Eluceo\\iCal\\Property\\RawStringValue' => __DIR__ . '/..' . '/eluceo/ical/src/Property/RawStringValue.php',
|
||||
'Eluceo\\iCal\\Property\\StringValue' => __DIR__ . '/..' . '/eluceo/ical/src/Property/StringValue.php',
|
||||
'Eluceo\\iCal\\Property\\ValueInterface' => __DIR__ . '/..' . '/eluceo/ical/src/Property/ValueInterface.php',
|
||||
'Eluceo\\iCal\\Util\\ComponentUtil' => __DIR__ . '/..' . '/eluceo/ical/src/Util/ComponentUtil.php',
|
||||
'Eluceo\\iCal\\Util\\DateUtil' => __DIR__ . '/..' . '/eluceo/ical/src/Util/DateUtil.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilder' => __DIR__ . '/..' . '/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilderInterface' => __DIR__ . '/..' . '/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilderInterface.php',
|
||||
'Gregwar\\Captcha\\ImageFileHandler' => __DIR__ . '/..' . '/gregwar/captcha/src/Gregwar/Captcha/ImageFileHandler.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilder' => __DIR__ . '/..' . '/gregwar/captcha/src/Gregwar/Captcha/PhraseBuilder.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilderInterface' => __DIR__ . '/..' . '/gregwar/captcha/src/Gregwar/Captcha/PhraseBuilderInterface.php',
|
||||
'Eluceo\\iCal\\Component' => __DIR__ . '/../..' . '/libs/ical/Component.php',
|
||||
'Eluceo\\iCal\\Component\\Alarm' => __DIR__ . '/../..' . '/libs/ical/Component/Alarm.php',
|
||||
'Eluceo\\iCal\\Component\\Calendar' => __DIR__ . '/../..' . '/libs/ical/Component/Calendar.php',
|
||||
'Eluceo\\iCal\\Component\\Event' => __DIR__ . '/../..' . '/libs/ical/Component/Event.php',
|
||||
'Eluceo\\iCal\\Component\\Timezone' => __DIR__ . '/../..' . '/libs/ical/Component/Timezone.php',
|
||||
'Eluceo\\iCal\\Component\\TimezoneRule' => __DIR__ . '/../..' . '/libs/ical/Component/TimezoneRule.php',
|
||||
'Eluceo\\iCal\\ParameterBag' => __DIR__ . '/../..' . '/libs/ical/ParameterBag.php',
|
||||
'Eluceo\\iCal\\Property' => __DIR__ . '/../..' . '/libs/ical/Property.php',
|
||||
'Eluceo\\iCal\\PropertyBag' => __DIR__ . '/../..' . '/libs/ical/PropertyBag.php',
|
||||
'Eluceo\\iCal\\Property\\ArrayValue' => __DIR__ . '/../..' . '/libs/ical/Property/ArrayValue.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimeProperty' => __DIR__ . '/../..' . '/libs/ical/Property/DateTimeProperty.php',
|
||||
'Eluceo\\iCal\\Property\\DateTimesProperty' => __DIR__ . '/../..' . '/libs/ical/Property/DateTimesProperty.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attachment' => __DIR__ . '/../..' . '/libs/ical/Property/Event/Attachment.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Attendees' => __DIR__ . '/../..' . '/libs/ical/Property/Event/Attendees.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Geo' => __DIR__ . '/../..' . '/libs/ical/Property/Event/Geo.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\Organizer' => __DIR__ . '/../..' . '/libs/ical/Property/Event/Organizer.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceId' => __DIR__ . '/../..' . '/libs/ical/Property/Event/RecurrenceId.php',
|
||||
'Eluceo\\iCal\\Property\\Event\\RecurrenceRule' => __DIR__ . '/../..' . '/libs/ical/Property/Event/RecurrenceRule.php',
|
||||
'Eluceo\\iCal\\Property\\RawStringValue' => __DIR__ . '/../..' . '/libs/ical/Property/RawStringValue.php',
|
||||
'Eluceo\\iCal\\Property\\StringValue' => __DIR__ . '/../..' . '/libs/ical/Property/StringValue.php',
|
||||
'Eluceo\\iCal\\Property\\ValueInterface' => __DIR__ . '/../..' . '/libs/ical/Property/ValueInterface.php',
|
||||
'Eluceo\\iCal\\Util\\ComponentUtil' => __DIR__ . '/../..' . '/libs/ical/Util/ComponentUtil.php',
|
||||
'Eluceo\\iCal\\Util\\DateUtil' => __DIR__ . '/../..' . '/libs/ical/Util/DateUtil.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilder' => __DIR__ . '/../..' . '/libs/Captcha/CaptchaBuilder.php',
|
||||
'Gregwar\\Captcha\\CaptchaBuilderInterface' => __DIR__ . '/../..' . '/libs/Captcha/CaptchaBuilderInterface.php',
|
||||
'Gregwar\\Captcha\\ImageFileHandler' => __DIR__ . '/../..' . '/libs/Captcha/ImageFileHandler.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilder' => __DIR__ . '/../..' . '/libs/Captcha/PhraseBuilder.php',
|
||||
'Gregwar\\Captcha\\PhraseBuilderInterface' => __DIR__ . '/../..' . '/libs/Captcha/PhraseBuilderInterface.php',
|
||||
'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php',
|
||||
'JsonRPC\\Client' => __DIR__ . '/../..' . '/libs/jsonrpc/src/JsonRPC/Client.php',
|
||||
'JsonRPC\\Exception\\AccessDeniedException' => __DIR__ . '/../..' . '/libs/jsonrpc/src/JsonRPC/Exception/AccessDeniedException.php',
|
||||
|
||||
172
vendor/composer/installed.json
vendored
172
vendor/composer/installed.json
vendored
@@ -116,60 +116,6 @@
|
||||
],
|
||||
"install-path": "../christian-riesen/otp"
|
||||
},
|
||||
{
|
||||
"name": "eluceo/ical",
|
||||
"version": "0.16.1",
|
||||
"version_normalized": "0.16.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/markuspoerschke/iCal.git",
|
||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/markuspoerschke/iCal/zipball/7043337feaeacbc016844e7e52ef41bba504ad8f",
|
||||
"reference": "7043337feaeacbc016844e7e52ef41bba504ad8f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1 || ~8.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "Massive performance enhancement of line folding"
|
||||
},
|
||||
"time": "2020-10-04T17:41:11+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Eluceo\\iCal\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Markus Poerschke",
|
||||
"email": "markus@eluceo.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "The eluceo/iCal package offers a abstraction layer for creating iCalendars. You can easily create iCal files by using PHP object instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.",
|
||||
"homepage": "https://github.com/markuspoerschke/iCal",
|
||||
"keywords": [
|
||||
"calendar",
|
||||
"iCalendar",
|
||||
"ical",
|
||||
"ics",
|
||||
"php calendar"
|
||||
],
|
||||
"install-path": "../eluceo/ical"
|
||||
},
|
||||
{
|
||||
"name": "erusev/parsedown",
|
||||
"version": "1.7.4",
|
||||
@@ -219,62 +165,6 @@
|
||||
],
|
||||
"install-path": "../erusev/parsedown"
|
||||
},
|
||||
{
|
||||
"name": "gregwar/captcha",
|
||||
"version": "v1.1.9",
|
||||
"version_normalized": "1.1.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Gregwar/Captcha.git",
|
||||
"reference": "4bb668e6b40e3205a020ca5ee4ca8cff8b8780c5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Gregwar/Captcha/zipball/4bb668e6b40e3205a020ca5ee4ca8cff8b8780c5",
|
||||
"reference": "4bb668e6b40e3205a020ca5ee4ca8cff8b8780c5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-gd": "*",
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=5.3.0",
|
||||
"symfony/finder": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.4"
|
||||
},
|
||||
"time": "2020-03-24T14:39:05+00:00",
|
||||
"type": "captcha",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Gregwar\\": "src/Gregwar"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Grégoire Passault",
|
||||
"email": "g.passault@gmail.com",
|
||||
"homepage": "http://www.gregwar.com/"
|
||||
},
|
||||
{
|
||||
"name": "Jeremy Livingston",
|
||||
"email": "jeremy.j.livingston@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Captcha generator",
|
||||
"homepage": "https://github.com/Gregwar/Captcha",
|
||||
"keywords": [
|
||||
"bot",
|
||||
"captcha",
|
||||
"spam"
|
||||
],
|
||||
"install-path": "../gregwar/captcha"
|
||||
},
|
||||
{
|
||||
"name": "pimple/pimple",
|
||||
"version": "v3.5.0",
|
||||
@@ -429,68 +319,6 @@
|
||||
],
|
||||
"install-path": "../psr/log"
|
||||
},
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"version": "v5.4.8",
|
||||
"version_normalized": "5.4.8.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/swiftmailer/swiftmailer.git",
|
||||
"reference": "9a06dc570a0367850280eefd3f1dc2da45aef517"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/9a06dc570a0367850280eefd3f1dc2da45aef517",
|
||||
"reference": "9a06dc570a0367850280eefd3f1dc2da45aef517",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.1",
|
||||
"symfony/phpunit-bridge": "~3.2"
|
||||
},
|
||||
"time": "2017-05-01T15:54:03+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.4-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"lib/swift_required.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Chris Corbyn"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"homepage": "http://swiftmailer.org",
|
||||
"keywords": [
|
||||
"email",
|
||||
"mail",
|
||||
"mailer"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/swiftmailer/swiftmailer/issues",
|
||||
"source": "https://github.com/swiftmailer/swiftmailer/tree/v5.4.8"
|
||||
},
|
||||
"abandoned": "symfony/mailer",
|
||||
"install-path": "../swiftmailer/swiftmailer"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v4.4.37",
|
||||
|
||||
31
vendor/composer/installed.php
vendored
31
vendor/composer/installed.php
vendored
@@ -5,7 +5,7 @@
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '14cdaa07bd0dad30903e4136e85124e1435c1f93',
|
||||
'reference' => 'f5bb55bdb8fe95c37877d4788cb85cfcb49c4d77',
|
||||
'name' => 'kanboard/kanboard',
|
||||
'dev' => false,
|
||||
),
|
||||
@@ -28,15 +28,6 @@
|
||||
'reference' => '20a539ce6280eb029030f4e7caefd5709a75e1ad',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'eluceo/ical' => array(
|
||||
'pretty_version' => '0.16.1',
|
||||
'version' => '0.16.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../eluceo/ical',
|
||||
'aliases' => array(),
|
||||
'reference' => '7043337feaeacbc016844e7e52ef41bba504ad8f',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'erusev/parsedown' => array(
|
||||
'pretty_version' => '1.7.4',
|
||||
'version' => '1.7.4.0',
|
||||
@@ -46,22 +37,13 @@
|
||||
'reference' => 'cb17b6477dfff935958ba01325f2e8a2bfa6dab3',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'gregwar/captcha' => array(
|
||||
'pretty_version' => 'v1.1.9',
|
||||
'version' => '1.1.9.0',
|
||||
'type' => 'captcha',
|
||||
'install_path' => __DIR__ . '/../gregwar/captcha',
|
||||
'aliases' => array(),
|
||||
'reference' => '4bb668e6b40e3205a020ca5ee4ca8cff8b8780c5',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'kanboard/kanboard' => array(
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '14cdaa07bd0dad30903e4136e85124e1435c1f93',
|
||||
'reference' => 'f5bb55bdb8fe95c37877d4788cb85cfcb49c4d77',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'pimple/pimple' => array(
|
||||
@@ -103,15 +85,6 @@
|
||||
0 => '1.0|2.0',
|
||||
),
|
||||
),
|
||||
'swiftmailer/swiftmailer' => array(
|
||||
'pretty_version' => 'v5.4.8',
|
||||
'version' => '5.4.8.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../swiftmailer/swiftmailer',
|
||||
'aliases' => array(),
|
||||
'reference' => '9a06dc570a0367850280eefd3f1dc2da45aef517',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/console' => array(
|
||||
'pretty_version' => 'v4.4.37',
|
||||
'version' => '4.4.37.0',
|
||||
|
||||
19
vendor/eluceo/ical/LICENSE
vendored
19
vendor/eluceo/ical/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2012-2019 Markus Poerschke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
46
vendor/eluceo/ical/composer.json
vendored
46
vendor/eluceo/ical/composer.json
vendored
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "eluceo/ical",
|
||||
"description": "The eluceo/iCal package offers a abstraction layer for creating iCalendars. You can easily create iCal files by using PHP object instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/markuspoerschke/iCal",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Markus Poerschke",
|
||||
"email": "markus@eluceo.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"ical",
|
||||
"php calendar",
|
||||
"icalendar",
|
||||
"ics",
|
||||
"calendar"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/markuspoerschke/iCal/issues",
|
||||
"source": "https://github.com/markuspoerschke/iCal"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Eluceo\\iCal\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Eluceo\\iCal\\": "tests/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1 || ~8.0.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring" : "Massive performance enhancement of line folding"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "phpunit"
|
||||
}
|
||||
}
|
||||
184
vendor/eluceo/ical/src/Component.php
vendored
184
vendor/eluceo/ical/src/Component.php
vendored
@@ -1,184 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
use Eluceo\iCal\Util\ComponentUtil;
|
||||
|
||||
/**
|
||||
* Abstract Calender Component.
|
||||
*/
|
||||
abstract class Component
|
||||
{
|
||||
/**
|
||||
* Array of Components.
|
||||
*
|
||||
* @var Component[]
|
||||
*/
|
||||
protected $components = [];
|
||||
|
||||
/**
|
||||
* The order in which the components will be rendered during build.
|
||||
*
|
||||
* Not defined components will be appended at the end.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $componentsBuildOrder = ['VTIMEZONE', 'DAYLIGHT', 'STANDARD'];
|
||||
|
||||
/**
|
||||
* The type of the concrete Component.
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function getType();
|
||||
|
||||
/**
|
||||
* Building the PropertyBag.
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @return PropertyBag
|
||||
*/
|
||||
abstract public function buildPropertyBag();
|
||||
|
||||
/**
|
||||
* Adds a Component.
|
||||
*
|
||||
* If $key is given, the component at $key will be replaced else the component will be append.
|
||||
*
|
||||
* @param Component $component The Component that will be added
|
||||
* @param null $key The key of the Component
|
||||
*/
|
||||
public function addComponent(self $component, $key = null)
|
||||
{
|
||||
if (null == $key) {
|
||||
$this->components[] = $component;
|
||||
} else {
|
||||
$this->components[$key] = $component;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all Components.
|
||||
*
|
||||
* @param Component[] $components The array of Component that will be set
|
||||
* @param null $key The key of the Component
|
||||
*/
|
||||
public function setComponents(array $components)
|
||||
{
|
||||
$this->components = $components;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an array containing the lines of the iCal file.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
$lines[] = sprintf('BEGIN:%s', $this->getType());
|
||||
|
||||
/** @var $property Property */
|
||||
foreach ($this->buildPropertyBag() as $property) {
|
||||
foreach ($property->toLines() as $l) {
|
||||
$lines[] = $l;
|
||||
}
|
||||
}
|
||||
|
||||
$this->buildComponents($lines);
|
||||
|
||||
$lines[] = sprintf('END:%s', $this->getType());
|
||||
|
||||
$ret = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
foreach (ComponentUtil::fold($line) as $l) {
|
||||
$ret[] = $l;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return implode("\r\n", $this->build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the output when treating the class as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $lines
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function buildComponents(array &$lines)
|
||||
{
|
||||
$componentsByType = [];
|
||||
|
||||
/** @var $component Component */
|
||||
foreach ($this->components as $component) {
|
||||
$type = $component->getType();
|
||||
if (!isset($componentsByType[$type])) {
|
||||
$componentsByType[$type] = [];
|
||||
}
|
||||
$componentsByType[$type][] = $component;
|
||||
}
|
||||
|
||||
// render ordered components
|
||||
foreach ($this->componentsBuildOrder as $type) {
|
||||
if (!isset($componentsByType[$type])) {
|
||||
continue;
|
||||
}
|
||||
foreach ($componentsByType[$type] as $component) {
|
||||
$this->addComponentLines($lines, $component);
|
||||
}
|
||||
unset($componentsByType[$type]);
|
||||
}
|
||||
|
||||
// render all other
|
||||
foreach ($componentsByType as $components) {
|
||||
foreach ($components as $component) {
|
||||
$this->addComponentLines($lines, $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $component
|
||||
*/
|
||||
private function addComponentLines(array &$lines, self $component)
|
||||
{
|
||||
foreach ($component->build() as $l) {
|
||||
$lines[] = $l;
|
||||
}
|
||||
}
|
||||
}
|
||||
150
vendor/eluceo/ical/src/Component/Alarm.php
vendored
150
vendor/eluceo/ical/src/Component/Alarm.php
vendored
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
|
||||
/**
|
||||
* Implementation of the VALARM component.
|
||||
*/
|
||||
class Alarm extends Component
|
||||
{
|
||||
/**
|
||||
* Alarm ACTION property.
|
||||
*
|
||||
* According to RFC 5545: 3.8.6.1. Action
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc5545#section-3.8.6.1
|
||||
*/
|
||||
const ACTION_AUDIO = 'AUDIO';
|
||||
const ACTION_DISPLAY = 'DISPLAY';
|
||||
const ACTION_EMAIL = 'EMAIL';
|
||||
|
||||
protected $action;
|
||||
protected $repeat;
|
||||
protected $duration;
|
||||
protected $description;
|
||||
protected $attendee;
|
||||
protected $trigger;
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'VALARM';
|
||||
}
|
||||
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
public function getRepeat()
|
||||
{
|
||||
return $this->repeat;
|
||||
}
|
||||
|
||||
public function getDuration()
|
||||
{
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getAttendee()
|
||||
{
|
||||
return $this->attendee;
|
||||
}
|
||||
|
||||
public function getTrigger()
|
||||
{
|
||||
return $this->trigger;
|
||||
}
|
||||
|
||||
public function setAction($action)
|
||||
{
|
||||
$this->action = $action;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRepeat($repeat)
|
||||
{
|
||||
$this->repeat = $repeat;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDuration($duration)
|
||||
{
|
||||
$this->duration = $duration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAttendee($attendee)
|
||||
{
|
||||
$this->attendee = $attendee;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTrigger($trigger)
|
||||
{
|
||||
$this->trigger = $trigger;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildPropertyBag()
|
||||
{
|
||||
$propertyBag = new PropertyBag();
|
||||
|
||||
if (null != $this->trigger) {
|
||||
$propertyBag->set('TRIGGER', $this->trigger);
|
||||
}
|
||||
|
||||
if (null != $this->action) {
|
||||
$propertyBag->set('ACTION', $this->action);
|
||||
}
|
||||
|
||||
if (null != $this->repeat) {
|
||||
$propertyBag->set('REPEAT', $this->repeat);
|
||||
}
|
||||
|
||||
if (null != $this->duration) {
|
||||
$propertyBag->set('DURATION', $this->duration);
|
||||
}
|
||||
|
||||
if (null != $this->description) {
|
||||
$propertyBag->set('DESCRIPTION', $this->description);
|
||||
}
|
||||
|
||||
if (null != $this->attendee) {
|
||||
$propertyBag->set('ATTENDEE', $this->attendee);
|
||||
}
|
||||
|
||||
return $propertyBag;
|
||||
}
|
||||
}
|
||||
324
vendor/eluceo/ical/src/Component/Calendar.php
vendored
324
vendor/eluceo/ical/src/Component/Calendar.php
vendored
@@ -1,324 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
|
||||
class Calendar extends Component
|
||||
{
|
||||
/**
|
||||
* Methods for calendar components.
|
||||
*
|
||||
* According to RFC 5545: 3.7.2. Method
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc5545#section-3.7.2
|
||||
*
|
||||
* And then according to RFC 2446: 3 APPLICATION PROTOCOL ELEMENTS
|
||||
* @see https://tools.ietf.org/html/rfc2446#section-3.2
|
||||
*/
|
||||
const METHOD_PUBLISH = 'PUBLISH';
|
||||
const METHOD_REQUEST = 'REQUEST';
|
||||
const METHOD_REPLY = 'REPLY';
|
||||
const METHOD_ADD = 'ADD';
|
||||
const METHOD_CANCEL = 'CANCEL';
|
||||
const METHOD_REFRESH = 'REFRESH';
|
||||
const METHOD_COUNTER = 'COUNTER';
|
||||
const METHOD_DECLINECOUNTER = 'DECLINECOUNTER';
|
||||
|
||||
/**
|
||||
* This property defines the calendar scale used for the calendar information specified in the iCalendar object.
|
||||
*
|
||||
* According to RFC 5545: 3.7.1. Calendar Scale
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc5545#section-3.7
|
||||
*/
|
||||
const CALSCALE_GREGORIAN = 'GREGORIAN';
|
||||
|
||||
/**
|
||||
* The Product Identifier.
|
||||
*
|
||||
* According to RFC 5545: 3.7.3 Product Identifier
|
||||
*
|
||||
* This property specifies the identifier for the product that created the Calendar object.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.7.3
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prodId = null;
|
||||
protected $method = null;
|
||||
protected $name = null;
|
||||
protected $description = null;
|
||||
protected $timezone = null;
|
||||
|
||||
/**
|
||||
* This property defines the calendar scale used for the
|
||||
* calendar information specified in the iCalendar object.
|
||||
*
|
||||
* Also identifies the calendar type of a non-Gregorian recurring appointment.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc5545#section-3.7
|
||||
* @see http://msdn.microsoft.com/en-us/library/ee237520(v=exchg.80).aspx
|
||||
*/
|
||||
protected $calendarScale = null;
|
||||
|
||||
/**
|
||||
* Specifies whether or not the iCalendar file only contains one appointment.
|
||||
*
|
||||
* @var bool
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/ee203486(v=exchg.80).aspx
|
||||
*/
|
||||
protected $forceInspectOrOpen = false;
|
||||
|
||||
/**
|
||||
* Specifies a globally unique identifier for the calendar.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/ee179588(v=exchg.80).aspx
|
||||
*/
|
||||
protected $calId = null;
|
||||
|
||||
/**
|
||||
* Specifies a suggested iCalendar file download frequency for clients and
|
||||
* servers with sync capabilities.
|
||||
*
|
||||
* For example you can set the value to 'P1W' if the calendar should be
|
||||
* synced once a week. Use 'P3H' to sync the file every 3 hours.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/ee178699(v=exchg.80).aspx
|
||||
*/
|
||||
protected $publishedTTL = null;
|
||||
|
||||
/**
|
||||
* Specifies a color for the calendar in calendar for Apple/Outlook.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @see http://msdn.microsoft.com/en-us/library/ee179588(v=exchg.80).aspx
|
||||
*/
|
||||
protected $calendarColor = null;
|
||||
|
||||
public function __construct($prodId)
|
||||
{
|
||||
if (empty($prodId)) {
|
||||
throw new \UnexpectedValueException('PRODID cannot be empty');
|
||||
}
|
||||
|
||||
$this->prodId = $prodId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return 'VCALENDAR';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMethod($method)
|
||||
{
|
||||
$this->method = $method;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $description
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $timezone
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimezone($timezone)
|
||||
{
|
||||
$this->timezone = $timezone;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $calendarColor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCalendarColor($calendarColor)
|
||||
{
|
||||
$this->calendarColor = $calendarColor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $calendarScale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCalendarScale($calendarScale)
|
||||
{
|
||||
$this->calendarScale = $calendarScale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $forceInspectOrOpen
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setForceInspectOrOpen($forceInspectOrOpen)
|
||||
{
|
||||
$this->forceInspectOrOpen = $forceInspectOrOpen;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $calId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCalId($calId)
|
||||
{
|
||||
$this->calId = $calId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ttl
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPublishedTTL($ttl)
|
||||
{
|
||||
$this->publishedTTL = $ttl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildPropertyBag()
|
||||
{
|
||||
$propertyBag = new PropertyBag();
|
||||
$propertyBag->set('VERSION', '2.0');
|
||||
$propertyBag->set('PRODID', $this->prodId);
|
||||
|
||||
if ($this->method) {
|
||||
$propertyBag->set('METHOD', $this->method);
|
||||
}
|
||||
|
||||
if ($this->calendarColor) {
|
||||
$propertyBag->set('X-APPLE-CALENDAR-COLOR', $this->calendarColor);
|
||||
$propertyBag->set('X-OUTLOOK-COLOR', $this->calendarColor);
|
||||
$propertyBag->set('X-FUNAMBOL-COLOR', $this->calendarColor);
|
||||
}
|
||||
|
||||
if ($this->calendarScale) {
|
||||
$propertyBag->set('CALSCALE', $this->calendarScale);
|
||||
$propertyBag->set('X-MICROSOFT-CALSCALE', $this->calendarScale);
|
||||
}
|
||||
|
||||
if ($this->name) {
|
||||
$propertyBag->set('X-WR-CALNAME', $this->name);
|
||||
}
|
||||
|
||||
if ($this->description) {
|
||||
$propertyBag->set('X-WR-CALDESC', $this->description);
|
||||
}
|
||||
|
||||
if ($this->timezone) {
|
||||
if ($this->timezone instanceof Timezone) {
|
||||
$propertyBag->set('X-WR-TIMEZONE', $this->timezone->getZoneIdentifier());
|
||||
$this->addComponent($this->timezone);
|
||||
} else {
|
||||
$propertyBag->set('X-WR-TIMEZONE', $this->timezone);
|
||||
$this->addComponent(new Timezone($this->timezone));
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->forceInspectOrOpen) {
|
||||
$propertyBag->set('X-MS-OLK-FORCEINSPECTOROPEN', $this->forceInspectOrOpen);
|
||||
}
|
||||
|
||||
if ($this->calId) {
|
||||
$propertyBag->set('X-WR-RELCALID', $this->calId);
|
||||
}
|
||||
|
||||
if ($this->publishedTTL) {
|
||||
$propertyBag->set('X-PUBLISHED-TTL', $this->publishedTTL);
|
||||
}
|
||||
|
||||
return $propertyBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an Event to the Calendar.
|
||||
*
|
||||
* Wrapper for addComponent()
|
||||
*
|
||||
* @see Eluceo\iCal::addComponent
|
||||
* @deprecated Please, use public method addComponent() from abstract Component class
|
||||
*/
|
||||
public function addEvent(Event $event)
|
||||
{
|
||||
$this->addComponent($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProdId()
|
||||
{
|
||||
return $this->prodId;
|
||||
}
|
||||
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
}
|
||||
941
vendor/eluceo/ical/src/Component/Event.php
vendored
941
vendor/eluceo/ical/src/Component/Event.php
vendored
@@ -1,941 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\Property;
|
||||
use Eluceo\iCal\Property\DateTimeProperty;
|
||||
use Eluceo\iCal\Property\DateTimesProperty;
|
||||
use Eluceo\iCal\Property\Event\Attachment;
|
||||
use Eluceo\iCal\Property\Event\Attendees;
|
||||
use Eluceo\iCal\Property\Event\Geo;
|
||||
use Eluceo\iCal\Property\Event\Organizer;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceId;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceRule;
|
||||
use Eluceo\iCal\Property\RawStringValue;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
|
||||
/**
|
||||
* Implementation of the EVENT component.
|
||||
*/
|
||||
class Event extends Component
|
||||
{
|
||||
const TIME_TRANSPARENCY_OPAQUE = 'OPAQUE';
|
||||
const TIME_TRANSPARENCY_TRANSPARENT = 'TRANSPARENT';
|
||||
|
||||
const STATUS_TENTATIVE = 'TENTATIVE';
|
||||
const STATUS_CONFIRMED = 'CONFIRMED';
|
||||
const STATUS_CANCELLED = 'CANCELLED';
|
||||
|
||||
const MS_BUSYSTATUS_FREE = 'FREE';
|
||||
const MS_BUSYSTATUS_TENTATIVE = 'TENTATIVE';
|
||||
const MS_BUSYSTATUS_BUSY = 'BUSY';
|
||||
const MS_BUSYSTATUS_OOF = 'OOF';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $uniqueId;
|
||||
|
||||
/**
|
||||
* The property indicates the date/time that the instance of
|
||||
* the iCalendar object was created.
|
||||
*
|
||||
* The value MUST be specified in the UTC time format.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $dtStamp;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $dtStart;
|
||||
|
||||
/**
|
||||
* Preferentially chosen over the duration if both are set.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $dtEnd;
|
||||
|
||||
/**
|
||||
* @var \DateInterval
|
||||
*/
|
||||
protected $duration;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $noTime = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $msBusyStatus = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $location;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $locationTitle;
|
||||
|
||||
/**
|
||||
* @var Geo
|
||||
*/
|
||||
protected $locationGeo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $summary;
|
||||
|
||||
/**
|
||||
* @var Organizer
|
||||
*/
|
||||
protected $organizer;
|
||||
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.2.7
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $transparency = self::TIME_TRANSPARENCY_OPAQUE;
|
||||
|
||||
/**
|
||||
* If set to true the timezone will be added to the event.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useTimezone = false;
|
||||
|
||||
/**
|
||||
* If set will be used as the timezone identifier.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $timezoneString = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $sequence = 0;
|
||||
|
||||
/**
|
||||
* @var Attendees
|
||||
*/
|
||||
protected $attendees;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $descriptionHTML;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* @var RecurrenceRule
|
||||
*/
|
||||
protected $recurrenceRule;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $recurrenceRules = [];
|
||||
|
||||
/**
|
||||
* This property specifies the date and time that the calendar
|
||||
* information was created.
|
||||
*
|
||||
* The value MUST be specified in the UTC time format.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $created;
|
||||
|
||||
/**
|
||||
* The property specifies the date and time that the information
|
||||
* associated with the calendar component was last revised.
|
||||
*
|
||||
* The value MUST be specified in the UTC time format.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $modified;
|
||||
|
||||
/**
|
||||
* Indicates if the UTC time should be used or not.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useUtc = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $cancelled;
|
||||
|
||||
/**
|
||||
* This property is used to specify categories or subtypes
|
||||
* of the calendar component. The categories are useful in searching
|
||||
* for a calendar component of a particular type and category.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.1.2
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $categories;
|
||||
|
||||
/**
|
||||
* https://tools.ietf.org/html/rfc5545#section-3.8.1.3.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isPrivate = false;
|
||||
|
||||
/**
|
||||
* Dates to be excluded from a series of events.
|
||||
*
|
||||
* @var \DateTimeInterface[]
|
||||
*/
|
||||
protected $exDates = [];
|
||||
|
||||
/**
|
||||
* @var RecurrenceId
|
||||
*/
|
||||
protected $recurrenceId;
|
||||
|
||||
/**
|
||||
* @var Attachment[]
|
||||
*/
|
||||
protected $attachments = [];
|
||||
|
||||
public function __construct(string $uniqueId = null)
|
||||
{
|
||||
if (null == $uniqueId) {
|
||||
$uniqueId = uniqid();
|
||||
}
|
||||
|
||||
$this->uniqueId = $uniqueId;
|
||||
$this->attendees = new Attendees();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return 'VEVENT';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildPropertyBag()
|
||||
{
|
||||
$propertyBag = new PropertyBag();
|
||||
|
||||
// mandatory information
|
||||
$propertyBag->set('UID', $this->uniqueId);
|
||||
|
||||
$propertyBag->add(new DateTimeProperty('DTSTART', $this->dtStart, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
|
||||
$propertyBag->set('SEQUENCE', $this->sequence);
|
||||
$propertyBag->set('TRANSP', $this->transparency);
|
||||
|
||||
if ($this->status) {
|
||||
$propertyBag->set('STATUS', $this->status);
|
||||
}
|
||||
|
||||
// An event can have a 'dtend' or 'duration', but not both.
|
||||
if ($this->dtEnd !== null) {
|
||||
$dtEnd = clone $this->dtEnd;
|
||||
if ($this->noTime === true) {
|
||||
$dtEnd = $dtEnd->add(new \DateInterval('P1D'));
|
||||
}
|
||||
$propertyBag->add(new DateTimeProperty('DTEND', $dtEnd, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
|
||||
} elseif ($this->duration !== null) {
|
||||
$propertyBag->set('DURATION', $this->duration->format('P%dDT%hH%iM%sS'));
|
||||
}
|
||||
|
||||
// optional information
|
||||
if (null != $this->url) {
|
||||
$propertyBag->set('URL', $this->url);
|
||||
}
|
||||
|
||||
if (null != $this->location) {
|
||||
$propertyBag->set('LOCATION', $this->location);
|
||||
|
||||
if (null != $this->locationGeo) {
|
||||
$propertyBag->add(
|
||||
new Property(
|
||||
'X-APPLE-STRUCTURED-LOCATION',
|
||||
new RawStringValue('geo:' . $this->locationGeo->getGeoLocationAsString(',')),
|
||||
[
|
||||
'VALUE' => 'URI',
|
||||
'X-ADDRESS' => $this->location,
|
||||
'X-APPLE-RADIUS' => 49,
|
||||
'X-TITLE' => $this->locationTitle,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (null != $this->locationGeo) {
|
||||
$propertyBag->add($this->locationGeo);
|
||||
}
|
||||
|
||||
if (null != $this->summary) {
|
||||
$propertyBag->set('SUMMARY', $this->summary);
|
||||
}
|
||||
|
||||
if (null != $this->attendees) {
|
||||
$propertyBag->add($this->attendees);
|
||||
}
|
||||
|
||||
$propertyBag->set('CLASS', $this->isPrivate ? 'PRIVATE' : 'PUBLIC');
|
||||
|
||||
if (null != $this->description) {
|
||||
$propertyBag->set('DESCRIPTION', $this->description);
|
||||
}
|
||||
|
||||
if (null != $this->descriptionHTML) {
|
||||
$propertyBag->add(
|
||||
new Property(
|
||||
'X-ALT-DESC',
|
||||
$this->descriptionHTML,
|
||||
[
|
||||
'FMTTYPE' => 'text/html',
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (null != $this->recurrenceRule) {
|
||||
$propertyBag->set('RRULE', $this->recurrenceRule);
|
||||
}
|
||||
|
||||
foreach ($this->recurrenceRules as $recurrenceRule) {
|
||||
$propertyBag->set('RRULE', $recurrenceRule);
|
||||
}
|
||||
|
||||
if (null != $this->recurrenceId) {
|
||||
$this->recurrenceId->applyTimeSettings($this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString);
|
||||
$propertyBag->add($this->recurrenceId);
|
||||
}
|
||||
|
||||
if (!empty($this->exDates)) {
|
||||
$propertyBag->add(new DateTimesProperty('EXDATE', $this->exDates, $this->noTime, $this->useTimezone, $this->useUtc, $this->timezoneString));
|
||||
}
|
||||
|
||||
if ($this->cancelled) {
|
||||
$propertyBag->set('STATUS', 'CANCELLED');
|
||||
}
|
||||
|
||||
if (null != $this->organizer) {
|
||||
$propertyBag->add($this->organizer);
|
||||
}
|
||||
|
||||
if ($this->noTime) {
|
||||
$propertyBag->set('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
|
||||
}
|
||||
|
||||
if (null != $this->msBusyStatus) {
|
||||
$propertyBag->set('X-MICROSOFT-CDO-BUSYSTATUS', $this->msBusyStatus);
|
||||
$propertyBag->set('X-MICROSOFT-CDO-INTENDEDSTATUS', $this->msBusyStatus);
|
||||
}
|
||||
|
||||
if (null != $this->categories) {
|
||||
$propertyBag->set('CATEGORIES', $this->categories);
|
||||
}
|
||||
|
||||
$propertyBag->add(
|
||||
new DateTimeProperty('DTSTAMP', $this->dtStamp ?: new \DateTimeImmutable(), false, false, true)
|
||||
);
|
||||
|
||||
if ($this->created) {
|
||||
$propertyBag->add(new DateTimeProperty('CREATED', $this->created, false, false, true));
|
||||
}
|
||||
|
||||
if ($this->modified) {
|
||||
$propertyBag->add(new DateTimeProperty('LAST-MODIFIED', $this->modified, false, false, true));
|
||||
}
|
||||
|
||||
foreach ($this->attachments as $attachment) {
|
||||
$propertyBag->add($attachment);
|
||||
}
|
||||
|
||||
return $propertyBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dtEnd
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDtEnd($dtEnd)
|
||||
{
|
||||
$this->dtEnd = $dtEnd;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDtEnd()
|
||||
{
|
||||
return $this->dtEnd;
|
||||
}
|
||||
|
||||
public function setDtStart($dtStart)
|
||||
{
|
||||
$this->dtStart = $dtStart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDtStart()
|
||||
{
|
||||
return $this->dtStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dtStamp
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDtStamp($dtStamp)
|
||||
{
|
||||
$this->dtStamp = $dtStamp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $duration
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDuration($duration)
|
||||
{
|
||||
$this->duration = $duration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $location
|
||||
* @param string $title
|
||||
* @param Geo|string $geo
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocation($location, $title = '', $geo = null)
|
||||
{
|
||||
if (is_scalar($geo)) {
|
||||
$geo = Geo::fromString($geo);
|
||||
} elseif (!is_null($geo) && !$geo instanceof Geo) {
|
||||
$className = get_class($geo);
|
||||
throw new \InvalidArgumentException("The parameter 'geo' must be a string or an instance of " . Geo::class . " but an instance of {$className} was given.");
|
||||
}
|
||||
|
||||
$this->location = $location;
|
||||
$this->locationTitle = $title;
|
||||
$this->locationGeo = $geo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setGeoLocation(Geo $geoProperty)
|
||||
{
|
||||
$this->locationGeo = $geoProperty;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $noTime
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNoTime($noTime)
|
||||
{
|
||||
$this->noTime = $noTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $msBusyStatus
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setMsBusyStatus($msBusyStatus)
|
||||
{
|
||||
$msBusyStatus = strtoupper($msBusyStatus);
|
||||
if ($msBusyStatus == self::MS_BUSYSTATUS_FREE
|
||||
|| $msBusyStatus == self::MS_BUSYSTATUS_TENTATIVE
|
||||
|| $msBusyStatus == self::MS_BUSYSTATUS_BUSY
|
||||
|| $msBusyStatus == self::MS_BUSYSTATUS_OOF
|
||||
) {
|
||||
$this->msBusyStatus = $msBusyStatus;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid value for status');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMsBusyStatus()
|
||||
{
|
||||
return $this->msBusyStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sequence
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSequence($sequence)
|
||||
{
|
||||
$this->sequence = $sequence;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSequence()
|
||||
{
|
||||
return $this->sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setOrganizer(Organizer $organizer)
|
||||
{
|
||||
$this->organizer = $organizer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summary
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSummary($summary)
|
||||
{
|
||||
$this->summary = $summary;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $uniqueId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUniqueId($uniqueId)
|
||||
{
|
||||
$this->uniqueId = $uniqueId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUniqueId()
|
||||
{
|
||||
return $this->uniqueId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $useTimezone
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUseTimezone($useTimezone)
|
||||
{
|
||||
$this->useTimezone = $useTimezone;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseTimezone()
|
||||
{
|
||||
return $this->useTimezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $timezoneString
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimezoneString($timezoneString)
|
||||
{
|
||||
$this->timezoneString = $timezoneString;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getTimezoneString()
|
||||
{
|
||||
return $this->timezoneString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setAttendees(Attendees $attendees)
|
||||
{
|
||||
$this->attendees = $attendees;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $attendee
|
||||
* @param array $params
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttendee($attendee, $params = [])
|
||||
{
|
||||
$this->attendees->add($attendee, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAttendees(): Attendees
|
||||
{
|
||||
return $this->attendees;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $description
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $descriptionHTML
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescriptionHTML($descriptionHTML)
|
||||
{
|
||||
$this->descriptionHTML = $descriptionHTML;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $useUtc
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUseUtc($useUtc = true)
|
||||
{
|
||||
$this->useUtc = $useUtc;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescriptionHTML()
|
||||
{
|
||||
return $this->descriptionHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $status
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCancelled($status)
|
||||
{
|
||||
$this->cancelled = (bool) $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $transparency
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setTimeTransparency($transparency)
|
||||
{
|
||||
$transparency = strtoupper($transparency);
|
||||
if ($transparency === self::TIME_TRANSPARENCY_OPAQUE
|
||||
|| $transparency === self::TIME_TRANSPARENCY_TRANSPARENT
|
||||
) {
|
||||
$this->transparency = $transparency;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid value for transparancy');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $status
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$status = strtoupper($status);
|
||||
if ($status == self::STATUS_CANCELLED
|
||||
|| $status == self::STATUS_CONFIRMED
|
||||
|| $status == self::STATUS_TENTATIVE
|
||||
) {
|
||||
$this->status = $status;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid value for status');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use addRecurrenceRule instead.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
|
||||
{
|
||||
@trigger_error('setRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use addRecurrenceRule instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->recurrenceRule = $recurrenceRule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated since version 0.11.0, to be removed in 1.0. Use getRecurrenceRules instead.
|
||||
*
|
||||
* @return RecurrenceRule
|
||||
*/
|
||||
public function getRecurrenceRule()
|
||||
{
|
||||
@trigger_error('getRecurrenceRule() is deprecated since version 0.11.0 and will be removed in 1.0. Use getRecurrenceRules instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->recurrenceRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function addRecurrenceRule(RecurrenceRule $recurrenceRule)
|
||||
{
|
||||
$this->recurrenceRules[] = $recurrenceRule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRecurrenceRules()
|
||||
{
|
||||
return $this->recurrenceRules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dtStamp
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreated($dtStamp)
|
||||
{
|
||||
$this->created = $dtStamp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dtStamp
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModified($dtStamp)
|
||||
{
|
||||
$this->modified = $dtStamp;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $categories
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCategories($categories)
|
||||
{
|
||||
$this->categories = $categories;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the event privacy.
|
||||
*
|
||||
* @param bool $flag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsPrivate($flag)
|
||||
{
|
||||
$this->isPrivate = (bool) $flag;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Eluceo\iCal\Component\Event
|
||||
*/
|
||||
public function addExDate(\DateTimeInterface $dateTime)
|
||||
{
|
||||
$this->exDates[] = $dateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeInterface[]
|
||||
*/
|
||||
public function getExDates()
|
||||
{
|
||||
return $this->exDates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTimeInterface[]
|
||||
*
|
||||
* @return \Eluceo\iCal\Component\Event
|
||||
*/
|
||||
public function setExDates(array $exDates)
|
||||
{
|
||||
$this->exDates = $exDates;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Eluceo\iCal\Property\Event\RecurrenceId
|
||||
*/
|
||||
public function getRecurrenceId()
|
||||
{
|
||||
return $this->recurrenceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Eluceo\iCal\Component\Event
|
||||
*/
|
||||
public function setRecurrenceId(RecurrenceId $recurrenceId)
|
||||
{
|
||||
$this->recurrenceId = $recurrenceId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $attachment
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addAttachment(Attachment $attachment)
|
||||
{
|
||||
$this->attachments[] = $attachment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAttachments()
|
||||
{
|
||||
return $this->attachments;
|
||||
}
|
||||
|
||||
public function addUrlAttachment(string $url)
|
||||
{
|
||||
$this->addAttachment(new Attachment($url));
|
||||
}
|
||||
}
|
||||
57
vendor/eluceo/ical/src/Component/Timezone.php
vendored
57
vendor/eluceo/ical/src/Component/Timezone.php
vendored
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
|
||||
/**
|
||||
* Implementation of the TIMEZONE component.
|
||||
*/
|
||||
class Timezone extends Component
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $timezone;
|
||||
|
||||
public function __construct($timezone)
|
||||
{
|
||||
$this->timezone = $timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return 'VTIMEZONE';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildPropertyBag()
|
||||
{
|
||||
$propertyBag = new PropertyBag();
|
||||
|
||||
$propertyBag->set('TZID', $this->timezone);
|
||||
$propertyBag->set('X-LIC-LOCATION', $this->timezone);
|
||||
|
||||
return $propertyBag;
|
||||
}
|
||||
|
||||
public function getZoneIdentifier()
|
||||
{
|
||||
return $this->timezone;
|
||||
}
|
||||
}
|
||||
211
vendor/eluceo/ical/src/Component/TimezoneRule.php
vendored
211
vendor/eluceo/ical/src/Component/TimezoneRule.php
vendored
@@ -1,211 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
use Eluceo\iCal\Component;
|
||||
use Eluceo\iCal\Property\Event\RecurrenceRule;
|
||||
use Eluceo\iCal\PropertyBag;
|
||||
|
||||
/**
|
||||
* Implementation of Standard Time and Daylight Saving Time observances (or rules)
|
||||
* which define the TIMEZONE component.
|
||||
*/
|
||||
class TimezoneRule extends Component
|
||||
{
|
||||
const TYPE_DAYLIGHT = 'DAYLIGHT';
|
||||
const TYPE_STANDARD = 'STANDARD';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tzOffsetFrom;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tzOffsetTo;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tzName;
|
||||
|
||||
/**
|
||||
* @var \DateTimeInterface
|
||||
*/
|
||||
protected $dtStart;
|
||||
|
||||
/**
|
||||
* @var RecurrenceRule
|
||||
*/
|
||||
protected $recurrenceRule;
|
||||
|
||||
/**
|
||||
* create new Timezone Rule object by giving a rule type identifier.
|
||||
*
|
||||
* @param string $ruleType one of DAYLIGHT or STANDARD
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($ruleType)
|
||||
{
|
||||
$ruleType = strtoupper($ruleType);
|
||||
if ($ruleType === self::TYPE_DAYLIGHT || $ruleType === self::TYPE_STANDARD) {
|
||||
$this->type = $ruleType;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid value for timezone rule type');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildPropertyBag()
|
||||
{
|
||||
$propertyBag = new PropertyBag();
|
||||
|
||||
if ($this->getTzName()) {
|
||||
$propertyBag->set('TZNAME', $this->getTzName());
|
||||
}
|
||||
|
||||
if ($this->getTzOffsetFrom()) {
|
||||
$propertyBag->set('TZOFFSETFROM', $this->getTzOffsetFrom());
|
||||
}
|
||||
|
||||
if ($this->getTzOffsetTo()) {
|
||||
$propertyBag->set('TZOFFSETTO', $this->getTzOffsetTo());
|
||||
}
|
||||
|
||||
if ($this->getDtStart()) {
|
||||
$propertyBag->set('DTSTART', $this->getDtStart());
|
||||
}
|
||||
|
||||
if ($this->recurrenceRule) {
|
||||
$propertyBag->set('RRULE', $this->recurrenceRule);
|
||||
}
|
||||
|
||||
return $propertyBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $offset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTzOffsetFrom($offset)
|
||||
{
|
||||
$this->tzOffsetFrom = $offset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $offset
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTzOffsetTo($offset)
|
||||
{
|
||||
$this->tzOffsetTo = $offset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTzName($name)
|
||||
{
|
||||
$this->tzName = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setDtStart(\DateTimeInterface $dtStart)
|
||||
{
|
||||
$this->dtStart = $dtStart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setRecurrenceRule(RecurrenceRule $recurrenceRule)
|
||||
{
|
||||
$this->recurrenceRule = $recurrenceRule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTzOffsetFrom()
|
||||
{
|
||||
return $this->tzOffsetFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTzOffsetTo()
|
||||
{
|
||||
return $this->tzOffsetTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTzName()
|
||||
{
|
||||
return $this->tzName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RecurrenceRule
|
||||
*/
|
||||
public function getRecurrenceRule()
|
||||
{
|
||||
return $this->recurrenceRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed return string representation of start date or NULL if no date was given
|
||||
*/
|
||||
public function getDtStart()
|
||||
{
|
||||
if ($this->dtStart) {
|
||||
return $this->dtStart->format('Ymd\THis');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
107
vendor/eluceo/ical/src/ParameterBag.php
vendored
107
vendor/eluceo/ical/src/ParameterBag.php
vendored
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class ParameterBag
|
||||
{
|
||||
/**
|
||||
* The params.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $params;
|
||||
|
||||
public function __construct($params = [])
|
||||
{
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setParam($name, $value)
|
||||
{
|
||||
$this->params[$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function getParam($name)
|
||||
{
|
||||
if (isset($this->params[$name])) {
|
||||
return $this->params[$name];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are any params.
|
||||
*/
|
||||
public function hasParams(): bool
|
||||
{
|
||||
return count($this->params) > 0;
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
$line = '';
|
||||
foreach ($this->params as $param => $paramValues) {
|
||||
if (!is_array($paramValues)) {
|
||||
$paramValues = [$paramValues];
|
||||
}
|
||||
foreach ($paramValues as $k => $v) {
|
||||
$paramValues[$k] = $this->escapeParamValue($v);
|
||||
}
|
||||
|
||||
if ('' != $line) {
|
||||
$line .= ';';
|
||||
}
|
||||
|
||||
$line .= $param . '=' . implode(',', $paramValues);
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an escaped string for a param value.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function escapeParamValue($value)
|
||||
{
|
||||
$count = 0;
|
||||
$value = str_replace('\\', '\\\\', $value);
|
||||
$value = str_replace('"', '\"', $value, $count);
|
||||
$value = str_replace("\n", '\\n', $value);
|
||||
if (false !== strpos($value, ';') || false !== strpos($value, ',') || false !== strpos($value, ':') || $count) {
|
||||
$value = '"' . $value . '"';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->toString();
|
||||
}
|
||||
}
|
||||
147
vendor/eluceo/ical/src/Property.php
vendored
147
vendor/eluceo/ical/src/Property.php
vendored
@@ -1,147 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
use Eluceo\iCal\Property\ArrayValue;
|
||||
use Eluceo\iCal\Property\StringValue;
|
||||
use Eluceo\iCal\Property\ValueInterface;
|
||||
|
||||
/**
|
||||
* The Property Class represents a property as defined in RFC 5545.
|
||||
*
|
||||
* The content of a line (unfolded) will be rendered in this class.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.5
|
||||
*/
|
||||
class Property
|
||||
{
|
||||
/**
|
||||
* The value of the Property.
|
||||
*
|
||||
* @var ValueInterface
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
/**
|
||||
* The params of the Property.
|
||||
*
|
||||
* @var ParameterBag
|
||||
*/
|
||||
protected $parameterBag;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct($name, $value, $params = [])
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->setValue($value);
|
||||
$this->parameterBag = new ParameterBag($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an unfolded line.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toLine()
|
||||
{
|
||||
// Property-name
|
||||
$line = $this->getName();
|
||||
|
||||
// Adding params
|
||||
//@todo added check for $this->parameterBag because doctrine/orm proxies won't execute constructor - ok?
|
||||
if ($this->parameterBag && $this->parameterBag->hasParams()) {
|
||||
$line .= ';' . $this->parameterBag->toString();
|
||||
}
|
||||
|
||||
// Property value
|
||||
$line .= ':' . $this->value->getEscapedValue();
|
||||
|
||||
return $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all unfolded lines.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toLines()
|
||||
{
|
||||
return [$this->toLine()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParam($name, $value)
|
||||
{
|
||||
$this->parameterBag->setParam($name, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*/
|
||||
public function getParam($name)
|
||||
{
|
||||
return $this->parameterBag->getParam($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
if (is_scalar($value)) {
|
||||
$this->value = new StringValue($value);
|
||||
} elseif (is_array($value)) {
|
||||
$this->value = new ArrayValue($value);
|
||||
} else {
|
||||
if (!$value instanceof ValueInterface) {
|
||||
throw new \Exception('The value must implement the ValueInterface.');
|
||||
} else {
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
41
vendor/eluceo/ical/src/Property/ArrayValue.php
vendored
41
vendor/eluceo/ical/src/Property/ArrayValue.php
vendored
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
class ArrayValue implements ValueInterface
|
||||
{
|
||||
/**
|
||||
* The value.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $values;
|
||||
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->values = $values;
|
||||
}
|
||||
|
||||
public function setValues(array $values)
|
||||
{
|
||||
$this->values = $values;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
return implode(',', array_map(function (string $value): string {
|
||||
return (new StringValue($value))->getEscapedValue();
|
||||
}, $this->values));
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
use Eluceo\iCal\Property;
|
||||
use Eluceo\iCal\Util\DateUtil;
|
||||
|
||||
class DateTimeProperty extends Property
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \DateTimeInterface $dateTime
|
||||
* @param bool $noTime
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
* @param string $timezoneString
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
\DateTimeInterface $dateTime = null,
|
||||
$noTime = false,
|
||||
$useTimezone = false,
|
||||
$useUtc = false,
|
||||
$timezoneString = ''
|
||||
) {
|
||||
$dateString = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc);
|
||||
$params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone, $timezoneString);
|
||||
|
||||
parent::__construct($name, $dateString, $params);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
use Eluceo\iCal\Property;
|
||||
use Eluceo\iCal\Util\DateUtil;
|
||||
|
||||
class DateTimesProperty extends Property
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \DateTimeInterface[] $dateTimes
|
||||
* @param bool $noTime
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
* @param string $timezoneString
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
$dateTimes = [],
|
||||
$noTime = false,
|
||||
$useTimezone = false,
|
||||
$useUtc = false,
|
||||
$timezoneString = ''
|
||||
) {
|
||||
$dates = [];
|
||||
$dateTime = new \DateTimeImmutable();
|
||||
foreach ($dateTimes as $dateTime) {
|
||||
$dates[] = DateUtil::getDateString($dateTime, $noTime, $useTimezone, $useUtc);
|
||||
}
|
||||
|
||||
//@todo stop this triggering an E_NOTICE when $dateTimes is empty
|
||||
$params = DateUtil::getDefaultParams($dateTime, $noTime, $useTimezone, $timezoneString);
|
||||
|
||||
parent::__construct($name, $dates, $params);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\Property;
|
||||
|
||||
/**
|
||||
* Class Attachment.
|
||||
*/
|
||||
class Attachment extends Property
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct($value, $params = [])
|
||||
{
|
||||
parent::__construct('ATTACH', $value, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $url
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->setValue($url);
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\Property;
|
||||
|
||||
class Attendees extends Property
|
||||
{
|
||||
/**
|
||||
* @var Property[]
|
||||
*/
|
||||
protected $attendees = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'ATTENDEES';
|
||||
// prevent super constructor to be called
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param array $params
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add($value, $params = [])
|
||||
{
|
||||
$this->attendees[] = new Property('ATTENDEE', $value, $params);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Property[] $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->attendees = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Property[]
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->attendees;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toLines()
|
||||
{
|
||||
$lines = [];
|
||||
foreach ($this->attendees as $attendee) {
|
||||
$lines[] = $attendee->toLine();
|
||||
}
|
||||
|
||||
return $lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function setParam($name, $value)
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot call setParam on Attendees Property');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function getParam($name)
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot call getParam on Attendees Property');
|
||||
}
|
||||
}
|
||||
82
vendor/eluceo/ical/src/Property/Event/Geo.php
vendored
82
vendor/eluceo/ical/src/Property/Event/Geo.php
vendored
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\Property;
|
||||
|
||||
/**
|
||||
* GEO property.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.1.6
|
||||
*/
|
||||
class Geo extends Property
|
||||
{
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $latitude;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
private $longitude;
|
||||
|
||||
public function __construct(float $latitude, float $longitude)
|
||||
{
|
||||
$this->latitude = $latitude;
|
||||
$this->longitude = $longitude;
|
||||
|
||||
if ($this->latitude < -90 || $this->latitude > 90) {
|
||||
throw new \InvalidArgumentException("The geographical latitude must be a value between -90 and 90 degrees. '{$this->latitude}' was given.");
|
||||
}
|
||||
|
||||
if ($this->longitude < -180 || $this->longitude > 180) {
|
||||
throw new \InvalidArgumentException("The geographical longitude must be a value between -180 and 180 degrees. '{$this->longitude}' was given.");
|
||||
}
|
||||
|
||||
parent::__construct('GEO', new Property\RawStringValue($this->getGeoLocationAsString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is used to allow backwards compatibility for Event::setLocation
|
||||
*
|
||||
* @return Geo
|
||||
*/
|
||||
public static function fromString(string $geoLocationString): self
|
||||
{
|
||||
$geoLocationString = str_replace(',', ';', $geoLocationString);
|
||||
$geoLocationString = str_replace('GEO:', '', $geoLocationString);
|
||||
$parts = explode(';', $geoLocationString);
|
||||
|
||||
return new static((float) $parts[0], (float) $parts[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the coordinates as a string.
|
||||
*
|
||||
* @example 37.386013;-122.082932
|
||||
*/
|
||||
public function getGeoLocationAsString(string $separator = ';'): string
|
||||
{
|
||||
return number_format($this->latitude, 6) . $separator . number_format($this->longitude, 6);
|
||||
}
|
||||
|
||||
public function getLatitude(): float
|
||||
{
|
||||
return $this->latitude;
|
||||
}
|
||||
|
||||
public function getLongitude(): float
|
||||
{
|
||||
return $this->longitude;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\Property;
|
||||
|
||||
/**
|
||||
* Class Organizer.
|
||||
*/
|
||||
class Organizer extends Property
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct($value, $params = [])
|
||||
{
|
||||
parent::__construct('ORGANIZER', $value, $params);
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\ParameterBag;
|
||||
use Eluceo\iCal\Property;
|
||||
use Eluceo\iCal\Property\ValueInterface;
|
||||
use Eluceo\iCal\Util\DateUtil;
|
||||
|
||||
/**
|
||||
* Implementation of Recurrence Id.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.4.4
|
||||
*/
|
||||
class RecurrenceId extends Property
|
||||
{
|
||||
/**
|
||||
* The effective range of recurrence instances from the instance
|
||||
* specified by the recurrence identifier specified by the property.
|
||||
*/
|
||||
const RANGE_THISANDPRIOR = 'THISANDPRIOR';
|
||||
const RANGE_THISANDFUTURE = 'THISANDFUTURE';
|
||||
|
||||
/**
|
||||
* The dateTime to identify a particular instance of a recurring event which is getting modified.
|
||||
*
|
||||
* @var \DateTimeInterface
|
||||
*/
|
||||
protected $dateTime;
|
||||
|
||||
/**
|
||||
* Specify the effective range of recurrence instances from the instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $range;
|
||||
|
||||
public function __construct(\DateTimeInterface $dateTime = null)
|
||||
{
|
||||
$this->name = 'RECURRENCE-ID';
|
||||
$this->parameterBag = new ParameterBag();
|
||||
if (isset($dateTime)) {
|
||||
$this->dateTime = $dateTime;
|
||||
}
|
||||
}
|
||||
|
||||
public function applyTimeSettings($noTime = false, $useTimezone = false, $useUtc = false, $timezoneString = '')
|
||||
{
|
||||
$params = DateUtil::getDefaultParams($this->dateTime, $noTime, $useTimezone, $timezoneString);
|
||||
foreach ($params as $name => $value) {
|
||||
$this->parameterBag->setParam($name, $value);
|
||||
}
|
||||
|
||||
if ($this->range) {
|
||||
$this->parameterBag->setParam('RANGE', $this->range);
|
||||
}
|
||||
|
||||
$this->setValue(DateUtil::getDateString($this->dateTime, $noTime, $useTimezone, $useUtc));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeInterface
|
||||
*/
|
||||
public function getDatetime()
|
||||
{
|
||||
return $this->dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Eluceo\iCal\Property\Event\RecurrenceId
|
||||
*/
|
||||
public function setDatetime(\DateTimeInterface $dateTime)
|
||||
{
|
||||
$this->dateTime = $dateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRange()
|
||||
{
|
||||
return $this->range;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $range
|
||||
*
|
||||
* @return \Eluceo\iCal\Property\Event\RecurrenceId
|
||||
*/
|
||||
public function setRange($range)
|
||||
{
|
||||
$this->range = $range;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all unfolded lines.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toLines()
|
||||
{
|
||||
if (!$this->value instanceof ValueInterface) {
|
||||
throw new \Exception('The value must implement the ValueInterface. Call RecurrenceId::applyTimeSettings() before adding RecurrenceId.');
|
||||
} else {
|
||||
return parent::toLines();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,546 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property\Event;
|
||||
|
||||
use Eluceo\iCal\ParameterBag;
|
||||
use Eluceo\iCal\Property\ValueInterface;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Implementation of Recurrence Rule.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.8.5.3
|
||||
*/
|
||||
class RecurrenceRule implements ValueInterface
|
||||
{
|
||||
const FREQ_YEARLY = 'YEARLY';
|
||||
const FREQ_MONTHLY = 'MONTHLY';
|
||||
const FREQ_WEEKLY = 'WEEKLY';
|
||||
const FREQ_DAILY = 'DAILY';
|
||||
const FREQ_HOURLY = 'HOURLY';
|
||||
const FREQ_MINUTELY = 'MINUTELY';
|
||||
const FREQ_SECONDLY = 'SECONDLY';
|
||||
|
||||
const WEEKDAY_SUNDAY = 'SU';
|
||||
const WEEKDAY_MONDAY = 'MO';
|
||||
const WEEKDAY_TUESDAY = 'TU';
|
||||
const WEEKDAY_WEDNESDAY = 'WE';
|
||||
const WEEKDAY_THURSDAY = 'TH';
|
||||
const WEEKDAY_FRIDAY = 'FR';
|
||||
const WEEKDAY_SATURDAY = 'SA';
|
||||
|
||||
/**
|
||||
* The frequency of an Event.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $freq = self::FREQ_YEARLY;
|
||||
|
||||
/**
|
||||
* BYSETPOS must require use of other BY*.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $canUseBySetPos = false;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
protected $interval = 1;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
protected $count = null;
|
||||
|
||||
/**
|
||||
* @var \DateTimeInterface|null
|
||||
*/
|
||||
protected $until = null;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $wkst;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
protected $bySetPos = null;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMonth;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byWeekNo;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byYearDay;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMonthDay;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byDay;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byHour;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $byMinute;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $bySecond;
|
||||
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
return $this->buildParameterBag()->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
protected function buildParameterBag()
|
||||
{
|
||||
$parameterBag = new ParameterBag();
|
||||
|
||||
$parameterBag->setParam('FREQ', $this->freq);
|
||||
|
||||
if (null !== $this->interval) {
|
||||
$parameterBag->setParam('INTERVAL', $this->interval);
|
||||
}
|
||||
|
||||
if (null !== $this->count) {
|
||||
$parameterBag->setParam('COUNT', $this->count);
|
||||
}
|
||||
|
||||
if (null != $this->until) {
|
||||
$parameterBag->setParam('UNTIL', $this->until->format('Ymd\THis\Z'));
|
||||
}
|
||||
|
||||
if (null !== $this->wkst) {
|
||||
$parameterBag->setParam('WKST', $this->wkst);
|
||||
}
|
||||
|
||||
if (null !== $this->bySetPos && $this->canUseBySetPos) {
|
||||
$parameterBag->setParam('BYSETPOS', $this->bySetPos);
|
||||
}
|
||||
|
||||
if (null !== $this->byMonth) {
|
||||
$parameterBag->setParam('BYMONTH', explode(',', $this->byMonth));
|
||||
}
|
||||
|
||||
if (null !== $this->byWeekNo) {
|
||||
$parameterBag->setParam('BYWEEKNO', explode(',', $this->byWeekNo));
|
||||
}
|
||||
|
||||
if (null !== $this->byYearDay) {
|
||||
$parameterBag->setParam('BYYEARDAY', explode(',', $this->byYearDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byMonthDay) {
|
||||
$parameterBag->setParam('BYMONTHDAY', explode(',', $this->byMonthDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byDay) {
|
||||
$parameterBag->setParam('BYDAY', explode(',', $this->byDay));
|
||||
}
|
||||
|
||||
if (null !== $this->byHour) {
|
||||
$parameterBag->setParam('BYHOUR', explode(',', $this->byHour));
|
||||
}
|
||||
|
||||
if (null !== $this->byMinute) {
|
||||
$parameterBag->setParam('BYMINUTE', explode(',', $this->byMinute));
|
||||
}
|
||||
|
||||
if (null !== $this->bySecond) {
|
||||
$parameterBag->setParam('BYSECOND', explode(',', $this->bySecond));
|
||||
}
|
||||
|
||||
return $parameterBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $count
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCount($count)
|
||||
{
|
||||
$this->count = $count;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCount()
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setUntil(\DateTimeInterface $until = null)
|
||||
{
|
||||
$this->until = $until;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeInterface|null
|
||||
*/
|
||||
public function getUntil()
|
||||
{
|
||||
return $this->until;
|
||||
}
|
||||
|
||||
/**
|
||||
* The FREQ rule part identifies the type of recurrence rule. This
|
||||
* rule part MUST be specified in the recurrence rule. Valid values
|
||||
* include.
|
||||
*
|
||||
* SECONDLY, to specify repeating events based on an interval of a second or more;
|
||||
* MINUTELY, to specify repeating events based on an interval of a minute or more;
|
||||
* HOURLY, to specify repeating events based on an interval of an hour or more;
|
||||
* DAILY, to specify repeating events based on an interval of a day or more;
|
||||
* WEEKLY, to specify repeating events based on an interval of a week or more;
|
||||
* MONTHLY, to specify repeating events based on an interval of a month or more;
|
||||
* YEARLY, to specify repeating events based on an interval of a year or more.
|
||||
*
|
||||
* @param string $freq
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setFreq($freq)
|
||||
{
|
||||
if (@constant('static::FREQ_' . $freq) !== null) {
|
||||
$this->freq = $freq;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("The Frequency {$freq} is not supported.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFreq()
|
||||
{
|
||||
return $this->freq;
|
||||
}
|
||||
|
||||
/**
|
||||
* The INTERVAL rule part contains a positive integer representing at
|
||||
* which intervals the recurrence rule repeats.
|
||||
*
|
||||
* @param int|null $interval
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInterval($interval)
|
||||
{
|
||||
$this->interval = $interval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getInterval()
|
||||
{
|
||||
return $this->interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* The WKST rule part specifies the day on which the workweek starts.
|
||||
* Valid values are MO, TU, WE, TH, FR, SA, and SU.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWkst($value)
|
||||
{
|
||||
$this->wkst = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYSETPOS filters one interval of events by the specified position.
|
||||
* A positive position will start from the beginning and go forward while
|
||||
* a negative position will start at the end and move backward.
|
||||
*
|
||||
* Valid values are a comma separated string or an array of integers
|
||||
* from 1 to 366 or negative integers from -1 to -366.
|
||||
*
|
||||
* @param int|string|array|null $value
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBySetPos($value)
|
||||
{
|
||||
if (null === $value) {
|
||||
$this->bySetPos = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!(is_string($value) || is_array($value) || is_int($value))) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
|
||||
$list = $value;
|
||||
|
||||
if (is_int($value)) {
|
||||
if ($value === 0 || $value < -366 || $value > 366) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
$this->bySetPos = [$value];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
$list = explode(',', $value);
|
||||
}
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach ($list as $item) {
|
||||
if (is_string($item)) {
|
||||
if (!preg_match('/^ *-?[0-9]* *$/', $item)) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
$item = intval($item);
|
||||
}
|
||||
|
||||
if (!is_int($item) || $item === 0 || $item < -366 || $item > 366) {
|
||||
throw new InvalidArgumentException('Invalid value for BYSETPOS');
|
||||
}
|
||||
|
||||
$output[] = $item;
|
||||
}
|
||||
|
||||
$this->bySetPos = $output;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYMONTH rule part specifies a COMMA-separated list of months of the year.
|
||||
* Valid values are 1 to 12.
|
||||
*
|
||||
* @param int $month
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setByMonth($month)
|
||||
{
|
||||
if (!is_integer($month) || $month <= 0 || $month > 12) {
|
||||
throw new InvalidArgumentException('Invalid value for BYMONTH');
|
||||
}
|
||||
|
||||
$this->byMonth = $month;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYWEEKNO rule part specifies a COMMA-separated list of ordinals specifying weeks of the year.
|
||||
* Valid values are 1 to 53 or -53 to -1.
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setByWeekNo($value)
|
||||
{
|
||||
if (!is_integer($value) || $value > 53 || $value < -53 || $value === 0) {
|
||||
throw new InvalidArgumentException('Invalid value for BYWEEKNO');
|
||||
}
|
||||
|
||||
$this->byWeekNo = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYYEARDAY rule part specifies a COMMA-separated list of days of the year.
|
||||
* Valid values are 1 to 366 or -366 to -1.
|
||||
*
|
||||
* @param int $day
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setByYearDay($day)
|
||||
{
|
||||
if (!is_integer($day) || $day > 366 || $day < -366 || $day === 0) {
|
||||
throw new InvalidArgumentException('Invalid value for BYYEARDAY');
|
||||
}
|
||||
|
||||
$this->byYearDay = $day;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYMONTHDAY rule part specifies a COMMA-separated list of days of the month.
|
||||
* Valid values are 1 to 31 or -31 to -1.
|
||||
*
|
||||
* @param int $day
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setByMonthDay($day)
|
||||
{
|
||||
if (!is_integer($day) || $day > 31 || $day < -31 || $day === 0) {
|
||||
throw new InvalidArgumentException('Invalid value for BYMONTHDAY');
|
||||
}
|
||||
|
||||
$this->byMonthDay = $day;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYDAY rule part specifies a COMMA-separated list of days of the week;.
|
||||
*
|
||||
* SU indicates Sunday; MO indicates Monday; TU indicates Tuesday;
|
||||
* WE indicates Wednesday; TH indicates Thursday; FR indicates Friday; and SA indicates Saturday.
|
||||
*
|
||||
* Each BYDAY value can also be preceded by a positive (+n) or negative (-n) integer.
|
||||
* If present, this indicates the nth occurrence of a specific day within the MONTHLY or YEARLY "RRULE".
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setByDay(string $day)
|
||||
{
|
||||
$this->byDay = $day;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYHOUR rule part specifies a COMMA-separated list of hours of the day.
|
||||
* Valid values are 0 to 23.
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setByHour($value)
|
||||
{
|
||||
if (!is_integer($value) || $value < 0 || $value > 23) {
|
||||
throw new \InvalidArgumentException('Invalid value for BYHOUR');
|
||||
}
|
||||
|
||||
$this->byHour = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYMINUTE rule part specifies a COMMA-separated list of minutes within an hour.
|
||||
* Valid values are 0 to 59.
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setByMinute($value)
|
||||
{
|
||||
if (!is_integer($value) || $value < 0 || $value > 59) {
|
||||
throw new \InvalidArgumentException('Invalid value for BYMINUTE');
|
||||
}
|
||||
|
||||
$this->byMinute = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The BYSECOND rule part specifies a COMMA-separated list of seconds within a minute.
|
||||
* Valid values are 0 to 60.
|
||||
*
|
||||
* @param int $value
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setBySecond($value)
|
||||
{
|
||||
if (!is_integer($value) || $value < 0 || $value > 60) {
|
||||
throw new \InvalidArgumentException('Invalid value for BYSECOND');
|
||||
}
|
||||
|
||||
$this->bySecond = $value;
|
||||
|
||||
$this->canUseBySetPos = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
class RawStringValue extends StringValue
|
||||
{
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
return $this->getValue();
|
||||
}
|
||||
}
|
||||
67
vendor/eluceo/ical/src/Property/StringValue.php
vendored
67
vendor/eluceo/ical/src/Property/StringValue.php
vendored
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
class StringValue implements ValueInterface
|
||||
{
|
||||
/**
|
||||
* The value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $value;
|
||||
|
||||
public function __construct($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function getEscapedValue(): string
|
||||
{
|
||||
$value = $this->value;
|
||||
|
||||
$value = str_replace('\\', '\\\\', $value);
|
||||
$value = str_replace('"', '\\"', $value);
|
||||
$value = str_replace(',', '\\,', $value);
|
||||
$value = str_replace(';', '\\;', $value);
|
||||
$value = str_replace("\n", '\\n', $value);
|
||||
$value = str_replace([
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
|
||||
"\x08", "\x09", /* \n*/ "\x0B", "\x0C", "\x0D", "\x0E", "\x0F",
|
||||
"\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
|
||||
"\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F",
|
||||
"\x7F",
|
||||
], '', $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Property;
|
||||
|
||||
interface ValueInterface
|
||||
{
|
||||
/**
|
||||
* Return the value of the Property as an escaped string.
|
||||
*
|
||||
* Escape values as per RFC 5545.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.3.11
|
||||
*/
|
||||
public function getEscapedValue(): string;
|
||||
}
|
||||
73
vendor/eluceo/ical/src/PropertyBag.php
vendored
73
vendor/eluceo/ical/src/PropertyBag.php
vendored
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class PropertyBag implements \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $elements = [];
|
||||
|
||||
/**
|
||||
* Creates a new Property with $name, $value and $params.
|
||||
*
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param array $params
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function set($name, $value, $params = [])
|
||||
{
|
||||
$this->add(new Property($name, $value, $params));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Property|null
|
||||
*/
|
||||
public function get(string $name)
|
||||
{
|
||||
if (isset($this->elements[$name])) {
|
||||
return $this->elements[$name];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Property. If Property already exists an Exception will be thrown.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function add(Property $property)
|
||||
{
|
||||
$name = $property->getName();
|
||||
|
||||
if (isset($this->elements[$name])) {
|
||||
throw new \Exception("Property with name '{$name}' already exists");
|
||||
}
|
||||
|
||||
$this->elements[$name] = $property;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIterator()
|
||||
{
|
||||
return new \ArrayObject($this->elements);
|
||||
}
|
||||
}
|
||||
62
vendor/eluceo/ical/src/Util/ComponentUtil.php
vendored
62
vendor/eluceo/ical/src/Util/ComponentUtil.php
vendored
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Util;
|
||||
|
||||
class ComponentUtil
|
||||
{
|
||||
/**
|
||||
* Folds a single line.
|
||||
*
|
||||
* According to RFC 5545, all lines longer than 75 characters should be folded
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-5
|
||||
* @see https://tools.ietf.org/html/rfc5545#section-3.1
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function fold($string)
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
if (function_exists('mb_strcut')) {
|
||||
while (strlen($string) > 0) {
|
||||
if (strlen($string) > 75) {
|
||||
$lines[] = mb_strcut($string, 0, 75, 'utf-8');
|
||||
$string = ' ' . mb_strcut($string, 75, strlen($string), 'utf-8');
|
||||
} else {
|
||||
$lines[] = $string;
|
||||
$string = '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$array = preg_split('/(?<!^)(?!$)/u', $string);
|
||||
$line = '';
|
||||
$lineNo = 0;
|
||||
foreach ($array as $char) {
|
||||
$charLen = strlen($char);
|
||||
$lineLen = strlen($line);
|
||||
if ($lineLen + $charLen > 75) {
|
||||
$line = ' ' . $char;
|
||||
++$lineNo;
|
||||
} else {
|
||||
$line .= $char;
|
||||
}
|
||||
$lines[$lineNo] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
return $lines;
|
||||
}
|
||||
}
|
||||
77
vendor/eluceo/ical/src/Util/DateUtil.php
vendored
77
vendor/eluceo/ical/src/Util/DateUtil.php
vendored
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the eluceo/iCal package.
|
||||
*
|
||||
* (c) Markus Poerschke <markus@eluceo.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace Eluceo\iCal\Util;
|
||||
|
||||
class DateUtil
|
||||
{
|
||||
public static function getDefaultParams(\DateTimeInterface $dateTime = null, $noTime = false, $useTimezone = false, $timezoneString = '')
|
||||
{
|
||||
$params = [];
|
||||
|
||||
if ($useTimezone && $noTime === false) {
|
||||
$timeZone = $timezoneString === '' ? $dateTime->getTimezone()->getName() : $timezoneString;
|
||||
$params['TZID'] = $timeZone;
|
||||
}
|
||||
|
||||
if ($noTime) {
|
||||
$params['VALUE'] = 'DATE';
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted date string.
|
||||
*
|
||||
* @param \DateTimeInterface|null $dateTime The DateTime object
|
||||
* @param bool $noTime Indicates if the time will be added
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getDateString(\DateTimeInterface $dateTime = null, $noTime = false, $useTimezone = false, $useUtc = false)
|
||||
{
|
||||
if (empty($dateTime)) {
|
||||
$dateTime = new \DateTimeImmutable();
|
||||
}
|
||||
|
||||
// Only convert the DateTime to UTC if there is a time present. For date-only the
|
||||
// timezone is meaningless and converting it might shift it to the wrong date.
|
||||
// Do not convert DateTime to UTC if a timezone it specified, as it should be local time.
|
||||
if (!$noTime && $useUtc && !$useTimezone) {
|
||||
$dateTime = clone $dateTime;
|
||||
$dateTime = $dateTime->setTimezone(new \DateTimeZone('UTC'));
|
||||
}
|
||||
|
||||
return $dateTime->format(self::getDateFormat($noTime, $useTimezone, $useUtc));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the date format that can be passed to DateTime::format().
|
||||
*
|
||||
* @param bool $noTime Indicates if the time will be added
|
||||
* @param bool $useTimezone
|
||||
* @param bool $useUtc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDateFormat($noTime = false, $useTimezone = false, $useUtc = false)
|
||||
{
|
||||
// Do not use UTC time (Z) if timezone support is enabled.
|
||||
if ($useTimezone || !$useUtc) {
|
||||
return $noTime ? 'Ymd' : 'Ymd\THis';
|
||||
}
|
||||
|
||||
return $noTime ? 'Ymd' : 'Ymd\THis\Z';
|
||||
}
|
||||
}
|
||||
5
vendor/gregwar/captcha/.gitignore
vendored
5
vendor/gregwar/captcha/.gitignore
vendored
@@ -1,5 +0,0 @@
|
||||
.idea/
|
||||
demo/*.jpg
|
||||
demo/*.pgm
|
||||
demo/temp/
|
||||
vendor/
|
||||
16
vendor/gregwar/captcha/.travis.yml
vendored
16
vendor/gregwar/captcha/.travis.yml
vendored
@@ -1,16 +0,0 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.2
|
||||
- hhvm
|
||||
|
||||
script:
|
||||
- composer install
|
||||
- phpunit
|
||||
19
vendor/gregwar/captcha/LICENSE
vendored
19
vendor/gregwar/captcha/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) <2012-2017> Grégoire Passault
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
146
vendor/gregwar/captcha/README.md
vendored
146
vendor/gregwar/captcha/README.md
vendored
@@ -1,146 +0,0 @@
|
||||
Captcha
|
||||
=======
|
||||
|
||||

|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YUXRLWHQSWS6L)
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
With composer :
|
||||
|
||||
``` json
|
||||
{
|
||||
...
|
||||
"require": {
|
||||
"gregwar/captcha": "1.*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
You can create a captcha with the `CaptchaBuilder` :
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
$builder = new CaptchaBuilder;
|
||||
$builder->build();
|
||||
```
|
||||
|
||||
You can then save it to a file :
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
$builder->save('out.jpg');
|
||||
```
|
||||
|
||||
Or output it directly :
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
header('Content-type: image/jpeg');
|
||||
$builder->output();
|
||||
```
|
||||
|
||||
Or inline it directly in the HTML page:
|
||||
|
||||
```php
|
||||
<img src="<?php echo $builder->inline(); ?>" />
|
||||
```
|
||||
|
||||
You'll be able to get the code and compare it with a user input :
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Example: storing the phrase in the session to test for the user
|
||||
// input later
|
||||
$_SESSION['phrase'] = $builder->getPhrase();
|
||||
```
|
||||
|
||||
You can compare the phrase with user input:
|
||||
```php
|
||||
if($builder->testPhrase($userInput)) {
|
||||
// instructions if user phrase is good
|
||||
}
|
||||
else {
|
||||
// user phrase is wrong
|
||||
}
|
||||
```
|
||||
|
||||
API
|
||||
===
|
||||
|
||||
You can use theses functions :
|
||||
|
||||
* **__construct($phrase = null)**, constructs the builder with the given phrase, if the phrase is null, a random one will be generated
|
||||
* **getPhrase()**, allow you to get the phrase contents
|
||||
* **setDistortion($distortion)**, enable or disable the distortion, call it before `build()`
|
||||
* **isOCRReadable()**, returns `true` if the OCR can be read using the `ocrad` software, you'll need to have shell_exec enabled, imagemagick and ocrad installed
|
||||
* **buildAgainstOCR($width = 150, $height = 40, $font = null)**, builds a code until it is not readable by `ocrad`
|
||||
* **build($width = 150, $height = 40, $font = null)**, builds a code with the given $width, $height and $font. By default, a random font will be used from the library
|
||||
* **save($filename, $quality = 80)**, saves the captcha into a jpeg in the $filename, with the given quality
|
||||
* **get($quality = 80)**, returns the jpeg data
|
||||
* **output($quality = 80)**, directly outputs the jpeg code to a browser
|
||||
* **setBackgroundColor($r, $g, $b)**, sets the background color to force it (this will disable many effects and is not recommended)
|
||||
* **setBackgroundImages(array($imagepath1, $imagePath2))**, Sets custom background images to be used as captcha background. It is recommended to disable image effects when passing custom images for background (ignore_all_effects). A random image is selected from the list passed, the full paths to the image files must be passed.
|
||||
* **setInterpolation($interpolate)**, enable or disable the interpolation (enabled by default), disabling it will be quicker but the images will look uglier
|
||||
* **setIgnoreAllEffects($ignoreAllEffects)**, disable all effects on the captcha image. Recommended to use when passing custom background images for the captcha.
|
||||
* **testPhrase($phrase)**, returns true if the given phrase is good
|
||||
* **setMaxBehindLines($lines)**, sets the maximum number of lines behind the code
|
||||
* **setMaxFrontLines($lines)**, sets the maximum number of lines on the front of the code
|
||||
|
||||
If you want to change the number of character, you can call the phrase builder directly using
|
||||
extra parameters:
|
||||
|
||||
```php
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
use Gregwar\Captcha\PhraseBuilder;
|
||||
|
||||
// Will build phrases of 3 characters
|
||||
$phraseBuilder = new PhraseBuilder(4)
|
||||
|
||||
// Will build phrases of 5 characters, only digits
|
||||
$phraseBuilder = new PhraseBuilder(5, '0123456789');
|
||||
|
||||
// Pass it as first argument of CaptchaBuilder, passing it the phrase
|
||||
// builder
|
||||
$captcha = new CaptchaBuilder(null, $phraseBuilder);
|
||||
```
|
||||
|
||||
You can also pass directly the wanted phrase to the builder:
|
||||
|
||||
```php
|
||||
// Building a Captcha with the "hello" phrase
|
||||
$captcha = new CaptchaBuilder('hello');
|
||||
```
|
||||
|
||||
Complete example
|
||||
================
|
||||
|
||||
If you want to see an example you can have a look at he ``demo/form.php``, which uses ``demo/session.php`` to
|
||||
render a captcha and check it after the submission
|
||||
|
||||
Symfony Bundle
|
||||
================
|
||||
|
||||
You can have a look at the following repository to enjoy the Symfony 2 bundle packaging this captcha generator :
|
||||
https://github.com/Gregwar/CaptchaBundle
|
||||
|
||||
Yii2 Extension
|
||||
===============
|
||||
|
||||
You can use the following extension for integrating with Yii2 Framework :
|
||||
https://github.com/juliardi/yii2-captcha
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
This library is under MIT license, have a look to the `LICENSE` file
|
||||
33
vendor/gregwar/captcha/composer.json
vendored
33
vendor/gregwar/captcha/composer.json
vendored
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "gregwar/captcha",
|
||||
"type": "captcha",
|
||||
"description": "Captcha generator",
|
||||
"keywords": ["captcha", "spam", "bot"],
|
||||
"homepage": "https://github.com/Gregwar/Captcha",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Grégoire Passault",
|
||||
"email": "g.passault@gmail.com",
|
||||
"homepage": "http://www.gregwar.com/"
|
||||
},
|
||||
{
|
||||
"name": "Jeremy Livingston",
|
||||
"email": "jeremy.j.livingston@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"ext-gd": "*",
|
||||
"ext-mbstring": "*",
|
||||
"symfony/finder": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Gregwar\\": "src/Gregwar"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.4"
|
||||
}
|
||||
}
|
||||
11
vendor/gregwar/captcha/demo/demo.php
vendored
11
vendor/gregwar/captcha/demo/demo.php
vendored
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
$captcha = new CaptchaBuilder;
|
||||
$captcha
|
||||
->build()
|
||||
->save('out.jpg')
|
||||
;
|
||||
12
vendor/gregwar/captcha/demo/fingerprint.php
vendored
12
vendor/gregwar/captcha/demo/fingerprint.php
vendored
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
echo count(CaptchaBuilder::create()
|
||||
->build()
|
||||
->getFingerprint()
|
||||
);
|
||||
|
||||
echo "\n";
|
||||
32
vendor/gregwar/captcha/demo/form.php
vendored
32
vendor/gregwar/captcha/demo/form.php
vendored
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
use Gregwar\Captcha\PhraseBuilder;
|
||||
|
||||
// We need the session to check the phrase after submitting
|
||||
session_start();
|
||||
?>
|
||||
|
||||
<html>
|
||||
<?php
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
// Checking that the posted phrase match the phrase stored in the session
|
||||
if (isset($_SESSION['phrase']) && PhraseBuilder::comparePhrases($_SESSION['phrase'], $_POST['phrase'])) {
|
||||
echo "<h1>Captcha is valid !</h1>";
|
||||
} else {
|
||||
echo "<h1>Captcha is not valid!</h1>";
|
||||
}
|
||||
// The phrase can't be used twice
|
||||
unset($_SESSION['phrase']);
|
||||
}
|
||||
?>
|
||||
<form method="post">
|
||||
Copy the CAPTCHA:
|
||||
<?php
|
||||
// See session.php, where the captcha is actually rendered and the session phrase
|
||||
// is set accordingly to the image displayed
|
||||
?>
|
||||
<img src="session.php" />
|
||||
<input type="text" name="phrase" />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
</html>
|
||||
15
vendor/gregwar/captcha/demo/index.php
vendored
15
vendor/gregwar/captcha/demo/index.php
vendored
@@ -1,15 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<body>
|
||||
<html>
|
||||
<meta charset="utf-8" />
|
||||
</html>
|
||||
<body>
|
||||
<h1>Captchas gallery</h1>
|
||||
<?php for ($x=0; $x<8; $x++) { ?>
|
||||
<?php for ($y=0; $y<5; $y++) { ?>
|
||||
<img src="output.php?n=<?php echo 5*$x+$y; ?>" />
|
||||
<?php } ?>
|
||||
<br />
|
||||
<?php } ?>
|
||||
</body>
|
||||
</body>
|
||||
22
vendor/gregwar/captcha/demo/inline.php
vendored
22
vendor/gregwar/captcha/demo/inline.php
vendored
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
$captcha = new CaptchaBuilder();
|
||||
$captcha->build();
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<body>
|
||||
<html>
|
||||
<meta charset="utf-8" />
|
||||
</html>
|
||||
<body>
|
||||
<h1>Inline Captcha</h1>
|
||||
|
||||
<img src="<?php echo $captcha->inline(); ?>"/><br/>
|
||||
Phrase: <?php echo $captcha->getPhrase(); ?>
|
||||
|
||||
</body>
|
||||
</body>
|
||||
39
vendor/gregwar/captcha/demo/ocr.php
vendored
39
vendor/gregwar/captcha/demo/ocr.php
vendored
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
/**
|
||||
* Generates 1000 captchas and try to read their code with the
|
||||
* ocrad OCR
|
||||
*/
|
||||
|
||||
$tests = 10000;
|
||||
$passed = 0;
|
||||
|
||||
shell_exec('rm passed*.jpg');
|
||||
|
||||
for ($i=0; $i<$tests; $i++) {
|
||||
echo "Captcha $i/$tests... ";
|
||||
|
||||
$captcha = new CaptchaBuilder;
|
||||
|
||||
$captcha
|
||||
->setDistortion(false)
|
||||
->build()
|
||||
;
|
||||
|
||||
if ($captcha->isOCRReadable()) {
|
||||
$passed++;
|
||||
$captcha->save("passed$passed.jpg");
|
||||
echo "passed at ocr... ";
|
||||
} else {
|
||||
echo "failed... ";
|
||||
}
|
||||
|
||||
echo "pass rate: ".round(100*$passed/($i+1),2)."%\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
echo "Over, $passed/$tests readed with OCR\n";
|
||||
12
vendor/gregwar/captcha/demo/output.php
vendored
12
vendor/gregwar/captcha/demo/output.php
vendored
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
header('Content-type: image/jpeg');
|
||||
|
||||
CaptchaBuilder::create()
|
||||
->build()
|
||||
->output()
|
||||
;
|
||||
22
vendor/gregwar/captcha/demo/session.php
vendored
22
vendor/gregwar/captcha/demo/session.php
vendored
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
// We need the session to store the correct phrase for later check
|
||||
session_start();
|
||||
|
||||
// Including the autoload (you need to composer install in the main directory)
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
|
||||
// Creating the captcha instance and setting the phrase in the session to store
|
||||
// it for check when the form is submitted
|
||||
$captcha = new CaptchaBuilder;
|
||||
$_SESSION['phrase'] = $captcha->getPhrase();
|
||||
|
||||
// Setting the header to image jpeg because we here render an image
|
||||
header('Content-Type: image/jpeg');
|
||||
|
||||
// Running the actual rendering of the captcha image
|
||||
$captcha
|
||||
->build()
|
||||
->output()
|
||||
;
|
||||
15
vendor/gregwar/captcha/phpunit.xml.dist
vendored
15
vendor/gregwar/captcha/phpunit.xml.dist
vendored
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit colors="true" bootstrap="vendor/autoload.php">
|
||||
<testsuites>
|
||||
<testsuite name="KnpMenu Test Suite">
|
||||
<directory suffix="Test.php">./tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./src</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
@@ -1,739 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Captcha;
|
||||
|
||||
use \Exception;
|
||||
|
||||
/**
|
||||
* Builds a new captcha image
|
||||
* Uses the fingerprint parameter, if one is passed, to generate the same image
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
* @author Jeremy Livingston <jeremy.j.livingston@gmail.com>
|
||||
*/
|
||||
class CaptchaBuilder implements CaptchaBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fingerprint = array();
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $useFingerprint = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $textColor = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $lineColor = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $backgroundColor = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $backgroundImages = array();
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
protected $contents = null;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $phrase = null;
|
||||
|
||||
/**
|
||||
* @var PhraseBuilderInterface
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $distortion = true;
|
||||
|
||||
/**
|
||||
* The maximum number of lines to draw in front of
|
||||
* the image. null - use default algorithm
|
||||
*/
|
||||
protected $maxFrontLines = null;
|
||||
|
||||
/**
|
||||
* The maximum number of lines to draw behind
|
||||
* the image. null - use default algorithm
|
||||
*/
|
||||
protected $maxBehindLines = null;
|
||||
|
||||
/**
|
||||
* The maximum angle of char
|
||||
*/
|
||||
protected $maxAngle = 8;
|
||||
|
||||
/**
|
||||
* The maximum offset of char
|
||||
*/
|
||||
protected $maxOffset = 5;
|
||||
|
||||
/**
|
||||
* Is the interpolation enabled ?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $interpolation = true;
|
||||
|
||||
/**
|
||||
* Ignore all effects
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $ignoreAllEffects = false;
|
||||
|
||||
/**
|
||||
* Allowed image types for the background images
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $allowedBackgroundImageTypes = array('image/png', 'image/jpeg', 'image/gif');
|
||||
|
||||
/**
|
||||
* The image contents
|
||||
*/
|
||||
public function getContents()
|
||||
{
|
||||
return $this->contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disables the interpolation
|
||||
*
|
||||
* @param $interpolate bool True to enable, false to disable
|
||||
*
|
||||
* @return CaptchaBuilder
|
||||
*/
|
||||
public function setInterpolation($interpolate = true)
|
||||
{
|
||||
$this->interpolation = $interpolate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary dir, for OCR check
|
||||
*/
|
||||
public $tempDir = 'temp/';
|
||||
|
||||
public function __construct($phrase = null, PhraseBuilderInterface $builder = null)
|
||||
{
|
||||
if ($builder === null) {
|
||||
$this->builder = new PhraseBuilder;
|
||||
} else {
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
$this->phrase = is_string($phrase) ? $phrase : $this->builder->build($phrase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the phrase
|
||||
*/
|
||||
public function setPhrase($phrase)
|
||||
{
|
||||
$this->phrase = (string) $phrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disable distortion
|
||||
*/
|
||||
public function setDistortion($distortion)
|
||||
{
|
||||
$this->distortion = (bool) $distortion;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMaxBehindLines($maxBehindLines)
|
||||
{
|
||||
$this->maxBehindLines = $maxBehindLines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMaxFrontLines($maxFrontLines)
|
||||
{
|
||||
$this->maxFrontLines = $maxFrontLines;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMaxAngle($maxAngle)
|
||||
{
|
||||
$this->maxAngle = $maxAngle;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMaxOffset($maxOffset)
|
||||
{
|
||||
$this->maxOffset = $maxOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the captcha phrase
|
||||
*/
|
||||
public function getPhrase()
|
||||
{
|
||||
return $this->phrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given phrase is good
|
||||
*/
|
||||
public function testPhrase($phrase)
|
||||
{
|
||||
return ($this->builder->niceize($phrase) == $this->builder->niceize($this->getPhrase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiation
|
||||
*/
|
||||
public static function create($phrase = null)
|
||||
{
|
||||
return new self($phrase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text color to use
|
||||
*/
|
||||
public function setTextColor($r, $g, $b)
|
||||
{
|
||||
$this->textColor = array($r, $g, $b);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the background color to use
|
||||
*/
|
||||
public function setBackgroundColor($r, $g, $b)
|
||||
{
|
||||
$this->backgroundColor = array($r, $g, $b);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLineColor($r, $g, $b)
|
||||
{
|
||||
$this->lineColor = array($r, $g, $b);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ignoreAllEffects value
|
||||
*
|
||||
* @param bool $ignoreAllEffects
|
||||
* @return CaptchaBuilder
|
||||
*/
|
||||
public function setIgnoreAllEffects($ignoreAllEffects)
|
||||
{
|
||||
$this->ignoreAllEffects = $ignoreAllEffects;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of background images to use (one image is randomly selected)
|
||||
*/
|
||||
public function setBackgroundImages(array $backgroundImages)
|
||||
{
|
||||
$this->backgroundImages = $backgroundImages;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw lines over the image
|
||||
*/
|
||||
protected function drawLine($image, $width, $height, $tcol = null)
|
||||
{
|
||||
if ($this->lineColor === null) {
|
||||
$red = $this->rand(100, 255);
|
||||
$green = $this->rand(100, 255);
|
||||
$blue = $this->rand(100, 255);
|
||||
} else {
|
||||
$red = $this->lineColor[0];
|
||||
$green = $this->lineColor[1];
|
||||
$blue = $this->lineColor[2];
|
||||
}
|
||||
|
||||
if ($tcol === null) {
|
||||
$tcol = imagecolorallocate($image, $red, $green, $blue);
|
||||
}
|
||||
|
||||
if ($this->rand(0, 1)) { // Horizontal
|
||||
$Xa = $this->rand(0, $width/2);
|
||||
$Ya = $this->rand(0, $height);
|
||||
$Xb = $this->rand($width/2, $width);
|
||||
$Yb = $this->rand(0, $height);
|
||||
} else { // Vertical
|
||||
$Xa = $this->rand(0, $width);
|
||||
$Ya = $this->rand(0, $height/2);
|
||||
$Xb = $this->rand(0, $width);
|
||||
$Yb = $this->rand($height/2, $height);
|
||||
}
|
||||
imagesetthickness($image, $this->rand(1, 3));
|
||||
imageline($image, $Xa, $Ya, $Xb, $Yb, $tcol);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply some post effects
|
||||
*/
|
||||
protected function postEffect($image)
|
||||
{
|
||||
if (!function_exists('imagefilter')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->backgroundColor != null || $this->textColor != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Negate ?
|
||||
if ($this->rand(0, 1) == 0) {
|
||||
imagefilter($image, IMG_FILTER_NEGATE);
|
||||
}
|
||||
|
||||
// Edge ?
|
||||
if ($this->rand(0, 10) == 0) {
|
||||
imagefilter($image, IMG_FILTER_EDGEDETECT);
|
||||
}
|
||||
|
||||
// Contrast
|
||||
imagefilter($image, IMG_FILTER_CONTRAST, $this->rand(-50, 10));
|
||||
|
||||
// Colorize
|
||||
if ($this->rand(0, 5) == 0) {
|
||||
imagefilter($image, IMG_FILTER_COLORIZE, $this->rand(-80, 50), $this->rand(-80, 50), $this->rand(-80, 50));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the phrase on the image
|
||||
*/
|
||||
protected function writePhrase($image, $phrase, $font, $width, $height)
|
||||
{
|
||||
$length = mb_strlen($phrase);
|
||||
if ($length === 0) {
|
||||
return \imagecolorallocate($image, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Gets the text size and start position
|
||||
$size = $width / $length - $this->rand(0, 3) - 1;
|
||||
$box = \imagettfbbox($size, 0, $font, $phrase);
|
||||
$textWidth = $box[2] - $box[0];
|
||||
$textHeight = $box[1] - $box[7];
|
||||
$x = ($width - $textWidth) / 2;
|
||||
$y = ($height - $textHeight) / 2 + $size;
|
||||
|
||||
if (!$this->textColor) {
|
||||
$textColor = array($this->rand(0, 150), $this->rand(0, 150), $this->rand(0, 150));
|
||||
} else {
|
||||
$textColor = $this->textColor;
|
||||
}
|
||||
$col = \imagecolorallocate($image, $textColor[0], $textColor[1], $textColor[2]);
|
||||
|
||||
// Write the letters one by one, with random angle
|
||||
for ($i=0; $i<$length; $i++) {
|
||||
$symbol = mb_substr($phrase, $i, 1);
|
||||
$box = \imagettfbbox($size, 0, $font, $symbol);
|
||||
$w = $box[2] - $box[0];
|
||||
$angle = $this->rand(-$this->maxAngle, $this->maxAngle);
|
||||
$offset = $this->rand(-$this->maxOffset, $this->maxOffset);
|
||||
\imagettftext($image, $size, $angle, $x, $y + $offset, $col, $font, $symbol);
|
||||
$x += $w;
|
||||
}
|
||||
|
||||
return $col;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to read the code against an OCR
|
||||
*/
|
||||
public function isOCRReadable()
|
||||
{
|
||||
if (!is_dir($this->tempDir)) {
|
||||
@mkdir($this->tempDir, 0755, true);
|
||||
}
|
||||
|
||||
$tempj = $this->tempDir . uniqid('captcha', true) . '.jpg';
|
||||
$tempp = $this->tempDir . uniqid('captcha', true) . '.pgm';
|
||||
|
||||
$this->save($tempj);
|
||||
shell_exec("convert $tempj $tempp");
|
||||
$value = trim(strtolower(shell_exec("ocrad $tempp")));
|
||||
|
||||
@unlink($tempj);
|
||||
@unlink($tempp);
|
||||
|
||||
return $this->testPhrase($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds while the code is readable against an OCR
|
||||
*/
|
||||
public function buildAgainstOCR($width = 150, $height = 40, $font = null, $fingerprint = null)
|
||||
{
|
||||
do {
|
||||
$this->build($width, $height, $font, $fingerprint);
|
||||
} while ($this->isOCRReadable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the image
|
||||
*/
|
||||
public function build($width = 150, $height = 40, $font = null, $fingerprint = null)
|
||||
{
|
||||
if (null !== $fingerprint) {
|
||||
$this->fingerprint = $fingerprint;
|
||||
$this->useFingerprint = true;
|
||||
} else {
|
||||
$this->fingerprint = array();
|
||||
$this->useFingerprint = false;
|
||||
}
|
||||
|
||||
if ($font === null) {
|
||||
$font = __DIR__ . '/Font/captcha'.$this->rand(0, 5).'.ttf';
|
||||
}
|
||||
|
||||
if (empty($this->backgroundImages)) {
|
||||
// if background images list is not set, use a color fill as a background
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
if ($this->backgroundColor == null) {
|
||||
$bg = imagecolorallocate($image, $this->rand(200, 255), $this->rand(200, 255), $this->rand(200, 255));
|
||||
} else {
|
||||
$color = $this->backgroundColor;
|
||||
$bg = imagecolorallocate($image, $color[0], $color[1], $color[2]);
|
||||
}
|
||||
$this->background = $bg;
|
||||
imagefill($image, 0, 0, $bg);
|
||||
} else {
|
||||
// use a random background image
|
||||
$randomBackgroundImage = $this->backgroundImages[rand(0, count($this->backgroundImages)-1)];
|
||||
|
||||
$imageType = $this->validateBackgroundImage($randomBackgroundImage);
|
||||
|
||||
$image = $this->createBackgroundImageFromType($randomBackgroundImage, $imageType);
|
||||
}
|
||||
|
||||
// Apply effects
|
||||
if (!$this->ignoreAllEffects) {
|
||||
$square = $width * $height;
|
||||
$effects = $this->rand($square/3000, $square/2000);
|
||||
|
||||
// set the maximum number of lines to draw in front of the text
|
||||
if ($this->maxBehindLines != null && $this->maxBehindLines > 0) {
|
||||
$effects = min($this->maxBehindLines, $effects);
|
||||
}
|
||||
|
||||
if ($this->maxBehindLines !== 0) {
|
||||
for ($e = 0; $e < $effects; $e++) {
|
||||
$this->drawLine($image, $width, $height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Write CAPTCHA text
|
||||
$color = $this->writePhrase($image, $this->phrase, $font, $width, $height);
|
||||
|
||||
// Apply effects
|
||||
if (!$this->ignoreAllEffects) {
|
||||
$square = $width * $height;
|
||||
$effects = $this->rand($square/3000, $square/2000);
|
||||
|
||||
// set the maximum number of lines to draw in front of the text
|
||||
if ($this->maxFrontLines != null && $this->maxFrontLines > 0) {
|
||||
$effects = min($this->maxFrontLines, $effects);
|
||||
}
|
||||
|
||||
if ($this->maxFrontLines !== 0) {
|
||||
for ($e = 0; $e < $effects; $e++) {
|
||||
$this->drawLine($image, $width, $height, $color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Distort the image
|
||||
if ($this->distortion && !$this->ignoreAllEffects) {
|
||||
$image = $this->distort($image, $width, $height, $bg);
|
||||
}
|
||||
|
||||
// Post effects
|
||||
if (!$this->ignoreAllEffects) {
|
||||
$this->postEffect($image);
|
||||
}
|
||||
|
||||
$this->contents = $image;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Distorts the image
|
||||
*/
|
||||
public function distort($image, $width, $height, $bg)
|
||||
{
|
||||
$contents = imagecreatetruecolor($width, $height);
|
||||
$X = $this->rand(0, $width);
|
||||
$Y = $this->rand(0, $height);
|
||||
$phase = $this->rand(0, 10);
|
||||
$scale = 1.1 + $this->rand(0, 10000) / 30000;
|
||||
for ($x = 0; $x < $width; $x++) {
|
||||
for ($y = 0; $y < $height; $y++) {
|
||||
$Vx = $x - $X;
|
||||
$Vy = $y - $Y;
|
||||
$Vn = sqrt($Vx * $Vx + $Vy * $Vy);
|
||||
|
||||
if ($Vn != 0) {
|
||||
$Vn2 = $Vn + 4 * sin($Vn / 30);
|
||||
$nX = $X + ($Vx * $Vn2 / $Vn);
|
||||
$nY = $Y + ($Vy * $Vn2 / $Vn);
|
||||
} else {
|
||||
$nX = $X;
|
||||
$nY = $Y;
|
||||
}
|
||||
$nY = $nY + $scale * sin($phase + $nX * 0.2);
|
||||
|
||||
if ($this->interpolation) {
|
||||
$p = $this->interpolate(
|
||||
$nX - floor($nX),
|
||||
$nY - floor($nY),
|
||||
$this->getCol($image, floor($nX), floor($nY), $bg),
|
||||
$this->getCol($image, ceil($nX), floor($nY), $bg),
|
||||
$this->getCol($image, floor($nX), ceil($nY), $bg),
|
||||
$this->getCol($image, ceil($nX), ceil($nY), $bg)
|
||||
);
|
||||
} else {
|
||||
$p = $this->getCol($image, round($nX), round($nY), $bg);
|
||||
}
|
||||
|
||||
if ($p == 0) {
|
||||
$p = $bg;
|
||||
}
|
||||
|
||||
imagesetpixel($contents, $x, $y, $p);
|
||||
}
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the Captcha to a jpeg file
|
||||
*/
|
||||
public function save($filename, $quality = 90)
|
||||
{
|
||||
imagejpeg($this->contents, $filename, $quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image GD
|
||||
*/
|
||||
public function getGd()
|
||||
{
|
||||
return $this->contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the image contents
|
||||
*/
|
||||
public function get($quality = 90)
|
||||
{
|
||||
ob_start();
|
||||
$this->output($quality);
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTML inline base64
|
||||
*/
|
||||
public function inline($quality = 90)
|
||||
{
|
||||
return 'data:image/jpeg;base64,' . base64_encode($this->get($quality));
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the image
|
||||
*/
|
||||
public function output($quality = 90)
|
||||
{
|
||||
imagejpeg($this->contents, null, $quality);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFingerprint()
|
||||
{
|
||||
return $this->fingerprint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random number or the next number in the
|
||||
* fingerprint
|
||||
*/
|
||||
protected function rand($min, $max)
|
||||
{
|
||||
if (!is_array($this->fingerprint)) {
|
||||
$this->fingerprint = array();
|
||||
}
|
||||
|
||||
if ($this->useFingerprint) {
|
||||
$value = current($this->fingerprint);
|
||||
next($this->fingerprint);
|
||||
} else {
|
||||
$value = mt_rand($min, $max);
|
||||
$this->fingerprint[] = $value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $x
|
||||
* @param $y
|
||||
* @param $nw
|
||||
* @param $ne
|
||||
* @param $sw
|
||||
* @param $se
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function interpolate($x, $y, $nw, $ne, $sw, $se)
|
||||
{
|
||||
list($r0, $g0, $b0) = $this->getRGB($nw);
|
||||
list($r1, $g1, $b1) = $this->getRGB($ne);
|
||||
list($r2, $g2, $b2) = $this->getRGB($sw);
|
||||
list($r3, $g3, $b3) = $this->getRGB($se);
|
||||
|
||||
$cx = 1.0 - $x;
|
||||
$cy = 1.0 - $y;
|
||||
|
||||
$m0 = $cx * $r0 + $x * $r1;
|
||||
$m1 = $cx * $r2 + $x * $r3;
|
||||
$r = (int) ($cy * $m0 + $y * $m1);
|
||||
|
||||
$m0 = $cx * $g0 + $x * $g1;
|
||||
$m1 = $cx * $g2 + $x * $g3;
|
||||
$g = (int) ($cy * $m0 + $y * $m1);
|
||||
|
||||
$m0 = $cx * $b0 + $x * $b1;
|
||||
$m1 = $cx * $b2 + $x * $b3;
|
||||
$b = (int) ($cy * $m0 + $y * $m1);
|
||||
|
||||
return ($r << 16) | ($g << 8) | $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $image
|
||||
* @param $x
|
||||
* @param $y
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getCol($image, $x, $y, $background)
|
||||
{
|
||||
$L = imagesx($image);
|
||||
$H = imagesy($image);
|
||||
if ($x < 0 || $x >= $L || $y < 0 || $y >= $H) {
|
||||
return $background;
|
||||
}
|
||||
|
||||
return imagecolorat($image, $x, $y);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $col
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRGB($col)
|
||||
{
|
||||
return array(
|
||||
(int) ($col >> 16) & 0xff,
|
||||
(int) ($col >> 8) & 0xff,
|
||||
(int) ($col) & 0xff,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the background image path. Return the image type if valid
|
||||
*
|
||||
* @param string $backgroundImage
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function validateBackgroundImage($backgroundImage)
|
||||
{
|
||||
// check if file exists
|
||||
if (!file_exists($backgroundImage)) {
|
||||
$backgroundImageExploded = explode('/', $backgroundImage);
|
||||
$imageFileName = count($backgroundImageExploded) > 1? $backgroundImageExploded[count($backgroundImageExploded)-1] : $backgroundImage;
|
||||
|
||||
throw new Exception('Invalid background image: ' . $imageFileName);
|
||||
}
|
||||
|
||||
// check image type
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
|
||||
$imageType = finfo_file($finfo, $backgroundImage);
|
||||
finfo_close($finfo);
|
||||
|
||||
if (!in_array($imageType, $this->allowedBackgroundImageTypes)) {
|
||||
throw new Exception('Invalid background image type! Allowed types are: ' . join(', ', $this->allowedBackgroundImageTypes));
|
||||
}
|
||||
|
||||
return $imageType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create background image from type
|
||||
*
|
||||
* @param string $backgroundImage
|
||||
* @param string $imageType
|
||||
* @return resource
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function createBackgroundImageFromType($backgroundImage, $imageType)
|
||||
{
|
||||
switch ($imageType) {
|
||||
case 'image/jpeg':
|
||||
$image = imagecreatefromjpeg($backgroundImage);
|
||||
break;
|
||||
case 'image/png':
|
||||
$image = imagecreatefrompng($backgroundImage);
|
||||
break;
|
||||
case 'image/gif':
|
||||
$image = imagecreatefromgif($backgroundImage);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Not supported file type for background image!');
|
||||
break;
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Captcha;
|
||||
|
||||
/**
|
||||
* A Captcha builder
|
||||
*/
|
||||
interface CaptchaBuilderInterface
|
||||
{
|
||||
/**
|
||||
* Builds the code
|
||||
*/
|
||||
public function build($width, $height, $font, $fingerprint);
|
||||
|
||||
/**
|
||||
* Saves the code to a file
|
||||
*/
|
||||
public function save($filename, $quality);
|
||||
|
||||
/**
|
||||
* Gets the image contents
|
||||
*/
|
||||
public function get($quality);
|
||||
|
||||
/**
|
||||
* Outputs the image
|
||||
*/
|
||||
public function output($quality);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Captcha;
|
||||
|
||||
use Symfony\Component\Finder\Finder;
|
||||
|
||||
/**
|
||||
* Handles actions related to captcha image files including saving and garbage collection
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
* @author Jeremy Livingston <jeremy@quizzle.com>
|
||||
*/
|
||||
class ImageFileHandler
|
||||
{
|
||||
/**
|
||||
* Name of folder for captcha images
|
||||
* @var string
|
||||
*/
|
||||
protected $imageFolder;
|
||||
|
||||
/**
|
||||
* Absolute path to public web folder
|
||||
* @var string
|
||||
*/
|
||||
protected $webPath;
|
||||
|
||||
/**
|
||||
* Frequency of garbage collection in fractions of 1
|
||||
* @var int
|
||||
*/
|
||||
protected $gcFreq;
|
||||
|
||||
/**
|
||||
* Maximum age of images in minutes
|
||||
* @var int
|
||||
*/
|
||||
protected $expiration;
|
||||
|
||||
/**
|
||||
* @param $imageFolder
|
||||
* @param $webPath
|
||||
* @param $gcFreq
|
||||
* @param $expiration
|
||||
*/
|
||||
public function __construct($imageFolder, $webPath, $gcFreq, $expiration)
|
||||
{
|
||||
$this->imageFolder = $imageFolder;
|
||||
$this->webPath = $webPath;
|
||||
$this->gcFreq = $gcFreq;
|
||||
$this->expiration = $expiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the provided image content as a file
|
||||
*
|
||||
* @param string $contents
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveAsFile($contents)
|
||||
{
|
||||
$this->createFolderIfMissing();
|
||||
|
||||
$filename = md5(uniqid()) . '.jpg';
|
||||
$filePath = $this->webPath . '/' . $this->imageFolder . '/' . $filename;
|
||||
imagejpeg($contents, $filePath, 15);
|
||||
|
||||
return '/' . $this->imageFolder . '/' . $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly runs garbage collection on the image directory
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function collectGarbage()
|
||||
{
|
||||
if (!mt_rand(1, $this->gcFreq) == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->createFolderIfMissing();
|
||||
|
||||
$finder = new Finder();
|
||||
$criteria = sprintf('<= now - %s minutes', $this->expiration);
|
||||
$finder->in($this->webPath . '/' . $this->imageFolder)
|
||||
->date($criteria);
|
||||
|
||||
foreach ($finder->files() as $file) {
|
||||
unlink($file->getPathname());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the folder if it doesn't exist
|
||||
*/
|
||||
protected function createFolderIfMissing()
|
||||
{
|
||||
if (!file_exists($this->webPath . '/' . $this->imageFolder)) {
|
||||
mkdir($this->webPath . '/' . $this->imageFolder, 0755);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Captcha;
|
||||
|
||||
/**
|
||||
* Generates random phrase
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
class PhraseBuilder implements PhraseBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $length;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $charset;
|
||||
/**
|
||||
* Constructs a PhraseBuilder with given parameters
|
||||
*/
|
||||
public function __construct($length = 5, $charset = 'abcdefghijklmnpqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
||||
{
|
||||
$this->length = $length;
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates random phrase of given length with given charset
|
||||
*/
|
||||
public function build($length = null, $charset = null)
|
||||
{
|
||||
if ($length !== null) {
|
||||
$this->length = $length;
|
||||
}
|
||||
if ($charset !== null) {
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
$phrase = '';
|
||||
$chars = str_split($this->charset);
|
||||
|
||||
for ($i = 0; $i < $this->length; $i++) {
|
||||
$phrase .= $chars[array_rand($chars)];
|
||||
}
|
||||
|
||||
return $phrase;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Niceize" a code
|
||||
*/
|
||||
public function niceize($str)
|
||||
{
|
||||
return self::doNiceize($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* A static helper to niceize
|
||||
*/
|
||||
public static function doNiceize($str)
|
||||
{
|
||||
return strtr(strtolower($str), '01', 'ol');
|
||||
}
|
||||
|
||||
/**
|
||||
* A static helper to compare
|
||||
*/
|
||||
public static function comparePhrases($str1, $str2)
|
||||
{
|
||||
return self::doNiceize($str1) === self::doNiceize($str2);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Captcha;
|
||||
|
||||
/**
|
||||
* Interface for the PhraseBuilder
|
||||
*
|
||||
* @author Gregwar <g.passault@gmail.com>
|
||||
*/
|
||||
interface PhraseBuilderInterface
|
||||
{
|
||||
/**
|
||||
* Generates random phrase of given length with given charset
|
||||
*/
|
||||
public function build();
|
||||
|
||||
/**
|
||||
* "Niceize" a code
|
||||
*/
|
||||
public function niceize($str);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Gregwar\Captcha\CaptchaBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CaptchaBuilderTest extends TestCase
|
||||
{
|
||||
public function testDemo()
|
||||
{
|
||||
$captcha = new CaptchaBuilder();
|
||||
$captcha
|
||||
->build()
|
||||
->save('out.jpg')
|
||||
;
|
||||
|
||||
$this->assertTrue(file_exists(__DIR__.'/../out.jpg'));
|
||||
}
|
||||
|
||||
public function testFingerPrint()
|
||||
{
|
||||
$int = count(CaptchaBuilder::create()
|
||||
->build()
|
||||
->getFingerprint()
|
||||
);
|
||||
|
||||
$this->assertTrue(is_int($int));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
*.crt -crlf
|
||||
*.key -crlf
|
||||
*.srl -crlf
|
||||
*.pub -crlf
|
||||
*.priv -crlf
|
||||
*.txt -crlf
|
||||
|
||||
# ignore /notes in the git-generated distributed .zip archive
|
||||
/notes export-ignore
|
||||
8
vendor/swiftmailer/swiftmailer/.gitignore
vendored
8
vendor/swiftmailer/swiftmailer/.gitignore
vendored
@@ -1,8 +0,0 @@
|
||||
/.php_cs.cache
|
||||
/.phpunit
|
||||
/build/*
|
||||
/composer.lock
|
||||
/phpunit.xml
|
||||
/tests/acceptance.conf.php
|
||||
/tests/smoke.conf.php
|
||||
/vendor/
|
||||
15
vendor/swiftmailer/swiftmailer/.php_cs.dist
vendored
15
vendor/swiftmailer/swiftmailer/.php_cs.dist
vendored
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules(array(
|
||||
'@Symfony' => true,
|
||||
'@Symfony:risky' => true,
|
||||
'array_syntax' => array('syntax' => 'long'),
|
||||
'no_unreachable_default_argument_value' => false,
|
||||
'braces' => array('allow_single_line_closure' => true),
|
||||
'heredoc_to_nowdoc' => false,
|
||||
'phpdoc_annotation_without_dot' => false,
|
||||
))
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder(PhpCsFixer\Finder::create()->in(__DIR__))
|
||||
;
|
||||
31
vendor/swiftmailer/swiftmailer/.travis.yml
vendored
31
vendor/swiftmailer/swiftmailer/.travis.yml
vendored
@@ -1,31 +0,0 @@
|
||||
language: php
|
||||
|
||||
sudo: false
|
||||
|
||||
before_script:
|
||||
- cp tests/acceptance.conf.php.default tests/acceptance.conf.php
|
||||
- cp tests/smoke.conf.php.default tests/smoke.conf.php
|
||||
- composer self-update
|
||||
- composer update --no-interaction --prefer-source
|
||||
- gem install mime-types -v 2.99.1
|
||||
- gem install mailcatcher
|
||||
- mailcatcher --smtp-port 4456
|
||||
|
||||
script: ./vendor/bin/simple-phpunit
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.3
|
||||
- php: 5.4
|
||||
- php: 5.5
|
||||
- php: 5.6
|
||||
- php: 7.0
|
||||
- php: 7.1
|
||||
- php: hhvm
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
fast_finish: true
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- .phpunit
|
||||
267
vendor/swiftmailer/swiftmailer/CHANGES
vendored
267
vendor/swiftmailer/swiftmailer/CHANGES
vendored
@@ -1,267 +0,0 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
5.4.8 (2017-05-01)
|
||||
------------------
|
||||
|
||||
* fixed encoding inheritance in addPart()
|
||||
* fixed sorting MIME children when their types are equal
|
||||
|
||||
5.4.7 (2017-04-20)
|
||||
------------------
|
||||
|
||||
* fixed NTLMAuthenticator clobbering bcmath scale
|
||||
|
||||
5.4.6 (2017-02-13)
|
||||
------------------
|
||||
|
||||
* removed exceptions thrown in destructors as they lead to fatal errors
|
||||
* switched to use sha256 by default in DKIM as per the RFC
|
||||
* fixed an 'Undefined variable: pipes' PHP notice
|
||||
* fixed long To headers when using the mail transport
|
||||
* fixed NTLMAuthenticator when no domain is passed with the username
|
||||
* prevented fatal error during unserialization of a message
|
||||
* fixed a PHP warning when sending a message that has a length of a multiple of 8192
|
||||
|
||||
5.4.5 (2016-12-29)
|
||||
------------------
|
||||
|
||||
* SECURITY FIX: fixed CVE-2016-10074 by disallowing potentially unsafe shell characters
|
||||
|
||||
Prior to 5.4.5, the mail transport (Swift_Transport_MailTransport) was vulnerable to passing
|
||||
arbitrary shell arguments if the "From", "ReturnPath" or "Sender" header came
|
||||
from a non-trusted source, potentially allowing Remote Code Execution
|
||||
* deprecated the mail transport
|
||||
|
||||
5.4.4 (2016-11-23)
|
||||
------------------
|
||||
|
||||
* reverted escaping command-line args to mail (PHP mail() function already does it)
|
||||
|
||||
5.4.3 (2016-07-08)
|
||||
------------------
|
||||
|
||||
* fixed SimpleHeaderSet::has()/get() when the 0 index is removed
|
||||
* removed the need to have mcrypt installed
|
||||
* fixed broken MIME header encoding with quotes/colons and non-ascii chars
|
||||
* allowed mail transport send for messages without To header
|
||||
* fixed PHP 7 support
|
||||
|
||||
5.4.2 (2016-05-01)
|
||||
------------------
|
||||
|
||||
* fixed support for IPv6 sockets
|
||||
* added auto-retry when sending messages from the memory spool
|
||||
* fixed consecutive read calls in Swift_ByteStream_FileByteStream
|
||||
* added support for iso-8859-15 encoding
|
||||
* fixed PHP mail extra params on missing reversePath
|
||||
* added methods to set custom stream context options
|
||||
* fixed charset changes in QpContentEncoderProxy
|
||||
* added return-path header to the ignoredHeaders list of DKIMSigner
|
||||
* fixed crlf for subject using mail
|
||||
* fixed add soft line break only when necessary
|
||||
* fixed escaping command-line args to mail
|
||||
|
||||
5.4.1 (2015-06-06)
|
||||
------------------
|
||||
|
||||
* made Swiftmailer exceptions confirm to PHP base exception constructor signature
|
||||
* fixed MAIL FROM & RCPT TO headers to be RFC compliant
|
||||
|
||||
5.4.0 (2015-03-14)
|
||||
------------------
|
||||
|
||||
* added the possibility to add extra certs to PKCS#7 signature
|
||||
* fix base64 encoding with streams
|
||||
* added a new RESULT_SPOOLED status for SpoolTransport
|
||||
* fixed getBody() on attachments when called more than once
|
||||
* removed dots from generated filenames in filespool
|
||||
|
||||
5.3.1 (2014-12-05)
|
||||
------------------
|
||||
|
||||
* fixed cloning of messages with attachments
|
||||
|
||||
5.3.0 (2014-10-04)
|
||||
------------------
|
||||
|
||||
* fixed cloning when using signers
|
||||
* reverted removal of Swift_Encoding
|
||||
* drop support for PHP 5.2.x
|
||||
|
||||
5.2.2 (2014-09-20)
|
||||
------------------
|
||||
|
||||
* fixed Japanese support
|
||||
* fixed the memory spool when the message changes when in the pool
|
||||
* added support for cloning messages
|
||||
* fixed PHP warning in the redirect plugin
|
||||
* changed the way to and cc-ed email are sent to only use one transaction
|
||||
|
||||
5.2.1 (2014-06-13)
|
||||
------------------
|
||||
|
||||
* SECURITY FIX: fixed CLI escaping when using sendmail as a transport
|
||||
|
||||
Prior to 5.2.1, the sendmail transport (Swift_Transport_SendmailTransport)
|
||||
was vulnerable to an arbitrary shell execution if the "From" header came
|
||||
from a non-trusted source and no "Return-Path" is configured.
|
||||
|
||||
* fixed parameter in DKIMSigner
|
||||
* fixed compatibility with PHP < 5.4
|
||||
|
||||
5.2.0 (2014-05-08)
|
||||
------------------
|
||||
|
||||
* fixed Swift_ByteStream_FileByteStream::read() to match to the specification
|
||||
* fixed from-charset and to-charset arguments in mbstring_convert_encoding() usages
|
||||
* fixed infinite loop in StreamBuffer
|
||||
* fixed NullTransport to return the number of ignored emails instead of 0
|
||||
* Use phpunit and mockery for unit testing (realityking)
|
||||
|
||||
5.1.0 (2014-03-18)
|
||||
------------------
|
||||
|
||||
* fixed data writing to stream when sending large messages
|
||||
* added support for libopendkim (https://github.com/xdecock/php-opendkim)
|
||||
* merged SignedMessage and Message
|
||||
* added Gmail XOAuth2 authentication
|
||||
* updated the list of known mime types
|
||||
* added NTLM authentication
|
||||
|
||||
5.0.3 (2013-12-03)
|
||||
------------------
|
||||
|
||||
* fixed double-dot bug
|
||||
* fixed DKIM signer
|
||||
|
||||
5.0.2 (2013-08-30)
|
||||
------------------
|
||||
|
||||
* handled correct exception type while reading IoBuffer output
|
||||
|
||||
5.0.1 (2013-06-17)
|
||||
------------------
|
||||
|
||||
* changed the spool to only start the transport when a mail has to be sent
|
||||
* fixed compatibility with PHP 5.2
|
||||
* fixed LICENSE file
|
||||
|
||||
5.0.0 (2013-04-30)
|
||||
------------------
|
||||
|
||||
* changed the license from LGPL to MIT
|
||||
|
||||
4.3.1 (2013-04-11)
|
||||
------------------
|
||||
|
||||
* removed usage of the native QP encoder when the charset is not UTF-8
|
||||
* fixed usage of uniqid to avoid collisions
|
||||
* made a performance improvement when tokenizing large headers
|
||||
* fixed usage of the PHP native QP encoder on PHP 5.4.7+
|
||||
|
||||
4.3.0 (2013-01-08)
|
||||
------------------
|
||||
|
||||
* made the temporary directory configurable via the TMPDIR env variable
|
||||
* added S/MIME signer and encryption support
|
||||
|
||||
4.2.2 (2012-10-25)
|
||||
------------------
|
||||
|
||||
* added the possibility to throttle messages per second in ThrottlerPlugin (mostly for Amazon SES)
|
||||
* switched mime.qpcontentencoder to automatically use the PHP native encoder on PHP 5.4.7+
|
||||
* allowed specifying a whitelist with regular expressions in RedirectingPlugin
|
||||
|
||||
4.2.1 (2012-07-13)
|
||||
------------------
|
||||
|
||||
* changed the coding standards to PSR-1/2
|
||||
* fixed issue with autoloading
|
||||
* added NativeQpContentEncoder to enhance performance (for PHP 5.3+)
|
||||
|
||||
4.2.0 (2012-06-29)
|
||||
------------------
|
||||
|
||||
* added documentation about how to use the Japanese support introduced in 4.1.8
|
||||
* added a way to override the default configuration in a lazy way
|
||||
* changed the PEAR init script to lazy-load the initialization
|
||||
* fixed a bug when calling Swift_Preferences before anything else (regression introduced in 4.1.8)
|
||||
|
||||
4.1.8 (2012-06-17)
|
||||
------------------
|
||||
|
||||
* added Japanese iso-2022-jp support
|
||||
* changed the init script to lazy-load the initialization
|
||||
* fixed docblocks (@id) which caused some problems with libraries parsing the dobclocks
|
||||
* fixed Swift_Mime_Headers_IdentificationHeader::setId() when passed an array of ids
|
||||
* fixed encoding of email addresses in headers
|
||||
* added replacements setter to the Decorator plugin
|
||||
|
||||
4.1.7 (2012-04-26)
|
||||
------------------
|
||||
|
||||
* fixed QpEncoder safeMapShareId property
|
||||
|
||||
4.1.6 (2012-03-23)
|
||||
------------------
|
||||
|
||||
* reduced the size of serialized Messages
|
||||
|
||||
4.1.5 (2012-01-04)
|
||||
------------------
|
||||
|
||||
* enforced Swift_Spool::queueMessage() to return a Boolean
|
||||
* made an optimization to the memory spool: start the transport only when required
|
||||
* prevented stream_socket_client() from generating an error and throw a Swift_TransportException instead
|
||||
* fixed a PHP warning when calling to mail() when safe_mode is off
|
||||
* many doc tweaks
|
||||
|
||||
4.1.4 (2011-12-16)
|
||||
------------------
|
||||
|
||||
* added a memory spool (Swift_MemorySpool)
|
||||
* fixed too many opened files when sending emails with attachments
|
||||
|
||||
4.1.3 (2011-10-27)
|
||||
------------------
|
||||
|
||||
* added STARTTLS support
|
||||
* added missing @return tags on fluent methods
|
||||
* added a MessageLogger plugin that logs all sent messages
|
||||
* added composer.json
|
||||
|
||||
4.1.2 (2011-09-13)
|
||||
------------------
|
||||
|
||||
* fixed wrong detection of magic_quotes_runtime
|
||||
* fixed fatal errors when no To or Subject header has been set
|
||||
* fixed charset on parameter header continuations
|
||||
* added documentation about how to install Swiftmailer from the PEAR channel
|
||||
* fixed various typos and markup problem in the documentation
|
||||
* fixed warning when cache directory does not exist
|
||||
* fixed "slashes are escaped" bug
|
||||
* changed require_once() to require() in autoload
|
||||
|
||||
4.1.1 (2011-07-04)
|
||||
------------------
|
||||
|
||||
* added missing file in PEAR package
|
||||
|
||||
4.1.0 (2011-06-30)
|
||||
------------------
|
||||
|
||||
* documentation has been converted to ReST
|
||||
|
||||
4.1.0 RC1 (2011-06-17)
|
||||
----------------------
|
||||
|
||||
New features:
|
||||
|
||||
* changed the Decorator Plugin to allow replacements in all headers
|
||||
* added Swift_Mime_Grammar and Swift_Validate to validate an email address
|
||||
* modified the autoloader to lazy-initialize Swiftmailer
|
||||
* removed Swift_Mailer::batchSend()
|
||||
* added NullTransport
|
||||
* added new plugins: RedirectingPlugin and ImpersonatePlugin
|
||||
* added a way to send messages asynchronously (Spool)
|
||||
19
vendor/swiftmailer/swiftmailer/LICENSE
vendored
19
vendor/swiftmailer/swiftmailer/LICENSE
vendored
@@ -1,19 +0,0 @@
|
||||
Copyright (c) 2013-2016 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
15
vendor/swiftmailer/swiftmailer/README
vendored
15
vendor/swiftmailer/swiftmailer/README
vendored
@@ -1,15 +0,0 @@
|
||||
Swift Mailer
|
||||
------------
|
||||
|
||||
Swift Mailer is a component based mailing solution for PHP 5.
|
||||
It is released under the MIT license.
|
||||
|
||||
Homepage: http://swiftmailer.org
|
||||
Documentation: http://swiftmailer.org/docs
|
||||
Bugs: https://github.com/swiftmailer/swiftmailer/issues
|
||||
Repository: https://github.com/swiftmailer/swiftmailer
|
||||
|
||||
Swift Mailer is highly object-oriented by design and lends itself
|
||||
to use in complex web application with a great deal of flexibility.
|
||||
|
||||
For full details on usage, see the documentation.
|
||||
1
vendor/swiftmailer/swiftmailer/VERSION
vendored
1
vendor/swiftmailer/swiftmailer/VERSION
vendored
@@ -1 +0,0 @@
|
||||
Swift-5.4.8
|
||||
37
vendor/swiftmailer/swiftmailer/composer.json
vendored
37
vendor/swiftmailer/swiftmailer/composer.json
vendored
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "swiftmailer/swiftmailer",
|
||||
"type": "library",
|
||||
"description": "Swiftmailer, free feature-rich PHP mailer",
|
||||
"keywords": ["mail","mailer","email"],
|
||||
"homepage": "http://swiftmailer.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Chris Corbyn"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~0.9.1",
|
||||
"symfony/phpunit-bridge": "~3.2"
|
||||
},
|
||||
"autoload": {
|
||||
"files": ["lib/swift_required.php"]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-0": {
|
||||
"Swift_": "tests/unit"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.4-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
742
vendor/swiftmailer/swiftmailer/doc/headers.rst
vendored
742
vendor/swiftmailer/swiftmailer/doc/headers.rst
vendored
@@ -1,742 +0,0 @@
|
||||
Message Headers
|
||||
===============
|
||||
|
||||
Sometimes you'll want to add your own headers to a message or modify/remove
|
||||
headers that are already present. You work with the message's HeaderSet to do
|
||||
this.
|
||||
|
||||
Header Basics
|
||||
-------------
|
||||
|
||||
All MIME entities in Swift Mailer -- including the message itself --
|
||||
store their headers in a single object called a HeaderSet. This HeaderSet is
|
||||
retrieved with the ``getHeaders()`` method.
|
||||
|
||||
As mentioned in the previous chapter, everything that forms a part of a message
|
||||
in Swift Mailer is a MIME entity that is represented by an instance of
|
||||
``Swift_Mime_MimeEntity``. This includes -- most notably -- the message object
|
||||
itself, attachments, MIME parts and embedded images. Each of these MIME entities
|
||||
consists of a body and a set of headers that describe the body.
|
||||
|
||||
For all of the "standard" headers in these MIME entities, such as the
|
||||
``Content-Type``, there are named methods for working with them, such as
|
||||
``setContentType()`` and ``getContentType()``. This is because headers are a
|
||||
moderately complex area of the library. Each header has a slightly different
|
||||
required structure that it must meet in order to comply with the standards that
|
||||
govern email (and that are checked by spam blockers etc).
|
||||
|
||||
You fetch the HeaderSet from a MIME entity like so:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance();
|
||||
|
||||
// Fetch the HeaderSet from a Message object
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$attachment = Swift_Attachment::fromPath('document.pdf');
|
||||
|
||||
// Fetch the HeaderSet from an attachment object
|
||||
$headers = $attachment->getHeaders();
|
||||
|
||||
The job of the HeaderSet is to contain and manage instances of Header objects.
|
||||
Depending upon the MIME entity the HeaderSet came from, the contents of the
|
||||
HeaderSet will be different, since an attachment for example has a different
|
||||
set of headers to those in a message.
|
||||
|
||||
You can find out what the HeaderSet contains with a quick loop, dumping out
|
||||
the names of the headers:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
foreach ($headers->getAll() as $header) {
|
||||
printf("%s<br />\n", $header->getFieldName());
|
||||
}
|
||||
|
||||
/*
|
||||
Content-Transfer-Encoding
|
||||
Content-Type
|
||||
MIME-Version
|
||||
Date
|
||||
Message-ID
|
||||
From
|
||||
Subject
|
||||
To
|
||||
*/
|
||||
|
||||
You can also dump out the rendered HeaderSet by calling its ``toString()``
|
||||
method:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
echo $headers->toString();
|
||||
|
||||
/*
|
||||
Message-ID: <1234869991.499a9ee7f1d5e@swift.generated>
|
||||
Date: Tue, 17 Feb 2009 22:26:31 +1100
|
||||
Subject: Awesome subject!
|
||||
From: sender@example.org
|
||||
To: recipient@example.org
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=utf-8
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
*/
|
||||
|
||||
Where the complexity comes in is when you want to modify an existing header.
|
||||
This complexity comes from the fact that each header can be of a slightly
|
||||
different type (such as a Date header, or a header that contains email
|
||||
addresses, or a header that has key-value parameters on it!). Each header in the
|
||||
HeaderSet is an instance of ``Swift_Mime_Header``. They all have common
|
||||
functionality, but knowing exactly what type of header you're working with will
|
||||
allow you a little more control.
|
||||
|
||||
You can determine the type of header by comparing the return value of its
|
||||
``getFieldType()`` method with the constants ``TYPE_TEXT``,
|
||||
``TYPE_PARAMETERIZED``, ``TYPE_DATE``, ``TYPE_MAILBOX``, ``TYPE_ID`` and
|
||||
``TYPE_PATH`` which are defined in ``Swift_Mime_Header``.
|
||||
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
foreach ($headers->getAll() as $header) {
|
||||
switch ($header->getFieldType()) {
|
||||
case Swift_Mime_Header::TYPE_TEXT: $type = 'text';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_PARAMETERIZED: $type = 'parameterized';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_MAILBOX: $type = 'mailbox';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_DATE: $type = 'date';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_ID: $type = 'ID';
|
||||
break;
|
||||
case Swift_Mime_Header::TYPE_PATH: $type = 'path';
|
||||
break;
|
||||
}
|
||||
printf("%s: is a %s header<br />\n", $header->getFieldName(), $type);
|
||||
}
|
||||
|
||||
/*
|
||||
Content-Transfer-Encoding: is a text header
|
||||
Content-Type: is a parameterized header
|
||||
MIME-Version: is a text header
|
||||
Date: is a date header
|
||||
Message-ID: is a ID header
|
||||
From: is a mailbox header
|
||||
Subject: is a text header
|
||||
To: is a mailbox header
|
||||
*/
|
||||
|
||||
Headers can be removed from the set, modified within the set, or added to the
|
||||
set.
|
||||
|
||||
The following sections show you how to work with the HeaderSet and explain the
|
||||
details of each implementation of ``Swift_Mime_Header`` that may
|
||||
exist within the HeaderSet.
|
||||
|
||||
Header Types
|
||||
------------
|
||||
|
||||
Because all headers are modeled on different data (dates, addresses, text!)
|
||||
there are different types of Header in Swift Mailer. Swift Mailer attempts to
|
||||
categorize all possible MIME headers into more general groups, defined by a
|
||||
small number of classes.
|
||||
|
||||
Text Headers
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Text headers are the simplest type of Header. They contain textual information
|
||||
with no special information included within it -- for example the Subject
|
||||
header in a message.
|
||||
|
||||
There's nothing particularly interesting about a text header, though it is
|
||||
probably the one you'd opt to use if you need to add a custom header to a
|
||||
message. It represents text just like you'd think it does. If the text
|
||||
contains characters that are not permitted in a message header (such as new
|
||||
lines, or non-ascii characters) then the header takes care of encoding the
|
||||
text so that it can be used.
|
||||
|
||||
No header -- including text headers -- in Swift Mailer is vulnerable to
|
||||
header-injection attacks. Swift Mailer breaks any attempt at header injection by
|
||||
encoding the dangerous data into a non-dangerous form.
|
||||
|
||||
It's easy to add a new text header to a HeaderSet. You do this by calling the
|
||||
HeaderSet's ``addTextHeader()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance();
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$headers->addTextHeader('Your-Header-Name', 'the header value');
|
||||
|
||||
Changing the value of an existing text header is done by calling it's
|
||||
``setValue()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$subject = $message->getHeaders()->get('Subject');
|
||||
|
||||
$subject->setValue('new subject');
|
||||
|
||||
When output via ``toString()``, a text header produces something like the
|
||||
following:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$subject = $message->getHeaders()->get('Subject');
|
||||
|
||||
$subject->setValue('amazing subject line');
|
||||
|
||||
echo $subject->toString();
|
||||
|
||||
/*
|
||||
|
||||
Subject: amazing subject line
|
||||
|
||||
*/
|
||||
|
||||
If the header contains any characters that are outside of the US-ASCII range
|
||||
however, they will be encoded. This is nothing to be concerned about since
|
||||
mail clients will decode them back.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$subject = $message->getHeaders()->get('Subject');
|
||||
|
||||
$subject->setValue('contains – dash');
|
||||
|
||||
echo $subject->toString();
|
||||
|
||||
/*
|
||||
|
||||
Subject: contains =?utf-8?Q?=E2=80=93?= dash
|
||||
|
||||
*/
|
||||
|
||||
Parameterized Headers
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Parameterized headers are text headers that contain key-value parameters
|
||||
following the textual content. The Content-Type header of a message is a
|
||||
parameterized header since it contains charset information after the content
|
||||
type.
|
||||
|
||||
The parameterized header type is a special type of text header. It extends the
|
||||
text header by allowing additional information to follow it. All of the methods
|
||||
from text headers are available in addition to the methods described here.
|
||||
|
||||
Adding a parameterized header to a HeaderSet is done by using the
|
||||
``addParameterizedHeader()`` method which takes a text value like
|
||||
``addTextHeader()`` but it also accepts an associative array of
|
||||
key-value parameters.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance();
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$headers->addParameterizedHeader(
|
||||
'Header-Name', 'header value',
|
||||
array('foo' => 'bar')
|
||||
);
|
||||
|
||||
To change the text value of the header, call it's ``setValue()`` method just as
|
||||
you do with text headers.
|
||||
|
||||
To change the parameters in the header, call the header's ``setParameters()``
|
||||
method or the ``setParameter()`` method (note the pluralization).
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$type = $message->getHeaders()->get('Content-Type');
|
||||
|
||||
// setParameters() takes an associative array
|
||||
$type->setParameters(array(
|
||||
'name' => 'file.txt',
|
||||
'charset' => 'iso-8859-1'
|
||||
));
|
||||
|
||||
// setParameter() takes two args for $key and $value
|
||||
$type->setParameter('charset', 'iso-8859-1');
|
||||
|
||||
When output via ``toString()``, a parameterized header produces something like
|
||||
the following:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$type = $message->getHeaders()->get('Content-Type');
|
||||
|
||||
$type->setValue('text/html');
|
||||
$type->setParameter('charset', 'utf-8');
|
||||
|
||||
echo $type->toString();
|
||||
|
||||
/*
|
||||
|
||||
Content-Type: text/html; charset=utf-8
|
||||
|
||||
*/
|
||||
|
||||
If the header contains any characters that are outside of the US-ASCII range
|
||||
however, they will be encoded, just like they are for text headers. This is
|
||||
nothing to be concerned about since mail clients will decode them back.
|
||||
Likewise, if the parameters contain any non-ascii characters they will be
|
||||
encoded so that they can be transmitted safely.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$attachment = Swift_Attachment::newInstance();
|
||||
|
||||
$disp = $attachment->getHeaders()->get('Content-Disposition');
|
||||
|
||||
$disp->setValue('attachment');
|
||||
$disp->setParameter('filename', 'report–may.pdf');
|
||||
|
||||
echo $disp->toString();
|
||||
|
||||
/*
|
||||
|
||||
Content-Disposition: attachment; filename*=utf-8''report%E2%80%93may.pdf
|
||||
|
||||
*/
|
||||
|
||||
Date Headers
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Date headers contains an RFC 2822 formatted date (i.e. what PHP's ``date('r')``
|
||||
returns). They are used anywhere a date or time is needed to be presented as a
|
||||
message header.
|
||||
|
||||
The data on which a date header is modeled is simply a UNIX timestamp such as
|
||||
that returned by ``time()`` or ``strtotime()``. The timestamp is used to create
|
||||
a correctly structured RFC 2822 formatted date such as
|
||||
``Tue, 17 Feb 2009 22:26:31 +1100``.
|
||||
|
||||
The obvious place this header type is used is in the ``Date:`` header of the
|
||||
message itself.
|
||||
|
||||
It's easy to add a new date header to a HeaderSet. You do this by calling
|
||||
the HeaderSet's ``addDateHeader()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance();
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$headers->addDateHeader('Your-Header-Name', strtotime('3 days ago'));
|
||||
|
||||
Changing the value of an existing date header is done by calling it's
|
||||
``setTimestamp()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$date = $message->getHeaders()->get('Date');
|
||||
|
||||
$date->setTimestamp(time());
|
||||
|
||||
When output via ``toString()``, a date header produces something like the
|
||||
following:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$date = $message->getHeaders()->get('Date');
|
||||
|
||||
echo $date->toString();
|
||||
|
||||
/*
|
||||
|
||||
Date: Wed, 18 Feb 2009 13:35:02 +1100
|
||||
|
||||
*/
|
||||
|
||||
Mailbox (e-mail address) Headers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Mailbox headers contain one or more email addresses, possibly with
|
||||
personalized names attached to them. The data on which they are modeled is
|
||||
represented by an associative array of email addresses and names.
|
||||
|
||||
Mailbox headers are probably the most complex header type to understand in
|
||||
Swift Mailer because they accept their input as an array which can take various
|
||||
forms, as described in the previous chapter.
|
||||
|
||||
All of the headers that contain e-mail addresses in a message -- with the
|
||||
exception of ``Return-Path:`` which has a stricter syntax -- use this header
|
||||
type. That is, ``To:``, ``From:`` etc.
|
||||
|
||||
You add a new mailbox header to a HeaderSet by calling the HeaderSet's
|
||||
``addMailboxHeader()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance();
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$headers->addMailboxHeader('Your-Header-Name', array(
|
||||
'person1@example.org' => 'Person Name One',
|
||||
'person2@example.org',
|
||||
'person3@example.org',
|
||||
'person4@example.org' => 'Another named person'
|
||||
));
|
||||
|
||||
Changing the value of an existing mailbox header is done by calling it's
|
||||
``setNameAddresses()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
|
||||
$to->setNameAddresses(array(
|
||||
'joe@example.org' => 'Joe Bloggs',
|
||||
'john@example.org' => 'John Doe',
|
||||
'no-name@example.org'
|
||||
));
|
||||
|
||||
If you don't wish to concern yourself with the complicated accepted input
|
||||
formats accepted by ``setNameAddresses()`` as described in the previous chapter
|
||||
and you only want to set one or more addresses (not names) then you can just
|
||||
use the ``setAddresses()`` method instead.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
|
||||
$to->setAddresses(array(
|
||||
'joe@example.org',
|
||||
'john@example.org',
|
||||
'no-name@example.org'
|
||||
));
|
||||
|
||||
.. note::
|
||||
|
||||
Both methods will accept the above input format in practice.
|
||||
|
||||
If all you want to do is set a single address in the header, you can use a
|
||||
string as the input parameter to ``setAddresses()`` and/or
|
||||
``setNameAddresses()``.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
|
||||
$to->setAddresses('joe-bloggs@example.org');
|
||||
|
||||
When output via ``toString()``, a mailbox header produces something like the
|
||||
following:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$to = $message->getHeaders()->get('To');
|
||||
|
||||
$to->setNameAddresses(array(
|
||||
'person1@example.org' => 'Name of Person',
|
||||
'person2@example.org',
|
||||
'person3@example.org' => 'Another Person'
|
||||
));
|
||||
|
||||
echo $to->toString();
|
||||
|
||||
/*
|
||||
|
||||
To: Name of Person <person1@example.org>, person2@example.org, Another Person
|
||||
<person3@example.org>
|
||||
|
||||
*/
|
||||
|
||||
ID Headers
|
||||
~~~~~~~~~~
|
||||
|
||||
ID headers contain identifiers for the entity (or the message). The most
|
||||
notable ID header is the Message-ID header on the message itself.
|
||||
|
||||
An ID that exists inside an ID header looks more-or-less less like an email
|
||||
address. For example, ``<1234955437.499becad62ec2@example.org>``.
|
||||
The part to the left of the @ sign is usually unique, based on the current time
|
||||
and some random factor. The part on the right is usually a domain name.
|
||||
|
||||
Any ID passed to the header's ``setId()`` method absolutely MUST conform to
|
||||
this structure, otherwise you'll get an Exception thrown at you by Swift Mailer
|
||||
(a ``Swift_RfcComplianceException``). This is to ensure that the generated
|
||||
email complies with relevant RFC documents and therefore is less likely to be
|
||||
blocked as spam.
|
||||
|
||||
It's easy to add a new ID header to a HeaderSet. You do this by calling
|
||||
the HeaderSet's ``addIdHeader()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance();
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$headers->addIdHeader('Your-Header-Name', '123456.unqiue@example.org');
|
||||
|
||||
Changing the value of an existing date header is done by calling its
|
||||
``setId()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$msgId = $message->getHeaders()->get('Message-ID');
|
||||
|
||||
$msgId->setId(time() . '.' . uniqid('thing') . '@example.org');
|
||||
|
||||
When output via ``toString()``, an ID header produces something like the
|
||||
following:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$msgId = $message->getHeaders()->get('Message-ID');
|
||||
|
||||
echo $msgId->toString();
|
||||
|
||||
/*
|
||||
|
||||
Message-ID: <1234955437.499becad62ec2@example.org>
|
||||
|
||||
*/
|
||||
|
||||
Path Headers
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Path headers are like very-restricted mailbox headers. They contain a single
|
||||
email address with no associated name. The Return-Path header of a message is
|
||||
a path header.
|
||||
|
||||
You add a new path header to a HeaderSet by calling the HeaderSet's
|
||||
``addPathHeader()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance();
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
$headers->addPathHeader('Your-Header-Name', 'person@example.org');
|
||||
|
||||
|
||||
Changing the value of an existing path header is done by calling its
|
||||
``setAddress()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$return = $message->getHeaders()->get('Return-Path');
|
||||
|
||||
$return->setAddress('my-address@example.org');
|
||||
|
||||
When output via ``toString()``, a path header produces something like the
|
||||
following:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$return = $message->getHeaders()->get('Return-Path');
|
||||
|
||||
$return->setAddress('person@example.org');
|
||||
|
||||
echo $return->toString();
|
||||
|
||||
/*
|
||||
|
||||
Return-Path: <person@example.org>
|
||||
|
||||
*/
|
||||
|
||||
Header Operations
|
||||
-----------------
|
||||
|
||||
Working with the headers in a message involves knowing how to use the methods
|
||||
on the HeaderSet and on the individual Headers within the HeaderSet.
|
||||
|
||||
Adding new Headers
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
New headers can be added to the HeaderSet by using one of the provided
|
||||
``add..Header()`` methods.
|
||||
|
||||
To add a header to a MIME entity (such as the message):
|
||||
|
||||
Get the HeaderSet from the entity by via its ``getHeaders()`` method.
|
||||
|
||||
* Add the header to the HeaderSet by calling one of the ``add..Header()``
|
||||
methods.
|
||||
|
||||
The added header will appear in the message when it is sent.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// Adding a custom header to a message
|
||||
$message = Swift_Message::newInstance();
|
||||
$headers = $message->getHeaders();
|
||||
$headers->addTextHeader('X-Mine', 'something here');
|
||||
|
||||
// Adding a custom header to an attachment
|
||||
$attachment = Swift_Attachment::fromPath('/path/to/doc.pdf');
|
||||
$attachment->getHeaders()->addDateHeader('X-Created-Time', time());
|
||||
|
||||
Retrieving Headers
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Headers are retrieved through the HeaderSet's ``get()`` and ``getAll()``
|
||||
methods.
|
||||
|
||||
To get a header, or several headers from a MIME entity:
|
||||
|
||||
* Get the HeaderSet from the entity by via its ``getHeaders()`` method.
|
||||
|
||||
* Get the header(s) from the HeaderSet by calling either ``get()`` or
|
||||
``getAll()``.
|
||||
|
||||
When using ``get()`` a single header is returned that matches the name (case
|
||||
insensitive) that is passed to it. When using ``getAll()`` with a header name,
|
||||
an array of headers with that name are returned. Calling ``getAll()`` with no
|
||||
arguments returns an array of all headers present in the entity.
|
||||
|
||||
.. note::
|
||||
|
||||
It's valid for some headers to appear more than once in a message (e.g.
|
||||
the Received header). For this reason ``getAll()`` exists to fetch all
|
||||
headers with a specified name. In addition, ``get()`` accepts an optional
|
||||
numerical index, starting from zero to specify which header you want more
|
||||
specifically.
|
||||
|
||||
.. note::
|
||||
|
||||
If you want to modify the contents of the header and you don't know for
|
||||
sure what type of header it is then you may need to check the type by
|
||||
calling its ``getFieldType()`` method.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Get the To: header
|
||||
$toHeader = $headers->get('To');
|
||||
|
||||
// Get all headers named "X-Foo"
|
||||
$fooHeaders = $headers->getAll('X-Foo');
|
||||
|
||||
// Get the second header named "X-Foo"
|
||||
$foo = $headers->get('X-Foo', 1);
|
||||
|
||||
// Get all headers that are present
|
||||
$all = $headers->getAll();
|
||||
|
||||
Check if a Header Exists
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can check if a named header is present in a HeaderSet by calling its
|
||||
``has()`` method.
|
||||
|
||||
To check if a header exists:
|
||||
|
||||
* Get the HeaderSet from the entity by via its ``getHeaders()`` method.
|
||||
|
||||
* Call the HeaderSet's ``has()`` method specifying the header you're looking
|
||||
for.
|
||||
|
||||
If the header exists, ``true`` will be returned or ``false`` if not.
|
||||
|
||||
.. note::
|
||||
|
||||
It's valid for some headers to appear more than once in a message (e.g.
|
||||
the Received header). For this reason ``has()`` accepts an optional
|
||||
numerical index, starting from zero to specify which header you want to
|
||||
check more specifically.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Check if the To: header exists
|
||||
if ($headers->has('To')) {
|
||||
echo 'To: exists';
|
||||
}
|
||||
|
||||
// Check if an X-Foo header exists twice (i.e. check for the 2nd one)
|
||||
if ($headers->has('X-Foo', 1)) {
|
||||
echo 'Second X-Foo header exists';
|
||||
}
|
||||
|
||||
Removing Headers
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Removing a Header from the HeaderSet is done by calling the HeaderSet's
|
||||
``remove()`` or ``removeAll()`` methods.
|
||||
|
||||
To remove an existing header:
|
||||
|
||||
* Get the HeaderSet from the entity by via its ``getHeaders()`` method.
|
||||
|
||||
* Call the HeaderSet's ``remove()`` or ``removeAll()`` methods specifying the
|
||||
header you want to remove.
|
||||
|
||||
When calling ``remove()`` a single header will be removed. When calling
|
||||
``removeAll()`` all headers with the given name will be removed. If no headers
|
||||
exist with the given name, no errors will occur.
|
||||
|
||||
.. note::
|
||||
|
||||
It's valid for some headers to appear more than once in a message (e.g.
|
||||
the Received header). For this reason ``remove()`` accepts an optional
|
||||
numerical index, starting from zero to specify which header you want to
|
||||
check more specifically. For the same reason, ``removeAll()`` exists to
|
||||
remove all headers that have the given name.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Remove the Subject: header
|
||||
$headers->remove('Subject');
|
||||
|
||||
// Remove all X-Foo headers
|
||||
$headers->removeAll('X-Foo');
|
||||
|
||||
// Remove only the second X-Foo header
|
||||
$headers->remove('X-Foo', 1);
|
||||
|
||||
Modifying a Header's Content
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To change a Header's content you should know what type of header it is and then
|
||||
call it's appropriate setter method. All headers also have a
|
||||
``setFieldBodyModel()`` method that accepts a mixed parameter and delegates to
|
||||
the correct setter.
|
||||
|
||||
To modify an existing header:
|
||||
|
||||
* Get the HeaderSet from the entity by via its ``getHeaders()`` method.
|
||||
|
||||
* Get the Header by using the HeaderSet's ``get()``.
|
||||
|
||||
* Call the Header's appropriate setter method or call the header's
|
||||
``setFieldBodyModel()`` method.
|
||||
|
||||
The header will be updated inside the HeaderSet and the changes will be seen
|
||||
when the message is sent.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$headers = $message->getHeaders();
|
||||
|
||||
// Change the Subject: header
|
||||
$subj = $headers->get('Subject');
|
||||
$subj->setValue('new subject here');
|
||||
|
||||
// Change the To: header
|
||||
$to = $headers->get('To');
|
||||
$to->setNameAddresses(array(
|
||||
'person@example.org' => 'Person',
|
||||
'thing@example.org'
|
||||
));
|
||||
|
||||
// Using the setFieldBodyModel() just delegates to the correct method
|
||||
// So here to calls setNameAddresses()
|
||||
$to->setFieldBodyModel(array(
|
||||
'person@example.org' => 'Person',
|
||||
'thing@example.org'
|
||||
));
|
||||
@@ -1,44 +0,0 @@
|
||||
Getting Help
|
||||
============
|
||||
|
||||
There are a number of ways you can get help when using Swift Mailer, depending
|
||||
upon the nature of your problem. For bug reports and feature requests create a
|
||||
new ticket in GitHub. For general advice ask on the Google Group
|
||||
(swiftmailer).
|
||||
|
||||
Submitting Bugs & Feature Requests
|
||||
----------------------------------
|
||||
|
||||
Bugs and feature requests should be posted on GitHub.
|
||||
|
||||
If you post a bug or request a feature in the forum, or on the Google Group
|
||||
you will most likely be asked to create a ticket in `GitHub`_ since it is
|
||||
simply not feasible to manage such requests from a number of a different
|
||||
sources.
|
||||
|
||||
When you go to GitHub you will be asked to create a username and password
|
||||
before you can create a ticket. This is free and takes very little time.
|
||||
|
||||
When you create your ticket, do not assign it to any milestones. A developer
|
||||
will assess your ticket and re-assign it as needed.
|
||||
|
||||
If your ticket is reporting a bug present in the current version, which was
|
||||
not present in the previous version please include the tag "regression" in
|
||||
your ticket.
|
||||
|
||||
GitHub will update you when work is performed on your ticket.
|
||||
|
||||
Ask on the Google Group
|
||||
-----------------------
|
||||
|
||||
You can seek advice at Google Groups, within the "swiftmailer" `group`_.
|
||||
|
||||
You can post messages to this group if you want help, or there's something you
|
||||
wish to discuss with the developers and with other users.
|
||||
|
||||
This is probably the fastest way to get help since it is primarily email-based
|
||||
for most users, though bug reports should not be posted here since they may
|
||||
not be resolved.
|
||||
|
||||
.. _`GitHub`: https://github.com/swiftmailer/swiftmailer/issues
|
||||
.. _`group`: http://groups.google.com/group/swiftmailer
|
||||
@@ -1,46 +0,0 @@
|
||||
Including Swift Mailer (Autoloading)
|
||||
====================================
|
||||
|
||||
If you are using Composer, Swift Mailer will be automatically autoloaded.
|
||||
|
||||
If not, you can use the built-in autoloader by requiring the
|
||||
``swift_required.php`` file::
|
||||
|
||||
require_once '/path/to/swift-mailer/lib/swift_required.php';
|
||||
|
||||
/* rest of code goes here */
|
||||
|
||||
If you want to override the default Swift Mailer configuration, call the
|
||||
``init()`` method on the ``Swift`` class and pass it a valid PHP callable (a
|
||||
PHP function name, a PHP 5.3 anonymous function, ...)::
|
||||
|
||||
require_once '/path/to/swift-mailer/lib/swift_required.php';
|
||||
|
||||
function swiftmailer_configurator() {
|
||||
// configure Swift Mailer
|
||||
|
||||
Swift_DependencyContainer::getInstance()->...
|
||||
Swift_Preferences::getInstance()->...
|
||||
}
|
||||
|
||||
Swift::init('swiftmailer_configurator');
|
||||
|
||||
/* rest of code goes here */
|
||||
|
||||
The advantage of using the ``init()`` method is that your code will be
|
||||
executed only if you use Swift Mailer in your script.
|
||||
|
||||
.. note::
|
||||
|
||||
While Swift Mailer's autoloader is designed to play nicely with other
|
||||
autoloaders, sometimes you may have a need to avoid using Swift Mailer's
|
||||
autoloader and use your own instead. Include the ``swift_init.php``
|
||||
instead of the ``swift_required.php`` if you need to do this. The very
|
||||
minimum include is the ``swift_init.php`` file since Swift Mailer will not
|
||||
work without the dependency injection this file sets up:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once '/path/to/swift-mailer/lib/swift_init.php';
|
||||
|
||||
/* rest of code goes here */
|
||||
16
vendor/swiftmailer/swiftmailer/doc/index.rst
vendored
16
vendor/swiftmailer/swiftmailer/doc/index.rst
vendored
@@ -1,16 +0,0 @@
|
||||
Swiftmailer
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
introduction
|
||||
overview
|
||||
installing
|
||||
help-resources
|
||||
including-the-files
|
||||
messages
|
||||
headers
|
||||
sending
|
||||
plugins
|
||||
japanese
|
||||
@@ -1,89 +0,0 @@
|
||||
Installing the Library
|
||||
======================
|
||||
|
||||
Installing with Composer
|
||||
------------------------
|
||||
|
||||
The recommended way to install Swiftmailer is via Composer:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ php composer.phar require swiftmailer/swiftmailer @stable
|
||||
|
||||
Installing from Git
|
||||
-------------------
|
||||
|
||||
It's possible to download and install Swift Mailer directly from github.com if
|
||||
you want to keep up-to-date with ease.
|
||||
|
||||
Swift Mailer's source code is kept in a git repository at github.com so you
|
||||
can get the source directly from the repository.
|
||||
|
||||
.. note::
|
||||
|
||||
You do not need to have git installed to use Swift Mailer from GitHub. If
|
||||
you don't have git installed, go to `GitHub`_ and click the "Download"
|
||||
button.
|
||||
|
||||
Cloning the Repository
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The repository can be cloned from git://github.com/swiftmailer/swiftmailer.git
|
||||
using the ``git clone`` command.
|
||||
|
||||
You will need to have ``git`` installed before you can use the
|
||||
``git clone`` command.
|
||||
|
||||
To clone the repository:
|
||||
|
||||
* Open your favorite terminal environment (command line).
|
||||
|
||||
* Move to the directory you want to clone to.
|
||||
|
||||
* Run the command ``git clone git://github.com/swiftmailer/swiftmailer.git
|
||||
swiftmailer``.
|
||||
|
||||
The source code will be downloaded into a directory called "swiftmailer".
|
||||
|
||||
The example shows the process on a UNIX-like system such as Linux, BSD or Mac
|
||||
OS X.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ cd source_code/
|
||||
$ git clone git://github.com/swiftmailer/swiftmailer.git swiftmailer
|
||||
Initialized empty Git repository in /Users/chris/source_code/swiftmailer/.git/
|
||||
remote: Counting objects: 6815, done.
|
||||
remote: Compressing objects: 100% (2761/2761), done.
|
||||
remote: Total 6815 (delta 3641), reused 6326 (delta 3286)
|
||||
Receiving objects: 100% (6815/6815), 4.35 MiB | 162 KiB/s, done.
|
||||
Resolving deltas: 100% (3641/3641), done.
|
||||
Checking out files: 100% (1847/1847), done.
|
||||
$ cd swiftmailer/
|
||||
$ ls
|
||||
CHANGES LICENSE ...
|
||||
$
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
Swift Mailer does not work when used with function overloading as implemented
|
||||
by ``mbstring`` (``mbstring.func_overload`` set to ``2``). A workaround is to
|
||||
temporarily change the internal encoding to ``ASCII`` when sending an email:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2)
|
||||
{
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('ASCII');
|
||||
}
|
||||
|
||||
// Create your message and send it with Swift Mailer
|
||||
|
||||
if (isset($mbEncoding))
|
||||
{
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
|
||||
.. _`GitHub`: http://github.com/swiftmailer/swiftmailer
|
||||
135
vendor/swiftmailer/swiftmailer/doc/introduction.rst
vendored
135
vendor/swiftmailer/swiftmailer/doc/introduction.rst
vendored
@@ -1,135 +0,0 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
Swift Mailer is a component-based library for sending e-mails from PHP
|
||||
applications.
|
||||
|
||||
Organization of this Book
|
||||
-------------------------
|
||||
|
||||
This book has been written so that those who need information quickly are able
|
||||
to find what they need, and those who wish to learn more advanced topics can
|
||||
read deeper into each chapter.
|
||||
|
||||
The book begins with an overview of Swift Mailer, discussing what's included
|
||||
in the package and preparing you for the remainder of the book.
|
||||
|
||||
It is possible to read this user guide just like any other book (from
|
||||
beginning to end). Each chapter begins with a discussion of the contents it
|
||||
contains, followed by a short code sample designed to give you a head start.
|
||||
As you get further into a chapter you will learn more about Swift Mailer's
|
||||
capabilities, but often you will be able to head directly to the topic you
|
||||
wish to learn about.
|
||||
|
||||
Throughout this book you will be presented with code samples, which most
|
||||
people should find ample to implement Swift Mailer appropriately in their own
|
||||
projects. We will also use diagrams where appropriate, and where we believe
|
||||
readers may find it helpful we will discuss some related theory, including
|
||||
reference to certain documents you are able to find online.
|
||||
|
||||
Code Samples
|
||||
------------
|
||||
|
||||
Code samples presented in this book will be displayed on a different colored
|
||||
background in a monospaced font. Samples are not to be taken as copy & paste
|
||||
code snippets.
|
||||
|
||||
Code examples are used through the book to clarify what is written in text.
|
||||
They will sometimes be usable as-is, but they should always be taken as
|
||||
outline/pseudo code only.
|
||||
|
||||
A code sample will look like this::
|
||||
|
||||
class AClass
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
// A Comment
|
||||
$obj = new AClass($arg1, $arg2, ... );
|
||||
|
||||
/* A note about another way of doing something
|
||||
$obj = AClass::newInstance($arg1, $arg2, ... );
|
||||
|
||||
*/
|
||||
|
||||
The presence of 3 dots ``...`` in a code sample indicates that we have left
|
||||
out a chunk of the code for brevity, they are not actually part of the code.
|
||||
|
||||
We will often place multi-line comments ``/* ... */`` in the code so that we
|
||||
can show alternative ways of achieving the same result.
|
||||
|
||||
You should read the code examples given and try to understand them. They are
|
||||
kept concise so that you are not overwhelmed with information.
|
||||
|
||||
History of Swift Mailer
|
||||
-----------------------
|
||||
|
||||
Swift Mailer began back in 2005 as a one-class project for sending mail over
|
||||
SMTP. It has since grown into the flexible component-based library that is in
|
||||
development today.
|
||||
|
||||
Chris Corbyn first posted Swift Mailer on a web forum asking for comments from
|
||||
other developers. It was never intended as a fully supported open source
|
||||
project, but members of the forum began to adopt it and make use of it.
|
||||
|
||||
Very quickly feature requests were coming for the ability to add attachments
|
||||
and use SMTP authentication, along with a number of other "obvious" missing
|
||||
features. Considering the only alternative was PHPMailer it seemed like a good
|
||||
time to bring some fresh tools to the table. Chris began working towards a
|
||||
more component based, PHP5-like approach unlike the existing single-class,
|
||||
legacy PHP4 approach taken by PHPMailer.
|
||||
|
||||
Members of the forum offered a lot of advice and critique on the code as he
|
||||
worked through this project and released versions 2 and 3 of the library in
|
||||
2005 and 2006, which by then had been broken down into smaller classes
|
||||
offering more flexibility and supporting plugins. To this day the Swift Mailer
|
||||
team still receive a lot of feature requests from users both on the forum and
|
||||
in by email.
|
||||
|
||||
Until 2008 Chris was the sole developer of Swift Mailer, but entering 2009 he
|
||||
gained the support of two experienced developers well-known to him: Paul
|
||||
Annesley and Christopher Thompson. This has been an extremely welcome change.
|
||||
|
||||
As of September 2009, Chris handed over the maintenance of Swift Mailer to
|
||||
Fabien Potencier.
|
||||
|
||||
Now 2009 and in its fourth major version Swift Mailer is more object-oriented
|
||||
and flexible than ever, both from a usability standpoint and from a
|
||||
development standpoint.
|
||||
|
||||
By no means is Swift Mailer ready to call "finished". There are still many
|
||||
features that can be added to the library along with the constant refactoring
|
||||
that happens behind the scenes.
|
||||
|
||||
It's a Library!
|
||||
---------------
|
||||
|
||||
Swift Mailer is not an application - it's a library.
|
||||
|
||||
To most experienced developers this is probably an obvious point to make, but
|
||||
it's certainly worth mentioning. Many people often contact us having gotten
|
||||
the completely wrong end of the stick in terms of what Swift Mailer is
|
||||
actually for.
|
||||
|
||||
It's not an application. It does not have a graphical user interface. It
|
||||
cannot be opened in your web browser directly.
|
||||
|
||||
It's a library (or a framework if you like). It provides a whole lot of
|
||||
classes that do some very complicated things, so that you don't have to. You
|
||||
"use" Swift Mailer within an application so that your application can have the
|
||||
ability to send emails.
|
||||
|
||||
The component-based structure of the library means that you are free to
|
||||
implement it in a number of different ways and that you can pick and choose
|
||||
what you want to use.
|
||||
|
||||
An application on the other hand (such as a blog or a forum) is already "put
|
||||
together" in a particular way, (usually) provides a graphical user interface
|
||||
and most likely doesn't offer a great deal of integration with your own
|
||||
application.
|
||||
|
||||
Embrace the structure of the library and use the components it offers to your
|
||||
advantage. Learning what the components do, rather than blindly copying and
|
||||
pasting existing code will put you in a great position to build a powerful
|
||||
application!
|
||||
22
vendor/swiftmailer/swiftmailer/doc/japanese.rst
vendored
22
vendor/swiftmailer/swiftmailer/doc/japanese.rst
vendored
@@ -1,22 +0,0 @@
|
||||
Using Swift Mailer for Japanese Emails
|
||||
======================================
|
||||
|
||||
To send emails in Japanese, you need to tweak the default configuration.
|
||||
|
||||
After requiring the Swift Mailer autoloader (by including the
|
||||
``swift_required.php`` file), call the ``Swift::init()`` method with the
|
||||
following code::
|
||||
|
||||
require_once '/path/to/swift-mailer/lib/swift_required.php';
|
||||
|
||||
Swift::init(function () {
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->register('mime.qpheaderencoder')
|
||||
->asAliasOf('mime.base64headerencoder');
|
||||
|
||||
Swift_Preferences::getInstance()->setCharset('iso-2022-jp');
|
||||
});
|
||||
|
||||
/* rest of code goes here */
|
||||
|
||||
That's all!
|
||||
1061
vendor/swiftmailer/swiftmailer/doc/messages.rst
vendored
1061
vendor/swiftmailer/swiftmailer/doc/messages.rst
vendored
File diff suppressed because it is too large
Load Diff
159
vendor/swiftmailer/swiftmailer/doc/overview.rst
vendored
159
vendor/swiftmailer/swiftmailer/doc/overview.rst
vendored
@@ -1,159 +0,0 @@
|
||||
Library Overview
|
||||
================
|
||||
|
||||
Most features (and more) of your every day mail client software are provided
|
||||
by Swift Mailer, using object-oriented PHP code as the interface.
|
||||
|
||||
In this chapter we will take a short tour of the various components, which put
|
||||
together form the Swift Mailer library as a whole. You will learn key
|
||||
terminology used throughout the rest of this book and you will gain a little
|
||||
understanding of the classes you will work with as you integrate Swift Mailer
|
||||
into your application.
|
||||
|
||||
This chapter is intended to prepare you for the information contained in the
|
||||
subsequent chapters of this book. You may choose to skip this chapter if you
|
||||
are fairly technically minded, though it is likely to save you some time in
|
||||
the long run if you at least read between the lines here.
|
||||
|
||||
System Requirements
|
||||
-------------------
|
||||
|
||||
The basic requirements to operate Swift Mailer are extremely minimal and
|
||||
easily achieved. Historically, Swift Mailer has supported both PHP 4 and PHP 5
|
||||
by following a parallel development workflow. Now in it's fourth major
|
||||
version, and Swift Mailer operates on servers running PHP 5.3.3 or higher.
|
||||
|
||||
The library aims to work with as many PHP 5 projects as possible:
|
||||
|
||||
* PHP 5.3.3 or higher, with the SPL extension (standard)
|
||||
|
||||
* Limited network access to connect to remote SMTP servers
|
||||
|
||||
* 8 MB or more memory limit (Swift Mailer uses around 2 MB)
|
||||
|
||||
Component Breakdown
|
||||
-------------------
|
||||
|
||||
Swift Mailer is made up of many classes. Each of these classes can be grouped
|
||||
into a general "component" group which describes the task it is designed to
|
||||
perform.
|
||||
|
||||
We'll take a brief look at the components which form Swift Mailer in this
|
||||
section of the book.
|
||||
|
||||
The Mailer
|
||||
~~~~~~~~~~
|
||||
|
||||
The mailer class, ``Swift_Mailer`` is the central class in the library where
|
||||
all of the other components meet one another. ``Swift_Mailer`` acts as a sort
|
||||
of message dispatcher, communicating with the underlying Transport to deliver
|
||||
your Message to all intended recipients.
|
||||
|
||||
If you were to dig around in the source code for Swift Mailer you'd notice
|
||||
that ``Swift_Mailer`` itself is pretty bare. It delegates to other objects for
|
||||
most tasks and in theory, if you knew the internals of Swift Mailer well you
|
||||
could by-pass this class entirely. We wouldn't advise doing such a thing
|
||||
however -- there are reasons this class exists:
|
||||
|
||||
* for consistency, regardless of the Transport used
|
||||
|
||||
* to provide abstraction from the internals in the event internal API changes
|
||||
are made
|
||||
|
||||
* to provide convenience wrappers around aspects of the internal API
|
||||
|
||||
An instance of ``Swift_Mailer`` is created by the developer before sending any
|
||||
Messages.
|
||||
|
||||
Transports
|
||||
~~~~~~~~~~
|
||||
|
||||
Transports are the classes in Swift Mailer that are responsible for
|
||||
communicating with a service in order to deliver a Message. There are several
|
||||
types of Transport in Swift Mailer, all of which implement the Swift_Transport
|
||||
interface and offer underlying start(), stop() and send() methods.
|
||||
|
||||
Typically you will not need to know how a Transport works under-the-surface,
|
||||
you will only need to know how to create an instance of one, and which one to
|
||||
use for your environment.
|
||||
|
||||
+---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Class | Features | Pros/cons |
|
||||
+=================================+=============================================================================================+===============================================================================================================================================+
|
||||
| ``Swift_SmtpTransport`` | Sends messages over SMTP; Supports Authentication; Supports Encryption | Very portable; Pleasingly predictable results; Provides good feedback |
|
||||
+---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| ``Swift_SendmailTransport`` | Communicates with a locally installed ``sendmail`` executable (Linux/UNIX) | Quick time-to-run; Provides less-accurate feedback than SMTP; Requires ``sendmail`` installation |
|
||||
+---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| ``Swift_LoadBalancedTransport`` | Cycles through a collection of the other Transports to manage load-reduction | Provides graceful fallback if one Transport fails (e.g. an SMTP server is down); Keeps the load on remote services down by spreading the work |
|
||||
+---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| ``Swift_FailoverTransport`` | Works in conjunction with a collection of the other Transports to provide high-availability | Provides graceful fallback if one Transport fails (e.g. an SMTP server is down) |
|
||||
+---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
MIME Entities
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Everything that forms part of a Message is called a MIME Entity. All MIME
|
||||
entities in Swift Mailer share a common set of features. There are various
|
||||
types of MIME entity that serve different purposes such as Attachments and
|
||||
MIME parts.
|
||||
|
||||
An e-mail message is made up of several relatively simple entities that are
|
||||
combined in different ways to achieve different results. All of these entities
|
||||
have the same fundamental outline but serve a different purpose. The Message
|
||||
itself can be defined as a MIME entity, an Attachment is a MIME entity, all
|
||||
MIME parts are MIME entities -- and so on!
|
||||
|
||||
The basic units of each MIME entity -- be it the Message itself, or an
|
||||
Attachment -- are its Headers and its body:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Other-Header: Another value
|
||||
|
||||
The body content itself
|
||||
|
||||
The Headers of a MIME entity, and its body must conform to some strict
|
||||
standards defined by various RFC documents. Swift Mailer ensures that these
|
||||
specifications are followed by using various types of object, including
|
||||
Encoders and different Header types to generate the entity.
|
||||
|
||||
Each MIME component implements the base ``Swift_Mime_MimeEntity`` interface,
|
||||
which offers methods for retrieving Headers, adding new Headers, changing the
|
||||
Encoder, updating the body and so on!
|
||||
|
||||
All MIME entities have one Header in common -- the Content-Type Header,
|
||||
updated with the entity's ``setContentType()`` method.
|
||||
|
||||
Encoders
|
||||
~~~~~~~~
|
||||
|
||||
Encoders are used to transform the content of Messages generated in Swift
|
||||
Mailer into a format that is safe to send across the internet and that
|
||||
conforms to RFC specifications.
|
||||
|
||||
Generally speaking you will not need to interact with the Encoders in Swift
|
||||
Mailer -- the correct settings will be handled by the library itself.
|
||||
However they are probably worth a brief mention in the event that you do want
|
||||
to play with them.
|
||||
|
||||
Both the Headers and the body of all MIME entities (including the Message
|
||||
itself) use Encoders to ensure the data they contain can be sent over the
|
||||
internet without becoming corrupted or misinterpreted.
|
||||
|
||||
There are two types of Encoder: Base64 and Quoted-Printable.
|
||||
|
||||
Plugins
|
||||
~~~~~~~
|
||||
|
||||
Plugins exist to extend, or modify the behaviour of Swift Mailer. They respond
|
||||
to Events that are fired within the Transports during sending.
|
||||
|
||||
There are a number of Plugins provided as part of the base Swift Mailer
|
||||
package and they all follow a common interface to respond to Events fired
|
||||
within the library. Interfaces are provided to "listen" to each type of Event
|
||||
fired and to act as desired when a listened-to Event occurs.
|
||||
|
||||
Although several plugins are provided with Swift Mailer out-of-the-box, the
|
||||
Events system has been specifically designed to make it easy for experienced
|
||||
object-oriented developers to write their own plugins in order to achieve
|
||||
goals that may not be possible with the base library.
|
||||
385
vendor/swiftmailer/swiftmailer/doc/plugins.rst
vendored
385
vendor/swiftmailer/swiftmailer/doc/plugins.rst
vendored
@@ -1,385 +0,0 @@
|
||||
Plugins
|
||||
=======
|
||||
|
||||
Plugins are provided with Swift Mailer and can be used to extend the behavior
|
||||
of the library in situations where using simple class inheritance would be more complex.
|
||||
|
||||
AntiFlood Plugin
|
||||
----------------
|
||||
|
||||
Many SMTP servers have limits on the number of messages that may be sent
|
||||
during any single SMTP connection. The AntiFlood plugin provides a way to stay
|
||||
within this limit while still managing a large number of emails.
|
||||
|
||||
A typical limit for a single connection is 100 emails. If the server you
|
||||
connect to imposes such a limit, it expects you to disconnect after that
|
||||
number of emails has been sent. You could manage this manually within a loop,
|
||||
but the AntiFlood plugin provides the necessary wrapper code so that you don't
|
||||
need to worry about this logic.
|
||||
|
||||
Regardless of limits imposed by the server, it's usually a good idea to be
|
||||
conservative with the resources of the SMTP server. Sending will become
|
||||
sluggish if the server is being over-used so using the AntiFlood plugin will
|
||||
not be a bad idea even if no limits exist.
|
||||
|
||||
The AntiFlood plugin's logic is basically to disconnect and the immediately
|
||||
re-connect with the SMTP server every X number of emails sent, where X is a
|
||||
number you specify to the plugin.
|
||||
|
||||
You can also specify a time period in seconds that Swift Mailer should pause
|
||||
for between the disconnect/re-connect process. It's a good idea to pause for a
|
||||
short time (say 30 seconds every 100 emails) simply to give the SMTP server a
|
||||
chance to process its queue and recover some resources.
|
||||
|
||||
Using the AntiFlood Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The AntiFlood Plugin -- like all plugins -- is added with the Mailer class's
|
||||
``registerPlugin()`` method. It takes two constructor parameters: the number of
|
||||
emails to pause after, and optionally the number of seconds to pause for.
|
||||
|
||||
To use the AntiFlood plugin:
|
||||
|
||||
* Create an instance of the Mailer using any Transport you choose.
|
||||
|
||||
* Create an instance of the ``Swift_Plugins_AntiFloodPlugin`` class, passing
|
||||
in one or two constructor parameters.
|
||||
|
||||
* Register the plugin using the Mailer's ``registerPlugin()`` method.
|
||||
|
||||
* Continue using Swift Mailer to send messages as normal.
|
||||
|
||||
When Swift Mailer sends messages it will count the number of messages that
|
||||
have been sent since the last re-connect. Once the number hits your specified
|
||||
threshold it will disconnect and re-connect, optionally pausing for a
|
||||
specified amount of time.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Mailer using any Transport
|
||||
$mailer = Swift_Mailer::newInstance(
|
||||
Swift_SmtpTransport::newInstance('smtp.example.org', 25)
|
||||
);
|
||||
|
||||
// Use AntiFlood to re-connect after 100 emails
|
||||
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100));
|
||||
|
||||
// And specify a time in seconds to pause for (30 secs)
|
||||
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 30));
|
||||
|
||||
// Continue sending as normal
|
||||
for ($lotsOfRecipients as $recipient) {
|
||||
...
|
||||
|
||||
$mailer->send( ... );
|
||||
}
|
||||
|
||||
Throttler Plugin
|
||||
----------------
|
||||
|
||||
If your SMTP server has restrictions in place to limit the rate at which you
|
||||
send emails, then your code will need to be aware of this rate-limiting. The
|
||||
Throttler plugin makes Swift Mailer run at a rate-limited speed.
|
||||
|
||||
Many shared hosts don't open their SMTP servers as a free-for-all. Usually
|
||||
they have policies in place (probably to discourage spammers) that only allow
|
||||
you to send a fixed number of emails per-hour/day.
|
||||
|
||||
The Throttler plugin supports two modes of rate-limiting and with each, you
|
||||
will need to do that math to figure out the values you want. The plugin can
|
||||
limit based on the number of emails per minute, or the number of
|
||||
bytes-transferred per-minute.
|
||||
|
||||
Using the Throttler Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Throttler Plugin -- like all plugins -- is added with the Mailer class'
|
||||
``registerPlugin()`` method. It has two required constructor parameters that
|
||||
tell it how to do its rate-limiting.
|
||||
|
||||
To use the Throttler plugin:
|
||||
|
||||
* Create an instance of the Mailer using any Transport you choose.
|
||||
|
||||
* Create an instance of the ``Swift_Plugins_ThrottlerPlugin`` class, passing
|
||||
the number of emails, or bytes you wish to limit by, along with the mode
|
||||
you're using.
|
||||
|
||||
* Register the plugin using the Mailer's ``registerPlugin()`` method.
|
||||
|
||||
* Continue using Swift Mailer to send messages as normal.
|
||||
|
||||
When Swift Mailer sends messages it will keep track of the rate at which sending
|
||||
messages is occurring. If it realises that sending is happening too fast, it
|
||||
will cause your program to ``sleep()`` for enough time to average out the rate.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Mailer using any Transport
|
||||
$mailer = Swift_Mailer::newInstance(
|
||||
Swift_SmtpTransport::newInstance('smtp.example.org', 25)
|
||||
);
|
||||
|
||||
// Rate limit to 100 emails per-minute
|
||||
$mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
|
||||
100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE
|
||||
));
|
||||
|
||||
// Rate limit to 10MB per-minute
|
||||
$mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin(
|
||||
1024 * 1024 * 10, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE
|
||||
));
|
||||
|
||||
// Continue sending as normal
|
||||
for ($lotsOfRecipients as $recipient) {
|
||||
...
|
||||
|
||||
$mailer->send( ... );
|
||||
}
|
||||
|
||||
Logger Plugin
|
||||
-------------
|
||||
|
||||
The Logger plugins helps with debugging during the process of sending. It can
|
||||
help to identify why an SMTP server is rejecting addresses, or any other
|
||||
hard-to-find problems that may arise.
|
||||
|
||||
The Logger plugin comes in two parts. There's the plugin itself, along with
|
||||
one of a number of possible Loggers that you may choose to use. For example,
|
||||
the logger may output messages directly in realtime, or it may capture
|
||||
messages in an array.
|
||||
|
||||
One other notable feature is the way in which the Logger plugin changes
|
||||
Exception messages. If Exceptions are being thrown but the error message does
|
||||
not provide conclusive information as to the source of the problem (such as an
|
||||
ambiguous SMTP error) the Logger plugin includes the entire SMTP transcript in
|
||||
the error message so that debugging becomes a simpler task.
|
||||
|
||||
There are a few available Loggers included with Swift Mailer, but writing your
|
||||
own implementation is incredibly simple and is achieved by creating a short
|
||||
class that implements the ``Swift_Plugins_Logger`` interface.
|
||||
|
||||
* ``Swift_Plugins_Loggers_ArrayLogger``: Keeps a collection of log messages
|
||||
inside an array. The array content can be cleared or dumped out to the
|
||||
screen.
|
||||
|
||||
* ``Swift_Plugins_Loggers_EchoLogger``: Prints output to the screen in
|
||||
realtime. Handy for very rudimentary debug output.
|
||||
|
||||
Using the Logger Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Logger Plugin -- like all plugins -- is added with the Mailer class'
|
||||
``registerPlugin()`` method. It accepts an instance of ``Swift_Plugins_Logger``
|
||||
in its constructor.
|
||||
|
||||
To use the Logger plugin:
|
||||
|
||||
* Create an instance of the Mailer using any Transport you choose.
|
||||
|
||||
* Create an instance of the a Logger implementation of
|
||||
``Swift_Plugins_Logger``.
|
||||
|
||||
* Create an instance of the ``Swift_Plugins_LoggerPlugin`` class, passing the
|
||||
created Logger instance to its constructor.
|
||||
|
||||
* Register the plugin using the Mailer's ``registerPlugin()`` method.
|
||||
|
||||
* Continue using Swift Mailer to send messages as normal.
|
||||
|
||||
* Dump the contents of the log with the logger's ``dump()`` method.
|
||||
|
||||
When Swift Mailer sends messages it will keep a log of all the interactions
|
||||
with the underlying Transport being used. Depending upon the Logger that has
|
||||
been used the behaviour will differ, but all implementations offer a way to
|
||||
get the contents of the log.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Mailer using any Transport
|
||||
$mailer = Swift_Mailer::newInstance(
|
||||
Swift_SmtpTransport::newInstance('smtp.example.org', 25)
|
||||
);
|
||||
|
||||
// To use the ArrayLogger
|
||||
$logger = new Swift_Plugins_Loggers_ArrayLogger();
|
||||
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
|
||||
|
||||
// Or to use the Echo Logger
|
||||
$logger = new Swift_Plugins_Loggers_EchoLogger();
|
||||
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));
|
||||
|
||||
// Continue sending as normal
|
||||
for ($lotsOfRecipients as $recipient) {
|
||||
...
|
||||
|
||||
$mailer->send( ... );
|
||||
}
|
||||
|
||||
// Dump the log contents
|
||||
// NOTE: The EchoLogger dumps in realtime so dump() does nothing for it
|
||||
echo $logger->dump();
|
||||
|
||||
Decorator Plugin
|
||||
----------------
|
||||
|
||||
Often there's a need to send the same message to multiple recipients, but with
|
||||
tiny variations such as the recipient's name being used inside the message
|
||||
body. The Decorator plugin aims to provide a solution for allowing these small
|
||||
differences.
|
||||
|
||||
The decorator plugin works by intercepting the sending process of Swift
|
||||
Mailer, reading the email address in the To: field and then looking up a set
|
||||
of replacements for a template.
|
||||
|
||||
While the use of this plugin is simple, it is probably the most commonly
|
||||
misunderstood plugin due to the way in which it works. The typical mistake
|
||||
users make is to try registering the plugin multiple times (once for each
|
||||
recipient) -- inside a loop for example. This is incorrect.
|
||||
|
||||
The Decorator plugin should be registered just once, but containing the list
|
||||
of all recipients prior to sending. It will use this list of recipients to
|
||||
find the required replacements during sending.
|
||||
|
||||
Using the Decorator Plugin
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To use the Decorator plugin, simply create an associative array of replacements
|
||||
based on email addresses and then use the mailer's ``registerPlugin()`` method
|
||||
to add the plugin.
|
||||
|
||||
First create an associative array of replacements based on the email addresses
|
||||
you'll be sending the message to.
|
||||
|
||||
.. note::
|
||||
|
||||
The replacements array becomes a 2-dimensional array whose keys are the
|
||||
email addresses and whose values are an associative array of replacements
|
||||
for that email address. The curly braces used in this example can be any
|
||||
type of syntax you choose, provided they match the placeholders in your
|
||||
email template.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$replacements = array();
|
||||
foreach ($users as $user) {
|
||||
$replacements[$user['email']] = array(
|
||||
'{username}'=>$user['username'],
|
||||
'{password}'=>$user['password']
|
||||
);
|
||||
}
|
||||
|
||||
Now create an instance of the Decorator plugin using this array of replacements
|
||||
and then register it with the Mailer. Do this only once!
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$decorator = new Swift_Plugins_DecoratorPlugin($replacements);
|
||||
|
||||
$mailer->registerPlugin($decorator);
|
||||
|
||||
When you create your message, replace elements in the body (and/or the subject
|
||||
line) with your placeholders.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$message = Swift_Message::newInstance()
|
||||
->setSubject('Important notice for {username}')
|
||||
->setBody(
|
||||
"Hello {username}, we have reset your password to {password}\n" .
|
||||
"Please log in and change it at your earliest convenience."
|
||||
)
|
||||
;
|
||||
|
||||
foreach ($users as $user) {
|
||||
$message->addTo($user['email']);
|
||||
}
|
||||
|
||||
When you send this message to each of your recipients listed in your
|
||||
``$replacements`` array they will receive a message customized for just
|
||||
themselves. For example, the message used above when received may appear like
|
||||
this to one user:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Subject: Important notice for smilingsunshine2009
|
||||
|
||||
Hello smilingsunshine2009, we have reset your password to rainyDays
|
||||
Please log in and change it at your earliest convenience.
|
||||
|
||||
While another use may receive the message as:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Subject: Important notice for billy-bo-bob
|
||||
|
||||
Hello billy-bo-bob, we have reset your password to dancingOctopus
|
||||
Please log in and change it at your earliest convenience.
|
||||
|
||||
While the decorator plugin provides a means to solve this problem, there are
|
||||
various ways you could tackle this problem without the need for a plugin.
|
||||
We're trying to come up with a better way ourselves and while we have several
|
||||
(obvious) ideas we don't quite have the perfect solution to go ahead and
|
||||
implement it. Watch this space.
|
||||
|
||||
Providing Your Own Replacements Lookup for the Decorator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Filling an array with replacements may not be the best solution for providing
|
||||
replacement information to the decorator. If you have a more elegant algorithm
|
||||
that performs replacement lookups on-the-fly you may provide your own
|
||||
implementation.
|
||||
|
||||
Providing your own replacements lookup implementation for the Decorator is
|
||||
simply a matter of passing an instance of ``Swift_Plugins_Decorator_Replacements`` to the decorator plugin's constructor,
|
||||
rather than passing in an array.
|
||||
|
||||
The Replacements interface is very simple to implement since it has just one
|
||||
method: ``getReplacementsFor($address)``.
|
||||
|
||||
Imagine you want to look up replacements from a database on-the-fly, you might
|
||||
provide an implementation that does this. You need to create a small class.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
class DbReplacements implements Swift_Plugins_Decorator_Replacements {
|
||||
public function getReplacementsFor($address) {
|
||||
$sql = sprintf(
|
||||
"SELECT * FROM user WHERE email = '%s'",
|
||||
mysql_real_escape_string($address)
|
||||
);
|
||||
|
||||
$result = mysql_query($sql);
|
||||
|
||||
if ($row = mysql_fetch_assoc($result)) {
|
||||
return array(
|
||||
'{username}'=>$row['username'],
|
||||
'{password}'=>$row['password']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Now all you need to do is pass an instance of your class into the Decorator
|
||||
plugin's constructor instead of passing an array.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$decorator = new Swift_Plugins_DecoratorPlugin(new DbReplacements());
|
||||
|
||||
$mailer->registerPlugin($decorator);
|
||||
|
||||
For each message sent, the plugin will call your class' ``getReplacementsFor()``
|
||||
method to find the array of replacements it needs.
|
||||
|
||||
.. note::
|
||||
|
||||
If your lookup algorithm is case sensitive, you should transform the
|
||||
``$address`` argument as appropriate -- for example by passing it
|
||||
through ``strtolower()``.
|
||||
571
vendor/swiftmailer/swiftmailer/doc/sending.rst
vendored
571
vendor/swiftmailer/swiftmailer/doc/sending.rst
vendored
@@ -1,571 +0,0 @@
|
||||
Sending Messages
|
||||
================
|
||||
|
||||
Quick Reference for Sending a Message
|
||||
-------------------------------------
|
||||
|
||||
Sending a message is very straightforward. You create a Transport, use it to
|
||||
create the Mailer, then you use the Mailer to send the message.
|
||||
|
||||
To send a Message:
|
||||
|
||||
* Create a Transport from one of the provided Transports --
|
||||
``Swift_SmtpTransport``, ``Swift_SendmailTransport``
|
||||
or one of the aggregate Transports.
|
||||
|
||||
* Create an instance of the ``Swift_Mailer`` class, using the Transport as
|
||||
it's constructor parameter.
|
||||
|
||||
* Create a Message.
|
||||
|
||||
* Send the message via the ``send()`` method on the Mailer object.
|
||||
|
||||
.. caution::
|
||||
|
||||
The ``Swift_SmtpTransport`` and ``Swift_SendmailTransport`` transports use
|
||||
``proc_*`` PHP functions, which might not be available on your PHP
|
||||
installation. You can easily check if that's the case by running the
|
||||
following PHP script: ``<?php echo function_exists('proc_open') ? "Yep,
|
||||
that will work" : "Sorry, that won't work";``
|
||||
|
||||
When using ``send()`` the message will be sent just like it would be sent if you
|
||||
used your mail client. An integer is returned which includes the number of
|
||||
successful recipients. If none of the recipients could be sent to then zero will
|
||||
be returned, which equates to a boolean ``false``. If you set two ``To:``
|
||||
recipients and three ``Bcc:`` recipients in the message and all of the
|
||||
recipients are delivered to successfully then the value 5 will be returned.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Transport
|
||||
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
|
||||
->setUsername('your username')
|
||||
->setPassword('your password')
|
||||
;
|
||||
|
||||
/*
|
||||
You could alternatively use a different transport such as Sendmail:
|
||||
|
||||
// Sendmail
|
||||
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
|
||||
*/
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
// Create a message
|
||||
$message = Swift_Message::newInstance('Wonderful Subject')
|
||||
->setFrom(array('john@doe.com' => 'John Doe'))
|
||||
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
|
||||
->setBody('Here is the message itself')
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$result = $mailer->send($message);
|
||||
|
||||
Transport Types
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
A Transport is the component which actually does the sending. You need to
|
||||
provide a Transport object to the Mailer class and there are several possible
|
||||
options.
|
||||
|
||||
Typically you will not need to know how a Transport works under-the-surface,
|
||||
you will only need to know how to create an instance of one, and which one to
|
||||
use for your environment.
|
||||
|
||||
The SMTP Transport
|
||||
..................
|
||||
|
||||
The SMTP Transport sends messages over the (standardized) Simple Message
|
||||
Transfer Protocol. It can deal with encryption and authentication.
|
||||
|
||||
The SMTP Transport, ``Swift_SmtpTransport`` is without doubt the most commonly
|
||||
used Transport because it will work on 99% of web servers (I just made that
|
||||
number up, but you get the idea). All the server needs is the ability to
|
||||
connect to a remote (or even local) SMTP server on the correct port number
|
||||
(usually 25).
|
||||
|
||||
SMTP servers often require users to authenticate with a username and password
|
||||
before any mail can be sent to other domains. This is easily achieved using
|
||||
Swift Mailer with the SMTP Transport.
|
||||
|
||||
SMTP is a protocol -- in other words it's a "way" of communicating a job
|
||||
to be done (i.e. sending a message). The SMTP protocol is the fundamental
|
||||
basis on which messages are delivered all over the internet 7 days a week, 365
|
||||
days a year. For this reason it's the most "direct" method of sending messages
|
||||
you can use and it's the one that will give you the most power and feedback
|
||||
(such as delivery failures) when using Swift Mailer.
|
||||
|
||||
Because SMTP is generally run as a remote service (i.e. you connect to it over
|
||||
the network/internet) it's extremely portable from server-to-server. You can
|
||||
easily store the SMTP server address and port number in a configuration file
|
||||
within your application and adjust the settings accordingly if the code is
|
||||
moved or if the SMTP server is changed.
|
||||
|
||||
Some SMTP servers -- Google for example -- use encryption for security reasons.
|
||||
Swift Mailer supports using both SSL and TLS encryption settings.
|
||||
|
||||
Using the SMTP Transport
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The SMTP Transport is easy to use. Most configuration options can be set with
|
||||
the constructor.
|
||||
|
||||
To use the SMTP Transport you need to know which SMTP server your code needs
|
||||
to connect to. Ask your web host if you're not sure. Lots of people ask me who
|
||||
to connect to -- I really can't answer that since it's a setting that's
|
||||
extremely specific to your hosting environment.
|
||||
|
||||
To use the SMTP Transport:
|
||||
|
||||
* Call ``Swift_SmtpTransport::newInstance()`` with the SMTP server name and
|
||||
optionally with a port number (defaults to 25).
|
||||
|
||||
* Use the returned object to create the Mailer.
|
||||
|
||||
A connection to the SMTP server will be established upon the first call to
|
||||
``send()``.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Transport
|
||||
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25);
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
/*
|
||||
It's also possible to use multiple method calls
|
||||
|
||||
$transport = Swift_SmtpTransport::newInstance()
|
||||
->setHost('smtp.example.org')
|
||||
->setPort(25)
|
||||
;
|
||||
*/
|
||||
|
||||
Encrypted SMTP
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
You can use SSL or TLS encryption with the SMTP Transport by specifying it as
|
||||
a parameter or with a method call.
|
||||
|
||||
To use encryption with the SMTP Transport:
|
||||
|
||||
* Pass the encryption setting as a third parameter to
|
||||
``Swift_SmtpTransport::newInstance()``; or
|
||||
|
||||
* Call the ``setEncryption()`` method on the Transport.
|
||||
|
||||
A connection to the SMTP server will be established upon the first call to
|
||||
``send()``. The connection will be initiated with the correct encryption
|
||||
settings.
|
||||
|
||||
.. note::
|
||||
|
||||
For SSL or TLS encryption to work your PHP installation must have
|
||||
appropriate OpenSSL transports wrappers. You can check if "tls" and/or
|
||||
"ssl" are present in your PHP installation by using the PHP function
|
||||
``stream_get_transports()``
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Transport
|
||||
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 587, 'ssl');
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
/*
|
||||
It's also possible to use multiple method calls
|
||||
|
||||
$transport = Swift_SmtpTransport::newInstance()
|
||||
->setHost('smtp.example.org')
|
||||
->setPort(587)
|
||||
->setEncryption('ssl')
|
||||
;
|
||||
*/
|
||||
|
||||
SMTP with a Username and Password
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Some servers require authentication. You can provide a username and password
|
||||
with ``setUsername()`` and ``setPassword()`` methods.
|
||||
|
||||
To use a username and password with the SMTP Transport:
|
||||
|
||||
* Create the Transport with ``Swift_SmtpTransport::newInstance()``.
|
||||
|
||||
* Call the ``setUsername()`` and ``setPassword()`` methods on the Transport.
|
||||
|
||||
Your username and password will be used to authenticate upon first connect
|
||||
when ``send()`` are first used on the Mailer.
|
||||
|
||||
If authentication fails, an Exception of type ``Swift_TransportException`` will
|
||||
be thrown.
|
||||
|
||||
.. note::
|
||||
|
||||
If you need to know early whether or not authentication has failed and an
|
||||
Exception is going to be thrown, call the ``start()`` method on the
|
||||
created Transport.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Transport the call setUsername() and setPassword()
|
||||
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
|
||||
->setUsername('username')
|
||||
->setPassword('password')
|
||||
;
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
The Sendmail Transport
|
||||
......................
|
||||
|
||||
The Sendmail Transport sends messages by communicating with a locally
|
||||
installed MTA -- such as ``sendmail``.
|
||||
|
||||
The Sendmail Transport, ``Swift_SendmailTransport`` does not directly connect to
|
||||
any remote services. It is designed for Linux servers that have ``sendmail``
|
||||
installed. The Transport starts a local ``sendmail`` process and sends messages
|
||||
to it. Usually the ``sendmail`` process will respond quickly as it spools your
|
||||
messages to disk before sending them.
|
||||
|
||||
The Transport is named the Sendmail Transport for historical reasons
|
||||
(``sendmail`` was the "standard" UNIX tool for sending e-mail for years). It
|
||||
will send messages using other transfer agents such as Exim or Postfix despite
|
||||
its name, provided they have the relevant sendmail wrappers so that they can be
|
||||
started with the correct command-line flags.
|
||||
|
||||
It's a common misconception that because the Sendmail Transport returns a
|
||||
result very quickly it must therefore deliver messages to recipients quickly
|
||||
-- this is not true. It's not slow by any means, but it's certainly not
|
||||
faster than SMTP when it comes to getting messages to the intended recipients.
|
||||
This is because sendmail itself sends the messages over SMTP once they have
|
||||
been quickly spooled to disk.
|
||||
|
||||
The Sendmail Transport has the potential to be just as smart of the SMTP
|
||||
Transport when it comes to notifying Swift Mailer about which recipients were
|
||||
rejected, but in reality the majority of locally installed ``sendmail``
|
||||
instances are not configured well enough to provide any useful feedback. As such
|
||||
Swift Mailer may report successful deliveries where they did in fact fail before
|
||||
they even left your server.
|
||||
|
||||
You can run the Sendmail Transport in two different modes specified by command
|
||||
line flags:
|
||||
|
||||
* "``-bs``" runs in SMTP mode so theoretically it will act like the SMTP
|
||||
Transport
|
||||
|
||||
* "``-t``" runs in piped mode with no feedback, but theoretically faster,
|
||||
though not advised
|
||||
|
||||
You can think of the Sendmail Transport as a sort of asynchronous SMTP Transport
|
||||
-- though if you have problems with delivery failures you should try using the
|
||||
SMTP Transport instead. Swift Mailer isn't doing the work here, it's simply
|
||||
passing the work to somebody else (i.e. ``sendmail``).
|
||||
|
||||
Using the Sendmail Transport
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
To use the Sendmail Transport you simply need to call
|
||||
``Swift_SendmailTransport::newInstance()`` with the command as a parameter.
|
||||
|
||||
To use the Sendmail Transport you need to know where ``sendmail`` or another MTA
|
||||
exists on the server. Swift Mailer uses a default value of
|
||||
``/usr/sbin/sendmail``, which should work on most systems.
|
||||
|
||||
You specify the entire command as a parameter (i.e. including the command line
|
||||
flags). Swift Mailer supports operational modes of "``-bs``" (default) and
|
||||
"``-t``".
|
||||
|
||||
.. note::
|
||||
|
||||
If you run sendmail in "``-t``" mode you will get no feedback as to whether
|
||||
or not sending has succeeded. Use "``-bs``" unless you have a reason not to.
|
||||
|
||||
To use the Sendmail Transport:
|
||||
|
||||
* Call ``Swift_SendmailTransport::newInstance()`` with the command, including
|
||||
the correct command line flags. The default is to use ``/usr/sbin/sendmail
|
||||
-bs`` if this is not specified.
|
||||
|
||||
* Use the returned object to create the Mailer.
|
||||
|
||||
A sendmail process will be started upon the first call to ``send()``. If the
|
||||
process cannot be started successfully an Exception of type
|
||||
``Swift_TransportException`` will be thrown.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Transport
|
||||
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs');
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
The Mail Transport
|
||||
..................
|
||||
|
||||
The Mail Transport sends messages by delegating to PHP's internal
|
||||
``mail()`` function.
|
||||
|
||||
In my experience -- and others' -- the ``mail()`` function is not particularly
|
||||
predictable, or helpful.
|
||||
|
||||
Quite notably, the ``mail()`` function behaves entirely differently between
|
||||
Linux and Windows servers. On linux it uses ``sendmail``, but on Windows it uses
|
||||
SMTP.
|
||||
|
||||
In order for the ``mail()`` function to even work at all ``php.ini`` needs to be
|
||||
configured correctly, specifying the location of sendmail or of an SMTP server.
|
||||
|
||||
The problem with ``mail()`` is that it "tries" to simplify things to the point
|
||||
that it actually makes things more complex due to poor interface design. The
|
||||
developers of Swift Mailer have gone to a lot of effort to make the Mail
|
||||
Transport work with a reasonable degree of consistency.
|
||||
|
||||
Serious drawbacks when using this Transport are:
|
||||
|
||||
* Unpredictable message headers
|
||||
|
||||
* Lack of feedback regarding delivery failures
|
||||
|
||||
* Lack of support for several plugins that require real-time delivery feedback
|
||||
|
||||
It's a last resort, and we say that with a passion!
|
||||
|
||||
Available Methods for Sending Messages
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The Mailer class offers two methods for sending Messages -- ``send()``.
|
||||
Each behaves in a slightly different way.
|
||||
|
||||
When a message is sent in Swift Mailer, the Mailer class communicates with
|
||||
whichever Transport class you have chosen to use.
|
||||
|
||||
Each recipient in the message should either be accepted or rejected by the
|
||||
Transport. For example, if the domain name on the email address is not
|
||||
reachable the SMTP Transport may reject the address because it cannot process
|
||||
it. Whichever method you use -- ``send()`` -- Swift Mailer will return
|
||||
an integer indicating the number of accepted recipients.
|
||||
|
||||
.. note::
|
||||
|
||||
It's possible to find out which recipients were rejected -- we'll cover that
|
||||
later in this chapter.
|
||||
|
||||
Using the ``send()`` Method
|
||||
...........................
|
||||
|
||||
The ``send()`` method of the ``Swift_Mailer`` class sends a message using
|
||||
exactly the same logic as your Desktop mail client would use. Just pass it a
|
||||
Message and get a result.
|
||||
|
||||
To send a Message with ``send()``:
|
||||
|
||||
* Create a Transport from one of the provided Transports --
|
||||
``Swift_SmtpTransport``, ``Swift_SendmailTransport``,
|
||||
or one of the aggregate Transports.
|
||||
|
||||
* Create an instance of the ``Swift_Mailer`` class, using the Transport as
|
||||
it's constructor parameter.
|
||||
|
||||
* Create a Message.
|
||||
|
||||
* Send the message via the ``send()`` method on the Mailer object.
|
||||
|
||||
The message will be sent just like it would be sent if you used your mail
|
||||
client. An integer is returned which includes the number of successful
|
||||
recipients. If none of the recipients could be sent to then zero will be
|
||||
returned, which equates to a boolean ``false``. If you set two
|
||||
``To:`` recipients and three ``Bcc:`` recipients in the message and all of the
|
||||
recipients are delivered to successfully then the value 5 will be returned.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Transport
|
||||
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
// Create a message
|
||||
$message = Swift_Message::newInstance('Wonderful Subject')
|
||||
->setFrom(array('john@doe.com' => 'John Doe'))
|
||||
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'))
|
||||
->setBody('Here is the message itself')
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$numSent = $mailer->send($message);
|
||||
|
||||
printf("Sent %d messages\n", $numSent);
|
||||
|
||||
/* Note that often that only the boolean equivalent of the
|
||||
return value is of concern (zero indicates FALSE)
|
||||
|
||||
if ($mailer->send($message))
|
||||
{
|
||||
echo "Sent\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Failed\n";
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
Sending Emails in Batch
|
||||
.......................
|
||||
|
||||
If you want to send a separate message to each recipient so that only their
|
||||
own address shows up in the ``To:`` field, follow the following recipe:
|
||||
|
||||
* Create a Transport from one of the provided Transports --
|
||||
``Swift_SmtpTransport``, ``Swift_SendmailTransport``,
|
||||
or one of the aggregate Transports.
|
||||
|
||||
* Create an instance of the ``Swift_Mailer`` class, using the Transport as
|
||||
it's constructor parameter.
|
||||
|
||||
* Create a Message.
|
||||
|
||||
* Iterate over the recipients and send message via the ``send()`` method on
|
||||
the Mailer object.
|
||||
|
||||
Each recipient of the messages receives a different copy with only their own
|
||||
email address on the ``To:`` field.
|
||||
|
||||
Make sure to add only valid email addresses as recipients. If you try to add an
|
||||
invalid email address with ``setTo()``, ``setCc()`` or ``setBcc()``, Swift
|
||||
Mailer will throw a ``Swift_RfcComplianceException``.
|
||||
|
||||
If you add recipients automatically based on a data source that may contain
|
||||
invalid email addresses, you can prevent possible exceptions by validating the
|
||||
addresses using ``Swift_Validate::email($email)`` and only adding addresses
|
||||
that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and
|
||||
``setBcc()`` calls in a try-catch block and handle the
|
||||
``Swift_RfcComplianceException`` in the catch block.
|
||||
|
||||
Handling invalid addresses properly is especially important when sending emails
|
||||
in large batches since a single invalid address might cause an unhandled
|
||||
exception and stop the execution or your script early.
|
||||
|
||||
.. note::
|
||||
|
||||
In the following example, two emails are sent. One to each of
|
||||
``receiver@domain.org`` and ``other@domain.org``. These recipients will
|
||||
not be aware of each other.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
require_once 'lib/swift_required.php';
|
||||
|
||||
// Create the Transport
|
||||
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
|
||||
|
||||
// Create the Mailer using your created Transport
|
||||
$mailer = Swift_Mailer::newInstance($transport);
|
||||
|
||||
// Create a message
|
||||
$message = Swift_Message::newInstance('Wonderful Subject')
|
||||
->setFrom(array('john@doe.com' => 'John Doe'))
|
||||
->setBody('Here is the message itself')
|
||||
;
|
||||
|
||||
// Send the message
|
||||
$failedRecipients = array();
|
||||
$numSent = 0;
|
||||
$to = array('receiver@domain.org', 'other@domain.org' => 'A name');
|
||||
|
||||
foreach ($to as $address => $name)
|
||||
{
|
||||
if (is_int($address)) {
|
||||
$message->setTo($name);
|
||||
} else {
|
||||
$message->setTo(array($address => $name));
|
||||
}
|
||||
|
||||
$numSent += $mailer->send($message, $failedRecipients);
|
||||
}
|
||||
|
||||
printf("Sent %d messages\n", $numSent);
|
||||
|
||||
Finding out Rejected Addresses
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
It's possible to get a list of addresses that were rejected by the Transport
|
||||
by using a by-reference parameter to ``send()``.
|
||||
|
||||
As Swift Mailer attempts to send the message to each address given to it, if a
|
||||
recipient is rejected it will be added to the array. You can pass an existing
|
||||
array, otherwise one will be created by-reference.
|
||||
|
||||
Collecting the list of recipients that were rejected can be useful in
|
||||
circumstances where you need to "prune" a mailing list for example when some
|
||||
addresses cannot be delivered to.
|
||||
|
||||
Getting Failures By-reference
|
||||
.............................
|
||||
|
||||
Collecting delivery failures by-reference with the ``send()`` method is as
|
||||
simple as passing a variable name to the method call.
|
||||
|
||||
To get failed recipients by-reference:
|
||||
|
||||
* Pass a by-reference variable name to the ``send()`` method of the Mailer
|
||||
class.
|
||||
|
||||
If the Transport rejects any of the recipients, the culprit addresses will be
|
||||
added to the array provided by-reference.
|
||||
|
||||
.. note::
|
||||
|
||||
If the variable name does not yet exist, it will be initialized as an
|
||||
empty array and then failures will be added to that array. If the variable
|
||||
already exists it will be type-cast to an array and failures will be added
|
||||
to it.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$mailer = Swift_Mailer::newInstance( ... );
|
||||
|
||||
$message = Swift_Message::newInstance( ... )
|
||||
->setFrom( ... )
|
||||
->setTo(array(
|
||||
'receiver@bad-domain.org' => 'Receiver Name',
|
||||
'other@domain.org' => 'A name',
|
||||
'other-receiver@bad-domain.org' => 'Other Name'
|
||||
))
|
||||
->setBody( ... )
|
||||
;
|
||||
|
||||
// Pass a variable name to the send() method
|
||||
if (!$mailer->send($message, $failures))
|
||||
{
|
||||
echo "Failures:";
|
||||
print_r($failures);
|
||||
}
|
||||
|
||||
/*
|
||||
Failures:
|
||||
Array (
|
||||
0 => receiver@bad-domain.org,
|
||||
1 => other-receiver@bad-domain.org
|
||||
)
|
||||
*/
|
||||
Binary file not shown.
BIN
vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle
vendored
BIN
vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle
vendored
Binary file not shown.
Binary file not shown.
@@ -1,80 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* General utility class in Swift Mailer, not to be instantiated.
|
||||
*
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
abstract class Swift
|
||||
{
|
||||
/** Swift Mailer Version number generated during dist release process */
|
||||
const VERSION = '@SWIFT_VERSION_NUMBER@';
|
||||
|
||||
public static $initialized = false;
|
||||
public static $inits = array();
|
||||
|
||||
/**
|
||||
* Registers an initializer callable that will be called the first time
|
||||
* a SwiftMailer class is autoloaded.
|
||||
*
|
||||
* This enables you to tweak the default configuration in a lazy way.
|
||||
*
|
||||
* @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class
|
||||
*/
|
||||
public static function init($callable)
|
||||
{
|
||||
self::$inits[] = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal autoloader for spl_autoload_register().
|
||||
*
|
||||
* @param string $class
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
// Don't interfere with other autoloaders
|
||||
if (0 !== strpos($class, 'Swift_')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$path = __DIR__.'/'.str_replace('_', '/', $class).'.php';
|
||||
|
||||
if (!file_exists($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
require $path;
|
||||
|
||||
if (self::$inits && !self::$initialized) {
|
||||
self::$initialized = true;
|
||||
foreach (self::$inits as $init) {
|
||||
call_user_func($init);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure autoloading using Swift Mailer.
|
||||
*
|
||||
* This is designed to play nicely with other autoloaders.
|
||||
*
|
||||
* @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class
|
||||
*/
|
||||
public static function registerAutoload($callable = null)
|
||||
{
|
||||
if (null !== $callable) {
|
||||
self::$inits[] = $callable;
|
||||
}
|
||||
spl_autoload_register(array('Swift', 'autoload'));
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Attachment class for attaching files to a {@link Swift_Mime_Message}.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_Attachment extends Swift_Mime_Attachment
|
||||
{
|
||||
/**
|
||||
* Create a new Attachment.
|
||||
*
|
||||
* Details may be optionally provided to the constructor.
|
||||
*
|
||||
* @param string|Swift_OutputByteStream $data
|
||||
* @param string $filename
|
||||
* @param string $contentType
|
||||
*/
|
||||
public function __construct($data = null, $filename = null, $contentType = null)
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Mime_Attachment::__construct'),
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('mime.attachment')
|
||||
);
|
||||
|
||||
$this->setBody($data);
|
||||
$this->setFilename($filename);
|
||||
if ($contentType) {
|
||||
$this->setContentType($contentType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Attachment.
|
||||
*
|
||||
* @param string|Swift_OutputByteStream $data
|
||||
* @param string $filename
|
||||
* @param string $contentType
|
||||
*
|
||||
* @return Swift_Mime_Attachment
|
||||
*/
|
||||
public static function newInstance($data = null, $filename = null, $contentType = null)
|
||||
{
|
||||
return new self($data, $filename, $contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Attachment from a filesystem path.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $contentType optional
|
||||
*
|
||||
* @return Swift_Mime_Attachment
|
||||
*/
|
||||
public static function fromPath($path, $contentType = null)
|
||||
{
|
||||
return self::newInstance()->setFile(
|
||||
new Swift_ByteStream_FileByteStream($path),
|
||||
$contentType
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the base functionality for an InputStream supporting filters.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_InputByteStream, Swift_Filterable
|
||||
{
|
||||
/**
|
||||
* Write sequence.
|
||||
*/
|
||||
protected $_sequence = 0;
|
||||
|
||||
/**
|
||||
* StreamFilters.
|
||||
*
|
||||
* @var Swift_StreamFilter[]
|
||||
*/
|
||||
private $_filters = array();
|
||||
|
||||
/**
|
||||
* A buffer for writing.
|
||||
*/
|
||||
private $_writeBuffer = '';
|
||||
|
||||
/**
|
||||
* Bound streams.
|
||||
*
|
||||
* @var Swift_InputByteStream[]
|
||||
*/
|
||||
private $_mirrors = array();
|
||||
|
||||
/**
|
||||
* Commit the given bytes to the storage medium immediately.
|
||||
*
|
||||
* @param string $bytes
|
||||
*/
|
||||
abstract protected function _commit($bytes);
|
||||
|
||||
/**
|
||||
* Flush any buffers/content with immediate effect.
|
||||
*/
|
||||
abstract protected function _flush();
|
||||
|
||||
/**
|
||||
* Add a StreamFilter to this InputByteStream.
|
||||
*
|
||||
* @param Swift_StreamFilter $filter
|
||||
* @param string $key
|
||||
*/
|
||||
public function addFilter(Swift_StreamFilter $filter, $key)
|
||||
{
|
||||
$this->_filters[$key] = $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an already present StreamFilter based on its $key.
|
||||
*
|
||||
* @param string $key
|
||||
*/
|
||||
public function removeFilter($key)
|
||||
{
|
||||
unset($this->_filters[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes $bytes to the end of the stream.
|
||||
*
|
||||
* @param string $bytes
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function write($bytes)
|
||||
{
|
||||
$this->_writeBuffer .= $bytes;
|
||||
foreach ($this->_filters as $filter) {
|
||||
if ($filter->shouldBuffer($this->_writeBuffer)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->_doWrite($this->_writeBuffer);
|
||||
|
||||
return ++$this->_sequence;
|
||||
}
|
||||
|
||||
/**
|
||||
* For any bytes that are currently buffered inside the stream, force them
|
||||
* off the buffer.
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
$this->_doWrite($this->_writeBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach $is to this stream.
|
||||
*
|
||||
* The stream acts as an observer, receiving all data that is written.
|
||||
* All {@link write()} and {@link flushBuffers()} operations will be mirrored.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
$this->_mirrors[] = $is;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an already bound stream.
|
||||
*
|
||||
* If $is is not bound, no errors will be raised.
|
||||
* If the stream currently has any buffered data it will be written to $is
|
||||
* before unbinding occurs.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
foreach ($this->_mirrors as $k => $stream) {
|
||||
if ($is === $stream) {
|
||||
if ($this->_writeBuffer !== '') {
|
||||
$stream->write($this->_writeBuffer);
|
||||
}
|
||||
unset($this->_mirrors[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the contents of the stream (empty it) and set the internal pointer
|
||||
* to the beginning.
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*/
|
||||
public function flushBuffers()
|
||||
{
|
||||
if ($this->_writeBuffer !== '') {
|
||||
$this->_doWrite($this->_writeBuffer);
|
||||
}
|
||||
$this->_flush();
|
||||
|
||||
foreach ($this->_mirrors as $stream) {
|
||||
$stream->flushBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
/** Run $bytes through all filters */
|
||||
private function _filter($bytes)
|
||||
{
|
||||
foreach ($this->_filters as $filter) {
|
||||
$bytes = $filter->filter($bytes);
|
||||
}
|
||||
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
/** Just write the bytes to the stream */
|
||||
private function _doWrite($bytes)
|
||||
{
|
||||
$this->_commit($this->_filter($bytes));
|
||||
|
||||
foreach ($this->_mirrors as $stream) {
|
||||
$stream->write($bytes);
|
||||
}
|
||||
|
||||
$this->_writeBuffer = '';
|
||||
}
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allows reading and writing of bytes to and from an array.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream
|
||||
{
|
||||
/**
|
||||
* The internal stack of bytes.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $_array = array();
|
||||
|
||||
/**
|
||||
* The size of the stack.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_arraySize = 0;
|
||||
|
||||
/**
|
||||
* The internal pointer offset.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_offset = 0;
|
||||
|
||||
/**
|
||||
* Bound streams.
|
||||
*
|
||||
* @var Swift_InputByteStream[]
|
||||
*/
|
||||
private $_mirrors = array();
|
||||
|
||||
/**
|
||||
* Create a new ArrayByteStream.
|
||||
*
|
||||
* If $stack is given the stream will be populated with the bytes it contains.
|
||||
*
|
||||
* @param mixed $stack of bytes in string or array form, optional
|
||||
*/
|
||||
public function __construct($stack = null)
|
||||
{
|
||||
if (is_array($stack)) {
|
||||
$this->_array = $stack;
|
||||
$this->_arraySize = count($stack);
|
||||
} elseif (is_string($stack)) {
|
||||
$this->write($stack);
|
||||
} else {
|
||||
$this->_array = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads $length bytes from the stream into a string and moves the pointer
|
||||
* through the stream by $length.
|
||||
*
|
||||
* If less bytes exist than are requested the
|
||||
* remaining bytes are given instead. If no bytes are remaining at all, boolean
|
||||
* false is returned.
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function read($length)
|
||||
{
|
||||
if ($this->_offset == $this->_arraySize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't use array slice
|
||||
$end = $length + $this->_offset;
|
||||
$end = $this->_arraySize < $end ? $this->_arraySize : $end;
|
||||
$ret = '';
|
||||
for (; $this->_offset < $end; ++$this->_offset) {
|
||||
$ret .= $this->_array[$this->_offset];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes $bytes to the end of the stream.
|
||||
*
|
||||
* @param string $bytes
|
||||
*/
|
||||
public function write($bytes)
|
||||
{
|
||||
$to_add = str_split($bytes);
|
||||
foreach ($to_add as $value) {
|
||||
$this->_array[] = $value;
|
||||
}
|
||||
$this->_arraySize = count($this->_array);
|
||||
|
||||
foreach ($this->_mirrors as $stream) {
|
||||
$stream->write($bytes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Not used.
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach $is to this stream.
|
||||
*
|
||||
* The stream acts as an observer, receiving all data that is written.
|
||||
* All {@link write()} and {@link flushBuffers()} operations will be mirrored.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function bind(Swift_InputByteStream $is)
|
||||
{
|
||||
$this->_mirrors[] = $is;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an already bound stream.
|
||||
*
|
||||
* If $is is not bound, no errors will be raised.
|
||||
* If the stream currently has any buffered data it will be written to $is
|
||||
* before unbinding occurs.
|
||||
*
|
||||
* @param Swift_InputByteStream $is
|
||||
*/
|
||||
public function unbind(Swift_InputByteStream $is)
|
||||
{
|
||||
foreach ($this->_mirrors as $k => $stream) {
|
||||
if ($is === $stream) {
|
||||
unset($this->_mirrors[$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the internal read pointer to $byteOffset in the stream.
|
||||
*
|
||||
* @param int $byteOffset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setReadPointer($byteOffset)
|
||||
{
|
||||
if ($byteOffset > $this->_arraySize) {
|
||||
$byteOffset = $this->_arraySize;
|
||||
} elseif ($byteOffset < 0) {
|
||||
$byteOffset = 0;
|
||||
}
|
||||
|
||||
$this->_offset = $byteOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the contents of the stream (empty it) and set the internal pointer
|
||||
* to the beginning.
|
||||
*/
|
||||
public function flushBuffers()
|
||||
{
|
||||
$this->_offset = 0;
|
||||
$this->_array = array();
|
||||
$this->_arraySize = 0;
|
||||
|
||||
foreach ($this->_mirrors as $stream) {
|
||||
$stream->flushBuffers();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allows reading and writing of bytes to and from a file.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_FileStream
|
||||
{
|
||||
/** The internal pointer offset */
|
||||
private $_offset = 0;
|
||||
|
||||
/** The path to the file */
|
||||
private $_path;
|
||||
|
||||
/** The mode this file is opened in for writing */
|
||||
private $_mode;
|
||||
|
||||
/** A lazy-loaded resource handle for reading the file */
|
||||
private $_reader;
|
||||
|
||||
/** A lazy-loaded resource handle for writing the file */
|
||||
private $_writer;
|
||||
|
||||
/** If magic_quotes_runtime is on, this will be true */
|
||||
private $_quotes = false;
|
||||
|
||||
/** If stream is seekable true/false, or null if not known */
|
||||
private $_seekable = null;
|
||||
|
||||
/**
|
||||
* Create a new FileByteStream for $path.
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $writable if true
|
||||
*/
|
||||
public function __construct($path, $writable = false)
|
||||
{
|
||||
if (empty($path)) {
|
||||
throw new Swift_IoException('The path cannot be empty');
|
||||
}
|
||||
$this->_path = $path;
|
||||
$this->_mode = $writable ? 'w+b' : 'rb';
|
||||
|
||||
if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) {
|
||||
$this->_quotes = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the complete path to the file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads $length bytes from the stream into a string and moves the pointer
|
||||
* through the stream by $length.
|
||||
*
|
||||
* If less bytes exist than are requested the
|
||||
* remaining bytes are given instead. If no bytes are remaining at all, boolean
|
||||
* false is returned.
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @throws Swift_IoException
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public function read($length)
|
||||
{
|
||||
$fp = $this->_getReadHandle();
|
||||
if (!feof($fp)) {
|
||||
if ($this->_quotes) {
|
||||
ini_set('magic_quotes_runtime', 0);
|
||||
}
|
||||
$bytes = fread($fp, $length);
|
||||
if ($this->_quotes) {
|
||||
ini_set('magic_quotes_runtime', 1);
|
||||
}
|
||||
$this->_offset = ftell($fp);
|
||||
|
||||
// If we read one byte after reaching the end of the file
|
||||
// feof() will return false and an empty string is returned
|
||||
if ($bytes === '' && feof($fp)) {
|
||||
$this->_resetReadHandle();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $bytes;
|
||||
}
|
||||
|
||||
$this->_resetReadHandle();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the internal read pointer to $byteOffset in the stream.
|
||||
*
|
||||
* @param int $byteOffset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function setReadPointer($byteOffset)
|
||||
{
|
||||
if (isset($this->_reader)) {
|
||||
$this->_seekReadStreamToPosition($byteOffset);
|
||||
}
|
||||
$this->_offset = $byteOffset;
|
||||
}
|
||||
|
||||
/** Just write the bytes to the file */
|
||||
protected function _commit($bytes)
|
||||
{
|
||||
fwrite($this->_getWriteHandle(), $bytes);
|
||||
$this->_resetReadHandle();
|
||||
}
|
||||
|
||||
/** Not used */
|
||||
protected function _flush()
|
||||
{
|
||||
}
|
||||
|
||||
/** Get the resource for reading */
|
||||
private function _getReadHandle()
|
||||
{
|
||||
if (!isset($this->_reader)) {
|
||||
$pointer = @fopen($this->_path, 'rb');
|
||||
if (!$pointer) {
|
||||
throw new Swift_IoException(
|
||||
'Unable to open file for reading ['.$this->_path.']'
|
||||
);
|
||||
}
|
||||
$this->_reader = $pointer;
|
||||
if ($this->_offset != 0) {
|
||||
$this->_getReadStreamSeekableStatus();
|
||||
$this->_seekReadStreamToPosition($this->_offset);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_reader;
|
||||
}
|
||||
|
||||
/** Get the resource for writing */
|
||||
private function _getWriteHandle()
|
||||
{
|
||||
if (!isset($this->_writer)) {
|
||||
if (!$this->_writer = fopen($this->_path, $this->_mode)) {
|
||||
throw new Swift_IoException(
|
||||
'Unable to open file for writing ['.$this->_path.']'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_writer;
|
||||
}
|
||||
|
||||
/** Force a reload of the resource for reading */
|
||||
private function _resetReadHandle()
|
||||
{
|
||||
if (isset($this->_reader)) {
|
||||
fclose($this->_reader);
|
||||
$this->_reader = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Check if ReadOnly Stream is seekable */
|
||||
private function _getReadStreamSeekableStatus()
|
||||
{
|
||||
$metas = stream_get_meta_data($this->_reader);
|
||||
$this->_seekable = $metas['seekable'];
|
||||
}
|
||||
|
||||
/** Streams in a readOnly stream ensuring copy if needed */
|
||||
private function _seekReadStreamToPosition($offset)
|
||||
{
|
||||
if ($this->_seekable === null) {
|
||||
$this->_getReadStreamSeekableStatus();
|
||||
}
|
||||
if ($this->_seekable === false) {
|
||||
$currentPos = ftell($this->_reader);
|
||||
if ($currentPos < $offset) {
|
||||
$toDiscard = $offset - $currentPos;
|
||||
fread($this->_reader, $toDiscard);
|
||||
|
||||
return;
|
||||
}
|
||||
$this->_copyReadStream();
|
||||
}
|
||||
fseek($this->_reader, $offset, SEEK_SET);
|
||||
}
|
||||
|
||||
/** Copy a readOnly Stream to ensure seekability */
|
||||
private function _copyReadStream()
|
||||
{
|
||||
if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) {
|
||||
/* We have opened a php:// Stream Should work without problem */
|
||||
} elseif (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) {
|
||||
/* We have opened a tmpfile */
|
||||
} else {
|
||||
throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available');
|
||||
}
|
||||
$currentPos = ftell($this->_reader);
|
||||
fclose($this->_reader);
|
||||
$source = fopen($this->_path, 'rb');
|
||||
if (!$source) {
|
||||
throw new Swift_IoException('Unable to open file for copying ['.$this->_path.']');
|
||||
}
|
||||
fseek($tmpFile, 0, SEEK_SET);
|
||||
while (!feof($source)) {
|
||||
fwrite($tmpFile, fread($source, 4096));
|
||||
}
|
||||
fseek($tmpFile, $currentPos, SEEK_SET);
|
||||
fclose($source);
|
||||
$this->_reader = $tmpFile;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Romain-Geissler
|
||||
*/
|
||||
class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$filePath = tempnam(sys_get_temp_dir(), 'FileByteStream');
|
||||
|
||||
if ($filePath === false) {
|
||||
throw new Swift_IoException('Failed to retrieve temporary file name.');
|
||||
}
|
||||
|
||||
parent::__construct($filePath, true);
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if (($content = file_get_contents($this->getPath())) === false) {
|
||||
throw new Swift_IoException('Failed to get temporary file content.');
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (file_exists($this->getPath())) {
|
||||
@unlink($this->getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Analyzes characters for a specific character set.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
interface Swift_CharacterReader
|
||||
{
|
||||
const MAP_TYPE_INVALID = 0x01;
|
||||
const MAP_TYPE_FIXED_LEN = 0x02;
|
||||
const MAP_TYPE_POSITIONS = 0x03;
|
||||
|
||||
/**
|
||||
* Returns the complete character map.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $startOffset
|
||||
* @param array $currentMap
|
||||
* @param mixed $ignoredChars
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars);
|
||||
|
||||
/**
|
||||
* Returns the mapType, see constants.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMapType();
|
||||
|
||||
/**
|
||||
* Returns an integer which specifies how many more bytes to read.
|
||||
*
|
||||
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||
* this method again.
|
||||
*
|
||||
* A value of zero means this is already a valid character.
|
||||
* A value of -1 means this cannot possibly be a valid character.
|
||||
*
|
||||
* @param int[] $bytes
|
||||
* @param int $size
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validateByteSequence($bytes, $size);
|
||||
|
||||
/**
|
||||
* Returns the number of bytes which should be read to start each character.
|
||||
*
|
||||
* For fixed width character sets this should be the number of octets-per-character.
|
||||
* For multibyte character sets this will probably be 1.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInitialByteSize();
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides fixed-width byte sizes for reading fixed-width character sets.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader
|
||||
{
|
||||
/**
|
||||
* The number of bytes in a single character.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_width;
|
||||
|
||||
/**
|
||||
* Creates a new GenericFixedWidthReader using $width bytes per character.
|
||||
*
|
||||
* @param int $width
|
||||
*/
|
||||
public function __construct($width)
|
||||
{
|
||||
$this->_width = $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the complete character map.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $startOffset
|
||||
* @param array $currentMap
|
||||
* @param mixed $ignoredChars
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
|
||||
{
|
||||
$strlen = strlen($string);
|
||||
// % and / are CPU intensive, so, maybe find a better way
|
||||
$ignored = $strlen % $this->_width;
|
||||
$ignoredChars = $ignored ? substr($string, -$ignored) : '';
|
||||
$currentMap = $this->_width;
|
||||
|
||||
return ($strlen - $ignored) / $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapType.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getMapType()
|
||||
{
|
||||
return self::MAP_TYPE_FIXED_LEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer which specifies how many more bytes to read.
|
||||
*
|
||||
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||
* this method again.
|
||||
*
|
||||
* A value of zero means this is already a valid character.
|
||||
* A value of -1 means this cannot possibly be a valid character.
|
||||
*
|
||||
* @param string $bytes
|
||||
* @param int $size
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validateByteSequence($bytes, $size)
|
||||
{
|
||||
$needed = $this->_width - $size;
|
||||
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bytes which should be read to start each character.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInitialByteSize()
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Analyzes US-ASCII characters.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader
|
||||
{
|
||||
/**
|
||||
* Returns the complete character map.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $startOffset
|
||||
* @param array $currentMap
|
||||
* @param string $ignoredChars
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
|
||||
{
|
||||
$strlen = strlen($string);
|
||||
$ignoredChars = '';
|
||||
for ($i = 0; $i < $strlen; ++$i) {
|
||||
if ($string[$i] > "\x07F") {
|
||||
// Invalid char
|
||||
$currentMap[$i + $startOffset] = $string[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $strlen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns mapType.
|
||||
*
|
||||
* @return int mapType
|
||||
*/
|
||||
public function getMapType()
|
||||
{
|
||||
return self::MAP_TYPE_INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer which specifies how many more bytes to read.
|
||||
*
|
||||
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||
* this method again.
|
||||
* A value of zero means this is already a valid character.
|
||||
* A value of -1 means this cannot possibly be a valid character.
|
||||
*
|
||||
* @param string $bytes
|
||||
* @param int $size
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validateByteSequence($bytes, $size)
|
||||
{
|
||||
$byte = reset($bytes);
|
||||
if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bytes which should be read to start each character.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInitialByteSize()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Analyzes UTF-8 characters.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader
|
||||
{
|
||||
/** Pre-computed for optimization */
|
||||
private static $length_map = array(
|
||||
// N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x0N
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x1N
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x2N
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x3N
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x4N
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x5N
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x6N
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x7N
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x8N
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x9N
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xAN
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xBN
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN
|
||||
);
|
||||
|
||||
private static $s_length_map = array(
|
||||
"\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1,
|
||||
"\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1,
|
||||
"\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1,
|
||||
"\x18" => 1, "\x19" => 1, "\x1a" => 1, "\x1b" => 1, "\x1c" => 1, "\x1d" => 1, "\x1e" => 1, "\x1f" => 1,
|
||||
"\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1,
|
||||
"\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x2e" => 1, "\x2f" => 1,
|
||||
"\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1,
|
||||
"\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1,
|
||||
"\x40" => 1, "\x41" => 1, "\x42" => 1, "\x43" => 1, "\x44" => 1, "\x45" => 1, "\x46" => 1, "\x47" => 1,
|
||||
"\x48" => 1, "\x49" => 1, "\x4a" => 1, "\x4b" => 1, "\x4c" => 1, "\x4d" => 1, "\x4e" => 1, "\x4f" => 1,
|
||||
"\x50" => 1, "\x51" => 1, "\x52" => 1, "\x53" => 1, "\x54" => 1, "\x55" => 1, "\x56" => 1, "\x57" => 1,
|
||||
"\x58" => 1, "\x59" => 1, "\x5a" => 1, "\x5b" => 1, "\x5c" => 1, "\x5d" => 1, "\x5e" => 1, "\x5f" => 1,
|
||||
"\x60" => 1, "\x61" => 1, "\x62" => 1, "\x63" => 1, "\x64" => 1, "\x65" => 1, "\x66" => 1, "\x67" => 1,
|
||||
"\x68" => 1, "\x69" => 1, "\x6a" => 1, "\x6b" => 1, "\x6c" => 1, "\x6d" => 1, "\x6e" => 1, "\x6f" => 1,
|
||||
"\x70" => 1, "\x71" => 1, "\x72" => 1, "\x73" => 1, "\x74" => 1, "\x75" => 1, "\x76" => 1, "\x77" => 1,
|
||||
"\x78" => 1, "\x79" => 1, "\x7a" => 1, "\x7b" => 1, "\x7c" => 1, "\x7d" => 1, "\x7e" => 1, "\x7f" => 1,
|
||||
"\x80" => 0, "\x81" => 0, "\x82" => 0, "\x83" => 0, "\x84" => 0, "\x85" => 0, "\x86" => 0, "\x87" => 0,
|
||||
"\x88" => 0, "\x89" => 0, "\x8a" => 0, "\x8b" => 0, "\x8c" => 0, "\x8d" => 0, "\x8e" => 0, "\x8f" => 0,
|
||||
"\x90" => 0, "\x91" => 0, "\x92" => 0, "\x93" => 0, "\x94" => 0, "\x95" => 0, "\x96" => 0, "\x97" => 0,
|
||||
"\x98" => 0, "\x99" => 0, "\x9a" => 0, "\x9b" => 0, "\x9c" => 0, "\x9d" => 0, "\x9e" => 0, "\x9f" => 0,
|
||||
"\xa0" => 0, "\xa1" => 0, "\xa2" => 0, "\xa3" => 0, "\xa4" => 0, "\xa5" => 0, "\xa6" => 0, "\xa7" => 0,
|
||||
"\xa8" => 0, "\xa9" => 0, "\xaa" => 0, "\xab" => 0, "\xac" => 0, "\xad" => 0, "\xae" => 0, "\xaf" => 0,
|
||||
"\xb0" => 0, "\xb1" => 0, "\xb2" => 0, "\xb3" => 0, "\xb4" => 0, "\xb5" => 0, "\xb6" => 0, "\xb7" => 0,
|
||||
"\xb8" => 0, "\xb9" => 0, "\xba" => 0, "\xbb" => 0, "\xbc" => 0, "\xbd" => 0, "\xbe" => 0, "\xbf" => 0,
|
||||
"\xc0" => 2, "\xc1" => 2, "\xc2" => 2, "\xc3" => 2, "\xc4" => 2, "\xc5" => 2, "\xc6" => 2, "\xc7" => 2,
|
||||
"\xc8" => 2, "\xc9" => 2, "\xca" => 2, "\xcb" => 2, "\xcc" => 2, "\xcd" => 2, "\xce" => 2, "\xcf" => 2,
|
||||
"\xd0" => 2, "\xd1" => 2, "\xd2" => 2, "\xd3" => 2, "\xd4" => 2, "\xd5" => 2, "\xd6" => 2, "\xd7" => 2,
|
||||
"\xd8" => 2, "\xd9" => 2, "\xda" => 2, "\xdb" => 2, "\xdc" => 2, "\xdd" => 2, "\xde" => 2, "\xdf" => 2,
|
||||
"\xe0" => 3, "\xe1" => 3, "\xe2" => 3, "\xe3" => 3, "\xe4" => 3, "\xe5" => 3, "\xe6" => 3, "\xe7" => 3,
|
||||
"\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3,
|
||||
"\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4,
|
||||
"\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0,
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the complete character map.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $startOffset
|
||||
* @param array $currentMap
|
||||
* @param mixed $ignoredChars
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
|
||||
{
|
||||
if (!isset($currentMap['i']) || !isset($currentMap['p'])) {
|
||||
$currentMap['p'] = $currentMap['i'] = array();
|
||||
}
|
||||
|
||||
$strlen = strlen($string);
|
||||
$charPos = count($currentMap['p']);
|
||||
$foundChars = 0;
|
||||
$invalid = false;
|
||||
for ($i = 0; $i < $strlen; ++$i) {
|
||||
$char = $string[$i];
|
||||
$size = self::$s_length_map[$char];
|
||||
if ($size == 0) {
|
||||
/* char is invalid, we must wait for a resync */
|
||||
$invalid = true;
|
||||
continue;
|
||||
} else {
|
||||
if ($invalid == true) {
|
||||
/* We mark the chars as invalid and start a new char */
|
||||
$currentMap['p'][$charPos + $foundChars] = $startOffset + $i;
|
||||
$currentMap['i'][$charPos + $foundChars] = true;
|
||||
++$foundChars;
|
||||
$invalid = false;
|
||||
}
|
||||
if (($i + $size) > $strlen) {
|
||||
$ignoredChars = substr($string, $i);
|
||||
break;
|
||||
}
|
||||
for ($j = 1; $j < $size; ++$j) {
|
||||
$char = $string[$i + $j];
|
||||
if ($char > "\x7F" && $char < "\xC0") {
|
||||
// Valid - continue parsing
|
||||
} else {
|
||||
/* char is invalid, we must wait for a resync */
|
||||
$invalid = true;
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
/* Ok we got a complete char here */
|
||||
$currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size;
|
||||
$i += $j - 1;
|
||||
++$foundChars;
|
||||
}
|
||||
}
|
||||
|
||||
return $foundChars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns mapType.
|
||||
*
|
||||
* @return int mapType
|
||||
*/
|
||||
public function getMapType()
|
||||
{
|
||||
return self::MAP_TYPE_POSITIONS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer which specifies how many more bytes to read.
|
||||
*
|
||||
* A positive integer indicates the number of more bytes to fetch before invoking
|
||||
* this method again.
|
||||
* A value of zero means this is already a valid character.
|
||||
* A value of -1 means this cannot possibly be a valid character.
|
||||
*
|
||||
* @param string $bytes
|
||||
* @param int $size
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validateByteSequence($bytes, $size)
|
||||
{
|
||||
if ($size < 1) {
|
||||
return -1;
|
||||
}
|
||||
$needed = self::$length_map[$bytes[0]] - $size;
|
||||
|
||||
return $needed > -1 ? $needed : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bytes which should be read to start each character.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInitialByteSize()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A factory for creating CharacterReaders.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_CharacterReaderFactory
|
||||
{
|
||||
/**
|
||||
* Returns a CharacterReader suitable for the charset applied.
|
||||
*
|
||||
* @param string $charset
|
||||
*
|
||||
* @return Swift_CharacterReader
|
||||
*/
|
||||
public function getReaderFor($charset);
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Standard factory for creating CharacterReaders.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift_CharacterReaderFactory
|
||||
{
|
||||
/**
|
||||
* A map of charset patterns to their implementation classes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_map = array();
|
||||
|
||||
/**
|
||||
* Factories which have already been loaded.
|
||||
*
|
||||
* @var Swift_CharacterReaderFactory[]
|
||||
*/
|
||||
private static $_loaded = array();
|
||||
|
||||
/**
|
||||
* Creates a new CharacterReaderFactory.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
if (count(self::$_map) > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$prefix = 'Swift_CharacterReader_';
|
||||
|
||||
$singleByte = array(
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(1),
|
||||
);
|
||||
|
||||
$doubleByte = array(
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(2),
|
||||
);
|
||||
|
||||
$fourBytes = array(
|
||||
'class' => $prefix.'GenericFixedWidthReader',
|
||||
'constructor' => array(4),
|
||||
);
|
||||
|
||||
// Utf-8
|
||||
self::$_map['utf-?8'] = array(
|
||||
'class' => $prefix.'Utf8Reader',
|
||||
'constructor' => array(),
|
||||
);
|
||||
|
||||
//7-8 bit charsets
|
||||
self::$_map['(us-)?ascii'] = $singleByte;
|
||||
self::$_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte;
|
||||
self::$_map['windows-?125[0-9]'] = $singleByte;
|
||||
self::$_map['cp-?[0-9]+'] = $singleByte;
|
||||
self::$_map['ansi'] = $singleByte;
|
||||
self::$_map['macintosh'] = $singleByte;
|
||||
self::$_map['koi-?7'] = $singleByte;
|
||||
self::$_map['koi-?8-?.+'] = $singleByte;
|
||||
self::$_map['mik'] = $singleByte;
|
||||
self::$_map['(cork|t1)'] = $singleByte;
|
||||
self::$_map['v?iscii'] = $singleByte;
|
||||
|
||||
//16 bits
|
||||
self::$_map['(ucs-?2|utf-?16)'] = $doubleByte;
|
||||
|
||||
//32 bits
|
||||
self::$_map['(ucs-?4|utf-?32)'] = $fourBytes;
|
||||
|
||||
// Fallback
|
||||
self::$_map['.*'] = $singleByte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a CharacterReader suitable for the charset applied.
|
||||
*
|
||||
* @param string $charset
|
||||
*
|
||||
* @return Swift_CharacterReader
|
||||
*/
|
||||
public function getReaderFor($charset)
|
||||
{
|
||||
$charset = trim(strtolower($charset));
|
||||
foreach (self::$_map as $pattern => $spec) {
|
||||
$re = '/^'.$pattern.'$/D';
|
||||
if (preg_match($re, $charset)) {
|
||||
if (!array_key_exists($pattern, self::$_loaded)) {
|
||||
$reflector = new ReflectionClass($spec['class']);
|
||||
if ($reflector->getConstructor()) {
|
||||
$reader = $reflector->newInstanceArgs($spec['constructor']);
|
||||
} else {
|
||||
$reader = $reflector->newInstance();
|
||||
}
|
||||
self::$_loaded[$pattern] = $reader;
|
||||
}
|
||||
|
||||
return self::$_loaded[$pattern];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An abstract means of reading and writing data in terms of characters as opposed
|
||||
* to bytes.
|
||||
*
|
||||
* Classes implementing this interface may use a subsystem which requires less
|
||||
* memory than working with large strings of data.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_CharacterStream
|
||||
{
|
||||
/**
|
||||
* Set the character set used in this CharacterStream.
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public function setCharacterSet($charset);
|
||||
|
||||
/**
|
||||
* Set the CharacterReaderFactory for multi charset support.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory
|
||||
*/
|
||||
public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory);
|
||||
|
||||
/**
|
||||
* Overwrite this character stream using the byte sequence in the byte stream.
|
||||
*
|
||||
* @param Swift_OutputByteStream $os output stream to read from
|
||||
*/
|
||||
public function importByteStream(Swift_OutputByteStream $os);
|
||||
|
||||
/**
|
||||
* Import a string a bytes into this CharacterStream, overwriting any existing
|
||||
* data in the stream.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function importString($string);
|
||||
|
||||
/**
|
||||
* Read $length characters from the stream and move the internal pointer
|
||||
* $length further into the stream.
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function read($length);
|
||||
|
||||
/**
|
||||
* Read $length characters from the stream and return a 1-dimensional array
|
||||
* containing there octet values.
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function readBytes($length);
|
||||
|
||||
/**
|
||||
* Write $chars to the end of the stream.
|
||||
*
|
||||
* @param string $chars
|
||||
*/
|
||||
public function write($chars);
|
||||
|
||||
/**
|
||||
* Move the internal pointer to $charOffset in the stream.
|
||||
*
|
||||
* @param int $charOffset
|
||||
*/
|
||||
public function setPointer($charOffset);
|
||||
|
||||
/**
|
||||
* Empty the stream and reset the internal pointer.
|
||||
*/
|
||||
public function flushContents();
|
||||
}
|
||||
@@ -1,293 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A CharacterStream implementation which stores characters in an internal array.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStream
|
||||
{
|
||||
/** A map of byte values and their respective characters */
|
||||
private static $_charMap;
|
||||
|
||||
/** A map of characters and their derivative byte values */
|
||||
private static $_byteMap;
|
||||
|
||||
/** The char reader (lazy-loaded) for the current charset */
|
||||
private $_charReader;
|
||||
|
||||
/** A factory for creating CharacterReader instances */
|
||||
private $_charReaderFactory;
|
||||
|
||||
/** The character set this stream is using */
|
||||
private $_charset;
|
||||
|
||||
/** Array of characters */
|
||||
private $_array = array();
|
||||
|
||||
/** Size of the array of character */
|
||||
private $_array_size = array();
|
||||
|
||||
/** The current character offset in the stream */
|
||||
private $_offset = 0;
|
||||
|
||||
/**
|
||||
* Create a new CharacterStream with the given $chars, if set.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory for loading validators
|
||||
* @param string $charset used in the stream
|
||||
*/
|
||||
public function __construct(Swift_CharacterReaderFactory $factory, $charset)
|
||||
{
|
||||
self::_initializeMaps();
|
||||
$this->setCharacterReaderFactory($factory);
|
||||
$this->setCharacterSet($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the character set used in this CharacterStream.
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public function setCharacterSet($charset)
|
||||
{
|
||||
$this->_charset = $charset;
|
||||
$this->_charReader = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CharacterReaderFactory for multi charset support.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory
|
||||
*/
|
||||
public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory)
|
||||
{
|
||||
$this->_charReaderFactory = $factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite this character stream using the byte sequence in the byte stream.
|
||||
*
|
||||
* @param Swift_OutputByteStream $os output stream to read from
|
||||
*/
|
||||
public function importByteStream(Swift_OutputByteStream $os)
|
||||
{
|
||||
if (!isset($this->_charReader)) {
|
||||
$this->_charReader = $this->_charReaderFactory
|
||||
->getReaderFor($this->_charset);
|
||||
}
|
||||
|
||||
$startLength = $this->_charReader->getInitialByteSize();
|
||||
while (false !== $bytes = $os->read($startLength)) {
|
||||
$c = array();
|
||||
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
|
||||
$c[] = self::$_byteMap[$bytes[$i]];
|
||||
}
|
||||
$size = count($c);
|
||||
$need = $this->_charReader
|
||||
->validateByteSequence($c, $size);
|
||||
if ($need > 0 &&
|
||||
false !== $bytes = $os->read($need)) {
|
||||
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
|
||||
$c[] = self::$_byteMap[$bytes[$i]];
|
||||
}
|
||||
}
|
||||
$this->_array[] = $c;
|
||||
++$this->_array_size;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a string a bytes into this CharacterStream, overwriting any existing
|
||||
* data in the stream.
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function importString($string)
|
||||
{
|
||||
$this->flushContents();
|
||||
$this->write($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read $length characters from the stream and move the internal pointer
|
||||
* $length further into the stream.
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function read($length)
|
||||
{
|
||||
if ($this->_offset == $this->_array_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Don't use array slice
|
||||
$arrays = array();
|
||||
$end = $length + $this->_offset;
|
||||
for ($i = $this->_offset; $i < $end; ++$i) {
|
||||
if (!isset($this->_array[$i])) {
|
||||
break;
|
||||
}
|
||||
$arrays[] = $this->_array[$i];
|
||||
}
|
||||
$this->_offset += $i - $this->_offset; // Limit function calls
|
||||
$chars = false;
|
||||
foreach ($arrays as $array) {
|
||||
$chars .= implode('', array_map('chr', $array));
|
||||
}
|
||||
|
||||
return $chars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read $length characters from the stream and return a 1-dimensional array
|
||||
* containing there octet values.
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function readBytes($length)
|
||||
{
|
||||
if ($this->_offset == $this->_array_size) {
|
||||
return false;
|
||||
}
|
||||
$arrays = array();
|
||||
$end = $length + $this->_offset;
|
||||
for ($i = $this->_offset; $i < $end; ++$i) {
|
||||
if (!isset($this->_array[$i])) {
|
||||
break;
|
||||
}
|
||||
$arrays[] = $this->_array[$i];
|
||||
}
|
||||
$this->_offset += ($i - $this->_offset); // Limit function calls
|
||||
|
||||
return call_user_func_array('array_merge', $arrays);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write $chars to the end of the stream.
|
||||
*
|
||||
* @param string $chars
|
||||
*/
|
||||
public function write($chars)
|
||||
{
|
||||
if (!isset($this->_charReader)) {
|
||||
$this->_charReader = $this->_charReaderFactory->getReaderFor(
|
||||
$this->_charset);
|
||||
}
|
||||
|
||||
$startLength = $this->_charReader->getInitialByteSize();
|
||||
|
||||
$fp = fopen('php://memory', 'w+b');
|
||||
fwrite($fp, $chars);
|
||||
unset($chars);
|
||||
fseek($fp, 0, SEEK_SET);
|
||||
|
||||
$buffer = array(0);
|
||||
$buf_pos = 1;
|
||||
$buf_len = 1;
|
||||
$has_datas = true;
|
||||
do {
|
||||
$bytes = array();
|
||||
// Buffer Filing
|
||||
if ($buf_len - $buf_pos < $startLength) {
|
||||
$buf = array_splice($buffer, $buf_pos);
|
||||
$new = $this->_reloadBuffer($fp, 100);
|
||||
if ($new) {
|
||||
$buffer = array_merge($buf, $new);
|
||||
$buf_len = count($buffer);
|
||||
$buf_pos = 0;
|
||||
} else {
|
||||
$has_datas = false;
|
||||
}
|
||||
}
|
||||
if ($buf_len - $buf_pos > 0) {
|
||||
$size = 0;
|
||||
for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i) {
|
||||
++$size;
|
||||
$bytes[] = $buffer[$buf_pos++];
|
||||
}
|
||||
$need = $this->_charReader->validateByteSequence(
|
||||
$bytes, $size);
|
||||
if ($need > 0) {
|
||||
if ($buf_len - $buf_pos < $need) {
|
||||
$new = $this->_reloadBuffer($fp, $need);
|
||||
|
||||
if ($new) {
|
||||
$buffer = array_merge($buffer, $new);
|
||||
$buf_len = count($buffer);
|
||||
}
|
||||
}
|
||||
for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) {
|
||||
$bytes[] = $buffer[$buf_pos++];
|
||||
}
|
||||
}
|
||||
$this->_array[] = $bytes;
|
||||
++$this->_array_size;
|
||||
}
|
||||
} while ($has_datas);
|
||||
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the internal pointer to $charOffset in the stream.
|
||||
*
|
||||
* @param int $charOffset
|
||||
*/
|
||||
public function setPointer($charOffset)
|
||||
{
|
||||
if ($charOffset > $this->_array_size) {
|
||||
$charOffset = $this->_array_size;
|
||||
} elseif ($charOffset < 0) {
|
||||
$charOffset = 0;
|
||||
}
|
||||
$this->_offset = $charOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the stream and reset the internal pointer.
|
||||
*/
|
||||
public function flushContents()
|
||||
{
|
||||
$this->_offset = 0;
|
||||
$this->_array = array();
|
||||
$this->_array_size = 0;
|
||||
}
|
||||
|
||||
private function _reloadBuffer($fp, $len)
|
||||
{
|
||||
if (!feof($fp) && ($bytes = fread($fp, $len)) !== false) {
|
||||
$buf = array();
|
||||
for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) {
|
||||
$buf[] = self::$_byteMap[$bytes[$i]];
|
||||
}
|
||||
|
||||
return $buf;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function _initializeMaps()
|
||||
{
|
||||
if (!isset(self::$_charMap)) {
|
||||
self::$_charMap = array();
|
||||
for ($byte = 0; $byte < 256; ++$byte) {
|
||||
self::$_charMap[$byte] = chr($byte);
|
||||
}
|
||||
self::$_byteMap = array_flip(self::$_charMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,267 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A CharacterStream implementation which stores characters in an internal array.
|
||||
*
|
||||
* @author Xavier De Cock <xdecock@gmail.com>
|
||||
*/
|
||||
class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream
|
||||
{
|
||||
/**
|
||||
* The char reader (lazy-loaded) for the current charset.
|
||||
*
|
||||
* @var Swift_CharacterReader
|
||||
*/
|
||||
private $_charReader;
|
||||
|
||||
/**
|
||||
* A factory for creating CharacterReader instances.
|
||||
*
|
||||
* @var Swift_CharacterReaderFactory
|
||||
*/
|
||||
private $_charReaderFactory;
|
||||
|
||||
/**
|
||||
* The character set this stream is using.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_charset;
|
||||
|
||||
/**
|
||||
* The data's stored as-is.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_datas = '';
|
||||
|
||||
/**
|
||||
* Number of bytes in the stream.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_datasSize = 0;
|
||||
|
||||
/**
|
||||
* Map.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
private $_map;
|
||||
|
||||
/**
|
||||
* Map Type.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_mapType = 0;
|
||||
|
||||
/**
|
||||
* Number of characters in the stream.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_charCount = 0;
|
||||
|
||||
/**
|
||||
* Position in the stream.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_currentPos = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory
|
||||
* @param string $charset
|
||||
*/
|
||||
public function __construct(Swift_CharacterReaderFactory $factory, $charset)
|
||||
{
|
||||
$this->setCharacterReaderFactory($factory);
|
||||
$this->setCharacterSet($charset);
|
||||
}
|
||||
|
||||
/* -- Changing parameters of the stream -- */
|
||||
|
||||
/**
|
||||
* Set the character set used in this CharacterStream.
|
||||
*
|
||||
* @param string $charset
|
||||
*/
|
||||
public function setCharacterSet($charset)
|
||||
{
|
||||
$this->_charset = $charset;
|
||||
$this->_charReader = null;
|
||||
$this->_mapType = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the CharacterReaderFactory for multi charset support.
|
||||
*
|
||||
* @param Swift_CharacterReaderFactory $factory
|
||||
*/
|
||||
public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory)
|
||||
{
|
||||
$this->_charReaderFactory = $factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::flushContents()
|
||||
*/
|
||||
public function flushContents()
|
||||
{
|
||||
$this->_datas = null;
|
||||
$this->_map = null;
|
||||
$this->_charCount = 0;
|
||||
$this->_currentPos = 0;
|
||||
$this->_datasSize = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::importByteStream()
|
||||
*
|
||||
* @param Swift_OutputByteStream $os
|
||||
*/
|
||||
public function importByteStream(Swift_OutputByteStream $os)
|
||||
{
|
||||
$this->flushContents();
|
||||
$blocks = 512;
|
||||
$os->setReadPointer(0);
|
||||
while (false !== ($read = $os->read($blocks))) {
|
||||
$this->write($read);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::importString()
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function importString($string)
|
||||
{
|
||||
$this->flushContents();
|
||||
$this->write($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::read()
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function read($length)
|
||||
{
|
||||
if ($this->_currentPos >= $this->_charCount) {
|
||||
return false;
|
||||
}
|
||||
$ret = false;
|
||||
$length = $this->_currentPos + $length > $this->_charCount ? $this->_charCount - $this->_currentPos : $length;
|
||||
switch ($this->_mapType) {
|
||||
case Swift_CharacterReader::MAP_TYPE_FIXED_LEN:
|
||||
$len = $length * $this->_map;
|
||||
$ret = substr($this->_datas,
|
||||
$this->_currentPos * $this->_map,
|
||||
$len);
|
||||
$this->_currentPos += $length;
|
||||
break;
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_INVALID:
|
||||
$ret = '';
|
||||
for (; $this->_currentPos < $length; ++$this->_currentPos) {
|
||||
if (isset($this->_map[$this->_currentPos])) {
|
||||
$ret .= '?';
|
||||
} else {
|
||||
$ret .= $this->_datas[$this->_currentPos];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Swift_CharacterReader::MAP_TYPE_POSITIONS:
|
||||
$end = $this->_currentPos + $length;
|
||||
$end = $end > $this->_charCount ? $this->_charCount : $end;
|
||||
$ret = '';
|
||||
$start = 0;
|
||||
if ($this->_currentPos > 0) {
|
||||
$start = $this->_map['p'][$this->_currentPos - 1];
|
||||
}
|
||||
$to = $start;
|
||||
for (; $this->_currentPos < $end; ++$this->_currentPos) {
|
||||
if (isset($this->_map['i'][$this->_currentPos])) {
|
||||
$ret .= substr($this->_datas, $start, $to - $start).'?';
|
||||
$start = $this->_map['p'][$this->_currentPos];
|
||||
} else {
|
||||
$to = $this->_map['p'][$this->_currentPos];
|
||||
}
|
||||
}
|
||||
$ret .= substr($this->_datas, $start, $to - $start);
|
||||
break;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::readBytes()
|
||||
*
|
||||
* @param int $length
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function readBytes($length)
|
||||
{
|
||||
$read = $this->read($length);
|
||||
if ($read !== false) {
|
||||
$ret = array_map('ord', str_split($read, 1));
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::setPointer()
|
||||
*
|
||||
* @param int $charOffset
|
||||
*/
|
||||
public function setPointer($charOffset)
|
||||
{
|
||||
if ($this->_charCount < $charOffset) {
|
||||
$charOffset = $this->_charCount;
|
||||
}
|
||||
$this->_currentPos = $charOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Swift_CharacterStream::write()
|
||||
*
|
||||
* @param string $chars
|
||||
*/
|
||||
public function write($chars)
|
||||
{
|
||||
if (!isset($this->_charReader)) {
|
||||
$this->_charReader = $this->_charReaderFactory->getReaderFor(
|
||||
$this->_charset);
|
||||
$this->_map = array();
|
||||
$this->_mapType = $this->_charReader->getMapType();
|
||||
}
|
||||
$ignored = '';
|
||||
$this->_datas .= $chars;
|
||||
$this->_charCount += $this->_charReader->getCharPositions(substr($this->_datas, $this->_datasSize), $this->_datasSize, $this->_map, $ignored);
|
||||
if ($ignored !== false) {
|
||||
$this->_datasSize = strlen($this->_datas) - strlen($ignored);
|
||||
} else {
|
||||
$this->_datasSize = strlen($this->_datas);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2009 Fabien Potencier <fabien.potencier@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for Spools (implements time and message limits).
|
||||
*
|
||||
* @author Fabien Potencier
|
||||
*/
|
||||
abstract class Swift_ConfigurableSpool implements Swift_Spool
|
||||
{
|
||||
/** The maximum number of messages to send per flush */
|
||||
private $_message_limit;
|
||||
|
||||
/** The time limit per flush */
|
||||
private $_time_limit;
|
||||
|
||||
/**
|
||||
* Sets the maximum number of messages to send per flush.
|
||||
*
|
||||
* @param int $limit
|
||||
*/
|
||||
public function setMessageLimit($limit)
|
||||
{
|
||||
$this->_message_limit = (int) $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum number of messages to send per flush.
|
||||
*
|
||||
* @return int The limit
|
||||
*/
|
||||
public function getMessageLimit()
|
||||
{
|
||||
return $this->_message_limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time limit (in seconds) per flush.
|
||||
*
|
||||
* @param int $limit The limit
|
||||
*/
|
||||
public function setTimeLimit($limit)
|
||||
{
|
||||
$this->_time_limit = (int) $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time limit (in seconds) per flush.
|
||||
*
|
||||
* @return int The limit
|
||||
*/
|
||||
public function getTimeLimit()
|
||||
{
|
||||
return $this->_time_limit;
|
||||
}
|
||||
}
|
||||
@@ -1,373 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dependency Injection container.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_DependencyContainer
|
||||
{
|
||||
/** Constant for literal value types */
|
||||
const TYPE_VALUE = 0x0001;
|
||||
|
||||
/** Constant for new instance types */
|
||||
const TYPE_INSTANCE = 0x0010;
|
||||
|
||||
/** Constant for shared instance types */
|
||||
const TYPE_SHARED = 0x0100;
|
||||
|
||||
/** Constant for aliases */
|
||||
const TYPE_ALIAS = 0x1000;
|
||||
|
||||
/** Singleton instance */
|
||||
private static $_instance = null;
|
||||
|
||||
/** The data container */
|
||||
private $_store = array();
|
||||
|
||||
/** The current endpoint in the data container */
|
||||
private $_endPoint;
|
||||
|
||||
/**
|
||||
* Constructor should not be used.
|
||||
*
|
||||
* Use {@link getInstance()} instead.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a singleton of the DependencyContainer.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (!isset(self::$_instance)) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* List the names of all items stored in the Container.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listItems()
|
||||
{
|
||||
return array_keys($this->_store);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if an item is registered in this container with the given name.
|
||||
*
|
||||
* @see register()
|
||||
*
|
||||
* @param string $itemName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($itemName)
|
||||
{
|
||||
return array_key_exists($itemName, $this->_store)
|
||||
&& isset($this->_store[$itemName]['lookupType']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the item with the given $itemName.
|
||||
*
|
||||
* @see register()
|
||||
*
|
||||
* @param string $itemName
|
||||
*
|
||||
* @throws Swift_DependencyException If the dependency is not found
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function lookup($itemName)
|
||||
{
|
||||
if (!$this->has($itemName)) {
|
||||
throw new Swift_DependencyException(
|
||||
'Cannot lookup dependency "'.$itemName.'" since it is not registered.'
|
||||
);
|
||||
}
|
||||
|
||||
switch ($this->_store[$itemName]['lookupType']) {
|
||||
case self::TYPE_ALIAS:
|
||||
return $this->_createAlias($itemName);
|
||||
case self::TYPE_VALUE:
|
||||
return $this->_getValue($itemName);
|
||||
case self::TYPE_INSTANCE:
|
||||
return $this->_createNewInstance($itemName);
|
||||
case self::TYPE_SHARED:
|
||||
return $this->_createSharedInstance($itemName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an array of arguments passed to the constructor of $itemName.
|
||||
*
|
||||
* @param string $itemName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createDependenciesFor($itemName)
|
||||
{
|
||||
$args = array();
|
||||
if (isset($this->_store[$itemName]['args'])) {
|
||||
$args = $this->_resolveArgs($this->_store[$itemName]['args']);
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new dependency with $itemName.
|
||||
*
|
||||
* This method returns the current DependencyContainer instance because it
|
||||
* requires the use of the fluid interface to set the specific details for the
|
||||
* dependency.
|
||||
*
|
||||
* @see asNewInstanceOf(), asSharedInstanceOf(), asValue()
|
||||
*
|
||||
* @param string $itemName
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function register($itemName)
|
||||
{
|
||||
$this->_store[$itemName] = array();
|
||||
$this->_endPoint = &$this->_store[$itemName];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the previously registered item as a literal value.
|
||||
*
|
||||
* {@link register()} must be called before this will work.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function asValue($value)
|
||||
{
|
||||
$endPoint = &$this->_getEndPoint();
|
||||
$endPoint['lookupType'] = self::TYPE_VALUE;
|
||||
$endPoint['value'] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the previously registered item as an alias of another item.
|
||||
*
|
||||
* @param string $lookup
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function asAliasOf($lookup)
|
||||
{
|
||||
$endPoint = &$this->_getEndPoint();
|
||||
$endPoint['lookupType'] = self::TYPE_ALIAS;
|
||||
$endPoint['ref'] = $lookup;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the previously registered item as a new instance of $className.
|
||||
*
|
||||
* {@link register()} must be called before this will work.
|
||||
* Any arguments can be set with {@link withDependencies()},
|
||||
* {@link addConstructorValue()} or {@link addConstructorLookup()}.
|
||||
*
|
||||
* @see withDependencies(), addConstructorValue(), addConstructorLookup()
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function asNewInstanceOf($className)
|
||||
{
|
||||
$endPoint = &$this->_getEndPoint();
|
||||
$endPoint['lookupType'] = self::TYPE_INSTANCE;
|
||||
$endPoint['className'] = $className;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the previously registered item as a shared instance of $className.
|
||||
*
|
||||
* {@link register()} must be called before this will work.
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function asSharedInstanceOf($className)
|
||||
{
|
||||
$endPoint = &$this->_getEndPoint();
|
||||
$endPoint['lookupType'] = self::TYPE_SHARED;
|
||||
$endPoint['className'] = $className;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a list of injected dependencies for the previously registered item.
|
||||
*
|
||||
* This method takes an array of lookup names.
|
||||
*
|
||||
* @see addConstructorValue(), addConstructorLookup()
|
||||
*
|
||||
* @param array $lookups
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function withDependencies(array $lookups)
|
||||
{
|
||||
$endPoint = &$this->_getEndPoint();
|
||||
$endPoint['args'] = array();
|
||||
foreach ($lookups as $lookup) {
|
||||
$this->addConstructorLookup($lookup);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a literal (non looked up) value for the constructor of the
|
||||
* previously registered item.
|
||||
*
|
||||
* @see withDependencies(), addConstructorLookup()
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addConstructorValue($value)
|
||||
{
|
||||
$endPoint = &$this->_getEndPoint();
|
||||
if (!isset($endPoint['args'])) {
|
||||
$endPoint['args'] = array();
|
||||
}
|
||||
$endPoint['args'][] = array('type' => 'value', 'item' => $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a dependency lookup for the constructor of the previously
|
||||
* registered item.
|
||||
*
|
||||
* @see withDependencies(), addConstructorValue()
|
||||
*
|
||||
* @param string $lookup
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addConstructorLookup($lookup)
|
||||
{
|
||||
$endPoint = &$this->_getEndPoint();
|
||||
if (!isset($this->_endPoint['args'])) {
|
||||
$endPoint['args'] = array();
|
||||
}
|
||||
$endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** Get the literal value with $itemName */
|
||||
private function _getValue($itemName)
|
||||
{
|
||||
return $this->_store[$itemName]['value'];
|
||||
}
|
||||
|
||||
/** Resolve an alias to another item */
|
||||
private function _createAlias($itemName)
|
||||
{
|
||||
return $this->lookup($this->_store[$itemName]['ref']);
|
||||
}
|
||||
|
||||
/** Create a fresh instance of $itemName */
|
||||
private function _createNewInstance($itemName)
|
||||
{
|
||||
$reflector = new ReflectionClass($this->_store[$itemName]['className']);
|
||||
if ($reflector->getConstructor()) {
|
||||
return $reflector->newInstanceArgs(
|
||||
$this->createDependenciesFor($itemName)
|
||||
);
|
||||
}
|
||||
|
||||
return $reflector->newInstance();
|
||||
}
|
||||
|
||||
/** Create and register a shared instance of $itemName */
|
||||
private function _createSharedInstance($itemName)
|
||||
{
|
||||
if (!isset($this->_store[$itemName]['instance'])) {
|
||||
$this->_store[$itemName]['instance'] = $this->_createNewInstance($itemName);
|
||||
}
|
||||
|
||||
return $this->_store[$itemName]['instance'];
|
||||
}
|
||||
|
||||
/** Get the current endpoint in the store */
|
||||
private function &_getEndPoint()
|
||||
{
|
||||
if (!isset($this->_endPoint)) {
|
||||
throw new BadMethodCallException(
|
||||
'Component must first be registered by calling register()'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_endPoint;
|
||||
}
|
||||
|
||||
/** Get an argument list with dependencies resolved */
|
||||
private function _resolveArgs(array $args)
|
||||
{
|
||||
$resolved = array();
|
||||
foreach ($args as $argDefinition) {
|
||||
switch ($argDefinition['type']) {
|
||||
case 'lookup':
|
||||
$resolved[] = $this->_lookupRecursive($argDefinition['item']);
|
||||
break;
|
||||
case 'value':
|
||||
$resolved[] = $argDefinition['item'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $resolved;
|
||||
}
|
||||
|
||||
/** Resolve a single dependency with an collections */
|
||||
private function _lookupRecursive($item)
|
||||
{
|
||||
if (is_array($item)) {
|
||||
$collection = array();
|
||||
foreach ($item as $k => $v) {
|
||||
$collection[$k] = $this->_lookupRecursive($v);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
return $this->lookup($item);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* DependencyException gets thrown when a requested dependency is missing.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_DependencyException extends Swift_SwiftException
|
||||
{
|
||||
/**
|
||||
* Create a new DependencyException with $message.
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function __construct($message)
|
||||
{
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An embedded file, in a multipart message.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile
|
||||
{
|
||||
/**
|
||||
* Create a new EmbeddedFile.
|
||||
*
|
||||
* Details may be optionally provided to the constructor.
|
||||
*
|
||||
* @param string|Swift_OutputByteStream $data
|
||||
* @param string $filename
|
||||
* @param string $contentType
|
||||
*/
|
||||
public function __construct($data = null, $filename = null, $contentType = null)
|
||||
{
|
||||
call_user_func_array(
|
||||
array($this, 'Swift_Mime_EmbeddedFile::__construct'),
|
||||
Swift_DependencyContainer::getInstance()
|
||||
->createDependenciesFor('mime.embeddedfile')
|
||||
);
|
||||
|
||||
$this->setBody($data);
|
||||
$this->setFilename($filename);
|
||||
if ($contentType) {
|
||||
$this->setContentType($contentType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new EmbeddedFile.
|
||||
*
|
||||
* @param string|Swift_OutputByteStream $data
|
||||
* @param string $filename
|
||||
* @param string $contentType
|
||||
*
|
||||
* @return Swift_Mime_EmbeddedFile
|
||||
*/
|
||||
public static function newInstance($data = null, $filename = null, $contentType = null)
|
||||
{
|
||||
return new self($data, $filename, $contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new EmbeddedFile from a filesystem path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return Swift_Mime_EmbeddedFile
|
||||
*/
|
||||
public static function fromPath($path)
|
||||
{
|
||||
return self::newInstance()->setFile(
|
||||
new Swift_ByteStream_FileByteStream($path)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of SwiftMailer.
|
||||
* (c) 2004-2009 Chris Corbyn
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface for all Encoder schemes.
|
||||
*
|
||||
* @author Chris Corbyn
|
||||
*/
|
||||
interface Swift_Encoder extends Swift_Mime_CharsetObserver
|
||||
{
|
||||
/**
|
||||
* Encode a given string to produce an encoded string.
|
||||
*
|
||||
* @param string $string
|
||||
* @param int $firstLineOffset if first line needs to be shorter
|
||||
* @param int $maxLineLength - 0 indicates the default length for this encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user