Beispiel #1
0
 /**
  * Initialisation method which calls all other methods in turn.
  */
 function init()
 {
     $assets = new Asset();
     $assets->meta();
     $assets->stylesheets();
     $assets->javascript();
     $assets->feeds();
     $assets->output();
 }
$brush = Text::parse($brush, '->text');
if (is_numeric($brush) && $brush <= 0) {
    $brush = false;
}
$_ = File::D(__DIR__) . DS . 'assets' . DS;
echo '<!DOCTYPE html>' . NL;
echo '<html dir="ltr">' . NL;
echo TAB . '<head>' . NL;
echo str_repeat(TAB, 2) . '<meta charset="' . $config->charset . '">' . NL;
echo str_repeat(TAB, 2) . '<title>' . File::B($snippet) . '</title>' . NL;
echo str_repeat(TAB, 2) . '<link href="' . Filter::colon('favicon:url', $config->url . '/favicon.ico') . '" rel="shortcut icon" type="image/x-icon">' . NL;
echo str_repeat(TAB, 2) . Asset::stylesheet(array($_ . 'shell' . DS . 'page.min.css', $_ . 'shell' . DS . 'brush.min.css'));
echo TAB . '</head>' . NL;
echo TAB . '<body>' . NL;
echo str_repeat(TAB, 2) . '<pre><code' . ($brush !== false ? ' data-language="' . $brush . '"' : "") . '>';
echo Filter::colon('snippet:content_raw', Text::parse($content, '->encoded_html'), $snippet);
echo '</code></pre>' . NL;
echo str_repeat(TAB, 2) . '<div>' . NL;
echo str_repeat(TAB, 3) . '<strong><a href="' . $config->url . '" title="' . $speak->home . '">' . $config->title . '</a></strong>' . NL;
echo str_repeat(TAB, 3) . '<a href="?raw=1" target="_blank">' . $speak->plugin_snippet_share_title_raw . '</a>' . NL;
echo str_repeat(TAB, 3) . '<a href="?file=1">' . $speak->download . '</a>' . NL;
echo str_repeat(TAB, 2) . '</div>' . NL;
echo str_repeat(TAB, 2) . Asset::javascript(array($_ . 'sword' . DS . 'brush.min.js', $_ . 'sword' . DS . 'brush.line.min.js'));
if ($brush !== false) {
    echo str_repeat(TAB, 2) . Asset::javascript($_ . 'sword' . DS . 'brush' . DS . 'generic.min.js');
    if ($brush !== 'generic' && ($f = File::exist($_ . 'sword' . DS . 'brush' . DS . $brush . '.min.js'))) {
        echo str_repeat(TAB, 2) . Asset::javascript($f);
    }
}
echo TAB . '</body>' . NL;
echo '</html>';
Beispiel #3
0
<?php

// DEPRECATED. Please use `Asset::javascript()`
Asset::plug('script', function ($path, $addon = "", $merge = false) {
    return Asset::javascript($path, $addon, $merge);
});
Beispiel #4
0
Weapon::add('meta', 'do_meta_3', 30);
Weapon::add('SHIPMENT_REGION_TOP', function () {
    Weapon::fire('meta');
}, 10);
/**
 * Inject Widget's CSS and JavaScript
 * ----------------------------------
 */
if ($config->widget_include_css) {
    Weapon::add('shell_before', function () {
        echo Asset::stylesheet(SHIELD . DS . 'widgets.css', "", 'shell/widgets.min.css');
    });
}
if ($config->widget_include_js) {
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript(SHIELD . DS . 'widgets.js', "", 'sword/widgets.min.js');
    });
}
/**
 * Loading Plugin(s)
 * -----------------
 */
Weapon::fire('plugins_before');
foreach ($plugins = Plugin::load() as $k => $v) {
    $__ = PLUGIN . DS . $k . DS;
    if (!($language = File::exist($__ . 'languages' . DS . $config->language . DS . 'speak.txt'))) {
        $language = $__ . 'languages' . DS . 'en_US' . DS . 'speak.txt';
    }
    if (file_exists($language)) {
        Config::merge('speak', Text::toArray(File::open($language)->read(), S, '  '));
        $speak = Config::speak();
Beispiel #5
0
<?php

if ($config->url_path === $config->manager->slug . '/article/ignite' || $config->url_path === $config->manager->slug . '/page/ignite' || $config->url_path === $config->manager->slug . '/comment/ignite' || strpos($config->url_path, $config->manager->slug . '/article/repair/id:') === 0 || strpos($config->url_path, $config->manager->slug . '/page/repair/id:') === 0 || strpos($config->url_path, $config->manager->slug . '/comment/repair/id:') === 0) {
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript(__DIR__ . DS . 'assets' . DS . 'sword' . DS . 'preview.js');
    });
    Weapon::add('tab_content_2_before', function ($page, $segment) use($config, $speak) {
        if (!is_array($segment)) {
            include __DIR__ . DS . 'workers' . DS . 'unit' . DS . 'form' . DS . '..._preview.php';
        }
    }, 0.9);
    Weapon::add('tab_content_after', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'workers' . DS . 'unit' . DS . 'tab' . DS . 'content' . DS . 'preview.php';
    });
    Weapon::add('tab_button_after', function ($page, $segment) use($config, $speak) {
        include __DIR__ . DS . 'workers' . DS . 'unit' . DS . 'tab' . DS . 'button' . DS . 'preview.php';
    });
}
 function do_response_reply_js()
 {
     echo Asset::javascript(File::D(__DIR__) . DS . 'assets' . DS . 'sword' . DS . 'do.js');
 }
