Example #1
0
 public function generate()
 {
     $data = array_merge($this->_data_def, $this->_data);
     $data['content'] = bu::view($this->_content_view, $data);
     $data['menu'] = bu::view('menu');
     echo bu::view($this->_layout_view, $data);
 }
Example #2
0
 public static function DoIt()
 {
     self::prepareHttpString();
     ob_start();
     try {
         $url = new BuUrl2(self::$httpString);
         bu::setBuUrlInstance($url);
         self::runController($url);
     } catch (Exception $e) {
         ob_end_clean();
         $msg = 'Ошибка на сайте';
         if (bu::config('rc/debug')) {
             $msg = get_class($e) . ': ' . $e->getMessage();
         }
         $content = $msg;
         if (bu::config('rc/debug')) {
             $content .= sprintf('<br><b>%s</b><br>', get_class($e));
             $content .= "<pre>";
             foreach (array_reverse($e->getTrace()) as $v) {
                 if (isset($v['line'])) {
                     $content .= $v['line'] . ' ' . $v['file'] . "\n";
                 }
             }
             $content .= "</pre>";
         }
         echo bu::view('layout/panic', array('content' => $content));
     }
 }
Example #3
0
function is_need_cache($v = null)
{
    if (!bu::config('rc/cache')) {
        return false;
    }
    static $r = false;
    if (!is_null($v)) {
        $r = $v;
    }
    return $r;
}
Example #4
0
 private static function tryToPreloadConfig($path)
 {
     if (bu::config('cache/config') and BuCache::exists('etc/' . md5($path))) {
         self::$configArray[$path] = BuCache::get('etc/' . md5($path));
     } else {
         self::$configArray[$path] = self::readConfigFromFiles($path);
         if (bu::config('cache/config')) {
             BuCache::set('etc/' . md5($path), self::$configArray[$path]);
         }
     }
 }
Example #5
0
 function example_title($example)
 {
     $cats = array();
     foreach (bu::path() as $v) {
         if (preg_match('/^[0-9]+$/', $v)) {
             break;
         }
         $cats[] = Category::get($v)->name();
     }
     return 'Пример: ' . implode('/', $cats) . ' #' . $example->id();
 }
 public function runController($__url)
 {
     bu::timer('Controller start.', 'system');
     bu::hook(array('pre_controller', 'blank'));
     ob_start();
     $layout = bu::layout();
     if ($__url->getBinUrl()) {
         $layout->_content_view = $__url->getBinUrl();
     }
     include $__url->getBinFile();
     $__content = ob_get_contents();
     ob_end_clean();
     $layout->content = $__content;
     $layout->generate();
     bu::timer('Controller end.', 'system');
 }
Example #7
0
 private static function getRouteList()
 {
     if (!self::$route) {
         $config = bu::config('route');
         $newRoute = array();
         if ($config) {
             foreach ($config as $k => $v) {
                 $newK = str_replace(':any', '.*', $k);
                 $newK = str_replace(':num', '[0-9]+', $newK);
                 $newRoute[$newK] = $v;
             }
         }
         self::$route = $newRoute;
     }
     return self::$route;
 }
<?php

bu::lib('php-activerecord/ActiveRecord');
ActiveRecord\Config::initialize(function ($cfg) {
    $dbs = bu::config('db');
    $connections = array();
    foreach ($dbs as $k => $v) {
        $connections[$k] = sprintf('%s://%s:%s@%s/%s', $v['driver'], $v['user'], $v['password'], $v['host'], $v['database']);
    }
    $cfg->set_connections($connections);
    $cfg->set_default_connection('default');
});
Example #9
0
?>
'><br>

<?php 
$bbCodeLink = htmlspecialchars('[url=http://' . HTTP_HOST . '/img' . $name . '][img]http://' . HTTP_HOST . '/small' . $name . '[/img][/url]');
$htmlCodeLink = htmlspecialchars('<a href="http://' . HTTP_HOST . '/img' . $name . '"><img src="http://' . HTTP_HOST . '/small' . $name . '"></a>');
echo bu::lang('BBCodeLegend');
?>
<br>
<input type'text' 
       class='link_text_field' 
       onclick='javascript:highlight(this)' 
       value='<?php 
