<?php
/**
 * app/plugins/bookmarks/controllers/tutorials.php
 *
 * This is the tutorials controller.
 *
 * @package TP Bookmarks
 * @version 3.0
 * @author  Joey Kimsey <Joey@thetempusproject.com>
 * @link    https://TheTempusProject.com
 * @license https://opensource.org/licenses/MIT [MIT LICENSE]
 */
namespace TheTempusProject\Controllers;

use TheTempusProject\Houdini\Classes\Issues;
use TheTempusProject\Houdini\Classes\Views;
use TheTempusProject\Classes\Controller;
use TheTempusProject\Houdini\Classes\Navigation;
use TheTempusProject\Houdini\Classes\Components;
use TheTempusProject\Bedrock\Functions\Input;

class Tutorials extends Controller {
    public function __construct() {
        parent::__construct();
        self::$title = 'Tutorials - {SITENAME}';
        self::$pageDescription = 'We have detailed walkthroughs on how to perform a number of tasks for every major browser.';
    }

    public function index( $browser = '', $tutorial = '' ) {
        return Views::view( 'bookmarks.tutorials.list' );
    }
    
    public function brave( $tutorial = '' ) {
        Navigation::setCrumbComponent( 'tutorialCrumbs', Input::get( 'url' ) );

        if ( ! in_array( $tutorial, ['pin','settings','import','export'] ) ) {
            $test = new \stdClass();
            $test->pretty = 'Brave';
            $test->printed = 'brave';
            return Views::view( 'bookmarks.tutorials.card', [ $test ] );
        }
        return Views::view( 'bookmarks.tutorials.brave.' . $tutorial );
    }

    public function chrome( $tutorial = '' ) {
        Navigation::setCrumbComponent( 'tutorialCrumbs', Input::get( 'url' ) );

        if ( ! in_array( $tutorial, ['pin','settings','import','export'] ) ) {
            $test = new \stdClass();
            $test->pretty = 'Chrome';
            $test->printed = 'chrome';
            return Views::view( 'bookmarks.tutorials.card', [ $test ] );
        }
        
        return Views::view( 'bookmarks.tutorials.chrome.' . $tutorial );
    }

    public function edge( $tutorial = '' ) {
        Navigation::setCrumbComponent( 'tutorialCrumbs', Input::get( 'url' ) );

        if ( ! in_array( $tutorial, ['pin','settings','import','export'] ) ) {
            $test = new \stdClass();
            $test->pretty = 'Edge';
            $test->printed = 'edge';
            return Views::view( 'bookmarks.tutorials.card', [ $test ] );
        }
        return Views::view( 'bookmarks.tutorials.edge.' . $tutorial );
    }

    public function opera( $tutorial = '' ) {
        Navigation::setCrumbComponent( 'tutorialCrumbs', Input::get( 'url' ) );

        if ( ! in_array( $tutorial, ['pin','settings','import','export'] ) ) {
            $test = new \stdClass();
            $test->pretty = 'Opera';
            $test->printed = 'opera';
            return Views::view( 'bookmarks.tutorials.card', [ $test ] );
        }
        return Views::view( 'bookmarks.tutorials.opera.' . $tutorial );
    }

    public function firefox( $tutorial = '' ) {
        Navigation::setCrumbComponent( 'tutorialCrumbs', Input::get( 'url' ) );

        if ( ! in_array( $tutorial, ['pin','settings','import','export'] ) ) {
            $test = new \stdClass();
            $test->pretty = 'Firefox';
            $test->printed = 'firefox';
            return Views::view( 'bookmarks.tutorials.card', [ $test ] );
        }
        return Views::view( 'bookmarks.tutorials.firefox.' . $tutorial );
    }

    public function safari( $tutorial = '' ) {
        Issues::add( 'notice', 'Safari is not supported at this time.' );
        return;
        if ( ! in_array( $tutorial, ['pin','settings','import','export'] ) ) {
            Issues::add( 'notice', 'Unknown tutorial' );
            return Views::view( 'bookmarks.tutorials.list' );
        }
        return Views::view( 'bookmarks.tutorials.safari.' . $tutorial );
    }
}