Ejemplo n.º 1
0
<?php

/**
 * This file is part of the Morfy.
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
// Add {block name=block-name} shortcode
Shortcode::add('block', function ($attributes) {
    if (isset($attributes['name'])) {
        return Blocks::get($attributes['name']);
    }
});
// Add {site_url} shortcode
Shortcode::add('site_url', function () {
    return Url::getBase();
});
Ejemplo n.º 2
0
 /**
  * Content Parser
  *
  * @param  string $content Content to parse
  * @return string $content Formatted content
  */
 protected static function parseContent($content)
 {
     // Add {site_url} shortcode
     Shortcode::add('site_url', function () {
         return Morfy::$site['url'];
     });
     // Add {block name=block-name} shortcode
     Shortcode::add('block', function ($attributes) {
         if (isset($attributes['name'])) {
             if (File::exists($block_file = BLOCKS_PATH . '/' . $attributes['name'] . '.md')) {
                 return file_get_contents($block_file);
             } else {
                 return 'Block ' . $attributes['name'] . ' is not found!';
             }
         }
     });
     // Parse Shortcodes
     $content = Shortcode::parse($content);
     // Parsedown
     $content = static::parsedown($content);
     // Parse page for summary <!--more-->
     if (($pos = strpos($content, "<!--more-->")) === false) {
         $content = static::applyFilter('content', $content);
     } else {
         $content = explode("<!--more-->", $content);
         $content['summary'] = static::applyFilter('content', $content[0]);
         $content['content'] = static::applyFilter('content', $content[0] . $content[1]);
     }
     // Return content
     return $content;
 }
Ejemplo n.º 3
0
    }
    // return
    return $label . ': ' . $value;
});
// Add Shortcode: {Tiny url='http://www.bludit.com'}
Shortcode::add('Tiny', function ($attributes) {
    // Extract
    extract($attributes);
    $url = isset($url) ? file_get_contents('http://tinyurl.com/api-create.php?url=' . $url) : '';
    // return
    return $url;
});
// Add Shortcode {Spoiler title='Spoiler' content='Spoiler content'}
Shortcode::add('Spoiler', function ($attributes) {
    // Extract attributes
    extract($attributes);
    // text
    if (isset($title)) {
        $title = $title;
    } else {
        $title = 'Toggle content';
    }
    if (isset($content)) {
        $content = $content;
    } else {
        $content = 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.';
    }
    // return
    return '<style>.spoiler-box{padding:5px;box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.2);;margin-top:5px;margin-bottom:5px;}.spoiler-close{background-color:#ddd;padding:0px 5px;float:right;}.spoiler-content2{width:100%;padding:5px;}.spoiler-title{background-color:#777;color:#fff;width:100%;display:block;padding:5px;position:relative;}.spoiler-close,.spoiler-content2{display:none}.spoiler-box:focus .spoiler-content2{display:block}.spoiler-box:focus .spoiler-close{display:block}</style>
<div class="spoiler-box" tabindex="1"><div class="spoiler-title">' . $title . '<div class="spoiler-close" tabindex="2">close</div></div><div class="spoiler-content2">' . $content . '</div></div>';
});
<?php

/**
 *	GithubRepo plugin
 *
 *	@package Monstra
 *  @subpackage Plugins
 *	@author Filip Gulan / Raiper34
 *	@copyright 2015 Filip Gulan / Raiper34
 *	@version 1.0.0
 *
 */