<?php

// include once ...
if (!Config::get('__js_google_plusone_1', false)) {
    Weapon::add('meta', function () {
        echo Asset::javascript('https://apis.google.com/js/plusone.js');
    }, 30);
    Config::set('__js_google_plusone_1', true);
}
Beispiel #8
0
        Guardian::checkToken($request['token']);
        $state = __DIR__ . DS . 'states' . DS;
        File::write(trim($request['abbr']))->saveTo($state . 'abbr.txt', 0600);
        File::write(trim($request['url']))->saveTo($state . 'url.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->plugin));
        Guardian::kick(File::D($config->url_current));
    }
});
// Editor ...
Weapon::add('shield_before', function () use($config, $speak) {
    $page = Config::get('page', array());
    $parser = isset($page->content_type_raw) ? $page->content_type_raw : $config->html_parser->active;
    if ($parser === 'Markdown' || $parser === 'Markdown Extra') {
        Config::merge('DASHBOARD.languages.MTE', $speak->__MTE);
        Config::set('MTE', 'MTE');
        Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
            echo Asset::javascript(__DIR__ . DS . 'assets' . DS . 'sword' . DS . 'help.js');
        }, 11);
        Filter::add('asset:path', function ($path) {
            // Replace `HTE` with `MTE`
            if ($path === PLUGIN . DS . '__editor' . DS . 'assets' . DS . 'sword' . DS . 'hte.min.js') {
                return __DIR__ . DS . 'assets' . DS . 'sword' . DS . 'mte.min.js';
            }
            // Replace default `table` button with the new one
            if ($path === PLUGIN . DS . '__editor-button' . DS . 'assets' . DS . 'sword' . DS . 'table.js') {
                return __DIR__ . DS . 'assets' . DS . 'sword' . DS . 'table.js';
            }
            return $path;
        });
    }
}, 1.1);
Beispiel #9
0
            } else {
                Page::open($page->path)->header($header)->content($content)->save();
                File::open($page->path)->renameTo(Date::format($date, 'Y-m-d-H-i-s') . '__' . $slug . $extension);
                include DECK . DS . 'workers' . DS . 'task.custom.1.php';
                if ($page->slug !== $slug && ($php_file = File::exist(File::D($page->path) . DS . $page->slug . '.php'))) {
                    File::open($php_file)->renameTo($slug . '.php');
                }
                Notify::success(Config::speak('notify_success_updated', $title) . ($extension === '.txt' ? ' <a class="pull-right" href="' . $config->url . '/' . $slug . '" target="_blank"><i class="fa fa-eye"></i> ' . $speak->view . '</a>' : ""));
                Weapon::fire('on_page_update', array($G, $P));
                Weapon::fire('on_page_repair', array($G, $P));
                Guardian::kick($config->manager->slug . '/page/repair/id:' . Date::format($date, 'U'));
            }
        }
    }
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript('manager/assets/sword/editor.compose.js', "", 'sword/editor.compose.min.js');
    }, 11);
    Shield::lot(array('segment' => 'page', 'default' => $page))->attach('manager', false);
});
/**
 * Page Killer
 * -----------
 */
