Example #1
0
/**
 * Viatges "handler" 
 * @pages:
 *       view,
 *       add
 *       
 *
 * @return diferent contents
 */
function trip_page_handler($trip)
{
    $page = $trip[0];
    if (empty($page)) {
        ossn_error_page();
        //Mostra 404
    }
    // var_dump($trip);
    switch ($page) {
        //Vista viatge (Accés públic no existeix restricció de visualització)
        case 'view':
            $view = new OptionTrips();
            $viewAlbum = new OssnAlbums();
            $album = $viewAlbum->GetAlbum(19);
            //Agafa id del viatge
            $infoTrip = $view->GetTrip($trip[1]);
            //Agafa id del viatge
            $infoDays = $view->GetTripDays($trip[1]);
            // var_dump($image);
            //$photo['entity'] = $image;
            $trip['info'] = $infoTrip;
            $trip['day'] = $infoDays;
            $trip['album'] = $album;
            //redirect user to home page if trip is empty
            if (empty($infoTrip)) {
                redirect();
            }
            //Missing "back" button to trips
            $owner = ossn_user_by_guid($infoTrip->guid);
            $back = array('text' => ossn_print('back'), 'href' => ossn_site_url("u/{$owner->username}/trips"), 'class' => 'button-grey');
            $control = ossn_plugin_view('output/url', $back);
            $contents = array('title' => ossn_print('trip:details'), 'content' => ossn_plugin_view('trips/pages/trip/view', $trip), 'controls' => $control, 'module_width' => '850px');
            //inclou page layout
            $module['content'] = ossn_set_page_layout('module', $contents);
            //Inclou modul amb els botons d'accions
            $content = ossn_set_page_layout('contents', $module);
            echo ossn_view_page($title, $content);
            break;
            //Afegir viatge
        //Afegir viatge
        case 'add':
            //Missing "back" button to trips
            $owner = ossn_loggedin_user()->username;
            // var_dump($owner);
            $back = array('text' => ossn_print('back'), 'href' => ossn_site_url("u/{$owner}/trips"), 'class' => 'button-grey');
            $control = ossn_plugin_view('output/url', $back);
            $contents = array('title' => ossn_print('add:trip'), 'content' => ossn_plugin_view('trips/pages/trip/add'), 'controls' => $control, 'module_width' => '850px');
            //inclou page layout
            $module['content'] = ossn_set_page_layout('module', $contents);
            //Inclou modul amb els botons d'accions
            $content = ossn_set_page_layout('contents', $module);
            echo ossn_view_page($title, $content);
            // echo ossn_plugin_view('output/url', array(
            // 		'title' => ossn_print('add:trip'),
            // 		'contents' => ossn_plugin_view('trips/pages/trip/add'),
            // 		'callback' => '#ossn-trip-submit'
            // ));
            break;
        case 'addPhoto':
            //add photos (ajax)
            if (!ossn_is_xhr()) {
                ossn_error_page();
            }
            echo ossn_plugin_view('output/ossnbox', array('title' => ossn_print('add:photos'), 'contents' => ossn_plugin_view('trips/pages/trip/addPhoto'), 'callback' => '#photos-submit'));
            break;
        default:
            ossn_error_page();
            //Mostra 404
            break;
    }
}