本文整理汇总了PHP中Node::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::load方法的具体用法?PHP Node::load怎么用?PHP Node::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
public function set($value, &$node)
{
if (empty($value) or !is_array($value)) {
return;
}
switch ($value['error']) {
case UPLOAD_ERR_OK:
$value = Node::create('file')->import($value);
break;
case UPLOAD_ERR_INI_SIZE:
throw new RuntimeException(t('Размер файла превышает установленное в системе ограничение (%size).', array('%size' => ini_get('upload_max_filesize'))));
case UPLOAD_ERR_FORM_SIZE:
throw new RuntimeException(t('Размер файла превышает установленное в форме ограничение.'));
case UPLOAD_ERR_PARTIAL:
throw new RuntimeException(t('Файл получен не полностью.'));
case UPLOAD_ERR_NO_FILE:
if (!empty($value['id']) and is_numeric($value['id'])) {
$value = Node::load($value['id']);
} elseif (!empty($value['url'])) {
$value = FileNode::fromURL($value['url']);
} elseif (!empty($value['ftp'])) {
$value = Node::create('file')->importFromFTP(array_shift($value['ftp']));
} elseif (!empty($value['unlink'])) {
$node->linkRemoveChild(null, $this->value);
$value = null;
} else {
$value = $node->{$this->value};
}
}
if ($this->required and empty($value)) {
throw new ValidationException($this->label, t('Вы не загрузили файл в поле «%name», хотя оно отмечено как обязательное.', array('%name' => mb_strtolower($this->label))));
}
$node->{$this->value} = $value;
}
示例2: rpc_get_default
public static function rpc_get_default(Context $ctx)
{
$user = Node::load(array('class' => 'user', 'deleted' => 0, 'published' => 1, 'id' => $ctx->get('id')), $ctx->db);
$email = $user ? $user->email : 'john.doe@example.com';
$gurl = 'http://www.gravatar.com/avatar/' . md5($email);
if (null !== ($s = $ctx->get('s'))) {
$gurl .= '?s=' . intval($s) . '&r=x';
}
return new Redirect($gurl);
}
示例3: on_post_detach
/**
* Открепление файлов от ноды.
*/
public static function on_post_detach(Context $ctx)
{
if (is_array($ids = $ctx->post('remove'))) {
$ctx->db->beginTransaction();
$params = array();
Node::load($ctx->get('id'), $ctx->db)->touch(ACL::UPDATE)->onSave('DELETE FROM `node__rel` WHERE `tid` = %ID% AND `key` IS NULL AND `nid` ' . sql::in($ids, $params), $params)->save();
$ctx->db->commit();
}
return $ctx->getRedirect();
}
示例4: onInstall
/**
* Добавляет тип документа label.
*
* @mcms_message ru.molinos.cms.install
*/
public static function onInstall(Context $ctx)
{
try {
$node = Node::load(array('class' => 'type', 'name' => 'label'), $ctx->db);
} catch (ObjectNotFoundException $e) {
$ctx->db->beginTransaction();
$node = Node::create(array('class' => 'type', 'name' => 'label', 'label' => t('Метка'), 'isdictionary' => true, 'fields' => array('name' => array('type' => 'TextLineControl', 'title' => t('Метка'), 'required' => true))), $ctx->db)->save();
$ctx->db->commit();
}
}
示例5: on_get_list
public static function on_get_list(Context $ctx)
{
$xml = $ctx->db->getResult("SELECT `xmltree` FROM `node` WHERE `class` = 'tag' AND `parent_id` IS NULL");
if (empty($xml)) {
$node = Node::load(array('class' => 'tag', 'deleted' => 0, 'parent_id' => null), $ctx->db);
$xml = $node->getTreeXML(false, true);
}
$data = html::em('data', $xml);
return html::em('content', array('edit' => true, 'nosearch' => true, 'name' => 'list', 'title' => t('Карта разделов сайта'), 'preset' => 'taxonomy'), $data);
}
示例6: rebuild
/**
* Воссоздаёт контролы из БД.
*/
public static function rebuild(Database $db, $className)
{
try {
$node = Node::load(array('class' => 'type', 'name' => $className, 'deleted' => 0), $db);
$schema = (array) $node->fields;
} catch (ObjectNotFoundException $e) {
$schema = array();
}
return $schema;
}
示例7: onInstall
/**
* Инсталляция типа документа subscription.
*
* @mcms_message ru.molinos.cms.install
*/
public static function onInstall(Context $ctx)
{
try {
$node = Node::load(array('class' => 'type', 'name' => 'subscription', 'deleted' => 0), $ctx->db);
} catch (ObjectNotFoundException $e) {
$ctx->db->beginTransaction();
$node = Node::create('type', array('name' => 'subscription', 'title' => t('Подписка на новости')))->save();
$ctx->db->commit();
}
}
示例8: getEmail
private static function getEmail(Context $ctx)
{
if ($id = $ctx->config->get('modules/admin/admin')) {
try {
$node = Node::load(array('id' => $id, 'class' => 'user'));
return $node->getEmail();
} catch (ObjectNotFoundException $e) {
}
}
}
示例9: update_node_xml
/**
* Обновление XML ноды и всех её связей.
*/
private static function update_node_xml(Node $node)
{
if ($ids = self::get_ids($node)) {
$upd = $node->getDB()->prepare("UPDATE `node` SET `xml` = ? WHERE `id` = ?");
foreach ($ids as $id) {
$upd->execute(array(Node::load($id, $node->getDB())->getXML(), $id));
Logger::log("node[{$id}]: XML updated", 'xml');
}
}
}
示例10: testLoadNode
public function testLoadNode()
{
$id = get_test_context()->db->getResult("SELECT `id` FROM `node` WHERE `deleted` = 0 AND `class` = 'type' AND `name` = 'domain'");
$this->assertNotEquals(null, $id);
$node = Node::load($id);
$this->assertTrue($node instanceof Node);
$this->assertEquals($id, $node->id);
$this->assertEquals('type', $node->class);
$this->assertEquals('domain', $node->name);
}
示例11: __get
public function __get($k)
{
if (!property_exists($this, $k)) {
if (property_exists($this, 'ref_' . $k) && null !== $this->{'ref_' . $k}) {
$this->{$k} = Node::load($this->{'ref_' . $k});
} else {
$this->{$k} = null;
}
}
return $this->{$k};
}
示例12: on_install
/**
* @mcms_message ru.molinos.cms.install
*/
public static function on_install(Context $ctx)
{
try {
$node = Node::load(array('class' => 'type', 'name' => 'tag', 'deleted' => 0), $ctx->db);
} catch (ObjectNotFoundException $e) {
$node = Node::create(array('class' => 'type', 'name' => 'tag', 'title' => t('Раздел'), 'fields' => array('name' => array('type' => 'TextLineControl', 'title' => t('Имя раздела'), 'required' => true))), $ctx->db);
$node->getDB()->beginTransaction();
$node->save();
$node->getDB()->commit();
}
}
示例13: rpc_get_restore
public static function rpc_get_restore(Context $ctx)
{
$node = Node::load(array('class' => 'user', 'name' => $ctx->get('email'), 'deleted' => 0, 'published' => 1));
if ($ctx->get('otp') != $node->otp) {
throw new ForbiddenException(t('Эта ссылка устарела.'));
}
$ctx->db->beginTransaction();
unset($node->otp);
$node->save();
$ctx->db->commit();
$ctx->user->login($node->name, null, true);
Logger::log($node->name . ' logged in using OTP.', 'auth');
}
示例14: editNode
/**
*
*/
protected function editNode($node, $errors = array())
{
$node = ARONode::finder()->byPK((int) $node);
$this->tpl->assign('node', $node);
$nodevalues = Node::load($node->id);
$this->tpl->assign('values', !empty($_POST) ? (object) $_POST : $nodevalues);
$this->tpl->assign('errors', $errors);
$ct = $node->type;
$ct->prepFields();
$this->tpl->assign('ct', $ct);
$this->tpl->display('content/node_form.tpl.php');
// print_r($node);
}
示例15: updateXML
private static function updateXML($db)
{
$db->beginTransaction();
$upd = $db->prepare("UPDATE `node` SET `xml` = ? WHERE `id` = ?");
$sel = $db->exec("SELECT * FROM `node` WHERE `xml` IS NULL");
while ($row = $sel->fetch(PDO::FETCH_ASSOC)) {
$id = $row['id'];
unset($row['id']);
unset($row['xml']);
$node = Node::load($id, $db);
$upd->execute(array($node->getXML(), $id));
}
$db->commit();
}