Plugin::register(__FILE__, __('GithubRepo'), __('GithubRepo plugin for Monstra.'), '1.0.0', 'Raiper34', 'http://raiper34.net');
Shortcode::add('githubrepo', 'GithubRepo::_shortcode');
class GithubRepo
{
    public static function _shortcode($attributes)
    {
        extract($attributes);
        $output = "";
        $repoUrl = file_get_contents("https://github.com/" . $user . "?tab=repositories");
        preg_match_all('~(?s)<li class=\\"repo-list-item public source\\">.*?<\\/li>~', $repoUrl, $reposBlock);
        foreach ($reposBlock[0] as $repo) {
            preg_match_all('~(?s)(?<=<h3 class=\\"repo-list-name\\">).*?(?=</h3>)~', $repo, $repoName);
            $repoName[0][0] = preg_replace("/=\"\\//", "=\"https://github.com/", $repoName[0][0]);
            preg_match_all('~(?s)(?<=<div class=\\"repo-list-stats\\">).*?(?=<a class="repo-list-stat-item tooltipped tooltipped-s\\")~', $repo, $repoLang);
            preg_match_all('~(?s)(?<=<p class=\\"repo-list-description\\">).*?(?=</p>)~', $repo, $repoDesc);
            preg_match_all('~(?s)(?<=is=\\"relative-time\\">).*?(?=</time>)~', $repo, $repoDate);
            $output = $output . "<h4>" . $repoName[0][0] . " in " . $repoLang[0][0] . "</h4>";
            $output = $output . "<p>" . $repoDesc[0][0] . "<br>";
            $output = $output . "Updated: " . $repoDate[0][0] . "</p><br>";
Ejemplo n.º 5
0
<?php

/**
 * Fansoro Snipplr Plugin
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
// Shortcode: {snipplr}
Shortcode::add('snipplr', function ($attributes) {
    // Extract
    extract($attributes);
    return isset($id) ? snipplr($id) : '';
});
/**
 * Return Snipplr snippet
 *
 *  <code>
 *      snipplr(12345);
 *  </code>
 *
 * @param  int    $id Snipplr ID
 * @return string
 */
function snipplr($id)
{
    return isset($id) ? "<div id=\"snipplr_embed_{$id}\" class=\"snipplr_embed\"><script type=\"text/javascript\" src=\"http://snipplr.com/js/embed.js\"></script><script type=\"text/javascript\" src=\"http://snipplr.com/json/{$id}\"></script>" : '';
}
Ejemplo n.º 6
0
 *
 *	@package    Monstra
 *  @subpackage Plugins
 *	@author     Andreas Müller | devmount <*****@*****.**>
 *	@license    MIT
 *  @link       https://github.com/devmount-monstra/toggle
 *
 */
// Register plugin
Plugin::register(__FILE__, __('Toggle', 'toggle'), __('Toggle plugin for Monstra.', 'toggle'), '1.3', 'devmount', 'http://devmount.de');
// Include plugin admin
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) {
    Plugin::Admin('toggle');
}
// Shortcode: {toggle click="some link text" toggle="some toggle content"}
Shortcode::add('toggle', 'Toggle::_shortcode');
// Add CSS and JavaScript
Action::add('theme_footer', 'Toggle::_insertJS');
Action::add('theme_header', 'Toggle::_insertCSS');
/**
 * Toggle class
 *
 * Usage: <?php Toggle::show('What is life, the universe and everything?', '42'); ?>
 *
 */
class Toggle
{
    /**
     * _shortcode
     *
     * @param  array $attributes given
Ejemplo n.º 7
0
Shortcode::add('Codepen', function ($attributes) {
    // Extract attributes
    extract($attributes);
    // name
    if (isset($user)) {
        $user = $user;
    } else {
        $user = '******';
    }
    if (isset($hash)) {
        $hash = $hash;
    } else {
        $hash = 'YPKYjK';
    }
    if (isset($tab)) {
        $tab = $tab;
    } else {
        $tab = 'default';
    }
    if (isset($height)) {
        $height = $height;
    } else {
        $height = '650';
    }
    // return
    return '<section>
                <p
                    data-height="' . $height . '"
                    data-slug-hash="' . $hash . '"
                    data-default-tab="' . $tab . '"
                    data-user="******"
                    class="codepen">
                </p>
                <script async src="//assets.codepen.io/assets/embed/ei.js"></script>
            </section>';
});
Shortcode::add('thumb', function ($attributes, $content) {
    // Получаем переметры
    extract($attributes);
    $content = trim($content);
    // Если есть контент (картинка) — работаем
    if ($content) {
        $imgResized = $content;
        // Если есть размер — работаем
        if (isset($size)) {
            // Задаём папку для обработанных картинок.
            $uploadDir = isset($folder) ? $folder : '/storage/images/thumb/';
            $imageDir = $uploadDir . $size . '/';
            $dir = ROOT_DIR . $imageDir;
            // Создаём папку при необходимости
            if (!is_dir($dir)) {
                @mkdir($dir, 0755, true);
                @chmod($dir, 0755);
            }
            if (!chmod($dir, 0755)) {
                @chmod($dir, 0755);
            }
            // Определяемся с методами ресайза
            if (isset($method)) {
                switch ($method) {
                    case 'exact':
                        $method = 'exact';
                        break;
                    case 'portrait':
                        $method = 'portrait';
                        break;
                    case 'landscape':
                        $method = 'landscape';
                        break;
                    case 'crop':
                        $method = 'crop';
                        break;
                    default:
                        $method = 'auto';
                        break;
                }
            } else {
                $method = 'auto';
            }
            // Определяемся с качеством картинки на выходе
            $quality = isset($quality) ? (string) $quality : '100';
            // Обрезаем текущий домен
            $urlShort = str_ireplace(Url::getBase(), '', $content);
            // Проверяем источник каринки
            $isRemote = preg_match('~^http(s)?://~', $urlShort) ? true : false;
            // Присваиваем переменной значение картинки (в т.ч. если это внешняя картинка)
            $imgResized = $urlShort;
            // Если не внешняя картинка — подставляем корневю дирректорию, чтоб ресайзер понял что ему дают.
            if (!$isRemote) {
                $imgResized = ROOT_DIR . $urlShort;
            }
            // Разделяем высоту и ширину
            $imgSize = explode('x', $size);
            // Если указана только одна величина - присваиваем второй первую, будет квадрат для exact, auto и crop, иначе класс ресайза жестоко тупит, ожидая вторую переменную.
            if (count($imgSize) == '1') {
                $imgSize[1] = $imgSize[0];
            }
            // Определяем имя файла
            $fileName = $size . '_' . $method . '_' . strtolower(basename($imgResized));
            // Если картинки нет в папке обработанных картинок — создадим её
            if (!file_exists($dir . $fileName)) {
                // Подключаем класс ресайза
                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 '';
});
 *  @subpackage Plugins
 *	@author Romanenko Sergey / Awilum
 *	@copyright 2012-2014 Romanenko Sergey / Awilum
 *	@version 1.0.0
 *
 */
// Register plugin
Plugin::register(__FILE__, __('Snippets', 'snippets'), __('Snippets manager plugin', 'snippets'), '1.0.0', 'Awilum', 'http://monstra.org/', null, 'box');
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
    // Include Admin
    Plugin::admin('snippets', 'box');
}
// Add Plugin Javascript
Javascript::add('plugins/box/snippets/js/snippets.js', 'backend');
// Add shortcode {snippet}
Shortcode::add('snippet', 'Snippet::_content');
/**
 * Snippet class
 */
class Snippet
{
    /**
     * Get snippet
     *
     *  <code>
     *      echo Snippet::get('snippetname');
     *      echo Snippet::get('snippetname', array('message' => 'Hello World'));
     *  </code>
     *
     * @param  string $name Snippet file name
     * @param  string $vars Vars
Ejemplo n.º 10
0
<?php

defined('MONSTRA_ACCESS') or die('No direct script access.');
/**
 * Add new shortcode {siteurl}
 */
Shortcode::add('siteurl', 'returnSiteUrl');
function returnSiteUrl()
{
    return Option::get('siteurl');
}
Ejemplo n.º 11
0
<?php

/**
 * Fansoro Tiny Url Plugin
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
// Shortcode: {tiny}
Shortcode::add('tiny', function ($attributes) {
    // Extract
    extract($attributes);
    return isset($url) ? tiny($url) : '';
});
/**
 * Takes a long url and uses the TinyURL API to return a shortened version.
 *
 *  <code>
 *      tiny('http:://sitename.com');
 *  </code>
 *
 * @param  string $url Long url
 * @return string
 */
function tiny($url)
{
    return isset($url) ? file_get_contents('http://tinyurl.com/api-create.php?url=' . $url) : '';
}
Ejemplo n.º 12
0
<?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');
Ejemplo n.º 13
0
 *	@package    Monstra
 *  @subpackage Plugins
 *	@author     Andreas Müller | devmount <*****@*****.**>
 *	@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>
 *
 */
Ejemplo n.º 14
0
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=""}
 * Template: templates/section.tpl
 */
Shortcode::add('Shop_section', 'Shipcart::section');
/*
 * Description :
 * ShortCode : {Shop_product_detail id="" title="" url="" image="" description=""}
 * Template: templates/item_info.tpl
 *
 */
Shortcode::add('Shop_product', 'Shipcart::item_info');
/*
 * Description : Details of product
 * ShortCode :
 *  {Shop_product_detail id="" title="" url="" image="" description=""}
 *    include title {$title}
 *    content
 *  {/Shop_product_detail}
 * Template: templates/item_detail.tpl
 */
Shortcode::add('Shop_product_detail', 'Shipcart::item_detail');
Shortcode::add('Image', function ($attributes) {
    // Extract attributes
    extract($attributes);
    // Open Image
    if (isset($open)) {
        $file = Image::open($open);
        // Resize Image
        if (isset($width) && isset($height)) {
            if (isset($resize_method) && in_array($resize_method, $resize_methods = ['scale', 'force', 'crop', 'zoom'])) {
                switch ($resize_method) {
                    case 'scale':
                        $file->scaleResize($width, $height, isset($background) ? $background : 0xffffff);
                        break;
                    case 'force':
                        $file->forceResize($width, $height, isset($background) ? $background : 0xffffff);
                        break;
                    case 'crop':
                        $file->cropResize($width, $height, isset($background) ? $background : 0xffffff);
                        break;
                    case 'zoom':
                        $file->zoomCrop($width, $height, isset($background) ? $background : 0xffffff, isset($xPos) ? $xPos : 0, isset($yPos) ? $yPos : 0);
                        break;
                }
            } else {
                $file->resize($width, $height, isset($background) ? $background : 0xffffff);
            }
        }
        if (isset($contrast)) {
            $file->contrast($contrast);
        }
        if (isset($brighness)) {
            $file->brighness($brighness);
        }
        if (isset($smooth)) {
            $file->smooth($smooth);
        }
        if (isset($negate) && $negate == 'true') {
            $file->negate();
        }
        if (isset($sepia) && $sepia == 'true') {
            $file->sepia();
        }
        if (isset($sharp) && $sharp == 'true') {
            $file->sharp();
        }
        if (isset($edge) && $edge == 'true') {
            $file->edge();
        }
        if (isset($emboss) && $emboss == 'true') {
            $file->emboss();
        }
        if (isset($grayscale) && $grayscale == 'true') {
            $file->grayscale();
        }
        if (isset($colorize) && $colorize == 'true' && isset($red) && isset($green) && isset($blue)) {
            $file->colorize($red, $green, $blue);
        }
        if (isset($color) && isset($x) && isset($y)) {
            $file->fill($color, $x, $y);
        }
        if (isset($angle)) {
            $file->rotate($angle, isset($background) ? $background : 0xffffff);
        }
        if (isset($font) && isset($text) && isset($x) && isset($y) && isset($size) && isset($angle) && isset($color) && isset($position)) {
            $file->write($font, $text, $x, $y, $size, $angle, $color, $position);
        }
    } else {
        $file = '';
    }
    return $file;
});
Ejemplo n.º 16
0
    if (isset($src)) {
        $src = $src;
    } else {
        $src = '';
    }
    // return
    return '<iframe width="' . $width . '" height="' . $height . '" src="//www.dailymotion.com/embed/video/' . $src . '" frameborder="0" allowfullscreen></iframe>';
});
// Add Shortcode {Vimeo width='560' height='315' src='144239829'}
Shortcode::add('Vimeo', function ($attributes) {
    // Extract attributes
    extract($attributes);
    // src
    if (isset($width)) {
        $width = $width;
    } else {
        $width = '560';
    }
    if (isset($height)) {
        $height = $height;
    } else {
        $height = '315';
    }
    if (isset($src)) {
        $src = $src;
    } else {
        $src = '';
    }
    // return
    return '<iframe width="' . $width . '" height="' . $height . '" src="//player.vimeo.com/video/' . $src . '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
});
<?php