echo $bbCodeLink;
?>
'><br>
<?php 
echo bu::lang('htmlLinkLegend');
?>
<br>
<input type'text' 
       class='link_text_field' 
       onclick='javascript:highlight(this)' 
       value='<?php 
echo $htmlCodeLink;
?>
'><br>
</td>
<tr>
</table>
Example #10
0
<?php

require 'base.php';
$content = bu::view('preview', array('name' => $_GET['img']));
echo bu::view('index', array('title' => bu::lang('linksTitle'), 'content' => $content));
Example #11
0
<?php

bu::lib('helpers/shortcut');
bu::hook('session/init');
if (bu::isValidRequest()) {
    bu::hook('session/pages');
    bu::hook('session/flash');
    bu::hook('session/last_post');
}
bu::hook('php_activerecord');
Example #12
0
<?php

$title = sf('%s %s', bu::lang('framework/name'), ' смотрит на тебя =_+!');
$layout->title = $title;
$layout->content = bu::view('index_content');
function activerecord_autoload($class_name)
{
    $inflector = new ActiveRecord\StandardInflector();
    bu::lib('models/' . $inflector->uncamelize($class_name));
}
Example #14
0
<?php

bu::lib('helpers/shortcut');
bu::hook('session/init');
if (bu::isValidRequest()) {
    bu::hook('session/pages');
    bu::hook('session/flash');
    bu::hook('session/last_post');
}
bu::hook('php_activerecord');
bu::lib('global');
bu::lib('yaml/sfYamlParser');
Example #15
0
<?php

include 'base.php';
include 'boot/spyc.php';
#библиотека для парсинга конфигов
include 'boot/bu_core.php';
include 'boot/bu_cache.php';
include 'boot/bu.php';
#магический класс который управляет всем-всем
include 'boot/bu_route.php';
include 'boot/bu_loader.php';
include 'boot/bu_url.php';
include 'boot/bu_statistic.php';
include 'boot/bu_logger.php';
bu::timer('init', 'system');
bu::hook(array('preload', 'blank'));
BuLoader::setHttpString(RAW_HTTP_STRING);
bu::timer('Aplication start.', 'system');
BuLoader::doIt();
bu::timer('Aplication end.', 'system');
bu::hook(array('postload', 'blank'));
Example #16
0
<?php

require_once 'lib/prj/cache.php';
include 'base.php';
include 'boot/spyc.php';
#библиотека для парсинга конфигов
include 'boot/bu_core.php';
include 'boot/bu_cache.php';
include 'boot/bu.php';
#магический класс который управляет всем-всем
include 'boot/bu_route.php';
include 'boot/bu_loader.php';
include 'boot/bu_url.php';
include 'boot/bu_statistic.php';
include 'boot/bu_logger.php';
bu::timer('init', 'system');
bu::hook(array('preload', 'blank'));
Example #17
0
 public function runController($__url)
 {
     bu::timer('Controller start.', 'system');
     include $__url->getBinFile();
     bu::timer('Controller end.', 'system');
 }
Example #18
0
 public static function log($name = false, $group = false, $data = false)
 {
     self::$_log .= bu::view('debug_bar/log_message', array('time' => time(), 'name' => $name, 'group' => $group, 'data' => $data), true);
 }
Example #19
0
<?php

$flash = bu::session('flash');
if (!is_array($flash)) {
    $flash = array();
}
foreach ($flash as $k => $v) {
    if (!$v['valid']) {
        unset($flash[$k]);
    } else {
        $flash[$k]['valid'] = false;
    }
}
bu::session('flash', $flash);
Example #20
0
<?php

