示例#1
0
<?php

/**
 * Morfy Sitemap Plugin
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
if (Url::getUriSegment(0) == 'sitemap.xml') {
    Morfy::factory()->addAction('before_render', function () {
        $fenom = Fenom::factory(PLUGINS_PATH . '/sitemap/templates/', CACHE_PATH . '/fenom/', Morfy::$fenom);
        $fenom->setOptions(array("strip" => false));
        $pages = Morfy::factory()->getPages('', 'date', 'DESC', array('404'));
        Response::status(200);
        Request::setHeaders('Content-Type: text/xml; charset=utf-8');
        $fenom->display('sitemap.tpl', array('pages' => $pages));
        Request::shutdown();
    });
}
示例#2
0
<?php

/**
 * Morfy Feed Plugin
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
if (Url::getUriSegment(0) == 'rss') {
    Morfy::factory()->addAction('before_render', function () {
        $fenom = Fenom::factory(PLUGINS_PATH . '/feed/templates/', CACHE_PATH . '/fenom/', Morfy::$fenom);
        $fenom->setOptions(array("strip" => false));
        Response::status(200);
        Request::setHeaders('Content-Type: text/xml; charset=utf-8');
        $fenom->display('rss.tpl', array('page' => Morfy::factory()->getPage(Morfy::$plugins['feed']['page']), 'pages' => Morfy::factory()->getPages(Morfy::$plugins['feed']['page'], 'date', 'DESC', array('404'))));
        Request::shutdown();
    });
}
</div> <?php 
            /* blog.tpl:9: {/foreach} */
        }
    }
    ?>
 </div>  <?php 
    /* base.tpl:27: {Morfy::runAction('theme_content_after')} */
    echo Morfy::runAction('theme_content_after');
    ?>
 </div> <div id="footer"> <div class="container"> <p class="text-muted pull-right">Powered by <a href="http://morfy.org" title="Simple and fast file-based CMS">Morfy</a></p> </div> </div>   <script src="<?php 
    /* base.tpl:36: {$.site.url} */
    echo $tpl->getStorage()->site_config["url"];
    ?>
/themes/<?php 
    /* base.tpl:36: {$.site.theme} */
    echo $tpl->getStorage()->site_config["theme"];
    ?>
/assets/js/jquery.min.js"></script> <script src="<?php 
    /* base.tpl:37: {$.site.url} */
    echo $tpl->getStorage()->site_config["url"];
    ?>
/themes/<?php 
    /* base.tpl:37: {$.site.theme} */
    echo $tpl->getStorage()->site_config["theme"];
    ?>
/assets/js/bootstrap.min.js"></script> <?php 
    /* base.tpl:38: {Morfy::runAction('theme_footer')} */
    echo Morfy::runAction('theme_footer');
    ?>
 </body> </html> <?php 
}, array('options' => 16576, 'provider' => false, 'name' => 'blog.tpl', 'base_name' => 'blog.tpl', 'time' => 1445769054, 'depends' => array(0 => array('base.tpl' => 1445769054, 'blog.tpl' => 1445769054)), 'macros' => array()));
 *
 *  @package Morfy
 *  @subpackage Plugins
 *  @author Pavel Belousov / pafnuty
 *  @copyright 2014 - 2015 Romanenko Sergey / Awilum
 *  @version 1.0.0
 *
 */
/**
 * Add to config.php
 * 'parsedown' => array(
 *     'extra'    => true, // Enable parsedownExtra
 *     'autoLink' => true, // Enable automatic convertation url to link
 * ),
 */
require_once PLUGINS_PATH . '/parsedown/Parsedown/Parsedown.php';
if (Morfy::$config['parsedown']['extra']) {
    require_once PLUGINS_PATH . '/parsedown/Parsedown-extra/ParsedownExtra.php';
}
Morfy::factory()->addFilter('content', 'parseMdText', 1);
function parseMdText($content)
{
    $parseDownConfig = Morfy::$config['parsedown'];
    if ($parseDownConfig['extra']) {
        $Parsedown = new ParsedownExtra();
    } else {
        $Parsedown = new Parsedown();
    }
    $Parsedown->setUrlsLinked($parseDownConfig['autoLink']);
    return $Parsedown->text($content);
}
示例#5
0
<?php

