コード例 #1
0
ファイル: plugin.php プロジェクト: agarwalayush92/sample
<?php

use Socio\Event;
View::add_js("google-analytics.js");
View::add_js("google-min.js");
Plugin::register_content("share", '<div class="fb-share-button" data-href= "https://www.google.com" data-layout="button_count"></div> ');
Route::get("plugintest2", "PluginTestController2");
Route::get("plugintest", "PluginTestController");
Socio\Event::listen("framework_ready", function () {
    Plugin::add_filter("menus", function ($arr) {
        if (User::isLoggedIn()) {
            $arr["Posts"] = "posts_link";
        }
        return $arr;
    });
});
Plugin::add_render("list_posts", function ($posts) {
    foreach ($posts as $post) {
        Plugin::render_views("hello/post_list_view.php", array("post" => $post));
    }
});
Plugin::add_render("create_post", function ($arr) {
    echo '<form action="/socio/profile/' . $arr["user"]->id . '" method="post">';
    if (isset($arr["post_status"])) {
        if (!$arr["post_status"]) {
            echo '<h1 style = "color:white;">Posted</h1>';
        }
    }
    echo '<label style = "color : white">wall</label><br/>
				<textarea rows = "5" cols = "100" name = "wallpost">
				</textarea>
コード例 #2
0
ファイル: plugin.php プロジェクト: agarwalayush92/sample
<?php

use socio\Event;
Event::listen("image_uploaded", function ($path) {
    list($width, $height) = getimagesize($path);
    $newwidth = 300;
    $newheight = 300;
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $var = explode('.', $path);
    $func = "imagecreatefrom{$var[1]}";
    $source = $func($path);
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    // Output and free memory
    //the resized image will be 400x300
    $func = "image{$var[1]}";
    return $func($thumb, $path);
});
コード例 #3
0
ファイル: index.php プロジェクト: agarwalayush92/sample
            require $file;
        }
    }
});
use Socio\Database;
use Socio\Settings;
use Socio\Event;
$config = (include 'config.php');
Socio\Settings::init($config);
Database::init();
/*$user = User::get(array('id' => '20'));
$user->name = "potter";
$user->gender = "f";
$user->save();*/
Plugin::register();
Socio\Event::fire("framework_ready");
$r = $_GET['r'];
if (isset($r)) {
    Route::post("register", "RegisterController");
    Route::get("register", "RegisterController");
    Route::get("login", "LoginController");
    Route::post("login", "LoginController");
    Route::get("home", "HomeController");
    Route::post("home", "HomeController");
    Route::get("logout", "LogoutController");
    Route::get("profile/{param}", "ProfileController");
    Route::post("profile/{param}", "ProfileController");
    Route::run($r);
} else {
    echo "You dont have access";
}
コード例 #4
0
ファイル: plugin.php プロジェクト: agarwalayush92/sample
Event::listen("framework_ready", function () {
    Plugin::add_filter("menus", function ($arr) {
        if (User::isLoggedIn()) {
            $arr["Profile"] = "/Socio/profile/" . Session::get("id");
        }
        return $arr;
    });
    Plugin::add_filter("menus", function ($arr) {
        if (User::isLoggedIn()) {
            $arr["edit"] = "/Socio/edit/";
        }
        return $arr;
    });
    Plugin::add_filter("menus", function ($arr) {
        if (!User::isLoggedIn()) {
            $arr["login"] = "******";
        }
        return $arr;
    });
    Plugin::add_filter("menus", function ($arr) {
        if (User::isLoggedIn()) {
            $arr["logout"] = "/Socio/logout";
        }
        return $arr;
    });
    Plugin::add_render("menus", function () {
        $menus = Plugin::get_filters("menus");
        $arr = array();
        $f = true;
        foreach ($menus as $menu) {
            if ($f) {
                $arr = $menu();
                $f = false;
            } else {
                $arr = $menu($arr);
            }
        }
        echo '<nav class="navbar navbar-inverse">
				<div class="container-fluid">
					<div class="navbar-header">
						<a class="navbar-brand" href="#">WebSiteName</a>
					</div>
				<div>
				<ul class="nav navbar-nav navbar-right">';
        foreach ($arr as $menuitem => $menulink) {
            echo '<li><a href="' . $menulink . '">' . $menuitem . '</a></li>';
        }
        echo '</ul></div></div></nav>';
    });
});