本文整理汇总了PHP中modResource::setProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::setProperties方法的具体用法?PHP modResource::setProperties怎么用?PHP modResource::setProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::setProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadManagerFiles
/**
* @param modManagerController $controller
* @param modResource $resource
*/
public function loadManagerFiles(modManagerController $controller, modResource $resource)
{
$modx23 = (int) $this->systemVersion();
$cssUrl = $this->config['cssUrl'] . 'mgr/';
$jsUrl = $this->config['jsUrl'] . 'mgr/';
$properties = $resource->getProperties('ms2gallery');
if (empty($properties['media_source'])) {
if (!($source_id = $resource->getTVValue('ms2Gallery'))) {
/** @var modContextSetting $setting */
$setting = $this->modx->getObject('modContextSetting', array('key' => 'ms2gallery_source_default', 'context_key' => $resource->get('context_key')));
$source_id = !empty($setting) ? $setting->get('value') : $this->modx->getOption('ms2gallery_source_default');
}
$resource->setProperties(array('media_source' => $source_id), 'ms2gallery');
$resource->save();
} else {
$source_id = $properties['media_source'];
}
if (empty($source_id)) {
$source_id = $this->modx->getOption('ms2gallery_source_default');
}
$resource->set('media_source', $source_id);
$controller->addLexiconTopic('ms2gallery:default');
$controller->addJavascript($jsUrl . 'ms2gallery.js');
$controller->addLastJavascript($jsUrl . 'misc/ms2.combo.js');
$controller->addLastJavascript($jsUrl . 'misc/ms2.utils.js');
$controller->addLastJavascript($jsUrl . 'misc/plupload/plupload.full.js');
$controller->addLastJavascript($jsUrl . 'misc/ext.ddview.js');
$controller->addLastJavascript($jsUrl . 'gallery.view.js');
$controller->addLastJavascript($jsUrl . 'gallery.window.js');
$controller->addLastJavascript($jsUrl . 'gallery.toolbar.js');
$controller->addLastJavascript($jsUrl . 'gallery.panel.js');
$controller->addCss($cssUrl . 'main.css');
if (!$modx23) {
$controller->addCss($cssUrl . 'font-awesome.min.css');
}
$source_config = array();
/** @var modMediaSource $source */
if ($source = $this->modx->getObject('modMediaSource', $source_id)) {
$tmp = $source->getProperties();
foreach ($tmp as $v) {
$source_config[$v['name']] = $v['value'];
}
}
$controller->addHtml('
<script type="text/javascript">
MODx.modx23 = ' . $modx23 . ';
ms2Gallery.config = ' . $this->modx->toJSON($this->config) . ';
ms2Gallery.config.media_source = ' . $this->modx->toJSON($source_config) . ';
</script>');
if ($this->modx->getOption('ms2gallery_new_tab_mode', null, true)) {
$controller->addLastJavascript($jsUrl . 'tab.js');
} else {
$insert = '
tabs.add({
xtype: "ms2gallery-page",
id: "ms2gallery-page",
title: _("ms2gallery"),
record: {
id: ' . $resource->get('id') . ',
source: ' . $source_id . ',
}
});
';
if ($this->modx->getCount('modPlugin', array('name' => 'AjaxManager', 'disabled' => false))) {
$controller->addHtml('
<script type="text/javascript">
Ext.onReady(function() {
window.setTimeout(function() {
var tabs = Ext.getCmp("modx-resource-tabs");
if (tabs) {
' . $insert . '
}
}, 10);
});
</script>');
} else {
$controller->addHtml('
<script type="text/javascript">
Ext.ComponentMgr.onAvailable("modx-resource-tabs", function() {
var tabs = this;
tabs.on("beforerender", function() {
' . $insert . '
});
});
</script>');
}
}
}
示例2: importResource
/**
* Import the Resource into Articles
*
* @param modResource $resource
* @return boolean
*/
public function importResource(modResource $resource)
{
$resource->set('searchable', true);
$resource->set('richtext', true);
$resource->set('isfolder', false);
$resource->set('cacheable', true);
$resource->set('class_key', 'Article');
$resource->set('parent', $this->container->get('id'));
$settings = $this->container->getProperties('articles');
$resource->setProperties($settings, 'articles');
if (!empty($this->config['modx-change-template'])) {
$resource->set('template', $settings['articleTemplate']);
}
$this->setResourceUri($resource);
if (!empty($this->config['modx-commentsThreadNameFormat'])) {
$this->importComments($resource);
}
$saved = true;
if (!$this->debug) {
$saved = $resource->save();
if ($saved) {
$resource->setTVValue('articlestags', $resource->get('tags'));
}
}
return $saved;
}