예제 #1
0
파일: I18Nv2.php 프로젝트: roojs/pear
 /**
  * Automatically transform output between encodings
  *
  * This method utilizes ob_iconv_handler(), so you should call it at the 
  * beginning of your script (prior to output).  If any output buffering has 
  * been started before, the contents will be fetched with ob_get_contents() 
  * and the buffers will be destroyed by ob_end_clean() if $refetchOB is set
  * to true.
  * 
  * <code>
  * require_once('I18Nv2.php');
  * I18Nv2::autoConv('CP1252');
  * print('...'); // some iso-8859-1 stuff gets converted to Windows-1252
  * // ...
  * </code>
  * 
  * @static
  * @access  public
  * @return  mixed   Returns &true; on success or 
  *                  <classname>PEAR_Error</classname> on failure.
  * @param   string  $oe             desired output encoding
  * @param   string  $ie             internal encoding
  * @param   bool    $decodeRequest  whether to decode request variables
  *                                  ($_GET and $_POST) from $oe to $ie
  * @param   bool    $refetchOB      whether contents of already active 
  *                                  output buffers should be fetched, the
  *                                  output buffer handlers destroyed and
  *                                  the fetched data be passed through
  *                                  ob_iconvhandler
  */
 function autoConv($oe = 'UTF-8', $ie = 'ISO-8859-1', $decodeRequest = true, $refetchOB = true)
 {
     if (!strcasecmp($oe, $ie)) {
         return true;
     }
     if (!extension_loaded('iconv')) {
         require_once 'PEAR.php';
         if (!PEAR::loadExtension('iconv')) {
             return PEAR::staticRaiseError('Error: ext/iconv is not available');
         }
     }
     iconv_set_encoding('internal_encoding', $ie);
     iconv_set_encoding('output_encoding', $oe);
     iconv_set_encoding('input_encoding', $oe);
     $buffer = '';
     if ($refetchOB && ($level = ob_get_level())) {
         while ($level--) {
             $buffer .= ob_get_contents();
             ob_end_clean();
         }
     }
     if (!ob_start('ob_iconv_handler')) {
         require_once 'PEAR.php';
         return PEAR::staticRaiseError('Couldn\'t start output buffering');
     }
     echo $buffer;
     if ($decodeRequest) {
         I18Nv2::recursiveIconv($_GET, $oe, $ie);
         I18Nv2::recursiveIconv($_POST, $oe, $ie);
     }
     return true;
 }
예제 #2
0
파일: Transform.php 프로젝트: roojs/pear
 /**
  * Converts an image into greyscale colors
  *
  * @return mixed TRUE or a PEAR error object on error
  * @access public
  **/
 function greyscale()
 {
     return PEAR::staticRaiseError('greyscale() method not supported by driver', IMAGE_TRANSFORM_ERROR_UNSUPPORTED);
 }
예제 #3
0
파일: Imagick3.php 프로젝트: roojs/pear
 /**
  * RaiseError Method - shows imagick Raw errors.
  *
  * @param string $message message = prefixed message..
  * @param int    $code error code
  * @return PEAR error object
  * @access protected
  */
 function raiseError($message, $code = 0)
 {
     return PEAR::staticRaiseError($message, $code);
 }
예제 #4
0
파일: Container.php 프로젝트: roojs/pear
 /**
  * Trigger a PEAR error
  *
  * @param string $msg    error message
  * @param int    $code   error code
  * @param int    $mode   PEAR error mode
  * @param int    $option error severity
  *
  * @return void|PEAR_Error
  * @access public
  */
 function raiseError($msg, $code, $mode = PEAR_ERROR_TRIGGER, $option = E_USER_WARNING)
 {
     if (isset($GLOBALS['_PEAR_default_error_mode'])) {
         $mode = $GLOBALS['_PEAR_default_error_mode'];
     }
     if (isset($GLOBALS['_PEAR_default_error_options'])) {
         $option = $GLOBALS['_PEAR_default_error_options'];
     }
     if ($mode == PEAR_ERROR_RETURN) {
         return PEAR::staticRaiseError($msg, $code, $mode, $option);
     } else {
         PEAR::staticRaiseError($msg, $code, $mode, $option);
     }
 }
예제 #5
0
파일: AbiToDocx.php 프로젝트: roojs/pear
 function parseProps()
 {
     ini_set('memory_limit', '512M');
     $attribute = $this->xr->getAttribute('props');
     if (empty($attribute)) {
         return array();
     }
     $data = explode(';', trim($attribute));
     foreach ($data as $attrs) {
         $attr = explode(':', trim($attrs));
         if (empty($attr[0])) {
             continue;
         }
         switch (trim($attr[0])) {
             case 'table-width-fixed':
                 $attrArray['fixed'] = trim($attr[1]);
                 break;
             case 'table-column-props':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $index => $prop) {
                     $attrArray['width' . $index] = trim($prop);
                     $attrArray['width' . $index . '_dax'] = $this->converttoDax(trim($prop), null);
                 }
                 break;
             case 'table-row-heights':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $index => $prop) {
                     $attrArray['height' . $index] = trim($prop);
                 }
                 break;
             case 'left-attach':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['columnNum'] = trim($prop);
                 }
                 break;
             case 'top-attach':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['rowNum'] = trim($prop);
                 }
                 break;
             case 'right-attach':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['mergeto'] = trim($prop);
                 }
                 break;
             case 'top-color':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['borderTopColor'] = trim($prop);
                 }
                 break;
             case 'left-color':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['borderLeftColor'] = trim($prop);
                 }
                 break;
             case 'right-color':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['borderRightColor'] = trim($prop);
                 }
                 break;
             case 'bot-color':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['borderBottomColor'] = trim($prop);
                 }
                 break;
                 // background color
             // background color
             case 'background-color':
                 $props = explode('/', $attr[1]);
                 foreach ($props as $prop) {
                     $attrArray['bgColor'] = trim($prop);
                 }
                 break;
             case 'font-weight':
                 $attrArray['bold'] = $attr[1] == 'bold' ? trim($attr[1]) : false;
                 break;
             case 'font-style':
                 $attrArray['italic'] = $attr[1] == 'italic' ? true : false;
                 break;
                 //
                 //                    case 'width':
                 //                        $props = explode('/', $attr[1]);
                 //                        foreach($props as $index => $prop){
                 //                            $attrArray['width'.$index] = trim($prop);
                 //                        }
                 //                        break;
                 //
             //
             //                    case 'width':
             //                        $props = explode('/', $attr[1]);
             //                        foreach($props as $index => $prop){
             //                            $attrArray['width'.$index] = trim($prop);
             //                        }
             //                        break;
             //
             default:
                 $key = trim($attr[0]);
                 if (empty($attr[1]) && $attr[1] != 0) {
                     // bit annoying.. but we currently only convert from trustes sources, so do not need to handle this.
                     PEAR::staticRaiseError("value missing in style key={$attr[0]}  for prop={$attribute}", 0, PEAR_ERROR_DIE);
                 }
                 $value = trim($attr[1]);
                 if (array_key_exists($key, $this->styleMatch)) {
                     $attrArray[$this->styleMatch[$key]] = $value;
                 } else {
                     $attrArray[$key] = $value;
                 }
         }
     }
     return $attrArray;
 }