function run() { require_once $this->sysRoot . '/Model/mysqlModel.php'; require_once $this->sysRoot . '/Model/newsModel.php'; $newsModel = new newsModel($this->year, $this->news_id); $newsData = $newsModel->run(); if (!empty($newsData)) { // データが存在 require_once $this->sysRoot . '/Controller/templateController.php'; $imageAreaCode = ''; for ($i = 0; $i < $newsData['images']; $i++) { $imageAreaCode .= '<img src="' . NEWS_IMAGE_PATH . $newsData['image_src' . ($i + 1)] . '" alt="' . $newsData['image_alt' . ($i + 1)] . '" class="newsImg">'; } $tpl = new templateController($this->sysRoot); $tpl->news_id = $newsData['news_id']; $tpl->title = $newsData['title']; $tpl->created = $newsData['created']; $tpl->jpcreated = $newsData['jpcreated']; $tpl->content = $newsData['content']; $tpl->author = $newsData['author']; $tpl->year = $this->year; $tpl->newsLink = $this->helpers->newsLink(); $tpl->imageArea = $imageAreaCode; $tpl->show($this->sysRoot . '/View/news.php'); } else { // データが存在しない // So, redirect header('Location: /news/'); } }
function run() { require_once $this->sysRoot . '/Controller/templateController.php'; $tpl = new templateController($this->sysRoot); $filePath = $this->sysRoot . '/View/' . $this->controller . 'View.php'; $tpl->show($filePath); }
function run() { require_once $this->sysRoot . '/Model/mysqlModel.php'; require_once $this->sysRoot . '/Model/newsListModel.php'; $newsListModel = new newsListModel($this->year); $newsData = $newsListModel->run(); if (!empty($newsData)) { // データが存在 $code = ''; for ($i = 0; $i < count($newsData); $i++) { $code .= '<li><a href="/news/' . $newsData[$i]['year'] . '/' . $newsData[$i]['news_id'] . '">'; $code .= '<div>'; $code .= '<p><time datetime="' . $newsData[$i]['created'] . '">' . $newsData[$i]['jpcreated'] . '</time></p>'; $code .= '<p><span class="' . $this->helpers->teamsClass[$newsData[$i]['team']] . '">' . $this->helpers->teamsName[$newsData[$i]['team']] . '</span></p>'; $code .= '</div>'; $code .= '<p class="newstitle">' . $newsData[$i]['title'] . '</p>'; $code .= '</a></li>'; } require_once $this->sysRoot . '/Controller/templateController.php'; $tpl = new templateController($this->sysRoot); $tpl->newsList = $code; $tpl->year = $this->year; $tpl->newsLink = $this->helpers->newsLink(); $tpl->show($this->sysRoot . '/View/newsList.php'); } else { // データが存在しない // So, redirect header('Location: /news/'); } }
function run() { // もし、渡されたファイル名のファイルが存在すればそれをreadfile, else notFoundをreadfile require_once $this->sysRoot . '/Controller/templateController.php'; $tpl = new templateController($this->sysRoot); $filePath = $this->sysRoot . '/View/' . $this->params[1]; if (file_exists($filePath)) { // ファイルが存在 $tpl->show($filePath); } else { // notFoundを送信 header('HTTP/1.0 404 Not Found'); $tpl->show($this->sysRoot . '/View/notFound.html'); } }
function run() { require_once $this->sysRoot . '/Model/mysqlModel.php'; require_once $this->sysRoot . '/Model/indexModel.php'; $indexModel = new indexModel(); $newsData = $indexModel->run(); // newsDataを利用してcodeを生成 $code = ''; for ($i = 0; $i < count($newsData); $i++) { $imgPath = ''; if (0 < $newsData[$i]['images']) { // 画像が存在する // So, display it. $imgPath = NEWS_IMAGE_PATH . $newsData[$i]['image_src1']; $imgAlt = $newsData[$i]['image_alt1']; } else { // 画像が存在しない // teamによって表示させる画像を切り替える $imgPath = $this->helpers->teamsImg[$newsData[$i]['team']]; $imgAlt = $this->helpers->teamsName[$newsData[$i]['team']]; } // split for php5.2 $code .= '<li><a href="/news/'; $code .= $newsData[$i]['year']; $code .= '/'; $code .= $newsData[$i]['news_id']; $code .= '">'; $code .= '<div><img src="' . $imgPath . '" alt="' . $imgAlt . '" style="width: 200px;"></div>'; // split for php5.2 //$code .= '<p>' . $newsData[$i]['jpcreated'] . ' / ' . $this->helpers->teamsName[$newsData[$i]['team']] . '</p>'; $code .= '<p>'; $code .= $newsData[$i]['jpcreated']; $code .= ' / '; $code .= $this->helpers->teamsName[$newsData[$i]['team']]; $code .= '</p>'; $code .= '<p>' . $newsData[$i]['title'] . '</p>'; $code .= '</a></li>'; } require_once $this->sysRoot . '/Controller/templateController.php'; $tpl = new templateController($this->sysRoot); $tpl->newsList = $code; $tpl->show($this->sysRoot . '/View/index.php'); }
$tmpl = preg_replace('~\\[endloop:[^\\]]+\\]~', '', $tmpl); $tmpl = str_replace('style="display:none"', '', $tmpl); $result = $holidays->get(10); foreach ($result['data'] as $rec) { $row = $tmpl; foreach ($rec as $k => $v) { if (is_array($v)) { continue; } $row = str_replace("[{$k}]", $v, $row); } $google_part .= $row; } } else { $google_part = '<h1>' . $description . '</h1>' . "\n"; $template = new templateController(); $template->init(); $countries = $template->countries(); $google_part .= '<ul>'; $countries = array_merge($countries, ['Majorka', 'Wyspy Kanaryjskie', 'Kreta', 'Kos']); sort($countries); foreach ($countries as $country) { $country = str_replace('Republika Południowej Afryki', 'RPA', $country); $country = str_replace('Trynidad I Tobago', 'Trynidad i Tobago', $country); $google_part .= '<li>'; $google_part .= '<a href="' . Tools::str_to_url($country) . '">'; $google_part .= $country; $google_part .= '</a></li>'; } $google_part .= '</ul>'; }