/**
 *  Asset Plugin
 *
 *  @package Morfy
 *  @subpackage Plugins
 *  @author Pavel Belousov / pafnuty
 *  @version 1.1.0
 *  @license https://github.com/pafnuty/morfy-plugin-asset/blob/master/LICENSE MIT
 */
require_once PLUGINS_PATH . '/asset/asset.class.php';
Morfy::addAction('asset_folder', function (array $folders = array(), array $excludes = array()) {
    $assetConfig = Morfy::$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/' . Morfy::$site['theme'] . $folder;
    }
    Asset::add($folders, $excludes);
});
Morfy::addAction('asset_file', function ($fileName = '', $attributes = '') {
    if ($fileName != '') {
        $fileName = '/themes/' . Morfy::$site['theme'] . $fileName;
        Asset::addFile($fileName, $attributes);
    }
});
示例#6
0
/**
 *  Sitemap plugin
 *
 *  @package Morfy
 *  @subpackage Plugins
 *  @author Romanenko Sergey / Awilum
 *  @copyright 2014 - 2015 Romanenko Sergey / Awilum
 *  @version 1.0.0
 *
 */
if (Morfy::factory()->getUrl() == 'sitemap.xml') {
    Morfy::factory()->addAction('before_render', function () {
        header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
        header("Content-Type: text/xml; charset=utf-8");
        echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
        $pages = Morfy::factory()->getPages(CONTENT_PATH, 'date', 'DESC', array('404'));
        foreach ($pages as $page) {
            echo '<url>
		<loc>' . $page['url'] . '</loc>
		<lastmod>' . $page['date'] . '</lastmod>
		<changefreq>weekly</changefreq>
		<priority>1.0</priority>
	</url>';
        }
        echo '
</urlset>
';
        exit;
    });
}
    // Get current URI segments
    $path = Url::getUriSegments();
    array_pop($path);
    $path = implode('/', $path);
    // Get all posts
    $all_pages = Morfy::getPages($path, 'date', 'DESC', array('404', 'index'));
    // Count total posts
    $total_pages = count($all_pages);
    // Get current page path
    $current_path = Url::getUriString();
    // Get current page data
    $current_page = Morfy::getPage($current_path);
    // Testing...
    // echo $current_page['date'];
    // Find next and previous link from current page
    $prev_page = $next_page = false;
    for ($i = 0; $i < $total_pages; $i++) {
        if ($current_page['date'] == $all_pages[$i]['date']) {
            $prev_page = isset($all_pages[$i - 1]['url']) && !empty($all_pages[$i - 1]['url']) ? $all_pages[$i - 1]['url'] : false;
            $next_page = isset($all_pages[$i + 1]['url']) && !empty($all_pages[$i + 1]['url']) ? $all_pages[$i + 1]['url'] : false;
        }
    }
    unset($all_pages);
    // Pagination
    $nextprev_template->display('nav.tpl', array('config' => $nextprev_config, 'current' => 1, 'total' => $total_pages, 'prev' => $prev_page, 'next' => $next_page));
});
// Conditional action between `index_nextprev` and `item_nextprev`
Morfy::addAction('nextprev', function () {
    $path = trim(Url::getUriString(), '/');
    Morfy::runAction((file_exists(PAGES_PATH . '/' . $path . '/index.md') ? 'index' : 'item') . '_nextprev');
});
示例#8
0
文件: index.php 项目: Razzwan/morfy
define('PLUGINS_PATH', ROOT_DIR . '/plugins');
/**
 * Define the path to the cache directory (without trailing slash).
 */
define('CACHE_PATH', ROOT_DIR . '/cache');
/**
 * Define the path to the config directory (without trailing slash).
 */
define('CONFIG_PATH', ROOT_DIR . '/config');
/**
 * Load Morfy
 */
require LIBRARIES_PATH . '/Morfy/Morfy.php';
/**
 * First check for installer then go
 */
if (file_exists('install.php')) {
    if (isset($_GET['install']) && $_GET['install'] == 'done') {
        // Try to delete install file if not DELETE MANUALLY !!!
        @unlink('install.php');
        // Redirect to main page
        header('location: index.php');
    } else {
        include 'install.php';
    }
} else {
    /**
     * Initialize Morfy Application
     */
    Morfy::init();
}
示例#9
0
define('PLUGINS_PATH', ROOT_DIR . '/plugins');
/**
 * Define the path to the cache directory (without trailing slash).
 */
