function tree($item, $parent) { $albums = ORM::factory("item")->where(array("parent_id" => $parent->id, "type" => "album"))->orderby(array("title" => "ASC"))->find_all(); $v = new View("organize_album.html"); $v->album = $parent; $v->selected = $parent->id == $item->id; if ($albums->count()) { $v->album_icon = $parent->id == 1 || $v->selected ? "ui-icon-minus" : "ui-icon-plus"; } else { $v->album_icon = ""; } $v->children = ""; foreach ($albums as $album) { $v->children .= $this->tree($item, $album); } return $v->__toString(); }
/** * @param string $class * @return boolean|string */ public static function dispatch($class) { if (!class_exists($class)) { include_once 'application/controllers/' . str_replace('_', '/', $class) . '.php'; } $instance = new $class(); $return = true; if (method_exists($instance, 'init')) { $params = array_slice(func_get_args(), 1); $return = call_user_func_array(array($instance, 'init'), $params); if (!(true === $return)) { if (is_string($return)) { Url::redirect($return); } return false; } } if (Request::getInstance()->isPost()) { if (!method_exists($instance, 'post')) { return false; } else { $return = $instance->post(); if (is_string($return)) { Url::redirect($return); } else { $url = new Url(); if (false === $return) { $url->addQuery('error', true); } Url::redirect($url); } return true; } } if (method_exists($instance, 'get')) { $return = $instance->get(); if (!(false === $return)) { $view = new View($class, $return); $viewContent = $view->__toString(); return $viewContent; } } return false; }
public function index($id) { $paths = unserialize(module::get_var("server_add", "authorized_paths")); $item = ORM::factory("item", $id); access::required("server_add", $item); access::required("add", $item); $view = new View("server_add_tree_dialog.html"); $view->action = url::abs_site("__ARGS__/{$id}__TASK_ID__?csrf=" . access::csrf_token()); $view->parents = $item->parents(); $view->album_title = $item->title; $tree = new View("server_add_tree.html"); $tree->data = array(); $tree->tree_id = "tree_{$id}"; foreach (array_keys($paths) as $path) { $tree->data[$path] = array("path" => $path, "is_dir" => true); } $view->tree = $tree->__toString(); print $view; }