Route::accept($config->manager->slug . '/page/kill/id:(:num)', function ($id = "") use($config, $speak) {
    if (!($page = Get::page($id, array('comments')))) {
        Shield::abort();
    }
    if (Guardian::get('status') !== 'pilot' && Guardian::get('author') !== $page->author) {
        Shield::abort();
    }
    Config::set(array('page_title' => $speak->deleting . ': ' . $page->title . $config->title_separator . $config->manager->title, 'page' => $page, 'cargo' => DECK . DS . 'workers' . DS . 'kill.page.php'));
Beispiel #10
0
    unset($constant);
    $cargo = array('segment' => $uri_end, 'languages' => Config::get('DASHBOARD.languages', array()), 'is_html_parser_enabled' => Config::get('html_parser') === HTML_PARSER, 'html_parser' => HTML_PARSER, 'tab_size' => TAB, 'element_suffix' => ES, 'file_extension_allow' => implode(',', File::$config['file_extension_allow']), 'url' => array('protocol' => $config->protocol, 'base' => $config->base, 'host' => $config->host, 'url' => $config->url, 'path' => $config->url_path, 'current' => $config->url_current, 'query' => $config->url_query));
    $output = O_BEGIN . '<script>var ' . rtrim($constant_js, ',') . ';';
    foreach ($cargo as $k => $v) {
        $output .= 'DASHBOARD.' . $k . '=' . json_encode($v) . ';';
    }
    $output .= 'DASHBOARD.url.hash=window.location.hash;';
    echo $output . '</script>' . O_END;
}, 1);
Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
    $MTE = Mecha::alter(Config::get('html_parser'), array(HTML_PARSER => 'mte', 'HTML' => 'hte'), 'hte');
    // default is `hte`
    Session::kill('recent_file_update');
    echo Asset::javascript('manager/assets/sword/editor/editor.min.js');
    echo Asset::javascript('manager/assets/sword/editor/' . $MTE . '.min.js');
    echo Asset::javascript(array('manager/assets/sword/editor/run.js', 'manager/assets/sword/ajax.js', 'manager/assets/sword/row.js', 'manager/assets/sword/slug.js', 'manager/assets/sword/check.js', 'manager/assets/sword/upload.js', 'manager/assets/sword/tab.js', 'manager/assets/sword/modal.js', 'manager/assets/sword/tooltip.js', 'manager/assets/sword/sortable.js', 'manager/assets/sword/accordion.js'), "", 'sword/manager.min.js');
}, 10);
/**
 * Cache Killer
 * ------------
 *
 * Add global cache killer for article(s) and page(s).
 *
 */
function do_remove_cache()
{
    global $config;
    File::open(CACHE . DS . 'sitemap.cache')->delete();
    File::open(CACHE . DS . 'feed.cache')->delete();
    File::open(CACHE . DS . 'feeds.cache')->delete();
    foreach (glob(CACHE . DS . '{feed,feeds}.*.cache', GLOB_NOSORT | GLOB_BRACE) as $cache) {
Beispiel #11
0
<?php

Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
    $assets = glob(__DIR__ . DS . 'assets' . DS . 'sword' . DS . '*.js', GLOB_NOSORT);
    echo Asset::javascript($assets);
}, 2.1);
Beispiel #12
0
    ?>
          <a href="<?php 
    echo $config->url . '/' . $config->manager->slug;
    ?>
/login" rel="nofollow"><i class="fa fa-sign-in"></i> <?php 
    echo $speak->log_in;
    ?>
</a>
          <?php 
}
?>
        </div>
      </footer>
    </div> <!-- .blog-wrapper -->
    <?php 
Weapon::fire('cargo_after');
?>
    <?php 
Weapon::fire('sword_before');
?>
    <?php 
echo Asset::javascript('assets/sword/main.js');
?>
    <?php 
Weapon::fire('sword_after');
?>
    <?php 
Weapon::fire('SHIPMENT_REGION_BOTTOM');
?>
  </body>
</html>
Beispiel #13
0
 * Set Default Time Zone
 * ---------------------
 */
date_default_timezone_set($config->timezone);
/**
 * Inject Widget's CSS and JavaScript
 * ----------------------------------
 */
if ($config->widget_include_css) {
    Weapon::add('shell_before', function () {
        echo Asset::stylesheet('cabinet/shields/widgets.css', "", 'shell/widgets.min.css');
    });
}
if ($config->widget_include_js) {
    Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
        echo Asset::javascript('cabinet/shields/widgets.js', "", 'sword/widgets.min.js');
    });
}
/**
 * Loading Plugin(s)
 * -----------------
 */
