本文整理汇总了PHP中Node::get_node方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::get_node方法的具体用法?PHP Node::get_node怎么用?PHP Node::get_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::get_node方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: def_module_uninstall
public static function def_module_uninstall($model)
{
$node = Node::get_node(constant("{$model}::Root"));
if ($node) {
$node->remove();
}
}
示例2: get_setting
public static function get_setting($name, $def = '')
{
if (!self::$_loaded_settings) {
$settings_node = Node::get_node(self::Root, __CLASS__);
if (!$settings_node) {
self::$_loaded_settings = array();
} else {
self::$_loaded_settings = SJson::deserialize($settings_node->data);
}
}
return array_key_exists($name, self::$_loaded_settings) ? self::$_loaded_settings[$name] : $def;
}
示例3: is_empty_users
public static function is_empty_users()
{
$users = Node::get_node('users');
if (!$users) {
return true;
}
// пустить, если модуль не активен
if (!count($users->childs)) {
return true;
}
// пустить если нет ни одного пользователя
$has_pwd = false;
foreach ($users->childs as $child) {
if (strlen($child->attr('pwd_hash'))) {
$has_pwd = true;
break;
}
}
return !$has_pwd;
// пустить если не установлено ни одного пароля
}
示例4: install
protected function install($module)
{
$node = Node::get_node('site');
if (!$node) {
$this->message('Creating root node');
Node::create_node(Node::Folder, 'site', conf_get('sitename'), Node::Visible | Node::System);
} else {
$this->message('Updating root node');
$node->title = conf_get('sitename');
$node->save();
}
if ($module) {
$this->call_module_method($module, 'module_install', 'Installing');
return;
}
if (!($dh = opendir(CMS . 'modules/'))) {
$this->message('"' . CMS . 'modules/" not found');
return;
}
$avail_modules = array();
while (($module = readdir($dh)) !== false) {
if (!is_dir(CMS . "modules/{$module}") || !is_readable(CMS . "modules/{$module}/admin.php")) {
continue;
}
require_once CMS . "modules/{$module}/admin.php";
$class_name = Cms::capitalize_words($module) . 'AdminModule';
if (!is_callable(array($class_name, 'module_install'))) {
continue;
}
$before = array();
$after = array();
if (is_callable(array($class_name, '_before'))) {
$before = call_user_func(array($class_name, '_before'));
if (!is_array($before)) {
$before = array($before);
}
}
if (is_callable(array($class_name, '_after'))) {
$after = call_user_func(array($class_name, '_after'));
if (!is_array($after)) {
$after = array($after);
}
}
$avail_modules[$module] = array('class' => $class_name, 'before' => $before, 'after' => $after);
}
closedir($dh);
foreach ($avail_modules as $mod_name => $item) {
foreach ($item['after'] as $name) {
if (!array_key_exists($name, $avail_modules)) {
$this->message("\"{$mod_name}\" depends on \"{$name}\", but \"{$name}\" not found");
return;
}
}
}
foreach ($avail_modules as $mod_name => $item) {
foreach ($item['before'] as $name) {
if (array_key_exists($name, $avail_modules)) {
if (!in_array($mod_name, $avail_modules[$name]['after'])) {
$avail_modules[$name]['after'][] = $mod_name;
}
}
}
}
$modules_list = array();
$modules_hash = array();
for (;;) {
$has_changes = false;
$has_modules = false;
foreach ($avail_modules as $mod_name => $item) {
if (array_key_exists($mod_name, $modules_hash)) {
continue;
}
$has_modules = true;
$can_insert = true;
foreach ($item['after'] as $name) {
if (!array_key_exists($name, $modules_hash)) {
$can_insert = false;
break;
}
}
if (!$can_insert) {
continue;
}
$class_name = $item['class'];
$modules_hash[$mod_name] = true;
$modules_list[] = $mod_name;
$has_changes = true;
}
if (!$has_modules) {
break;
}
if (!$has_changes) {
$this->message("Can't resolve modules dependencies");
return;
}
}
foreach ($modules_list as $module) {
$this->call_module_method($module, 'module_install', 'Installing');
}
}
示例5: can_put
protected function can_put($parent_path, $name, $type, $parent_node = null, $check_names = true)
{
if ($parent_node == null) {
$parent_node = Node::get_node($parent_path);
if ($parent_node == null) {
return 'Parent node not found';
}
} else {
$parent_path = $parent_node->full_path;
}
if ($check_names) {
if (array_key_exists($parent_node->type, $this->modules)) {
if (!$this->modules[$parent_node->type]->can_has_childs($parent_node)) {
return '@denied';
}
}
foreach ($parent_node->childs as $nd) {
if ($nd->name == $name) {
return "Путь \"{$nd->full_path}\" уже существует";
}
}
}
$res = $this->modules[$type]->can_put($parent_path, $parent_node);
return $res === null || $res === false ? '@denied' : $res;
}