本文整理汇总了PHP中eZCharTransform类 的典型用法代码示例。如果您正苦于以下问题:PHP eZCharTransform类的具体用法?PHP eZCharTransform怎么用?PHP eZCharTransform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZCharTransform类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:jordanmanning, 项目名称:ezpublish, 代码行数:32, 代码来源:ezsearchlog.php
示例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', ''));
}
开发者ID:BornaP, 项目名称:eztags, 代码行数:21, 代码来源:ezjsctags.php
示例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));
}
开发者ID:EVE-Corp-Center, 项目名称:ECC-Website, 代码行数:12, 代码来源:ezmatrixdefinition.php
示例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;
}
开发者ID:mugoweb, 项目名称:ezpublish-legacy, 代码行数:51, 代码来源:ezobjectrelationtype.php
示例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;
}
开发者ID:jordanmanning, 项目名称:ezpublish, 代码行数:49, 代码来源:ezextensionpackagehandler.php
示例6: process
/**
* Append the node ID of the object being published
* So its URL alias will look like :
* someurlalias-<nodeID>
*
* @param string The text of the URL alias
* @param object The eZContentObject object being published
* @params object The eZContentObjectTreeNode in which the eZContentObject is published
* @return string The transformed URL alias with the nodeID
*/
public function process($text, &$languageObject, &$caller)
{
if (!$caller instanceof eZContentObjectTreeNode) {
eZDebug::writeError('The caller variable was not an eZContentObjectTreeNode', __METHOD__);
return $text;
}
$ini = eZINI::instance('site.ini');
$applyOnClassList = $ini->variable('AppendNodeIDFilterSettings', 'ApplyOnClass');
$classIdentifier = $caller->attribute('class_identifier');
if (in_array($classIdentifier, $applyOnClassList)) {
$separator = eZCharTransform::wordSeparator();
$text .= $separator . $caller->attribute('node_id');
}
return $text;
}
开发者ID:brookinsconsulting, 项目名称:ezecosystem, 代码行数:25, 代码来源:ezurlaliasfilterappendnodeid.php
示例7: 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();
}
开发者ID:brookinsconsulting, 项目名称:ezecosystem, 代码行数:23, 代码来源:ezsearchlog.php
示例8: fetchKeyword
//.........这里部分代码省略.........
$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;
}
$sqlTarget .= $sortingInfo['attributeTargetSQL'];
}
else
{
$sortingInfo['sortingFields'] = 'ezkeyword.keyword ASC';
}
$sortingInfo['attributeWhereSQL'] .= " a1.version=ezcontentobject.current_version
AND a1.contentobject_id=ezcontentobject.id AND";
//Adding DISTINCT to avoid duplicates,
//check if DISTINCT keyword was added before providing clauses for sorting.
if ( !$includeDuplicates && substr( $sqlTarget, 0, 9) != 'DISTINCT ' )
{
$sqlTarget = 'DISTINCT ' . $sqlTarget;
}
$sqlOwnerString = is_numeric( $owner ) ? "AND ezcontentobject.owner_id = '$owner'" : '';
$parentNodeIDString = is_numeric( $parentNodeID ) ? "AND ezcontentobject_tree.parent_node_id = '$parentNodeID'" : '';
$sqlClassIDString = '';
if ( is_array( $classIDArray ) and count( $classIDArray ) )
{
$sqlClassIDString = 'AND ' . $db->generateSQLINStatement( $classIDArray, 'ezkeyword.class_id', false, false, 'int' ) . ' ';
}
// composing sql for matching tag word, it could be strict equiality or LIKE clause
// dependent of $strictMatching parameter.
$sqlMatching = "ezkeyword.keyword LIKE '$alphabet%'";
if ( $strictMatching )
{
$sqlMatching = "ezkeyword.keyword = '$alphabet'";
}
$query = "SELECT $sqlTarget
FROM ezkeyword, ezkeyword_attribute_link,ezcontentobject_tree,ezcontentobject,ezcontentclass
$sortingInfo[attributeFromSQL]
$sqlPermissionChecking[from]
WHERE
$sortingInfo[attributeWhereSQL]
$sqlMatching
$showInvisibleNodesCond
$sqlPermissionChecking[where]
$sqlClassIDString
$sqlOwnerString
$parentNodeIDString
AND ezcontentclass.version=0
AND ezcontentobject.status=".eZContentObject::STATUS_PUBLISHED."
AND ezcontentobject_tree.main_node_id=ezcontentobject_tree.node_id
AND ezcontentobject_tree.contentobject_id = ezcontentobject.id
AND ezcontentclass.id = ezcontentobject.contentclass_id
AND a1.id=ezkeyword_attribute_link.objectattribute_id
AND ezkeyword_attribute_link.keyword_id = ezkeyword.id ORDER BY {$sortingInfo['sortingFields']}";
$keyWords = $db->arrayQuery( $query, $db_params );
$trans = eZCharTransform::instance();
foreach ( $keyWords as $keywordArray )
{
$keyword = $keywordArray['keyword'];
$nodeID = $keywordArray['node_id'];
$nodeObject = eZContentObjectTreeNode::fetch( $nodeID );
if ( $nodeObject != null )
{
$keywordLC = $trans->transformByGroup( $keyword, 'lowercase' );
if ( $lastKeyword == $keywordLC )
$keywordNodeArray[] = array( 'keyword' => '', 'link_object' => $nodeObject );
else
$keywordNodeArray[] = array( 'keyword' => $keyword, 'link_object' => $nodeObject );
$lastKeyword = $keywordLC;
}
else
{
$lastKeyword = $trans->transformByGroup( $keyword, 'lowercase' );
}
}
return array( 'result' => $keywordNodeArray );
}
开发者ID:robinmuilwijk, 项目名称:ezpublish, 代码行数:101, 代码来源:ezcontentfunctioncollection.php
示例9: sortKey
function sortKey($contentObjectAttribute)
{
//include_once( 'lib/ezpI18n::tr/classes/ezchartransform.php' );
$trans = eZCharTransform::instance();
return $trans->transformByGroup($contentObjectAttribute->attribute('data_text'), 'lowercase');
}
开发者ID:heliopsis, 项目名称:ezxmlinstaller, 代码行数:6, 代码来源:ezfeatureselecttype.php
示例10: batchInitializeObjectAttributeData
function batchInitializeObjectAttributeData($classAttribute)
{
$default = $classAttribute->attribute('data_text1');
if ($default !== '' && $default !== NULL) {
$db = eZDB::instance();
$default = "'" . $db->escapeString($default) . "'";
$trans = eZCharTransform::instance();
$lowerCasedDefault = $trans->transformByGroup($default, 'lowercase');
return array('data_text' => $default, 'sort_key_string' => $lowerCasedDefault);
}
return array();
}
开发者ID:legende91, 项目名称:ez, 代码行数:12, 代码来源:ezstringtype.php
示例11: 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;
}
开发者ID:nfrp, 项目名称:ezpublish, 代码行数:66, 代码来源:ezpackagecreationhandler.php
示例12: fetchKeyword
//.........这里部分代码省略.........
//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'] = '';
$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';
} elseif ($sortBy[0] == 'keyword') {
if ($includeDuplicates) {
$sortingString = 'ezkeyword.keyword';
} else {
$sortingString = 'keyword';
}
}
$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);
}
// Fixing the attributeTargetSQL
switch ($sortBy[0]) {
case 'keyword':
$sortingInfo['attributeTargetSQL'] = '';
break;
case 'name':
$sortingInfo['attributeTargetSQL'] = ', ezcontentobject.name';
break;
case 'attribute':
case 'class_name':
break;
default:
$sortingInfo['attributeTargetSQL'] .= ', ' . strtok($sortingInfo["sortingFields"], " ");
}
$sqlTarget .= $sortingInfo['attributeTargetSQL'];
} else {
$sortingInfo['sortingFields'] = 'ezkeyword.keyword ASC';
}
//Adding DISTINCT to avoid duplicates,
//check if DISTINCT keyword was added before providing clauses for sorting.
if (!$includeDuplicates && substr($sqlTarget, 0, 9) != 'DISTINCT ') {
$sqlTarget = 'DISTINCT ' . $sqlTarget;
}
$sqlOwnerString = is_numeric($owner) ? "AND ezcontentobject.owner_id = '{$owner}'" : '';
$parentNodeIDString = '';
if (is_numeric($parentNodeID)) {
$notEqParentString = '';
// If the node(s) doesn't exist we return null.
if (!eZContentObjectTreeNode::createPathConditionAndNotEqParentSQLStrings($parentNodeIDString, $notEqParentString, $parentNodeID, $depth)) {
return null;
}
}
$sqlClassIDString = '';
if (is_array($classIDArray) and count($classIDArray)) {
$sqlClassIDString = 'AND ' . $db->generateSQLINStatement($classIDArray, 'ezkeyword.class_id', false, false, 'int') . ' ';
}
// composing sql for matching tag word, it could be strict equiality or LIKE clause
// dependent of $strictMatching parameter.
$sqlMatching = "ezkeyword.keyword LIKE '{$alphabet}%'";
if ($strictMatching) {
$sqlMatching = "ezkeyword.keyword = '{$alphabet}'";
}
$query = "SELECT {$sqlTarget}\n FROM ezkeyword\n INNER JOIN ezkeyword_attribute_link ON (ezkeyword_attribute_link.keyword_id = ezkeyword.id)\n INNER JOIN ezcontentobject_attribute ON (ezcontentobject_attribute.id = ezkeyword_attribute_link.objectattribute_id)\n INNER JOIN ezcontentobject ON (ezcontentobject_attribute.version = ezcontentobject.current_version AND ezcontentobject_attribute.contentobject_id = ezcontentobject.id)\n INNER JOIN ezcontentobject_tree ON (ezcontentobject_tree.contentobject_id = ezcontentobject.id)\n INNER JOIN ezcontentclass ON (ezcontentclass.id = ezcontentobject.contentclass_id)\n {$sortingInfo['attributeFromSQL']}\n {$sqlPermissionChecking['from']}\n WHERE\n {$parentNodeIDString}\n {$sqlMatching}\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$sqlClassIDString}\n {$sqlOwnerString}\n AND ezcontentclass.version = 0\n AND ezcontentobject.status = " . eZContentObject::STATUS_PUBLISHED . "\n AND ezcontentobject_tree.main_node_id = ezcontentobject_tree.node_id\n ORDER BY {$sortingInfo['sortingFields']}";
$keyWords = $db->arrayQuery($query, $db_params);
$trans = eZCharTransform::instance();
foreach ($keyWords as $keywordArray) {
$keyword = $keywordArray['keyword'];
$nodeID = $keywordArray['node_id'];
$nodeObject = eZContentObjectTreeNode::fetch($nodeID);
if ($nodeObject != null) {
$keywordLC = $trans->transformByGroup($keyword, 'lowercase');
if ($lastKeyword == $keywordLC) {
$keywordNodeArray[] = array('keyword' => '', 'link_object' => $nodeObject);
} else {
$keywordNodeArray[] = array('keyword' => $keyword, 'link_object' => $nodeObject);
}
$lastKeyword = $keywordLC;
} else {
$lastKeyword = $trans->transformByGroup($keyword, 'lowercase');
}
}
return array('result' => $keywordNodeArray);
}
开发者ID:CG77, 项目名称:ezpublish-legacy, 代码行数:101, 代码来源:ezcontentfunctioncollection.php
示例13: isValid
/**
* Checks if all data is valid and can be stored to the database.
*
* @param array &$messages
* @return boolean true when valid, false when not valid
* @see eZContentObjectState::store()
*/
public function isValid(&$messages = array())
{
$isValid = true;
// missing identifier
if (!isset($this->Identifier) || $this->Identifier == '') {
$messages[] = ezpI18n::tr('kernel/state/edit', 'Identifier: input required');
$isValid = false;
} else {
// make sure the identifier contains only valid characters
$trans = eZCharTransform::instance();
$validIdentifier = $trans->transformByGroup($this->Identifier, 'identifier');
if (strcmp($validIdentifier, $this->Identifier) != 0) {
// invalid identifier
$messages[] = ezpI18n::tr('kernel/state/edit', 'Identifier: invalid, it can only consist of characters in the range a-z, 0-9 and underscore.');
$isValid = false;
} else {
if (strlen($this->Identifier) > self::MAX_IDENTIFIER_LENGTH) {
$messages[] = ezpI18n::tr('kernel/state/edit', 'Identifier: invalid, maximum %max characters allowed.', null, array('%max' => self::MAX_IDENTIFIER_LENGTH));
$isValid = false;
} else {
if (isset($this->GroupID)) {
// check for existing identifier
$existingState = self::fetchByIdentifier($this->Identifier, $this->GroupID);
if ($existingState && (!isset($this->ID) || $existingState->attribute('id') !== $this->ID)) {
$messages[] = ezpI18n::tr('kernel/state/edit', 'Identifier: a content object state group with this identifier already exists, please give another identifier');
$isValid = false;
}
}
}
}
}
$translationsWithData = 0;
foreach ($this->AllTranslations as $translation) {
if ($translation->hasData()) {
$translationsWithData++;
if (!$translation->isValid($messages)) {
$isValid = false;
}
} else {
if (($translation->attribute('language_id') & ~1) == $this->DefaultLanguageID) {
// if name nor description are set but translation is specified as main language
$isValid = false;
$messages[] = ezpI18n::tr('kernel/state/edit', '%language_name: this language is the default but neither name or description were provided for this language', null, array('%language_name' => $translation->attribute('language')->attribute('locale_object')->attribute('intl_language_name')));
}
}
}
if ($translationsWithData == 0) {
$isValid = false;
$messages[] = ezpI18n::tr('kernel/state/edit', 'Translations: you need to add at least one localization');
} else {
if (empty($this->DefaultLanguageID) && $translationsWithData > 1) {
$isValid = false;
$messages[] = ezpI18n::tr('kernel/state/edit', 'Translations: there are multiple localizations but you did not specify which is the default one');
}
}
return $isValid;
}
开发者ID:CG77, 项目名称:ezpublish-legacy, 代码行数:64, 代码来源:ezcontentobjectstate.php
示例14: commandUrlCleanupIRI
static function commandUrlCleanupIRI($text, $charsetName)
{
// With IRI support we keep all characters except some reserved ones,
// they are space, tab, ampersand, semi-colon, forward slash, colon, equal sign, question mark,
// square brackets, parenthesis, plus.
//
// Note: Spaces and tabs are turned into a dash to make it easier for people to
// paste urls from the system and have the whole url recognized
// instead of being broken off
$sep = eZCharTransform::wordSeparator();
$sepQ = preg_quote($sep);
$prepost = " ." . $sepQ;
if ($sep != "-") {
$prepost .= "-";
}
$text = preg_replace(array("#[ \t\\\\%\\#&;/:=?\\[\\]()+]+#", "#\\.\\.+#", "#[{$sepQ}]+#", "#^[{$prepost}]+|[!{$prepost}]+\$#"), array($sep, $sep, $sep, ""), $text);
return $text;
}
开发者ID:ezsystems, 项目名称:ezpublish-legacy, 代码行数:18, 代码来源:ezchartransform.php
示例15: convertToAliasCompat
public static function convertToAliasCompat($urlElement, $defaultValue = false)
{
$trans = eZCharTransform::instance();
$urlElement = $trans->transformByGroup($urlElement, "urlalias_compat");
if (strlen($urlElement) == 0) {
if ($defaultValue === false) {
$urlElement = '_1';
} else {
$urlElement = $defaultValue;
$urlElement = $trans->transformByGroup($urlElement, "urlalias_compat");
}
}
return $urlElement;
}
开发者ID:patrickallaert, 项目名称:ezpublish-legacy-php7, 代码行数:14, 代码来源:ezurlaliasml.php
示例16: sortKey
/**
* Returns the sort key of the attribute
*
* @param eZContentObjectAttribute $contentObjectAttribute
*
* @return string
*/
function sortKey($contentObjectAttribute)
{
$trans = eZCharTransform::instance();
return $trans->transformByGroup(trim($contentObjectAttribute->attribute(self::OIB_FIELD)), "lowercase");
}
开发者ID:netgen, 项目名称:ngoib, 代码行数:12, 代码来源:ngoibtype.php
示例17: executeCommandCode
function executeCommandCode(&$text, $command, $charsetName)
{
if ($command['command'] == 'url_cleanup_iri') {
$text = eZCharTransform::commandUrlCleanupIRI($text, $charsetName);
return true;
} else {
if ($command['command'] == 'url_cleanup') {
$text = eZCharTransform::commandUrlCleanup($text, $charsetName);
return true;
} else {
if ($command['command'] == 'url_cleanup_compat') {
$text = eZCharTransform::commandUrlCleanupCompat($text, $charsetName);
return true;
} else {
if ($command['command'] == 'identifier_cleanup') {
$text = strtolower($text);
$text = preg_replace(array("#[^a-z0-9_ ]#", "/ /", "/__+/", "/^_|_\$/"), array(" ", "_", "_", ""), $text);
return true;
} else {
if ($command['command'] == 'search_cleanup') {
$nonCJKCharsets = $this->nonCJKCharsets();
if (!in_array($charsetName, $nonCJKCharsets)) {
// 4 Add spaces after chinese / japanese / korean multibyte characters
$codec = eZTextCodec::instance(false, 'unicode');
$unicodeValueArray = $codec->convertString($text);
$normalizedTextArray = array();
$bFlag = false;
foreach (array_keys($unicodeValueArray) as $valueKey) {
// Check for word characters that should be broken up for search
if ($unicodeValueArray[$valueKey] >= 12289 and $unicodeValueArray[$valueKey] <= 12542 or $unicodeValueArray[$valueKey] >= 13312 and $unicodeValueArray[$valueKey] <= 40863 or $unicodeValueArray[$valueKey] >= 44032 and $unicodeValueArray[$valueKey] <= 55203) {
if ($bFlag) {
$normalizedTextArray[] = $unicodeValueArray[$valueKey];
}
$normalizedTextArray[] = 32;
// A space
$normalizedTextArray[] = $unicodeValueArray[$valueKey];
$bFlag = true;
} else {
if ($bFlag) {
$normalizedTextArray[] = 32;
// A space
}
$normalizedTextArray[] = $unicodeValueArray[$valueKey];
$bFlag = false;
}
}
if ($bFlag) {
$normalizedTextArray[count($normalizedTextArray) - 1] = 32;
}
$revCodec = eZTextCodec::instance('unicode', false);
// false means use internal charset
$text = $revCodec->convertString($normalizedTextArray);
}
// Make sure dots inside words/numbers are kept, the rest is turned into space
$text = preg_replace(array("#(\\.){2,}#", "#^\\.#", "#\\s\\.#", "#\\.\\s#", "#\\.\$#", "#([^0-9])%#"), array(" ", " ", " ", " ", " ", "\$1 "), $text);
$ini = eZINI::instance();
if ($ini->variable('SearchSettings', 'EnableWildcard') != 'true') {
$text = str_replace("*", " ", $text);
}
$charset = eZTextCodec::internalCharset();
$hasUTF8 = $charset == "utf-8";
if ($hasUTF8) {
$text = preg_replace("#(\\s+)#u", " ", $text);
} else {
$text = preg_replace("#(\\s+)#", " ", $text);
}
return true;
} else {
$ini = eZINI::instance('transform.ini');
$commands = $ini->variable('Extensions', 'Commands');
if (isset($commands[$command['command']])) {
list($path, $className) = explode(':', $commands[$command['command']], 2);
if (file_exists($path)) {
include_once $path;
$text = call_user_func_array(array($className, 'executeCommand'), array($text, $command['command'], $charsetName));
return true;
} else {
eZDebug::writeError("Could not locate include file '{$path}' for transformation '" . $command['command'] . "'");
}
}
}
}
}
}
}
return false;
}
开发者ID:legende91, 项目名称:ez, 代码行数:87, 代码来源:ezcodemapper.php
示例18: generateIdentifier
/**
* Generates an identifier from provided name
*
* @param string $name
* @param array $identifierArray
*
* @return string
*/
protected function generateIdentifier($name, $identifierArray = array())
{
if (empty($name)) {
return '';
}
$identifier = $name;
$generatedIdentifier = eZCharTransform::instance()->transformByGroup($identifier, 'identifier');
// We have $generatedIdentifier now, check for existence
if (is_array($identifierArray) && !empty($identifierArray) && in_array($generatedIdentifier, $identifierArray)) {
$highestNumber = 0;
foreach ($identifierArray as $identifierItem) {
if (preg_match('/^' . $generatedIdentifier . '__(\\d+)$/', $identifierItem, $matchArray)) {
if ($matchArray[1] > $highestNumber) {
$highestNumber = $matchArray[1];
}
}
}
$generatedIdentifier .= "__" . ++$highestNumber;
}
return $generatedIdentifier;
}
开发者ID:netgen, 项目名称:enhancedselection2, 代码行数:29, 代码来源:sckenhancedselectiontype.php
librespeed/speedtest: Self-hosted Speedtest for HTML5 and more. Easy setup, exam
阅读:1218| 2022-08-30
avehtari/BDA_m_demos: Bayesian Data Analysis demos for Matlab/Octave
阅读:1130| 2022-08-17
女人怀孕后,为了有一个健康聪明的宝宝,经历各种体检、筛查。其实这些体检和筛查中的
阅读:941| 2022-11-06
1,基本思路梯度法也称最速下降法。目标函数的...
阅读:531| 2022-07-18
medfreeman/markdown-it-toc-and-anchor: markdown-it plugin to add a toc and ancho
阅读:1335| 2022-08-18
本文借鉴小墨学FPGA的文章《零基础学FPGA(三十二)写在京城,多级FIR半带滤波器的FPG
阅读:1002| 2022-07-18
The dainst/cilantro repository through 0.0.4 on GitHub allows absolute path trav
阅读:771| 2022-07-29
sydney0zq/covid-19-detection: The implementation of A Weakly-supervised Framewor
阅读:485| 2022-08-16
containous/traefik-library-image: ARCHIVED
阅读:1342| 2022-08-15
离中国最远的国家是阿根廷。从太平洋直线计算,即往东线走,北京到阿根廷的布宜诺斯艾
阅读:640| 2022-11-06
请发表评论