przewiń do treści

PHP, MySQL i MVC
Tworzenie witryn WWW opartych na bazie danych

Włodzimierz Gajda

Okładka książki „PHP. Praktyczne projekty”

Listing 6.2.
Metoda execute_show() akcji koleda/show

ROZDZIAŁ:6. Translacja adresów URL
TXT:listing-06-02.txt
public function execute_show()
{
    if (
        isset($_GET['slug']) &&
        str_ivslug($_GET['slug']) &&
        in_array($_GET['slug'], $this->controller->dane[1])
    ) {
        $nr = array_search($_GET['slug'], $this->controller->dane[1]);
        $tekst = file_get_contents('koledy/' . $this->controller->dane[1][$nr] . '.txt');
        $this->set('tekst', $tekst);
        $nuty = file_exists('koledy/' . $this->controller->dane[1][$nr] . '.mus');
        $this->set('nuty', $nuty);
        $this->set('slug', $this->controller->dane[1][$nr]);
        $this->set('tytul', $this->controller->dane[0][$nr]);
    } else {
        $this->execute_404();
    }
}
©2010 Włodzimierz Gajda