本文整理汇总了PHP中KTUtil::replaceInvalidCharacters方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::replaceInvalidCharacters方法的具体用法?PHP KTUtil::replaceInvalidCharacters怎么用?PHP KTUtil::replaceInvalidCharacters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::replaceInvalidCharacters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_sysdata
/**
* This updates the system metadata on the document.
*
* @author KnowledgeTree Team
* @access public
* @param array $sysdata The system metadata to be applied
* @return void|PEAR_Error Returns nothing on success | a PEAR_Error on failure
*/
function update_sysdata($sysdata)
{
global $default;
if (empty($sysdata)) {
return;
}
$owner_mapping = array('created_by' => 'creator_id', 'modified_by' => 'modified_user_id', 'owner' => 'owner_id');
$documents = array();
$document_content = array();
$indexContent = null;
$uniqueOemNo = false;
foreach ($sysdata as $rec) {
if (is_object($rec)) {
$name = $rec->name;
$value = sanitizeForSQL($rec->value);
} elseif (is_array($rec)) {
$name = $rec['name'];
$value = sanitizeForSQL($rec['value']);
} else {
// just ignore
continue;
}
switch (strtolower($name)) {
case 'unique_oem_document_no':
$documents['oem_no'] = $value;
$uniqueOemNo = true;
break;
case 'oem_document_no':
$documents['oem_no'] = $value;
break;
case 'index_content':
$indexContent = $value;
break;
case 'created_date':
if (!empty($value)) {
$documents['created'] = $value;
}
break;
case 'modified_date':
if (!empty($value)) {
$documents['modified'] = $value;
}
break;
case 'is_immutable':
$documents['immutable'] = in_array(strtolower($value), array('1', 'true', 'on', 'yes')) ? '1' : '0';
break;
case 'filename':
$value = KTUtil::replaceInvalidCharacters($value);
$document_content['filename'] = $value;
break;
case 'major_version':
$document_content['major_version'] = $value;
break;
case 'minor_version':
$document_content['minor_version'] = $value;
break;
case 'version':
$version = number_format($value + 0, 5);
list($major_version, $minor_version) = explode('.', $version);
$document_content['major_version'] = $major_version;
$document_content['minor_version'] = $minor_version;
break;
case 'mime_type':
$sql = "select id from mime_types where mimetypes='{$value}'";
$value = DBUtil::getResultArray($sql);
if (PEAR::isError($value)) {
$default->log->error("Problem resolving mime type '{$value}' for document id {$this->documentid}. Reason: " . $value->getMessage());
return $value;
}
if (count($value) == 0) {
$default->log->error("Problem resolving mime type '{$value}' for document id {$this->documentid}. None found.");
break;
}
$value = $value[0]['id'];
$document_content['mime_id'] = $value;
break;
case 'owner':
case 'created_by':
case 'modified_by':
$sql = "select id from users where name='{$value}'";
$userId = DBUtil::getResultArray($sql);
if (PEAR::isError($userId)) {
$default->log->error("Problem resolving user '{$value}' for document id {$this->documentid}. Reason: " . $userId->getMessage());
return $userId;
}
if (empty($userId)) {
$sql = "select id from users where username='{$value}'";
$userId = DBUtil::getResultArray($sql);
if (PEAR::isError($userId)) {
$default->log->error("Problem resolving username '{$value}' for document id {$this->documentid}. Reason: " . $userId->getMessage());
return $userId;
}
//.........这里部分代码省略.........
示例2: rename
/**
* This renames the folder
*
* @author KnowledgeTree Team
* @access public
* @param string $newname
*/
function rename($newname)
{
$user = $this->can_user_access_object_requiring_permission($this->folder, KTAPI_PERMISSION_RENAME_FOLDER);
if (PEAR::isError($user)) {
return $user;
}
$newname = KTUtil::replaceInvalidCharacters($newname);
DBUtil::startTransaction();
$result = KTFolderUtil::rename($this->folder, $newname, $user);
if (PEAR::isError($result)) {
DBUtil::rollback();
return new KTAPI_Error(KTAPI_ERROR_INTERNAL_ERROR, $result);
}
DBUtil::commit();
}