File: text_plain__substr.inc.php

package info (click to toggle)
phpmyadmin 4%3A2.9.1.1-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 13,224 kB
  • ctags: 119,177
  • sloc: php: 148,860; sh: 636; sql: 224; perl: 142
file content (44 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/* $Id: text_plain__substr.inc.php 5523 2004-03-09 15:02:28Z nijel $ */
// vim: expandtab sw=4 ts=4 sts=4:

function PMA_transformation_text_plain__substr($buffer, $options = array(), $meta = '') {
    // possibly use a global transform and feed it with special options:
    // include('./libraries/transformations/global.inc.php');

    // 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;
}

?>