/**
 * Fansoro Bacon Ipsum Plugin
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
// Shortcode: {bacon}
Shortcode::add('bacon', 'bacon');
function bacon($attributes)
{
    // Extract
    extract($attributes);
    if (isset($type) && in_array($type, ['all-meat', 'meat-and-filler'])) {
        $type = '?type=' . $type;
    } else {
        $type = '?type=' . Config::get('plugins.bacon-ipsum.type');
    }
    if (isset($p)) {
        $p = '&paras=' . $p;
    } else {
        $p = '&paras=' . Config::get('plugins.bacon-ipsum.p');
    }
    if (isset($sentences)) {
        $sentences = '&sentences=' . $sentences;
    } else {
        $sentences = '&sentences=' . Config::get('plugins.bacon-ipsum.sentences');
    }
Ejemplo n.º 18
0
     *
     */
    public static function robots()
    {
        if (Pages::$page !== null) {
            $_index = isset(Pages::$page['robots_index']) ? Pages::$page['robots_index'] : '';
            $_follow = isset(Pages::$page['robots_follow']) ? Pages::$page['robots_follow'] : '';
            $robots = !empty($_index) && !empty($_follow) ? $_index . ', ' . $_follow : '';
        } else {
            $robots = '';
        }
        return $robots;
    }
    public static function _date($attributes)
    {
        return Page::date(isset($attributes['format']) ? $attributes['format'] : 'Y-m-d');
    }
    public static function _content($attributes)
    {
        return Pages::content(isset($attributes['name']) ? $attributes['name'] : '');
    }
}
/**
 * Add new shortcodes {page_author} {page_slug} {page_url} {page_date} {page_content}
 */
