Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / transformations / abstract / SubstringTransformationsPlugin.class.php
blob2de48e6bb04f49ab1566246ee9b5cefdfdc1c5a7
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Abstract class for the substring transformations plugins
6 * @package PhpMyAdmin-Transformations
7 * @subpackage Substring
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /* Get the transformations interface */
14 require_once 'libraries/plugins/TransformationsPlugin.class.php';
16 /**
17 * Provides common methods for all of the substring transformations plugins.
19 * @package PhpMyAdmin
21 abstract class SubstringTransformationsPlugin extends TransformationsPlugin
23 /**
24 * Gets the transformation description of the specific plugin
26 * @return string
28 public static function getInfo()
30 return __(
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: "…").'
39 /**
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
46 * @return void
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] == '') {
54 $options[0] = 0;
57 if (!isset($options[1]) || $options[1] == '') {
58 $options[1] = 'all';
61 if (!isset($options[2]) || $options[2] == '') {
62 $options[2] = '…';
65 $newtext = '';
66 if ($options[1] != 'all') {
67 $newtext = PMA_substr($buffer, $options[0], $options[1]);
68 } else {
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];
84 return $newtext;
87 /**
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
92 * of an update.
94 * @todo implement
95 * @return void
97 public function update (SplSubject $subject)
103 /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
107 * Gets the transformation name of the specific plugin
109 * @return string
111 public static function getName()
113 return "Substring";