document->addFile($name, $mime, io_readfile($src,false)); } else { $name = $src; } // make sure width and height are available if (!$width && !$height) { list($width, $height) = ODTUtility::getImageSizeString($src, $width, $height, true, $params->units); } else { list($width, $height) = ODTUtility::getImageSizeString($src, $width, $height, false, $params->units); } if($align){ $anchor = 'paragraph'; }else{ $anchor = 'as-char'; } if (empty($style) || !$params->document->styleExists($style)) { if (!empty($align)) { $style = $params->document->getStyleName('media '.$align); } else { $style = $params->document->getStyleName('media'); } } // Open paragraph if necessary if (!$params->document->state->getInParagraph()) { $params->document->paragraphOpen(); } if ($title) { $encoded .= ''; $encoded .= ''; $encoded .= ''; } if (!empty($title)) { $encoded .= ''; } else { $encoded .= ''; } $encoded .= ''; $encoded .= ''; if ($title) { $encoded .= $params->document->replaceXMLEntities($title).''; } if($returnonly) { return $encoded; } else { $params->content .= $encoded; } $z++; } /** * Adds the content of $string as a SVG picture file to the document. * The link name which can be used for the ODT draw:image xlink:href * is returned. The caller is responsible for creating the frame and image tag * but therefore has full control over it. This means he can also set parameters * in the odt frame and image tag which can not be changed using the function _odtAddImage. * * @author LarsDW223 * * @param string $string SVG code to add * @return string */ public static function addStringAsSVGImageFile(ODTDocument $doc, $string) { if ( empty($string) ) { return; } $ext = '.svg'; $mime = '.image/svg+xml'; $name = 'Pictures/'.md5($string).'.'.$ext; $doc->addFile($name, $mime, $string); return $name; } /** * Adds the content of $string as a SVG picture to the document. * The other parameters behave in the same way as in _odtAddImage. * * @author LarsDW223 * * @param string $string * @param $width * @param $height * @param $align * @param $title * @param $style */ function addStringAsSVGImage(ODTInternalParams $params, $string, $width = NULL, $height = NULL, $align = NULL, $title = NULL, $style = NULL) { if ( empty($string) ) { return; } $name = self::addStringAsSVGImageFile($params->document, $string); // make sure width and height are available if (!$width || !$height) { list($width, $height) = ODTUtility::getImageSizeString($string, $width, $height, true, $params->units); } if($align){ $anchor = 'paragraph'; }else{ $anchor = 'as-char'; } if (!$style or !$params->document->styleExists($style)) { $style = $params->document->getStyleName('media '.$align); } // Open paragraph if necessary if (!$params->document->state->getInParagraph()) { $params->document->paragraphOpen(); } if ($title) { $params->content .= ''; $params->content .= ''; $params->document->paragraphOpen($$params->document->getStyleName('legend center')); } $params->content .= ''; $params->content .= ''; $params->content .= ''; if ($title) { $params->content .= $params->document->replaceXMLEntities($title); $params->document->paragraphClose(); $params->content .= ''; } } /** * Adds an image $src to the document using the parameters set in $properties. * The actually supported properties are: * - width and height * - title * - background-color * - margin-left, margin-right, margin-top, margin-bottom * * @param string $src The path to the image file * @param array $properties Properties (width, height... see ODTImage::addImageUseProperties) * @param boolean $returnonly Only return code */ public static function addImageUseProperties(ODTInternalParams $params, $src, array $properties, $returnonly = false){ static $z = 0; ODTUtility::adjustValuesForODT ($properties, $params->units); $width = $properties ['width']; $height = $properties ['height']; $title = $properties ['title']; $bg_color = $properties ['background-color']; $encoded = ''; if (file_exists($src)) { list($ext,$mime) = mimetype($src); $name = 'Pictures/'.md5($src).'.'.$ext; $params->document->addFile($name, $mime, io_readfile($src,false)); } else { $name = $src; } // make sure width and height are available if (!$width || !$height) { list($width, $height) = ODTUtility::getImageSizeString($src, $width, $height, true, $params->units); } else { // Adjust values for ODT $width = $params->document->toPoints($width, 'x').'pt'; $height = $params->document->toPoints($height, 'y').'pt'; } if($align){ $anchor = 'paragraph'; }else{ $anchor = 'as-char'; } // Open paragraph if necessary if (!$params->document->state->getInParagraph()) { $params->document->paragraphOpen(); } // Define graphic style for picture $style_name = ODTStyle::getNewStylename('span_graphic'); $image_style = ''; $image_style .= 'document->addAutomaticStyle($style_obj); if ($title) { $encoded .= ''; $encoded .= ''; $encoded .= ''; } if (!empty($title)) { $encoded .= ''; } else { $encoded .= ''; } $encoded .= ''; $encoded .= ''; if ($title) { $encoded .= $params->document->replaceXMLEntities($title).''; } if($returnonly) { return $encoded; } else { $params->content .= $encoded; } $z++; } }