$plugins = Plugin::load();
for ($i = 0, $count = count($plugins); $i < $count; ++$i) {
    if ($plugins[$i]) {
        $plugins[$i] = PLUGIN . DS . $plugins[$i];
        if (!($language = File::exist($plugins[$i] . DS . 'languages' . DS . $config->language . DS . 'speak.txt'))) {
            $language = $plugins[$i] . DS . 'languages' . DS . 'en_US' . DS . 'speak.txt';
        }
        if (File::exist($language)) {
            Config::merge('speak', Text::toArray(File::open($language)->read(), ':', '  '));
Beispiel #14
0
    }
    // Merge language data to the `DASHBOARD`
    Config::merge('DASHBOARD.languages.MTE', $editor);
}, 1);
// Inject editor's CSS
Weapon::add('shell_after', function () use($editor_config) {
    echo Asset::stylesheet(__DIR__ . DS . 'assets' . DS . 'shell' . DS . 'editor.css', "", 'shell/editor.min.css');
}, 2);
// Inject editor's JavaScript
Weapon::add('SHIPMENT_REGION_BOTTOM', function () use($config, $speak) {
    echo '<script>(function($){$(\'.MTE\').attr(\'data-MTE-config\',\'{"toolbar":true,"shortcut":true}\')})(DASHBOARD.$);</script>';
    $path = __DIR__ . DS . 'assets' . DS . 'sword' . DS;
    $editor = Config::get('MTE', 'HTE');
    echo Asset::javascript(array($path . 'editor.min.js', $path . 'hte.min.js'));
    echo '<script>var MTE=' . $editor . ';</script>';
    echo Asset::javascript($path . 'run.js', "", 'sword/run.min.js');
}, 2);
/**
 * Plugin Updater
 * --------------
 */
Route::accept($config->manager->slug . '/plugin/' . File::B(__DIR__) . '/update', function () use($config, $speak) {
    if ($request = Request::post()) {
        Guardian::checkToken($request['token']);
        unset($request['token']);
        // Remove token from request array
        File::serialize($request)->saveTo(__DIR__ . DS . 'states' . DS . 'config.txt', 0600);
        Notify::success(Config::speak('notify_success_updated', $speak->plugin));
        Guardian::kick(File::D($config->url_current));
    }
});
Beispiel #15
0
/**
 * tarski_javascript() - Adds Tarski JavaScript to the document head.
 * 
 * @deprecated 2.1
 * @since 2.0.1
 * @return string
 */
function tarski_javascript()
{
    _deprecated_function(__FUNCTION__, '2.1', Asset::javascript());
    $assets = new Asset();
    $assets->javascript();
    $assets->output();
}
Beispiel #16
0
     if (!Asset::loaded($config->protocol . ICON_LIBRARY_PATH)) {
         echo Asset::stylesheet($config->protocol . ICON_LIBRARY_PATH);
     }
     $path = __DIR__ . DS . 'assets' . DS . 'shell' . DS;
     echo Asset::stylesheet(array($path . 'row.css', $path . 'upload.css', $path . 'tab.css', $path . 'toggle.css', $path . 'modal.css', $path . 'tooltip.css', $path . 'sortable.css', $path . 'accordion.css', $path . 'layout.css', SHIELD . DS . $config->shield . DS . 'assets' . DS . 'shell' . DS . 'manager.css'), "", 'shell/manager.min.css');
 }, 10);
 Weapon::add('cargo_after', function () use($config, $speak) {
     if (Config::get('widget_manager_bar_id', 0) <= 1) {
         echo Widget::manager('BAR');
         // include once ...
     }
 }, 20);
 Weapon::add('SHIPMENT_REGION_BOTTOM', function () use($config) {
     Session::kill('recent_item_update');
     $path = __DIR__ . DS . 'assets' . DS . 'sword' . DS;
     echo Asset::javascript(array($path . 'ajax.js', $path . 'row.js', $path . 'slug.js', $path . 'upload.js', $path . 'tab.js', $path . 'toggle.js', $path . 'modal.js', $path . 'tooltip.js', $path . 'sortable.js', $path . 'accordion.js', SHIELD . DS . $config->shield . DS . 'assets' . DS . 'sword' . DS . 'manager.js'), "", 'sword/manager.min.js');
 }, 1);
 /**
  * Footer Link(s)
  * --------------
  */
 if ($config->page_type === 'manager' || $config->is->post) {
     // Add default comment footer link(s)
     Weapon::add('comment_footer', function ($comment, $article) use($config, $speak) {
         $status = Mecha::alter(File::E($comment->path), array('hold' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->pending) . ' &middot; '), "");
         echo $status . Cell::a($config->manager->slug . '/comment/repair/id:' . $comment->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/comment/kill/id:' . $comment->id, $speak->delete);
     }, 20);
 }
 /**
  * Widget Manager Menu(s) and Bar(s)
  * ---------------------------------
Beispiel #17
0
      </div> <!-- .blog-content -->
      <?php 
Shield::chunk('block.footer');
?>
    </div> <!-- .blog-wrapper -->
    <?php 
Weapon::fire('cargo_after');
?>
    <?php 
Weapon::fire('sword_before');
?>
    <?php 
echo Asset::javascript('assets/sword/layout.js');
?>
    <?php 
Weapon::fire('sword_after');
?>
    <?php 
Weapon::fire('SHIPMENT_REGION_BOTTOM');
?>
  </body>
</html>