diff options
Diffstat (limited to 'hugo/libraries/plugins/transformations')
32 files changed, 2546 insertions, 0 deletions
diff --git a/hugo/libraries/plugins/transformations/Application_Octetstream_Download.class.php b/hugo/libraries/plugins/transformations/Application_Octetstream_Download.class.php new file mode 100644 index 0000000..46bda70 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Application_Octetstream_Download.class.php @@ -0,0 +1,64 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Application OctetStream Download Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Download + */ +if (! defined('PHPMYADMIN')) { + exit; +} +/* Get the download transformations interface */ +require_once 'abstract/DownloadTransformationsPlugin.class.php'; + +/** + * Handles the download transformation for application octetstream + * + * @package PhpMyAdmin-Transformations + * @subpackage Download + */ +class Application_Octetstream_Download extends DownloadTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Application"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "OctetStream"; + } +} + +/** + * Function to call Application_Octetstream_Download::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Application_Octetstream_Download_getInfo() +{ + return Application_Octetstream_Download::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Application_Octetstream_Hex.class.php b/hugo/libraries/plugins/transformations/Application_Octetstream_Hex.class.php new file mode 100644 index 0000000..f876abb --- /dev/null +++ b/hugo/libraries/plugins/transformations/Application_Octetstream_Hex.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Application OctetStream Hex Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Hex + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the hex transformations interface */ +require_once 'abstract/HexTransformationsPlugin.class.php'; + +/** + * Handles the hex transformation for application octetstream + * + * @package PhpMyAdmin-Transformations + * @subpackage Hex + */ +class Application_Octetstream_Hex extends HexTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Application"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "OctetStream"; + } +} + +/** + * Function to call Application_Octetstream_Hex::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Application_Octetstream_Hex_getInfo() +{ + return Application_Octetstream_Hex::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Image_JPEG_Inline.class.php b/hugo/libraries/plugins/transformations/Image_JPEG_Inline.class.php new file mode 100644 index 0000000..934df75 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Image_JPEG_Inline.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Image JPEG Inline Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Inline + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the inline transformations interface */ +require_once 'abstract/InlineTransformationsPlugin.class.php'; + +/** + * Handles the inline transformation for image jpeg + * + * @package PhpMyAdmin-Transformations + * @subpackage Inline + */ +class Image_JPEG_Inline extends InlineTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Image"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "JPEG"; + } +} + +/** + * Function to call Image_JPEG_Inline::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Image_JPEG_Inline_getInfo() +{ + return Image_JPEG_Inline::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Image_JPEG_Link.class.php b/hugo/libraries/plugins/transformations/Image_JPEG_Link.class.php new file mode 100644 index 0000000..fc04040 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Image_JPEG_Link.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Image JPEG Link Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Link + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the link transformations interface */ +require_once 'abstract/ImageLinkTransformationsPlugin.class.php'; + +/** + * Handles the link transformation for image jpeg + * + * @package PhpMyAdmin-Transformations + * @subpackage Link + */ +class Image_JPEG_Link extends ImageLinkTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Image"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "JPEG"; + } +} + +/** + * Function to call Image_JPEG_Link::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Image_JPEG_Link_getInfo() +{ + return Image_JPEG_Link::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Image_PNG_Inline.class.php b/hugo/libraries/plugins/transformations/Image_PNG_Inline.class.php new file mode 100644 index 0000000..e879c23 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Image_PNG_Inline.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Image PNG Inline Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Inline + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the inline transformations interface */ +require_once 'abstract/InlineTransformationsPlugin.class.php'; + +/** + * Handles the inline transformation for image png + * + * @package PhpMyAdmin-Transformations + * @subpackage Inline + */ +class Image_PNG_Inline extends InlineTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Image"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "PNG"; + } +} + +/** + * Function to call Image_PNG_Inline::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Image_PNG_Inline_getInfo() +{ + return Image_PNG_Inline::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/README b/hugo/libraries/plugins/transformations/README new file mode 100644 index 0000000..7d7a125 --- /dev/null +++ b/hugo/libraries/plugins/transformations/README @@ -0,0 +1,4 @@ +TRANSFORMATION USAGE (Garvin Hicking, <me@supergarv.de>) +==================== + +See the documentation for complete instructions on how to use transformation plugins. diff --git a/hugo/libraries/plugins/transformations/TEMPLATE b/hugo/libraries/plugins/transformations/TEMPLATE new file mode 100644 index 0000000..b0ce2f0 --- /dev/null +++ b/hugo/libraries/plugins/transformations/TEMPLATE @@ -0,0 +1,68 @@ +<?php +// vim: expandtab sw=4 ts=4 sts=4: +/** + * This file contains the basic structure for a specific MIME Type and Subtype + * transformations class. + * For instructions, read the documentation + * + * @package PhpMyAdmin-Transformations + * @subpackage [TransformationName] + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the [TransformationName] transformations interface */ +require_once 'abstract/[TransformationName]TransformationsPlugin.class.php'; + +/** + * Handles the [TransformationName] transformation for [MIMEType] - [MIMESubtype] + * + * @package PhpMyAdmin + */ +class [MIMEType]_[MIMESubtype]_[TransformationName] + extends [TransformationName]TransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "[MIMEType]"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "[MIMESubtype]"; + } +} + +/** + * Function to call [MIMEType]_[MIMESubtype]_[TransformationName]::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ + +function [MIMEType]_[MIMESubtype]_[TransformationName]_getInfo() +{ + return [MIMEType]_[MIMESubtype]_[TransformationName]::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/TEMPLATE_ABSTRACT b/hugo/libraries/plugins/transformations/TEMPLATE_ABSTRACT new file mode 100644 index 0000000..5cc1d26 --- /dev/null +++ b/hugo/libraries/plugins/transformations/TEMPLATE_ABSTRACT @@ -0,0 +1,89 @@ +<?php +// vim: expandtab sw=4 ts=4 sts=4: +/** + * This file contains the basic structure for an abstract class defining a + * transformation. + * For instructions, read the documentation + * + * @package PhpMyAdmin-Transformations + * @subpackage [TransformationName] + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the [TransformationName] transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class [TransformationName]TransformationsPlugin + extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Description of the transformation.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + // possibly use a global transform and feed it with special options + + // further operations on $buffer using the $options[] array. + + // You can evaluate the propagated $meta Object. It's contained fields are described in http://www.php.net/mysql_fetch_field. + // This stored information can be used to get the field information about the transformed field. + // $meta->mimetype contains the original MimeType of the field (i.e. 'text/plain', 'image/jpeg' etc.) + + return $buffer; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the TransformationName of the specific plugin + * + * @return string + */ + public static function getName() + { + return "[TransformationName]"; + } +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Append.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Append.class.php new file mode 100644 index 0000000..8a102cb --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Append.class.php @@ -0,0 +1,66 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain Append Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Append + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the append transformations interface */ +require_once 'abstract/AppendTransformationsPlugin.class.php'; + +/** + * Handles the append transformation for text plain. + * Has one option: the text to be appended (default '') + * + * @package PhpMyAdmin-Transformations + * @subpackage Append + */ +class Text_Plain_Append extends AppendTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Append::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Append_getInfo() +{ + return Text_Plain_Append::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Dateformat.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Dateformat.class.php new file mode 100644 index 0000000..ed8c9e5 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Dateformat.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain Date Format Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage DateFormat + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the date format transformations interface */ +require_once 'abstract/DateFormatTransformationsPlugin.class.php'; + +/** + * Handles the date format transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage DateFormat + */ +class Text_Plain_Dateformat extends DateFormatTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Dateformat::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Dateformat_getInfo() +{ + return Text_Plain_Dateformat::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_External.class.php b/hugo/libraries/plugins/transformations/Text_Plain_External.class.php new file mode 100644 index 0000000..1aa321a --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_External.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain External Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage External + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the external transformations interface */ +require_once 'abstract/ExternalTransformationsPlugin.class.php'; + +/** + * Handles the external transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage External + */ +class Text_Plain_External extends ExternalTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_External::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_External_getInfo() +{ + return Text_Plain_External::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Formatted.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Formatted.class.php new file mode 100644 index 0000000..5c6b683 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Formatted.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain Formatted Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Formatted + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the formatted transformations interface */ +require_once 'abstract/FormattedTransformationsPlugin.class.php'; + +/** + * Handles the formatted transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage Formatted + */ +class Text_Plain_Formatted extends FormattedTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Formatted::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Formatted_getInfo() +{ + return Text_Plain_Formatted::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Imagelink.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Imagelink.class.php new file mode 100644 index 0000000..4cb1800 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Imagelink.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain Image Link Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage ImageLink + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the image link transformations interface */ +require_once 'abstract/TextImageLinkTransformationsPlugin.class.php'; + +/** + * Handles the image link transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage ImageLink + */ +class Text_Plain_Imagelink extends TextImageLinkTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Imagelink::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Imagelink_getInfo() +{ + return Text_Plain_Imagelink::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Link.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Link.class.php new file mode 100644 index 0000000..1e64203 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Link.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain Link Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Link + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the link transformations interface */ +require_once 'abstract/TextLinkTransformationsPlugin.class.php'; + +/** + * Handles the link transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage Link + */ +class Text_Plain_Link extends TextLinkTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Link::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Link_getInfo() +{ + return Text_Plain_Link::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Longtoipv4.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Longtoipv4.class.php new file mode 100644 index 0000000..44eea50 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Longtoipv4.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain Long To IPv4 Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage LongToIPv4 + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the long to ipv4 transformations interface */ +require_once 'abstract/LongToIPv4TransformationsPlugin.class.php'; + +/** + * Handles the long to ipv4 transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage LongToIPv4 + */ +class Text_Plain_Longtoipv4 extends LongToIPv4TransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Longtoipv4::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Longtoipv4_getInfo() +{ + return Text_Plain_Longtoipv4::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Sql.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Sql.class.php new file mode 100644 index 0000000..cc92491 --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Sql.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain SQL Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage SQL + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the sql transformations interface */ +require_once 'abstract/SQLTransformationsPlugin.class.php'; + +/** + * Handles the sql transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage SQL + */ +class Text_Plain_Sql extends SQLTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Sql::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Sql_getInfo() +{ + return Text_Plain_Sql::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/Text_Plain_Substring.class.php b/hugo/libraries/plugins/transformations/Text_Plain_Substring.class.php new file mode 100644 index 0000000..b04231f --- /dev/null +++ b/hugo/libraries/plugins/transformations/Text_Plain_Substring.class.php @@ -0,0 +1,65 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Text Plain Substring Transformations plugin for phpMyAdmin + * + * @package PhpMyAdmin-Transformations + * @subpackage Substring + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the substring transformations interface */ +require_once 'abstract/SubstringTransformationsPlugin.class.php'; + +/** + * Handles the substring transformation for text plain + * + * @package PhpMyAdmin-Transformations + * @subpackage Substring + */ +class Text_Plain_Substring extends SubstringTransformationsPlugin +{ + /** + * Gets the plugin`s MIME type + * + * @return string + */ + public static function getMIMEType() + { + return "Text"; + } + + /** + * Gets the plugin`s MIME subtype + * + * @return string + */ + public static function getMIMESubtype() + { + return "Plain"; + } +} + +/** + * Function to call Text_Plain_Substring::getInfo(); + * + * Temporary workaround for bug #3783 : + * Calling a method from a variable class is not possible before PHP 5.3. + * + * This function is called by PMA_getTransformationDescription() + * in libraries/transformations.lib.php using a variable to construct it's name. + * This function then calls the static method. + * + * Don't use this function unless you are affected by the same issue. + * Call the static method directly instead. + * + * @deprecated + * @return string Info about transformation class + */ +function Text_Plain_Substring_getInfo() +{ + return Text_Plain_Substring::getInfo(); +} +?> diff --git a/hugo/libraries/plugins/transformations/abstract/AppendTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/AppendTransformationsPlugin.class.php new file mode 100644 index 0000000..0fc3b4d --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/AppendTransformationsPlugin.class.php @@ -0,0 +1,86 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the append transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Append + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the append transformations plugins. + * + * @package PhpMyAdmin-Transformations + * @subpackage Append + */ +abstract class AppendTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Appends text to a string. The only option is the text to be appended' + . ' (enclosed in single quotes, default empty string).' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + if (! isset($options[0]) || $options[0] == '') { + $options[0] = ''; + } + //just append the option to the original text + $newtext = $buffer . htmlspecialchars($options[0]); + + return $newtext; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Append"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php new file mode 100644 index 0000000..530379f --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/DateFormatTransformationsPlugin.class.php @@ -0,0 +1,178 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the date format transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage DateFormat + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the date format transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class DateFormatTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp' + . ' column as formatted date. The first option is the offset (in' + . ' hours) which will be added to the timestamp (Default: 0). Use' + . ' second option to specify a different date/time format string.' + . ' Third option determines whether you want to see local date or' + . ' UTC one (use "local" or "utc" strings) for that. According to' + . ' that, date format has different value - for "local" see the' + . ' documentation for PHP\'s strftime() function and for "utc" it' + . ' is done using gmdate() function.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + // possibly use a global transform and feed it with special options + + // further operations on $buffer using the $options[] array. + if (empty($options[0])) { + $options[0] = 0; + } + + if (empty($options[2])) { + $options[2] = 'local'; + } else { + $options[2] = strtolower($options[2]); + } + + if (empty($options[1])) { + if ($options[2] == 'local') { + $options[1] = __('%B %d, %Y at %I:%M %p'); + } else { + $options[1] = 'Y-m-d H:i:s'; + } + } + + $timestamp = -1; + + // INT columns will be treated as UNIX timestamps + // and need to be detected before the verification for + // MySQL TIMESTAMP + if ($meta->type == 'int') { + $timestamp = $buffer; + + // Detect TIMESTAMP(6 | 8 | 10 | 12 | 14) + // TIMESTAMP (2 | 4) not supported here. + // (Note: prior to MySQL 4.1, TIMESTAMP has a display size + // for example TIMESTAMP(8) means YYYYMMDD) + } else if (preg_match('/^(\d{2}){3,7}$/', $buffer)) { + + if (strlen($buffer) == 14 || strlen($buffer) == 8) { + $offset = 4; + } else { + $offset = 2; + } + + $d = array(); + $d['year'] = substr($buffer, 0, $offset); + $d['month'] = substr($buffer, $offset, 2); + $d['day'] = substr($buffer, $offset + 2, 2); + $d['hour'] = substr($buffer, $offset + 4, 2); + $d['minute'] = substr($buffer, $offset + 6, 2); + $d['second'] = substr($buffer, $offset + 8, 2); + + if (checkdate($d['month'], $d['day'], $d['year'])) { + $timestamp = mktime( + $d['hour'], + $d['minute'], + $d['second'], + $d['month'], + $d['day'], + $d['year'] + ); + } + // If all fails, assume one of the dozens of valid strtime() syntaxes + // (http://www.gnu.org/manual/tar-1.12/html_chapter/tar_7.html) + } else { + if (preg_match('/^[0-9]\d{1,9}$/', $buffer)) { + $timestamp = (int)$buffer; + } else { + $timestamp = strtotime($buffer); + } + } + + // If all above failed, maybe it's a Unix timestamp already? + if ($timestamp < 0 && preg_match('/^[1-9]\d{1,9}$/', $buffer)) { + $timestamp = $buffer; + } + + // Reformat a valid timestamp + if ($timestamp >= 0) { + $timestamp -= $options[0] * 60 * 60; + $source = $buffer; + if ($options[2] == 'local') { + $text = PMA_Util::localisedDate( + $timestamp, + $options[1] + ); + } elseif ($options[2] == 'utc') { + $text = gmdate($options[1], $timestamp); + } else { + $text = 'INVALID DATE TYPE'; + } + $buffer = '<dfn onclick="alert(\'' . $source . '\');" title="' + . $source . '">' . $text . '</dfn>'; + } + + return $buffer; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Date Format"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/DownloadTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/DownloadTransformationsPlugin.class.php new file mode 100644 index 0000000..82eda40 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/DownloadTransformationsPlugin.class.php @@ -0,0 +1,110 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the download transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Download + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the download transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class DownloadTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays a link to download the binary data of the column. You can' + . ' use the first option to specify the filename, or use the second' + . ' option as the name of a column which contains the filename. If' + . ' you use the second option, you need to set the first option to' + . ' the empty string.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + global $row, $fields_meta; + + if (isset($options[0]) && !empty($options[0])) { + $cn = $options[0]; // filename + } else { + if (isset($options[1]) && !empty($options[1])) { + foreach ($fields_meta as $key => $val) { + if ($val->name == $options[1]) { + $pos = $key; + break; + } + } + if (isset($pos)) { + $cn = $row[$pos]; + } + } + if (empty($cn)) { + $cn = 'binary_file.dat'; + } + } + + return sprintf( + '<a href="transformation_wrapper.php%s&ct=application' + . '/octet-stream&cn=%s" title="%s">%s</a>', + $options['wrapper_link'], + urlencode($cn), + htmlspecialchars($cn), + htmlspecialchars($cn) + ); + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Download"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/ExternalTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/ExternalTransformationsPlugin.class.php new file mode 100644 index 0000000..f93f069 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/ExternalTransformationsPlugin.class.php @@ -0,0 +1,182 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the external transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage External + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the external transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class ExternalTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'LINUX ONLY: Launches an external application and feeds it the column' + . ' data via standard input. Returns the standard output of the' + . ' application. The default is Tidy, to pretty-print HTML code.' + . ' For security reasons, you have to manually edit the file' + . ' libraries/plugins/transformations/Text_Plain_External' + . '.class.php and list the tools you want to make available.' + . ' The first option is then the number of the program you want to' + . ' use and the second option is the parameters for the program.' + . ' The third option, if set to 1, will convert the output using' + . ' htmlspecialchars() (Default 1). The fourth option, if set to 1,' + . ' will prevent wrapping and ensure that the output appears all on' + . ' one line (Default 1).' + ); + } + + /** + * Enables no-wrapping + * + * @param array $options transformation options + * + * @return bool + */ + public function applyTransformationNoWrap($options = array()) + { + if (! isset($options[3]) || $options[3] == '') { + $nowrap = true; + } elseif ($options[3] == '1' || $options[3] == 1) { + $nowrap = true; + } else { + $nowrap = false; + } + + return $nowrap; + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + // possibly use a global transform and feed it with special options + + // further operations on $buffer using the $options[] array. + + $allowed_programs = array(); + + // + // WARNING: + // + // It's up to administrator to allow anything here. Note that users may + // specify any parameters, so when programs allow output redirection or + // any other possibly dangerous operations, you should write wrapper + // script that will publish only functions you really want. + // + // Add here program definitions like (note that these are NOT safe + // programs): + // + //$allowed_programs[0] = '/usr/local/bin/tidy'; + //$allowed_programs[1] = '/usr/local/bin/validate'; + + // no-op when no allowed programs + if (count($allowed_programs) == 0) { + return $buffer; + } + + if (! isset($options[0]) + || $options[0] == '' + || ! isset($allowed_programs[$options[0]]) + ) { + $program = $allowed_programs[0]; + } else { + $program = $allowed_programs[$options[0]]; + } + + if (!isset($options[1]) || $options[1] == '') { + $poptions = '-f /dev/null -i -wrap -q'; + } else { + $poptions = $options[1]; + } + + if (!isset($options[2]) || $options[2] == '') { + $options[2] = 1; + } + + if (!isset($options[3]) || $options[3] == '') { + $options[3] = 1; + } + + // needs PHP >= 4.3.0 + $newstring = ''; + $descriptorspec = array( + 0 => array("pipe", "r"), + 1 => array("pipe", "w") + ); + $process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes); + if (is_resource($process)) { + fwrite($pipes[0], $buffer); + fclose($pipes[0]); + + while (!feof($pipes[1])) { + $newstring .= fgets($pipes[1], 1024); + } + fclose($pipes[1]); + // we don't currently use the return value + proc_close($process); + } + + if ($options[2] == 1 || $options[2] == '2') { + $retstring = htmlspecialchars($newstring); + } else { + $retstring = $newstring; + } + + return $retstring; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "External"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/FormattedTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/FormattedTransformationsPlugin.class.php new file mode 100644 index 0000000..e6bb8d9 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/FormattedTransformationsPlugin.class.php @@ -0,0 +1,80 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the formatted transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Formatted + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the formatted transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class FormattedTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays the contents of the column as-is, without running it' + . ' through htmlspecialchars(). That is, the column is assumed' + . ' to contain valid HTML.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + return $buffer; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Formatted"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/HexTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/HexTransformationsPlugin.class.php new file mode 100644 index 0000000..8022da9 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/HexTransformationsPlugin.class.php @@ -0,0 +1,91 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the hex transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Hex + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the hex transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class HexTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays hexadecimal representation of data. Optional first' + . ' parameter specifies how often space will be added (defaults' + . ' to 2 nibbles).' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + // possibly use a global transform and feed it with special options + if (!isset($options[0])) { + $options[0] = 2; + } else { + $options[0] = (int)$options[0]; + } + + if ($options[0] < 1) { + return bin2hex($buffer); + } else { + return chunk_split(bin2hex($buffer), $options[0], ' '); + } + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Hex"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/ImageLinkTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/ImageLinkTransformationsPlugin.class.php new file mode 100644 index 0000000..456f102 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/ImageLinkTransformationsPlugin.class.php @@ -0,0 +1,89 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the link transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Link + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; +/* For PMA_transformation_global_html_replace */ +require_once 'libraries/transformations.lib.php'; + +/** + * Provides common methods for all of the link transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class ImageLinkTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays a link to download this image.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + $transform_options = array ( + 'string' => '<a href="transformation_wrapper.php' + . $options['wrapper_link'] . '" alt="[__BUFFER__]">[BLOB]</a>' + ); + $buffer = PMA_transformation_global_html_replace( + $buffer, + $transform_options + ); + + return $buffer; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Link"; + } +} +?> diff --git a/hugo/libraries/plugins/transformations/abstract/InlineTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/InlineTransformationsPlugin.class.php new file mode 100644 index 0000000..b1ef0ae --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/InlineTransformationsPlugin.class.php @@ -0,0 +1,103 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the inline transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Inline + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; +/* For PMA_transformation_global_html_replace */ +require_once 'libraries/transformations.lib.php'; + +/** + * Provides common methods for all of the inline transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class InlineTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays a clickable thumbnail. The options are the maximum width' + . ' and height in pixels. The original aspect ratio is preserved.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + if (PMA_IS_GD2) { + $transform_options = array ( + 'string' => '<a href="transformation_wrapper.php' + . $options['wrapper_link'] + . '" target="_blank"><img src="transformation_wrapper.php' + . $options['wrapper_link'] . '&resize=jpeg&newWidth=' + . (isset($options[0]) ? $options[0] : '100') . '&newHeight=' + . (isset($options[1]) ? $options[1] : 100) + . '" alt="[__BUFFER__]" border="0" /></a>' + ); + } else { + $transform_options = array ( + 'string' => '<img src="transformation_wrapper.php' + . $options['wrapper_link'] + . '" alt="[__BUFFER__]" width="320" height="240" />' + ); + } + $buffer = PMA_transformation_global_html_replace( + $buffer, + $transform_options + ); + + return $buffer; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Inline"; + } +} +?> diff --git a/hugo/libraries/plugins/transformations/abstract/LongToIPv4TransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/LongToIPv4TransformationsPlugin.class.php new file mode 100644 index 0000000..58dda95 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/LongToIPv4TransformationsPlugin.class.php @@ -0,0 +1,83 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the long to IPv4 transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage LongToIPv4 + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the long to IPv4 transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class LongToIPv4TransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Converts an (IPv4) Internet network address into a string in' + . ' Internet standard dotted format.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + if ($buffer < 0 || $buffer > 4294967295) { + return $buffer; + } + + return long2ip($buffer); + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Long To IPv4"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/SQLTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/SQLTransformationsPlugin.class.php new file mode 100644 index 0000000..2123cdb --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/SQLTransformationsPlugin.class.php @@ -0,0 +1,81 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the SQL transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage SQL + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the SQL transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class SQLTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Formats text as SQL query with syntax highlighting.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + $result = PMA_SQP_formatHtml(PMA_SQP_parse($buffer)); + // Need to clear error state not to break subsequent queries display. + PMA_SQP_resetError(); + return $result; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "SQL"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php new file mode 100644 index 0000000..2de48e6 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/SubstringTransformationsPlugin.class.php @@ -0,0 +1,116 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the substring transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Substring + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; + +/** + * Provides common methods for all of the substring transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class SubstringTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays a part of a string. The first option is the number of' + . ' characters to skip from the beginning of the string (Default 0).' + . ' The second option is the number of characters to return (Default:' + . ' until end of string). The third option is the string to append' + . ' and/or prepend when truncation occurs (Default: "…").' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + // possibly use a global transform and feed it with special options + + // further operations on $buffer using the $options[] array. + if (!isset($options[0]) || $options[0] == '') { + $options[0] = 0; + } + + if (!isset($options[1]) || $options[1] == '') { + $options[1] = 'all'; + } + + if (!isset($options[2]) || $options[2] == '') { + $options[2] = '…'; + } + + $newtext = ''; + if ($options[1] != 'all') { + $newtext = PMA_substr($buffer, $options[0], $options[1]); + } else { + $newtext = PMA_substr($buffer, $options[0]); + } + + $length = strlen($newtext); + $baselength = strlen($buffer); + if ($length != $baselength) { + if ($options[0] != 0) { + $newtext = $options[2] . $newtext; + } + + if (($length + $options[0]) != $baselength) { + $newtext .= $options[2]; + } + } + + return $newtext; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Substring"; + } +} +?>
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/abstract/TextImageLinkTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/TextImageLinkTransformationsPlugin.class.php new file mode 100644 index 0000000..054b2f9 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/TextImageLinkTransformationsPlugin.class.php @@ -0,0 +1,96 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the image link transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage ImageLink + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; +/* For PMA_transformation_global_html_replace */ +require_once 'libraries/transformations.lib.php'; + +/** + * Provides common methods for all of the image link transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class TextImageLinkTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays an image and a link; the column contains the filename. The' + . ' first option is a URL prefix like "http://www.example.com/". The' + . ' second and third options are the width and the height in pixels.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + $transform_options = array ( + 'string' => '<a href="' . (isset($options[0]) ? $options[0] : '') + . $buffer . '" target="_blank"><img src="' + . (isset($options[0]) ? $options[0] : '') . $buffer + . '" border="0" width="' . (isset($options[1]) ? $options[1] : 100) + . '" height="' . (isset($options[2]) ? $options[2] : 50) . '" />' + . $buffer . '</a>' + ); + + $buffer = PMA_transformation_global_html_replace( + $buffer, + $transform_options + ); + + return $buffer; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Image Link"; + } +} +?> diff --git a/hugo/libraries/plugins/transformations/abstract/TextLinkTransformationsPlugin.class.php b/hugo/libraries/plugins/transformations/abstract/TextLinkTransformationsPlugin.class.php new file mode 100644 index 0000000..f61e9a9 --- /dev/null +++ b/hugo/libraries/plugins/transformations/abstract/TextLinkTransformationsPlugin.class.php @@ -0,0 +1,100 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Abstract class for the link transformations plugins + * + * @package PhpMyAdmin-Transformations + * @subpackage Link + */ +if (! defined('PHPMYADMIN')) { + exit; +} + +/* Get the transformations interface */ +require_once 'libraries/plugins/TransformationsPlugin.class.php'; +/* For PMA_transformation_global_html_replace */ +require_once 'libraries/transformations.lib.php'; + +/** + * Provides common methods for all of the link transformations plugins. + * + * @package PhpMyAdmin + */ +abstract class TextLinkTransformationsPlugin extends TransformationsPlugin +{ + /** + * Gets the transformation description of the specific plugin + * + * @return string + */ + public static function getInfo() + { + return __( + 'Displays a link; the column contains the filename. The first option' + . ' is a URL prefix like "http://www.example.com/". The second option' + . ' is a title for the link.' + ); + } + + /** + * Does the actual work of each specific transformations plugin. + * + * @param string $buffer text to be transformed + * @param array $options transformation options + * @param string $meta meta information + * + * @return void + */ + public function applyTransformation($buffer, $options = array(), $meta = '') + { + + $append_part = (isset($options[2]) && $options[2]) ? '' : $buffer; + + $transform_options = array ( + 'string' => '<a href="' + . PMA_linkURL((isset($options[0]) ? $options[0] : '') . $append_part) + . '" title="' + . htmlspecialchars(isset($options[1]) ? $options[1] : '') + . '" target="_new">' + . htmlspecialchars(isset($options[1]) ? $options[1] : $buffer) + . '</a>' + ); + + $buffer = PMA_transformation_global_html_replace( + $buffer, + $transform_options + ); + + return $buffer; + } + + /** + * This method is called when any PluginManager to which the observer + * is attached calls PluginManager::notify() + * + * @param SplSubject $subject The PluginManager notifying the observer + * of an update. + * + * @todo implement + * @return void + */ + public function update (SplSubject $subject) + { + ; + } + + + /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ + + + /** + * Gets the transformation name of the specific plugin + * + * @return string + */ + public static function getName() + { + return "Link"; + } +} +?> diff --git a/hugo/libraries/plugins/transformations/generator_main_class.sh b/hugo/libraries/plugins/transformations/generator_main_class.sh new file mode 100755 index 0000000..0587667 --- /dev/null +++ b/hugo/libraries/plugins/transformations/generator_main_class.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Shell script that creates only the main class for a new transformation +# plug-in, using a template +# +# $1: MIMEType +# $2: MIMESubtype +# $3: Transformation Name + +if [ $# != 3 ] +then + echo -e "Usage: ./generator_main_class.sh MIMEType MIMESubtype TransformationName\n" + exit 65 +fi + +./generator_plugin.sh "$1" "$2" "$3" "--generate_only_main_class"
\ No newline at end of file diff --git a/hugo/libraries/plugins/transformations/generator_plugin.sh b/hugo/libraries/plugins/transformations/generator_plugin.sh new file mode 100755 index 0000000..225a2cb --- /dev/null +++ b/hugo/libraries/plugins/transformations/generator_plugin.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# Shell script that creates a new transformation plug-in (both main and +# abstract class) using a template. +# +# The 'description' parameter will add a new entry in the language file. +# Watch out for special escaping. +# +# $1: MIMEType +# $2: MIMESubtype +# $3: Transformation Name +# $4: (optional) Description + +echo $# +if [ $# -ne 3 -a $# -ne 4 ]; then + echo -e "Usage: ./generator_plugin.sh MIMEType MIMESubtype TransformationName [Description]\n" + exit 65 +fi + +# make sure that the MIME Type, MIME Subtype and Transformation names +# are in the correct format + +# make all names lowercase +MT="`echo $1 | tr [:upper:] [:lower:]`" +MS="`echo $2 | tr [:upper:] [:lower:]`" +TN="`echo $3 | tr [:upper:] [:lower:]`" +# make first letter uppercase +MT="${MT^}" +MS="${MS^}" +TN="${TN^}" +# make the first letter after each underscore uppercase +MT="`echo $MT`" +MT="`echo $MT | sed -e 's/_./\U&\E/g'`" +MS="`echo $MS`" +MS="`echo $MS | sed -e 's/_./\U&\E/g'`" +TN="`echo $TN`" +TN="`echo $TN | sed -e 's/_./\U&\E/g'`" + +# define the name of the main class file and of its template +ClassFile=$MT\_$MS\_$TN.class.php +Template=TEMPLATE +# define the name of the abstract class file and its template +AbstractClassFile=abstract/"$TN"TransformationsPlugin.class.php +AbstractTemplate=TEMPLATE_ABSTRACT +# replace template names with argument names +sed "s/\[MIMEType]/$MT/; s/\[MIMESubtype\]/$MS/; s/\[TransformationName\]/$TN/;" < $Template > $ClassFile +echo "Created $ClassFile" + +GenerateAbstractClass=1 +if [ -n $4 ]; then + if [ "$4" == "--generate_only_main_class" ]; then + if [ -e $AbstractClassFile ]; then + GenerateAbstractClass=0 + fi + fi +fi + +if [ $GenerateAbstractClass -eq 1 ]; then + # replace template names with argument names + sed "s/\[TransformationName\]/$TN/; s/Description of the transformation./$4/;" < $AbstractTemplate > $AbstractClassFile + echo "Created $AbstractClassFile" +fi + +echo ""
\ No newline at end of file |