define('CACHE_PATH', ROOT_DIR . '/cache');
/**
 * Define the path to the config directory (without trailing slash).
 */
define('CONFIG_PATH', ROOT_DIR . '/config');
/**
 * Load Morfy
 */
require LIBRARIES_PATH . '/Morfy/Morfy.php';
/**
 * First check for installer then go
 */
if (file_exists('install.php')) {
    if (isset($_GET['install']) && $_GET['install'] == 'done') {
        // Try to delete install file if not DELETE MANUALLY !!!
        @unlink('install.php');
        // Redirect to main page
        header('location: index.php');
    } else {
        include 'install.php';
    }
} else {
    /**
     * Run Morfy Application
     */
    Morfy::factory()->run();
}
示例#10
0
Morfy::addAction('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="' . Morfy::$site['url'] . $media['thumb'] . '"/>
                <figcaption>
                    <a href="' . Morfy::$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>';
        }
    }
});
示例#11
0
<?php

/**
 * Morfy Sitemap Plugin
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
if (Url::getUriSegment(0) == 'sitemap.xml') {
    Morfy::addAction('before_render', function () {
        $fenom = Fenom::factory(PLUGINS_PATH . '/sitemap/templates/', CACHE_PATH . '/fenom/', Morfy::$fenom);
        $fenom->setOptions(array("strip" => false));
        $pages = Morfy::getPages('', 'date', 'DESC', array('404'));
        Response::status(200);
        Request::setHeaders('Content-Type: text/xml; charset=utf-8');
        $fenom->display('sitemap.tpl', array('pages' => $pages));
        Request::shutdown();
    });
}
示例#12
0
<?php

/**
 *  Statistics plugin for Morfy
 *
 *  @package Morfy
 *  @subpackage Plugins
 *  @author Pavel Belousov / pafnuty
 *  @version 2.0.0
 *  @license https://github.com/pafnuty/morfy-statistics/blob/master/LICENSE MIT
 *
 */
require_once PLUGINS_PATH . '/statistics/ShowStatistics.php';
Morfy::addAction('plugins_loaded', function () {
    global $statistics;
    $statistics = new ShowStatistics();
});
Morfy::addAction('after_render', function () {
    global $statistics;
    echo $statistics->showStat();
});
示例#13
0
define('LIBRARIES_PATH', ROOT_DIR . '/libraries');
/**
 * Define the path to the themes directory (without trailing slash).
 */
define('THEMES_PATH', ROOT_DIR . '/themes');
/**
 * Define the path to the plugins directory (without trailing slash).
 */
define('PLUGINS_PATH', ROOT_DIR . '/plugins');
/**
 * Load Morfy
 */
require LIBRARIES_PATH . '/Morfy/Morfy.php';
/**
 * First check for installer then go
 */
if (file_exists('install.php')) {
    if (isset($_GET['install']) && $_GET['install'] == 'done') {
        // Try to delete install file if not DELETE MANUALLY !!!
        @unlink('install.php');
        // Redirect to main page
        header('location: index.php');
    } else {
        include 'install.php';
    }
} else {
    /**
     * Run Morfy Application
     */
    Morfy::factory()->run('config.php');
}
示例#14
0
文件: Morfy.php 项目: zorca/morfy
 /**
  * Initialize Morfy Application
  *
  *  <code>
  *      Morfy::init();
  *  </code>
  *
  * @access public
  * @return object
  */
 public static function init()
 {
     return !isset(self::$instance) and self::$instance = new Morfy();
 }
示例#15
0
 /**
  * Check that the given token matches the currently stored security token.
  *
  *  <code>
  *     if (Morfy::factory()->checkToken($token)) {
  *         // Pass
  *     }
  *  </code>
  *
  * @param  string  $token token to check
  * @return boolean
  */
 public function checkToken($token)
 {
     return Morfy::factory()->generateToken() === $token;
 }
