<?php
/**
 * Open Source Social Network
 *
 * @package   Open Source Social Network
 * @version   1.0.0
 * @link      https://www.opensource-socialnetwork.org/
 */

define('__OSSN_HELLO_WORLD__', ossn_route()->com . 'HelloWorld/');




require_once(__OSSN_HELLO_WORLD__ . 'classes/Worlds.php');
require_once(__OSSN_HELLO_WORLD__ . 'classes/Cover.php');
require_once(__OSSN_HELLO_WORLD__ . 'classes/Logo.php');




function ossn_hello_world() {
    ossn_register_action('hello/simple/form', __OSSN_HELLO_WORLD__ . 'actions/form.php');

    if (ossn_isLoggedin()) {
        ossn_register_site_settings_page('wpages', 'settings/admin/wpages');
        ossn_register_admin_sidemenu('admin:wpages', 'admin:wpages', ossn_site_url('administrator/settings/wpages?mpage=list'), ossn_print('admin:sidemenu:settings'));

        if (ossn_isAdminLoggedin()) {
            ossn_register_action('wpages/add', __OSSN_HELLO_WORLD__ . 'actions/add.php');
            ossn_register_action('wpages/edit', __OSSN_HELLO_WORLD__ . 'actions/edit.php');
            ossn_register_action('wpages/delete', __OSSN_HELLO_WORLD__ . 'actions/delete.php');
            ossn_register_action('wpages/cover/add', __OSSN_HELLO_WORLD__ . 'actions/cover/add.php');
            ossn_register_action('wpages/cover/save', __OSSN_HELLO_WORLD__ . 'actions/cover/save.php');
        }

        ossn_extend_view('css/ossn.default', 'helloworld/css');
        ossn_extend_view('js/opensource.socialnetwork', 'helloworld/js');
        ossn_new_css('hello.world', 'css/standalone/helloworld');
        ossn_load_css('hello.world');
        ossn_register_page('hello', 'ossn_hello_page');
        ossn_register_page('hello_custom_template', 'hello_custom_template_page');
        ossn_register_page('hello_simple_form', 'hello_simple_form_page');
        ossn_register_page('worlds', 'hello_worlds_page');
    }
}

function ossn_hello_page() {
    echo 'Hello World';
}

function hello_simple_form_page() {
    $title = 'Simple Form Page';
    $form = ossn_view_form('helloworld/form', array(
        'action' => ossn_site_url('action/hello/simple/form'),
    ));
    $contents = array(
        'content' => $form,
    );
    $content = ossn_set_page_layout('contents', $contents);
    echo ossn_view_page($title, $content);
}

function hello_custom_template_page() {
    $title = 'ABC';
    $contents = array('content' => ossn_plugin_view('helloworld/hello_custom_page'));
    $content = ossn_set_page_layout('contents', $contents);
    echo ossn_view_page($title, $content);
}

function hello_worlds_page() {
    $title = 'Worlds Page';
    $contents = array('content' => ossn_plugin_view('theme/page/worlds_page'));
    $content = ossn_set_page_layout('contents', $contents);
    echo ossn_view_page($title, $content);
}

ossn_register_callback('ossn', 'init', 'ossn_hello_world');
