本文整理汇总了PHP中eZTextCodec类 的典型用法代码示例。如果您正苦于以下问题:PHP eZTextCodec类的具体用法?PHP eZTextCodec怎么用?PHP eZTextCodec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZTextCodec类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: eZUpdateTextCodecSettings
/**
Reads settings from i18n.ini and passes them to eZTextCodec.
*/
function eZUpdateTextCodecSettings()
{
$ini = eZINI::instance('i18n.ini');
list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = $ini->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled'));
//include_once( 'lib/ezi18n/classes/eztextcodec.php' );
eZTextCodec::updateSettings($i18nSettings);
}
开发者ID:gggeek, 项目名称:ggwebservices, 代码行数:10, 代码来源:webservicescontroller.php
示例2: _connect
/**
* Reimplement parent's method to make use of a tracing dfs backend class
*/
public function _connect()
{
$siteINI = eZINI::instance('site.ini');
// DB Connection setup
// This part is not actually required since _connect will only be called
// once, but it is useful to run the unit tests. So be it.
// @todo refactor this using eZINI::setVariable in unit tests
if (parent::$dbparams === null) {
$fileINI = eZINI::instance('file.ini');
parent::$dbparams = array();
parent::$dbparams['host'] = $fileINI->variable('eZDFSClusteringSettings', 'DBHost');
$dbPort = $fileINI->variable('eZDFSClusteringSettings', 'DBPort');
parent::$dbparams['port'] = $dbPort !== '' ? $dbPort : null;
parent::$dbparams['socket'] = $fileINI->variable('eZDFSClusteringSettings', 'DBSocket');
parent::$dbparams['dbname'] = $fileINI->variable('eZDFSClusteringSettings', 'DBName');
parent::$dbparams['user'] = $fileINI->variable('eZDFSClusteringSettings', 'DBUser');
parent::$dbparams['pass'] = $fileINI->variable('eZDFSClusteringSettings', 'DBPassword');
parent::$dbparams['max_connect_tries'] = $fileINI->variable('eZDFSClusteringSettings', 'DBConnectRetries');
parent::$dbparams['max_execute_tries'] = $fileINI->variable('eZDFSClusteringSettings', 'DBExecuteRetries');
parent::$dbparams['sql_output'] = $siteINI->variable("DatabaseSettings", "SQLOutput") == "enabled";
parent::$dbparams['cache_generation_timeout'] = $siteINI->variable("ContentSettings", "CacheGenerationTimeout");
}
$serverString = parent::$dbparams['host'];
if (parent::$dbparams['socket']) {
$serverString .= ':' . parent::$dbparams['socket'];
} elseif (parent::$dbparams['port']) {
$serverString .= ':' . parent::$dbparams['port'];
}
$maxTries = parent::$dbparams['max_connect_tries'];
$tries = 0;
eZPerfLogger::accumulatorStart('mysql_cluster_connect', 'MySQL Cluster', 'Cluster database connection');
while ($tries < $maxTries) {
if ($this->db = mysqli_connect(parent::$dbparams['host'], parent::$dbparams['user'], parent::$dbparams['pass'], parent::$dbparams['dbname'], parent::$dbparams['port'])) {
break;
}
++$tries;
}
eZPerfLogger::accumulatorStop('mysql_cluster_connect');
if (!$this->db) {
throw new eZClusterHandlerDBNoConnectionException($serverString, parent::$dbparams['user'], parent::$dbparams['pass']);
}
/*if ( !mysql_select_db( parent::$dbparams['dbname'], $this->db ) )
throw new eZClusterHandlerDBNoDatabaseException( parent::$dbparams['dbname'] );*/
// DFS setup
if ($this->dfsbackend === null) {
$this->dfsbackend = new eZDFSFileHandlerTracing46DFSBackend();
}
$charset = trim($siteINI->variable('DatabaseSettings', 'Charset'));
if ($charset === '') {
$charset = eZTextCodec::internalCharset();
}
if ($charset) {
if (!mysqli_set_charset($this->db, eZMySQLCharset::mapTo($charset))) {
$this->_fail("Failed to set Database charset to {$charset}.");
}
}
}
开发者ID:gggeek, 项目名称:ezperformancelogger, 代码行数:60, 代码来源:tracingmysqli.php
示例3: validateStringHTTPInput
function validateStringHTTPInput($data, $contentObjectAttribute, $classAttribute)
{
$maxLen = $classAttribute->attribute(self::MAX_LEN_FIELD);
$textCodec = eZTextCodec::instance(false);
if ($textCodec->strlen($data) > $maxLen and $maxLen > 0) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input text is too long. The maximum number of characters allowed is %1.'), $maxLen);
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
开发者ID:legende91, 项目名称:ez, 代码行数:10, 代码来源:ezstringtype.php
示例4: transformByGroup
function transformByGroup($text, $group, $charset = false, $useCache = true)
{
if ($text === '') {
return $text;
}
$charsetName = $charset === false ? eZTextCodec::internalCharset() : eZCharsetInfo::realCharsetCode($charset);
if ($useCache) {
// CRC32 is used for speed, MD5 would be more unique but is slower
$keyText = 'Group:' . $group;
$key = eZSys::ezcrc32($keyText . '-' . $charset);
$filepath = $this->cacheFilePath('g-' . $group . '-', '-' . $charsetName, $key);
// Try to execute code in the cache file, if it succeeds
// \a $text will/ transformated
$retText = $this->executeCacheFile($text, $filepath);
if ($retText !== false) {
return $retText;
}
}
$commands = $this->groupCommands($group);
if ($commands === false) {
return false;
}
$mapper = new eZCodeMapper();
$mapper->loadTransformationFiles($charsetName, $group);
$rules = array();
foreach ($commands as $command) {
$rules = array_merge($rules, $mapper->decodeCommand($command['command'], $command['parameters']));
}
// First generate a unicode based mapping table from the rules
$unicodeTable = $mapper->generateMappingCode($rules);
unset($unicodeTable[0]);
// Then transform that to a table that works with the current charset
// Any character not available in the current charset will be removed
$charsetTable = $mapper->generateCharsetMappingTable($unicodeTable, $charset);
$transformationData = array('table' => $charsetTable);
unset($unicodeTable);
if ($useCache) {
$extraCode = '';
foreach ($commands as $command) {
$code = $mapper->generateCommandCode($command, $charsetName);
if ($code !== false) {
$extraCode .= $code . "\n";
}
}
$this->storeCacheFile($filepath, $transformationData, $extraCode, 'Group:' . $group, $charsetName);
}
// Execute transformations
$text = strtr($text, $transformationData['table']);
// Execute custom code
foreach ($commands as $command) {
$mapper->executeCommandCode($text, $command, $charsetName);
}
return $text;
}
开发者ID:patrickallaert, 项目名称:ezpublish-legacy-php7, 代码行数:54, 代码来源:ezchartransform.php
示例5: _connect
function _connect()
{
$siteINI = eZINI::instance('site.ini');
if (!isset($GLOBALS['eZDBFileHandlerMysqlBackend_dbparams'])) {
$fileINI = eZINI::instance('file.ini');
$params['host'] = $fileINI->variable('ClusteringSettings', 'DBHost');
$params['port'] = $fileINI->variable('ClusteringSettings', 'DBPort');
$params['socket'] = $fileINI->variable('ClusteringSettings', 'DBSocket');
$params['dbname'] = $fileINI->variable('ClusteringSettings', 'DBName');
$params['user'] = $fileINI->variable('ClusteringSettings', 'DBUser');
$params['pass'] = $fileINI->variable('ClusteringSettings', 'DBPassword');
$params['chunk_size'] = $fileINI->variable('ClusteringSettings', 'DBChunkSize');
$params['max_connect_tries'] = $fileINI->variable('ClusteringSettings', 'DBConnectRetries');
$params['max_execute_tries'] = $fileINI->variable('ClusteringSettings', 'DBExecuteRetries');
$params['sql_output'] = $siteINI->variable("DatabaseSettings", "SQLOutput") == "enabled";
$params['cache_generation_timeout'] = $siteINI->variable("ContentSettings", "CacheGenerationTimeout");
$GLOBALS['eZDBFileHandlerMysqlBackend_dbparams'] = $params;
} else {
$params = $GLOBALS['eZDBFileHandlerMysqlBackend_dbparams'];
}
$this->dbparams = $params;
$maxTries = $params['max_connect_tries'];
$tries = 0;
eZDebug::accumulatorStart('mysql_cluster_connect', 'mysql_cluster_total', 'Cluster_database_connection');
while ($tries < $maxTries) {
/// @todo what if port is null, '' ??? to be tested
if ($this->db = mysqli_connect($params['host'], $params['user'], $params['pass'], $params['dbname'], $params['port'])) {
break;
}
++$tries;
}
eZDebug::accumulatorStop('mysql_cluster_connect');
if (!$this->db) {
return $this->_die("Unable to connect to storage server");
}
$charset = trim($siteINI->variable('DatabaseSettings', 'Charset'));
if ($charset === '') {
$charset = eZTextCodec::internalCharset();
}
if ($charset) {
if (!mysqli_set_charset($this->db, eZMySQLCharset::mapTo($charset))) {
return $this->_die("Failed to set Database charset to {$charset}.");
}
}
}
开发者ID:legende91, 项目名称:ez, 代码行数:45, 代码来源:mysqli.php
示例6: instance
public static function instance()
{
if ( is_null(self::$_instance) )
{
$ini = eZINI::instance();
if ( !$ini->hasSection( 'MMDatabaseSettings') )
return eZDB::instance();
list( $server, $port, $user, $pwd, $db ) =
$ini->variableMulti( 'MMDatabaseSettings', array( 'Server', 'Port', 'User', 'Password', 'Database' ) );
list( $charset, $retries, $usePersistentConnection ) =
$ini->variableMulti( 'DatabaseSettings', array( 'Charset', 'ConnectRetries', 'UserPersistentConnection' ) );
$isInternalCharset = false;
if ( trim( $charset ) == '' )
{
$charset = eZTextCodec::internalCharset();
$isInternalCharset = true;
}
$builtinEncoding = ( $ini->variable( 'DatabaseSettings', 'UseBuiltinEncoding' ) == 'true' );
$params = array('server' => $server,
'port' => $port,
'user' => $user,
'password' => $pwd,
'database' => $db,
'use_slave_server' => false,
'slave_server' => null,
'slave_port' => null,
'slave_user' => null,
'slave_password' => null,
'slave_database' => null,
'charset' => $charset,
'is_internal_charset' => $isInternalCharset,
'socket' => false,
'builtin_encoding' => $builtinEncoding,
'connect_retries' => $retries,
'use_persistent_connection' => $usePersistentConnection,
'show_errors' => true );
self::$_instance = new eZMySQLiDB( $params );
}
return self::$_instance;
}
开发者ID:sushilbshinde, 项目名称:ezpublish-study, 代码行数:44, 代码来源:mmdb.php
示例7: fetchAlphabet
static function fetchAlphabet()
{
$contentINI = eZINI::instance('content.ini');
$alphabetRangeList = $contentINI->hasVariable('AlphabeticalFilterSettings', 'AlphabetList') ? $contentINI->variable('AlphabeticalFilterSettings', 'AlphabetList') : array();
$alphabetFromArray = $contentINI->hasVariable('AlphabeticalFilterSettings', 'ContentFilterList') ? $contentINI->variable('AlphabeticalFilterSettings', 'ContentFilterList') : array('default');
// If alphabet list is empty
if (count($alphabetFromArray) == 0) {
return false;
}
$alphabetRangeList = array_merge($alphabetRangeList, array('default' => '97-122'));
$alphabet = array();
foreach ($alphabetFromArray as $alphabetFrom) {
// If $alphabetFrom exists in range array $alphabetRangeList
if (isset($alphabetRangeList[$alphabetFrom])) {
$lettersArray = explode(',', $alphabetRangeList[$alphabetFrom]);
foreach ($lettersArray as $letter) {
$rangeArray = explode('-', $letter);
if (isset($rangeArray[1])) {
$alphabet = array_merge($alphabet, range(trim($rangeArray[0]), trim($rangeArray[1])));
} else {
$alphabet = array_merge($alphabet, array(trim($letter)));
}
}
}
}
// Get alphabet by default (eng-GB)
if (count($alphabet) == 0) {
$rangeArray = explode('-', $alphabetRangeList['default']);
$alphabet = range($rangeArray[0], $rangeArray[1]);
}
$resAlphabet = array();
$i18nINI = eZINI::instance('i18n.ini');
$charset = $i18nINI->variable('CharacterSettings', 'Charset');
$codec = eZTextCodec::instance('utf-8', $charset);
$utf8_codec = eZUTF8Codec::instance();
// Convert all letters of alphabet from unicode to utf-8 and from utf-8 to current locale
foreach ($alphabet as $item) {
$utf8Letter = $utf8_codec->toUtf8($item);
$resAlphabet[] = $codec ? $codec->convertString($utf8Letter) : $utf8Letter;
}
return $resAlphabet;
}
开发者ID:nfrp, 项目名称:ezpublish, 代码行数:42, 代码来源:ezalphabetoperator.php
示例8: checkObjectAttribute
/**
* (called for each obj attribute)
*/
public function checkObjectAttribute(array $contentObjectAttribute)
{
// we adopt the ez api instead of acting on raw data
$contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
// do not check attributes which do not even contain images
if ($contentObjectAttribute->attribute('has_content')) {
if ($this->maxLen > 0) {
/// @todo check that this is the appropriate way of counting length of db data
$textCodec = eZTextCodec::instance(false);
$stringLength = $textCodec->strlen($contentObjectAttribute->attribute('content'));
if ($stringLength > $this->maxLen) {
return array("String longer than {$this->maxLen} chars: {$stringLength}" . $this->postfixErrorMsg($contentObjectAttribute));
}
}
} else {
if (!$this->nullable) {
return array("Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute));
}
}
return array();
}
开发者ID:gggeek, 项目名称:ezdbintegrity, 代码行数:24, 代码来源:ezdbiezstringchecker.php
示例9: convertNumericEntities
function convertNumericEntities($text)
{
if (strlen($text) < 4) {
return $text;
}
// Convert other HTML entities to the current charset characters.
$codec = eZTextCodec::instance('unicode', false);
$pos = 0;
$domString = "";
while ($pos < strlen($text) - 1) {
$startPos = $pos;
while (!($text[$pos] == '&' && isset($text[$pos + 1]) && $text[$pos + 1] == '#') && $pos < strlen($text) - 1) {
$pos++;
}
$domString .= substr($text, $startPos, $pos - $startPos);
if ($pos < strlen($text) - 1) {
$endPos = strpos($text, ';', $pos + 2);
if ($endPos === false) {
$pos += 2;
continue;
}
$code = substr($text, $pos + 2, $endPos - ($pos + 2));
$char = $codec->convertString(array($code));
$pos = $endPos + 1;
$domString .= $char;
} else {
$domString .= substr($text, $pos, 2);
}
}
return $domString;
}
开发者ID:jordanmanning, 项目名称:ezpublish, 代码行数:31, 代码来源:ezxmlinputparser.php
示例10: file_get_contents
}
$templateContent = file_get_contents( $fileName );
/* Here we figure out the characterset of the template. If there is a charset
* associated with the template in the header we use that one, if not we fall
* back to the INI setting "DefaultTemplateCharset". */
if ( preg_match('|{\*\?template.*charset=([a-zA-Z0-9-]*).*\?\*}|', $templateContent, $matches ) )
{
$templateCharset = $matches[1];
}
else
{
$templateCharset = $templateConfig->variable( 'CharsetSettings', 'DefaultTemplateCharset');
}
/* If we're loading a template for editting we need to convert it to the HTTP
* Charset. */
$codec = eZTextCodec::instance( $templateCharset, $outputCharset, false );
if ( $codec )
{
$templateContent = $codec->convertString( $templateContent );
}
$tpl->setVariable( 'template', $template );
$tpl->setVariable( 'template_content', $templateContent );
$Result['content'] = $tpl->fetch( "design:visual/templateedit.tpl" );
?>
开发者ID:robinmuilwijk, 项目名称:ezpublish, 代码行数:30, 代码来源:templateedit.php
示例11: strpos
$ifModifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
// Internet Explorer specific
$pos = strpos($ifModifiedSince, ';');
if ($pos !== false) {
$ifModifiedSince = substr($ifModifiedSince, 0, $pos);
}
if (strcmp($lastModified, $ifModifiedSince) == 0) {
header('HTTP/1.1 304 Not Modified');
header('Last-Modified: ' . $lastModified);
header('X-Powered-By: ' . eZPublishSDK::EDITION);
eZExecution::cleanExit();
}
}
$rssContent = $cacheFile->fetchContents();
}
}
// Set header settings
$httpCharset = eZTextCodec::httpCharset();
header('Last-Modified: ' . $lastModified);
if ($RSSExport->attribute('rss_version') === 'ATOM') {
header('Content-Type: application/xml; charset=' . $httpCharset);
} else {
header('Content-Type: application/rss+xml; charset=' . $httpCharset);
}
header('Content-Length: ' . strlen($rssContent));
header('X-Powered-By: ' . eZPublishSDK::EDITION);
for ($i = 0, $obLevel = ob_get_level(); $i < $obLevel; ++$i) {
ob_end_clean();
}
echo $rssContent;
eZExecution::cleanExit();
开发者ID:nfrp, 项目名称:ezpublish, 代码行数:31, 代码来源:feed.php
示例12: writeDocument
function writeDocument()
{
$ooINI = eZINI::instance('odf.ini');
// Initalize directories
eZDir::mkdir($this->OORootDir);
eZDir::mkdir($this->OOExportDir . "META-INF", false, true);
eZDir::mkdir($this->OOTemplateDir);
$metaXML = "<?xml version='1.0' encoding='UTF-8'?>" . "<office:document-meta xmlns:office='urn:oasis:names:tc:opendocument:xmlns:office:1.0' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:meta='urn:oasis:names:tc:opendocument:xmlns:meta:1.0' xmlns:ooo='http://openoffice.org/2004/office' office:version='1.0' xmlns:ezpublish='http://www.ez.no/ezpublish/oasis'>" . "<office:meta>" . "<meta:generator>eZ Publish</meta:generator>" . " <meta:creation-date>2004-11-10T11:39:50</meta:creation-date>" . " <dc:date>2004-11-10T11:40:15</dc:date>" . " <dc:language>en-US</dc:language>" . " <meta:editing-cycles>3</meta:editing-cycles>" . " <meta:editing-duration>PT26S</meta:editing-duration>" . " <meta:user-defined meta:name='Info 1'/>" . " <meta:user-defined meta:name='Info 2'/>" . " <meta:user-defined meta:name='Info 3'/>" . " <meta:user-defined meta:name='Info 4'/>" . " <meta:document-statistic meta:table-count='0' meta:image-count='0' meta:object-count='0' meta:page-count='1' meta:paragraph-count='1' meta:word-count='2' meta:character-count='10'/>" . " </office:meta>" . "</office:document-meta>";
file_put_contents($this->OOExportDir . "meta.xml", $metaXML);
$settingsXML = "<?xml version='1.0' encoding='UTF-8'?>" . "<office:document-settings xmlns:office='urn:oasis:names:tc:opendocument:xmlns:office:1.0' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:config='urn:oasis:names:tc:opendocument:xmlns:config:1.0' xmlns:ooo='http://openoffice.org/2004/office' office:version='1.0'>" . " <office:settings>" . " </office:settings>" . "</office:document-settings>";
file_put_contents($this->OOExportDir . "settings.xml", $settingsXML);
$useTemplate = $ooINI->variable('ODFExport', 'UseTemplate') == "true";
$templateName = $ooINI->variable('ODFExport', 'TemplateName');
if ($useTemplate) {
$templateFile = "extension/ezodf/templates/" . $templateName;
$archiveOptions = new ezcArchiveOptions(array('readOnly' => true));
$archive = ezcArchive::open($templateFile, null, $archiveOptions);
$archive->extract($this->OOTemplateDir);
// Copy styles.xml and images, if any to the document being generated
if (!copy($this->OOTemplateDir . "styles.xml", $this->OOExportDir . "styles.xml")) {
return array(self::ERROR_COULD_NOT_COPY, "Could not copy the styles.xml file.");
}
$sourceDir = $this->OOTemplateDir . "Pictures";
$destDir = $this->OOExportDir . "Pictures";
eZDir::mkdir($destDir, false, true);
eZDir::copy($sourceDir, $destDir, false, true);
} else {
// Generate a default empty styles.xml file
$stylesXML = "<?xml version='1.0' encoding='UTF-8'?>" . "<office:document-styles xmlns:office='urn:oasis:names:tc:opendocument:xmlns:office:1.0' xmlns:style='urn:oasis:names:tc:opendocument:xmlns:style:1.0' xmlns:text='urn:oasis:names:tc:opendocument:xmlns:text:1.0' xmlns:table='urn:oasis:names:tc:opendocument:xmlns:table:1.0' xmlns:draw='urn:oasis:names:tc:opendocument:xmlns:drawing:1.0' xmlns:fo='urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:meta='urn:oasis:names:tc:opendocument:xmlns:meta:1.0' xmlns:number='urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0' xmlns:svg='urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0' xmlns:chart='urn:oasis:names:tc:opendocument:xmlns:chart:1.0' xmlns:dr3d='urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0' xmlns:math='http://www.w3.org/1998/Math/MathML' xmlns:form='urn:oasis:names:tc:opendocument:xmlns:form:1.0' xmlns:script='urn:oasis:names:tc:opendocument:xmlns:script:1.0' xmlns:ooo='http://openoffice.org/2004/office' xmlns:ooow='http://openoffice.org/2004/writer' xmlns:oooc='http://openoffice.org/2004/calc' xmlns:dom='http://www.w3.org/2001/xml-events' office:version='1.0'>" . " <office:font-face-decls>" . " </office:font-face-decls>" . " <office:styles>" . " <style:style style:name='Table_20_Heading' style:display-name='Table Heading' style:family='paragraph' style:parent-style-name='Table_20_Contents' style:class='extra'>" . " <style:paragraph-properties fo:text-align='center' style:justify-single-word='false' text:number-lines='false' text:line-number='0'/>" . " <style:text-properties fo:font-style='italic' fo:font-weight='bold' style:font-style-asian='italic' style:font-weight-asian='bold' style:font-style-complex='italic' style:font-weight-complex='bold'/>" . " </style:style>" . " <style:style style:name='Preformatted_20_Text' style:display-name='Preformatted Text' style:family='paragraph' style:parent-style-name='Standard' style:class='html'>" . " <style:paragraph-properties fo:margin-top='0in' fo:margin-bottom='0in'/>" . " <style:text-properties style:font-name='Courier New' fo:font-size='10pt' style:font-name-asian='Courier New' style:font-size-asian='10pt' style:font-name-complex='Courier New' style:font-size-complex='10pt'/>" . " </style:style>" . " <style:style style:name='eZCustom_20_factbox' style:display-name='eZCustom_20_factbox' style:family='paragraph' style:parent-style-name='Standard' style:class='text'>" . " <style:paragraph-properties fo:margin-top='0in' fo:margin-bottom='0in'/>" . " <style:text-properties style:font-name='Helvetica' fo:font-size='10pt' style:font-name-asian='Helvetica' style:font-size-asian='10pt' style:font-name-complex='Helvetica' style:font-size-complex='10pt'/>" . " </style:style>" . " <style:style style:name='eZCustom_20_quote' style:display-name='eZCustom_20_quote' style:family='paragraph' style:parent-style-name='Standard' style:class='text'>" . " <style:paragraph-properties fo:margin-top='0in' fo:margin-bottom='0in'/>" . " <style:text-properties style:font-name='Helvetica' fo:font-size='10pt' style:font-name-asian='Helvetica' style:font-size-asian='10pt' style:font-name-complex='Helvetica' style:font-size-complex='10pt'/>" . " </style:style>" . " </office:styles>" . "</office:document-styles>";
file_put_contents($this->OOExportDir . "styles.xml", $stylesXML);
}
$mimeType = "application/vnd.oasis.opendocument.text";
file_put_contents($this->OOExportDir . "mimetype", $mimeType);
// Write content XML file
$contentXML = "<?xml version='1.0' encoding='UTF-8'?>" . "<!DOCTYPE office:document-content PUBLIC '-//OpenOffice.org//DTD OfficeDocument1.0//EN' 'office.dtd'>" . "<office:document-content xmlns:office='urn:oasis:names:tc:opendocument:xmlns:office:1.0'" . " xmlns:meta='urn:oasis:names:tc:opendocument:xmlns:meta:1.0'" . " xmlns:config='urn:oasis:names:tc:opendocument:xmlns:config:1.0'" . " xmlns:text='urn:oasis:names:tc:opendocument:xmlns:text:1.0'" . " xmlns:table='urn:oasis:names:tc:opendocument:xmlns:table:1.0'" . " xmlns:draw='urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'" . " xmlns:presentation='urn:oasis:names:tc:opendocument:xmlns:presentation:1.0'" . " xmlns:dr3d='urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'" . " xmlns:chart='urn:oasis:names:tc:opendocument:xmlns:chart:1.0'" . " xmlns:form='urn:oasis:names:tc:opendocument:xmlns:form:1.0'" . " xmlns:script='urn:oasis:names:tc:opendocument:xmlns:script:1.0'" . " xmlns:style='urn:oasis:names:tc:opendocument:xmlns:style:1.0'" . " xmlns:number='urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'" . " xmlns:math='http://www.w3.org/1998/Math/MathML'" . " xmlns:svg='urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'" . " xmlns:fo='urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'" . " xmlns:koffice='http://www.koffice.org/2005/'" . " xmlns:dc='http://purl.org/dc/elements/1.1/'" . " xmlns:xlink='http://www.w3.org/1999/xlink'>" . " <office:script/>" . " <office:font-face-decls/>" . " <office:automatic-styles>" . " <text:list-style style:name='bulletlist'>" . " <text:list-level-style-bullet text:level='1' text:style-name='Bullet_20_Symbols' style:num-suffix='.' text:bullet-char='●'>" . " <style:list-level-properties text:space-before='0.25in' text:min-label-width='0.25in'/>" . " <style:text-properties style:font-name='StarSymbol'/>" . " </text:list-level-style-bullet>" . " <text:list-level-style-bullet text:level='2' text:style-name='Bullet_20_Symbols' style:num-suffix='.' text:bullet-char='○'>" . " <style:list-level-properties text:space-before='0.5in' text:min-label-width='0.25in'/>" . " <style:text-properties style:font-name='StarSymbol'/>" . " </text:list-level-style-bullet>" . " <text:list-level-style-bullet text:level='3' text:style-name='Bullet_20_Symbols' style:num-suffix='.' text:bullet-char='■'>" . " <style:list-level-properties text:space-before='0.75in' text:min-label-width='0.25in'/>" . " <style:text-properties style:font-name='StarSymbol'/>" . " </text:list-level-style-bullet>" . " </text:list-style>" . " <text:list-style style:name='numberedlist'>" . " <text:list-level-style-number text:level='1' text:style-name='Numbering_20_Symbols' style:num-suffix='.' style:num-format='1'>" . " <style:list-level-properties text:space-before='0.25in' text:min-label-width='0.25in'/>" . " </text:list-level-style-number>" . " </text:list-style>" . " <style:style style:name='imagecentered' style:family='graphic' style:parent-style-name='Graphics'>" . " <style:graphic-properties style:horizontal-pos='center' style:horizontal-rel='paragraph' style:mirror='none' fo:clip='rect(0in 0in 0in 0in)' draw:luminance='0%' draw:contrast='0%' draw:red='0%' draw:green='0%' draw:blue='0%' draw:gamma='100%' draw:color-inversion='false' draw:image-opacity='100%' draw:color-mode='standard'/>" . " </style:style>" . " <style:style style:name='imageleft' style:family='graphic' style:parent-style-name='Graphics'>" . " <style:graphic-properties style:wrap='right' style:horizontal-pos='left' style:horizontal-rel='paragraph' style:mirror='none' fo:clip='rect(0in 0in 0in 0in)' draw:luminance='0%' draw:contrast='0%' draw:red='0%' draw:green='0%' draw:blue='0%' draw:gamma='100%' draw:color-inversion='false' draw:image-opacity='100%' draw:color-mode='standard'/>" . " </style:style>" . " <style:style style:name='imageright' style:family='graphic' style:parent-style-name='Graphics'>" . " <style:graphic-properties style:wrap='left' style:horizontal-pos='right' style:horizontal-rel='paragraph' style:mirror='none' fo:clip='rect(0in 0in 0in 0in)' draw:luminance='0%' draw:contrast='0%' draw:red='0%' draw:green='0%' draw:blue='0%' draw:gamma='100%' draw:color-inversion='false' draw:image-opacity='100%' draw:color-mode='standard'/>" . " </style:style>" . " <style:style style:name='T1' style:family='text'>" . " <style:text-properties fo:font-weight='bold' style:font-weight-asian='bold' style:font-weight-complex='bold'/>" . " </style:style>" . " <style:style style:name='T2' style:family='text'>" . " <style:text-properties fo:font-style='italic' style:font-style-asian='italic' style:font-style-complex='italic'/>" . " </style:style>" . " </office:automatic-styles>" . " <office:body>" . " <office:text>";
$bodyXML = "";
// Add body contents
foreach ($this->DocumentArray as $element) {
$bodyXML .= $this->handleElement($element);
}
// Handle charset conversion if needed
$charset = 'UTF-8';
$codec = eZTextCodec::instance(false, $charset);
$bodyXML = $codec->convertString($bodyXML);
$contentXML .= $bodyXML;
// Add the content end
$contentXML .= "</office:text></office:body></office:document-content>";
file_put_contents($this->OOExportDir . "content.xml", $contentXML);
// Write the manifest file
$manifestXML = "<?xml version='1.0' encoding='UTF-8'?>" . "<!DOCTYPE manifest:manifest PUBLIC '-//OpenOffice.org//DTD Manifest 1.0//EN' 'Manifest.dtd'>" . "<manifest:manifest xmlns:manifest='urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'>" . "<manifest:file-entry manifest:media-type='application/vnd.oasis.opendocument.text' manifest:full-path='/'/>" . "<manifest:file-entry manifest:media-type='application/vnd.sun.xml.ui.configuration' manifest:full-path='Configurations2/'/>" . "<manifest:file-entry manifest:media-type='' manifest:full-path='Pictures/'/>" . "<manifest:file-entry manifest:media-type='text/xml' manifest:full-path='content.xml'/>" . "<manifest:file-entry manifest:media-type='text/xml' manifest:full-path='styles.xml'/>" . "<manifest:file-entry manifest:media-type='text/xml' manifest:full-path='meta.xml'/>" . "<manifest:file-entry manifest:media-type='' manifest:full-path='Thumbnails/'/>" . "<manifest:file-entry manifest:media-type='text/xml' manifest:full-path='settings.xml'/>";
// Do not include the thumnail file.
// "<manifest:file-entry manifest:media-type='' manifest:full-path='Thumbnails/thumbnail.png'/>" .
foreach ($this->ImageFileArray as $imageFile) {
$manifestXML .= "<manifest:file-entry manifest:media-type='' manifest:full-path='{$imageFile}'/>\n";
}
$manifestXML .= "</manifest:manifest>";
file_put_contents($this->OOExportDir . "META-INF/manifest.xml", $manifestXML);
$fileName = $this->OORootDir . "ootest.odt";
$zipArchive = ezcArchive::open($fileName, ezcArchive::ZIP);
$zipArchive->truncate();
$prefix = $this->OOExportDir;
$fileList = array();
eZDir::recursiveList($this->OOExportDir, $this->OOExportDir, $fileList);
foreach ($fileList as $fileInfo) {
$path = $fileInfo['type'] === 'dir' ? $fileInfo['path'] . '/' . $fileInfo['name'] . '/' : $fileInfo['path'] . '/' . $fileInfo['name'];
$zipArchive->append(array($path), $prefix);
}
$zipArchive->close();
// Clean up
eZDir::recursiveDelete($this->OOExportDir);
eZDir::recursiveDelete($this->OOTemplateDir);
// Clean up temporary image files if any
$fileHandler = eZClusterFileHandler::instance();
foreach ($this->SourceImageArray as $sourceImageFile) {
$fileHandler->fileDeleteLocal($sourceImageFile);
}
return $fileName;
}
开发者ID:brookinsconsulting, 项目名称:ezecosystem, 代码行数:78, 代码来源:ezoogenerator.php
示例13: instance
/**
* Returns a shared instance of the eZDBInterface class aka database object.
* If you want to change the current database values you should use $forceNewInstance.
*
* @param string|false $databaseImplementation
* @param array|false $databaseParameters If array, then key 'use_defaults' (bool) is used.
* @param bool $forceNewInstance
* @return eZDBInterface
*/
static function instance($databaseImplementation = false, $databaseParameters = false, $forceNewInstance = false)
{
$impl =& $GLOBALS['eZDBGlobalInstance'];
$fetchInstance = false;
if (!$impl instanceof eZDBInterface) {
$fetchInstance = true;
}
if ($forceNewInstance) {
unset($impl);
$impl = false;
$fetchInstance = true;
}
$useDefaults = true;
if (is_array($databaseParameters) and isset($databaseParameters['use_defaults'])) {
$useDefaults = $databaseParameters['use_defaults'];
}
if ($fetchInstance) {
$ini = eZINI::instance();
if ($databaseImplementation === false and $useDefaults) {
$databaseImplementation = $ini->variable('DatabaseSettings', 'DatabaseImplementation');
}
$server = $user = $pwd = $db = $usePersistentConnection = $port = false;
if ($useDefaults) {
list($server, $port, $user, $pwd, $db, $usePersistentConnection) = $ini->variableMulti('DatabaseSettings', array('Server', 'Port', 'User', 'Password', 'Database', 'UsePersistentConnection'));
}
$socketPath = false;
if ($useDefaults) {
$socket = $ini->variable('DatabaseSettings', 'Socket');
if (trim($socket != "") and $socket != "disabled") {
$socketPath = $socket;
}
}
// Check slave servers
$slaveServer = null;
$slaveServerPort = null;
$slaveServerUser = null;
$slaveServerPassword = null;
$slaveServerDatabase = null;
$useSlave = $ini->variable('DatabaseSettings', 'UseSlaveServer');
if ($useSlave == "enabled") {
$slaveServers = $ini->variable('DatabaseSettings', 'SlaveServerArray');
$slaveServerPorts = $ini->variable('DatabaseSettings', 'SlaveServerPort');
$slaveServerUsers = $ini->variable('DatabaseSettings', 'SlaverServerUser');
$slaveServerPasswords = $ini->variable('DatabaseSettings', 'SlaverServerPassword');
$slaveServerDatabases = $ini->variable('DatabaseSettings', 'SlaverServerDatabase');
$numberServers = count($slaveServers);
if ($numberServers > 1) {
$index = mt_rand(1, $numberServers) - 1;
} else {
$index = 0;
}
$slaveServer = $slaveServers[$index];
$slaveServerPort = $slaveServerPorts[$index];
$slaveServerUser = $slaveServerUsers[$index];
$slaveServerPassword = $slaveServerPasswords[$index];
$slaveServerDatabase = $slaveServerDatabases[$index];
}
list($charset, $retries) = $ini->variableMulti('DatabaseSettings', array('Charset', 'ConnectRetries'));
$isInternalCharset = false;
if (trim($charset) == '') {
$charset = eZTextCodec::internalCharset();
$isInternalCharset = true;
}
$builtinEncoding = $ini->variable('DatabaseSettings', 'UseBuiltinEncoding') == 'true';
$impl = null;
$useSlaveServer = false;
if ($useSlave == "enabled") {
$useSlaveServer = true;
}
$defaultDatabaseParameters = array('server' => $server, 'port' => $port, 'user' => $user, 'password' => $pwd, 'database' => $db, 'use_slave_server' => $useSlaveServer, 'slave_server' => $slaveServer, 'slave_port' => $slaveServerPort, 'slave_user' => $slaveServerUser, 'slave_password' => $slaveServerPassword, 'slave_database' => $slaveServerDatabase, 'charset' => $charset, 'is_internal_charset' => $isInternalCharset, 'socket' => $socketPath, 'builtin_encoding' => $builtinEncoding, 'connect_retries' => $retries, 'use_persistent_connection' => $usePersistentConnection, 'show_errors' => true);
/* This looks funny, but is needed to fix a crash in PHP */
$b = $databaseParameters;
$databaseParameters = $defaultDatabaseParameters;
if (isset($b['server'])) {
$databaseParameters['server'] = $b['server'];
}
if (isset($b['port'])) {
$databaseParameters['port'] = $b['port'];
}
if (isset($b['user'])) {
$databaseParameters['user'] = $b['user'];
}
if (isset($b['password'])) {
$databaseParameters['password'] = $b['password'];
}
if (isset($b['database'])) {
$databaseParameters['database'] = $b['database'];
}
if (isset($b['use_slave_server'])) {
$databaseParameters['use_slave_server'] = $b['use_slave_server'];
}
//.........这里部分代码省略.........
开发者ID:nfrp, 项目名称:ezpublish, 代码行数:101, 代码来源:ezdb.php
示例14: modify
function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement )
{
$config = eZINI::instance( 'pdf.ini' );
switch ( $namedParameters['operation'] )
{
case 'toc':
{
$operatorValue = '<C:callTOC';
if ( count( $operatorParameters ) > 1 )
{
$params = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
$operatorValue .= isset( $params['size'] ) ? ':size:'. implode(',', $params['size'] ) : '';
$operatorValue .= isset( $params['dots'] ) ? ':dots:'. $params['dots'] : '';
$operatorValue .= isset( $params['contentText'] ) ? ':contentText:'. $params['contentText'] : '';
$operatorValue .= isset( $params['indent'] ) ? ':indent:'. implode(',', $params['indent'] ) : '';
}
$operatorValue .= '>';
eZDebug::writeNotice( 'PDF: Generating TOC', __METHOD__ );
} break;
case 'set_font':
{
$params = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
$operatorValue = '<ezCall:callFont';
foreach ( $params as $key => $value )
{
if ( $key == 'colorCMYK' )
{
$operatorValue .= ':cmyk:' . implode( ',', $value );
}
else if ( $key == 'colorRGB' )
{
$operatorValue .= ':cmyk:' . implode( ',', eZMath::rgbToCMYK2( $value[0]/255,
$value[1]/255,
$value[2]/255 ) );
}
else
{
$operatorValue .= ':' . $key . ':' . $value;
}
}
$operatorValue .= '>';
eZDebug::writeNotice( 'PDF: Changed font.' );
} break;
case 'table':
{
$operatorValue = '<ezGroup:callTable';
if ( count( $operatorParameters > 2 ) )
{
$tableSettings = $tpl->elementValue( $operatorParameters[2], $rootNamespace, $currentNamespace );
if ( is_array( $tableSettings ) )
{
foreach( array_keys( $tableSettings ) as $key )
{
switch( $key )
{
case 'headerCMYK':
case 'cellCMYK':
case 'textCMYK':
case 'titleCellCMYK':
case 'titleTextCMYK':
{
$operatorValue .= ':' . $key . ':' . implode( ',', $tableSettings[$key] );
} break;
default:
{
$operatorValue .= ':' . $key . ':' . $tableSettings[$key];
} break;
}
}
}
}
$operatorValue .= '>';
$rows = $tpl->elementValue( $operatorParameters[1], $rootNamespace, $currentNamespace );
$rows = str_replace( array( ' ', "\t", "\r\n", "\n" ),
'',
$rows );
$httpCharset = eZTextCodec::internalCharset();
$outputCharset = $config->hasVariable( 'PDFGeneral', 'OutputCharset' )
? $config->variable( 'PDFGeneral', 'OutputCharset' )
: 'iso-8859-1';
$codec = eZTextCodec::instance( $httpCharset, $outputCharset );
// Convert current text to $outputCharset (by default iso-8859-1)
$rows = $codec->convertString( $rows );
//.........这里部分代码省略.........
开发者ID:nottavi, 项目名称:ezpublish, 代码行数:101, 代码来源:ezpdf.php
GitbookIO/gitbook:
阅读:954| 2022-08-17
juleswhite/mobile-cloud-asgn1
阅读:1029| 2022-08-30
kyamagu/matlab-json: Use official API: https://mathworks.com/help/matlab/json-fo
阅读:924| 2022-08-17
书名:墙壁眼睛膝盖 作者:温柔一刀 类别:欲望丛林,饮食男女。 簡介:Wall(我)Eye(爱)Kn
阅读:655| 2022-11-06
前言 在编写MATLAB程序时,我们可以不指定变量的数据类型。这使得MATALB编程很接近演
阅读:1519| 2022-07-18
sevenjay/cpp-markdown: Cpp-Markdown is a freely-available Markdown text-to-HTML
阅读:578| 2022-08-18
Q1: 多线程中需避免多个线程同时向全局变量进行写入操作,导致访问冲突问题。A1:
阅读:1193| 2022-07-18
An issue in the isSVG() function of Known v1.2.2+2020061101 allows attackers to
阅读:967| 2022-07-29
mathjax/MathJax-i18n: MathJax localization
阅读:387| 2022-08-16
众所周知,我们的身份证号码里面包含的信息有很多,如出生日期、性别和识别码等,如果
阅读:251| 2022-11-06
请发表评论