public static function __import__() { self::$BASE_PATH = Rhaco::def("core.Template@path", Rhaco::path("templates")); self::$BASE_URL = Rhaco::def("core.Template@url", Rhaco::url("templates")); self::$CACHE = Rhaco::def("core.Template@cache", false); self::$CACHE_TIME = Rhaco::def("core.Template@time", 86400); }
<?php require_once '__init__.php'; Rhaco::import('generic.Urls'); Rhaco::import('model.Todo'); Rhaco::import('model.Category'); $db = new DbUtil(Category::connection()); $patterns = array('^$' => array('class' => 'generic.Views', 'method' => 'read', 'args' => array(new Todo(), new C(Q::eq(Todo::columnClose(), false), Q::fact())), 'template' => 'list.html'), '^detail/(\\d+)$' => array('method' => 'detail', 'args' => array(new Todo(), new C(Q::fact()))), '^create$' => array('method' => 'create', 'args' => array(new Todo(), Rhaco::url())), '^update/(\\d+)$' => array('method' => 'update', 'args' => array(new Todo(), null, Rhaco::url())), '^delete/(\\d+)$' => array('method' => 'delete', 'args' => array(new Todo(), null, Rhaco::url())), '^cat/(\\d+)$' => array('method' => 'detail', 'args' => array(new Category(), new C(Q::depend())))); $parser = Urls::parser($patterns, $db); $parser->setVariable('categories', $db->select(new Category())); $parser->write();
<?php require dirname(__FILE__) . '/__init__.php'; Rhaco::import('generic.Flow'); Rhaco::import('network.http.Header'); $flow = new Flow(); if (!$flow->isVariable('id')) { Header::redirect(Rhaco::url()); } $db = new DbUtil(Event::connection()); if ($flow->isPost() && $flow->isVariable('pass')) { $participant = $db->get(new Participant($flow->getVariable('id'))); if (Variable::istype('Participant', $participant) && $participant->hash === $flow->getVariable('pass')) { $db->delete($participant); Header::redirect(Rhaco::url()); } } $flow->setVariable('hatena', Rhaco::obj('HatenaSyntax', array('headlevel' => 4, 'id' => 'event_description'))); $flow->write('cancel.html');
/** * アプリケーションのurlを取得する * * @param string $path * @return string */ function url($path = null) { return Rhaco::url($path); }
<?php require './__init__.php'; Rhaco::import('generic.Views'); Rhaco::import('model.Todo'); $views = new Views(); $views->create(new Todo(), Rhaco::url('views.php'))->write();
function __init__($url, $endPointUrl) { $this->url = is_null($url) ? Rhaco::url() : $url; $this->endPointUrl = is_null($endPointUrl) ? Rhaco::url('login') : $endPointUrl; }
/** * urlパスを返す * * @param string $path * @return string */ public static final function url($path = null) { return Rhaco::url($path); }
<?php require dirname(__FILE__) . '/__init__.php'; $id = isset($_GET['stage_id']) ? $_GET['stage_id'] : null; if (is_numeric($id)) { header('location: ' . Rhaco::url('play/') . $id); exit; } header('location: ' . Rhaco::url());
function upload() { if ($this->isPost() && $this->isFile('stage')) { $file = $this->getFile('stage'); $src = mb_convert_encoding(file_get_contents($file->tmp), 'utf-8', 'Shift_JIS,EUC-JP,UTF-8'); if (SimpleTag::setof($tag, $src, 'body', true)) { foreach ($tag->getIn('applet') as $applet) { if ($applet->getParameter('code') != 'MasaoConstruction') { continue; } $gamedata = array(); foreach ($applet->getIn('param') as $param) { $gamedata[$param->getParameter('name')] = array('name' => $param->getParameter('name'), 'value' => $param->getParameter('value')); } if (empty($gamedata)) { break; } $stage = $this->dbUtil->insert($this->toObject(new Stage())); if (!Variable::istype('Stage', $stage)) { break; } $_images = array('title', 'ending', 'gameover', 'pattern', 'chizu'); foreach ($_images as $k) { if (!isset($gamedata[sprintf("filename_%s", $k)])) { continue; } $gamedata[sprintf("filename_%s", $k)] = array('name' => sprintf("filename_%s", $k), 'value' => 'images/' . $k . '.gif'); if ($this->isFile('img_' . $k)) { $image = $this->getFile('img_' . $k); $img_info = getimagesize($image->tmp); if ($img_info[2] != IMAGETYPE_GIF) { continue; } $filename = Rhaco::path(sprintf('images/%s_%d.gif', $k, $stage->id)); if (move_uploaded_file($image->tmp, $filename)) { $gamedata[sprintf("filename_%s", $k)] = array('name' => sprintf("filename_%s", $k), 'value' => sprintf("images/%s_%d.gif", $k, $stage->getId())); } } } FileUtil::write(Rhaco::path(sprintf('stages/%d.apif', $stage->id)), serialize($gamedata)); Header::redirect(Rhaco::url()); Rhaco::end(); } } } return $this->parser('upload.html'); }