<?php /** * Fansoro Gallery Plugin. * * (c) Moncho Varela / Nakome <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /* * fn: Action::run('Gallery') * Page/File: gallery.md * Template: gallery.tpl * * */ include_once 'gallery_functions.php'; Action::add('Gallery', 'Gallery::init'); Action::add('theme_header', 'Gallery::set_css'); Action::add('theme_footer', 'Gallery::set_js'); Shortcode::add('Gallery', 'Gallery::ShortCode');
<?php /** * Bootstrap Markdown plugin * * @package Monstra * @subpackage Plugins * @author William Marshall / Mightyhaggis * @copyright 2015 William Marshall / Mightyhaggis * @version 1.0.0 * */ // Register plugin Plugin::register(__FILE__, __('Bootstrap Markdown', 'bootstrap-markdown'), __('Bootstrap Markdown Editor by @toopay', 'bootstrap-markdown'), '1.0.0', 'Mightyhaggis', 'http://mightyhaggis.com/'); // Add hooks Action::add('admin_header', 'BootstrapMarkdown::headers'); /** * BootstrapMarkdown Class */ class BootstrapMarkdown { /** * Set editor headers */ public static function headers() { echo ' <!-- Bootstrap Markdown & required libs --> <script type="text/javascript" src="' . Option::get('siteurl') . '/plugins/bootstrap-markdown/bootstrap-markdown/lib/markdown.js"></script> <script type="text/javascript" src="' . Option::get('siteurl') . '/plugins/bootstrap-markdown/bootstrap-markdown/lib/to-markdown.js"></script> <script type="text/javascript" src="' . Option::get('siteurl') . '/plugins/bootstrap-markdown/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<?php /** * Custom Action Plugin for Fansoro CMS * Based on https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-boilerplate/custom-action * * @package Fansoro * @subpackage Plugins * @author John Doe * @version 1.0.0 * @license MIT */ // Use in template: // {Action::run('custom-action')} Action::add('custom-action', function () { // Get config of custom-action $config = Config::get('plugins.custom-action'); // Print the custom-action config echo "<pre>"; print_r($config); echo "</pre>"; });
Action::add('Media', function () { // id of media item $id = Request::get('id'); // Obtain json file on public folder $json = array(); $mediaFile = ROOT_DIR . '/public/media/mdb.json'; if (File::exists($mediaFile)) { /* * Json Template * { * "5606e4ad88ed0": { // id of album * "id": "5606e4ad88ed0", // id of image folder album * "title": "Album title", // title of album * "desc": "Album description", // diescription of album * "thumb": "/public/media/album_thumbs/album_5606e4ad88ed0.jpg", // image preview of album * "images": "/public/media/albums/album_5606e4ad88ed0", // images album * "tag": "Nature", // tag of album for filter with javascript * "width": "700", // style width of tumb * "height": "400" // style height of tumb * } * } * */ $json = json_decode(File::getContent($mediaFile), true); } else { die('OOps Whrere is media.json file!'); } // get single id of album or all albums if (Request::get('action') == 'view' && Request::get('id')) { // id of album $id = Request::get('id'); if ($id) { // get id on json $media = $json[$id]; // get all images of this album $mediaImages = File::scan(ROOT_DIR . $media['images']); // get images of this album $albumImages = ''; // check files if (count($mediaImages) > 0) { foreach ($mediaImages as $image) { $albumImages .= '<img class="thumbnail img-responsive" src="public/media/albums/album_' . $id . '/' . File::name($image) . '.' . File::ext($image) . '">'; } } // template $templateSingle = '<h3>' . toHtml($media['title']) . '</h3> ' . toHtml($media['desc']) . ' <p><b>Tag: </b><span class="label label-info">' . toHtml($media['tag']) . '</span></p>' . $albumImages; // return echo $templateSingle; } } else { // all media files $templateAll = ''; foreach ($json as $media) { $templateAll .= '<figure> <img width="' . $media['width'] . '" height="' . $media['height'] . '" src="' . Config::get('site.site_url') . $media['thumb'] . '"/> <figcaption> <a href="' . Config::get('site.site_url') . '/media?action=view&id=' . $media['id'] . '" title="' . toHtml($media['title']) . '">' . toHtml($media['title']) . '</a> </figcaption> </figure>'; } // check json file if not empty if (count($json) > 0) { echo $templateAll; } else { echo '<div class="alert alert-danger">Empty Media albums</div>'; } // get config //print_r(json_encode(Config::getConfig(),true)); } });
if (!class_exists('resize')) { require_once PLUGINS_PATH . '/thumb/classes/resize.php'; } // Изменяем размер $resizeImg = new resize($imgResized); $resizeImg->resizeImage($imgSize[0], $imgSize[1], $method); // Сохраняем картинку в заданную папку $resizeImg->saveImage($dir . $fileName, $quality); } $imgResized = Url::getBase() . $imageDir . $fileName; } $title = isset($title) ? $title : ''; $alt = isset($alt) ? $alt : ''; $class = isset($class) ? $class . ' popup-image' : 'popup-image'; $gallery = isset($gallery) ? '-gallery' : ''; $imageLink = '<a class="' . $class . $gallery . '" href="' . $content . '" title="' . $title . '"><img src="' . $imgResized . '" alt="' . $alt . '"></a>'; return $imageLink; } return ''; }); Action::add('theme_header', function () { if (Config::get('plugins.thumb.loadcss')) { echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css">'; } }); Action::add('theme_footer', function () { if (Config::get('plugins.thumb.loadjs')) { echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>'; echo '<script src="' . Url::getBase() . '/plugins/thumb/assets/js/thumb.js"></script>'; } });
*/ /** * Description : include class shipcart. */ include_once 'shipcart.fn.php'; /* * Description : Styles and javascript */ Action::add('theme_header', 'Shipcart::set_css'); Action::add('theme_footer', 'Shipcart::set_js'); /* * Description : Checkout for navbar ( render li tag ) * Action : Action::run('Shop_cart') * Template: templates/cart.tpl */ Action::add('Shop_cart', 'Shipcart::cart'); /* * Description : User login * ShortCode : {Shop_user} * Template: templates/customer.tpl */ Shortcode::add('Shop_user', 'Shipcart::customer'); /* * Description : Total items * ShortCode : {Shop_total} * Template: templates/total.tpl */ Shortcode::add('Shop_total', 'Shipcart::total'); /* * Description : Category section * ShortCode : {Shop_section title="" image="" url="" description=""}
<?php /** * Youtube for Fansoro CMS * Based on https://togetherjs.com/#tryitout-section. * * @author Moncho Varela * * @version 1.0.0 * * @license MIT */ Action::add('theme_footer', function () { echo '<script type="text/javascript" src="' . Url::getBase() . '/plugins/channel/assets/channel-dist.js"></script>'; }); ShortCode::add('Channel', function ($attr) { extract($attr); //{Channel name="nakome" limit="50"} $name = isset($name) ? $name : Config::get('plugins.channel.username'); $limit = isset($limit) ? $limit : 1; $quality = isset($quality) ? $quality : 'false'; $quantity = isset($quantity) ? $quantity : 8; // template factory $template = Template::factory(PLUGINS_PATH . '/' . Config::get('plugins.channel.name') . '/templates/'); $template->setOptions(['strip' => false]); return $template->fetch('gallery.tpl', ['name' => $name, 'limit' => $limit, 'quality' => $quality, 'quantity' => $quantity, 'apikey' => Config::get('plugins.channel.apikey')]); });
<?php // Admin Navigation: add new item Navigation::add(__('Sandbox', 'sandbox'), 'content', 'sandbox', 10); // Add actions Action::add('admin_themes_extra_index_template_actions', 'SandboxAdmin::formComponent'); Action::add('admin_themes_extra_actions', 'SandboxAdmin::formComponentSave'); /** * Sandbox admin class */ class SandboxAdmin extends Backend { /** * Main Sandbox admin function */ public static function main() { // // Do something here... // // Check for get actions // ------------------------------------- if (Request::get('action')) { // Switch actions // ------------------------------------- switch (Request::get('action')) { // Plugin action // ------------------------------------- case "add": // // Do something here...
<?php /** * Define WordPress actions for your theme. * * Based on the WordPress action hooks. * https://developer.wordpress.org/reference/hooks/ * */ /** * Handle Browser Sync. * * The framework loads by default the local environment * where the constant BS (Browser Sync) is defined to true for development purpose. * * Note: make sure to update the script statement below based on the terminal/console message * when launching the "gulp watch" task. */ Action::add('wp_footer', function () { if (defined('BS') && BS) { ?> <script type="text/javascript" id="__bs_script__"> //<![CDATA[ document.write('<script async src="http://HOST:3000/browser-sync/browser-sync-client.2.12.7.js"><\/script>'.replace("HOST", location.hostname)); //]]> </script> <?php } });
<?php /** * MarkItUp! plugin * * @package Monstra * @subpackage Plugins * @author Romanenko Sergey / Awilum * @copyright 2012-2014 Romanenko Sergey / Awilum * @version 1.0.0 * */ // Register plugin Plugin::register(__FILE__, __('MarkItUp!', 'markitup'), __('MarkItUp! universal markup jQuery editor', 'markitup'), '1.0.0', 'Awilum', 'http://monstra.org/'); // Add hooks Action::add('admin_header', 'MarkItUp::headers'); /** * MarkItUp Class */ class MarkItUp { /** * Set editor headers */ public static function headers() { echo ' <!-- markItUp! 1.1.13 --> <script type="text/javascript" src="' . Option::get('siteurl') . '/plugins/markitup/markitup/jquery.markitup.js"></script> <!-- markItUp! toolbar settings --> <script type="text/javascript" src="' . Option::get('siteurl') . '/plugins/markitup/markitup/sets/html/set.js"></script>
<?php /** * This file is part of the Fansoro. * * (c) Romanenko Sergey / Awilum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // Set Fansoro Meta Generator Action::add('theme_meta', function () { echo '<meta name="generator" content="Powered by Fansoro" />'; });
<?php defined('MONSTRA_ACCESS') or die('No direct script access.'); /** * Set meta generator */ Action::add('theme_meta', 'setMetaGenerator'); function setMetaGenerator() { echo '<meta name="generator" content="Powered by Monstra ' . Monstra::VERSION . '" />' . "\n"; }
<?php /** * Asset Plugin * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 2.1.0 * @license https://github.com/pafnuty/fansoro-plugin-asset/blob/master/LICENSE MIT */ require_once PLUGINS_PATH . '/asset/asset.class.php'; Action::add('asset_folder', function (array $folders = array(), array $excludes = array()) { $assetConfig = Fansoro::$plugins['asset']; $folders = array_unique(array_filter(array_merge($folders, (array) $assetConfig['folders']))); $excludes = array_unique(array_filter(array_merge($excludes, (array) $assetConfig['excludes']))); foreach ($folders as $k => $folder) { $folders[$k] = '/themes/' . Fansoro::$site['theme'] . $folder; } Asset::add($folders, $excludes); }); Action::add('asset_file', function ($fileName = '', $attributes = '') { if ($fileName != '') { $fileName = '/themes/' . Fansoro::$site['theme'] . $fileName; Asset::addFile($fileName, $attributes); } });
<?php /** * Poll for Fansoro CMS. * * @author Moncho Varela * * @version 1.0.0 * * @license MIT */ Action::add('theme_footer', function () { echo '<script> var current = "' . Url::getCurrent() . '"; var pollDb = "' . Url::getBase() . '/plugins/poll/db/db.json"; </script>'; echo '<script src="' . Url::getBase() . '/plugins/poll/assets/poll.js"></script>'; }); /* * Description: add function * Example: {Poll(1,'Do you like Fansoro?','yes','no')} */ function Poll($id, $question, $answer1 = 'Yes', $answer2 = 'No') { // values $id = isset($id) ? $id : ''; $question = isset($question) ? $question : ''; $answer1 = isset($answer1) ? $answer1 : ''; $answer2 = isset($answer2) ? $answer2 : ''; // json dir $dir = PLUGINS_PATH . '/poll/db/db.json';
* Sitemap plugin * * @package Monstra * @subpackage Plugins * @author Romanenko Sergey / Awilum * @copyright 2012-2014 Romanenko Sergey / Awilum * @version 1.0.0 * */ // Register plugin Plugin::register(__FILE__, __('Sitemap', 'sitemap'), __('Sitemap plugin', 'sitemap'), '1.0.0', 'Awilum', 'http://monstra.org/', 'sitemap', 'box'); // Add actions Action::add('admin_pages_action_add', 'Sitemap::create'); Action::add('admin_pages_action_edit', 'Sitemap::create'); Action::add('admin_pages_action_clone', 'Sitemap::create'); Action::add('admin_pages_action_delete', 'Sitemap::create'); /** * Sitemap class */ class Sitemap extends Frontend { /** * Forbidden components * * @var array */ public static $forbidden_components = array('pages', 'sitemap'); /** * Sitemap Title * * @return string
Action::add('Edit', function () { // login vars $user = trim(Config::get('plugins.edit.email')); $password = trim(Config::get('plugins.edit.password')); $token = trim(Config::get('plugins.edit.token')); $hash = md5($token . $password); // get plugin info //var_dump(json_encode(Config::getConfig(),true)); // current url $url = str_replace(Url::getBase(), '', Url::getCurrent()); $page = ''; $name = ''; // empty = index.md if ($url == trim('/')) { $name = trim('/index.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); // blog = blog/index.md } elseif ($url == trim('/blog')) { $name = trim('/blog/index.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); /* // for another index folder names }else if($url == trim('/foldername ')){ $name = trim('/foldername/index.md'); $page = File::getContent(STORAGE_PATH.'/pages'.$name); */ // others } else { $name = trim($url . '.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); } // template factory $template = Template::factory(PLUGINS_PATH . '/' . Config::get('plugins.edit.name') . '/templates/'); $template->setOptions(['strip' => false]); // show loginbtn if (Session::exists(Config::get('plugins.edit.name') . '_user')) { // update file if (Request::post('Update_page')) { if (Request::post('token')) { $content = Request::post('content'); if ($content) { File::setContent(STORAGE_PATH . '/pages' . $name, $content); Request::redirect(Url::getCurrent()); } else { die('You Cant write empty file'); } } else { // crsf die('crsf detect'); } } // logout if (Request::post('access_logout')) { Session::delete(Config::get('plugins.edit.name') . '_user'); Request::redirect(Url::getCurrent()); } // show template $template->display('admin.tpl', ['title' => $name, 'content' => $page]); } else { // login if (Request::post('access_login')) { if (Request::post('token')) { if (Request::post('password') == $password && Request::post('email') == $user) { @Session::start(); Session::set(Config::get('plugins.edit.name') . '_user', $hash); // show admin template Request::redirect(Url::getCurrent()); } else { // password not correct show error $template->display('partials/error.tpl', ['title' => 'Access Error', 'content' => Config::get('plugins.gallery.errorPassword')]); } } else { // crsf die('crsf detect'); } } // show template $template->display('home.tpl'); } });
<?php /** * Breadcrumb Plugin * Based on idea from https://github.com/tovic/breadcrumb-plugin-for-fansoro-cms * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.1.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-breadcrumb/blob/master/LICENSE MIT */ Action::add('breadcrumb', function () { // Configuration data $config = Config::get('plugins.breadcrumb'); // Get current URI segments $paths = Url::getUriSegments(); // Count total paths $total_paths = count($paths); // Path lifter $lift = ''; // Breadcrumb's data $data = []; for ($i = 0; $i < $total_paths; $i++) { $lift .= '/' . $paths[$i]; $page = Pages::getPage(file_exists(STORAGE_PATH . '/pages/' . $lift . '/index.md') || file_exists(STORAGE_PATH . '/pages/' . $lift . '.md') ? $lift : '404'); $data[Url::getBase() . $lift] = ['title' => $page['title'], 'current' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase() . $lift, '/')]; } $template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme')); $template->display('/plugins/breadcrumb/breadcrumb.tpl', ['home' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase(), '/') ? true : Url::getBase(), 'config' => $config, 'branch' => $data]); });
* @subpackage Plugins * @author Andreas Müller | devmount <*****@*****.**> * @license MIT * @link https://github.com/devmount-monstra/events * */ // Add plugin styles and scripts Stylesheet::add('plugins/events/css/events.admin.css', 'backend', 11); Javascript::add('plugins/events/js/events.admin.js', 'backend', 11); // lib: Image Picker http://rvera.github.io/image-picker/ Stylesheet::add('plugins/events/lib/image-picker/image-picker.css', 'backend', 11); Javascript::add('plugins/events/lib/image-picker/image-picker.js', 'backend', 11); // Admin Navigation: add new item Navigation::add(__('Events', 'events'), 'content', 'events', 10); // Add action on admin_pre_render hook Action::add('admin_pre_render', 'EventsAdmin::_getAjaxData'); // register repository classes require_once 'repositories/repository.events.php'; require_once 'repositories/repository.categories.php'; require_once 'repositories/repository.locations.php'; /** * Events class * */ class EventsAdmin extends Backend { /** * Ajax: get Event by ID */ public static function _getAjaxData() {
<?php /** * Detect plugin for Fansoro CMS * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @author Romanenko Sergey / Awilum * @version 1.1.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-detect/blob/master/LICENSE MIT * */ require_once 'classes/Mobile_Detect.php'; Action::add('before_page_rendered', function () { Detect::init(); }); class Detect { protected static $detect; public static function init() { static::$detect = new Mobile_Detect(); } public static function isMobile($userAgent = null, $httpHeaders = null) { return static::$detect->isMobile($userAgent, $httpHeaders); } public static function isTablet($userAgent = null, $httpHeaders = null) { return static::$detect->isTablet($userAgent, $httpHeaders);
<?php /** * Fansoro Fluidbox Plugin * * (c) Romanenko Sergey / Awilum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ Action::add('theme_header', function () { echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fluidbox/2.0.0/css/fluidbox.min.css" type="text/css" />'; echo '<style>.fluidbox__wrap { display: inline-block; }</style>'; }); Action::add('theme_footer', function () { echo '<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-throttle-debounce/1.1/jquery.ba-throttle-debounce.min.js"></script>'; echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/fluidbox/2.0.0/js/jquery.fluidbox.min.js"></script>'; $template = Template::factory(PLUGINS_PATH . '/fluidbox/templates/'); $template->setOptions(["strip" => false]); $types = ''; foreach (Config::get('plugins.fluidbox.types') as $type) { $types .= 'a[href$=".' . $type . '"],'; } $types = rtrim($types, ","); return $template->display('fluidbox.tpl', ['types' => $types]); });
<?php /** * Asset Plugin * * @package Morfy * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.0.0 * @license https://github.com/pafnuty/morfy-plugin-asset/blob/master/LICENSE MIT */ require_once PLUGINS_PATH . '/asset/asset.class.php'; Action::add('asset_folder', function (array $folders = array(), array $excludes = array()) { $assetConfig = Config::get('plugins.asset'); $folders = array_unique(array_filter(array_merge($folders, (array) $assetConfig['folders']))); $excludes = array_unique(array_filter(array_merge($excludes, (array) $assetConfig['excludes']))); foreach ($folders as $k => $folder) { $folders[$k] = '/themes/' . Config::get('system.theme') . $folder; } Asset::add($folders, $excludes); }); Action::add('asset_file', function ($fileName = '', $attributes = '') { if ($fileName != '') { $fileName = '/themes/' . Config::get('system.theme') . $fileName; Asset::addFile($fileName, $attributes); } });
<?php /** * CodeMirror plugin * * @package Monstra * @subpackage Plugins * @author Romanenko Sergey / Awilum * @copyright 2012-2014 Romanenko Sergey / Awilum * @version 1.0.0 * */ // Register plugin Plugin::register(__FILE__, __('CodeMirror', 'codemirror'), __('CodeMirror is a versatile text editor implemented in JavaScript for the browser.', 'codemirror'), '1.0.0', 'Awilum', 'http://monstra.org/'); // Add hooks Action::add('admin_header', 'CodeMirror::headers'); /** * Codemirror Class */ class CodeMirror { public static $theme = 'mdn-like'; /** * Set editor headers */ public static function headers() { echo ' <link rel="stylesheet" type="text/css" href="' . Option::get('siteurl') . '/plugins/codemirror/codemirror/lib/codemirror.css" /> <script type="text/javascript" src="' . Option::get('siteurl') . '/plugins/codemirror/codemirror/lib/codemirror.js"></script> <script type="text/javascript" src="' . Option::get('siteurl') . '/plugins/codemirror/codemirror/addon/edit/matchbrackets.js"></script>
<?php /** * Statistics plugin for Fansoro * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 3.1.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-statistics/blob/master/LICENSE MIT * */ require_once PLUGINS_PATH . '/statistics/ShowStatistics.php'; Action::add('plugins_loaded', function () { global $statistics; $statistics = new ShowStatistics(); }); Action::add('after_page_rendered', function () { global $statistics; echo $statistics->showStat(); });
/** * Morfy Social Sharing Buttons Plugin based on Likely * * (c) Evgeny Steblinsky / volter9 <volter9.github.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ class Likely { /** * @param string $title * @param string $url * @param array|string $classes */ public static function buttons($title = '', $url = '', $classes = '') { $classes = is_array($classes) ? implode(' ', $classes) : $classes; $template = Template::factory(PLUGINS_PATH . '/likely/templates/'); $template->display('likely.tpl', compact('title', 'url', 'classes')); } } Action::add('theme_header', function () { $base = Url::getBase(); printf('<link href="%s/plugins/likely/bower_components/ilyabirman-likely/release/likely.css" rel="stylesheet">', $base); }); Action::add('theme_footer', function () { $base = Url::getBase(); printf('<script src="%s/plugins/likely/bower_components/ilyabirman-likely/release/likely.js"></script>', $base); });
if (empty($content)) { return $content; } $content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8"); $document = new DOMDocument(); libxml_use_internal_errors(true); $document->loadHTML(utf8_decode($content)); $imgs = $document->getElementsByTagName('img'); foreach ($imgs as $img) { $existing_class = $img->getAttribute('class'); $img->setAttribute('class', 'img-responsive ' . $existing_class); } $html = $document->saveHTML(); return $html; }); Action::add('wp_head', function ($post_id) { if (is_single()) { if (empty($post_id)) { set_post_view($post_id); } else { global $post; set_post_view($post->ID); } } }); /* * Load translation * */ Action::add('after_setup_theme', function () { load_theme_textdomain(THEMOSIS_TEXTDOMAIN, themosis_path("theme") . 'languages'); });
Action::add('Edit', function () { // login vars $user = trim(Config::get('plugins.edit.email')); $password = trim(Config::get('plugins.edit.password')); $token = trim(Config::get('plugins.edit.token')); $hash = md5($token . $password); // get plugin info //var_dump(json_encode(Config::getConfig(),true)); // current url $url = str_replace(Url::getBase(), '', Url::getCurrent()); $page = ''; $name = ''; // empty = index.md if ($url == trim('/')) { $name = trim('/index.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); // blog = blog/index.md } elseif ($url == trim('/blog')) { $name = trim('/blog/index.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); // others } else { $name = trim($url . '.md'); $page = File::getContent(STORAGE_PATH . '/pages' . $name); } // template factory $template = Template::factory(PLUGINS_PATH . '/' . Config::get('plugins.edit.name') . '/templates/'); $template->setOptions(['strip' => false]); // show loginbtn if (Session::exists(Config::get('plugins.edit.name') . '_user')) { // update file if (Request::post('Update_page')) { if (Request::post('token')) { $content = Request::post('content'); if ($content) { File::setContent(STORAGE_PATH . '/pages' . $name, $content); Request::redirect(Url::getCurrent()); } else { die('You Cant write empty file'); } } else { // crsf die('crsf detect'); } } // new file if (Request::post('Save_page')) { if (Request::post('token')) { $filename = Request::post('newFile'); $dir = Request::post('directory'); $content = Request::post('newContent'); if ($filename && $content) { // empty dir save on pages dir if ($dir == '') { if (File::exists(STORAGE_PATH . '/pages/' . sanitize($filename) . '.md')) { die('<span class="alert alert-danger">The file ' . sanitize($filename) . ' already exists</span>'); } File::setContent(STORAGE_PATH . '/pages/' . $filename . '.md', $content); Request::redirect(Url::getBase() . '/' . $filename); } else { if (File::exists(STORAGE_PATH . '/pages/' . $dir . '/' . sanitize($filename) . '.md')) { die('<span class="alert alert-danger">The file ' . sanitize($filename) . ' already exists</span>'); } File::setContent(STORAGE_PATH . '/pages/' . $dir . '/' . sanitize($filename) . '.md', $content); Request::redirect(Url::getBase() . '/' . $dir . '/' . sanitize($filename)); } // } else { die('You Cant write empty file'); } } else { // crsf die('crsf detect'); } } // remove file if (Request::get('del')) { if (Request::get('token')) { File::delete(STORAGE_PATH . '/pages' . Request::get('del') . '.md'); Request::redirect(Url::getBase()); } else { die('crsf detect !'); } } // remove Cache if (Request::get('clearcache') == 'true') { if (Request::get('token')) { if (Dir::exists(CACHE_PATH . '/doctrine/')) { Dir::delete(CACHE_PATH . '/doctrine/'); } if (Dir::exists(CACHE_PATH . '/fenom/')) { Dir::delete(CACHE_PATH . '/fenom/'); } Request::redirect(Url::getBase()); } else { die('crsf detect !'); } } // logout if (Request::post('access_logout')) { Session::delete(Config::get('plugins.edit.name') . '_user'); Request::redirect(Url::getCurrent()); } // show template $template->display('admin.tpl', ['title' => $name, 'content' => $page, 'current' => $url, 'directory' => Dir::scan(STORAGE_PATH . '/pages')]); } else { // login if (Request::post('access_login')) { if (Request::post('token')) { if (sha1(md5(Request::post('password'))) == $password && Request::post('email') == $user) { @Session::start(); Session::set(Config::get('plugins.edit.name') . '_user', $hash); // show admin template Request::redirect(Url::getCurrent()); } else { // password not correct show error $template->display('partials/error.tpl', ['title' => 'Access Error', 'content' => Config::get('plugins.edit.errorPassword')]); } } else { // crsf die('crsf detect'); } } // show template $template->display('home.tpl'); } });
/** * Social Meta Plugin * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.2.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-socialmeta/blob/master/LICENSE MIT */ Action::add('theme_meta', function () { if (!class_exists('resize')) { require_once PLUGINS_PATH . '/socialmeta/classes/resize.php'; } require_once PLUGINS_PATH . '/socialmeta/classes/SocialMeta.php'; $config = Config::get('plugins.socialmeta'); $page = Pages::getCurrentPage(); $socialMeta = new SocialMeta(); $title = $page['title']; $description = $page['description'] ? $page['description'] : $page['content']; $description = $socialMeta->textLimit($description, 250); $twitterImage = isset($page['twitter_image']) ? Url::getBase() . $page['twitter_image'] : $socialMeta->getImage($page['content'], $config['twitter']['noimage'], '600x330', '100'); $facebookImage = isset($page['og_image']) ? Url::getBase() . $page['og_image'] : $socialMeta->getImage($page['content'], $config['facebook']['noimage'], '600x315', '100'); $arTwitter = ['twitter:card' => 'summary_large_image', 'twitter:site' => '@' . $config['twitter']['author'], 'twitter:creator' => '@' . $config['twitter']['author'], 'twitter:domain' => Url::getBase(), 'twitter:title' => $title, 'twitter:description' => $description, 'twitter:image' => $twitterImage]; $arFacebook = ['og:type' => 'website', 'og:site_name' => Config::get('site.title'), 'og:url' => $page['url'], 'og:title' => $title, 'og:description' => $description, 'og:image' => $facebookImage]; foreach ($arTwitter as $name => $content) { echo '<meta name="' . $name . '" content="' . $content . '">'; } foreach ($arFacebook as $property => $content) { echo '<meta property="' . $property . '" content="' . $content . '">'; } }, '100');
Action::add('Api', function () { //print_r(json_encode(Config::getConfig(),true)); if (Request::get('type')) { cors(); Request::setHeaders('Content-Type: application/json; charset=' . Config::get('system.charset')); $result = ''; switch (Request::get('type')) { case 'page': // api?type=page&name=blog/hello get all if (Request::get('name')) { // get page name $p = @Pages::getPage(Request::get('name')); $title = isset($p['title']) ? $p['title'] : ''; $date = isset($p['date']) ? $p['date'] : ''; $slug = isset($p['slug']) ? $p['slug'] : ''; $url = isset($p['url']) ? $p['url'] : ''; $tag = isset($p['tag']) ? $p['tag'] : ''; $thumbnail = isset($p['thumbnail']) ? $p['thumbnail'] : ''; $template = isset($p['template']) ? $p['template'] : ''; $summary = isset($p['summary']) ? $p['summary'] : ''; $content = isset($p['content']) ? $p['content'] : ''; $keywords = isset($p['keywords']) ? $p['keywords'] : ''; $description = isset($p['description']) ? $p['description'] : ''; // api?type=page&name=blog/hello&filter=title get only title if (Request::get('filter')) { switch (Request::get('filter')) { // api?type=page&name=blog/hello&filter=title case 'title': $result = array('title' => $title); break; // api?type=page&name=blog/hello&filter=date // api?type=page&name=blog/hello&filter=date case 'date': $result = array('date' => $date); break; // api?type=page&name=blog/hello&filter=slug // api?type=page&name=blog/hello&filter=slug case 'slug': $result = array('slug' => $slug); break; // api?type=page&name=blog/hello&filter=url // api?type=page&name=blog/hello&filter=url case 'url': $result = array('url' => $url); break; // api?type=page&name=blog/hello&filter=tag // api?type=page&name=blog/hello&filter=tag case 'tag': $result = array('tag' => $tag); break; // api?type=page&name=blog/hello&filter=thumbnail // api?type=page&name=blog/hello&filter=thumbnail case 'thumbnail': $result = array('thumbnail' => $thumbnail); break; // api?type=page&name=blog/hello&filter=template // api?type=page&name=blog/hello&filter=template case 'template': $result = array('template' => $template); break; // api?type=page&name=blog/hello&filter=summary // api?type=page&name=blog/hello&filter=summary case 'summary': $result = array('summary' => $summary); break; // api?type=page&name=blog/hello&filter=content // api?type=page&name=blog/hello&filter=content case 'content': $result = array('content' => $content); break; // api?type=page&name=blog/hello&filter=keywords // api?type=page&name=blog/hello&filter=keywords case 'keywords': $result = array('keywords' => $keywords); break; // api?type=page&name=blog/hello&filter=description // api?type=page&name=blog/hello&filter=description case 'description': $result = array('description' => $description); break; default: // filter not found get error $result = array('404' => 'Filter Not Found'); break; } // encode to json echo json_encode($result, true); } else { // get all info $result = array('title' => $title, 'date' => $date, 'slug' => $slug, 'url' => $url, 'tag' => $tag, 'thumbnail' => $thumbnail, 'template' => $template, 'keywords' => $keywords, 'description' => $description, 'summary' => $summary, 'content' => $content); // encode to jso echo json_encode($result, true); } } else { // no name get error echo json_encode(array('404' => 'Not Found'), true); } break; case 'pages': //api?type=pages&name=test get all of test folder if (Request::get('name')) { $pages = @Pages::getPages(Request::get('name')); if ($pages != null) { $result = ''; if (Request::get('filter')) { switch (Request::get('filter')) { // get titles // api?type=pages&name=test&filter=title case 'title': foreach ($pages as $page) { $title = isset($page['title']) ? $page['title'] : ''; $result .= json_encode(array('title' => $title), true) . ','; } break; // get dates // api?type=pages&name=test&filter=date // get dates // api?type=pages&name=test&filter=date case 'date': foreach ($pages as $page) { $date = isset($page['date']) ? $page['date'] : ''; $result .= json_encode(array('date' => $date), true) . ','; } break; // get slug // api?type=pages&name=test&filter=slug // get slug // api?type=pages&name=test&filter=slug case 'slug': foreach ($pages as $page) { $slug = isset($page['slug']) ? $page['slug'] : ''; $result .= json_encode(array('slug' => $slug), true) . ','; } break; // get urls // api?type=pages&name=test&filter=url // get urls // api?type=pages&name=test&filter=url case 'url': foreach ($pages as $page) { $url = isset($page['url']) ? $page['url'] : ''; $result .= json_encode(array('url' => $url), true) . ','; } break; // get tag // api?type=pages&name=test&filter=tag // get tag // api?type=pages&name=test&filter=tag case 'tag': foreach ($pages as $page) { $tag = isset($page['tag']) ? $page['tag'] : ''; $result .= json_encode(array('tag' => $tag), true) . ','; } break; // get thumbnail // api?type=pages&name=test&filter=thumbnail // get thumbnail // api?type=pages&name=test&filter=thumbnail case 'thumbnail': foreach ($pages as $page) { $thumbnail = isset($page['thumbnail']) ? $page['thumbnail'] : ''; $result .= json_encode(array('thumbnail' => $thumbnail), true) . ','; } break; // get templates // api?type=pages&name=test&filter=template // get templates // api?type=pages&name=test&filter=template case 'template': foreach ($pages as $page) { $template = isset($page['template']) ? $page['template'] : ''; $result .= json_encode(array('template' => $template), true) . ','; } break; // get summary // api?type=pages&name=test&filter=summary // get summary // api?type=pages&name=test&filter=summary case 'summary': foreach ($pages as $page) { $summary = isset($page['summary']) ? $page['summary'] : ''; $result .= json_encode(array('summary' => $summary), true) . ','; } break; // get content // api?type=pages&name=test&filter=content // get content // api?type=pages&name=test&filter=content case 'content': foreach ($pages as $page) { $content = isset($page['content']) ? $page['content'] : ''; $result .= json_encode(array('content' => $content), true) . ','; } break; default: // filter not found get error $result = json_encode(array('404' => 'Not Found'), true) . ','; break; } // get by filter echo '[' . rtrim($result, ',') . ']'; } else { // get all data by name foreach ($pages as $page) { $title = isset($page['title']) ? $page['title'] : ''; $date = isset($page['date']) ? $page['date'] : ''; $slug = isset($page['slug']) ? $page['slug'] : ''; $url = isset($page['url']) ? $page['url'] : ''; $tag = isset($page['tag']) ? $page['tag'] : ''; $thumbnail = isset($page['thumbnail']) ? $page['thumbnail'] : ''; $template = isset($page['template']) ? $page['template'] : ''; $summary = isset($page['summary']) ? $page['summary'] : ''; $content = isset($page['content']) ? $page['content'] : ''; $keywords = isset($page['keywords']) ? $page['keywords'] : ''; $description = isset($page['description']) ? $page['description'] : ''; $data = array('title' => $title, 'date' => $date, 'slug' => $slug, 'url' => $url, 'tag' => $tag, 'thumbnail' => $thumbnail, 'template' => $template, 'keywords' => $keywords, 'description' => $description, 'summary' => $summary, 'content' => $content); $result .= json_encode($data, true) . ','; } // encode to json echo '[' . rtrim($result, ',') . ']'; } } else { // not get error echo json_encode(array('404' => 'Not Found'), true); } } else { // no type get error echo json_encode(array('404' => 'Not Found'), true); } break; } } });
<?php // Add Monstra check action if (CHECK_MONSTRA_VERSION) { Action::add('admin_post_template', 'checkMonstraVersion', 9999); } /** * Check Monstra version */ function checkMonstraVersion() { echo ' <script type="text/javascript"> $.getJSON("http://monstra.org/api/version.php?jsoncallback=?", function(data){ var current_monstra_version = "' . Monstra::VERSION . '"; var stable_monstra_version = data.version; if (current_monstra_version < stable_monstra_version) { $("#update-monstra").addClass("alert alert-info").html("' . __("Published a new version of the :monstra", "system", array(":monstra" => "<a target='_blank' href='http://monstra.org/download'>Monstra</a>")) . '"); } } ); </script> '; } /** * System Admin */ class SystemAdmin extends Backend { /**
* @license MIT * @version 0.1.2016-01-02 * @link https://github.com/devmount-monstra/events * */ // Register plugin Plugin::register(__FILE__, __('Events'), __('Event management for Monstra.'), '0.1.2016-01-02', 'devmount', 'http://devmount.de'); // Include plugin admin if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) { Plugin::Admin('events'); } // Add shortcode Shortcode::add('events', 'Events::_shortcode'); // Add CSS and JavaScript Action::add('theme_footer', 'Events::_insertJS'); Action::add('theme_header', 'Events::_insertCSS'); // register repository classes require_once 'repositories/repository.events.php'; require_once 'repositories/repository.categories.php'; require_once 'repositories/repository.locations.php'; /** * Events class * * <code> * <?php Events::listEvents('list', 'minimal', 'future', 5, 'ASC'); ?> * </code> * */ class Events { /**