本文整理汇总了PHP中modResource类的典型用法代码示例。如果您正苦于以下问题:PHP modResource类的具体用法?PHP modResource怎么用?PHP modResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了modResource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: checkRules
public function checkRules()
{
$DocID = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$rules = $this->getOptions("rules", array());
$flag = empty($rules);
if (!$flag && $DocID && $this->loadModClass("modResource")) {
$DOC = new modResource($this->_modx);
$data = $DOC->edit($DocID)->toArray();
$flag = true;
foreach ($rules as $item => $value) {
switch ($item) {
case 'id':
if ($DOC->getID() != $value) {
$flag = false;
}
break;
default:
if (!isset($data[$item]) || $data[$item] != $value) {
$flag = false;
}
break;
}
}
}
return $flag;
}
开发者ID:dukeRD,项目名称:customTables,代码行数:26,代码来源:CRGrid.class.php
示例2: handleOriginalParent
/**
* @param \modResource $originalParent
*/
protected function handleOriginalParent($originalParent)
{
$originalGreatParent = $originalParent->Parent;
if ($originalGreatParent && $originalGreatParent->class_key == 'CollectionContainer' && $originalParent->hasChildren() == 0) {
$originalParent->set('show_in_tree', 0);
$originalParent->save();
}
}
开发者ID:Burick,项目名称:Collections,代码行数:11,代码来源:collectionsonresourcebeforesort.class.php
示例3: beforeSave
public function beforeSave()
{
/** @var modResource $parent */
$parent = $this->modx->getObject('modResource', $this->object->parent);
if ($parent && $parent->class_key == 'CollectionContainer') {
$this->object->set('show_in_tree', 0);
} else {
$this->object->set('show_in_tree', 1);
}
return parent::beforeSave();
}
开发者ID:lokamaya,项目名称:Collections,代码行数:11,代码来源:changeparent.class.php
示例4: process
public function process()
{
/* @var modResourceGroupResource $resourceGroupResource */
$resourceGroupResource = $this->modx->getObject('modResourceGroupResource', array('document_group' => $this->resourceGroup->get('id'), 'document' => $this->resource->get('id')));
if (empty($resourceGroupResource)) {
return $this->failure($this->modx->lexicon('resource_group_resource_err_nf'));
}
if ($resourceGroupResource->remove() == false) {
return $this->failure($this->modx->lexicon('resource_group_resource_err_remove'));
} else {
$this->fireAfterRemove();
}
return $this->success('', $resourceGroupResource);
}
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:14,代码来源:removeresource.class.php
示例5: process
/**
* Process this page, load the resource, and present its values
* @return void
*/
public function process()
{
$data = $this->processInput($this->config['gpc']);
/* @var modProcessorResponse $response */
$response = $this->modx->runProcessor('resource/update', $data);
if (!$response->isError()) {
$tempRes = $response->getObject();
$this->resource = $this->modx->getObject('modResource', $tempRes['id']);
$this->setPlaceholders(array('message' => $this->modx->lexicon('updated'), 'resid' => $this->resource->get('id'), 'ctx' => $this->resource->get('context_key')));
} else {
$error = $response->getAllErrors();
$this->setPlaceholder('message', 'Something went wrong updating the Resource: ' . implode(', ', $error));
}
}
开发者ID:rossng,项目名称:HandyMan,代码行数:18,代码来源:update.save.class.php
示例6: handleOriginalParent
/**
* @param \modResource $parent
* @param \modResource $resource
* @param \modResource $originalParent
*/
protected function handleOriginalParent($parent, $resource, $originalParent)
{
if ($originalParent->class_key == 'CollectionContainer') {
if ($parent->class_key != 'CollectionContainer') {
$resource->set('show_in_tree', 1);
}
} else {
/** @var \modResource $originalGreatParent */
$originalGreatParent = $originalParent->Parent;
if ($originalGreatParent && $originalGreatParent->class_key == 'CollectionContainer') {
$resource->set('show_in_tree', 1);
}
}
}
开发者ID:Burick,项目名称:Collections,代码行数:19,代码来源:collectionsonbeforedocformsave.class.php
示例7: getResourceGroups
public function getResourceGroups()
{
$parentGroups = array();
if ($this->resource->get('id') == 0) {
$parent = $this->modx->getObject('modResource', $this->resource->get('parent'));
/** @var modResource $parent */
if ($parent) {
$parentResourceGroups = $parent->getMany('ResourceGroupResources');
/** @var modResourceGroupResource $parentResourceGroup */
foreach ($parentResourceGroups as $parentResourceGroup) {
$parentGroups[] = $parentResourceGroup->get('document_group');
}
$parentGroups = array_unique($parentGroups);
}
}
$this->resourceArray['resourceGroups'] = array();
$resourceGroups = $this->resource->getGroupsList(array('name' => 'ASC'), 0, 0);
/** @var modResourceGroup $resourceGroup */
foreach ($resourceGroups['collection'] as $resourceGroup) {
$access = (bool) $resourceGroup->get('access');
if (!empty($parent) && $this->resource->get('id') == 0) {
$access = in_array($resourceGroup->get('id'), $parentGroups) ? true : false;
}
$resourceGroupArray = array($resourceGroup->get('id'), $resourceGroup->get('name'), $access);
$this->resourceArray['resourceGroups'][] = $resourceGroupArray;
}
return $this->resourceArray['resourceGroups'];
}
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:28,代码来源:resource.class.php
示例8: modresource_populate_children
function modresource_populate_children(\Teleport\Action\Extract &$extract, modResource &$object, $criteria, $graph, $graphCriteria, $vehicle, &$vehicleCount)
{
unset($criteria['parent']);
$children = $object->getMany('Children', null, false);
if ($children) {
foreach ($children as &$child) {
/** @var modResource $child */
if ($graph !== null) {
$child->getGraph($graph, $graphCriteria);
}
if ($extract->package->put($child, $vehicle['attributes'])) {
$vehicleCount++;
}
modresource_populate_children($extract, $child, $criteria, $graph, $graphCriteria, $vehicle, $vehicleCount);
}
}
}
开发者ID:exside,项目名称:teleport,代码行数:17,代码来源:modresourcechildren.php
示例9: prepareResourceNode
/** {@inheritDoc} */
public function prepareResourceNode(modResource $resource)
{
$qtipField = $this->getProperty('qtipField');
$nodeField = $this->getProperty('nodeField');
$hasChildren = (int) $resource->get('childrenCount') > 0 && $resource->get('hide_children_in_tree') == 0 ? true : false;
// Assign an icon class based on the class_key
$class = $iconCls = array();
$classKey = strtolower($resource->get('class_key'));
if (substr($classKey, 0, 3) == 'mod') {
$classKey = substr($classKey, 3);
}
$classKeyIcon = $this->modx->getOption('mgr_tree_icon_' . $classKey, null, 'tree-resource');
$iconCls[] = $classKeyIcon;
$class[] = 'icon-' . strtolower(str_replace('mod', '', $resource->get('class_key')));
if (!$resource->isfolder) {
$class[] = 'x-tree-node-leaf icon-resource';
}
if (!$resource->get('published')) {
$class[] = 'unpublished';
}
if ($resource->get('deleted')) {
$class[] = 'deleted';
}
if ($resource->get('hidemenu')) {
$class[] = 'hidemenu';
}
if ($hasChildren) {
$class[] = 'haschildren';
$iconCls[] = $this->modx->getOption('mgr_tree_icon_folder', null, 'tree-folder');
$iconCls[] = 'parent-resource';
}
$qtip = '';
if (!empty($qtipField)) {
$qtip = '<b>' . strip_tags($resource->{$qtipField}) . '</b>';
} else {
if ($resource->longtitle != '') {
$qtip = '<b>' . strip_tags($resource->longtitle) . '</b><br />';
}
if ($resource->description != '') {
$qtip = '<i>' . strip_tags($resource->description) . '</i>';
}
}
$idNote = $this->modx->hasPermission('tree_show_resource_ids') ? ' <span dir="ltr">(' . $resource->id . ')</span>' : '';
$itemArray = array('text' => strip_tags($resource->{$nodeField}) . $idNote, 'id' => $resource->context_key . '_' . $resource->id, 'pk' => $resource->id, 'cls' => implode(' ', $class), 'iconCls' => implode(' ', $iconCls), 'type' => 'modResource', 'classKey' => $resource->class_key, 'ctx' => $resource->context_key, 'hide_children_in_tree' => $resource->hide_children_in_tree, 'qtip' => $qtip, 'checked' => !empty($resource->member) || $resource->id == $this->parent_id ? true : false, 'disabled' => $resource->id == $this->parent_id ? true : false);
if (!$hasChildren) {
$itemArray['hasChildren'] = false;
$itemArray['children'] = array();
$itemArray['expanded'] = true;
} else {
$itemArray['hasChildren'] = true;
}
if ($itemArray['classKey'] != 'msCategory') {
unset($itemArray['checked']);
}
return $itemArray;
}
开发者ID:volkovnd,项目名称:miniShop2,代码行数:57,代码来源:getnodes.class.php
示例10: getResource
/**
* Get the Resource associated
*
* @return modResource|string
*/
public function getResource()
{
$resourceId = $this->getProperty('resource', 0);
if (empty($resourceId)) {
$this->resource = $this->modx->newObject('modResource');
$this->resource->set('id', 0);
} else {
$this->resource = $this->modx->getObject('modResource', $resourceId);
if (empty($this->resource)) {
return $this->modx->lexicon('resource_err_nfs', array('id' => $resourceId));
}
/* check access */
if (!$this->resource->checkPolicy('view')) {
return $this->modx->lexicon('permission_denied');
}
}
return $this->resource;
}
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:23,代码来源:getlist.class.php
示例11: getTemplateVarCollection
public static function getTemplateVarCollection(modResource &$resource) {
$c = $resource->xpdo->newQuery('modTemplateVar');
$c->query['distinct'] = 'DISTINCT';
$c->select($resource->xpdo->getSelectColumns('modTemplateVar', 'modTemplateVar'));
if ($resource->isNew()) {
$c->select(array(
"modTemplateVar.default_text AS value",
"0 AS resourceId"
));
} else {
$c->select(array(
"ISNULL(tvc.value,modTemplateVar.default_text) AS value",
"{$resource->get('id')} AS resourceId"
));
}
$c->select($resource->xpdo->getSelectColumns('modTemplateVarTemplate', 'tvtpl', '', array('rank')));
$c->innerJoin('modTemplateVarTemplate','tvtpl',array(
'tvtpl.tmplvarid = modTemplateVar.id',
'tvtpl.templateid' => $resource->get('template'),
));
if (!$resource->isNew()) {
$c->leftJoin('modTemplateVarResource','tvc',array(
'tvc.tmplvarid = modTemplateVar.id',
'tvc.contentid' => $resource->get('id'),
));
}
$c->sortby('tvtpl.rank,modTemplateVar.rank');
return $resource->xpdo->getCollection('modTemplateVar', $c);
}
开发者ID:raf3600,项目名称:revolution,代码行数:30,代码来源:modresource.class.php
示例12: 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('modupdater');
$controller->addLexiconTopic('modupdater:default');
$controller->addJavascript($jsUrl . 'modupdater.js');
$controller->addLastJavascript($jsUrl . 'misc/utils.js');
$controller->addCss($cssUrl . 'main.css');
if (!$modx23) {
$controller->addCss($cssUrl . 'font-awesome.min.css');
}
$controller->addHtml('
<script type="text/javascript">
MODx.modx23 = ' . $modx23 . ';
modUpdater.config = ' . $this->modx->toJSON($this->config) . ';
modUpdater.config.resID = ' . $resource->id . ';
modUpdater.config.connector_url = "' . $this->config['connectorUrl'] . '";
</script>', true);
$controller->addLastJavascript($jsUrl . 'widgets/items.windows.js');
}
开发者ID:Homchenkokostya,项目名称:simpleUpdater,代码行数:26,代码来源:modupdater.class.php
示例13: beforeSave
public function beforeSave()
{
/* format data */
$resourceId = substr(strrchr($this->getProperty('resource', ''), '_'), 1);
$resourceGroupId = substr(strrchr($this->getProperty('resourceGroup', ''), '_'), 1);
if (empty($resourceId) || empty($resourceGroupId)) {
return $this->modx->lexicon('invalid_data');
}
$this->resource = $this->modx->getObject('modResource', $resourceId);
if (!$this->resource) {
return $this->modx->lexicon('resource_err_nfs', array('id' => $resourceId));
}
$this->resourceGroup = $this->modx->getObject('modResourceGroup', $resourceGroupId);
if (!$this->resourceGroup) {
return $this->modx->lexicon('resource_group_err_nf');
}
if ($this->doesAlreadyExist(array('document' => $this->resource->get('id'), 'document_group' => $this->resourceGroup->get('id')))) {
return $this->modx->lexicon($this->objectType . '_err_ae');
}
$this->object->set('document', $this->resource->get('id'));
$this->object->set('document_group', $this->resourceGroup->get('id'));
return parent::beforeSave();
}
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:23,代码来源:updateresourcesin.class.php
示例14: Lists
public function Lists()
{
$out = '';
$this->_modx->documentIdentifier = $this->_modx->getConfig('site_start');
$this->_modx->config['site_url'] = MODX_MANAGER_URL;
$method = $this->getParam('method', $_GET, '');
$addWhere = array();
switch ($method) {
case 'doc':
$docID = (int) $this->getParam('doc', $_GET, 0);
$addWhere[] = '`page`=' . $docID;
break;
case 'active':
$addWhere[] = '`active`=1';
break;
case 'deactive':
$addWhere[] = '`active`=0';
break;
}
/**
* По какому полю вести сортировку
*/
$key = $this->getParam('by', $_GET, 'page');
$modSeo = Action::getClassTable();
if (!$modSeo->issetField($key)) {
$key = 'uri';
}
$data = array('orderBy' => '`' . $key . '` ' . $this->getParam('order', $_GET, 'ASC'), 'addWhereList' => implode(" AND ", $addWhere));
/**
* Хакаем URL пагинатора
*/
parse_str(parse_url(MODX_SITE_URL . $_SERVER['REQUEST_URI'], PHP_URL_QUERY), $URL);
$_SERVER['REQUEST_URI'] = $this->_modx->getManagerPath() . "?" . http_build_query(array_merge($URL, array('q' => null, 'action' => null)));
if (!empty($data)) {
$out = $this->_modx->runSnippet('DocLister', array_merge(array('controller' => 'onetable', 'table' => Action::TABLE(), 'tpl' => '@CODE: ' . $this->showBody('table/body'), 'ownerTPL' => '@CODE: ' . $this->showBody('table/wrap'), 'altItemClass' => 'gridAltItem', 'itemClass' => 'gridItem', 'display' => self::getParam('display', $this->_modx->event->params), 'id' => 'dl', 'pageInfoTpl' => '@CODE: ' . $this->showBody('table/pageInfo'), 'pageInfoEmptyTpl' => '@CODE: ' . $this->showBody('table/pageInfoEmpty'), 'debug' => 0, 'noneTPL' => '@CODE: Нет данных', 'noneWrapOuter' => 0, 'paginate' => 'pages', 'prepare' => function (array $data = array(), \DocumentParser $modx, \onetableDocLister $_DocLister) {
if (!empty($data['page'])) {
include_once MODX_BASE_PATH . "assets/lib/MODxAPI/modResource.php";
$DOC = new \modResource($modx);
$DOC->edit($data['page']);
$data['doc_pagetitle'] = $DOC->getID() ? $DOC->get('pagetitle') : '';
$data['doc_parent'] = $DOC->getID() ? $DOC->get('parent') : '0';
$tpl = 'pageInfoTpl';
} else {
$tpl = 'pageInfoEmptyTpl';
}
$data['pageInfo'] = $_DocLister->parseChunk($_DocLister->getCFGDef($tpl), $data);
$data['saveGet'] = $data['save_get'] ? 'save' : 'exclamation';
$data['fullRequest'] = $data['full_request'] ? 'page_white_copy' : 'page_white_magnify';
$data['active'] = $data['active'] ? 'stop' : 'add';
$data['class'] = isset($data['dl.iteration']) && $data['dl.iteration'] % 2 ? $_DocLister->getCFGDef('itemClass') : $_DocLister->getCFGDef('altItemClass');
return $data;
}, 'idType' => 'documents', 'ignoreEmpty' => 1), $data));
$out .= $this->_modx->getPlaceholder('dl.pages');
}
return $out;
}
开发者ID:bagi091,项目名称:DocLister,代码行数:56,代码来源:Template.class.php
示例15: getResource
/**
* Get the Resource associated
*
* @return modResource|string
*/
public function getResource()
{
$resource_id = $this->getProperty('resource');
if (empty($resource_id)) {
return $this->modx->lexicon('resource_err_ns');
}
$this->resource = $this->modx->getObject('modResource', $resource_id);
if (empty($resourcegroup)) {
return $this->modx->lexicon('resource_err_nf');
}
/* check access */
if (!$this->resource->checkPolicy('save')) {
return $this->modx->lexicon('permission_denied');
}
return $this->resource;
}
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:21,代码来源:updatefromgrid.class.php
示例16: _getTemplateVars
/**
* Used in MODX < 2.1 where the modResource::getTemplateVarCollection method is not yet available.
* Collects modTemplateVar objects with their value for the current resource.
*
* @return array An array with TV objects.
*/
private function _getTemplateVars()
{
$c = $this->modx->newQuery('modTemplateVar');
$c->query['distinct'] = 'DISTINCT';
$c->select($this->modx->getSelectColumns('modTemplateVar', 'modTemplateVar'));
if ($this->resource->isNew()) {
$c->select(array('modTemplateVar.default_text AS value', '0 AS resourceId'));
} else {
$c->select(array('IF(ISNULL(tvc.value),modTemplateVar.default_text,tvc.value) AS value', $this->resource->get('id') . ' AS resourceId'));
}
$c->innerJoin('modTemplateVarTemplate', 'tvtpl', array('tvtpl.tmplvarid = modTemplateVar.id', 'tvtpl.templateid' => $this->resource->get('template')));
if (!$this->resource->isNew()) {
$c->leftJoin('modTemplateVarResource', 'tvc', array('tvc.tmplvarid = modTemplateVar.id', 'tvc.contentid' => $this->resource->get('id')));
}
$c->sortby('tvtpl.rank,modTemplateVar.rank');
return $this->modx->getCollection('modTemplateVar', $c);
}
开发者ID:rossng,项目名称:HandyMan,代码行数:23,代码来源:update.class.php
示例17: process
public function process()
{
if (!$this->validate()) {
return $this->failure();
}
$this->resource->fromArray($this->getProperties());
if ($this->resource->save() === false) {
return $this->failure($this->modx->lexicon('resource_err_save'));
}
return $this->success();
}
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:11,代码来源:updatefromgrid.class.php
示例18: process
/**
* @return array|string
*/
public function process()
{
if (!($data = $this->handleFile())) {
return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_ns'));
}
$properties = $this->mediaSource->getProperties();
$tmp = explode('.', $data['name']);
$extension = strtolower(end($tmp));
$image_extensions = $allowed_extensions = array();
if (!empty($properties['imageExtensions']['value'])) {
$image_extensions = array_map('trim', explode(',', strtolower($properties['imageExtensions']['value'])));
}
if (!empty($properties['allowedFileTypes']['value'])) {
$allowed_extensions = array_map('trim', explode(',', strtolower($properties['allowedFileTypes']['value'])));
}
if (!empty($allowed_extensions) && !in_array($extension, $allowed_extensions)) {
return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_ext'));
} else {
if (in_array($extension, $image_extensions)) {
$type = 'image';
} else {
$type = $extension;
}
}
$hash = sha1($data['stream']);
if ($this->modx->getCount('msResourceFile', array('resource_id' => $this->resource->id, 'hash' => $hash, 'parent' => 0))) {
return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_exists'));
}
$filename = !empty($properties['imageNameType']) && $properties['imageNameType']['value'] == 'friendly' ? $this->resource->cleanAlias($data['name']) : $hash . '.' . $extension;
$rank = isset($properties['imageUploadDir']) && empty($properties['imageUploadDir']['value']) ? 0 : $this->modx->getCount('msResourceFile', array('parent' => 0, 'resource_id' => $this->resource->id));
/* @var msResourceFile $product_file */
$product_file = $this->modx->newObject('msResourceFile', array('resource_id' => $this->resource->id, 'parent' => 0, 'name' => $data['name'], 'file' => $filename, 'path' => $this->resource->id . '/', 'source' => $this->mediaSource->get('id'), 'type' => $type, 'rank' => $rank, 'createdon' => date('Y-m-d H:i:s'), 'createdby' => $this->modx->user->id, 'active' => 1, 'hash' => $hash, 'properties' => $data['properties']));
$this->mediaSource->createContainer($product_file->path, '/');
$file = $this->mediaSource->createObject($product_file->get('path'), $product_file->get('file'), $data['stream']);
if ($file) {
$url = $this->mediaSource->getObjectUrl($product_file->get('path') . $product_file->get('file'));
$product_file->set('url', $url);
$product_file->save();
if (empty($rank)) {
$imagesTable = $this->modx->getTableName('msResourceFile');
$sql = "UPDATE {$imagesTable} SET rank = rank + 1 WHERE resource_id ='" . $this->resource->id . "' AND id !='" . $product_file->get('id') . "'";
$this->modx->exec($sql);
}
$generate = $product_file->generateThumbnails($this->mediaSource);
if ($generate !== true) {
$this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not generate thumbnails for image with id = ' . $product_file->get('id') . '. ' . $generate);
return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_thumb'));
} else {
return $this->success();
}
} else {
return $this->failure($this->modx->lexicon('ms2gallery_err_gallery_save') . ': ' . print_r($this->mediaSource->getErrors(), 1));
}
}
开发者ID:sin4end,项目名称:ms2Gallery,代码行数:57,代码来源:upload.class.php
示例19: process
public function process()
{
$action = $this->resource->get('deleted') ? 'undelete' : 'delete';
$return = $this->hm->runProcessor(array('action' => 'resource/' . $action, 'id' => $this->resource->get('id')));
if ($return['success'] == 1) {
if ($action == 'undelete') {
$message = 'Successfully undeleted resource ' . $this->resource->get('pagetitle') . '.';
} else {
$message = 'Successfully deleted resource ' . $this->resource->get('pagetitle') . '.';
}
} else {
$message = 'Something went wrong. ' . $return['message'];
}
$this->setPlaceholder('message', $message);
}
开发者ID:rossng,项目名称:HandyMan,代码行数:15,代码来源:delete.class.php
示例20: clearCache
/**
* Empty site cache if specified to do so
* @return void
*/
public function clearCache()
{
$syncSite = $this->getProperty('syncsite', false);
$clearCache = $this->getProperty('clearCache', false);
if (!empty($syncSite) || !empty($clearCache)) {
$this->modx->cacheManager->refresh(array('db' => array(), 'auto_publish' => array('contexts' => array($this->object->get('context_key'))), 'context_settings' => array('contexts' => array($this->object->get('context_key'))), 'resource' => array('contexts' => array($this->object->get('context_key')))));
}
}
开发者ID:rosstimson,项目名称:revolution,代码行数:12,代码来源:update.class.php
注:本文中的modResource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论