public static function embedTagIsCompatibilityMode() { if ( self::$embedIsCompatibilityMode === null ) { $ezoeIni = eZINI::instance('ezoe.ini'); self::$embedIsCompatibilityMode = $ezoeIni->variable('EditorSettings', 'CompatibilityMode' ) === 'enabled'; } return self::$embedIsCompatibilityMode; }
/** * Test for EZP-21986 * Make sure the custom tag underline is transformed into a <u> tag * * @link https://jira.ez.no/browse/EZP-21986 */ public function testCustomUnderlineToU() { ezpINIHelper::setINISetting('content.ini', 'CustomTagSettings', 'AvailableCustomTags', array('underline')); ezpINIHelper::setINISetting('content.ini', 'CustomTagSettings', 'IsInline', array('underline' => 'true')); $xmlData = '<?xml version="1.0" encoding="utf-8"?>'; $xmlData .= '<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/"> <paragraph>If I could <custom name="underline">sleep</custom> forever</paragraph> </section>'; $folder = new ezpObject('folder', 2); $folder->name = 'The Dandy Warhols - Sleep'; $folder->short_description = ''; $oeHandler = new eZOEXMLInput($xmlData, false, $folder->short_description); $xhtml = $oeHandler->attribute('input_xml'); self::assertEquals('<p>If I could <u class="ezoeItemCustomTag underline" type="custom">sleep</u> forever</p><p><br /></p>', $xhtml); ezpINIHelper::restoreINISettings(); }
} } if (!$embedObject instanceof eZContentObject || !$embedObject->canRead()) { echo ezpI18n::tr('design/standard/ezoe', 'Invalid parameter: %parameter = %value', null, array('%parameter' => 'EmbedID', '%value' => $Params['EmbedID'])); eZExecution::cleanExit(); } $imageSizeArray = $imageIni->variable('AliasSettings', 'AliasList'); $ini = eZINI::instance('site.ini'); $contentIni = eZINI::instance('content.ini'); $ezoeIni = eZINI::instance('ezoe.ini'); $embedClassIdentifier = $embedObject->attribute('class_identifier'); $embedClassID = $embedObject->attribute('contentclass_id'); $sizeTypeArray = array(); if ($contentType === 'auto') { // figgure out what content type group this class is in $contentType = eZOEXMLInput::embedTagContentType($embedClassIdentifier, $embedClassID); } if ($embedSize && $contentType === 'images') { $params['imagePreGenerateSizes'][] = $embedSize; } foreach ($imageSizeArray as $size) { if ($imageIni->hasVariable($size, 'HideFromRelations') && $imageIni->variable($size, 'HideFromRelations') === 'enabled') { continue; } if ($imageIni->hasVariable($size, 'GUIName')) { $sizeTypeArray[$size] = $imageIni->variable($size, 'GUIName'); } else { $sizeTypeArray[$size] = ucfirst($size); } $imagePixelSize = ''; foreach ($imageIni->variable($size, 'Filters') as $filter) {
<?php $return = true; $attributeId = (int) $_REQUEST['attribute_id']; $versionId = (int) $_REQUEST['version_id']; $content = $_REQUEST['data']; if ($attributeId && $versionId) { $attribute = eZContentObjectAttribute::fetch($attributeId, $versionId); switch ($attribute->attribute('data_type_string')) { case 'ezxmltext': if (eZOEXMLInput::browserSupportsDHTMLType() === 'Trident') { $content = str_replace("\t", '', $content); } $parser = new eZOEInputParser(); $document = $parser->process($content); // Remove last empty paragraph (added in the output part) $parent = $document->documentElement; $lastChild = $parent->lastChild; while ($lastChild && $lastChild->nodeName !== 'paragraph') { $parent = $lastChild; $lastChild = $parent->lastChild; } if ($lastChild && $lastChild->nodeName === 'paragraph') { $textChild = $lastChild->lastChild; // $textChild->textContent == "�" : string(2) whitespace in Opera if (!$textChild || $lastChild->childNodes->length == 1 && $textChild->nodeType == XML_TEXT_NODE && ($textChild->textContent == "�" || $textChild->textContent == ' ' || $textChild->textContent == '' || $textChild->textContent == ' ')) { $parent->removeChild($lastChild); } } $xmlString = eZXMLTextType::domString($document); $attribute->setAttribute('data_text', $xmlString);
/** * Test for issue #18220: non breaking spaces are wrongly encoded * * Check that utf8 non breaking spaces are correctly decoded to be use in * Online Editor. * * @group issue_18220 * @link http://issues.ez.no/18220 */ public function testNonBreakingSpaceDecodingUtf8Encoding() { $xmlData = '<?xml version="1.0" encoding="utf-8"?>'; $xmlData .= '<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">'; $xmlData .= "<paragraph>French typography :</paragraph>"; $xmlData .= "</section>"; $folder = new ezpObject('folder', 2); $folder->name = 'Non breaking space decoding of utf8 encoding'; $folder->short_description = ''; $oeHandler = new eZOEXMLInput($xmlData, false, $folder->short_description); $xhtml = $oeHandler->attribute('input_xml'); self::assertEquals('<p>French typography&nbsp;:</p><p><br /></p>', $xhtml); }
/** * Set content object attributes * * @private * @param eZContentObject $object * @param array( attributeIdentifier => attributeStringValue ) $attributesValues * @return void */ private function setObjectAttributes(eZContentObject $object, array $attributesValues) { $attributes = $object->dataMap(); foreach ($attributesValues as $identifier => $value) { if (isset($attributes[$identifier])) { $attribute = $attributes[$identifier]; switch ($attribute->attribute('data_type_string')) { case 'ezimage': $arr = explode('|', trim($value)); $source = str_replace(' ', '%20', $arr[0]); if (file_exists($source)) { // Handle local files $content = $attribute->attribute('content'); $content->initializeFromFile($source, isset($arr[1]) ? $arr[1] : null); $content->store($attribute); } else { // Handle remote files $filename = 'var/cache/' . md5(microtime()) . substr($source, strrpos($source, '.')); if (!empty($source)) { if (in_array('curl', get_loaded_extensions())) { $ch = curl_init(); $out = fopen($filename, 'w'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_URL, $source); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FILE, $out); curl_exec($ch); curl_close($ch); fclose($out); } else { copy($source, $filename); } } if (file_exists($filename)) { $content = $attribute->attribute('content'); $content->initializeFromFile($filename, isset($arr[1]) ? $arr[1] : null); $content->store($attribute); unlink($filename); } } break; case 'ezxmltext': $parser = new eZOEInputParser(); $value = '<div>' . trim($value) . '</div>'; $document = $parser->process($value); $urlIDArray = $parser->getUrlIDArray(); if (count($urlIDArray) > 0) { eZOEXMLInput::updateUrlObjectLinks($attribute, $urlIDArray); } $object->appendInputRelationList($parser->getLinkedObjectIDArray(), eZContentObject::RELATION_LINK); $object->appendInputRelationList($parser->getEmbeddedObjectIDArray(), eZContentObject::RELATION_EMBED); $value = $document ? eZXMLTextType::domString($document) : null; $attribute->fromString($value); break; default: if (is_callable(array($attribute, 'fromString'))) { $attribute->fromString($value); } else { $attribute->setAttribute('data_text', $value); } } $attribute->store(); } } }