当前位置: 首页>>代码示例>>PHP>>正文


PHP MOXMAN::getPluginManager方法代码示例

本文整理汇总了PHP中MOXMAN::getPluginManager方法的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN::getPluginManager方法的具体用法?PHP MOXMAN::getPluginManager怎么用?PHP MOXMAN::getPluginManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MOXMAN的用法示例。


在下文中一共展示了MOXMAN::getPluginManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: api

 /**
  * Wrap Moxiemanager's api.php in a controller action.
  *
  * @return void
  */
 public function api()
 {
     try {
         $pluginPath = Plugin::path('CkTools');
         define('MOXMAN_CLASSES', $pluginPath . 'src/Lib/moxiemanager/classes');
         define('MOXMAN_PLUGINS', $pluginPath . 'src/Lib/moxiemanager/plugins');
         define('MOXMAN_ROOT', $pluginPath . 'src/Lib/moxiemanager');
         define('MOXMAN_API_FILE', __FILE__);
         $appConfig = Configure::read('CkTools.moxiemanager');
         Configure::load('CkTools.moxiemanager');
         $moxieManagerConfig = Configure::read('moxiemanager');
         if (is_array($appConfig)) {
             $moxieManagerConfig = Hash::merge($moxieManagerConfig, $appConfig);
         }
         $GLOBALS['moxieManagerConfig'] = $moxieManagerConfig;
         require_once MOXMAN_CLASSES . '/MOXMAN.php';
         $context = \MOXMAN_Http_Context::getCurrent();
         $pluginManager = \MOXMAN::getPluginManager();
         foreach ($pluginManager->getAll() as $plugin) {
             if ($plugin instanceof \MOXMAN_Http_IHandler) {
                 $plugin->processRequest($context);
             }
         }
     } catch (Exception $e) {
         \MOXMAN_Exception::printException($e);
     }
     return $this->render(false, false);
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:33,代码来源:MoxiemanagerController.php

示例2: execute

 /**
  * Executes the command logic with the specified RPC parameters.
  *
  * @param Object $params Command parameters sent from client.
  * @return Object Result object to be passed back to client.
  */
 public function execute($params)
 {
     $file = MOXMAN::getFile($params->path);
     $config = $file->getConfig();
     if ($config->get('general.demo')) {
         throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
     }
     if (!$file->canWrite()) {
         throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
     }
     if ($file->exists()) {
         throw new MOXMAN_Exception("File already exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
     }
     $filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "createdir");
     if ($filter->accept($file, false) !== MOXMAN_Vfs_CombinedFileFilter::ACCEPTED) {
         throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
     }
     // Fire event before folder created.
     $args = new MOXMAN_Core_FileActionEventArgs("add", $file);
     MOXMAN::getPluginManager()->get("core")->fire("BeforeFileAction", $args);
     $file = $args->getFile();
     if (isset($params->template)) {
         // TODO: Security audit this
         $templateFile = MOXMAN::getFile($params->template);
         if (!$templateFile->exists()) {
             throw new MOXMAN_Exception("Template file doesn't exists: " . $file->getPublicPath(), MOXMAN_Exception::FILE_DOESNT_EXIST);
         }
         $templateFile->copyTo($file);
     } else {
         $file->mkdir();
     }
     $this->fireFileAction(MOXMAN_Core_FileActionEventArgs::ADD, $file);
     return $this->fileToJson($file);
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:40,代码来源:CreateDirectoryCommand.php

示例3: processRequest

 /**
  * Process a request using the specified context.
  *
  * @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
  */
 public function processRequest(MOXMAN_Http_Context $httpContext)
 {
     $request = $httpContext->getRequest();
     $response = $httpContext->getResponse();
     try {
         $config = MOXMAN::getConfig();
         $allItems = $config->getAll();
         $licenseKey = trim($config->get("general.license"));
         $installed = !empty($allItems);
         $response->disableCache();
         $response->setHeader('Content-type', 'application/json');
         if ($installed && !$config->get('filesystem.rootpath')) {
             throw new MOXMAN_Exception("You must configure filesystem.rootpath.");
         }
         if ($request->getMethod() != 'POST') {
             throw new MOXMAN_Exception("Not a HTTP post request.");
         }
         if ($installed && !preg_match('/^([0-9A-Z]{4}\\-){7}[0-9A-Z]{4}$/', $licenseKey)) {
             throw new MOXMAN_Exception("Invalid license key specified in config.");
         }
         $authInfo = (object) array("token" => MOXMAN_Http_Csrf::createToken(MOXMAN::getConfig()->get('general.license')), "installed" => $installed, "loggedin" => MOXMAN::getAuthManager()->isAuthenticated(), "loginurl" => $config->get("authenticator.login_page", ""), "standalone" => MOXMAN::getAuthManager()->hasStandalone(), "overwrite_action" => $config->get("filesystem.overwrite_action", ""));
         $args = new MOXMAN_Auth_AuthInfoEventArgs();
         MOXMAN::getPluginManager()->get("core")->fire("AuthInfo", $args);
         foreach ($args->getInfo() as $key => $value) {
             $authInfo->{$key} = $value;
         }
         $response->sendJson($authInfo);
     } catch (Exception $e) {
         $response->sendJson((object) array("error" => array("code" => $e->getCode(), "message" => $e->getMessage())));
     }
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:36,代码来源:AuthHandler.php

示例4: execute

 /**
  * Executes the command logic with the specified RPC parameters.
  *
  * @param Object $params Command parameters sent from client.
  * @return Object Result object to be passed back to client.
  */
 public function execute($params)
 {
     $file = MOXMAN::getFile($params->path);
     $config = $file->getConfig();
     $resolution = $params->resolution;
     if ($config->get('general.demo')) {
         throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
     }
     $content = $this->getUrlContent($params->url, $config);
     // Fire before file action add event
     $args = $this->fireBeforeFileAction("add", $file, strlen($content));
     $file = $args->getFile();
     if (!$file->canWrite()) {
         throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
     }
     $filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "upload");
     if (!$filter->accept($file, true)) {
         throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
     }
     if ($resolution == "rename") {
         $file = MOXMAN_Util_FileUtils::uniqueFile($file);
     } else {
         if ($resolution == "overwrite") {
             MOXMAN::getPluginManager()->get("core")->deleteFile($file);
         } else {
             throw new MOXMAN_Exception("To file already exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
         }
     }
     $stream = $file->open(MOXMAN_Vfs_IFileStream::WRITE);
     $stream->write($content);
     $stream->close();
     $args = new MOXMAN_Vfs_FileActionEventArgs("add", $file);
     MOXMAN::getPluginManager()->get("core")->fire("FileAction", $args);
     return parent::fileToJson($file, true);
 }
开发者ID:robbie778,项目名称:dolphin.pro,代码行数:41,代码来源:ImportFromUrlCommand.php

示例5: execute

 /**
  * Executes the command logic with the specified RPC parameters.
  *
  * @param Object $params Command parameters sent from client.
  * @return Object Result object to be passed back to client.
  */
 public function execute($params)
 {
     $file = MOXMAN::getFile($params->path);
     $url = parse_url($params->url);
     $config = $file->getConfig();
     if ($config->get('general.demo')) {
         throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
     }
     if ($file->exists()) {
         throw new MOXMAN_Exception("To file already exist: " . $file->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
     }
     if (!$file->canWrite()) {
         throw new MOXMAN_Exception("No write access to file: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
     }
     $filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "upload");
     if (!$filter->accept($file, true)) {
         throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
     }
     $port = "";
     if (isset($url["port"])) {
         $port = ":" . $url["port"];
     }
     $query = "";
     if (isset($url["query"])) {
         $query = "?" . $url["query"];
     }
     $path = $url["path"] . $query;
     $host = $url["scheme"] . "://" . $url["host"] . $port;
     $httpClient = new MOXMAN_Http_HttpClient($host);
     $request = $httpClient->createRequest($path);
     $response = $request->send();
     // Handle redirects
     $location = $response->getHeader("location");
     if ($location) {
         $httpClient->close();
         $httpClient = new MOXMAN_Http_HttpClient($location);
         $request = $httpClient->createRequest($location);
         $response = $request->send();
     }
     // Read file into ram
     // TODO: This should not happen if we know the file size
     $content = "";
     while (($chunk = $response->read()) != "") {
         $content .= $chunk;
     }
     $httpClient->close();
     // Fire before file action add event
     $args = $this->fireBeforeFileAction("add", $file, strlen($content));
     $file = $args->getFile();
     $stream = $file->open(MOXMAN_Vfs_IFileStream::WRITE);
     $stream->write($content);
     $stream->close();
     $args = new MOXMAN_Vfs_FileActionEventArgs("add", $file);
     MOXMAN::getPluginManager()->get("core")->fire("FileAction", $args);
     return parent::fileToJson($file, true);
 }
开发者ID:newton27,项目名称:dolphin.pro,代码行数:62,代码来源:ImportFromUrlCommand.php

示例6: moveFile

 /** @ignore */
 private function moveFile($fromFile, $toFile, $resolution)
 {
     $config = $toFile->getConfig();
     if ($config->get('general.demo')) {
         throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
     }
     if (!$fromFile->exists()) {
         throw new MOXMAN_Exception("From file doesn't exist: " . $fromFile->getPublicPath(), MOXMAN_Exception::FILE_DOESNT_EXIST);
     }
     $fromFileParentFile = $fromFile->getParentFile();
     if (!$fromFileParentFile || !$fromFileParentFile->canWrite()) {
         throw new MOXMAN_Exception("No write access to file: " . $fromFile->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
     }
     if (!$toFile->canWrite()) {
         throw new MOXMAN_Exception("No write access to file: " . $toFile->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
     }
     $filter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($config);
     if (!$filter->accept($fromFile, $fromFile->isFile())) {
         throw new MOXMAN_Exception("Invalid file name for: " . $fromFile->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
     }
     $filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "rename");
     if (!$filter->accept($toFile, $fromFile->isFile())) {
         throw new MOXMAN_Exception("Invalid file name for: " . $toFile->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
     }
     // Fire before file action event
     $args = $this->fireBeforeTargetFileAction(MOXMAN_Vfs_FileActionEventArgs::MOVE, $fromFile, $toFile);
     $fromFile = $args->getFile();
     $toFile = $args->getTargetFile();
     // Handle overwrite state
     if ($toFile->exists()) {
         if ($resolution == "rename") {
             $toFile = MOXMAN_Util_FileUtils::uniqueFile($args->getTargetFile());
         } else {
             if ($resolution == "overwrite") {
                 MOXMAN::getPluginManager()->get("core")->deleteFile($toFile);
                 $this->fireFileAction(MOXMAN_Vfs_FileActionEventArgs::DELETE, $toFile);
             } else {
                 throw new MOXMAN_Exception("To file already exist: " . $toFile->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
             }
         }
     }
     $fromFile->moveTo($toFile);
     $this->fireTargetFileAction(MOXMAN_Vfs_FileActionEventArgs::MOVE, $fromFile, $toFile);
     return $toFile;
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:46,代码来源:MoveToCommand.php

示例7: copyFile

 /** @ignore */
 private function copyFile($fromFile, $toFile)
 {
     $config = $toFile->getConfig();
     if ($config->get('general.demo')) {
         throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
     }
     if (!$fromFile->exists()) {
         throw new MOXMAN_Exception("From file doesn't exist: " . $fromFile->getPublicPath(), MOXMAN_Exception::FILE_DOESNT_EXIST);
     }
     if (!$toFile->canWrite()) {
         throw new MOXMAN_Exception("No write access to file: " . $toFile->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
     }
     $filter = MOXMAN_Vfs_BasicFileFilter::createFromConfig($config);
     if ($filter->accept($fromFile, $fromFile->isFile()) !== MOXMAN_Vfs_BasicFileFilter::ACCEPTED) {
         throw new MOXMAN_Exception("Invalid file name for: " . $fromFile->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
     }
     // Fire before file action event
     $args = new MOXMAN_Core_FileActionEventArgs(MOXMAN_Core_FileActionEventArgs::COPY, $fromFile);
     $args->setTargetFile($toFile);
     $args->getData()->fileSize = $fromFile->getSize();
     MOXMAN::getPluginManager()->get("core")->fire("BeforeFileAction", $args);
     $fromFile = $args->getFile();
     $toFile = $args->getTargetFile();
     // To file exists generate unique name
     $fileName = $toFile->getName();
     $ext = MOXMAN_Util_PathUtils::getExtension($fileName);
     for ($i = 2; $toFile->exists(); $i++) {
         if ($toFile->isFile() && $ext) {
             $toFile = MOXMAN::getFile($toFile->getParent(), basename($fileName, '.' . $ext) . '_' . $i . '.' . $ext);
         } else {
             $toFile = MOXMAN::getFile($toFile->getParent(), $fileName . '_' . $i);
         }
     }
     $fromFile->copyTo($toFile);
     $this->fireTargetFileAction(MOXMAN_Core_FileActionEventArgs::COPY, $fromFile, $toFile);
     return $toFile;
 }
开发者ID:tremor-od,项目名称:pizza.loc,代码行数:38,代码来源:CopyToCommand.php

示例8: init

<?php

/**
 * Plugin.php
 *
 * Copyright 2003-2013, Moxiecode Systems AB, All rights reserved.
 */
/**
 * ...
 */
class MOXMAN_Dropbox_Plugin implements MOXMAN_IPlugin, MOXMAN_ICommandHandler
{
    public function init()
    {
    }
    /**
     * Gets executed when a RPC call is made.
     *
     * @param string $name Name of RPC command to execute.
     * @param Object $params Object passed in from RPC handler.
     * @return Object Return object that gets passed back to client.
     */
    public function execute($name, $params)
    {
        if ($name === "dropbox.getClientId") {
            return MOXMAN::getConfig()->get("dropbox.app_id");
        }
    }
}
MOXMAN::getPluginManager()->add("dropbox", new MOXMAN_Dropbox_Plugin());
开发者ID:buildshop,项目名称:bs-common,代码行数:30,代码来源:Plugin.php

示例9: explode

$plugins = explode(',', MOXMAN::getConfig()->get("general.plugins"));
foreach ($plugins as $plugin) {
    if ($plugin) {
        $pluginPath = MOXMAN_ROOT . '/plugins/' . $plugin;
        MOXMAN_AutoLoader::addPrefixPath("MOXMAN_" . $plugin, $pluginPath);
        $plugin = $pluginPath . "/Plugin.php";
        if (file_exists($plugin)) {
            require_once $plugin;
        }
    }
}
// Load core plugin last
require_once MOXMAN_CLASSES . '/Core/Plugin.php';
// Trigger authenticate on all plugins so it can override any config options
try {
    MOXMAN::getAuthManager()->isAuthenticated();
} catch (Exception $e) {
    // Handle exceptions in authenticators
    $httpContext = MOXMAN_Http_Context::getCurrent();
    $request = $httpContext->getRequest();
    $response = $httpContext->getResponse();
    if ($request->get("json")) {
        $response->sendJson((object) array("jsonrpc" => "2.0", "error" => array("code" => '200', "message" => $e->getMessage()), "id" => "r0"));
    } else {
        die($e->getMessage());
    }
    die;
}
// Initialize all plugins
MOXMAN::getPluginManager()->initAll();
开发者ID:GHarutyunyan,项目名称:cms,代码行数:30,代码来源:MOXMAN.php

示例10: processRequest

 /**
  * Process a request using the specified context.
  *
  * @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
  */
 public function processRequest(MOXMAN_Http_Context $httpContext)
 {
     $request = $httpContext->getRequest();
     $response = $httpContext->getResponse();
     $response->disableCache();
     $response->setHeader('Content-type', 'application/json');
     @set_time_limit(5 * 60);
     // 5 minutes execution time
     $id = null;
     try {
         $json = MOXMAN_Util_Json::decode($request->get("json"));
         // Check if we should install
         if ($json && $json->method != "install") {
             $config = MOXMAN::getConfig()->getAll();
             if (empty($config) || !isset($config["general.license"])) {
                 $exception = new MOXMAN_Exception("Installation needed.", MOXMAN_Exception::NEEDS_INSTALLATION);
                 throw $exception;
             }
             if (!preg_match('/^([0-9A-Z]{4}\\-){7}[0-9A-Z]{4}$/', trim($config["general.license"]))) {
                 throw new MOXMAN_Exception("Invalid license: " . $config["general.license"]);
             }
         }
         // Check if the user is authenticated or not
         if (!MOXMAN::getAuthManager()->isAuthenticated()) {
             if (!isset($json->method) || !preg_match('/^(login|logout|install)$/', $json->method)) {
                 $exception = new MOXMAN_Exception("Access denied by authenticator(s).", MOXMAN_Exception::NO_ACCESS);
                 $exception->setData(array("login_url" => MOXMAN::getConfig()->get("authenticator.login_page")));
                 throw $exception;
             }
         }
         if ($json && isset($json->id) && isset($json->method) && isset($json->params)) {
             $id = $json->id;
             $params = $json->params;
             $result = null;
             if (isset($params->access)) {
                 MOXMAN::getAuthManager()->setClientAuthData($params->access);
             }
             $plugins = MOXMAN::getPluginManager()->getAll();
             foreach ($plugins as $plugin) {
                 if ($plugin instanceof MOXMAN_ICommandHandler) {
                     $result = $plugin->execute($json->method, $json->params);
                     if ($result !== null) {
                         break;
                     }
                 }
             }
             if ($result === null) {
                 throw new Exception("Method not found: " . $json->method, -32601);
             }
             $response->sendJson((object) array("jsonrpc" => "2.0", "result" => $result, "id" => $id));
         } else {
             throw new Exception("Invalid Request.", -32600);
         }
         MOXMAN::dispose();
     } catch (Exception $e) {
         MOXMAN::dispose();
         $message = $e->getMessage();
         $data = null;
         if (MOXMAN::getConfig()->get("general.debug")) {
             $message .= "\n\nStacktrace:\n";
             $trace = $e->getTrace();
             array_shift($trace);
             $message .= $e->getFile() . ":" . $e->getLine() . "\n";
             foreach ($trace as $item) {
                 if (isset($item["file"]) && isset($item["line"])) {
                     $message .= $item["file"] . ":" . $item["line"] . "\n";
                 }
             }
         }
         if ($e instanceof MOXMAN_Exception && !$data) {
             $data = $e->getData();
         }
         $response->sendJson((object) array("jsonrpc" => "2.0", "error" => array("code" => $e->getCode(), "message" => $message, "data" => $data), "id" => $id));
     }
 }
开发者ID:shainmcalindon,项目名称:boothsgardenstudios,代码行数:80,代码来源:JsonRpcHandler.php

示例11: fireFileAction

 /** @ignore */
 private function fireFileAction($action, $file, $data = array())
 {
     $args = new MOXMAN_Core_FileActionEventArgs($action, $file);
     $args->getData()->thumb = true;
     return MOXMAN::getPluginManager()->get("core")->fire("FileAction", $args);
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:7,代码来源:Plugin.php

示例12: init

<?php

/**
 * Plugin.php
 *
 * Copyright 2003-2013, Moxiecode Systems AB, All rights reserved.
 */
/**
 * AzureBlobStorage file system.
 */
class MOXMAN_Azure_Plugin implements MOXMAN_IPlugin
{
    public function init()
    {
        MOXMAN::getFileSystemManager()->registerFileSystem("azure", "MOXMAN_Azure_FileSystem");
    }
}
MOXMAN::getPluginManager()->add("azure", new MOXMAN_Azure_Plugin());
开发者ID:newton27,项目名称:dolphin.pro,代码行数:18,代码来源:Plugin.php

示例13: processRequest

 /**
  * Process a request using the specified context.
  *
  * @param MOXMAN_Http_Context $httpContext Context instance to pass to use for the handler.
  */
 public function processRequest(MOXMAN_Http_Context $httpContext)
 {
     $tempFilePath = null;
     $chunkFilePath = null;
     $request = $httpContext->getRequest();
     $response = $httpContext->getResponse();
     try {
         // Check if the user is authenticated or not
         if (!MOXMAN::getAuthManager()->isAuthenticated()) {
             if (!isset($json->method) || !preg_match('/^(login|logout)$/', $json->method)) {
                 $exception = new MOXMAN_Exception("Access denied by authenticator(s).", 10);
                 $exception->setData(array("login_url" => MOXMAN::getConfig()->get("authenticator.login_page")));
                 throw $exception;
             }
         }
         $file = MOXMAN::getFile($request->get("path"));
         $config = $file->getConfig();
         if ($config->get('general.demo')) {
             throw new MOXMAN_Exception("This action is restricted in demo mode.", MOXMAN_Exception::DEMO_MODE);
         }
         $maxSizeBytes = preg_replace("/[^0-9.]/", "", $config->get("upload.maxsize"));
         if (strpos(strtolower($config->get("upload.maxsize")), "k") > 0) {
             $maxSizeBytes = round(floatval($maxSizeBytes) * 1024);
         }
         if (strpos(strtolower($config->get("upload.maxsize")), "m") > 0) {
             $maxSizeBytes = round(floatval($maxSizeBytes) * 1024 * 1024);
         }
         function generateRandomString($length = 10)
         {
             $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
             $charactersLength = strlen($characters);
             $randomString = '';
             for ($i = 0; $i < $length; $i++) {
                 $randomString .= $characters[rand(0, $charactersLength - 1)];
             }
             return $randomString;
         }
         $filename = generateRandomString() . '.' . MOXMAN_Util_PathUtils::getExtension($request->get("name"));
         $id = $request->get("id");
         $loaded = intval($request->get("loaded", "0"));
         $total = intval($request->get("total", "-1"));
         $file = MOXMAN::getFile($file->getPath(), $filename);
         // Generate unique id for first chunk
         // TODO: We should cleanup orphan ID:s if upload fails etc
         if ($loaded == 0) {
             $id = uniqid();
         }
         // Setup path to temp file based on id
         $tempFilePath = MOXMAN_Util_PathUtils::combine(MOXMAN_Util_PathUtils::getTempDir(), "mcupload_" . $id . "." . MOXMAN_Util_PathUtils::getExtension($file->getName()));
         $chunkFilePath = MOXMAN_Util_PathUtils::combine(MOXMAN_Util_PathUtils::getTempDir(), "mcupload_chunk_" . $id . "." . MOXMAN_Util_PathUtils::getExtension($file->getName()));
         if (!$file->canWrite()) {
             throw new MOXMAN_Exception("No write access to path: " . $file->getPublicPath(), MOXMAN_Exception::NO_WRITE_ACCESS);
         }
         if ($total > $maxSizeBytes) {
             throw new MOXMAN_Exception("File size to large: " . $file->getPublicPath(), MOXMAN_Exception::FILE_SIZE_TO_LARGE);
         }
         // Operations on first chunk
         if ($loaded == 0) {
             // Fire before file action add event
             $args = new MOXMAN_Core_FileActionEventArgs("add", $file);
             $args->getData()->fileSize = $total;
             MOXMAN::getPluginManager()->get("core")->fire("BeforeFileAction", $args);
             $file = $args->getFile();
             if ($file->exists()) {
                 if (!$config->get("upload.overwrite") && !$request->get("overwrite")) {
                     throw new MOXMAN_Exception("Target file exists: " . $file->getPublicPath(), MOXMAN_Exception::FILE_EXISTS);
                 } else {
                     MOXMAN::getPluginManager()->get("core")->deleteThumbnail($file);
                     $file->delete();
                 }
             }
             $filter = MOXMAN_Vfs_CombinedFileFilter::createFromConfig($config, "upload");
             if ($filter->accept($file) !== MOXMAN_Vfs_CombinedFileFilter::ACCEPTED) {
                 throw new MOXMAN_Exception("Invalid file name for: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_NAME);
             }
         }
         $blobSize = 0;
         $inputFile = $request->getFile("file");
         if (!$inputFile) {
             throw new MOXMAN_Exception("No input file specified.");
         }
         if ($loaded === 0) {
             // Check if we should mock or not
             if (defined('PHPUNIT')) {
                 if (!copy($inputFile['tmp_name'], $tempFilePath)) {
                     throw new MOXMAN_Exception("Could not move the uploaded temp file.");
                 }
             } else {
                 if (!move_uploaded_file($inputFile['tmp_name'], $tempFilePath)) {
                     throw new MOXMAN_Exception("Could not move the uploaded temp file.");
                 }
             }
             $blobSize = filesize($tempFilePath);
         } else {
             // Check if we should mock or not
//.........这里部分代码省略.........
开发者ID:GHarutyunyan,项目名称:cms,代码行数:101,代码来源:UploadHandler.php

示例14: fireThumbnailTargetFileAction

 protected function fireThumbnailTargetFileAction($action, $fromFile, $toFile)
 {
     $args = new MOXMAN_Vfs_FileActionEventArgs($action, $fromFile);
     $args->setTargetFile($toFile);
     $args->getData()->thumb = true;
     return MOXMAN::getPluginManager()->get("core")->fire("FileAction", $args);
 }
开发者ID:codekanzlei,项目名称:cake-cktools,代码行数:7,代码来源:CorePlugin.php

示例15: init

<?php

/**
 * Ftp.php
 *
 * Copyright 2003-2013, Moxiecode Systems AB, All rights reserved.
 */
/**
 * ...
 */
class MOXMAN_Ftp_Plugin implements MOXMAN_IPlugin
{
    public function init()
    {
        MOXMAN::getFileSystemManager()->registerFileSystem("ftp", "MOXMAN_Ftp_FileSystem");
    }
}
// Add plugin
MOXMAN::getPluginManager()->add("ftp", new MOXMAN_Ftp_Plugin());
开发者ID:tremor-od,项目名称:pizza.loc,代码行数:19,代码来源:Plugin.php


注:本文中的MOXMAN::getPluginManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。