source: sandbox/expressoMail1_2/corretor_ortografico/spell_checker/cpaint/cpaint2.inc.php @ 2375

Revision 2375, 26.5 KB checked in by paula.franceschini, 14 years ago (diff)

Ticket #891 - adicionando modulo do corretor ortografico

Line 
1<?php
2/**
3* CPAINT - Cross-Platform Asynchronous INterface Toolkit
4*
5* http://sf.net/projects/cpaint
6*
7* released under the terms of the LGPL
8* see http://www.fsf.org/licensing/licenses/lgpl.txt for details
9*
10* @package    CPAINT
11* @author     Paul Sullivan <wiley14@gmail.com>
12* @author     Dominique Stender <dstender@st-webdevelopment.de>
13* @copyright  Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
14* @version    $Id$
15*/
16 
17//---- includes ----------------------------------------------------------------
18  /**
19  * @include JSON
20  */
21  require_once(dirname(__FILE__) . '/json.php');
22       
23  /**
24  *     @include config
25  */
26  require_once("cpaint2.config.php");
27
28//---- variables ---------------------------------------------------------------
29  $GLOBALS['__cpaint_json'] = new JSON();
30
31//---- error reporting ---------------------------------------------------------
32        error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
33
34//---- classes -----------------------------------------------------------------
35  /**
36  * cpaint base class.
37  *
38  * @package    CPAINT
39  * @access     public
40  * @author     Paul Sullivan <wiley14@gmail.com>
41  * @author     Dominique Stender <dstender@st-webdevelopment.de>
42  * @copyright  Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
43  * @version    2.0.2
44  */
45  class cpaint {
46    /**
47    * version number
48    *
49    * @access private
50    * @var    string $version
51    */
52    var $version = '2.0.2';
53   
54    /**
55    * response type.
56    *
57    * @access   protected
58    * @var      string    $response_type
59    */
60    var $response_type;
61   
62    /**
63    * the basenode ajaxResponse.
64    *
65    * @access   protected
66    * @var      object    $basenode
67    */
68    var $basenode;
69   
70    /**
71    * list of registered methods available through the CPAINT API
72    *
73    * @access   protected
74    * @var      array     $api_functions
75    */
76    var $api_functions;
77   
78    /**
79    * list of registered complex types used in the CPAINT API
80    *
81    * @access protected
82    * @var    array $api_datatypes
83    */
84    var $api_datatypes;
85   
86    /**
87    * whether or not the CPAINT API generates a WSDL when called with ?wsdl querystring
88    *
89    * @access private
90    * @var    boolean $use_wsdl
91    */
92    var $use_wsdl;
93   
94    /**
95    * PHP4 constructor.
96    *
97    * @access   public
98    * @return   void
99    */
100    function cpaint() {
101      $this->__construct();
102    }
103   
104    /**
105    * PHP 5 constructor.
106    *
107    * @access   public
108    * @return   void
109    * @todo -o"Dominique Stender" -ccpaint implement a better debugging
110    */
111    function __construct() {
112      // initialize properties
113      $this->basenode       = new cpaint_node();
114      $this->basenode->set_name('ajaxResponse');
115      $this->basenode->set_attribute('id', '');
116      $this->basenode->set_encoding('UTF-8');
117     
118      $this->response_type  = 'TEXT';
119      $this->api_functions  = array();
120      $this->api_datatypes  = array();
121      $this->use_wsdl       = true;
122     
123      $this->complex_type(array(
124          'name'      => 'cpaintResponseType',
125          'type'      => 'restriction',   // (restriction|complex|list)
126          'base_type' => 'string',        // scalar type of all values, e.g. 'string', for type = (restriction|list) only
127          'values'    => array(           // for type = 'restriction' only: list of allowed values
128            'XML', 'TEXT', 'OBJECT', 'E4X', 'JSON',
129          ),
130        )
131      );
132      $this->complex_type(array(
133          'name'      => 'cpaintDebugLevel',
134          'type'      => 'restriction',
135          'base_type' => 'long',
136          'values'    => array(
137            -1, 0, 1, 2
138          ),
139        )
140      );
141      $this->complex_type(array(
142          'name'      => 'cpaintDebugMessage',
143          'type'      => 'list',
144          'base_type' => 'string',
145        )
146      );
147     
148      $this->complex_type(array(
149          'name'      => 'cpaintRequestHead',
150          'type'      => 'complex',
151          'struct'    => array(
152            0 => array('name' => 'functionName',  'type' => 'string'),
153            1 => array('name' => 'responseType',  'type' => 'cpaintResponseType'),
154            2 => array('name' => 'debugLevel',    'type' => 'cpaintDebugLevel'),
155          ),
156        )
157      );
158     
159      $this->complex_type(array(
160          'name'      => 'cpaintResponseHead',
161          'type'      => 'complex',
162          'struct'    => array(
163            0 => array('name' => 'success',  'type' => 'boolean'),
164            1 => array('name' => 'debugger', 'type' => 'cpaintDebugMessage'),
165          ),
166        )
167      );
168     
169      // determine response type
170      if (isset($_REQUEST['cpaint_response_type'])) {
171        $this->response_type = strtoupper((string) $_REQUEST['cpaint_response_type']);
172      } // end: if
173    }
174
175    /**
176    * calls the user function responsible for this specific call.
177    *
178    * @access   public
179    * @param    string      $input_encoding         input data character encoding, default is UTF-8
180    * @return   void
181    */
182    function start($input_encoding = 'UTF-8') {
183      $user_function  = '';
184      $arguments      = array();
185     
186      // work only if there is no API version request
187      if (!isset($_REQUEST['api_query'])
188        && !isset($_REQUEST['wsdl'])) {
189        $this->basenode->set_encoding($input_encoding);
190       
191        if ($_REQUEST['cpaint_function'] != '') {
192          $user_function  = $_REQUEST['cpaint_function'];
193          $arguments      = $_REQUEST['cpaint_argument'];
194        }
195 
196        // perform character conversion on every argument
197        foreach ($arguments as $key => $value) {
198         
199          if (get_magic_quotes_gpc() == true) {
200            $value = stripslashes($value);
201          } // end: if
202         
203          // convert from JSON string
204          $arguments[$key] = $GLOBALS['__cpaint_json']->parse($value);
205        } // end: foreach
206       
207        $arguments = cpaint_transformer::decode_array($arguments, $this->basenode->get_encoding());
208 
209        if (is_array($this->api_functions[$user_function])
210          && is_callable($this->api_functions[$user_function]['call'])) {
211          // a valid API function is to be called
212          call_user_func_array($this->api_functions[$user_function]['call'], $arguments);
213       
214        } else if ($user_function != '') {
215          // desired function is not registered as API function
216          $this->basenode->set_data('[CPAINT] A function name was passed that is not allowed to execute on this server.');
217        }
218      } // end: if
219    }
220
221    /**
222    * generates and prints the response based on response type supplied by the frontend.
223    *
224    * @access  public
225    * @return  void
226    */
227    function return_data() {
228      // send appropriate headers to avoid caching
229      header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
230      header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
231      header('Cache-Control: no-cache, must-revalidate');
232      header('Pragma: no-cache');
233      header('X-Powered-By: CPAINT v' . $this->version . '/PHP v' . phpversion());
234     
235      // work only if there is no API version request
236     
237      if (!isset($_REQUEST['api_query'])
238        && !isset($_REQUEST['wsdl'])) {
239        // trigger generation of response
240        switch (trim($this->response_type)) {
241 
242          case 'TEXT':
243            header('Content-type: text/plain; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding()));
244            echo cpaint_transformer::toString($this->basenode);
245            break;
246         
247          case 'JSON':
248            header('Content-type: text/plain; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding()));
249            echo cpaint_transformer::toJSON($this->basenode);
250            break;
251               
252          case 'OBJECT':
253          case 'E4X':
254          case 'XML':
255            header('Content-type:  text/xml; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding()));
256            echo '<?xml version="1.0" encoding="' . cpaint_transformer::find_output_charset($this->basenode->get_encoding()) . '"?>'
257                . cpaint_transformer::toXML($this->basenode);
258            break;
259 
260          default:
261            echo 'ERROR: invalid response type \'' . $this->response_type . '\'';
262        } // end: switch
263     
264      } elseif (isset($_REQUEST['api_query'])) {
265        // API version request
266        header('Content-type: text/plain; charset=ISO-8859-1');
267        echo 'CPAINT v' . $this->version . '/PHP v' . phpversion();
268     
269      } elseif ($this->use_wsdl == true
270        && isset($_REQUEST['wsdl'])) {
271       
272        if (is_file(dirname(__FILE__) . '/cpaint2.wsdl.php')
273          && is_readable(dirname(__FILE__) . '/cpaint2.wsdl.php')) {
274         
275          require_once(dirname(__FILE__) . '/cpaint2.wsdl.php');
276         
277          if (class_exists('cpaint_wsdl')) {
278            // create new instance of WSDL library
279            $wsdl = new cpaint_wsdl();
280
281            // build WSDL info
282            header('Content-type: text/xml; charset=UTF-8');
283            echo $wsdl->generate($this->api_functions, $this->api_datatypes);
284
285          } else {
286            header('Content-type: text/plain; charset=ISO-8859-1');
287            echo 'WSDL generator is unavailable';
288          } // end: if
289       
290        } else {
291          header('Content-type: text/plain; charset=ISO-8859-1');
292          echo 'WSDL generator is unavailable';
293        } // end: if
294      } // end: if
295    }
296   
297    /**
298    * registers a new function or method as part of the CPAINT API
299    *
300    * @access public
301    * @param  mixed     $func     function name, array(&$object, 'function_name') or array('class', 'function_name')
302    * @param  array     $input    function input parameters (not yet used by CPAINT and subject to change)
303    * @param  array     $output   function output format (not yed used by CPAINT and subject to change)
304    * @param  string    $comment  description of the functionality
305    * @return boolean
306    */
307    function register($func, $input = array(), $output = array(), $comment = '') {
308      $return_value = false;
309      $input        = (array)   $input;
310      $output       = (array)   $output;
311      $comment      = (string)  $comment;
312     
313      if (is_array($func)
314        && (is_object($func[0]) || is_string($func[0]))
315        && is_string($func[1])
316        && is_callable($func)) {
317       
318        // calling a method of an object
319        $this->api_functions[$func[1]] = array(
320          'call'    => $func,
321          'input'   => $input,
322          'output'  => $output,
323          'comment' => $comment,
324        );
325        $return_value = true;
326       
327      } elseif (is_string($func)) {
328        // calling a standalone function
329        $this->api_functions[$func] = array(
330          'call'    => $func,
331          'input'   => $input,
332          'output'  => $output,
333          'comment' => $comment,
334        );
335        $return_value = true;
336      } // end: if
337     
338      return $return_value;
339    }
340   
341   
342   
343    /**
344    * unregisters a function that is currently part of the CPAINT API.
345    *     
346    * proves useful when the same set of functions is to be used in the
347    * frontend and in some kind of administration environment. you might
348    * want to unregister a few (admin) functions for the frontend in this
349    * case.
350    *
351    * @access public
352    * @param  string     $func     function name
353    * @return boolean
354    */
355    function unregister($func) {
356      $retval = false;
357     
358      if (is_array($this->api_functions[$func])) {
359        unset($this->api_functions[$func]);
360      } // end: if
361   
362      return $retval;
363    }
364   
365   
366   
367    /**
368    * registers a complex data type
369    *
370    * @access public
371    * @param  array     $schema     schema definition for the complex type
372    * @return boolean
373    */
374    function complex_type($schema) {
375      $return_value = false;
376      $schema       = (array)   $schema;
377     
378      if ($schema['name'] != ''
379        && in_array($schema['type'], array('restriction', 'complex', 'list'))) {
380       
381        $this->api_datatypes[] = $schema;
382        $return_value          = true;
383      } // end: if
384   
385      return $return_value;
386    }
387   
388    /**
389    * switches the generation of WSDL on/off. default is on
390    *
391    * @access public
392    * @param  boolean   $state      state of WSDL generation
393    * @return void
394    */
395    function use_wsdl($state) {
396      $this->use_wsdl = (boolean) $state;
397    }
398   
399    /**
400    * adds a new subnode to the basenode.
401    *
402    * will return a reference to it for further processing.
403    *
404    * @access   public
405    * @param    string    $nodename     name of the new node
406    * @param    string    $id           id of the new node
407    * @return   object
408    */
409    function &add_node($nodename, $id = '') {
410      return $this->basenode->add_node($nodename, $id);
411    }
412
413    /**
414    * assigns textual data to the basenode.
415    *
416    * @access   public
417    * @param    mixed    $data    data to assign to this node
418    * @return   void
419    */
420    function set_data($data) {
421      $this->basenode->set_data($data);
422    }
423   
424    /**
425    * returns the data assigned to the basenode.
426    *
427    * @access   public
428    * @return   mixed
429    */
430    function get_data() {
431      return $this->basenode->get_data();
432    }
433   
434    /**
435    * sets the id property of the basenode.
436    *
437    * @deprecated   deprecated since version 2.0.0
438    * @access       public
439    * @param        string    $id      the id
440    * @return       void
441    */
442    function set_id($id) {
443      $this->basenode->set_attribute('id', $id);
444    }
445   
446    /**
447    * gets the id property of the basenode.
448    *
449    * @deprecated   deprecated since version 2.0.0
450    * @access       public
451    * @return       string
452    */
453    function get_id() {
454      return $this->basenode->get_attribute('id');
455    }
456   
457    /**
458    * adds a new attribute to the basenode.
459    *
460    * @access   public
461    * @param    string    $name       attribute name
462    * @param    mixed     $value      attribute value
463    * @return   void
464    */
465    function set_attribute($name, $value) {
466      $this->basenode->set_attribute($name, $value);
467    }
468   
469    /**
470    * retrieves an attribute of the basenode by name.
471    *
472    * @access   public
473    * @param    string    $name       attribute name
474    * @return   string
475    */
476    function get_attribute($name) {
477      return $this->basenode->get_attributes($name);
478    }
479   
480    /**
481    * set name property of the basenode.
482    *
483    * @access   public
484    * @param    string    $name   the name
485    * @return   void
486    */
487    function set_name($name) {
488      $this->basenode->set_name($name);
489    }
490
491    /**
492    * get name property of the basenode.
493    *
494    * @access   public
495    * @return   string
496    */
497    function get_name() {
498      return $this->basenode->get_name();
499    }
500   
501   
502   
503    /**
504    * returns the response type as requested by the client
505    *
506    * @access public
507    * @return string
508    */
509    function get_response_type() {
510      return $this->response_type;
511    }
512   
513  }
514 
515  /**
516  * a cpaint data node. Data nodes are used to build up the response.
517  *
518  * @package   CPAINT
519  * @access    public
520  * @author    Dominique Stender <dstender@st-webdevelopment.de>
521  * @copyright 2005 (Dominique Stender); All rights reserved
522  * @version   2.0.2
523  */
524  class cpaint_node {
525    /**
526    * array of subnodes.
527    *
528    * @access   public
529    * @var      array     $composites
530    */
531    var $composites;
532   
533    /**
534    * node attributes.
535    *
536    * @access   public
537    * @var      array     $attributes
538    */
539    var $attributes;
540
541    /**
542    * name of this node.
543    *
544    * @access   public
545    * @var      string    $nodename
546    */
547    var $nodename;
548
549    /**
550    * textual data of this node.
551    *
552    * @access   public
553    * @var      string    $data
554    */
555    var $data;
556
557    /**
558    * character encoding for input data
559    *
560    * @access   private
561    * @var      $input_encoding
562    */
563    var $input_encoding;
564
565    /**
566    * PHP4 constructor.
567    *
568    * @package  CPAINT
569    * @access   public
570    * @return   void
571    */
572    function cpaint_node() {
573      $this->__construct();
574    }
575   
576    /**
577    * PHP 5 constructor.
578    *
579    * @access   public
580    * @return   void
581    */
582    function __construct() {
583      // initialize properties
584      $this->composites     = array();
585      $this->attributes     = array();
586      $this->data           = '';
587     
588      $this->set_encoding('UTF-8');
589      $this->set_name('');
590      $this->set_attribute('id', '');
591    }
592
593    /**
594    * adds a new subnode to this node.
595    *
596    * will return a reference to it for further processing.
597    *
598    * @access   public
599    * @param    string    $nodename     name of the new node
600    * @param    string    $id           id of the new node
601    * @return   object
602    */
603    function &add_node($nodename, $id = '') {
604      $composites = count($this->composites);
605
606      // create new node
607      $this->composites[$composites] =& new cpaint_node();
608      $this->composites[$composites]->set_name($nodename);
609      $this->composites[$composites]->set_attribute('id', $id);
610      $this->composites[$composites]->set_encoding($this->input_encoding);
611
612      return $this->composites[$composites];
613    }
614
615    /**
616    * assigns textual data to this node.
617    *
618    * @access   public
619    * @param    mixed    $data    data to assign to this node
620    * @return   void
621    */
622    function set_data($data) {
623      $this->data = $data;
624    }
625   
626    /**
627    * returns the textual data assigned to this node.
628    *
629    * @access   public
630    * @return   mixed
631    */
632    function get_data() {
633      return $this->data;
634    }
635   
636    /**
637    * sets the id property of this node.
638    *
639    * @deprecated   deprecated since version 2.0.0
640    * @access       public
641    * @param        string    id      the id
642    * @return       void
643    */
644    function set_id($id) {
645      if ($id != '') {
646        $this->set_attribute('id', $id);
647      } // end: if
648    }
649   
650    /**
651    * returns the id property if this node.
652    *
653    * @deprecated   deprecated since version 2.0.0
654    * @access       public
655    * @return       string
656    */
657    function get_id() {
658      return $this->get_attribute('id');
659    }
660   
661    /**
662    * adds a new attribute to this node.
663    *
664    * @access   public
665    * @param    string    $name       attribute name
666    * @param    mixed     $value      attribute value
667    * @return   void
668    */
669    function set_attribute($name, $value) {
670      $this->attributes[$name] = (string) $value;
671    }
672   
673    /**
674    * retrieves an attribute by name.
675    *
676    * @access   public
677    * @param    string    $name       attribute name
678    * @return   string
679    */
680    function get_attribute($name) {
681      return $this->attributes[$name];
682    }
683   
684    /**
685    * set name property.
686    *
687    * @access   public
688    * @param    string    $name   the name
689    * @return   void
690    */
691    function set_name($name) {
692      $this->nodename = (string) $name;
693    }
694
695    /**
696    * get name property.
697    *
698    * @access   public
699    * @return   string
700    */
701    function get_name() {
702      return $this->nodename;
703    }
704 
705    /**
706    * sets the character encoding for this node
707    *
708    * @access   public
709    * @param    string      $encoding     character encoding
710    * @return   void
711    */
712    function set_encoding($encoding) {
713      $this->input_encoding = strtoupper((string) $encoding);
714    }
715 
716    /**
717    * returns the character encoding for this node
718    *
719    * @access   public
720    * @return   string
721    */
722    function get_encoding() {
723      return $this->input_encoding;
724    }
725  }
726 
727  /**
728  * static class of output transformers.
729  *
730  * @package   CPAINT
731  * @access    public
732  * @author    Dominique Stender <dstender@st-webdevelopment.de>
733  * @copyright 2002-2005 (Dominique Stender); All rights reserved
734  * @version   2.0.2
735  */
736  class cpaint_transformer {
737    /**
738    * toString method, used to generate response of type TEXT.
739    * will perform character transformation according to parameters.
740    *
741    * @access   public
742    * @param    object    $node               a cpaint_node object
743    * @return   string
744    */
745    function toString(&$node) {
746      $return_value = '';
747
748      foreach ($node->composites as $composite) {
749        $return_value .= cpaint_transformer::toString($composite);
750      }
751
752      $return_value .= cpaint_transformer::encode($node->get_data(), $node->get_encoding());
753
754      return $return_value;
755    }
756   
757    /**
758    * XML response generator.
759    * will perform character transformation according to parameters.
760    *
761    * @access   public
762    * @param    object    $node               a cpaint_node object
763    * @return   string
764    */
765    function toXML(&$node) {
766      $return_value = '<' . $node->get_name();
767     
768      // handle attributes
769      foreach ($node->attributes as $name => $value) {
770        if ($value != '') {
771          $return_value .= ' ' . $name . '="' . $node->get_attribute($name) . '"';
772        }
773      } // end: foreach
774     
775      $return_value .= '>';
776
777      // handle subnodes   
778      foreach ($node->composites as $composite) {
779        $return_value .= cpaint_transformer::toXML($composite);
780      }
781
782      $return_value .= cpaint_transformer::encode($node->get_data(), $node->get_encoding())
783                    . '</' . $node->get_name() . '>';
784
785      return $return_value;
786    }
787   
788    /**
789    * JSON response generator.
790    * will perform character transformation according to parameters.
791    *
792    * @access   public
793    * @param    object    $node               a cpaint_node object
794    * @return   string
795    */
796    function toJSON($node) {
797      $return_value = '';
798      $JSON_node    = new stdClass();
799
800      // handle attributes
801      $JSON_node->attributes = $node->attributes;     
802
803      // handle subnodes   
804      foreach ($node->composites as $composite) {
805       
806        if (!is_array($JSON_node->{$composite->nodename})) {
807          $JSON_node->{$composite->nodename} = array();
808        } // end: if
809       
810        // we need to parse the JSON object again to avoid multiple encoding
811        $JSON_node->{$composite->nodename}[] = $GLOBALS['__cpaint_json']->parse(cpaint_transformer::toJSON($composite));
812      }
813
814      // handle data
815      $JSON_node->data = $node->data;
816     
817      return $GLOBALS['__cpaint_json']->stringify($JSON_node);
818    }
819   
820    /**
821    * performs conversion to JavaScript-safe UTF-8 characters
822    *
823    * @access   public
824    * @param    string    $data         data to convert
825    * @param    string    $encoding     character encoding
826    * @return   string
827    */
828    function encode($data, $encoding) {
829      // convert string
830      if (function_exists('iconv')) {
831        // iconv is by far the most flexible approach, try this first
832        $return_value = iconv($encoding, 'UTF-8', $data);
833
834      } elseif ($encoding == 'ISO-8859-1') {
835        // for ISO-8859-1 we can use utf8-encode()
836        $return_value = utf8_encode($data);
837
838      } else {
839        // give up. if UTF-8 data was supplied everything is fine!
840        $return_value = $data;
841      } /* end: if */
842     
843      // now encode non-printable characters
844      for ($i = 0; $i < 32; $i++) {
845        $return_value = str_replace(chr($i), '\u00' . sprintf('%02x', $i), $return_value);
846      } // end: for
847     
848      // encode <, >, and & respectively for XML sanity
849      $return_value = str_replace(chr(0x26), '\u0026', $return_value);
850      $return_value = str_replace(chr(0x3c), '\u003c', $return_value);
851      $return_value = str_replace(chr(0x3e), '\u003e', $return_value);
852     
853      return $return_value;
854    }
855 
856    /**
857    * performs conversion from JavaScript encodeURIComponent() string (UTF-8) to
858    * the charset in use.
859    *
860    * @access   public
861    * @param    string    $data         data to convert
862    * @param    string    $encoding     character encoding
863    * @return   string
864    */
865    function decode($data, $encoding) {
866      // convert string
867     
868      if (is_string($data)) {
869        if (function_exists('iconv')) {
870          // iconv is by far the most flexible approach, try this first
871          $return_value = iconv('UTF-8', $encoding, $data);
872 
873        } elseif ($encoding == 'ISO-8859-1') {
874          // for ISO-8859-1 we can use utf8-decode()
875          $return_value = utf8_decode($data);
876 
877        } else {
878          // give up. if data was supplied in the correct format everything is fine!
879          $return_value = $data;
880        } // end: if
881     
882      } else {
883        // non-string value
884        $return_value = $data;
885      } // end: if
886     
887      return $return_value;
888    }
889
890    /**
891    * decodes a (nested) array of data from UTF-8 into the configured character set
892    *
893    * @access   public
894    * @param    array     $data         data to convert
895    * @param    string    $encoding     character encoding
896    * @return   array
897    */
898    function decode_array($data, $encoding) {
899      $return_value = array();
900   
901      foreach ($data as $key => $value) {
902
903        if (!is_array($value)) {
904          $return_value[$key] = cpaint_transformer::decode($value, $encoding);
905
906        } else {
907          $return_value[$key] = cpaint_transformer::decode_array($value, $encoding);
908        }
909      }
910
911      return $return_value;
912    }
913   
914    /**
915    * determines the output character set
916    * based on input character set
917    *
918    * @access   public
919    * @param    string    $encoding     character encoding
920    * @return   string
921    */
922    function find_output_charset($encoding) {
923      $return_value = 'UTF-8';
924   
925      if (function_exists('iconv')
926        || $encoding == 'UTF-8'
927        || $encoding == 'ISO-8859-1') {
928       
929        $return_value = 'UTF-8';
930
931      } else {
932        $return_value = $encoding;
933      } // end: if
934     
935      return $return_value;
936    }
937  }
938 
939?>
Note: See TracBrowser for help on using the repository browser.