本文整理汇总了PHP中AJXP_Utils::relativeDate方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Utils::relativeDate方法的具体用法?PHP AJXP_Utils::relativeDate怎么用?PHP AJXP_Utils::relativeDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Utils
的用法示例。
在下文中一共展示了AJXP_Utils::relativeDate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: getDescription
/**
* @param bool $public
* @return String
*/
public function getDescription($public = false, $ownerLabel = null)
{
$m = ConfService::getMessages();
if (isset($this->options["USER_DESCRIPTION"]) && !empty($this->options["USER_DESCRIPTION"])) {
if (isset($m[$this->options["USER_DESCRIPTION"]])) {
return $m[$this->options["USER_DESCRIPTION"]];
} else {
return $this->options["USER_DESCRIPTION"];
}
}
if (isset($this->parentId) && isset($this->owner)) {
if (isset($this->options["CREATION_TIME"])) {
$date = AJXP_Utils::relativeDate($this->options["CREATION_TIME"], $m);
return str_replace(array("%date", "%user"), array($date, $ownerLabel != null ? $ownerLabel : $this->owner), $public ? $m["470"] : $m["473"]);
} else {
if ($public) {
return $m["474"];
} else {
return str_replace(array("%user"), array($ownerLabel != null ? $ownerLabel : $this->owner), $m["472"]);
}
}
} else {
if ($this->isWriteable() && isset($this->options["CREATION_TIME"])) {
$date = AJXP_Utils::relativeDate($this->options["CREATION_TIME"], $m);
if (isset($this->options["CREATION_USER"])) {
return str_replace(array("%date", "%user"), array($date, $this->options["CREATION_USER"]), $m["471"]);
} else {
return str_replace(array("%date"), array($date), $m["470"]);
}
} else {
return $m["474"];
}
}
}
示例3: switchActions
/**
* @param String $actionName
* @param Array $httpVars
* @param Array $fileVars
*/
public function switchActions($actionName, $httpVars, $fileVars)
{
$userSelection = new UserSelection($this->accessDriver->repository, $httpVars);
$uniqNode = $userSelection->getUniqueNode();
$feedStore = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("feed");
$existingFeed = $uniqNode->retrieveMetadata(AJXP_META_SPACE_COMMENTS, false);
if ($existingFeed == null) {
$existingFeed = array();
}
$mess = ConfService::getMessages();
switch ($actionName) {
case "post_comment":
$uId = AuthService::getLoggedUser()->getId();
$limit = $this->getFilteredOption("COMMENT_SIZE_LIMIT");
if (!empty($limit)) {
$content = substr(AJXP_Utils::decodeSecureMagic($httpVars["content"]), 0, $limit);
} else {
$content = AJXP_Utils::decodeSecureMagic($httpVars["content"]);
}
$com = array("date" => time(), "author" => $uId, "content" => $content);
$existingFeed[] = $com;
if ($feedStore !== false) {
$feedStore->persistMetaObject($uniqNode->getPath(), base64_encode($content), $uniqNode->getRepositoryId(), $uniqNode->getRepository()->securityScope(), $uniqNode->getRepository()->getOwner(), AuthService::getLoggedUser()->getId(), AuthService::getLoggedUser()->getGroupPath());
} else {
$uniqNode->removeMetadata(AJXP_META_SPACE_COMMENTS, false);
$uniqNode->setMetadata(AJXP_META_SPACE_COMMENTS, $existingFeed, false);
}
HTMLWriter::charsetHeader("application/json");
$com["hdate"] = AJXP_Utils::relativeDate($com["date"], $mess);
$com["path"] = $uniqNode->getPath();
echo json_encode($com);
break;
case "load_comments_feed":
HTMLWriter::charsetHeader("application/json");
if ($feedStore !== false) {
$sortBy = isset($httpVars["sort_by"]) ? AJXP_Utils::decodeSecureMagic($httpVars["sort_by"]) : "date";
$sortDir = isset($httpVars["sort_dir"]) ? AJXP_Utils::decodeSecureMagic($httpVars["sort_dir"]) : "asc";
$offset = isset($httpVars["offset"]) ? intval($httpVars["offset"]) : 0;
$limit = isset($httpVars["limit"]) ? intval($httpVars["limit"]) : 100;
$uniqNode->loadNodeInfo();
$data = $feedStore->findMetaObjectsByIndexPath($this->accessDriver->repository->getId(), $uniqNode->getPath(), AuthService::getLoggedUser()->getId(), AuthService::getLoggedUser()->getGroupPath(), $offset, $limit, $sortBy, $sortDir, !$uniqNode->isLeaf());
$theFeed = array();
foreach ($data as $stdObject) {
$rPath = substr($stdObject->path, strlen($uniqNode->getPath()));
if ($rPath == false && $stdObject->path == $uniqNode->getPath()) {
$rPath = "";
}
$rPath = ltrim($rPath, "/");
$newItem = array("date" => $stdObject->date, "hdate" => AJXP_Utils::relativeDate($stdObject->date, $mess), "author" => $stdObject->author, "content" => base64_decode($stdObject->content), "path" => $stdObject->path, "rpath" => $rPath, "uuid" => $stdObject->uuid);
if (isset($previous) && $previous["author"] == $newItem["author"] && $previous["path"] == $newItem["path"] && $previous["hdate"] == $newItem["hdate"]) {
$theFeed[count($theFeed) - 1]["content"] .= '<br>' . $newItem["content"];
} else {
$theFeed[] = $newItem;
}
$previous = $newItem;
}
echo json_encode($theFeed);
} else {
foreach ($existingFeed as &$item) {
$item["hdate"] = AJXP_Utils::relativeDate($item["date"], $mess);
}
echo json_encode($existingFeed);
}
break;
case "delete_comment":
$data = json_decode($httpVars["comment_data"], true);
if ($feedStore === false) {
$reFeed = array();
if ($data["author"] != AuthService::getLoggedUser()->getId()) {
break;
}
foreach ($existingFeed as $fElement) {
if ($fElement["date"] == $data["date"] && $fElement["author"] == $data["author"] && $fElement["content"] == $data["content"]) {
continue;
}
$fElement["hdate"] = AJXP_Utils::relativeDate($fElement["date"], $mess);
$reFeed[] = $fElement;
}
$uniqNode->removeMetadata(AJXP_META_SPACE_COMMENTS, false);
$uniqNode->setMetadata(AJXP_META_SPACE_COMMENTS, $reFeed, false);
HTMLWriter::charsetHeader("application/json");
echo json_encode($reFeed);
} else {
$feedStore->dismissAlertById($data["uuid"], 1);
}
break;
default:
break;
}
}
示例4: applyAction
public function applyAction($actionName, $httpVars, $fileVars)
{
$messages = ConfService::getMessages();
$repoId = $this->accessDriver->repository->getId();
if ($actionName == "search") {
// TMP
if (strpos($httpVars["query"], "keyword:") === 0) {
$parts = explode(":", $httpVars["query"]);
$this->applyAction("search_by_keyword", array("field" => $parts[1]), array());
return null;
}
require_once "Zend/Search/Lucene.php";
try {
$index = $this->loadIndex($repoId, false);
} catch (Exception $ex) {
AJXP_XMLWriter::header();
if ($this->seemsCurrentlyIndexing($repoId, 3)) {
AJXP_XMLWriter::sendMessage($messages["index.lucene.11"], null);
} else {
if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
AJXP_Controller::applyActionInBackground($repoId, "index", array());
sleep(2);
AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $repoId), sprintf($messages["index.lucene.8"], "/"), true, 5);
AJXP_XMLWriter::sendMessage($messages["index.lucene.7"], null);
} else {
AJXP_XMLWriter::sendMessage($messages["index.lucene.12"], null);
}
}
AJXP_XMLWriter::close();
return null;
}
$textQuery = $httpVars["query"];
if ($this->getFilteredOption("AUTO_WILDCARD") === true && strlen($textQuery) > 0 && ctype_alnum($textQuery)) {
if ($textQuery[0] == '"' && $textQuery[strlen($textQuery) - 1] == '"') {
$textQuery = substr($textQuery, 1, -1);
} else {
if ($textQuery[strlen($textQuery) - 1] != "*") {
$textQuery .= "*";
}
}
}
if (strpos($textQuery, ":") !== false) {
$textQuery = str_replace("ajxp_meta_ajxp_document_content:", "body:", $textQuery);
$textQuery = $this->filterSearchRangesKeywords($textQuery);
$query = "ajxp_scope:shared AND ({$textQuery})";
} else {
if ((isset($this->metaFields) || $this->indexContent) && isset($httpVars["fields"])) {
$sParts = array();
foreach (explode(",", $httpVars["fields"]) as $searchField) {
if ($searchField == "filename") {
$sParts[] = "basename:" . $textQuery;
} else {
if ($searchField == "ajxp_document_content") {
$sParts[] = $textQuery;
} else {
if (in_array($searchField, $this->metaFields)) {
$sParts[] = "ajxp_meta_" . $searchField . ":" . $textQuery;
} else {
if ($searchField == "ajxp_document_content") {
$sParts[] = "title:" . $textQuery;
$sParts[] = "body:" . $textQuery;
$sParts[] = "keywords:" . $textQuery;
}
}
}
}
}
$query = implode(" OR ", $sParts);
$query = "ajxp_scope:shared AND ({$query})";
$this->logDebug("Query : {$query}");
} else {
$index->setDefaultSearchField("basename");
$query = $this->filterSearchRangesKeywords($textQuery);
}
}
$this->setDefaultAnalyzer();
if ($query == "*") {
$index->setDefaultSearchField("ajxp_node");
$query = "yes";
$hits = $index->find($query, "node_url", SORT_STRING);
} else {
$hits = $index->find($query);
}
$commitIndex = false;
if (isset($httpVars['return_selection'])) {
$returnNodes = array();
} else {
AJXP_XMLWriter::header();
}
$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);
//.........这里部分代码省略.........
示例5: getNodes
public static function getNodes($checkStats = false, $touch = true)
{
if (isset(self::$output)) {
return self::$output;
}
$mess = ConfService::getMessages();
$repos = ConfService::getAccessibleRepositories();
$output = array();
$touchReposIds = array();
foreach ($repos as $repo) {
if (!$repo->hasOwner() || !$repo->hasContentFilter()) {
continue;
}
$repoId = $repo->getId();
if (strpos("ocs_remote_share_", $repoId) !== 0) {
$touchReposIds[] = $repoId;
}
$url = "pydio://" . $repoId . "/";
$meta = array("shared_repository_id" => $repoId, "ajxp_description" => "File shared by " . $repo->getOwner() . " " . AJXP_Utils::relativeDate($repo->getOption("CREATION_TIME"), $mess), "share_meta_type" => 1);
$cFilter = $repo->getContentFilter();
$filter = $cFilter instanceof ContentFilter ? array_keys($cFilter->filters)[0] : $cFilter;
if (!is_array($filter)) {
$label = basename($filter);
} else {
$label = $repo->getDisplay();
}
if (strpos($repoId, "ocs_remote_share") !== 0) {
// FOR REMOTE SHARES, DO NOT APPEND THE DOCUMENTNAME, WE STAT THE ROOT DIRECTLY
$url .= $label;
}
$status = null;
$remoteShare = null;
$name = pathinfo($label, PATHINFO_FILENAME);
$ext = pathinfo($label, PATHINFO_EXTENSION);
$node = new AJXP_Node($url);
$node->setLabel($label);
if ($checkStats) {
$node->getRepository()->driverInstance = null;
try {
ConfService::loadDriverForRepository($node->getRepository());
} catch (Exception $e) {
$ext = "error";
$meta["ajxp_mime"] = "error";
}
$node->getRepository()->detectStreamWrapper(true);
$stat = @stat($url);
if ($stat === false) {
$ext = "error";
$meta["ajxp_mime"] = "error";
$meta["share_meta_type"] = 2;
} else {
if (strpos($repoId, "ocs_remote_share_") === 0) {
// Check Status
$linkId = str_replace("ocs_remote_share_", "", $repoId);
$ocsStore = new \Pydio\OCS\Model\SQLStore();
$remoteShare = $ocsStore->remoteShareById($linkId);
$status = $remoteShare->getStatus();
if ($status == OCS_INVITATION_STATUS_PENDING) {
$stat = stat(AJXP_Utils::getAjxpTmpDir());
$ext = "invitation";
$meta["ajxp_mime"] = "invitation";
$meta["share_meta_type"] = 0;
} else {
$meta["remote_share_accepted"] = "true";
}
$meta["remote_share_id"] = $remoteShare->getId();
}
}
if ($ext == "invitation") {
$label .= " (" . $mess["inbox_driver.4"] . ")";
} else {
if ($ext == "error") {
$label .= " (" . $mess["inbox_driver.5"] . ")";
}
}
if (is_array($stat) && AuthService::getLoggedUser() != null) {
$acl = AuthService::getLoggedUser()->mergedRole->getAcl($repoId);
if ($acl == "r") {
self::disableWriteInStat($stat);
}
}
}
$index = 0;
$suffix = "";
while (isset($output[$name . $suffix . "." . $ext])) {
$index++;
$suffix = " ({$index})";
}
$output[$name . $suffix . "." . $ext] = ["label" => $label, "url" => $url, "remote_share" => $remoteShare, "meta" => $meta];
if (isset($stat)) {
$output[$name . $suffix . "." . $ext]['stat'] = $stat;
}
}
ConfService::loadDriverForRepository(ConfService::getRepository());
self::$output = $output;
if ($touch) {
if (count($touchReposIds) && AuthService::getLoggedUser() != null) {
$uPref = AuthService::getLoggedUser()->getPref("repository_last_connected");
if (empty($uPref)) {
$uPref = array();
//.........这里部分代码省略.........
示例6: loadUserAlerts
public function loadUserAlerts($actionName, $httpVars, $fileVars)
{
if (!$this->eventStore) {
return;
}
$u = AuthService::getLoggedUser();
$userId = $u->getId();
$repositoryFilter = null;
if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) {
$repositoryFilter = $httpVars["repository_id"];
}
if ($repositoryFilter == null) {
$repositoryFilter = ConfService::getRepository()->getId();
}
$res = $this->eventStore->loadAlerts($userId, $repositoryFilter);
if (!count($res)) {
return;
}
// Recompute children notifs
$format = $httpVars["format"];
$skipContainingTags = isset($httpVars["skip_container_tags"]);
$mess = ConfService::getMessages();
if (!$skipContainingTags) {
if ($format == "html") {
echo "<h2>" . $mess["notification_center.3"] . "</h2>";
echo "<ul class='notification_list'>";
} else {
AJXP_XMLWriter::header();
}
}
$parentRepository = ConfService::getRepositoryById($repositoryFilter);
$parentRoot = $parentRepository->getOption("PATH");
$cumulated = array();
foreach ($res as $notification) {
if ($format == "html") {
echo "<li>";
echo $notification->getDescriptionLong(true);
echo "</li>";
} else {
$node = $notification->getNode();
$path = $node->getPath();
$nodeRepo = $node->getRepository();
if ($nodeRepo != null && $nodeRepo->hasParent() && $nodeRepo->getParentId() == $repositoryFilter) {
$currentRoot = $nodeRepo->getOption("PATH");
$contentFilter = $nodeRepo->getContentFilter();
if (isset($contentFilter)) {
$nodePath = $contentFilter->filterExternalPath($node->getPath());
if ($nodePath == "/") {
$k = array_keys($contentFilter->filters);
$nodePath = $k[0];
}
} else {
$nodePath = $node->getPath();
}
$relative = rtrim(substr($currentRoot, strlen($parentRoot)), "/") . rtrim($nodePath, "/");
$parentNodeURL = $node->getScheme() . "://" . $repositoryFilter . $relative;
$this->logDebug("action.share", "Recompute alert to " . $parentNodeURL);
$node = new AJXP_Node($parentNodeURL);
}
if (isset($cumulated[$path])) {
$cumulated[$path]->event_occurence++;
continue;
}
try {
$node->loadNodeInfo();
} catch (Exception $e) {
if ($notification->alert_id) {
$this->eventStore->dismissAlertById($notification->alert_id);
}
continue;
}
$node->event_is_alert = true;
$node->event_description = ucfirst($notification->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notification->getAuthorLabel();
$node->event_description_long = $notification->getDescriptionLong(true);
$node->event_date = SystemTextEncoding::fromUTF8(AJXP_Utils::relativeDate($notification->getDate(), $mess));
$node->event_type = "alert";
$node->alert_id = $notification->alert_id;
if ($node->getRepository() != null) {
$node->repository_id = '' . $node->getRepository()->getId();
if ($node->repository_id != $repositoryFilter && $node->getRepository()->getDisplay() != null) {
$node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]";
}
} else {
$node->event_repository_label = "[N/A]";
}
$node->event_author = $notification->getAuthor();
$node->event_occurence = 1;
$cumulated[$path] = $node;
}
}
$index = 1;
foreach ($cumulated as $nodeToSend) {
$nodeOcc = $nodeToSend->event_occurence > 1 ? "(" . $nodeToSend->event_occurence . ")" : "";
if (isset($httpVars["merge_description"]) && $httpVars["merge_description"] == "true") {
if (isset($httpVars["description_as_label"]) && $httpVars["description_as_label"] == "true") {
$nodeToSend->setLabel($nodeToSend->event_description . " " . $nodeOcc . " " . $nodeToSend->event_date);
} else {
$nodeToSend->setLabel(basename($nodeToSend->getPath()) . " " . $nodeOcc . " " . " <small class='notif_desc'>" . $nodeToSend->event_description . " " . $nodeToSend->event_date . "</small>");
}
} else {
//.........这里部分代码省略.........
示例7: loadUserAlerts
public function loadUserAlerts($actionName, $httpVars, $fileVars)
{
if (!$this->eventStore) {
return;
}
$u = AuthService::getLoggedUser();
$userId = $u->getId();
$repositoryFilter = null;
if (isset($httpVars["repository_id"]) && $u->mergedRole->canRead($httpVars["repository_id"])) {
$repositoryFilter = $httpVars["repository_id"];
}
$res = $this->eventStore->loadAlerts($userId, $repositoryFilter);
if ($repositoryFilter == null) {
$repositoryFilter = ConfService::getRepository()->getId();
}
if (!count($res)) {
return;
}
$format = $httpVars["format"];
$skipContainingTags = isset($httpVars["skip_container_tags"]);
$mess = ConfService::getMessages();
if (!$skipContainingTags) {
if ($format == "html") {
echo "<h2>" . $mess["notification_center.3"] . "</h2>";
echo "<ul class='notification_list'>";
} else {
AJXP_XMLWriter::header();
}
}
$cumulated = array();
foreach ($res as $notification) {
if ($format == "html") {
echo "<li>";
echo $notification->getDescriptionLong(true);
echo "</li>";
} else {
$node = $notification->getNode();
$path = $node->getPath();
if (isset($cumulated[$path])) {
$cumulated[$path]->event_occurence++;
continue;
}
try {
$node->loadNodeInfo();
} catch (Exception $e) {
continue;
}
$node->event_is_alert = true;
$node->event_description = ucfirst($notification->getDescriptionBlock()) . " " . $mess["notification.tpl.block.user_link"] . " " . $notification->getAuthor();
$node->event_description_long = $notification->getDescriptionLong(true);
$node->event_date = AJXP_Utils::relativeDate($notification->getDate(), $mess);
$node->event_type = "alert";
$node->alert_id = $notification->alert_id;
if ($node->getRepository() != null) {
$node->repository_id = '' . $node->getRepository()->getId();
if ($node->repository_id != $repositoryFilter && $node->getRepository()->getDisplay() != null) {
$node->event_repository_label = "[" . $node->getRepository()->getDisplay() . "]";
}
} else {
$node->event_repository_label = "[N/A]";
}
$node->event_author = $notification->getAuthor();
$node->event_occurence = 1;
$cumulated[$path] = $node;
}
}
$index = 1;
foreach ($cumulated as $nodeToSend) {
if ($nodeToSend->event_occurence > 1) {
$nodeToSend->setLabel(basename($nodeToSend->getPath()) . " (" . $nodeToSend->event_occurence . ")");
} else {
$nodeToSend->setLabel(basename($nodeToSend->getPath()));
}
// Replace PATH
$nodeToSend->real_path = $path;
$url = parse_url($nodeToSend->getUrl());
$nodeToSend->setUrl($url["scheme"] . "://" . $url["host"] . "/alert_" . $index);
$index++;
AJXP_XMLWriter::renderAjxpNode($nodeToSend);
}
if (!$skipContainingTags) {
if ($format == "html") {
echo "</ul>";
} else {
AJXP_XMLWriter::close();
}
}
}
示例8: loadNodeInfo
/**
* @param AJXP_Node $ajxpNode
* @param bool $parentNode
* @param bool $details
* @return void
*/
public function loadNodeInfo(&$ajxpNode, $parentNode = false, $details = false)
{
$mess = ConfService::getMessages();
$nodeName = basename($ajxpNode->getPath());
$metaData = $ajxpNode->metadata;
if (!isset($metaData["is_file"])) {
$isLeaf = is_file($ajxpNode->getUrl()) || AJXP_Utils::isBrowsableArchive($nodeName);
$metaData["is_file"] = $isLeaf ? "1" : "0";
} else {
$isLeaf = $metaData["is_file"] == "1" ? true : false;
}
$metaData["filename"] = $ajxpNode->getPath();
if (RecycleBinManager::recycleEnabled() && $ajxpNode->getPath() == RecycleBinManager::getRelativeRecycle()) {
$recycleIcon = $this->countFiles($ajxpNode->getUrl(), false, true) > 0 ? "trashcan_full.png" : "trashcan.png";
$metaData["icon"] = $recycleIcon;
$metaData["mimestring"] = $mess[122];
$ajxpNode->setLabel($mess[122]);
$metaData["ajxp_mime"] = "ajxp_recycle";
} else {
$mimeData = AJXP_Utils::mimeData($ajxpNode->getUrl(), !$isLeaf);
$metaData["mimestring_id"] = $mimeData[0];
//AJXP_Utils::mimetype($ajxpNode->getUrl(), "type", !$isLeaf);
$metaData["icon"] = $mimeData[1];
//AJXP_Utils::mimetype($nodeName, "image", !$isLeaf);
if ($metaData["icon"] == "folder.png") {
$metaData["openicon"] = "folder_open.png";
}
if (!$isLeaf) {
$metaData["ajxp_mime"] = "ajxp_folder";
}
}
//if ($lsOptions["l"]) {
$metaData["file_group"] = @filegroup($ajxpNode->getUrl()) || "unknown";
$metaData["file_owner"] = @fileowner($ajxpNode->getUrl()) || "unknown";
$crtPath = $ajxpNode->getPath();
$vRoots = $this->repository->listVirtualRoots();
$metaData["ajxp_readonly"] = "false";
if (!@$this->isWriteable($ajxpNode->getUrl())) {
$metaData["ajxp_readonly"] = "true";
}
if (!empty($crtPath)) {
if (isset($vRoots[ltrim($crtPath, "/")])) {
$metaData["ajxp_readonly"] = $vRoots[ltrim($crtPath, "/")]["right"] == "r" ? "true" : "false";
}
} else {
if (count($vRoots)) {
$metaData["ajxp_readonly"] = "true";
}
}
$fPerms = @fileperms($ajxpNode->getUrl());
if ($fPerms !== false) {
$fPerms = substr(decoct($fPerms), $isLeaf ? 2 : 1);
} else {
$fPerms = '0000';
}
$metaData["file_perms"] = $fPerms;
$datemodif = $this->date_modif($ajxpNode->getUrl());
$metaData["ajxp_modiftime"] = $datemodif ? $datemodif : "0";
$metaData["ajxp_description"] = $metaData["ajxp_relativetime"] = $mess[4] . " " . AJXP_Utils::relativeDate($datemodif, $mess);
$metaData["bytesize"] = 0;
if ($isLeaf) {
$metaData["bytesize"] = filesize($ajxpNode->getUrl());
}
$metaData["filesize"] = AJXP_Utils::roundSize($metaData["bytesize"]);
if (AJXP_Utils::isBrowsableArchive($nodeName)) {
$metaData["ajxp_mime"] = "ajxp_browsable_archive";
}
if ($details == "minimal") {
$miniMeta = array("is_file" => $metaData["is_file"], "filename" => $metaData["filename"], "bytesize" => $metaData["bytesize"], "ajxp_modiftime" => $metaData["ajxp_modiftime"]);
$ajxpNode->mergeMetadata($miniMeta);
} else {
$ajxpNode->mergeMetadata($metaData);
}
}
示例9: listUsers
//.........这里部分代码省略.........
if (!$returnNodes) {
print $xml;
} else {
$allNodes[$nodeKey] = $xml;
}
}
foreach ($groups as $groupId => $groupLabel) {
$nodeKey = "/data/" . $root . "/" . ltrim($groupId, "/");
$meta = array("icon" => "users-folder.png", "icon_class" => "icon-folder-close", "ajxp_mime" => "group", "object_id" => $groupId);
if (in_array($nodeKey, $this->currentBookmarks)) {
$meta = array_merge($meta, array("ajxp_bookmarked" => "true", "overlay_icon" => "bookmark.png"));
}
$xml = AJXP_XMLWriter::renderNode($nodeKey, $groupLabel, false, $meta, true, false);
if (!$returnNodes) {
print $xml;
} else {
$allNodes[$nodeKey] = $xml;
}
}
$mess = ConfService::getMessages();
$loggedUser = AuthService::getLoggedUser();
$userArray = array();
$logger = AJXP_Logger::getInstance();
if (method_exists($logger, "usersLastConnection")) {
$allUserIds = array();
}
foreach ($users as $userObject) {
$label = $userObject->getId();
if (isset($allUserIds)) {
$allUserIds[] = $label;
}
if ($userObject->hasParent()) {
$label = $userObject->getParent() . "000" . $label;
} else {
$children = ConfService::getConfStorageImpl()->getUserChildren($label);
foreach ($children as $addChild) {
$userArray[$label . "000" . $addChild->getId()] = $addChild;
}
}
$userArray[$label] = $userObject;
}
if (isset($allUserIds) && count($allUserIds)) {
$connections = $logger->usersLastConnection($allUserIds);
}
ksort($userArray);
foreach ($userArray as $userObject) {
$repos = ConfService::getConfStorageImpl()->listRepositories($userObject);
$isAdmin = $userObject->isAdmin();
$userId = $userObject->getId();
$icon = "user" . ($userId == "guest" ? "_guest" : ($isAdmin ? "_admin" : ""));
$iconClass = "icon-user";
if ($userObject->hasParent()) {
$icon = "user_child";
$iconClass = "icon-angle-right";
}
if ($isAdmin) {
$rightsString = $mess["ajxp_conf.63"];
} else {
$r = array();
foreach ($repos as $repoId => $repository) {
if ($repository->getAccessType() == "ajxp_shared") {
continue;
}
if (!$userObject->canRead($repoId) && !$userObject->canWrite($repoId)) {
continue;
}
$rs = $userObject->canRead($repoId) ? "r" : "";
$rs .= $userObject->canWrite($repoId) ? "w" : "";
$r[] = $repository->getDisplay() . " (" . $rs . ")";
}
$rightsString = implode(", ", $r);
}
$nodeLabel = $userId;
$test = $userObject->personalRole->filterParameterValue("core.conf", "USER_DISPLAY_NAME", AJXP_REPO_SCOPE_ALL, "");
if (!empty($test)) {
$nodeLabel = $test;
}
$scheme = AuthService::getAuthScheme($userId);
$nodeKey = "/data/{$root}/" . $userId;
$roles = array_filter(array_keys($userObject->getRoles()), array($this, "filterReservedRoles"));
$meta = array("isAdmin" => $mess[$isAdmin ? "ajxp_conf.14" : "ajxp_conf.15"], "icon" => $icon . ".png", "icon_class" => $iconClass, "object_id" => $userId, "auth_scheme" => $scheme != null ? $scheme : "", "rights_summary" => $rightsString, "ajxp_roles" => implode(", ", $roles), "ajxp_mime" => "user" . ($userId != "guest" && $userId != $loggedUser->getId() ? "_editable" : ""), "json_merged_role" => json_encode($userObject->mergedRole->getDataArray(true)));
if ($userObject->hasParent()) {
$meta["shared_user"] = "true";
}
if (isset($connections) && isset($connections[$userObject->getId()]) && !empty($connections[$userObject->getId()])) {
$meta["last_connection"] = strtotime($connections[$userObject->getId()]);
$meta["last_connection_readable"] = AJXP_Utils::relativeDate($meta["last_connection"], $mess);
}
if (in_array($nodeKey, $this->currentBookmarks)) {
$meta = array_merge($meta, array("ajxp_bookmarked" => "true", "overlay_icon" => "bookmark.png"));
}
$xml = AJXP_XMLWriter::renderNode($nodeKey, $nodeLabel, true, $meta, true, false);
if (!$returnNodes) {
print $xml;
} else {
$allNodes[$nodeKey] = $xml;
}
}
return $allNodes;
}
示例10: 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);
}