本文整理汇总了PHP中eZCharTransform::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZCharTransform::instance方法的具体用法?PHP eZCharTransform::instance怎么用?PHP eZCharTransform::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZCharTransform
的用法示例。
在下文中一共展示了eZCharTransform::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPhrase
static function addPhrase($phrase, $returnCount)
{
$db = eZDB::instance();
$db->begin();
$db->lock("ezsearch_search_phrase");
$trans = eZCharTransform::instance();
$phrase = $trans->transformByGroup(trim($phrase), 'search');
// 250 is the numbers of characters accepted by the DB table, so shorten to fit
if (strlen($phrase) > 250) {
$phrase = substr($phrase, 0, 247) . "...";
}
$phrase = $db->escapeString($phrase);
// find or store the phrase
$phraseRes = $db->arrayQuery("SELECT id FROM ezsearch_search_phrase WHERE phrase='{$phrase}'");
if (count($phraseRes) == 1) {
$phraseID = $phraseRes[0]['id'];
$db->query("UPDATE ezsearch_search_phrase\n SET phrase_count = phrase_count + 1,\n result_count = result_count + {$returnCount}\n WHERE id = {$phraseID}");
} else {
$db->query("INSERT INTO\n ezsearch_search_phrase ( phrase, phrase_count, result_count )\n VALUES ( '{$phrase}', 1, {$returnCount} )");
/* when breaking BC: delete next line */
$phraseID = $db->lastSerialID('ezsearch_search_phrase', 'id');
}
$db->unlock();
/* when breaking BC: delete next lines */
/* ezsearch_return_count is not used any more by eZ Publish
but perhaps someone else added some functionality... */
$time = time();
// store the search result
$db->query("INSERT INTO\n ezsearch_return_count ( phrase_id, count, time )\n VALUES ( '{$phraseID}', '{$returnCount}', '{$time}' )");
/* end of BC breaking delete*/
$db->commit();
}
示例2: autocomplete
/**
* Provides auto complete results when adding tags to object
*
* @static
*
* @param array $args
*
* @return array
*/
public static function autocomplete($args)
{
$http = eZHTTPTool::instance();
$searchString = trim($http->postVariable('search_string'), '');
if (empty($searchString)) {
return array('status' => 'success', 'message' => '', 'tags' => array());
}
// Initialize transformation system
$trans = eZCharTransform::instance();
$searchString = $trans->transformByGroup($http->postVariable('search_string'), 'lowercase');
return self::generateOutput(array('LOWER( eztags_keyword.keyword )' => array('like', $searchString . '%')), $http->postVariable('subtree_limit', 0), $http->postVariable('hide_root_tag', '0'), $http->postVariable('locale', ''));
}
示例3: addColumn
function addColumn($name = false, $id = false)
{
if ($name == false) {
$name = 'Col_' . count($this->ColumnNames);
}
if ($id == false) {
// Initialize transformation system
$trans = eZCharTransform::instance();
$id = $trans->transformByGroup($name, 'identifier');
}
$this->ColumnNames[] = array('name' => $name, 'identifier' => $id, 'index' => count($this->ColumnNames));
}
示例4: fetchObjectAttributeHTTPInput
function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$postVariableName = $base . "_data_object_relation_id_" . $contentObjectAttribute->attribute("id");
$haveData = false;
if ($http->hasPostVariable($postVariableName)) {
$relatedObjectID = $http->postVariable($postVariableName);
if ($relatedObjectID == '') {
$relatedObjectID = null;
}
$contentObjectAttribute->setAttribute('data_int', $relatedObjectID);
$haveData = true;
}
$fuzzyMatchVariableName = $base . "_data_object_relation_fuzzy_match_" . $contentObjectAttribute->attribute("id");
if ($http->hasPostVariable($fuzzyMatchVariableName)) {
$trans = eZCharTransform::instance();
$fuzzyMatchText = trim($http->postVariable($fuzzyMatchVariableName));
if ($fuzzyMatchText != '') {
$fuzzyMatchText = $trans->transformByGroup($fuzzyMatchText, 'lowercase');
$classAttribute = $contentObjectAttribute->attribute('contentclass_attribute');
if ($classAttribute) {
$classContent = $classAttribute->content();
if ($classContent['default_selection_node']) {
$nodeID = $classContent['default_selection_node'];
$nodeList = eZContentObjectTreeNode::subTreeByNodeID(array('Depth' => 1), $nodeID);
$lastDiff = false;
$matchObjectID = false;
foreach ($nodeList as $node) {
$name = $trans->transformByGroup(trim($node->attribute('name')), 'lowercase');
$diff = $this->fuzzyTextMatch($name, $fuzzyMatchText);
if ($diff === false) {
continue;
}
if ($diff == 0) {
$matchObjectID = $node->attribute('contentobject_id');
break;
}
if ($lastDiff === false or $diff < $lastDiff) {
$lastDiff = $diff;
$matchObjectID = $node->attribute('contentobject_id');
}
}
if ($matchObjectID !== false) {
$contentObjectAttribute->setAttribute('data_int', $matchObjectID);
$haveData = true;
}
}
}
}
}
return $haveData;
}
示例5: install
function install($package, $installType, $parameters, $name, $os, $filename, $subdirectory, $content, &$installParameters, &$installData)
{
//$this->Package =& $package;
$trans = eZCharTransform::instance();
$name = $content->getAttribute('name');
$extensionName = $trans->transformByGroup($name, 'urlalias');
if (strcmp($name, $extensionName) !== 0) {
$description = ezpI18n::tr('kernel/package', 'Package contains an invalid extension name: %extensionname', false, array('%extensionname' => $name));
$installParameters['error'] = array('error_code' => false, 'element_id' => $name, 'description' => $description);
return false;
}
$siteINI = eZINI::instance();
$extensionRootDir = $siteINI->variable('ExtensionSettings', 'ExtensionDirectory');
$extensionDir = $extensionRootDir . '/' . $extensionName;
$packageExtensionDir = $package->path() . '/' . $parameters['sub-directory'] . '/' . $extensionName;
// Error: extension already exists.
if (file_exists($extensionDir)) {
$description = ezpI18n::tr('kernel/package', "Extension '%extensionname' already exists.", false, array('%extensionname' => $extensionName));
$choosenAction = $this->errorChoosenAction(self::ERROR_EXISTS, $installParameters, $description, $this->HandlerType);
switch ($choosenAction) {
case self::ACTION_SKIP:
return true;
case eZPackage::NON_INTERACTIVE:
case self::ACTION_REPLACE:
eZDir::recursiveDelete($extensionDir);
break;
default:
$installParameters['error'] = array('error_code' => self::ERROR_EXISTS, 'element_id' => $extensionName, 'description' => $description, 'actions' => array(self::ACTION_REPLACE => ezpI18n::tr('kernel/package', "Replace extension"), self::ACTION_SKIP => ezpI18n::tr('kernel/package', 'Skip')));
return false;
}
}
eZDir::mkdir($extensionDir, false, true);
eZDir::copy($packageExtensionDir, $extensionRootDir);
// Regenerate autoloads for extensions to pick up the newly created extension
ezpAutoloader::updateExtensionAutoloadArray();
// Activate extension
$siteINI = eZINI::instance('site.ini', 'settings/override', null, null, false, true);
if ($siteINI->hasVariable('ExtensionSettings', "ActiveExtensions")) {
$selectedExtensions = $siteINI->variable('ExtensionSettings', "ActiveExtensions");
} else {
$selectedExtensions = array();
}
if (!in_array($extensionName, $selectedExtensions)) {
$selectedExtensions[] = $extensionName;
$siteINI->setVariable("ExtensionSettings", "ActiveExtensions", $selectedExtensions);
$siteINI->save('site.ini.append', '.php', false, false);
}
return true;
}
示例6: addPhrase
static function addPhrase($phrase, $returnCount)
{
$db = eZDB::instance();
$db->begin();
$db->lock("ezsearch_search_phrase");
$trans = eZCharTransform::instance();
$phrase = $trans->transformByGroup(trim($phrase), 'search');
// 250 is the numbers of characters accepted by the DB table, so shorten to fit
if (strlen($phrase) > 250) {
$phrase = substr($phrase, 0, 247) . "...";
}
$phrase = $db->escapeString($phrase);
// find or store the phrase
$phraseRes = $db->arrayQuery("SELECT id FROM ezsearch_search_phrase WHERE phrase='{$phrase}'");
if (count($phraseRes) == 1) {
$phraseID = $phraseRes[0]['id'];
$db->query("UPDATE ezsearch_search_phrase\n SET phrase_count = phrase_count + 1,\n result_count = result_count + {$returnCount}\n WHERE id = {$phraseID}");
} else {
$db->query("INSERT INTO\n ezsearch_search_phrase ( phrase, phrase_count, result_count )\n VALUES ( '{$phrase}', 1, {$returnCount} )");
}
$db->unlock();
$db->commit();
}
示例7: sortKey
/**
* Returns a key to sort attributes.
*
* @param mixed $contentObjectAttribute Class eZContentObjectAttribute.
*
* @return string
*/
public function sortKey($contentObjectAttribute)
{
include_once 'lib/ezi18n/classes/ezchartransform.php';
$trans = eZCharTransform::instance();
$data = $contentObjectAttribute->attribute('data_text');
return $trans->transformByGroup($data, 'lowercase');
}
示例8: fetchKeyword
static public function fetchKeyword( $alphabet,
$classid,
$offset,
$limit,
$owner = false,
$sortBy = array(),
$parentNodeID = false,
$includeDuplicates = true,
$strictMatching = false )
{
$classIDArray = array();
if ( is_numeric( $classid ) )
{
$classIDArray = array( $classid );
}
else if ( is_array( $classid ) )
{
$classIDArray = $classid;
}
$showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString( true, false );
$limitation = false;
$limitationList = eZContentObjectTreeNode::getLimitationList( $limitation );
$sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL( $limitationList );
$db_params = array();
$db_params['offset'] = $offset;
$db_params['limit'] = $limit;
$keywordNodeArray = array();
$lastKeyword = '';
$db = eZDB::instance();
//in SELECT clause below we will use a full keyword value
//or just a part of ezkeyword.keyword matched to $alphabet respective to $includeDuplicates parameter.
//In the case $includeDuplicates = ture we need only a part
//of ezkeyword.keyword to be fetched in field to allow DISTINCT to remove rows with the same node id's
$sqlKeyword = 'ezkeyword.keyword';
if ( !$includeDuplicates )
{
$sqlKeyword = $db->subString('ezkeyword.keyword', 1, strlen( $alphabet ) ) . ' AS keyword ';
}
$alphabet = $db->escapeString( $alphabet );
$sortingInfo = array();
$sortingInfo['attributeFromSQL'] = ', ezcontentobject_attribute a1';
$sortingInfo['attributeWhereSQL'] = '';
$sqlTarget = $sqlKeyword.',ezcontentobject_tree.node_id';
if ( is_array( $sortBy ) && count ( $sortBy ) > 0 )
{
switch ( $sortBy[0] )
{
case 'keyword':
case 'name':
{
$sortingString = '';
if ( $sortBy[0] == 'name' )
{
$sortingString = 'ezcontentobject.name';
$sortingInfo['attributeTargetSQL'] = ', ' . $sortingString;
}
elseif ( $sortBy[0] == 'keyword' )
{
if ( $includeDuplicates )
$sortingString = 'ezkeyword.keyword';
else
$sortingString = 'keyword';
$sortingInfo['attributeTargetSQL'] = '';
}
$sortOrder = true; // true is ascending
if ( isset( $sortBy[1] ) )
$sortOrder = $sortBy[1];
$sortingOrder = $sortOrder ? ' ASC' : ' DESC';
$sortingInfo['sortingFields'] = $sortingString . $sortingOrder;
} break;
default:
{
$sortingInfo = eZContentObjectTreeNode::createSortingSQLStrings( $sortBy );
if ( $sortBy[0] == 'attribute' )
{
// if sort_by is 'attribute' we should add ezcontentobject_name to "FromSQL" and link to ezcontentobject
$sortingInfo['attributeFromSQL'] .= ', ezcontentobject_name, ezcontentobject_attribute a1';
$sortingInfo['attributeWhereSQL'] .= ' ezcontentobject.id = ezcontentobject_name.contentobject_id AND';
$sqlTarget = 'DISTINCT ezcontentobject_tree.node_id, '.$sqlKeyword;
}
else // for unique declaration
{
$sortByArray = explode( ' ', $sortingInfo['sortingFields'] );
$sortingInfo['attributeTargetSQL'] .= ', ' . $sortByArray[0];
$sortingInfo['attributeFromSQL'] .= ', ezcontentobject_attribute a1';
}
} break;
}
//.........这里部分代码省略.........
示例9: validatePackageInformation
function validatePackageInformation($package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList)
{
$packageName = false;
$packageSummary = false;
$packageVersion = false;
$packageDescription = false;
$packageLicence = 'GPL';
$packageHost = false;
$packagePackager = false;
if ($http->hasPostVariable('PackageName')) {
$packageName = trim($http->postVariable('PackageName'));
}
if ($http->hasPostVariable('PackageSummary')) {
$packageSummary = $http->postVariable('PackageSummary');
}
if ($http->hasPostVariable('PackageDescription')) {
$packageDescription = $http->postVariable('PackageDescription');
}
if ($http->hasPostVariable('PackageVersion')) {
$packageVersion = trim($http->postVariable('PackageVersion'));
}
if ($http->hasPostVariable('PackageLicence')) {
$packageLicence = $http->postVariable('PackageLicence');
}
if ($http->hasPostVariable('PackageHost')) {
$packageHost = $http->postVariable('PackageHost');
}
if ($http->hasPostVariable('PackagePackager')) {
$packagePackager = $http->postVariable('PackagePackager');
}
$persistentData['name'] = $packageName;
$persistentData['summary'] = $packageSummary;
$persistentData['description'] = $packageDescription;
$persistentData['version'] = $packageVersion;
$persistentData['licence'] = $packageLicence;
$persistentData['host'] = $packageHost;
$persistentData['packager'] = $packagePackager;
$result = true;
if ($packageName == '') {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Package name'), 'description' => ezpI18n::tr('kernel/package', 'Package name is missing'));
$result = false;
} else {
$existingPackage = eZPackage::fetch($packageName, false, true);
if ($existingPackage) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Package name'), 'description' => ezpI18n::tr('kernel/package', 'A package named %packagename already exists, please give another name', false, array('%packagename' => $packageName)));
$result = false;
} else {
// Make sure the package name contains only valid characters
$trans = eZCharTransform::instance();
$validPackageName = $trans->transformByGroup($packageName, 'identifier');
if (strcmp($validPackageName, $packageName) != 0) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Package name'), 'description' => ezpI18n::tr('kernel/package', "The package name %packagename is not valid, it can only contain characters in the range a-z, 0-9 and underscore.", false, array('%packagename' => $packageName)));
$result = false;
}
}
}
if (!$packageSummary) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Summary'), 'description' => ezpI18n::tr('kernel/package', 'Summary is missing'));
$result = false;
}
if (!preg_match("#^[0-9](\\.[0-9]([a-zA-Z]+[0-9]*)?)*\$#", $packageVersion)) {
$errorList[] = array('field' => ezpI18n::tr('kernel/package', 'Version'), 'description' => ezpI18n::tr('kernel/package', 'The version must only contain numbers (optionally followed by text) and must be delimited by dots (.), e.g. 1.0, 3.4.0beta1'));
$result = false;
}
return $result;
}
示例10: isValidName
/**
* Checks if a package name is valid
*
* @param string $packageName the package name
* @param string $transformedPackageName the package name, transformed to be valid
* @return boolean true if the package name is valid, false if not
*/
static function isValidName($packageName, &$transformedPackageName = null)
{
$trans = eZCharTransform::instance();
$transformedPackageName = $trans->transformByGroup($packageName, 'identifier');
return $transformedPackageName === $packageName;
}
示例11: sortKey
function sortKey($contentObjectAttribute)
{
$trans = eZCharTransform::instance();
return $trans->transformByGroup($contentObjectAttribute->attribute('data_text'), 'lowercase');
}
示例12: sortKey
function sortKey($contentObjectAttribute)
{
$trans = eZCharTransform::instance();
$content = $contentObjectAttribute->content();
return $trans->transformByGroup($content['value'], 'lowercase');
}
示例13: normalizeText
function normalizeText($text, $isMetaData = false)
{
$trans = eZCharTransform::instance();
$text = $trans->transformByGroup($text, 'search');
// Remove quotes and asterix when not handling search text by end-user
if ($isMetaData) {
$text = str_replace(array("\"", "*"), array(" ", " "), $text);
}
return $text;
}
示例14: array
<?php
/**
* File containing the section identifier upgrade script.
*
* @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version 2013.11
* @package update
*/
require 'autoload.php';
$script = eZScript::instance(array('description' => 'eZ Publish section identifier update script. ' . 'This script will update existing sections with missing identifiers.', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions('', '', array('-q' => 'Quiet mode'));
$script->initialize();
$cli = eZCLI::instance();
$trans = eZCharTransform::instance();
// Fetch 50 items per iteration
$limit = 50;
$offset = 0;
do {
// Fetch items with empty identifier
$rows = eZSection::fetchFilteredList(null, $offset, $limit);
if (!$rows) {
break;
}
foreach ($rows as $row) {
if ($row->attribute('identifier') == '') {
// Create a new section identifier with NAME_ID pattern
$name = $row->attribute('name');
$identifier = $trans->transformByGroup($name, 'identifier') . '_' . $row->attribute('id');
// Set new section identifier and store it
示例15: normalizeText
function normalizeText($text, $isMetaData = false)
{
$text = self::removeDuplicatedSpaces(trim(self::removeAllQuotes(eZCharTransform::instance()->transformByGroup($text, 'search'))));
// Remove quotes and asterix when not handling search text by end-user
if ($isMetaData) {
$text = str_replace("*", " ", $text);
}
return $text;
}