2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Abstract class for the substring transformations plugins
6 * @package PhpMyAdmin-Transformations
7 * @subpackage Substring
9 if (! defined('PHPMYADMIN')) {
13 /* Get the transformations interface */
14 require_once 'libraries/plugins/TransformationsPlugin.class.php';
17 * Provides common methods for all of the substring transformations plugins.
21 abstract class SubstringTransformationsPlugin
extends TransformationsPlugin
24 * Gets the transformation description of the specific plugin
28 public static function getInfo()
31 'Displays a part of a string. The first option is the number of'
32 . ' characters to skip from the beginning of the string (Default 0).'
33 . ' The second option is the number of characters to return (Default:'
34 . ' until end of string). The third option is the string to append'
35 . ' and/or prepend when truncation occurs (Default: "…").'
40 * Does the actual work of each specific transformations plugin.
42 * @param string $buffer text to be transformed
43 * @param array $options transformation options
44 * @param string $meta meta information
48 public function applyTransformation($buffer, $options = array(), $meta = '')
50 // possibly use a global transform and feed it with special options
52 // further operations on $buffer using the $options[] array.
53 if (!isset($options[0]) ||
$options[0] == '') {
57 if (!isset($options[1]) ||
$options[1] == '') {
61 if (!isset($options[2]) ||
$options[2] == '') {
66 if ($options[1] != 'all') {
67 $newtext = PMA_substr($buffer, $options[0], $options[1]);
69 $newtext = PMA_substr($buffer, $options[0]);
72 $length = strlen($newtext);
73 $baselength = strlen($buffer);
74 if ($length != $baselength) {
75 if ($options[0] != 0) {
76 $newtext = $options[2] . $newtext;
79 if (($length +
$options[0]) != $baselength) {
80 $newtext .= $options[2];
88 * This method is called when any PluginManager to which the observer
89 * is attached calls PluginManager::notify()
91 * @param SplSubject $subject The PluginManager notifying the observer
97 public function update (SplSubject
$subject)
103 /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
107 * Gets the transformation name of the specific plugin
111 public static function getName()