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


PHP modMediaSource类代码示例

本文整理汇总了PHP中modMediaSource的典型用法代码示例。如果您正苦于以下问题:PHP modMediaSource类的具体用法?PHP modMediaSource怎么用?PHP modMediaSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->modx->loadClass('sources.modMediaSource');
     $this->source = $this->modx->newObject('sources.modMediaSource');
     $this->source->fromArray(array('name' => 'UnitTestSource', 'description' => '', 'class_key' => 'sources.modFileMediaSource', 'properties' => array()), '', true);
 }
开发者ID:rossng,项目名称:revolution,代码行数:10,代码来源:modMediaSourceTest.php

示例2: getSource

 /**
  * Get the active Source
  * @return modMediaSource|boolean
  */
 public function getSource()
 {
     $this->modx->loadClass('sources.modMediaSource');
     $this->source = modMediaSource::getDefaultSource($this->modx, $this->getProperty('source'));
     if (empty($this->source) || !$this->source->getWorkingContext()) {
         return false;
     }
     return $this->source;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:13,代码来源:getlist.class.php

示例3: getSource

 /**
  * Get the active Source
  * @return modMediaSource|boolean
  */
 public function getSource()
 {
     $this->modx->loadClass('sources.modMediaSource');
     $this->source = $this->modx->getObject('modMediaSource', $_POST['sourceID']);
     if (empty($this->source) || !$this->source->getWorkingContext()) {
         return false;
     }
     return $this->source;
 }
开发者ID:neonoviy,项目名称:CET_AssetsTV,代码行数:13,代码来源:upload.class.php

示例4: getSource

 /**
  * @return boolean|string
  */
 public function getSource()
 {
     /** @var modMediaSource $source */
     $this->modx->loadClass('sources.modMediaSource');
     $this->source = $this->modx->getObject('modMediaSource', $_POST['sourceID']);
     if (!$this->source->getWorkingContext()) {
         return $this->modx->lexicon('permission_denied');
     }
     $this->source->setRequestProperties($this->getProperties());
     return $this->source->initialize();
 }
开发者ID:neonoviy,项目名称:CET_AssetsTV,代码行数:14,代码来源:remove.class.php

示例5: getSource

 /**
  * @return boolean|string
  */
 public function getSource()
 {
     $source = $this->getProperty('source', 1);
     /** @var modMediaSource $source */
     $this->modx->loadClass('sources.modMediaSource');
     $this->source = modMediaSource::getDefaultSource($this->modx, $source);
     if (!$this->source->getWorkingContext()) {
         return $this->modx->lexicon('permission_denied');
     }
     $this->source->setRequestProperties($this->getProperties());
     return $this->source->initialize();
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:15,代码来源:update.class.php

示例6: getSource

 /**
  * Get the source to load the paths from
  * 
  * @param int $sourceId
  * @return modMediaSource|modFileMediaSource
  */
 public function getSource($sourceId)
 {
     /** @var modMediaSource|modWebDAVMediaSource $source */
     $this->modx->loadClass('sources.modMediaSource');
     $this->source = modMediaSource::getDefaultSource($this->modx, $sourceId, false);
     if (empty($this->source)) {
         return false;
     }
     if (!$this->source->getWorkingContext()) {
         return false;
     }
     $this->source->setRequestProperties($this->getProperties());
     $this->source->initialize();
     return $this->source;
 }
开发者ID:Burick,项目名称:modx-WebDAV,代码行数:21,代码来源:proxy.class.php

示例7: process

 public function process()
 {
     if (!$this->validate()) {
         return $this->failure();
     }
     $source = $this->getProperty('source', 1);
     /** @var modMediaSource $source */
     $this->modx->loadClass('sources.modMediaSource');
     $source = modMediaSource::getDefaultSource($this->modx, $source);
     if (!$source->getWorkingContext()) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $source->setRequestProperties($this->getProperties());
     $source->initialize();
     $success = $source->renameContainer($this->getProperty('dir'), $this->getProperty('name'));
     if (!$success) {
         $msg = '';
         $errors = $source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:25,代码来源:update.class.php

示例8: process

 public function process()
 {
     $from = $this->getProperty('from');
     $to = $this->getProperty('to');
     $point = $this->getProperty('point', 'append');
     if (empty($from)) {
         return $this->failure($this->modx->lexicon('file_folder_err_ns'));
     }
     if (empty($to)) {
         return $this->failure($this->modx->lexicon('file_folder_err_ns'));
     }
     $source = $this->getProperty('source', 1);
     /** @var modMediaSource $source */
     $this->modx->loadClass('sources.modMediaSource');
     $source = modMediaSource::getDefaultSource($this->modx, $source);
     if (!$source->getWorkingContext()) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $source->setRequestProperties($this->getProperties());
     $source->initialize();
     if (!$source->checkPolicy('save')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $success = $source->moveObject($from, $to, $point);
     if (!$success) {
         $errors = $source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($this->modx->error->message);
     }
     return $this->success();
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:33,代码来源:sort.class.php

示例9: getAccess

 public function getAccess()
 {
     $c = $this->modx->newQuery('sources.modAccessMediaSource');
     $c->innerJoin('sources.modMediaSource', 'Target');
     $c->innerJoin('modAccessPolicy', 'Policy');
     $c->innerJoin('modUserGroup', 'Principal');
     $c->innerJoin('modUserGroupRole', 'MinimumRole');
     $c->where(array('target' => $this->source->get('id')));
     $c->select($this->modx->getSelectColumns('sources.modAccessMediaSource', 'modAccessMediaSource'));
     $c->select(array('target_name' => 'Target.name', 'principal_name' => 'Principal.name', 'policy_name' => 'Policy.name', 'authority_name' => 'MinimumRole.name'));
     $acls = $this->modx->getCollection('sources.modAccessMediaSource', $c);
     $access = array();
     /** @var modAccessMediaSource $acl */
     foreach ($acls as $acl) {
         $access[] = array($acl->get('id'), $acl->get('target'), $acl->get('target_name'), $acl->get('principal_class'), $acl->get('principal'), $acl->get('principal_name'), $acl->get('authority'), $acl->get('authority_name'), $acl->get('policy'), $acl->get('policy_name'), $acl->get('context_key'));
     }
     $this->sourceArray['access'] = $this->modx->toJSON($access);
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:18,代码来源:update.class.php

示例10: initializeMediaSource

 /**
  * @param string $ctx
  * @param $source
  *
  * @return bool|null|object
  */
 public function initializeMediaSource($ctx = '', $source)
 {
     if ($this->mediaSource = $this->modx->getObject('sources.modMediaSource', $source)) {
         $this->mediaSource->set('ctx', $ctx);
         $this->mediaSource->initialize();
         return $this->mediaSource;
     } else {
         return false;
     }
 }
开发者ID:arkadiy-vl,项目名称:ms2Gallery,代码行数:16,代码来源:ms2gallery.class.php

示例11: getElementSources

 public function getElementSources()
 {
     $c = $this->modx->newQuery('modContext');
     $c->where(array('key:!=' => 'mgr'));
     $c->sortby($this->modx->escape('rank'), 'ASC');
     $c->sortby($this->modx->escape('key'), 'DESC');
     $contexts = $this->modx->getCollection('modContext', $c);
     $list = array();
     $this->modx->loadClass('sources.modMediaSource');
     /** @var $source modMediaSource */
     $source = modMediaSource::getDefaultSource($this->modx);
     /** @var modContext $context */
     foreach ($contexts as $context) {
         $list[] = array($context->get('key'), $source->get('id'), $source->get('name'));
     }
     return $list;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:17,代码来源:create.class.php

示例12: getSource

 /**
  * Get the active source
  * @return modMediaSource
  */
 public function getSource()
 {
     /** @var modMediaSource|modFileMediaSource $source */
     $this->modx->loadClass('sources.modMediaSource');
     $source = $this->modx->getOption('source', $this->scriptProperties, false);
     if (!empty($source)) {
         $source = $this->modx->getObject('source.modMediaSource', $source);
     }
     if (empty($source)) {
         $source = modMediaSource::getDefaultSource($this->modx);
     }
     if (!$source->getWorkingContext()) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $source->setRequestProperties($this->scriptProperties);
     $source->initialize();
     return $source;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:22,代码来源:edit.class.php

示例13: initialize

 /**
  * Initializes component into different contexts.
  *
  * @param string $ctx The context to load. Defaults to web.
  * @param array $scriptProperties
  *
  * @return boolean
  */
 public function initialize($ctx = 'web', $scriptProperties = array())
 {
     $this->config = array_merge($this->config, $scriptProperties);
     $this->config['ctx'] = $ctx;
     if (empty($this->initialized[$ctx])) {
         $properties = $this->ms2Gallery->getSourceProperties();
         $config_js = array('ctx' => $ctx, 'jsUrl' => $this->config['jsUrl'] . 'web/', 'cssUrl' => $this->config['cssUrl'] . 'web/', 'actionUrl' => $this->config['actionUrl'], 'source' => array('size' => !empty($properties['maxUploadSize']) ? $properties['maxUploadSize'] : 3145728, 'height' => !empty($properties['maxUploadHeight']) ? $properties['maxUploadHeight'] : 1080, 'width' => !empty($properties['maxUploadWidth']) ? $properties['maxUploadWidth'] : 1920, 'extensions' => !empty($properties['allowedFileTypes']) ? $properties['allowedFileTypes'] : 'jpg,jpeg,png,gif'));
         $this->modx->regClientStartupScript('<script type="text/javascript">ms2GalleryFormConfig=' . $this->modx->toJSON($config_js) . '</script>', true);
         $css = !empty($this->config['frontend_css']) ? $this->config['frontend_css'] : $this->config['cssUrl'] . 'web/default.css';
         if (!empty($css) && preg_match('/\\.css/i', $css)) {
             $this->modx->regClientCSS($css);
         }
         $js = !empty($this->config['frontend_js']) ? $this->config['frontend_js'] : $this->config['jsUrl'] . 'web/default.js';
         if (!empty($js) && preg_match('/\\.js/i', $js)) {
             $this->modx->regClientScript($js);
         }
         $this->modx->regClientScript($this->config['jsUrl'] . 'web/lib/plupload/plupload.full.min.js');
         $this->modx->regClientScript($this->config['jsUrl'] . 'web/files.js');
         $lang = $this->modx->getOption('cultureKey');
         if ($lang != 'en' && file_exists($this->config['jsUrl'] . 'web/lib/plupload/i18n/' . $lang . '.js')) {
             $this->modx->regClientScript($this->config['jsUrl'] . 'web/lib/plupload/i18n/' . $lang . '.js');
         }
         $this->initialized[$ctx] = true;
     }
     return true;
 }
开发者ID:bendasvadim,项目名称:ms2GalleryForm,代码行数:34,代码来源:ms2galleryform.class.php

示例14: process

 public function process()
 {
     if (!($data = $this->handleFile())) {
         return $this->failure($this->modx->lexicon('ticket_err_file_ns'));
     }
     $properties = $this->mediaSource->getPropertyList();
     $tmp = explode('.', $data['name']);
     $extension = strtolower(end($tmp));
     $image_extensions = $allowed_extensions = array();
     if (!empty($properties['imageExtensions'])) {
         $image_extensions = array_map('trim', explode(',', strtolower($properties['imageExtensions'])));
     }
     if (!empty($properties['allowedFileTypes'])) {
         $allowed_extensions = array_map('trim', explode(',', strtolower($properties['allowedFileTypes'])));
     }
     if (!empty($allowed_extensions) && !in_array($extension, $allowed_extensions)) {
         return $this->failure($this->modx->lexicon('ticket_err_file_ext'));
     } elseif (in_array($extension, $image_extensions)) {
         $type = 'image';
     } else {
         $type = $extension;
     }
     $hash = sha1($data['stream']);
     $path = '0/';
     $filename = !empty($properties['imageNameType']) && $properties['imageNameType'] == 'friendly' ? $this->ticket->cleanAlias($data['name']) : $hash . '.' . $extension;
     if (strpos($filename, '.' . $extension) === false) {
         $filename .= '.' . $extension;
     }
     // Check for existing file
     $where = $this->modx->newQuery($this->classKey, array('class' => $this->class));
     if (!empty($this->ticket->id)) {
         $where->andCondition(array('parent:IN' => array(0, $this->ticket->id)));
     } else {
         $where->andCondition(array('parent' => 0));
     }
     $where->andCondition(array('file' => $filename, 'OR:hash:=' => $hash), null, 1);
     if ($this->modx->getCount($this->classKey, $where)) {
         return $this->failure($this->modx->lexicon('ticket_err_file_exists', array('file' => $data['name'])));
     }
     /* @var TicketFile $ticket_file */
     $ticket_file = $this->modx->newObject('TicketFile', array('parent' => 0, 'name' => $data['name'], 'file' => $filename, 'path' => $path, 'source' => $this->mediaSource->id, 'type' => $type, 'createdon' => date('Y-m-d H:i:s'), 'createdby' => $this->modx->user->id, 'deleted' => 0, 'hash' => $hash, 'size' => $data['size'], 'class' => $this->class, 'properties' => $data['properties']));
     $this->mediaSource->createContainer($ticket_file->path, '/');
     unset($this->mediaSource->errors['file']);
     $file = $this->mediaSource->createObject($ticket_file->get('path'), $ticket_file->get('file'), $data['stream']);
     if ($file) {
         $url = $this->mediaSource->getObjectUrl($ticket_file->get('path') . $ticket_file->get('file'));
         $ticket_file->set('url', $url);
         $ticket_file->save();
         $ticket_file->generateThumbnail($this->mediaSource);
         return $this->success('', $ticket_file->toArray());
     } else {
         $this->modx->log(modX::LOG_LEVEL_ERROR, '[Tickets] Could not save file: ' . print_r($this->mediaSource->getErrors(), 1));
         return $this->failure($this->modx->lexicon('ticket_err_file_save'));
     }
 }
开发者ID:soulcreate,项目名称:Tickets,代码行数:55,代码来源:upload.class.php

示例15: createAsset

 /**
  * @param $new_name
  * @param $file
  * @return string $url_name
  */
 protected function createAsset($new_name, $file, $remote = true)
 {
     //$this->modx->importx->log('error', 'Create Asset ');
     if (is_object($this->mediaSource)) {
         //$this->modx->importx->log('error', 'Yes: '.$file);
         if ($remote && strpos($file, 'http') !== 0) {
             $file = rtrim($this->config['link'], '/') . '/' . ltrim($file, '/');
         }
         // directory:
         $object_path = '';
         if (in_array(strtolower(pathinfo($new_name, PATHINFO_EXTENSION)), array('doc', 'pdf', 'docx', 'csv', 'xlsx'))) {
             $object_path = 'docs' . DIRECTORY_SEPARATOR;
         }
         $content = $remote ? $this->getRemoteData($file) : file_get_contents($file);
         $file = rawurldecode($this->mediaSource->createObject($object_path, $new_name, $content));
         $basePath = $this->mediaSource->getBasePath($file);
         $baseUrl = $this->mediaSource->getBaseUrl($file);
         $file = str_replace($basePath, $baseUrl, $file);
         if ($file !== false) {
             $this->modx->importx->log('info', 'File transferred to: ' . $file);
         }
         return $file;
     }
     return false;
 }
开发者ID:jgulledge19,项目名称:importX,代码行数:30,代码来源:wordpress.php


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