Skip to content

Instantly share code, notes, and snippets.

@simon511000
Last active January 23, 2019 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simon511000/931743c68c95a7d2e68a9ab78205a48b to your computer and use it in GitHub Desktop.
Save simon511000/931743c68c95a7d2e68a9ab78205a48b to your computer and use it in GitHub Desktop.
<?php defined('FLATBOARD') or die('Flatboard Community.');
/**
* Core: include Infinite Ajax Scroll, font awesome 4.7, category icon picker and mini colors JS
*
* @author Frédéric K.
* @copyright (c) 2015-2019
* @license http://opensource.org/licenses/MIT
* @package FlatBoard
* @version 2.0
* @update 2018-12-23
*/
function core_install()
{
$plugin = 'core';
if (flatDB::isValidEntry('plugin', $plugin))
return;
$data[$plugin.'state'] = true; // Ne pas désactiver !
flatDB::saveEntry('plugin', $plugin, $data);
}
function core_head()
{
$plugin = 'core';
$out = '';
# Lecture des données
$data = flatDB::readEntry('plugin', $plugin);
if ($data[$plugin.'state']) {
$out .= ' ' .base64_decode('ICA8bWV0YSBuYW1lPSJnZW5lcmF0b3IiIGNvbnRlbnQ9IkZsYXRib2FyZA==') .(DEBUG_MODE ? ' '.VERSION : ''). '" />'.PHP_EOL;
$out .= ' <link href="' .HTML_PLUGIN_DIR . $plugin . DS . 'assets' . DS . 'css' . DS . 'font-awesome.min.css?ver=4.7.0" rel="stylesheet" type="text/css" />'.PHP_EOL;
$out .= ' <style type="text/css">.pass_show{position:relative}.pass_show .ptxt{position:absolute;top:50%;right:10px;z-index:1;color:#f36c01;margin-top:-10px;cursor:pointer;transition:.3s ease all}</style>'.PHP_EOL;
if (User::isWorker()) {
$out .= ' <link rel="stylesheet" href="' .HTML_PLUGIN_DIR . $plugin . DS . 'assets' . DS . 'css' . DS . 'icon-picker.min.css">'.PHP_EOL;
$out .= ' <link rel="stylesheet" href="' .HTML_PLUGIN_DIR . $plugin . DS . 'assets' . DS . 'minicolors' . DS . 'jquery.minicolors.css">'.PHP_EOL;
}
}
return $out;
}
function core_footerJS()
{
global $lang, $cur, $config;
$plugin = 'core';
$out='';
$assets = HTML_PLUGIN_DIR . $plugin. DS . 'assets' .DS;
# Lecture des données
$data = flatDB::readEntry('plugin', $plugin);
if ($data[$plugin.'state']) {
$out .= (User::isWorker()? '
<div class="fa-set icon-set"><ul id="awesome"></ul></div>
<script type="text/javascript" src="' . $assets . 'js' . DS . 'icon-picker.min.js"></script>
<script type="text/javascript">$.getJSON("'.$assets.'font-awesome.json",function(s){var n=[];$.each(s,function(s,a){n.push("<li data-class=\'fa "+s+"\' class=\'fa "+s+"\'></li>")}),$("<div/>",{class:"icons",html:n.join("")}).appendTo("#awesome")}),function(s){s(document).ready(function(){s(".icon-picker").qlIconPicker({save:"class"})})}(jQuery);</script>
<script src="' . $assets . 'minicolors' . DS . 'jquery.minicolors.min.js"></script>
<script>$(document).ready(function(){$(".color").each(function(){$(this).minicolors({control:$(this).attr("data-control")||"hue",defaultValue:$(this).attr("data-defaultValue")||"",format:$(this).attr("data-format")||"hex",keywords:$(this).attr("data-keywords")||"",inline:"true"===$(this).attr("data-inline"),letterCase:$(this).attr("data-letterCase")||"lowercase",opacity:$(this).attr("data-opacity"),position:$(this).attr("data-position")||"bottom left",swatches:$(this).attr("data-swatches")?$(this).attr("data-swatches").split("|"):[],change:function(t,a){t&&(a&&(t+=", "+a),"object"==typeof console&&console.log(t))},theme:"bootstrap"})})});</script>' : '').
PHP_EOL;
// Infinite Ajax Scroll : http://infiniteajaxscroll.com/
if($cur=='home' || $cur=='blog') {
$out .= ' <script src="' . $assets . 'js' . DS . 'jquery-ias.min.js?ver=2.2.2"></script>'.PHP_EOL;
$out .= ' <script>var ias = $.ias({container: "#timeline",item: ".media,.card",pagination: ".pagination",next: "#next a",delay: 600});ias.extension(new IASSpinnerExtension({html: \'<p class="mt-3 text-center"><i class="fa fa-circle-o-notch fa-spin fa-fw"></i><span class="sr-only">' .$lang['loading']. '</span></p>\'}));ias.extension(new IASTriggerExtension({html: \'<div class="ias-trigger ias-trigger-next text-center mt-3 mb-3"><button class="btn btn-outline-primary btn-sm"><i class="fa fa-refresh"></i> ' .$lang['load_more']. '</button></a></div>\',offset: ' .$config['nb_page_scroll_infinite']. '}));ias.extension(new IASNoneLeftExtension({html: \'<div class="ias-noneleft text-center mt-3 mb-3"><button class="btn btn-outline-primary btn-sm disabled">' .$lang['no_more_load']. '</button></div>\'}));</script>' .PHP_EOL;
}
$out .= ' <script>$(document).ready(function(){$(".pass_show").append(\'<span class="ptxt">' .$lang['show']. '</span>\')});$(document).on("click",".pass_show .ptxt",function(){$(this).text($(this).text()=="' .$lang['show']. '"?"' .$lang['hide']. '":"' .$lang['show']. '");$(this).prev().attr("type",function(index,attr){return attr=="password"?"text":"password"})})</script>'.PHP_EOL;
$out .= "<script src='".HTML_PLUGIN_DIR . $plugin . DS . "savenote.js"."'></script>";
}
return $out;
}
function core_init(){
$plugin = "core";
$data = flatDB::readEntry('plugin', $plugin);
if ($data[$plugin.'state']) {
if(isset($_POST["coreNote"])){
$data["note"] = $_POST["coreNote"];
flatDB::saveEntry('plugin',$plugin,$data);
exit;
}
}
}
?>
<?php if(!isset($out)) exit;
$assets = HTML_THEME_DIR. 'assets' .DS;
?>
<!DOCTYPE html>
<html lang="<?php echo $config['lang']?>">
<head>
<meta charset="<?php echo CHARSET ?>" />
<meta name="robots" content="index, follow" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="<?php echo Util::Description()?>"/>
<title><?php echo $config['title']?> - <?php echo $out['subtitle']?></title>
<base href="<?php echo $out['baseURL']?>"/>
<!-- Bootstrap core CSS -->
<link href="<?php echo $assets?>css/bootstrap.css" rel="stylesheet">
<!-- Dashboard -->
<link href="<?php echo $assets?>css/dashboard.css" rel="stylesheet">
<!-- favicon -->
<link rel="icon" href="<?php echo $assets?>img/favicon.ico">
<link rel="apple-touch-icon" href="<?php echo $assets?>img/apple-touch-icon.png">
<!-- RSS Feeds -->
<link rel="alternate" type="application/atom+xml" href="feed.php/topic" title="<?php echo $lang['topic']?> - <?php echo $config['title']?>"/>
<link rel="alternate" type="application/atom+xml" href="feed.php/reply" title="<?php echo $lang['reply']?> - <?php echo $config['title']?>"/>
<style>.bg-costum { background: <?php echo $config['style']?>;color: rgba(0, 0, 0, 0.5) !important;padding: 1rem}</style>
<?php echo Plugin::hook('head', $out['self'])?>
</head>
<body>
<div class="wrapper">
<!-- Sidebar Holder -->
<nav id="sidebar">
<div class="sidebar-header shadow">
<!--h3 class="text-uppercase">Flatboard</h3-->
<a href="<?php echo HTML_BASEPATH . DS?>config.php">
<img class="logo-icon" src="<?php echo $assets?>img/<?php echo (defined('FLATBOARD_PRO'))?'flatboard-pro':'flatboard' ?>.png" alt="Flatboard">
</a>
<p class="text-uppercase"><?php echo (defined('FLATBOARD_PRO'))?'FLATBOARD PRO':'FLATBOARD' ?></p>
</div>
<ul class="list-unstyled components">
<!-- Welcome message -->
<p id="hello-message" class="text-center">
<?php echo $lang['hello'] ?> <?php echo $lang[$_SESSION['role']] ?>
</p>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Note</span>
<a class="d-flex align-items-center text-muted">
<i class="fa fa-pencil fa-lg" aria-hidden="true"></i>
</a>
</h6>
<textarea name="note" id="note"><?= FlatDB::readEntry('plugin','core')["note"] ?></textarea>
<?php if (User::isAdmin()): ?>
<li class="nav-item">
<a class="nav-link<?php if ($cur == 'config') echo ' active'; ?>" href="config.php">
<i class="fa fa-sliders" aria-hidden="true"></i> <?php echo $lang['config'] ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link<?php if ($cur == 'plugin') echo ' active'; ?>" href="config.php/plugin">
<i class="fa fa-plug" aria-hidden="true"></i> <?php echo $lang['plugin'].$lang['plural'] ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link<?php if ($cur == 'tags') echo ' active'; ?>" href="config.php/tags">
<i class="fa fa-tags" aria-hidden="true"></i> <?php echo $lang['tags'] ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link<?php if ($cur == 'notifications') echo ' active'; ?>" href="config.php/notifications">
<i class="fa fa-tachometer" aria-hidden="true"></i> <?php echo $lang['dashboard'] ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link<?php if ($cur == 'worker') echo ' active'; ?>" href="config.php/worker">
<i class="fa fa-users" aria-hidden="true"></i> <?php echo $lang['worker'] ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link<?php if ($cur == 'ban') echo ' active'; ?>" href="config.php/ban">
<i class="fa fa-ban" aria-hidden="true"></i> <?php echo $lang['ban_list'] ?>
</a>
</li>
<li class="nav-item">
<a class="nav-link<?php if ($cur == 'password') echo ' active'; ?>" href="auth.php/password">
<i class="fa fa-key" aria-hidden="true"></i> <?php echo $lang['change_pwd'] ?>
</a>
</li>
<?php endif;?>
<li>
<a href="#pageSubmenu" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle">
<i class="fa fa-plug" aria-hidden="true"></i> Extras <?php echo $lang['plugin'].$lang['plural'] ?>
</a>
<ul class="collapse list-unstyled" id="pageSubmenu">
<?php
// Liens générés par les plugins
echo Plugin::hook('core_menu', $out['self'])
?>
</ul>
</li>
</ul>
<ul class="list-unstyled links">
<li>
<a href="<?php echo HTML_BASEPATH?>" class="article">
<i class="fa fa-home" aria-hidden="true"></i> <?php echo $lang['back_to_site'] ?>
</a>
</li>
</ul>
<hr>
<p class="footer text-center text-white">
<small><?php echo $lang['powered']?></small>
</p>
<?php echo Plugin::hook('adminSidebar', $out['self'])?>
</nav>
<!-- Page Content Holder -->
<div id="content">
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
<div class="container-fluid">
<button type="button" id="sidebarCollapse" class="navbar-btn">
<span></span>
<span></span>
<span></span>
</button>
<button class="btn btn-dark d-inline-block d-lg-none ml-auto" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<i class="fa fa-align-justify"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item active">
<?php if (User::isWorker()): ?>
<a class="nav-link" href="auth.php/logout"><?php echo $lang['logout'] ?></a>
<?php else: ?>
<a class="nav-link" href="auth.php" class="btn btn-link"><?php echo $lang['login'] ?></a>
<?php endif;?>
</li>
</ul>
</div>
</div>
</nav>
<h1 class="h4 text-center text-uppercase"><?php echo $out['sub_prefix'].$out['subtitle']?></h1>
<?php echo Plugin::hook('adminBeforeMain', $out['self'])?>
<?php echo $out['content']?>
<?php echo Plugin::hook('adminAfterMain', $out['self'])?>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<script src="<?php echo $assets?>js/jquery.min.js"></script>
<script src="<?php echo $assets?>js/bootstrap.bundle.min.js"></script>
<script src="<?php echo $assets?>js/flatboard.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#sidebarCollapse').on('click', function () {
$('#sidebar').toggleClass('active');
$(this).toggleClass('active');
});
$("#hello-message").fadeOut(2000, function() {
var date = new Date()
var hours = date.getHours()
if (hours >= 6 && hours < 12) {
$(this).html('<span class="text-warning"><i class="fa fa-sun-o" aria-hidden="true"></i> <?php echo $lang['good-morning'] ?></span>');
} else if (hours >= 12 && hours < 18) {
$(this).html('<span class="text-warning"><i class="fa fa-sun-o" aria-hidden="true"></i> <?php echo $lang['good-afternoon'] ?></span>');
} else if (hours >= 18 && hours < 22) {
$(this).html('<span class="text-primary"><i class="fa fa-moon-o" aria-hidden="true"></i> <?php echo $lang['good-evening'] ?></span>');
} else {
$(this).html('<span class="text-primary"><i class="fa fa-moon-o" aria-hidden="true"></i> <?php echo $lang['good-night'] ?></span>');
}
}).fadeIn(2000);
});
</script>
<?php echo Plugin::hook('footerJS', $out['self'])?>
</body>
</html>
$(function(){
$("#note").on("keyup",function(e){
e.preventDefault();
$.ajax({
url:"#",
type: "POST",
data: {
coreNote: $("#note").val()
}
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment