本文整理汇总了PHP中Node::getDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getDB方法的具体用法?PHP Node::getDB怎么用?PHP Node::getDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::getDB方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: on_get_node_xml
/**
* Добавление произвольных файлов в XML ноды.
* @mcms_message ru.molinos.cms.node.xml
*/
public static function on_get_node_xml(Node $node)
{
if ($node instanceof FileNode) {
return;
}
return html::wrap('files', Node::findXML(array('class' => 'file', 'deleted' => 0, 'id' => $node->getDB()->getResultsV("nid", "SELECT `nid` FROM `node__rel` WHERE `tid` = ? AND `key` IS NULL", array($node->id))), $node->getDB()));
}
示例2: hookNodeUpdate
/**
* @mcms_message ru.molinos.cms.hook.node
*/
public static function hookNodeUpdate(Context $ctx, Node $node, $op)
{
switch ($op) {
case 'delete':
$node->onSave("UPDATE `node` SET `deleted` = 1 WHERE `class` = 'comment' AND `id` IN (SELECT `nid` FROM `node__rel` WHERE `tid` = %ID%");
break;
case 'erase':
$node->onSave("DELETE FROM `node` WHERE `class` = 'comment' AND `id` IN (SELECT `nid` FROM `node__rel` WHERE `tid` = %ID%)");
break;
case 'create':
if (!empty($node->doc) and is_numeric($nid = Node::_id($node->doc))) {
// Собираем прикреплённых пользователей.
$l1 = $node->getDB()->getResultsV("nid", "SELECT `nid` " . "FROM `node__rel` WHERE `tid` = ? AND `nid` IN (SELECT `id` " . "FROM `node` WHERE `class` = 'user')", array($nid));
// Собираем пользователей, комментировавших ранее
$l2 = $node->getDB()->getResultsV("uid", "SELECT `n`.`uid` " . "FROM `node` `n` " . "INNER JOIN `node__rel` `r` ON `r`.`nid` = `n`.`id` " . "WHERE `r`.`tid` = ? AND `n`.`class` = 'comment'", array($nid));
$uids = array_diff(array_unique(array_merge($l1, $l2)), array($ctx->user->id));
$body = mcms::render(__CLASS__, array('mode' => 'new', 'comment' => $node->getRaw()));
if (!empty($body) and !empty($uids)) {
foreach ($uids as $uid) {
if (empty($node->doc)) {
$subject = t('Новый комментарий');
} else {
$subject = t('Новый комментарий [%id]', array('%id' => Node::_id($node->doc)));
}
mcms::mail(null, $uid, $subject, $body);
}
}
}
}
}
示例3: on_node_change
/**
* Обновляет XML при изменении объекта.
* @mcms_message ru.molinos.cms.hook.node
*/
public static function on_node_change(Context $ctx, Node $node, $op)
{
if ($parents = Node::getNodeParentIds($node->getDB(), $node->id)) {
$params = array();
$node->getDB()->exec($sql = "UPDATE `node` SET `xmltree` = NULL WHERE `id` " . sql::in($parents, $params));
$upd = $node->getDB()->prepare("UPDATE `node` SET `xmltree` = ? WHERE `id` = ?");
while ($id = array_pop($parents)) {
$upd->execute(array(Node::load($id, $node->getDB())->getTreeXML(false), $id));
}
}
}
示例4: getLabelsFor
/**
* Возвращает список меток для документа.
*/
protected function getLabelsFor(Node $node)
{
if (!$node->id) {
return array();
}
return array_unique((array) $node->getDB()->getResultsKV('id', 'name', "SELECT `id`, `name` FROM `node` " . "WHERE `class` = 'label' AND `deleted` = 0 AND `id` " . "IN (SELECT `tid` FROM `node__rel` WHERE `nid` = ? AND `key` = ?)", array($node->id, $this->value . '*')));
}
示例5: hookNodeUpdate
/**
* Сборщик мусора.
*
* При удалении документов удаляет информацию о ревизии, связях и доступе к
* удаляемому объекту. Это позволяет отказаться от требования InnoDB и других
* типов БД, занимающихся каскадным удалением автоматически.
*
* @mcms_message ru.molinos.cms.hook.node
*
* @return void
*/
public static function hookNodeUpdate(Context $ctx, Node $node, $op)
{
switch ($op) {
case 'erase':
// Удаляем связи.
$node->getDB()->exec("DELETE FROM `node__rel` WHERE `nid` = :nid OR `tid` = :tid", array(':nid' => $node->id, ':tid' => $node->id));
break;
}
}
示例6: get_ids
private static function get_ids(Node $node)
{
$ids = array($node->id);
while (true) {
$params = array();
$sql = "SELECT DISTINCT `id` FROM `node` WHERE `deleted` = 0 AND `id` IN " . "(SELECT `tid` FROM `node__rel` WHERE `nid` " . sql::in($ids, $params) . ")" . " AND `id` " . sql::notIn($ids, $params);
$rows = $node->getDB()->getResultsV("id", $sql, $params);
if (empty($rows)) {
break;
}
foreach ($rows as $id) {
$ids[] = $id;
}
}
$params = array();
$ids = (array) $node->getDB()->getResultsV("id", "SELECT `id` FROM `node` WHERE `class` NOT IN ('tag', 'label') AND `id` " . sql::in($ids, $params), $params);
return array_reverse($ids);
}
示例7: reindexNode
private static function reindexNode(Node $node)
{
return;
$html = '';
$schema = Schema::load($node->getDB(), $node->class);
foreach ($schema['fields'] as $k => $v) {
if (isset($node->{$k})) {
$html .= '<strong>' . html::plain($v['label']) . '</strong>';
$html .= '<div class=\'data\'>' . $node->{$k} . '</div>';
}
}
$lang = empty($node->lang) ? 'en' : $node->lang;
$html = "HTTP/1.0 200 OK\n" . "Content-Type: text/html; charset=utf-8\n" . "Content-Language: {$lang}\n\n" . "<html><head><title>{$node->name}</title></head>" . "<body><h1>{$node->name}</h1>{$html}</body></html>";
try {
$node->getDB()->exec('DELETE FROM `node__searchindex` WHERE `nid` = :nid', array(':nid' => $node->id));
$node->getDB()->exec('INSERT INTO `node__searchindex` (`nid`, `url`, `html`) ' . 'VALUES (:nid, :url, :html)', array(':nid' => $node->id, ':url' => self::getNodeUrl($node), ':html' => $html));
} catch (TableNotFoundException $e) {
}
}
示例8: on_node_xml
/**
* Добавляет в XML нод информацию о разделах.
* @mcms_message ru.molinos.cms.node.xml
*/
public static function on_node_xml(Node $node)
{
list($sql, $params) = Query::build(array('class' => 'tag', 'deleted' => 0, 'tagged' => $node->id))->getSelect(array('id', 'published', 'name', 'class'));
$data = $node->getDB()->getResults($sql, $params);
$result = '';
foreach ($data as $row) {
$result .= html::em('node', $row);
}
return html::wrap('taxonomy', $result);
}
示例9: hookNodeUpdate
/**
* @mcms_message ru.molinos.cms.hook.node
*/
public static function hookNodeUpdate(Context $ctx, Node $node, $op)
{
if ($op == 'erase') {
$db = $node->getDB();
if ('user' == $node->class) {
$db->exec("DELETE FROM `node_rating` WHERE `nid` = :nid OR `uid` = :uid", array(':nid' => $node->id, ':uid' => $node->id));
} else {
$db->exec("DELETE FROM `node_rating` WHERE `nid` = :nid", array(':nid' => $node->id));
}
}
}
示例10: on_preview_tags
/**
* Добавляет информацию о разделах в предварительный просмотр.
* @mcms_message ru.molinos.cms.hook.preview.xml
*/
public static function on_preview_tags(Node $node)
{
if (!$node->checkPermission(ACL::UPDATE)) {
return;
}
if ($data = $node->getDB()->getResultsKV("id", "name", "SELECT `id`, `name` FROM `node` WHERE `deleted` = 0 AND `class` = 'tag' AND `id` IN (SELECT `tid` FROM `node__rel` WHERE `nid` = ?)", array($node->id))) {
$result = array();
foreach ($data as $k => $v) {
$result[] = html::em('a', array('href' => "admin/node/{$k}?destination=CURRENT"), html::plain($v));
}
$result = html::em('value', html::cdata(implode(', ', $result)));
return html::em('field', array('html' => true, 'title' => t('Находится в разделах'), 'editurl' => "admin/structure/taxonomy/setup?node={$node->id}&destination=" . urlencode(MCMS_REQUEST_URI)), $result);
}
}
示例11: on_node_hook
/**
* Удаление прав при удалении объектов.
* @mcms_message ru.molinos.cms.hook.node
*/
public static function on_node_hook(Context $ctx, Node $node, $op)
{
if ('erase' == $op) {
$node->getDB()->exec("DELETE FROM `node__access` WHERE `nid` = ? OR `uid` = ?", array($node->id, $node->id));
self::flush();
}
}
示例12: getNodeUrl
private static function getNodeUrl(Node $node)
{
return 'http://' . $_SERVER['HTTP_HOST'] . '/node/' . $node->id . '/';
$tag = $node->getDB()->getResults("SELECT `id`, `code` FROM `node` `n` " . "INNER JOIN `node__rel` `r` ON `r`.`tid` = `n`.`id` " . "WHERE `r`.`nid` = :nid AND `n`.`class` = 'tag' AND `n`.`deleted` = 0 AND `n`.`published` = 1", array(':nid' => $node->id));
$tag = $tag[0]['id'];
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $tag . '/' . $node->id . '/';
return $url;
}