Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / transformations / abstract / DownloadTransformationsPlugin.class.php
blob82eda40f724a34416b911adaa31a2e2a7e87117b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Abstract class for the download transformations plugins
6 * @package PhpMyAdmin-Transformations
7 * @subpackage Download
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 download transformations plugins.
19 * @package PhpMyAdmin
21 abstract class DownloadTransformationsPlugin 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 link to download the binary data of the column. You can'
32 . ' use the first option to specify the filename, or use the second'
33 . ' option as the name of a column which contains the filename. If'
34 . ' you use the second option, you need to set the first option to'
35 . ' the empty string.'
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 global $row, $fields_meta;
52 if (isset($options[0]) && !empty($options[0])) {
53 $cn = $options[0]; // filename
54 } else {
55 if (isset($options[1]) && !empty($options[1])) {
56 foreach ($fields_meta as $key => $val) {
57 if ($val->name == $options[1]) {
58 $pos = $key;
59 break;
62 if (isset($pos)) {
63 $cn = $row[$pos];
66 if (empty($cn)) {
67 $cn = 'binary_file.dat';
71 return sprintf(
72 '<a href="transformation_wrapper.php%s&amp;ct=application'
73 . '/octet-stream&amp;cn=%s" title="%s">%s</a>',
74 $options['wrapper_link'],
75 urlencode($cn),
76 htmlspecialchars($cn),
77 htmlspecialchars($cn)
81 /**
82 * This method is called when any PluginManager to which the observer
83 * is attached calls PluginManager::notify()
85 * @param SplSubject $subject The PluginManager notifying the observer
86 * of an update.
88 * @todo implement
89 * @return void
91 public function update (SplSubject $subject)
97 /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
101 * Gets the transformation name of the specific plugin
103 * @return string
105 public static function getName()
107 return "Download";