Exemplo n.º 1
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();
    });
}
 *
 *  @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);
}
Exemplo n.º 3
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();
    });
}
Exemplo n.º 4
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;
    });
}
Exemplo n.º 5
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;
 }
Exemplo n.º 6
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();
}
Exemplo n.º 7
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');
}
Exemplo n.º 8
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);
}