本文整理汇总了PHP中SystemTextEncoding::getEncoding方法的典型用法代码示例。如果您正苦于以下问题:PHP SystemTextEncoding::getEncoding方法的具体用法?PHP SystemTextEncoding::getEncoding怎么用?PHP SystemTextEncoding::getEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemTextEncoding
的用法示例。
在下文中一共展示了SystemTextEncoding::getEncoding方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setAdditionalData
/**
* Non-impacting operations
* @param array $data Installer parsed form result
* @throws Exception
*/
public function setAdditionalData($data)
{
if ($data["ENCODING"] != (defined('AJXP_LOCALE') ? AJXP_LOCALE : SystemTextEncoding::getEncoding())) {
file_put_contents($this->getPluginWorkDir() . "/encoding.php", "<?php \$ROOT_ENCODING='" . $data["ENCODING"] . "';");
}
}
示例2: toStorageEncoding
/**
* Decode a string from UTF8 to current Storage Charset
* @static
* @param string $filesystemElement
* @param bool $test Try to detect if it's really utf8 or not
* @return string
*/
public static function toStorageEncoding($filesystemElement, $test = false)
{
if ($test && !SystemTextEncoding::isUtf8($filesystemElement)) {
return $filesystemElement;
}
$enc = SystemTextEncoding::getEncoding();
return SystemTextEncoding::changeCharset("UTF-8", $enc, $filesystemElement);
}
示例3: xmlEntities
/**
* Replace specific chars by their XML Entities, for use inside attributes value
* @static
* @param $string
* @param bool $toUtf8
* @return mixed|string
*/
public static function xmlEntities($string, $toUtf8 = false)
{
$xmlSafe = str_replace(array("&", "<", ">", "\"", "\n", "\r"), array("&", "<", ">", """, " ", " "), $string);
if ($toUtf8 && SystemTextEncoding::getEncoding() != "UTF-8") {
return SystemTextEncoding::toUTF8($xmlSafe);
} else {
return $xmlSafe;
}
}
示例4: createIndexedDocument
/**
* @param AJXP_Node $ajxpNode
* @param Zend_Search_Lucene_Interface $index
* @throws Exception
* @return Zend_Search_Lucene_Document
*/
public function createIndexedDocument($ajxpNode, &$index)
{
if (!empty($this->metaFields)) {
$ajxpNode->loadNodeInfo(false, false, "all");
} else {
$ajxpNode->loadNodeInfo();
}
$ext = strtolower(pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION));
$parseContent = $this->indexContent;
if ($parseContent && $ajxpNode->bytesize > $this->getFilteredOption("PARSE_CONTENT_MAX_SIZE")) {
$parseContent = false;
}
if ($parseContent && in_array($ext, explode(",", $this->getFilteredOption("PARSE_CONTENT_HTML")))) {
$doc = @Zend_Search_Lucene_Document_Html::loadHTMLFile($ajxpNode->getUrl());
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Docx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Docx::loadDocxFile($realFile);
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Pptx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Pptx::loadPptxFile($realFile);
} elseif ($parseContent && $ext == "xlsx" && class_exists("Zend_Search_Lucene_Document_Xlsx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($realFile);
} else {
$doc = new Zend_Search_Lucene_Document();
}
if ($doc == null) {
throw new Exception("Could not load document");
}
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl()), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Text("basename", basename($ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_node", "yes"), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "shared"));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_modiftime", date("Ymd", $ajxpNode->ajxp_modiftime)));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_bytesize", $ajxpNode->bytesize));
$ajxpMime = $ajxpNode->ajxp_mime;
if (empty($ajxpMime)) {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION)));
} else {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", $ajxpNode->ajxp_mime));
}
// Store a cached copy of the metadata
$serializedMeta = base64_encode(serialize($ajxpNode->metadata));
$doc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
if (isset($ajxpNode->indexableMetaKeys["shared"])) {
foreach ($ajxpNode->indexableMetaKeys["shared"] as $sharedField) {
if ($ajxpNode->{$sharedField}) {
$doc->addField(Zend_search_Lucene_Field::keyword($sharedField, $ajxpNode->{$sharedField}));
}
}
}
foreach ($this->metaFields as $field) {
if ($ajxpNode->{$field} != null) {
$doc->addField(Zend_Search_Lucene_Field::Text("ajxp_meta_{$field}", $ajxpNode->{$field}), SystemTextEncoding::getEncoding());
}
}
if (isset($ajxpNode->indexableMetaKeys["user"]) && count($ajxpNode->indexableMetaKeys["user"]) && AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$privateDoc = new Zend_Search_Lucene_Document();
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl(), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath()), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "user"));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_user", AuthService::getLoggedUser()->getId()));
foreach ($ajxpNode->indexableMetaKeys["user"] as $userField) {
if ($ajxpNode->{$userField}) {
$privateDoc->addField(Zend_search_Lucene_Field::keyword($userField, $ajxpNode->{$userField}));
}
}
$privateDoc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
$index->addDocument($privateDoc);
}
if ($parseContent) {
$body = $this->extractIndexableContent($ajxpNode);
if (!empty($body)) {
$doc->addField(Zend_Search_Lucene_Field::unStored("body", $body));
}
}
$index->addDocument($doc);
return $doc;
}
示例5: toUTF8
function toUTF8($filesystemElement)
{
$enc = SystemTextEncoding::getEncoding();
return SystemTextEncoding::changeCharset($enc, "UTF-8", $filesystemElement);
}
示例6: makeZip
/**
* @param $src
* @param $dest
* @param $basedir
* @throws Exception
* @return zipfile
*/
public function makeZip($src, $dest, $basedir)
{
$zipEncoding = ConfService::getCoreConf("ZIP_ENCODING");
@set_time_limit(0);
require_once AJXP_BIN_FOLDER . "/pclzip.lib.php";
$filePaths = array();
foreach ($src as $item) {
$realFile = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase . "/" . $item);
$realFile = AJXP_Utils::securePath($realFile);
if (basename($item) == "") {
$filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile);
} else {
$shortName = basename($item);
if (!empty($zipEncoding)) {
$test = iconv(SystemTextEncoding::getEncoding(), $zipEncoding, $shortName);
if ($test !== false) {
$shortName = $test;
}
}
$filePaths[] = array(PCLZIP_ATT_FILE_NAME => $realFile, PCLZIP_ATT_FILE_NEW_SHORT_NAME => $shortName);
}
}
$this->logDebug("Pathes", $filePaths);
self::$filteringDriverInstance = $this;
$archive = new PclZip($dest);
if ($basedir == "__AJXP_ZIP_FLAT__/") {
$vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback');
} else {
$basedir = call_user_func(array($this->wrapperClassName, "getRealFSReference"), $this->urlBase) . trim($basedir);
$this->logDebug("Basedir", array($basedir));
$vList = $archive->create($filePaths, PCLZIP_OPT_REMOVE_PATH, $basedir, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_ADD_TEMP_FILE_ON, PCLZIP_CB_PRE_ADD, 'zipPreAddCallback');
}
if (!$vList) {
throw new Exception("Zip creation error : ({$dest}) " . $archive->errorInfo(true));
}
self::$filteringDriverInstance = null;
return $vList;
}
示例7: toUTF8
/**
* Transform a string from current charset to utf8
* @static
* @param string $filesystemElement
* @param bool $test Test if it's already UTF8 or not, to avoid double-encoding
* @return string
*/
static function toUTF8($filesystemElement, $test = true)
{
if ($test && SystemTextEncoding::isUtf8($filesystemElement)) {
return $filesystemElement;
}
$enc = SystemTextEncoding::getEncoding();
return SystemTextEncoding::changeCharset($enc, "UTF-8", $filesystemElement);
}
示例8: applyInstallerForm
/**
* Transmit to the ajxp_conf load_plugin_manifest action
* @param $action
* @param $httpVars
* @param $fileVars
*/
public function applyInstallerForm($action, $httpVars, $fileVars)
{
$data = array();
AJXP_Utils::parseStandardFormParameters($httpVars, $data, null, "");
// Create a custom bootstrap.json file
$coreConf = array();
$coreAuth = array();
$this->_loadPluginConfig("core.conf", $coreConf);
$this->_loadPluginConfig("core.auth", $coreAuth);
if (!isset($coreConf["UNIQUE_INSTANCE_CONFIG"])) {
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array();
}
if (!isset($coreAuth["MASTER_INSTANCE_CONFIG"])) {
$coreAuth["MASTER_INSTANCE_CONFIG"] = array();
}
$coreConf["AJXP_CLI_SECRET_KEY"] = AJXP_Utils::generateRandomString(24, true);
$storageType = $data["STORAGE_TYPE"]["type"];
if ($storageType == "db") {
// REWRITE BOOTSTRAP.JSON
$coreConf["DIBI_PRECONFIGURATION"] = $data["STORAGE_TYPE"]["db_type"];
if (isset($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_driver"])) {
$dbFile = AJXP_VarsFilter::filter($coreConf["DIBI_PRECONFIGURATION"]["sqlite3_database"]);
if (!file_exists(dirname($dbFile))) {
mkdir(dirname($dbFile), 0755, true);
}
}
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.sql", "group_switch_value" => "conf.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")));
$coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.sql", "group_switch_value" => "auth.sql", "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core")));
// INSTALL ALL SQL TABLES
$sqlPlugs = array("conf.sql", "auth.sql", "feed.sql", "log.sql", "meta.syncable");
foreach ($sqlPlugs as $plugId) {
$plug = AJXP_PluginsService::findPluginById($plugId);
$plug->installSQLTables(array("SQL_DRIVER" => $data["STORAGE_TYPE"]["db_type"]));
}
} else {
$coreConf["UNIQUE_INSTANCE_CONFIG"] = array_merge($coreConf["UNIQUE_INSTANCE_CONFIG"], array("instance_name" => "conf.serial", "group_switch_value" => "conf.serial"));
$coreAuth["MASTER_INSTANCE_CONFIG"] = array_merge($coreAuth["MASTER_INSTANCE_CONFIG"], array("instance_name" => "auth.serial", "group_switch_value" => "auth.serial"));
}
$oldBoot = $this->getPluginWorkDir(true) . "/bootstrap.json";
if (is_file($oldBoot)) {
copy($oldBoot, $oldBoot . ".bak");
unlink($oldBoot);
}
$newBootstrap = array("core.conf" => $coreConf, "core.auth" => $coreAuth);
AJXP_Utils::saveSerialFile($oldBoot, $newBootstrap, true, false, "json", true);
// Write new bootstrap and reload conf plugin!
if ($storageType == "db") {
$coreConf["UNIQUE_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
$coreAuth["MASTER_INSTANCE_CONFIG"]["SQL_DRIVER"] = $coreConf["DIBI_PRECONFIGURATION"];
}
$newConfigPlugin = ConfService::instanciatePluginFromGlobalParams($coreConf["UNIQUE_INSTANCE_CONFIG"], "AbstractConfDriver");
$newAuthPlugin = ConfService::instanciatePluginFromGlobalParams($coreAuth["MASTER_INSTANCE_CONFIG"], "AbstractAuthDriver");
if ($data["ENCODING"] != (defined('AJXP_LOCALE') ? AJXP_LOCALE : SystemTextEncoding::getEncoding())) {
file_put_contents($this->getPluginWorkDir() . "/encoding.php", "<?php \$ROOT_ENCODING='" . $data["ENCODING"] . "';");
}
$tpl = file_get_contents($this->getBaseDir() . "/htaccess.tpl");
if (!empty($data["SERVER_URI"]) && $data["SERVER_URI"] != "/") {
$htContent = str_replace('${APPLICATION_ROOT}', $data["SERVER_URI"], $tpl);
} else {
$htContent = str_replace('${APPLICATION_ROOT}/', "/", $tpl);
$htContent = str_replace('${APPLICATION_ROOT}', "/", $htContent);
}
if (is_writeable(AJXP_INSTALL_PATH . "/.htaccess")) {
file_put_contents(AJXP_INSTALL_PATH . "/.htaccess", $htContent);
} else {
$htAccessToUpdate = AJXP_INSTALL_PATH . "/.htaccess";
}
if ($storageType == "db") {
$sqlPlugs = array("core.notifications/UNIQUE_FEED_INSTANCE" => "feed.sql", "core.log/UNIQUE_PLUGIN_INSTANCE" => "log.sql", "core.mq/UNIQUE_MS_INSTANCE" => "mq.sql");
$data["ENABLE_NOTIF"] = $data["STORAGE_TYPE"]["notifications"];
}
// Prepare plugins configs
$direct = array("APPLICATION_TITLE" => "core.ajaxplorer/APPLICATION_TITLE", "APPLICATION_LANGUAGE" => "core.ajaxplorer/DEFAULT_LANGUAGE", "ENABLE_NOTIF" => "core.notifications/USER_EVENTS", "APPLICATION_WELCOME" => "gui.ajax/CUSTOM_WELCOME_MESSAGE");
$mailerEnabled = $data["MAILER_ENABLE"]["status"];
if ($mailerEnabled == "yes") {
// Enable core.mailer
$data["MAILER_SYSTEM"] = $data["MAILER_ENABLE"]["MAILER_SYSTEM"];
$data["MAILER_ADMIN"] = $data["MAILER_ENABLE"]["MAILER_ADMIN"];
$direct = array_merge($direct, array("MAILER_SYSTEM" => "mailer.phpmailer-lite/MAILER", "MAILER_ADMIN" => "core.mailer/FROM"));
}
foreach ($direct as $key => $value) {
list($pluginId, $param) = explode("/", $value);
$options = array();
$newConfigPlugin->_loadPluginConfig($pluginId, $options);
$options[$param] = $data[$key];
$newConfigPlugin->_savePluginConfig($pluginId, $options);
}
if (isset($sqlPlugs)) {
foreach ($sqlPlugs as $core => $value) {
list($pluginId, $param) = explode("/", $core);
$options = array();
$newConfigPlugin->_loadPluginConfig($pluginId, $options);
$options[$param] = array("instance_name" => $value, "group_switch_value" => $value, "SQL_DRIVER" => array("core_driver" => "core", "group_switch_value" => "core"));
$newConfigPlugin->_savePluginConfig($pluginId, $options);
//.........这里部分代码省略.........
示例9: stream_open
public function stream_open($path, $mode, $options, &$opened_path)
{
// parse URL
$parts = parse_url($path);
$this->repositoryId = $parts["host"];
$mainCacheDir = defined('AJXP_SHARED_CACHE_DIR') ? AJXP_SHARED_CACHE_DIR : AJXP_CACHE_DIR;
if (!isset(self::$delimiter) && file_exists($mainCacheDir . "/access.imap/mailbox_delim_" . $this->repositoryId)) {
self::$delimiter = file_get_contents($mainCacheDir . "/access.imap/mailbox_delim_" . $this->repositoryId);
}
$this->path = substr($parts["path"], 1);
//$this->mailbox = "INBOX";
$pathParts = explode("/", $this->path);
$pathParts = array_filter($pathParts, "rejectEmpty");
if (count($pathParts) > 1) {
$this->path = array_pop($pathParts);
$this->mailbox = implode("/", $pathParts);
} else {
if (count($pathParts) == 1) {
$this->mailbox = implode("/", $pathParts);
$this->path = "";
} else {
$this->mailbox = "";
$this->path = "";
}
}
$this->fragment = $parts["fragment"];
if (empty($this->path) && $mode !== 'np') {
return false;
}
if (!empty($this->mailbox)) {
$this->mailbox = mb_convert_encoding($this->mailbox, "UTF7-IMAP", SystemTextEncoding::getEncoding());
$this->mailbox = str_replace("__delim__", isset(self::$delimiter) ? self::$delimiter : "/", $this->mailbox);
}
if (!empty($this->fragment) && strpos($this->fragment, "attachments") === 0 && strpos($this->fragment, "/") !== false) {
// remove fragment
$ar = explode("#", $path);
$mailPath = array_shift($ar);
$ar = explode("/", $this->fragment);
$attachmentId = array_pop($ar);
$this->currentAttachmentData = array("realPath" => $mailPath, "attachmentId" => $attachmentId);
// EXTRACT ATTACHMENT AND RETURN
require_once AJXP_INSTALL_PATH . "/plugins/editor.eml/class.EmlParser.php";
$emlParser = new EmlParser("", "");
$attachMeta = array();
$this->data = $emlParser->getAttachmentBody($this->currentAttachmentData["realPath"], $this->currentAttachmentData["attachmentId"], true, $attachMeta);
if (self::$attachmentsMetadata == null) {
self::$attachmentsMetadata = array($attachMeta);
}
$this->currentAttachmentData["size"] = strlen($this->data);
$this->pos = 0;
$this->size = strlen($this->data);
return true;
}
// open IMAP connection
if (self::$currentStream != null) {
AJXP_Logger::debug(__CLASS__, __FUNCTION__, "Using currently opened stream! " . print_r(self::$currentStream, true));
$this->ih = self::$currentStream;
// Rewind everything
$this->dir_rewinddir();
$this->stream_seek(0);
} else {
$repository = ConfService::getRepositoryById($this->repositoryId);
$ssl = $repository->getOption("SSL") == "true" ? true : false;
$this->pop3 = $repository->getOption("BOX_TYPE") == "pop3" ? true : false;
$this->host = $repository->getOption("HOST");
$this->port = $repository->getOption("PORT");
$this->username = $repository->getOption("USER");
$this->password = $repository->getOption("PASS");
$server = "{" . $this->host . ":" . $this->port . "/" . ($this->pop3 ? "pop3/" : "") . ($ssl ? "ssl/novalidate-cert" : "novalidate-cert") . "}";
self::$currentRef = $server;
AJXP_Logger::debug(__CLASS__, __FUNCTION__, "Opening a new stream " . $server . " with mailbox '" . $this->mailbox . "'");
try {
$this->ih = imap_open($server . $this->mailbox, $this->username, $this->password, !$this->pop3 && empty($this->mailbox) ? OP_HALFOPEN : NULL, 1);
} catch (Exception $e) {
throw new Exception($e->getMessage() . " - imap errors : " . print_r(imap_errors(), true), $e->getCode());
}
self::$currentStream = $this->ih;
register_shutdown_function(array("imapAccessWrapper", "closeStreamFunc"));
}
if ($this->ih) {
if (!empty($this->path)) {
list($stats, ) = imap_fetch_overview($this->ih, $this->path);
$this->size = $stats->size;
$this->time = strtotime($stats->date);
}
return true;
} else {
return false;
}
}
示例10: createIndexedDocument
/**
* @param AJXP_Node $ajxpNode
* @param Zend_Search_Lucene_Interface $index
* @throws Exception
* @return Zend_Search_Lucene_Document
*/
public function createIndexedDocument($ajxpNode, &$index)
{
$ajxpNode->loadNodeInfo();
$ext = strtolower(pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION));
$parseContent = $this->indexContent;
if ($parseContent && $ajxpNode->bytesize > $this->getFilteredOption("PARSE_CONTENT_MAX_SIZE")) {
$parseContent = false;
}
if ($parseContent && in_array($ext, explode(",", $this->getFilteredOption("PARSE_CONTENT_HTML")))) {
$doc = @Zend_Search_Lucene_Document_Html::loadHTMLFile($ajxpNode->getUrl());
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Docx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Docx::loadDocxFile($realFile);
} elseif ($parseContent && $ext == "docx" && class_exists("Zend_Search_Lucene_Document_Pptx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Pptx::loadPptxFile($realFile);
} elseif ($parseContent && $ext == "xlsx" && class_exists("Zend_Search_Lucene_Document_Xlsx")) {
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$doc = @Zend_Search_Lucene_Document_Xlsx::loadXlsxFile($realFile);
} else {
$doc = new Zend_Search_Lucene_Document();
}
if ($doc == null) {
throw new Exception("Could not load document");
}
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl()), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Text("basename", basename($ajxpNode->getPath())), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_node", "yes"), SystemTextEncoding::getEncoding());
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "shared"));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_modiftime", date("Ymd", $ajxpNode->ajxp_modiftime)));
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_bytesize", $ajxpNode->bytesize));
$ajxpMime = $ajxpNode->ajxp_mime;
if (empty($ajxpMime)) {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", pathinfo($ajxpNode->getLabel(), PATHINFO_EXTENSION)));
} else {
$doc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_mime", $ajxpNode->ajxp_mime));
}
// Store a cached copy of the metadata
$serializedMeta = base64_encode(serialize($ajxpNode->metadata));
$doc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
if (isset($ajxpNode->indexableMetaKeys["shared"])) {
foreach ($ajxpNode->indexableMetaKeys["shared"] as $sharedField) {
if ($ajxpNode->{$sharedField}) {
$doc->addField(Zend_search_Lucene_Field::keyword($sharedField, $ajxpNode->{$sharedField}));
}
}
}
foreach ($this->metaFields as $field) {
if ($ajxpNode->{$field} != null) {
$doc->addField(Zend_Search_Lucene_Field::Text("ajxp_meta_{$field}", $ajxpNode->{$field}), SystemTextEncoding::getEncoding());
}
}
if (isset($ajxpNode->indexableMetaKeys["user"]) && count($ajxpNode->indexableMetaKeys["user"]) && AuthService::usersEnabled() && AuthService::getLoggedUser() != null) {
$privateDoc = new Zend_Search_Lucene_Document();
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_url", $ajxpNode->getUrl(), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("node_path", str_replace("/", "AJXPFAKESEP", $ajxpNode->getPath()), SystemTextEncoding::getEncoding()));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_scope", "user"));
$privateDoc->addField(Zend_Search_Lucene_Field::Keyword("ajxp_user", AuthService::getLoggedUser()->getId()));
foreach ($ajxpNode->indexableMetaKeys["user"] as $userField) {
if ($ajxpNode->{$userField}) {
$privateDoc->addField(Zend_search_Lucene_Field::keyword($userField, $ajxpNode->{$userField}));
}
}
$privateDoc->addField(Zend_Search_Lucene_Field::Binary("serialized_metadata", $serializedMeta));
$index->addDocument($privateDoc);
}
if ($parseContent && in_array($ext, explode(",", $this->getFilteredOption("PARSE_CONTENT_TXT")))) {
$doc->addField(Zend_Search_Lucene_Field::unStored("body", file_get_contents($ajxpNode->getUrl())));
}
$unoconv = $this->getFilteredOption("UNOCONV");
$pipe = false;
if ($parseContent && !empty($unoconv) && in_array($ext, array("doc", "odt", "xls", "ods"))) {
$targetExt = "txt";
if (in_array($ext, array("xls", "ods"))) {
$targetExt = "csv";
} else {
if (in_array($ext, array("odp", "ppt"))) {
$targetExt = "pdf";
$pipe = true;
}
}
$realFile = call_user_func(array($ajxpNode->wrapperClassName, "getRealFSReference"), $ajxpNode->getUrl());
$unoconv = "HOME=" . AJXP_Utils::getAjxpTmpDir() . " " . $unoconv . " --stdout -f {$targetExt} " . escapeshellarg($realFile);
if ($pipe) {
$newTarget = str_replace(".{$ext}", ".pdf", $realFile);
$unoconv .= " > {$newTarget}";
register_shutdown_function("unlink", $newTarget);
}
$output = array();
exec($unoconv, $output, $return);
if (!$pipe) {
$out = implode("\n", $output);
$enc = 'ISO-8859-1';
//.........这里部分代码省略.........