require_once 'vendor/autoload.php';
require_once 'lib/prj/cache.php';
include 'base.php';
include 'boot/spyc.php';
#библиотека для парсинга конфигов
include 'boot/bu_core.php';
include 'boot/bu_cache.php';
include 'boot/bu.php';
#магический класс который управляет всем-всем
include 'boot/bu_route.php';
include 'boot/bu_loader.php';
include 'boot/bu_url.php';
include 'boot/bu_statistic.php';
include 'boot/bu_logger.php';
bu::timer('init', 'system');
bu::hook(['preload', 'blank']);
bu::lib('category');
bu::lib('models/example');
Example #21
0
<?php

require_once 'lib/bu.defun/load.php';
bu::lib('category');
Example #22
0
<?php

echo bu::view('path_block');
?>
<?

if ($data->getInfo()): ?>
<div class='alert alert-info'>
  <?php 
echo $data->getInfo();
?>
</div>
<?endif?>

<?

if ($data->categories()): ?>
<div id="subdirs">
	 <?
$sub_dirs = $data->categories();

if (count($sub_dirs) > 20) {
  $groups = group_by(function ($k, $v) {return strtolower(first_letter($v->name()));},
    $data->categories());
  ksort($groups);
  $columns = group_by_column($groups, 3);
  echo '<table><tr>';

  foreach ($columns as $groups) {
    echo "<td width='230px' style='vertical-align: top'>";
Example #23
0
 public static function layout()
 {
     bu::lib('bu/layout');
     return buLayout::getInstance();
 }
Example #24
0
 public static function clear($path)
 {
     unset($_SESSION[bu::config('session/prefix')][$path]);
 }
Example #25
0
function resizeImage($origName, $destName, $maxWidth = false, $maxHeight = false, $quality = false)
{
    //http://php.net/manual/en/function.imagecopyresampled.php
    if (!$maxWidth) {
        $maxWidth = bu::config('rc/maxWidth');
    }
    if (!$maxHeight) {
        $maxHeight = bu::config('rc/maxHeight');
    }
    if (!$quality) {
        $quality = bu::config('rc/quality');
    }
    $width = $maxWidth;
    $height = $maxHeight;
    list($width_orig, $height_orig) = getimagesize($origName);
    $ratio_orig = $width_orig / $height_orig;
    if ($width_orig < $width and $height_orig < $height) {
        $width = $width_orig;
        $height = $height_orig;
    } elseif ($width / $height > $ratio_orig) {
        $width = $height * $ratio_orig;
    } else {
        $height = $width / $ratio_orig;
    }
    bu::lib('opt/smart_resize_image/smart_resize_image.function');
    smart_resize_image($origName, $width, $height, false, $destName, false);
}
Example #26
0
 public static function printa()
 {
     echo bu::act('debug_bar');
 }
Example #27
0
<div id="navigation">
	 <a href='/'>/</a> &rarr;
<?php 
$path = bu::path();
$prefix = '/';
$last = $path[count($path) - 1];
$last_i = count($path) - 1;
foreach ($path as $k => $v) {
    $category_path = trim($prefix . $v, '/');
    $c = Category::get($category_path);
    if ($k == $last_i) {
        if (preg_match('/^[0-9]+$/', $c->getName())) {
            echo '<b>пример #' . $id . '</b>' . "\n";
        } else {
            echo '<b>' . $c->getName() . '</b>' . "\n";
        }
    } else {
        echo '<a href="' . $prefix . $v . '">' . $c->getName() . '</a> &rarr;' . "\n";
    }
    $prefix = $prefix . $v . '/';
}
?>
</div>
Example #28
0
function exception_handler($exception)
{
    ob_end_clean();
    echo bu::view('error', array('message' => $exception->getMessage()));
}
Example #29
0
<?php

bu::lib('session');
Session::start();
Example #30
0
<?php

if (bu::config('rc/debugBar')) {
    BuStatistic::printa();
}
$pages = bu::session('pages');
$pages['num_redirects'] = 0;
bu::session('pages', $pages);