本文整理汇总了PHP中SystemTextEncoding::fromStorageEncoding方法的典型用法代码示例。如果您正苦于以下问题:PHP SystemTextEncoding::fromStorageEncoding方法的具体用法?PHP SystemTextEncoding::fromStorageEncoding怎么用?PHP SystemTextEncoding::fromStorageEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemTextEncoding
的用法示例。
在下文中一共展示了SystemTextEncoding::fromStorageEncoding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createOrLoadSharedRepository
/**
* @param array $httpVars
* @param bool $update
* @return Repository
* @throws Exception
*/
protected function createOrLoadSharedRepository($httpVars, &$update)
{
if (!isset($httpVars["repo_label"]) || $httpVars["repo_label"] == "") {
$mess = ConfService::getMessages();
throw new Exception($mess["349"]);
}
if (isset($httpVars["repository_id"])) {
$editingRepo = ConfService::getRepositoryById($httpVars["repository_id"]);
$update = true;
}
// CHECK REPO DOES NOT ALREADY EXISTS WITH SAME LABEL
$label = AJXP_Utils::sanitize(AJXP_Utils::securePath($httpVars["repo_label"]), AJXP_SANITIZE_HTML);
$description = AJXP_Utils::sanitize(AJXP_Utils::securePath($httpVars["repo_description"]), AJXP_SANITIZE_HTML);
$exists = $this->checkRepoWithSameLabel($label, isset($editingRepo) ? $editingRepo : null);
if ($exists) {
$mess = ConfService::getMessages();
throw new Exception($mess["share_center.352"]);
}
$loggedUser = AuthService::getLoggedUser();
if (isset($editingRepo)) {
$this->getShareStore()->testUserCanEditShare($editingRepo->getOwner(), $editingRepo->options);
$newRepo = $editingRepo;
$replace = false;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
$replace = true;
}
if ($editingRepo->getDescription() != $description) {
$newRepo->setDescription($description);
$replace = true;
}
$newScope = isset($httpVars["share_scope"]) && $httpVars["share_scope"] == "public" ? "public" : "private";
$oldScope = $editingRepo->getOption("SHARE_ACCESS");
$currentOwner = $editingRepo->getOwner();
if ($newScope != $oldScope && $currentOwner != AuthService::getLoggedUser()->getId()) {
$mess = ConfService::getMessages();
throw new Exception($mess["share_center.224"]);
}
if ($newScope !== $oldScope) {
$editingRepo->addOption("SHARE_ACCESS", $newScope);
$replace = true;
}
if (isset($httpVars["transfer_owner"])) {
$newOwner = $httpVars["transfer_owner"];
if ($newOwner != $currentOwner && $currentOwner != AuthService::getLoggedUser()->getId()) {
$mess = ConfService::getMessages();
throw new Exception($mess["share_center.224"]);
}
$editingRepo->setOwnerData($editingRepo->getParentId(), $newOwner, $editingRepo->getUniqueUser());
$replace = true;
}
if ($replace) {
ConfService::replaceRepository($newRepo->getId(), $newRepo);
}
} else {
$options = $this->accessDriver->makeSharedRepositoryOptions($httpVars, $this->repository);
// TMP TESTS
$options["SHARE_ACCESS"] = $httpVars["share_scope"];
$newRepo = $this->repository->createSharedChild($label, $options, $this->repository->getId(), $loggedUser->getId(), null);
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription($description);
// Smells like dirty hack!
$newRepo->options["PATH"] = SystemTextEncoding::fromStorageEncoding($newRepo->options["PATH"]);
if (isset($httpVars["filter_nodes"])) {
$newRepo->setContentFilter(new ContentFilter($httpVars["filter_nodes"]));
}
ConfService::addRepository($newRepo);
}
return $newRepo;
}
示例2: migrateLegacyMeta
/**
* @param ShareCenter $shareCenter
* @param ShareStore $shareStore
* @param ShareRightsManager $shareRightManager
*/
public static function migrateLegacyMeta($shareCenter, $shareStore, $shareRightManager, $dryRun = true)
{
$metaStoreDir = AJXP_DATA_PATH . "/plugins/metastore.serial";
$publicFolder = ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER");
$metastores = glob($metaStoreDir . "/ajxp_meta_0");
if ($dryRun) {
print "RUNNING A DRY RUN FOR META MIGRATION";
}
foreach ($metastores as $store) {
if (strpos($store, ".bak") !== false) {
continue;
}
// Backup store
if (!$dryRun) {
copy($store, $store . ".bak");
}
$data = unserialize(file_get_contents($store));
foreach ($data as $filePath => &$metadata) {
foreach ($metadata as $userName => &$meta) {
if (!AuthService::userExists($userName)) {
continue;
}
$userObject = ConfService::getConfStorageImpl()->createUserObject($userName);
if (isset($meta["ajxp_shared"]) && isset($meta["ajxp_shared"]["element"])) {
print "\n\nItem {$filePath} requires upgrade :";
$share = $meta["ajxp_shared"];
$element = $meta["ajxp_shared"]["element"];
if (is_array($element)) {
$element = array_shift(array_keys($element));
}
// Take the first one only
$legacyLinkFile = $publicFolder . "/" . $element . ".php";
if (file_exists($legacyLinkFile)) {
// Load file, move it to DB and move the meta
$publiclet = $shareStore->loadShare($element);
rename($legacyLinkFile, $legacyLinkFile . ".migrated");
if (isset($share["minisite"])) {
print "\n--Migrate legacy minisite to new minisite?";
try {
$sharedRepoId = $publiclet["REPOSITORY"];
$sharedRepo = ConfService::getRepositoryById($sharedRepoId);
if ($sharedRepo == null) {
print "\n--ERROR: Cannot find repository with id " . $sharedRepoId;
continue;
}
$shareLink = new ShareLink($shareStore, $publiclet);
$user = $shareLink->getUniqueUser();
if (AuthService::userExists($user)) {
$userObject = ConfService::getConfStorageImpl()->createUserObject($user);
$userObject->setHidden(true);
print "\n--Should set existing user {$user} as hidden";
if (!$dryRun) {
$userObject->save();
}
}
$shareLink->parseHttpVars(["custom_handle" => $element]);
$shareLink->setParentRepositoryId($sharedRepo->getParentId());
print "\n--Creating the following share object";
print_r($shareLink->getJsonData($shareCenter->getPublicAccessManager(), ConfService::getMessages()));
if (!$dryRun) {
$shareLink->save();
}
$meta["ajxp_shared"] = ["shares" => [$element => ["type" => "minisite"], $sharedRepoId => ["type" => "repository"]]];
} catch (Exception $e) {
print "\n-- Error " . $e->getMessage();
}
} else {
print "\n--Should migrate legacy link to new minisite with ContentFilter";
try {
$link = new ShareLink($shareStore);
$link->setOwnerId($userName);
$parameters = array("custom_handle" => $element, "simple_right_download" => true);
if (isset($publiclet["EXPIRE_TIME"])) {
$parameters["expiration"] = $publiclet["EXPIRE_TIME"];
}
if (isset($publiclet["DOWNLOAD_LIMIT"])) {
$parameters["downloadlimit"] = $publiclet["DOWNLOAD_LIMIT"];
}
$link->parseHttpVars($parameters);
$parentRepositoryObject = $publiclet["REPOSITORY"];
$driverInstance = AJXP_PluginsService::findPlugin("access", $parentRepositoryObject->getAccessType());
if (empty($driverInstance)) {
print "\n-- ERROR: Cannot find driver instance!";
continue;
}
$options = $driverInstance->makeSharedRepositoryOptions(["file" => "/"], $parentRepositoryObject);
$options["SHARE_ACCESS"] = "private";
$newRepo = $parentRepositoryObject->createSharedChild(basename($filePath), $options, $parentRepositoryObject->getId(), $userObject->getId(), null);
$gPath = $userObject->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription("");
// Smells like dirty hack!
$newRepo->options["PATH"] = SystemTextEncoding::fromStorageEncoding($newRepo->options["PATH"]);
//.........这里部分代码省略.........
示例3: createSharedRepository
//.........这里部分代码省略.........
}
if (isset($editingRepo)) {
$newRepo = $editingRepo;
$replace = false;
if ($editingRepo->getDisplay() != $label) {
$newRepo->setDisplay($label);
$replace = true;
}
if ($editingRepo->getDescription() != $description) {
$newRepo->setDescription($description);
$replace = true;
}
if ($replace) {
ConfService::replaceRepository($httpVars["repository_id"], $newRepo);
}
} else {
if ($repository->getOption("META_SOURCES")) {
$options["META_SOURCES"] = $repository->getOption("META_SOURCES");
foreach ($options["META_SOURCES"] as $index => &$data) {
if (isset($data["USE_SESSION_CREDENTIALS"]) && $data["USE_SESSION_CREDENTIALS"] === true) {
$options["META_SOURCES"][$index]["ENCODED_CREDENTIALS"] = AJXP_Safe::getEncodedCredentialString();
}
if ($index == "meta.syncable" && (!isset($data["REPO_SYNCABLE"]) || $data["REPO_SYNCABLE"] === true)) {
$data["REQUIRES_INDEXATION"] = true;
}
}
}
$newRepo = $repository->createSharedChild($label, $options, $repository->id, $loggedUser->id, null);
$gPath = $loggedUser->getGroupPath();
if (!empty($gPath) && !ConfService::getCoreConf("CROSSUSERS_ALLGROUPS", "conf")) {
$newRepo->setGroupPath($gPath);
}
$newRepo->setDescription($description);
$newRepo->options["PATH"] = SystemTextEncoding::fromStorageEncoding($newRepo->options["PATH"]);
if (isset($httpVars["filter_nodes"])) {
$newRepo->setContentFilter(new ContentFilter($httpVars["filter_nodes"]));
}
ConfService::addRepository($newRepo);
if (!isset($httpVars["minisite"])) {
$this->getShareStore()->storeShare($repository->getId(), array("REPOSITORY" => $newRepo->getUniqueId(), "OWNER_ID" => $loggedUser->getId()), "repository");
}
}
$file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
if (isset($editingRepo)) {
$currentRights = $this->computeSharedRepositoryAccessRights($httpVars["repository_id"], false, $this->urlBase . $file);
$originalUsers = array_keys($currentRights["USERS"]);
$removeUsers = array_diff($originalUsers, $users);
if (count($removeUsers)) {
foreach ($removeUsers as $user) {
if (AuthService::userExists($user)) {
$userObject = $confDriver->createUserObject($user);
$userObject->personalRole->setAcl($newRepo->getUniqueId(), "");
$userObject->save("superuser");
}
$this->watcher->removeWatchFromFolder(new AJXP_Node($this->urlBase . $file), $user, true);
}
}
$originalGroups = array_keys($currentRights["GROUPS"]);
$removeGroups = array_diff($originalGroups, $groups);
if (count($removeGroups)) {
foreach ($removeGroups as $groupId) {
$role = AuthService::getRole($groupId);
if ($role !== false) {
$role->setAcl($newRepo->getUniqueId(), "");
AuthService::updateRole($role);
}