/** * Methode : page de détail d'un article */ public function show($idActualite = FALSE) { if (!$idActualite || !is_numeric($idActualite)) { return parent::redirect_erreur('articles'); } cookie::set('UserFilesPath', url::base() . '../images/articles/' . $idActualite); cookie::set('UserFilesAbsolutePath', DOCROOT . '../images/articles/' . $idActualite); if (!cookie::get('UserFilesPath')) { return url::redirect('articles/show/' . $idActualite); } if (!($actualite = $this->acticles->select(array('id_article' => $idActualite), TRUE))) { return parent::redirect_erreur('articles'); } $actualiteCategories = $this->acticles->selectListeCategories(); $this->script = array('js/lib/jquery.validate', 'js/articles'); $this->css = array('form', 'article'); $this->template->titre = array(Kohana::lang('article.all_article') => 'articles', $actualite->title => NULL); $this->template->button = TRUE; $this->template->navigation = $this->acticles->navigation($idActualite, 'id_article', 'articles'); $this->template->navigationURL = 'articles/show'; $this->template->contenu = new View('formulaire/form'); $this->template->contenu->action = 'articles/save'; $this->template->contenu->id = $idActualite; $this->template->contenu->formulaire = new View('articles/show'); $this->template->contenu->formulaire->row = $actualite; $this->template->contenu->formulaire->actualiteCategories = $actualiteCategories; $this->template->contenu->formulaire->regions = Region_Model::instance()->listing_parent(); }
/** * Méthode : pour empêcher un utilisateur d'accéder directement à ce controller */ public function index() { $regionManager = Region_Model::instance(); if (!($region = $regionManager->select(array('id' => $this->user->id), 1))) { $insert = array('name' => $this->user->username, 'id' => $this->user->id, 'x' => 50, 'y' => 50, 'z' => 50, 'background_color' => '0x8fa2ff'); $regionManager->insert($insert); $region = $regionManager->select(array('id' => $this->user->id), 1); } $elements = FALSE; if (($rows = Map_Model::instance()->select(array('region_id' => $this->user->id))) !== FALSE) { foreach ($rows as $row) { $listOptimise[$row->x][$row->y][$row->z] = true; } foreach ($rows as $row) { if (!isset($listOptimise[$row->x + 1][$row->y][$row->z]) || !isset($listOptimise[$row->x - 1][$row->y][$row->z]) || !isset($listOptimise[$row->x][$row->y + 1][$row->z]) || !isset($listOptimise[$row->x][$row->y - 1][$row->z]) || !isset($listOptimise[$row->x][$row->y][$row->z + 1]) || !isset($listOptimise[$row->x][$row->y][$row->z - 1])) { $elements[] = '{"x" : "' . $row->x . '", "z" : "' . $row->z . '", "y" : "' . $row->y . '", "materials" : [ "' . $row->background_px . '", "' . $row->background_nx . '", "' . $row->background_py . '", "' . $row->background_ny . '", "' . $row->background_pz . '", "' . $row->background_nz . '" ] }'; } else { Map_Model::instance()->delete((array) $row); } } } $this->script = array('js/lib/three.control', 'js/lib/jquery.facebox', 'js/editor'); $this->css = array('css/core', 'css/editor', 'css/facebox'); $this->template->content = new View('editor/index'); $this->template->content->region = json_encode($region); $this->template->content->elements = $elements ? implode(',' . "\n", $elements) : FALSE; }
/** * Methode : page de détail d'un utilisateur */ public function show($idUser) { if (!($user = $this->user->select(array('id' => $idUser), TRUE))) { parent::redirect_erreur('users'); } $role = new Roles_Model(); $listeRole = $role->liste(); $roleUser = $role->selectUser($idUser); $this->script = array('js/lib/jquery.validate', 'js/lib/jquery.facebox', 'js/users'); $this->css = array('form', 'facebox', 'user'); $this->template->titre = array(Kohana::lang('user.all_user') => 'users', Kohana::lang('user.show_name', ucfirst(mb_strtolower($user->username))) => NULL); $this->template->button = TRUE; $this->template->navigation = parent::navigation($idUser, 'id', 'users'); $this->template->contenu = new View('formulaire/form'); $this->template->contenu->action = 'users/save'; $this->template->contenu->id = $idUser; $this->template->contenu->formulaire = new View('users/show'); $this->template->contenu->formulaire->row = $user; $this->template->contenu->formulaire->roles = $listeRole; $this->template->contenu->formulaire->roleUser = $roleUser; $this->template->contenu->formulaire->regions = Region_Model::instance()->listing_parent(); $this->template->contenu->formulaire->avatar = file::listing_dir(DOCROOT . '../images/character'); }
/** * Methode : gestion du listing en ajax */ public function resultatAjax() { $this->auto_render = FALSE; if (!request::is_ajax()) { return FALSE; } $arrayCol = array('id', 'title', 'module_map', 'region_id', 'x', 'y', 'z'); $searchAjax = Search_Model::instance(); $arrayResultat = $searchAjax->indexRecherche($arrayCol, 'map', $this->input, array('module_map !=' => '')); $display = false; $list_carte = Region_Model::instance()->listing_parent(); foreach ($arrayResultat as $row) { $v[] = '<center>' . $row->id . '</center>'; $v[] = $row->title ? $row->title : '<strong class="rouge">' . Kohana::lang('form.inconnu') . '</strong>'; $v[] = '<center>' . $row->module_map . '</center>'; $v[] = '<center>' . $list_carte[$row->region_id]->name . '</center>'; $v[] = '<center>' . $row->x . '</center>'; $v[] = '<center>' . $row->y . '</center>'; $v[] = '<center>' . $row->z . '</center>'; $display .= '[' . parent::json($v) . '],'; unset($v); } echo $searchAjax->displayRecherche($display, $this->input->get('sEcho')); }
/** * Gestion fonction region * * @return void */ public function fonction() { $this->auto_render = FALSE; if (!request::is_ajax() || !($value = $this->input->post())) { return; } $array = array(); $array['fonction'] = isset($value['fonction']) ? $value['fonction'] : FALSE; Region_Model::instance()->update($array, $value['id']); }
/** * Méthode : */ public function index(&$view) { $view->region = Region_Model::instance()->listing_parent(); }
/** * Générer un JSON * * @return void */ public function index($render = TRUE) { $json = new View('map/json'); $json->my = $this->user; if (!($this->region = Region_Model::instance()->select(array('id' => $this->user->region_id), 1))) { return FALSE; } $json->items = Item_Model::instance()->select(); $elements = $modules = $items = FALSE; if (($rows = Map_Model::instance()->select(array('region_id' => $this->region->id), FALSE)) !== FALSE) { $prenoms = Name_Model::instance()->select(); $listName = array(); foreach ($prenoms as $prenom) { $listName[] = ucfirst(mb_strtolower($prenom->prenom)); } $images = file::listing_dir(DOCROOT . 'images/character'); foreach ($rows as $row) { if (!$row->module_map && !$row->bot) { $elements[] = '{"x" : ' . $row->x . ', "z" : ' . $row->z . ', "y" : ' . $row->y . ', "subX" : ' . $row->subX . ', "subZ" : ' . $row->subZ . ', "subY" : ' . $row->subY . ', "materials" : [ "' . $row->background_px . '", "' . $row->background_nx . '", "' . $row->background_py . '", "' . $row->background_ny . '", "' . $row->background_pz . '", "' . $row->background_nz . '" ] }'; } else { $data = @unserialize($row->action_map); $action = json_encode($data); if ($row->module_map == 'article') { $article = Article_Model::instance()->select(array('id_article' => $data->id_article, 'article_category_id' => 2, 'status' => 1), 1); $modules[] = '{"x" : ' . $row->x . ', "z" : ' . $row->z . ', "y" : ' . $row->y . ', "subX" : ' . $row->subX . ', "subZ" : ' . $row->subZ . ', "subY" : ' . $row->subY . ', "data" : ' . $action . ', "article" : ' . json_encode($article->article) . ' }'; } elseif ($row->bot) { $v = new stdClass(); $v->id = 0; $v->name = $row->bot ? $row->title : $listName[array_rand($listName)]; $v->x = $row->x; $v->y = $row->y; $v->z = $row->z; $v->region_id = $row->region_id; $v->user_id = $this->user->id; if ($row->bot == 2) { $v->image = 'animals/bears.png'; } elseif ($row->bot == 3) { $v->image = 'animals/dog.png'; } else { $v->image = 'character/' . $images[array_rand($images)]; } $v->hp_max = 100; $v->hp = 100; $v->leak = 0; $v->type = $row->bot; $v->fixe = $row->bot && !$row->module_map ? 0 : 1; $v->argent = 1000; $v->xp = 10; $v->niveau = 0; $this->botFixe[] = $v; if ($row->module_map == 'quete') { $modules[] = '{"x" : ' . $row->x . ', "z" : ' . $row->z . ', "y" : ' . ($row->y - 1) . ', "subX" : ' . $row->subX . ', "subZ" : ' . $row->subZ . ', "subY" : ' . $row->subY . ', "data" : ' . $action . ', "article" : "" }'; } } else { $modules[] = '{"x" : ' . $row->x . ', "z" : ' . $row->z . ', "y" : ' . ($row->y - 1) . ', "subX" : ' . $row->subX . ', "subZ" : ' . $row->subZ . ', "subY" : ' . $row->subY . ', "data" : ' . $action . ', "article" : "" }'; } } } } $articles = Article_Model::instance()->select(array('region_id' => $this->region->id, 'article_category_id' => 2, 'status' => 1)); $articlesList = null; if ($articles) { foreach ($articles as $row) { $articlesList[] = json_encode($row->reponse ? $row->article . '<div class="reponse">' . $row->reponse . '</div>' : $row->article); } } $this->region->map = new stdClass(); $this->region->map->region = $this->region; $this->region->map->elements = $elements ? implode(',', $elements) : FALSE; $this->region->map->modules = $modules ? implode(',', $modules) : FALSE; $this->region->map->articles = $articlesList ? implode(',', $articlesList) : FALSE; $this->region->map->region->bots = $this->botFixe; $json->region = $this->region; $sounds = file::listing_dir(DOCROOT . 'audios', array('home.mp3')); $json->sounds = $sounds ? json_encode($sounds) : FALSE; return $json->render($render); }
public function __construct() { parent::__construct(); parent::access('region'); $this->region = Region_Model::instance(); }