Pogledajte određenu poruku
Staro 04. 10. 2011.   #2
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

Nemogu da objašnjavam, ovo sam davno nešto škrabao. U suštini proslediš array u template... http://en.wikipedia.org/wiki/Model%E...0%93controller

PHP kôd:
class View {
        
    public static function 
factory($file, array $array)
    {
        
extract($arrayEXTR_SKIP);
        
ob_start();
        include 
$file.'.php';
        return 
ob_get_clean();
    }
    
    public static function 
render()
    {
        global 
$html;
        
$content = &$html;
        
ob_start();
        include 
'views/template.php';
        echo 
ob_get_clean();
        return 
true;
    }
    


PHP kôd:
$date date('dmY'time());
$file ".cache/gallery/{$date}.json";

if(
file_exists($file) === true)
{
    
$json file_get_contents($file);
}
else
{
    
$json curl('https://graph.facebook.com/'.$id.'/photos?limit=200&offset=0&access_token='.$token);
    
file_put_contents($file$json);
}

$json json_decode($jsontrue);
foreach(
$json['data'] as $photo)
{
    
$gallery .= View::factory('views/gallery/photo', array('photo' => $photo));
}

$html .= View::factory('views/gallery/index', array('gallery' => $gallery));

View::render(); 
photo.php

PHP kôd:
<a href="<?=$photo['source']?>" class="modal" rel="foto"><img alt="" src="<?=$photo['images'][1]['source']?>"/></a>
__________________
Github // LinkedIn // PHP // ZCE // Stackoverflow PHP // Site5 Web Hosting
webarto je offline   Odgovorite uz citat