本文整理汇总了PHP中modResource::get方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::get方法的具体用法?PHP modResource::get怎么用?PHP modResource::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveFilesUnderCorrectResource
private function moveFilesUnderCorrectResource(&$md, $field)
{
$matches = array();
preg_match_all('~' . $this->uploadURL . '0/(?<file>[^ "\\)]+)~', $md, $matches);
$path = $this->uploadPath . '0/';
$correctPath = $this->uploadPath . $this->resource->id . '/';
if (!is_dir($correctPath)) {
mkdir($correctPath);
}
$files = $matches['file'];
if (!empty($files)) {
$files = array_map('trim', $files);
$files = array_keys(array_flip($files));
$files = array_filter($files);
foreach ($files as $file) {
rename($path . $file, $correctPath . $file);
}
$md = str_replace($this->uploadURL . '0/', $this->uploadURL . $this->resource->id . '/', $md);
if (strpos($field, 'tv')) {
$tvID = str_replace('tv', '', $field);
$content = str_replace($this->uploadURL . '0/', $this->uploadURL . $this->resource->id . '/', $this->resource->getTVValue($tvID));
$this->resource->setTVValue($tvID, $content);
} else {
if ($field == 'ta') {
$field = 'content';
}
$content = str_replace($this->uploadURL . '0/', $this->uploadURL . $this->resource->id . '/', $this->resource->get($field));
$this->resource->set($field, $content);
$this->resource->save();
}
}
}
示例2: process
/**
* {@inheritDoc}
*
* @return mixed
*/
public function process()
{
/* get resource */
$this->resource = $this->getResource();
if (!is_object($this->resource) || !$this->resource instanceof modResource) {
return $this->failure($this->resource);
}
/* get resource group */
$resourceGroup = $this->modx->getObject('modResourceGroup', $this->getProperty('id'));
if (empty($resourceGroup)) {
return $this->failure($this->modx->lexicon('resource_group_err_nf'));
}
/* get access */
$resourceGroupResource = $this->modx->getObject('modResourceGroupResource', array('document' => $this->resource->get('id'), 'document_group' => $resourceGroup->get('id')));
if ($this->getProperty('access') == true && $resourceGroupResource != null) {
return $this->failure($this->modx->lexicon('resource_group_resource_err_ae'));
}
if ($this->getProperty('access') == false && $resourceGroupResource == null) {
return $this->failure($this->modx->lexicon('resource_group_resource_err_nf'));
}
if ($this->getProperty('access') == true) {
$resourceGroupResource = $this->modx->newObject('modResourceGroupResource');
$resourceGroupResource->set('document', $this->resource->get('id'));
$resourceGroupResource->set('document_group', $resourceGroup->get('id'));
$resourceGroupResource->save();
} else {
if ($resourceGroupResource instanceof modResourceGroupResource) {
$resourceGroupResource->remove();
}
}
return $this->success();
}
示例3: 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);
}
示例4: 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;
}
示例5: 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);
}
示例6: 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));
}
}
示例7: 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);
}
示例8: 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'];
}
示例9: 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')))));
}
}
示例10: getChanges
public function getChanges(array $resourceArray)
{
$emptyDate = '0000-00-00 00:00:00';
$resourceArray['pub_date'] = !empty($resourceArray['pub_date']) && $resourceArray['pub_date'] != $emptyDate ? $resourceArray['pub_date'] : $this->modx->lexicon('none');
$resourceArray['unpub_date'] = !empty($resourceArray['unpub_date']) && $resourceArray['unpub_date'] != $emptyDate ? $resourceArray['unpub_date'] : $this->modx->lexicon('none');
$resourceArray['status'] = $resourceArray['published'] ? $this->modx->lexicon('resource_published') : $this->modx->lexicon('resource_unpublished');
$server_offset_time = intval($this->modx->getOption('server_offset_time', null, 0));
$resourceArray['createdon_adjusted'] = strftime('%c', strtotime($this->resource->get('createdon')) + $server_offset_time);
$resourceArray['createdon_by'] = $this->resource->get('creator');
if (!empty($resourceArray['editedon']) && $resourceArray['editedon'] != $emptyDate) {
$resourceArray['editedon_adjusted'] = strftime('%c', strtotime($this->resource->get('editedon')) + $server_offset_time);
$resourceArray['editedon_by'] = $this->resource->get('editor');
} else {
$resourceArray['editedon_adjusted'] = $this->modx->lexicon('none');
$resourceArray['editedon_by'] = $this->modx->lexicon('none');
}
if (!empty($resourceArray['publishedon']) && $resourceArray['publishedon'] != $emptyDate) {
$resourceArray['publishedon_adjusted'] = strftime('%c', strtotime($this->resource->get('editedon')) + $server_offset_time);
$resourceArray['publishedon_by'] = $this->resource->get('publisher');
} else {
$resourceArray['publishedon_adjusted'] = $this->modx->lexicon('none');
$resourceArray['publishedon_by'] = $this->modx->lexicon('none');
}
return $resourceArray;
}
示例11: fireOnTVFormRender
/**
* Fire the TV Form Render event
* @return mixed
*/
public function fireOnTVFormRender()
{
$onResourceTVFormPrerender = $this->modx->invokeEvent('OnResourceTVFormPrerender', array('resource' => $this->resource->get('id')));
if (is_array($onResourceTVFormPrerender)) {
$onResourceTVFormPrerender = implode('', $onResourceTVFormPrerender);
}
$this->setPlaceholder('OnResourceTVFormPrerender', $onResourceTVFormPrerender);
return $onResourceTVFormPrerender;
}
示例12: checkIfSiteStart
/**
* Quick check to make sure it's not site_start, if so, publish if not published to prevent site error
*
* @return boolean
*/
public function checkIfSiteStart()
{
$saved = false;
if ($this->object->get('id') == $this->workingContext->getOption('site_start') && !$this->object->get('published')) {
$this->object->set('published', true);
$saved = $this->object->save();
}
return $saved;
}
示例13: get
function get($k, $format = NULL, $formatTemplate = NULL)
{
switch ($k) {
case 'url':
return $this->makeUrl();
break;
}
return parent::get($k, $format, $formatTemplate);
}
示例14: 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/create', $data);
if (!$response->isError()) {
$tempRes = $response->getObject();
$this->resource = $this->modx->getObject('modResource', $tempRes['id']);
/* Make sure the createdby column is set */
$cb = $this->resource->get('createdby');
if (empty($cb)) {
$this->resource->set('createdby', $this->modx->user->get('id'));
$this->resource->save();
}
$this->setPlaceholders(array('message' => 'Resource created.', 'resid' => $this->resource->get('id'), 'ctx' => $this->resource->get('context_key')));
} else {
$error = $response->getAllErrors();
$this->setPlaceholder('message', 'Something went wrong creating the Resource: ' . implode(', ', $error));
}
}
示例15: 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;
}