本文整理汇总了PHP中AJXP_Node::isLeaf方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Node::isLeaf方法的具体用法?PHP AJXP_Node::isLeaf怎么用?PHP AJXP_Node::isLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Node
的用法示例。
在下文中一共展示了AJXP_Node::isLeaf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceVars
protected function replaceVars($tplString, $mess, $rich = true)
{
$tplString = SystemTextEncoding::fromUTF8($tplString);
$repoId = $this->getNode()->getRepositoryId();
$repoObject = ConfService::getRepositoryById($repoId);
if ($repoObject != null) {
$repoLabel = $repoObject->getDisplay();
} else {
$repoLabel = "Repository";
}
$uLabel = "";
if (strstr($tplString, "AJXP_USER") !== false) {
$uLabel = $this->getAuthorLabel();
}
$em = $rich ? "<em>" : "";
$me = $rich ? "</em>" : "";
$replaces = array("AJXP_NODE_PATH" => $em . $this->getRoot($this->getNode()->getPath()) . $me, "AJXP_NODE_LABEL" => $em . $this->getNode()->getLabel() . $me, "AJXP_PARENT_PATH" => $em . $this->getRoot(dirname($this->getNode()->getPath())) . $me, "AJXP_PARENT_LABEL" => $em . $this->getRoot(basename(dirname($this->getNode()->getPath()))) . $me, "AJXP_REPOSITORY_ID" => $em . $repoId . $me, "AJXP_REPOSITORY_LABEL" => $em . $repoLabel . $me, "AJXP_LINK" => $this->getMainLink(), "AJXP_USER" => $uLabel, "AJXP_DATE" => SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($this->getDate(), $mess)));
if ($replaces["AJXP_NODE_LABEL"] == $em . $me || $replaces["AJXP_NODE_LABEL"] == $em . "/" . $me) {
$replaces["AJXP_NODE_LABEL"] = $replaces["AJXP_REPOSITORY_LABEL"];
}
if ($replaces["AJXP_PARENT_LABEL"] == $em . $me || $replaces["AJXP_PARENT_LABEL"] == $em . "/" . $me) {
$replaces["AJXP_PARENT_LABEL"] = $replaces["AJXP_REPOSITORY_LABEL"];
}
if ((strstr($tplString, "AJXP_TARGET_FOLDER") !== false || strstr($tplString, "AJXP_SOURCE_FOLDER")) && isset($this->secondaryNode)) {
$p = $this->secondaryNode->getPath();
if ($this->secondaryNode->isLeaf()) {
$p = $this->getRoot(dirname($p));
}
$replaces["AJXP_TARGET_FOLDER"] = $replaces["AJXP_SOURCE_FOLDER"] = $em . $p . $me;
}
if ((strstr($tplString, "AJXP_TARGET_LABEL") !== false || strstr($tplString, "AJXP_SOURCE_LABEL") !== false) && isset($this->secondaryNode)) {
$replaces["AJXP_TARGET_LABEL"] = $replaces["AJXP_SOURCE_LABEL"] = $em . $this->secondaryNode->getLabel() . $me;
}
return str_replace(array_keys($replaces), array_values($replaces), $tplString);
}
示例2: replaceVars
protected function replaceVars($tplString, $mess, $rich = true)
{
$tplString = SystemTextEncoding::fromUTF8($tplString);
$repoId = $this->getNode()->getRepositoryId();
if (ConfService::getRepositoryById($repoId) != null) {
$repoLabel = ConfService::getRepositoryById($repoId)->getDisplay();
} else {
$repoLabel = "Repository";
}
$uLabel = "";
if (array_key_exists($this->getAuthor(), self::$usersCaches)) {
if (self::$usersCaches[$this->getAuthor()] != 'AJXP_USER_DONT_EXISTS') {
$uLabel = self::$usersCaches[$this->getAuthor()];
}
} else {
if (strstr($tplString, "AJXP_USER") !== false) {
if (AuthService::userExists($this->getAuthor())) {
$obj = ConfService::getConfStorageImpl()->createUserObject($this->getAuthor());
$uLabel = $obj->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
self::$usersCaches[$this->getAuthor()] = $uLabel;
} else {
self::$usersCaches[$this->getAuthor()] = 'AJXP_USER_DONT_EXISTS';
}
}
}
if (empty($uLabel)) {
$uLabel = $this->getAuthor();
}
$em = $rich ? "<em>" : "";
$me = $rich ? "</em>" : "";
$replaces = array("AJXP_NODE_PATH" => $em . $this->getRoot($this->getNode()->getPath()) . $me, "AJXP_NODE_LABEL" => $em . $this->getNode()->getLabel() . $me, "AJXP_PARENT_PATH" => $em . $this->getRoot(dirname($this->getNode()->getPath())) . $me, "AJXP_PARENT_LABEL" => $em . $this->getRoot(basename(dirname($this->getNode()->getPath()))) . $me, "AJXP_REPOSITORY_ID" => $em . $repoId . $me, "AJXP_REPOSITORY_LABEL" => $em . $repoLabel . $me, "AJXP_LINK" => $this->getMainLink(), "AJXP_USER" => $uLabel, "AJXP_DATE" => SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($this->getDate(), $mess)));
if ($replaces["AJXP_NODE_LABEL"] == $em . $me) {
$replaces["AJXP_NODE_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
}
if ($replaces["AJXP_PARENT_LABEL"] == $em . $me) {
$replaces["AJXP_PARENT_LABEL"] = $em . "[" . $replaces["AJXP_REPOSITORY_LABEL"] . "]" . $me;
}
if ((strstr($tplString, "AJXP_TARGET_FOLDER") !== false || strstr($tplString, "AJXP_SOURCE_FOLDER")) && isset($this->secondaryNode)) {
$p = $this->secondaryNode->getPath();
if ($this->secondaryNode->isLeaf()) {
$p = $this->getRoot(dirname($p));
}
$replaces["AJXP_TARGET_FOLDER"] = $replaces["AJXP_SOURCE_FOLDER"] = $em . $p . $me;
}
if ((strstr($tplString, "AJXP_TARGET_LABEL") !== false || strstr($tplString, "AJXP_SOURCE_LABEL") !== false) && isset($this->secondaryNode)) {
$replaces["AJXP_TARGET_LABEL"] = $replaces["AJXP_SOURCE_LABEL"] = $em . $this->secondaryNode->getLabel() . $me;
}
return str_replace(array_keys($replaces), array_values($replaces), $tplString);
}
示例3: scanFile
/**
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* Main function, it is called by the hook.
*/
public function scanFile($oldNode = null, $newNode = null)
{
if ($oldNode != null || $newNode == null) {
return;
}
// ADD THOSE TWO LINES
$newNode->loadNodeInfo();
if (!$newNode->isLeaf()) {
return;
}
$this->callSet($newNode);
//initializes attributes
// This block scans or doesn't scan the file. This is based on plugin parameters
if ($this->file_size < $this->scan_max_size) {
if ($this->scan_all == true) {
if ($this->inList() == true) {
if ($this->getFilteredOption("TRACE") == false) {
return;
}
$this->scanLater();
return;
} else {
$this->scanNow();
return;
}
} else {
if ($this->inList() == true) {
$this->scanNow();
return;
} else {
if ($this->getFilteredOption("TRACE") == false) {
return;
}
$this->scanLater();
return;
}
}
} else {
$this->scanLater();
return;
}
}
示例4: moveShareIfPossible
/**
* @param String $type
* @param String $element
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* @return bool
*/
public function moveShareIfPossible($type, $element, $oldNode, $newNode)
{
if (!$this->sqlSupported) {
return false;
}
$this->confStorage->simpleStoreGet("share", $element, "serial", $data);
if ($oldNode->isLeaf() && $type == "minisite" && is_array($data)) {
$repo = ConfService::getRepositoryById($data["REPOSITORY"]);
$cFilter = $repo->getContentFilter();
if (isset($cFilter)) {
$cFilter->movePath($oldNode->getPath(), $newNode->getPath());
}
}
}
示例5: extractMeta
/**
* @param AJXP_Node $ajxpNode
*/
public function extractMeta(&$ajxpNode)
{
$currentFile = $ajxpNode->getUrl();
if (!$ajxpNode->isLeaf() || preg_match("/\\.zip\\//", $currentFile)) {
return;
}
if (!preg_match("/\\.jpg\$|\\.jpeg\$|\\.tif\$|\\.tiff\$/i", $currentFile)) {
return;
}
$definitions = $this->getMetaDefinition();
if (!count($definitions)) {
return;
}
if (!function_exists("exif_read_data")) {
return;
}
//if(!exif_imagetype($currentFile)) return ;
$realFile = $ajxpNode->getRealFile();
$exif = @exif_read_data($realFile, 0, TRUE);
$iptc = $this->extractIPTC($realFile);
if ($exif === false) {
return;
}
$additionalMeta = array();
foreach ($definitions as $def => $label) {
list($exifSection, $exifName) = explode("-", $def);
if ($exifSection == "COMPUTED_GPS" && !isset($exif["COMPUTED_GPS"])) {
$exif['COMPUTED_GPS'] = $this->convertGPSData($exif);
}
if (isset($exif[$exifSection]) && isset($exif[$exifSection][$exifName])) {
$additionalMeta[$def] = $exif[$exifSection][$exifName];
}
if ($exifSection == "IPTC" && isset($iptc[$exifName])) {
$additionalMeta[$def] = $iptc[$exifName];
}
}
$ajxpNode->mergeMetadata($additionalMeta);
}
示例6: shareNode
/**
* @param AJXP_Node $ajxpNode
* @param array $httpVars
* @param bool $update
* @return Repository[]|ShareLink[]
* @throws Exception
*/
public function shareNode($ajxpNode, $httpVars, &$update)
{
$hiddenUserEntries = array();
$originalHttpVars = $httpVars;
$ocsStore = new Pydio\OCS\Model\SQLStore();
$ocsClient = new Pydio\OCS\Client\OCSClient();
$userSelection = new UserSelection($this->repository, $httpVars);
$mess = ConfService::getMessages();
/**
* @var ShareLink[] $shareObjects
*/
$shareObjects = array();
// PUBLIC LINK
if (isset($httpVars["enable_public_link"])) {
if (!$this->getAuthorization($ajxpNode->isLeaf() ? "file" : "folder", "minisite")) {
throw new Exception($mess["share_center." . ($ajxpNode->isLeaf() ? "225" : "226")]);
}
$this->shareObjectFromParameters($httpVars, $hiddenUserEntries, $shareObjects, "public");
} else {
if (isset($httpVars["disable_public_link"])) {
$this->getShareStore()->deleteShare("minisite", $httpVars["disable_public_link"], true);
}
}
if (isset($httpVars["ocs_data"])) {
$ocsData = json_decode($httpVars["ocs_data"], true);
$removeLinks = $ocsData["REMOVE"];
foreach ($removeLinks as $linkHash) {
// Delete Link, delete invitation(s)
$this->getShareStore()->deleteShare("minisite", $linkHash, true);
$invitations = $ocsStore->invitationsForLink($linkHash);
foreach ($invitations as $invitation) {
$ocsStore->deleteInvitation($invitation);
$ocsClient->cancelInvitation($invitation);
}
}
$newLinks = $ocsData["LINKS"];
foreach ($newLinks as $linkData) {
$this->shareObjectFromParameters($linkData, $hiddenUserEntries, $shareObjects, "targetted", $userSelection->getUniqueNode()->getLabel());
}
}
$this->filterHttpVarsFromUniqueNode($httpVars, $ajxpNode);
$users = array();
$groups = array();
$this->getRightsManager()->createUsersFromParameters($httpVars, $users, $groups);
if ((count($users) || count($groups)) && !$this->getAuthorization($ajxpNode->isLeaf() ? "file" : "folder", "workspace")) {
$users = $groups = array();
}
foreach ($hiddenUserEntries as $entry) {
$users[$entry["ID"]] = $entry;
}
if (!count($users) && !count($groups)) {
ob_start();
unset($originalHttpVars["hash"]);
$this->switchAction("unshare", $originalHttpVars, array());
ob_end_clean();
return null;
}
$newRepo = $this->createSharedRepository($httpVars, $repoUpdate, $users, $groups);
foreach ($shareObjects as $shareObject) {
$shareObject->setParentRepositoryId($this->repository->getId());
$shareObject->attachToRepository($newRepo->getId());
$shareObject->save();
if ($shareObject instanceof \Pydio\OCS\Model\TargettedLink) {
$invitation = $shareObject->getPendingInvitation();
if (!empty($invitation)) {
$ocsStore->generateInvitationId($invitation);
try {
$ocsClient->sendInvitation($invitation);
} catch (Exception $e) {
$this->getShareStore()->deleteShare("minisite", $shareObject->getHash(), true);
$shareUserId = $shareObject->getUniqueUser();
unset($users[$shareUserId]);
if (!count($users) && !count($groups)) {
$this->getShareStore()->deleteShare("repository", $newRepo->getId());
}
throw $e;
}
$ocsStore->storeInvitation($invitation);
}
} else {
$this->getPublicAccessManager()->initFolder();
$url = $this->getPublicAccessManager()->buildPublicLink($shareObject->getHash());
$existingShortForm = $shareObject->getShortFormUrl();
if (empty($existingShortForm)) {
$shortForm = "";
AJXP_Controller::applyHook("url.shorten", array($url, &$shortForm));
if (!empty($shortForm)) {
$shareObject->setShortFormUrl($shortForm);
$shareObject->save();
}
}
}
}
//.........这里部分代码省略.........
示例7: updateNodeMetaPath
/**
* @param AJXP_Node $ajxpNode
* @param boolean $create
* @return String
*/
private function updateNodeMetaPath($ajxpNode, $create = false)
{
$folder = false;
$trim = trim($ajxpNode->getPath(), "/");
if ($ajxpNode->is_file !== null) {
$folder = !$ajxpNode->isLeaf();
} else {
$folder = !is_file($ajxpNode->getUrl());
}
if (!$folder) {
return $trim;
}
$meta = is_file(rtrim($ajxpNode->getUrl(), "/") . "/.meta");
if (!$meta) {
if ($create) {
file_put_contents(rtrim($ajxpNode->getUrl(), "/") . "/.meta", "meta");
} else {
return null;
}
}
return $trim . "/.meta";
}
示例8: updateNodeSharedData
/**
*
* Hooked to node.change, this will update the index
* if $oldNode = null => create node $newNode
* if $newNode = null => delete node $oldNode
* Else copy or move oldNode to newNode.
*
* @param AJXP_Node $oldNode
*/
public function updateNodeSharedData($oldNode)
{
if (empty($this->accessDriver) || $this->accessDriver->getId() == "access.imap") {
return;
}
if ($oldNode == null || !$oldNode->hasMetaStore()) {
return;
}
$metadata = $oldNode->retrieveMetadata("ajxp_shared", true);
if (count($metadata) && !empty($metadata["element"])) {
// TODO
// Make sure node info is loaded, to check if it's a dir or a file.
// Maybe could be directly embedded in metadata, to avoid having to load here.
$oldNode->loadNodeInfo();
try {
$type = $oldNode->isLeaf() ? "file" : "repository";
$elementIds = array();
if ($type == "file") {
if (!is_array($metadata["element"])) {
$elementIds[] = $metadata["element"];
} else {
$elementIds = array_keys($metadata["element"]);
}
} else {
$elementIds[] = $metadata["element"];
}
foreach ($elementIds as $elementId) {
self::deleteSharedElement($type, $elementId, AuthService::getLoggedUser());
}
$oldNode->removeMetadata("ajxp_shared", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
} catch (Exception $e) {
$this->logError("Exception", $e->getMessage(), $e->getTrace());
}
}
}
示例9: updateNodesIndex
/**
* @param AJXP_Node $oldNode
* @param AJXP_Node $newNode
* @param bool $copy
*/
public function updateNodesIndex($oldNode = null, $newNode = null, $copy = false)
{
require_once AJXP_BIN_FOLDER . "/dibi.compact.php";
try {
if ($newNode == null) {
$repoId = $this->computeIdentifier($oldNode->getRepository());
// DELETE
dibi::query("DELETE FROM [ajxp_index] WHERE [node_path] LIKE %like~ AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
} else {
if ($oldNode == null) {
// CREATE
$stat = stat($newNode->getUrl());
$res = dibi::query("INSERT INTO [ajxp_index]", array("node_path" => $newNode->getPath(), "bytesize" => $stat["size"], "mtime" => $stat["mtime"], "md5" => $newNode->isLeaf() ? md5_file($newNode->getUrl()) : "directory", "repository_identifier" => $repoId = $this->computeIdentifier($newNode->getRepository())));
} else {
$repoId = $this->computeIdentifier($oldNode->getRepository());
if ($oldNode->getPath() == $newNode->getPath()) {
// CONTENT CHANGE
clearstatcache();
$stat = stat($newNode->getUrl());
$this->logDebug("Content changed", "current stat size is : " . $stat["size"]);
dibi::query("UPDATE [ajxp_index] SET ", array("bytesize" => $stat["size"], "mtime" => $stat["mtime"], "md5" => md5_file($newNode->getUrl())), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
} else {
// PATH CHANGE ONLY
$newNode->loadNodeInfo();
if ($newNode->isLeaf()) {
dibi::query("UPDATE [ajxp_index] SET ", array("node_path" => $newNode->getPath()), "WHERE [node_path] = %s AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
} else {
dibi::query("UPDATE [ajxp_index] SET [node_path]=REPLACE( REPLACE(CONCAT('\$\$\$',[node_path]), CONCAT('\$\$\$', %s), CONCAT('\$\$\$', %s)) , '\$\$\$', '') ", $oldNode->getPath(), $newNode->getPath(), "WHERE [node_path] LIKE %like~ AND [repository_identifier] = %s", $oldNode->getPath(), $repoId);
}
}
}
}
} catch (Exception $e) {
AJXP_Logger::error("[meta.syncable]", "Indexation", $e->getMessage());
}
}
示例10: switchAction
//.........这里部分代码省略.........
foreach ($nodes as $node) {
if ($orderField == "filesize") {
$toSort[$node] = is_file($nonPatchedPath . "/" . $node) ? $this->filesystemFileSize($nonPatchedPath . "/" . $node) : 0;
} else {
if ($orderField == "ajxp_modiftime") {
$toSort[$node] = filemtime($nonPatchedPath . "/" . $node);
} else {
if ($orderField == "mimestring") {
$toSort[$node] = pathinfo($node, PATHINFO_EXTENSION);
}
}
}
}
if ($orderDirection == "asc") {
asort($toSort);
} else {
arsort($toSort);
}
$nodes = array_keys($toSort);
}
//while (strlen($nodeName = readdir($handle)) > 0) {
foreach ($nodes as $nodeName) {
if ($nodeName == "." || $nodeName == "..") {
continue;
}
if (isset($uniqueFile) && $nodeName != $uniqueFile) {
$cursor++;
continue;
}
if ($offset > 0 && $cursor < $offset) {
$cursor++;
continue;
}
$isLeaf = "";
if (!$this->filterNodeName($path, $nodeName, $isLeaf, $lsOptions)) {
continue;
}
if (RecycleBinManager::recycleEnabled() && $dir == "" && "/" . $nodeName == RecycleBinManager::getRecyclePath()) {
continue;
}
if ($limitPerPage > 0 && $cursor - $offset >= $limitPerPage) {
break;
}
$currentFile = $nonPatchedPath . "/" . $nodeName;
$meta = array();
if ($isLeaf != "") {
$meta = array("is_file" => $isLeaf ? "1" : "0");
}
$node = new AJXP_Node($currentFile, $meta);
$node->setLabel($nodeName);
$node->loadNodeInfo(false, false, $lsOptions["l"] ? "all" : "minimal");
if (!empty($node->metaData["nodeName"]) && $node->metaData["nodeName"] != $nodeName) {
$node->setUrl($nonPatchedPath . "/" . $node->metaData["nodeName"]);
}
if (!empty($node->metaData["hidden"]) && $node->metaData["hidden"] === true) {
continue;
}
if (!empty($node->metaData["mimestring_id"]) && array_key_exists($node->metaData["mimestring_id"], $mess)) {
$node->mergeMetadata(array("mimestring" => $mess[$node->metaData["mimestring_id"]]));
}
if (isset($originalLimitPerPage) && $cursor > $originalLimitPerPage) {
$node->mergeMetadata(array("page_position" => floor($cursor / $originalLimitPerPage) + 1));
}
$nodeType = "d";
if ($node->isLeaf()) {
if (AJXP_Utils::isBrowsableArchive($nodeName)) {
示例11: clearCacheForNode
/**
* @param AJXP_Node $node
*/
protected function clearCacheForNode($node)
{
if ($node->isLeaf()) {
// Clear meta
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, $this->computeId($node, true));
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, $this->computeId($node, false));
// Clear stat
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, AbstractCacheDriver::computeIdForNode($node, "stat"));
// Clear parent listing
if ($node->getParent() !== null) {
CacheService::delete(AJXP_CACHE_SERVICE_NS_NODES, AbstractCacheDriver::computeIdForNode($node->getParent(), "list"));
}
} else {
$cacheDriver = ConfService::getCacheDriverImpl();
$cacheDriver->deleteKeyStartingWith(AJXP_CACHE_SERVICE_NS_NODES, $this->computeId($node, true));
$cacheDriver->deleteKeyStartingWith(AJXP_CACHE_SERVICE_NS_NODES, $this->computeId($node, false));
$cacheDriver->deleteKeyStartingWith(AJXP_CACHE_SERVICE_NS_NODES, AbstractCacheDriver::computeIdForNode($node, "stat"));
if ($node->getParent() !== null) {
$cacheDriver->deleteKeyStartingWith(AJXP_CACHE_SERVICE_NS_NODES, AbstractCacheDriver::computeIdForNode($node->getParent(), "list"));
} else {
$cacheDriver->deleteKeyStartingWith(AJXP_CACHE_SERVICE_NS_NODES, AbstractCacheDriver::computeIdForNode($node, "list"));
}
}
}
示例12: applyAction
//.........这里部分代码省略.........
$qb = new Elastica\QueryBuilder();
$fullQuery = new Elastica\Query();
$filter = $qb->query()->match("ajxp_scope", "shared");
$fullQuery->setQuery($qb->query()->bool()->addMust($fieldQuery)->addFilter($filter));
$result = $search->search($fullQuery, $searchOptions);
$this->logDebug(__FUNCTION__, "Search finished. ");
$hits = $result->getResults();
AJXP_XMLWriter::header();
foreach ($hits as $hit) {
$source = $hit->getSource();
if ($source["serialized_metadata"] != null) {
$meta = unserialize(base64_decode($source["serialized_metadata"]));
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($source["node_url"]), $meta);
} else {
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($source["node_url"]), array());
$tmpNode->loadNodeInfo();
}
if (!file_exists($tmpNode->getUrl())) {
$this->currentType->deleteById($hit->getId());
continue;
}
$tmpNode->search_score = sprintf("%0.2f", $hit->getScore());
AJXP_XMLWriter::renderAjxpNode($tmpNode);
}
AJXP_XMLWriter::close();
} else {
if ($actionName == "search_by_keyword") {
$scope = "user";
try {
$this->loadIndex($repoId, false);
} catch (Exception $ex) {
throw new Exception($messages["index.lucene.7"]);
}
/*
$sParts = array();
$searchField = $httpVars["field"];
if ($scope == "user") {
if (AuthService::usersEnabled() && AuthService::getLoggedUser() == null) {
throw new Exception("Cannot find current user");
}
$sParts[] = "ajxp_scope:user";
$sParts[] = "ajxp_user:".AuthService::getLoggedUser()->getId();
} else {
$sParts[] = "ajxp_scope:shared";
}
$query = implode(" AND ", $sParts);
$this->logDebug("Query : $query");*/
$searchField = AJXP_Utils::sanitize($httpVars["field"], AJXP_SANITIZE_ALPHANUM);
$fieldQuery = new Elastica\Query\QueryString();
$fields = array($searchField);
$fieldQuery->setQuery($searchField == "ajxp_node" ? "yes" : "true");
$fieldQuery->setFields($fields);
$fieldQuery->setAllowLeadingWildcard(false);
$fieldQuery->setFuzzyMinSim(0.8);
$search = new Elastica\Search($this->client);
$search->addIndex($this->currentIndex)->addType($this->currentType);
$maxResults = $this->getFilteredOption("MAX_RESULTS");
if (isset($httpVars['limit'])) {
$maxResults = intval($httpVars['limit']);
}
$searchOptions = array(\Elastica\Search::OPTION_SEARCH_TYPE => \Elastica\Search::OPTION_SEARCH_TYPE_QUERY_THEN_FETCH, \Elastica\Search::OPTION_SIZE => $maxResults);
/* ADD SCOPE FILTER
$term = new Elastica\Filter\Term();
$term->setTerm("ajxp_scope", "user");*/
$qb = new Elastica\QueryBuilder();
$fullQuery = new Elastica\Query();
$fullQuery->setQuery($qb->query()->bool()->addMust($fieldQuery)->addMust($qb->query()->match("ajxp_scope", "user"))->addMust($qb->query()->match("user", AuthService::getLoggedUser()->getId())));
$result = $search->search($fullQuery, $searchOptions);
$this->logDebug(__FUNCTION__, "Search finished. ");
$hits = $result->getResults();
AJXP_XMLWriter::header();
$leafNodes = [];
foreach ($hits as $hit) {
if ($hit->serialized_metadata != null) {
$meta = unserialize(base64_decode($hit->serialized_metadata));
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), $meta);
} else {
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), array());
$tmpNode->loadNodeInfo();
}
if (!file_exists($tmpNode->getUrl())) {
$this->currentType->deleteById($hit->id);
continue;
}
$tmpNode->search_score = sprintf("%0.2f", $hit->score);
if ($tmpNode->isLeaf()) {
$leafNodes[] = $tmpNode;
} else {
AJXP_XMLWriter::renderAjxpNode($tmpNode);
}
}
foreach ($leafNodes as $leaf) {
AJXP_XMLWriter::renderAjxpNode($leaf);
}
AJXP_XMLWriter::close();
}
}
}
示例13: delete
public function delete($selectedFiles, &$logMessages)
{
$repoData = array('base_url' => $this->urlBase, 'chmod' => $this->repository->getOption('CHMOD_VALUE'), 'recycle' => $this->repository->getOption('RECYCLE_BIN'));
$mess = ConfService::getMessages();
foreach ($selectedFiles as $selectedFile) {
if ($selectedFile == "" || $selectedFile == DIRECTORY_SEPARATOR) {
return $mess[120];
}
$fileToDelete = $this->urlBase . $selectedFile;
if (!file_exists($fileToDelete)) {
$logMessages[] = $mess[100] . " " . SystemTextEncoding::toUTF8($selectedFile);
continue;
}
$node = new AJXP_Node($fileToDelete);
$node->setLeaf(!is_dir($fileToDelete));
$this->deldir($fileToDelete, $repoData);
if ($node->isLeaf()) {
$logMessages[] = "{$mess['38']} " . SystemTextEncoding::toUTF8($selectedFile) . " {$mess['44']}.";
} else {
$logMessages[] = "{$mess['34']} " . SystemTextEncoding::toUTF8($selectedFile) . " {$mess['44']}.";
}
AJXP_Controller::applyHook("node.change", [$node]);
}
return null;
}
示例14: renderAjxpNode
/**
* @static
* @param AJXP_Node $ajxpNode
* @param bool $close
* @param bool $print
* @return void|string
*/
public static function renderAjxpNode($ajxpNode, $close = true, $print = true)
{
return AJXP_XMLWriter::renderNode($ajxpNode->getPath(), $ajxpNode->getLabel(), $ajxpNode->isLeaf(), $ajxpNode->metadata, $close, $print);
}
示例15: applyAction
//.........这里部分代码省略.........
}
$cursor = 0;
if (isset($httpVars['limit'])) {
$limit = intval($httpVars['limit']);
}
foreach ($hits as $hit) {
// Backward compatibility
$hit->node_url = preg_replace("#ajxp\\.[a-z_]+://#", "pydio://", $hit->node_url);
if ($hit->serialized_metadata != null) {
$meta = unserialize(base64_decode($hit->serialized_metadata));
if (isset($meta["ajxp_modiftime"])) {
$meta["ajxp_relativetime"] = $meta["ajxp_description"] = $messages[4] . " " . AJXP_Utils::relativeDate($meta["ajxp_modiftime"], $messages);
}
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), $meta);
} else {
$tmpNode = new AJXP_Node(SystemTextEncoding::fromUTF8($hit->node_url), array());
$tmpNode->loadNodeInfo();
}
if ($tmpNode->getRepositoryId() != $repoId) {
$this->logDebug(__CLASS__, "Strange case, search retrieves a node from wrong repository!");
$index->delete($hit->id);
$commitIndex = true;
continue;
}
if (!file_exists($tmpNode->getUrl())) {
$index->delete($hit->id);
$commitIndex = true;
continue;
}
if (!is_readable($tmpNode->getUrl())) {
continue;
}
$basename = basename($tmpNode->getPath());
$isLeaf = $tmpNode->isLeaf();
if (!$this->accessDriver->filterNodeName($tmpNode->getPath(), $basename, $isLeaf, array("d" => true, "f" => true))) {
continue;
}
$tmpNode->search_score = sprintf("%0.2f", $hit->score);
if (isset($returnNodes)) {
$returnNodes[] = $tmpNode;
} else {
AJXP_XMLWriter::renderAjxpNode($tmpNode);
}
$cursor++;
if (isset($limit) && $cursor > $limit) {
break;
}
}
if (!isset($returnNodes)) {
AJXP_XMLWriter::close();
}
if ($commitIndex) {
$index->commit();
}
} else {
if ($actionName == "search_by_keyword") {
require_once "Zend/Search/Lucene.php";
$scope = "user";
try {
$index = $this->loadIndex($repoId, false);
} catch (Exception $ex) {
AJXP_XMLWriter::header();
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
AJXP_Controller::applyActionInBackground($repoId, "index", array());
AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repoId), sprintf($messages["index.lucene.8"], "/"), true, 2);
}