本文整理汇总了PHP中modMediaSource类的典型用法代码示例。如果您正苦于以下问题:PHP modMediaSource类的具体用法?PHP modMediaSource怎么用?PHP modMediaSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了modMediaSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getSource
/**
* Get the active Source
* @return modMediaSource|boolean
*/
public function getSource()
{
$path = $this->modx->getOption('modxsdk.core_path', null);
if (!$path) {
$path = MODX_CORE_PATH . 'components/modxsdk/';
}
$path .= 'model/modxSDK/';
if (!$this->modx->loadClass('ModxsdkFileMediaSource', $path)) {
return false;
}
$source = modMediaSource::getDefaultSource($this->modx, $this->getProperty('source'));
if (empty($source) || !$source->getWorkingContext()) {
return false;
}
$this->source = $this->modx->newObject('ModxsdkFileMediaSource');
if (!$this->source->checkPolicy('list')) {
return 'Source access denied';
}
$this->source->fromArray($source->toArray());
$this->source->setRequestProperties($this->getProperties());
$this->source->initialize();
return true;
}
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:27,代码来源:getlist.class.php
示例14: _getSource
/**
* @param $source_id
* @return bool|modFileMediaSource|modMediaSource|null
*/
protected function _getSource($source_id)
{
$this->modx->loadClass('sources.modMediaSource');
$source = modMediaSource::getDefaultSource($this->modx, $source_id);
if (empty($source) || !$source->getWorkingContext()) {
return false;
}
$images = $this->modx->getOption('imageExtensions', $source->getPropertyList(), 'jpg,jpeg,png,gif');
$this->_images = array_map('trim', explode(',', $images));
return $source;
}
开发者ID:suasti,项目名称:mxManager,代码行数:15,代码来源:getlist.class.php
示例15: getFieldSource
function getFieldSource($field, &$tv)
{
//source from config
$sourcefrom = isset($field['sourceFrom']) && !empty($field['sourceFrom']) ? $field['sourceFrom'] : 'config';
if ($sourcefrom == 'config' && isset($field['sources'])) {
if (is_array($field['sources'])) {
foreach ($field['sources'] as $context => $sourceid) {
$sources[$context] = $sourceid;
}
} else {
$fsources = $this->modx->fromJson($field['sources']);
if (is_array($fsources)) {
foreach ($fsources as $source) {
if (isset($source['context']) && isset($source['sourceid'])) {
$sources[$source['context']] = $source['sourceid'];
}
}
}
}
}
if (isset($sources[$this->working_context]) && !empty($sources[$this->working_context])) {
//try using field-specific mediasource from config
if ($mediasource = $this->modx->getObject('sources.modMediaSource', $sources[$this->working_context])) {
return $mediasource;
}
}
if ($this->source && $sourcefrom == 'migx') {
//use global MIGX-mediasource for all TVs
$tv->setSource($this->source);
$mediasource = $this->source;
} else {
//useTV-specific mediasource
$mediasource = $tv->getSource($this->working_context, false);
}
//try to get the context-default-media-source
if (!$mediasource) {
$defaultSourceId = null;
if ($contextSetting = $this->modx->getObject('modContextSetting', array('key' => 'default_media_source', 'context_key' => $this->working_context))) {
$defaultSourceId = $contextSetting->get('value');
}
$mediasource = modMediaSource::getDefaultSource($this->modx, $defaultSourceId);
}
return $mediasource;
}
开发者ID:shot131,项目名称:MIGX,代码行数:44,代码来源:migx.class.php
示例16: getSource
/**
* Get the Source for this Element
*
* @param string $contextKey
* @param boolean $fallbackToDefault
* @return modMediaSource|null
*/
public function getSource($contextKey = '', $fallbackToDefault = true)
{
if (empty($contextKey)) {
$contextKey = $this->xpdo->context->get('key');
}
$source = $this->_source;
if (empty($source)) {
$c = $this->xpdo->newQuery('sources.modMediaSource');
$c->innerJoin('sources.modMediaSourceElement', 'SourceElement');
$c->where(array('SourceElement.object' => $this->get('id'), 'SourceElement.object_class' => $this->_class, 'SourceElement.context_key' => $contextKey));
$source = $this->xpdo->getObject('sources.modMediaSource', $c);
if (!$source && $fallbackToDefault) {
$source = modMediaSource::getDefaultSource($this->xpdo);
}
$this->setSource($source);
}
return $source;
}
开发者ID:OptimusCrime,项目名称:revolution,代码行数:25,代码来源:modelement.class.php
示例17: array
$resource = $modx->newObject('modResource');
}
//set objectid for migxObjectMediaPath - snippet
$co_id = $modx->getOption('co_id', $scriptProperties, '');
if (!empty($co_id)) {
$modx->setPlaceholder('objectid', $co_id);
}
if ($tv = $modx->getObject('modTemplateVar', array('name' => $tvname))) {
$source = $tv->getSource($wctx, false);
}
if (!$source instanceof modMediaSource) {
$sourceid = $modx->getOption('source', $_REQUEST, '');
/**
* * * * @var modMediaSource $source */
$modx->loadClass('sources.modMediaSource');
$source = modMediaSource::getDefaultSource($modx, $sourceid);
if (!$source->getWorkingContext()) {
return $modx->lexicon('permission_denied');
}
$source->setRequestProperties($_REQUEST);
}
$result = array();
if ($source instanceof modMediaSource) {
$dirTree = $modx->getOption('dirtree', $_REQUEST, '');
$modx->setPlaceholder('docid', $resource_id);
$source->initialize();
$cachepath = str_replace('/./', '/', $source->getBasePath());
$cachepath = $cachepath . $dirTree;
$baseUrl = $modx->getOption('site_url') . $source->getBaseUrl();
$baseUrl = $baseUrl . $dirTree;
$sourceProperties = $source->getPropertyList();
开发者ID:raadhuis,项目名称:modx-basic,代码行数:31,代码来源:imageupload.php
示例18: getProfilePhoto
/**
* Retrieve the profile photo, if any
*
* @param int $width The desired photo width
* @param int $height The desired photo height
*
* @return string The photo URL
*/
public function getProfilePhoto($width = 128, $height = 128)
{
if (empty($this->Profile->photo)) {
return '';
}
$this->xpdo->loadClass('sources.modMediaSource');
/** @var modMediaSource $source */
$source = modMediaSource::getDefaultSource($this->xpdo, $this->xpdo->getOption('photo_profile_source'));
$source->initialize();
$path = $source->getBasePath($this->Profile->photo) . $this->Profile->photo;
return $this->xpdo->getOption('connectors_url', MODX_CONNECTORS_URL) . "system/phpthumb.php?zc=1&h={$height}&w={$width}&src={$path}";
}
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:20,代码来源:moduser.class.php
示例19: getDefaultSource
function getDefaultSource($return = 'object')
{
$defaultSourceId = null;
if ($contextSetting = $this->modx->getObject('modContextSetting', array('key' => 'default_media_source', 'context_key' => $this->working_context))) {
$defaultSourceId = $contextSetting->get('value');
}
$mediasource = modMediaSource::getDefaultSource($this->modx, $defaultSourceId);
return $return == 'object' ? $mediasource : $mediasource->get($return);
}
开发者ID:pixelfanatiker,项目名称:MIGX,代码行数:9,代码来源:migx.class.php
示例20: 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
注:本文中的modMediaSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论