示例#16
0
文件: Morfy.php 项目: Razzwan/morfy
 /**
  * Initialize Morfy Application
  *
  *  <code>
  *      Morfy::init();
  *  </code>
  *
  * @access  public
  */
 public static function init()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Morfy();
     }
     return self::$instance;
 }
示例#17
0
 /**
  * Run Morfy Application
  *
  *  <code>
  *      Morfy::factory()->run();
  *  </code>
  *
  * @access  public
  */
 public function run()
 {
     // Use the Force...
     include LIBRARIES_PATH . '/Force/ClassLoader/ClassLoader.php';
     // Map Classes
     ClassLoader::mapClasses(array('Spyc' => LIBRARIES_PATH . '/Spyc/Spyc.php', 'Arr' => LIBRARIES_PATH . '/Force/Arr/Arr.php', 'Session' => LIBRARIES_PATH . '/Force/Session/Session.php', 'Token' => LIBRARIES_PATH . '/Force/Token/Token.php', 'Request' => LIBRARIES_PATH . '/Force/Http/Request.php', 'Response' => LIBRARIES_PATH . '/Force/Http/Response.php', 'Url' => LIBRARIES_PATH . '/Force/Url/Url.php', 'File' => LIBRARIES_PATH . '/Force/FileSystem/File.php', 'Dir' => LIBRARIES_PATH . '/Force/FileSystem/Dir.php', 'Parsedown' => LIBRARIES_PATH . '/Parsedown/Parsedown.php', 'ParsedownExtra' => LIBRARIES_PATH . '/Parsedown/ParsedownExtra.php'));
     // Map Fenom Template Engine folder
     ClassLoader::directory(LIBRARIES_PATH . '/Fenom/');
     // Register the ClassLoader to the SPL autoload stack.
     ClassLoader::register();
     // Load config file
     $this->loadConfig();
     // Set default timezone
     @ini_set('date.timezone', static::$site['timezone']);
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(static::$site['timezone']);
     } else {
         putenv('TZ=' . static::$site['timezone']);
     }
     // Sanitize URL to prevent XSS - Cross-site scripting
     Url::runSanitizeURL();
     // Send default header and set internal encoding
     header('Content-Type: text/html; charset=' . static::$site['charset']);
     function_exists('mb_language') and mb_language('uni');
     function_exists('mb_regex_encoding') and mb_regex_encoding(static::$site['charset']);
     function_exists('mb_internal_encoding') and mb_internal_encoding(static::$site['charset']);
     // Gets the current configuration setting of magic_quotes_gpc and kill magic quotes
     if (get_magic_quotes_gpc()) {
         function stripslashesGPC(&$value)
         {
             $value = stripslashes($value);
         }
         array_walk_recursive($_GET, 'stripslashesGPC');
         array_walk_recursive($_POST, 'stripslashesGPC');
         array_walk_recursive($_COOKIE, 'stripslashesGPC');
         array_walk_recursive($_REQUEST, 'stripslashesGPC');
     }
     // Start the session
     Session::start();
     // Load Plugins
     $this->loadPlugins();
     $this->runAction('plugins_loaded');
     // Get page for current requested url
     Morfy::$page = $this->getPage(Url::getUriString());
     // Load template
     $this->runAction('before_render');
     $this->loadPageTemplate(Morfy::$page);
     $this->runAction('after_render');
 }
示例#18
0
<?php

/**
 * Morfy Redirect Plugin
 *
 * (c) Romanenko Sergey / Awilum <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
Morfy::addAction('before_render', function () {
    if (isset(Morfy::$page['redirect'])) {
        Request::redirect(Morfy::$page['redirect']);
    }
});
示例#19
0
<?php

/**
 * Markdown plugin
 *
 *  @package Morfy
 *  @subpackage Plugins
 *  @author Romanenko Sergey / Awilum
 *  @copyright 2014 - 2015 Romanenko Sergey / Awilum
 *  @version 1.0.0
 *
 */
use Michelf\MarkdownExtra;
include PLUGINS_PATH . '/markdown/php-markdown/Michelf/Markdown.php';
include PLUGINS_PATH . '/markdown/php-markdown/Michelf/MarkdownExtra.php';
Morfy::factory()->addFilter('content', 'markdown', 1);
function markdown($content)
{
    return MarkdownExtra::defaultTransform($content);
}