本文整理汇总了PHP中AJXP_Utils::mimetype方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Utils::mimetype方法的具体用法?PHP AJXP_Utils::mimetype怎么用?PHP AJXP_Utils::mimetype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AJXP_Utils
的用法示例。
在下文中一共展示了AJXP_Utils::mimetype方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyActions
public function applyActions($actionName, $httpVars, $fileVars)
{
$git = new VersionControl_Git($this->repoBase);
switch ($actionName) {
case "git_history":
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
$file = ltrim($file, "/");
$res = $this->gitHistory($git, $file);
AJXP_XMLWriter::header();
$ic = AJXP_Utils::mimetype($file, "image", false);
$index = count($res);
$mess = ConfService::getMessages();
foreach ($res as &$commit) {
unset($commit["DETAILS"]);
$commit["icon"] = $ic;
$commit["index"] = $index;
$commit["EVENT"] = $mess["meta.git." . $commit["EVENT"]];
$index--;
AJXP_XMLWriter::renderNode("/" . $commit["ID"], basename($commit["FILE"]), true, $commit);
}
AJXP_XMLWriter::close();
break;
break;
case "git_revertfile":
$originalFile = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
$commitId = $httpVars["commit_id"];
$command = $git->getCommand("cat-file");
$command->setOption("s", true);
$command->addArgument($commitId . ":" . $file);
$size = $command->execute();
$command = $git->getCommand("show");
$command->addArgument($commitId . ":" . $file);
$commandLine = $command->createCommandString();
$outputStream = fopen($this->repoBase . $originalFile, "w");
$this->executeCommandInStreams($git, $commandLine, $outputStream);
fclose($outputStream);
$this->commitChanges();
AJXP_XMLWriter::header();
AJXP_XMLWriter::reloadDataNode();
AJXP_XMLWriter::close();
break;
case "git_getfile":
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
$commitId = $httpVars["commit_id"];
$attach = $httpVars["attach"];
$command = $git->getCommand("cat-file");
$command->setOption("s", true);
$command->addArgument($commitId . ":" . $file);
$size = $command->execute();
$command = $git->getCommand("show");
$command->addArgument($commitId . ":" . $file);
$commandLine = $command->createCommandString();
if ($attach == "inline") {
$fileExt = substr(strrchr(basename($file), '.'), 1);
if (empty($fileExt)) {
$fileMime = "application/octet-stream";
} else {
$regex = "/^([\\w\\+\\-\\.\\/]+)\\s+(\\w+\\s)*({$fileExt}\\s)/i";
$lines = file(AJXP_INSTALL_PATH . "/" . AJXP_PLUGINS_FOLDER . "/editor.browser/resources/other/mime.types");
foreach ($lines as $line) {
if (substr($line, 0, 1) == '#') {
continue;
}
// skip comments
$line = rtrim($line) . " ";
if (!preg_match($regex, $line, $matches)) {
continue;
}
// no match to the extension
$fileMime = $matches[1];
}
}
if (empty($fileMime)) {
$fileMime = "application/octet-stream";
}
HTMLWriter::generateInlineHeaders(basename($file), $size, $fileMime);
} else {
HTMLWriter::generateAttachmentsHeader(basename($file), $size, false, false);
}
$outputStream = fopen("php://output", "a");
$this->executeCommandInStreams($git, $commandLine, $outputStream);
fclose($outputStream);
break;
break;
default:
break;
}
}
示例2: enrichMetadata
/**
*
* @param AJXP_Node $ajxpNode
*/
public function enrichMetadata(&$ajxpNode)
{
$currentNode = $ajxpNode->getUrl();
$metadata = $ajxpNode->metadata;
$parsed = parse_url($currentNode);
if (isset($parsed["fragment"]) && strpos($parsed["fragment"], "attachments") === 0) {
list(, $attachmentId) = explode("/", $parsed["fragment"]);
$meta = imapAccessWrapper::getCurrentAttachmentsMetadata();
if ($meta != null) {
foreach ($meta as $attach) {
if ($attach["x-attachment-id"] == $attachmentId) {
$metadata["text"] = $attach["filename"];
$metadata["icon"] = AJXP_Utils::mimetype($attach["filename"], "image", false);
$metadata["mimestring"] = AJXP_Utils::mimetype($attach["filename"], "text", false);
}
}
}
}
if (!$metadata["is_file"] && $currentNode != "") {
$metadata["icon"] = "imap_images/ICON_SIZE/mail_folder_sent.png";
}
if (basename($currentNode) == "INBOX") {
$metadata["text"] = "Incoming Mails";
}
if (strstr($currentNode, "__delim__") !== false) {
$parts = explode("/", $currentNode);
$metadata["text"] = str_replace("__delim__", "/", array_pop($parts));
}
$ajxpNode->metadata = $metadata;
}
示例3: listingEndElement
function listingEndElement($parser, $tag)
{
if ($tag == "ENTRY") {
if ($this->crtListingMode == "file_list" || $this->crtListingMode == "search") {
if (!$this->crtElement["is_file"]) {
$this->crtElement["filesize"] = "-";
}
$this->crtElement["mimestring"] = AJXP_Utils::mimetype($this->crtElement["filename"], "text", !$this->crtElement["is_file"]);
$this->crtElement["icon"] = AJXP_Utils::mimetype($this->crtElement["filename"], "image", !$this->crtElement["is_file"]);
$this->crtElement["is_file"] = $this->crtElement["is_file"] ? "1" : "0";
$this->listElements[] = $this->crtElement;
} else {
if (!$this->crtElement["is_file"]) {
$this->crtElement["icon"] = CLIENT_RESOURCES_FOLDER . "/images/foldericon.png";
$this->crtElement["openicon"] = CLIENT_RESOURCES_FOLDER . "/images/openfoldericon.png";
$this->crtElement["src"] = SERVER_ACCESS . "?dir=" . $this->crtPath . "/" . $this->crtElement["text"];
$this->crtElement["parentname"] = $this->crtPath == "/" ? "" : $this->crtPath;
$this->crtElement["action"] = "javascript:ajaxplorer.getFoldersTree().clickNode(CURRENT_ID)";
$this->crtElement["is_file"] = $this->crtElement["is_file"] ? "1" : "0";
$this->listElements[] = $this->crtElement;
}
}
} else {
if ($tag == "NAME") {
$this->crtElement["filename"] = $this->cdataBuffer;
$this->crtElement["text"] = basename($this->cdataBuffer);
} else {
if ($tag == "AUTHOR" && $this->crtListingMode == "file_list") {
$this->crtElement["author"] = $this->cdataBuffer;
} else {
if ($tag == "SIZE" && $this->crtListingMode == "file_list") {
$this->crtElement["filesize"] = AJXP_Utils::roundSize(intval($this->cdataBuffer));
} else {
if ($tag == "DATE" && $this->crtListingMode == "file_list") {
$date = $this->cdataBuffer;
$split = explode("T", $date);
$realDate = $split[0];
$split = explode("\\.", $split[1]);
$realTime = $split[0];
$this->crtElement["modiftime"] = date("d/m/Y H:i", strtotime($realDate . " " . $realTime));
}
}
}
}
}
}
示例4: switchAction
//.........这里部分代码省略.........
}
}
}
// skip "complete" mode that was in fact quite the same as standard tree listing (dz)
}
if (!isset($dir) || $dir == "/") {
$dir = "";
}
$searchMode = $fileListMode = $completeMode = false;
if (isset($mode)) {
if ($mode == "search") {
$searchMode = true;
} else {
if ($mode == "file_list") {
$fileListMode = true;
} else {
if ($mode == "complete") {
$completeMode = true;
}
}
}
}
$nom_rep = $dir;
//AJXP_Exception::errorToXml($nom_rep);
$result = $this->SSHOperation->listFilesIn($nom_rep);
$metaData = array();
if (RecycleBinManager::recycleEnabled() && RecycleBinManager::currentLocationIsRecycle($dir)) {
$metaData["ajxp_mime"] = "ajxp_recycle";
}
AJXP_XMLWriter::renderHeaderNode(AJXP_Utils::xmlEntities($dir, true), AJXP_Utils::xmlEntities(basename($dir), true), false, $metaData);
foreach ($result as $file) {
$attributes = "";
$fileName = SystemTextEncoding::toUTF8($file["name"]);
$icon = AJXP_Utils::mimetype($fileName, "image", $file["isDir"] == 1);
if ($searchMode) {
if ($file["isDir"] == 0) {
$attributes = "is_file=\"true\" icon=\"" . SystemTextEncoding::toUTF8($icon) . "\"";
}
} else {
if ($fileListMode) {
$atts = array();
$atts[] = "is_file=\"" . (1 - $file["isDir"]) . "\"";
$atts[] = "is_image=\"" . AJXP_Utils::is_image($fileName) . "\"";
$atts[] = "mimestring=\"" . AJXP_Utils::mimetype($fileName, "type", $file["isDir"] == 1) . "\"";
$atts[] = "ajxp_modiftime=\"" . $this->dateModif($file["time"]) . "\"";
$atts[] = "filesize=\"" . AJXP_Utils::roundSize($file["size"]) . "\"";
$atts[] = "bytesize=\"" . $file["size"] . "\"";
$atts[] = "filename=\"" . str_replace("&", "&", $dir . "/" . $fileName) . "\"";
$atts[] = "icon=\"" . ($file["isDir"] == 1 ? "folder.png" : SystemTextEncoding::toUTF8($icon)) . "\"";
$attributes = join(" ", $atts);
} else {
if ($file["isDir"] == 1) {
$link = SERVER_ACCESS . "?dir=" . $dir . "/" . $fileName;
$link = urlencode($link);
$folderBaseName = str_replace("&", "&", $fileName);
$folderFullName = "{$dir}/" . $folderBaseName;
$parentFolderName = $dir;
if (!$completeMode) {
$icon = "folder.png";
$openicon = "folder_open.png";
if (preg_match("/\\.zip\$/", $file["name"])) {
$icon = $openicon = CLIENT_RESOURCES_FOLDER . "/images/actions/16/accessories-archiver.png";
}
$attributes = "icon=\"{$icon}\" openicon=\"{$openicon}\" filename=\"" . $folderFullName . "\" src=\"{$link}\"";
}
}
示例5: switchAction
//.........这里部分代码省略.........
continue;
}
$isLeaf = is_file($path . "/" . $nodeName) || AJXP_Utils::isBrowsableArchive($nodeName);
if (!$this->filterNodeName($path, $nodeName, $isLeaf, $lsOptions)) {
continue;
}
if (RecycleBinManager::recycleEnabled() && $dir == "" && "/" . $nodeName == RecycleBinManager::getRecyclePath()) {
continue;
}
$nodeType = "d";
if ($isLeaf) {
if (AJXP_Utils::isBrowsableArchive($nodeName)) {
if ($lsOptions["f"] && $lsOptions["z"]) {
// See archives as files
$nodeType = "f";
} else {
$nodeType = "z";
}
} else {
$nodeType = "f";
}
}
if ($offset > 0 && $cursor < $offset) {
$cursor++;
continue;
}
if ($limitPerPage > 0 && $cursor - $offset >= $limitPerPage) {
break;
}
$metaData = array();
$currentFile = $path . "/" . $nodeName;
$metaData["is_file"] = $isLeaf ? "1" : "0";
$metaData["filename"] = AJXP_Utils::xmlEntities(SystemTextEncoding::toUTF8($dir . "/" . $nodeName));
$metaData["icon"] = AJXP_Utils::mimetype($nodeName, "image", !$isLeaf);
if ($metaData["icon"] == "folder.png") {
$metaData["openicon"] = "folder_open.png";
}
if (!is_file($currentFile) || AJXP_Utils::isBrowsableArchive($nodeName)) {
$link = SystemTextEncoding::toUTF8(SERVER_ACCESS . "?get_action=ls&options=dz&dir=" . $dir . "/" . $nodeName);
$link = urlencode($link);
$metaData["src"] = $link;
}
if ($lsOptions["l"]) {
$metaData["file_group"] = @filegroup($currentFile) || "unknown";
$metaData["file_owner"] = @fileowner($currentFile) || "unknown";
$fPerms = @fileperms($currentFile);
if ($fPerms !== false) {
$fPerms = substr(decoct($fPerms), $isLeaf ? 2 : 1);
} else {
$fPerms = '0000';
}
$metaData["file_perms"] = $fPerms;
$metaData["mimestring"] = AJXP_Utils::mimetype($currentFile, "type", !$isLeaf);
$datemodif = $this->date_modif($currentFile);
$metaData["ajxp_modiftime"] = $datemodif ? $datemodif : "0";
$metaData["bytesize"] = 0;
if ($isLeaf) {
$metaData["bytesize"] = filesize($currentFile);
}
$metaData["filesize"] = AJXP_Utils::roundSize($metaData["bytesize"]);
if (AJXP_Utils::isBrowsableArchive($nodeName)) {
$metaData["ajxp_mime"] = "ajxp_browsable_archive";
}
$realFile = null;
// A reference to the real file.
AJXP_Controller::applyHook("ls.metadata", array($currentFile, &$metaData, $this->wrapperClassName, &$realFile));