Shortcode::add('page_author', 'Page::author');
Shortcode::add('page_slug', 'Page::slug');
Shortcode::add('page_url', 'Page::url');
Shortcode::add('page_content', 'Page::_content');
Shortcode::add('page_date', 'Page::_date');
Ejemplo n.º 19
0
function install_bbcodeHide()
{
    Shortcode::add('hide', 'parse_bbcodeHide');
}
Ejemplo n.º 20
0
 *  @subpackage Plugins
 *  @author cmroanirgo
 *  @copyright 2016 cmroanirgo / kodespace.com
 *  @version 1.0.0
 *
 */
// Register plugin
Plugin::register(__FILE__, __('Slider', 'slider'), __('Slider manager', 'slider'), '1.0.0', 'kodespace', 'http://kodespace.com/');
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
    // Include Admin
    Plugin::admin('slider');
}
// Add Plugin Javascript
Javascript::add('plugins/slider/js/slider.js', 'backend');
// Add shortcode {snippet}
Shortcode::add('slider', 'Slider::_get');
/**
 * Slider Class
 */
class Slider
{
    /**
     * Get slider
     *
     * @param string $category Category name
     */
    public static function get($category = '')
    {
        if ($category == 'default') {
            $category = '';
        }
 *
 */
// Register plugin
Plugin::register(__FILE__, __('Blocks', 'blocks'), __('Blocks manager plugin', 'blocks'), '1.0.0', 'Awilum', 'http://monstra.org/', null, 'box');
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) {
    // Include Admin
    Plugin::admin('blocks', 'box');
}
// Add Plugin Javascript
Javascript::add('plugins/box/blocks/js/blocks.js', 'backend');
// Add shortcode {block get="blockname"}
Shortcode::add('block', 'Block::_content');
// Add shortcode {block_inline name="blockname"}
Shortcode::add('block_inline', 'Block::_inlineBlock');
// Add shortcode {block_inline_create name="blockname"} Block content here {/block_inline_create}
Shortcode::add('block_inline_create', 'Block::_createInlineBlock');
/**
 * Block Class
 */
class Block
{
    /**
     * Inline Blocks
     *
     * @var array
     */
    public static $inline_blocks = array();
    /**
     * Create Inline Block
     */
    public static function _createInlineBlock($attributes, $content)