本文整理汇总了PHP中modResource::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP modResource::getID方法的具体用法?PHP modResource::getID怎么用?PHP modResource::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modResource
的用法示例。
在下文中一共展示了modResource::getID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}