Ejemplo n.º 1
0
 /**
  * @param array $result
  * @return array
  */
 public function getInfo($result = array())
 {
     $result['tableInfo'] = Fx::db()->tables_info();
     $result['tables'] = array();
     $result['sys_tables'] = Fx::db()->find(Fx::service_context()->namespace['struct_db'], array(), function ($item) {
         return $item['code'];
     });
     foreach ($result['tableInfo']['table'] as $key => $value) {
         $result['tables'][$key] = Fx::db()->extract(Fx::db()->go(array('event' => 'find', 'from' => $key, 'limit' => 25)), function ($item) {
             return $item;
         });
     }
     foreach ($result['sys_tables'] as $k => $v) {
         unset($result['sys_tables'][$k]);
         $result['sys_tables'][$v] = $result['tables'][$v];
         unset($result['tables'][$v]);
     }
     foreach (Fx::service_context()->manifest['baseCollection'] as $k => $v) {
         $name = Fx::service_context()->config['db']['sys_namespace'] . $k;
         if (isset($result['tables'][$name])) {
             $result['sys_tables'][$name] = $result['tables'][$name];
             unset($result['tables'][$name]);
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 public function find($param)
 {
     $val = $param['value'];
     $result = array();
     if (is_numeric($val)) {
         Fx::db()->search(Fx::service_context()->namespace['construct_db'], array('id' => (int) $val, 'chpu' => $val));
     }
     foreach (Fx::db()->find(Fx::service_context()->namespace['struct_db']) as $v) {
         $table = $v['code'];
         $row = Fx::db()->extract(Fx::db()->go(array('event' => 'find', 'from' => $table, 'limit' => 1)));
         if (!isset($row[0])) {
             continue;
         }
         $rows = $row[0];
         $where = array();
         foreach (array_keys($rows) as $row) {
             $where[$row] = $val;
         }
         $find = Fx::db()->search($table, $where);
         if (count($find) > 0) {
             $result[] = array('name' => $v['name'], 'code' => $v['code'], 'find' => $find);
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
 private function rec($id)
 {
     $find = $this->perform(Fx::service_context()->namespace['construct_db'], array('parent' => $id));
     foreach ($find as $v) {
         $active = isset($this->path[0]) && $this->path[0]['id'] == $v['id'] ? ' class="active"' : '';
         if ($active == '' && Fx::context()->struct_db[$v['object']]['show_wood'] < 1) {
             continue;
         }
         $elem = Fx::db()->find($v['object'], array('id' => $v['id']));
         if (!isset($elem[0])) {
             continue;
         }
         $elem = $elem[0];
         $name = isset($elem['name']) && $elem['name'] !== '' ? $elem['name'] : 'undefiend-' . $v['id'];
         $this->result[] = '<li>';
         $this->result[] = '<a' . $active . ' href="?mode=project&id=' . $v['id'] . '">' . $name . '</a>';
         if ($active != '') {
             $item = array_shift($this->path);
             if (Fx::context()->struct_db[$item['object']]['show_wood'] > 0) {
                 $this->result[] = '<ul>';
                 $this->rec($item['id']);
                 $this->result[] = '</ul>';
             }
         }
         $this->result[] = '</li>';
     }
 }
Ejemplo n.º 4
0
 protected function createFolder($folderName, $pathTo)
 {
     $folder = Fx::io()->path(root, Fx::service_context()->config['folder']['file_manager'], $folderName);
     if (strlen($pathTo) > 1) {
         $folder = Fx::io()->path(root, Fx::service_context()->config['folder']['file_manager'], $pathTo, $folderName);
     }
     Fx::io()->create_dir($folder);
 }
Ejemplo n.º 5
0
 public function compile()
 {
     $folderExtension = root . '/' . Fx::service_context()->config['folder']['extension'] . '/';
     $fileExtensionSave = $folderExtension . 'extension.php';
     if (!is_dir($folderExtension)) {
         Fx::io()->create_dir($folderExtension);
     }
     if (!file_exists($fileExtensionSave)) {
         Fx::io()->create_file($fileExtensionSave);
     }
     $listExtension = Fx::io()->read_dir($folderExtension, 'dir');
     $ext = array();
     if (file_exists($fileExtensionSave)) {
         ob_start();
         $ext = (include $fileExtensionSave);
         ob_clean();
     }
     $Extensions = array('list' => array());
     if (count($listExtension)) {
         foreach ($listExtension as $k => $v) {
             if ($k === 'list') {
                 continue;
             }
             $fileInit = $v . 'init.php';
             if (file_exists($fileInit)) {
                 $sha = sha1_file($fileInit);
                 if (isset($ext[$v]) && $ext[$v]['sha'] === $sha) {
                     $Extensions[$v] = $ext[$v];
                 } else {
                     $Extensions[$v] = array('sha' => $sha, 'ext' => $this->compileExtension($v));
                 }
                 foreach ($Extensions[$v]['ext'] as $event) {
                     if (!isset($Extensions['list'][$event['use']])) {
                         $Extensions['list'][$event['use']] = array();
                     }
                     $event['url'] = $v;
                     $Extensions['list'][$event['use']][] = $event;
                 }
             }
         }
     }
     if (file_exists($fileExtensionSave)) {
         Fx::io()->del($fileExtensionSave);
     }
     Fx::io()->create_file($fileExtensionSave);
     Fx::io()->write($fileExtensionSave, '<? return $Extension = ' . Fx::io()->arrayToString($Extensions) . '; ?>');
     $this->extensions = $Extensions;
     return $Extensions;
 }
Ejemplo n.º 6
0
 /**
  * @param array $ctx
  * @param $param
  * @return array
  */
 public function run($ctx = array(), $param)
 {
     if (isset($param['controllerAction']) && $param['controllerAction'] === 'saveList') {
         Fx::db()->remove(Fx::service_context()->namespace['rewrite']);
         foreach ($param['option'] as $v) {
             if ($v['from'] !== '') {
                 $v['from'] = $this->normalizeString($v['from']);
                 if ($v['to']) {
                     $v['to'] = $this->normalizeString($v['to']);
                 }
                 Fx::db()->insert(Fx::service_context()->namespace['rewrite'], $v);
             }
         }
     } else {
         $ctx = array_merge($ctx, array('dict' => Fx::service_context()->dict, 'list' => Fx::db()->find(Fx::service_context()->namespace['rewrite'])));
     }
     return $ctx;
 }
Ejemplo n.º 7
0
<?php

$lastChange = Fx::db()->extract(Fx::db()->go(array('event' => 'find', 'from' => Fx::service_context()->namespace['construct_db'], 'order' => '`date` DESC', 'limit' => 15)), function ($item, $db) {
    $data = $db->findOne($item['object'], array('id' => $item['id']));
    return array('date' => date('d.m.Y G:i', $item['date']), 'id' => $item['id'], 'name' => isset($data['name']) && $data['name'] !== '' ? $data['name'] : 'undefiend-' . $item['id'], 'url' => '?mode=elem&id=' . $item['id']);
});
$dbInfo = Fx::db()->tables_info();
Ejemplo n.º 8
0
 if (Fx::db()->isConnect()) {
     $login = trim($_POST['user']['login']);
     $pass = hashGenerate(strtolower(trim($_POST['user']['pass'])));
     foreach ($manifest['baseCollection'] as $k => $v) {
         Fx::db()->createCollection(array('name' => Fx::service_context()->namespace[$k], 'row' => $v));
     }
     $find = Fx::db()->find(Fx::service_context()->namespace['user'], array('login' => $login, 'pass' => $pass));
     if (count($find)) {
         Fx::db()->update(Fx::service_context()->namespace['user'], array('access' => 0), array('id' => $find[0]['id']));
     } else {
         Fx::db()->insert(Fx::service_context()->namespace['user'], array('login' => $login, 'pass' => $pass, 'access' => 0));
     }
     Fx::io()->create_file(root . '/config.php');
     Fx::io()->write(root . '/config.php', '<? return $config = ' . Fx::io()->arrayToString(Fx::service_context()->config) . '; ?>');
     $folderFrom = root . '/install/templating/' . Fx::service_context()->config['templating'] . '/';
     $folderTo = root . '/' . Fx::service_context()->config['folder']['template'] . '/';
     if (!is_dir($folderTo)) {
         Fx::io()->create_dir($folderTo);
     }
     $dir = Fx::io()->tree($folderFrom);
     foreach ($dir['dir'] as $v) {
         $folder = str_replace($folderFrom, '', $v);
         if (!is_dir($folderTo . $folder)) {
             Fx::io()->create_dir($folderTo . $folder);
         }
     }
     foreach ($dir['file'] as $v) {
         $file = explode('/', $v);
         $file = str_replace($folderFrom, '', $v);
         if (!file_exists($folderTo . $file)) {
             Fx::io()->copy($v, $folderTo . $file);
Ejemplo n.º 9
0
}
req($config, '/class/class_templating.php');
/** Устанлвка базового пути для контроллеров */
Fx::cLoader()->setPath(sys . '/template/controller/');
/** Устанлвка базового пути для статики */
Fx::cStatic()->root(sys);
/** Добавляем конфиги в контекст приложения */
Fx::service_context()->config = $config;
/** Добавляем манифест в контекст приложения */
Fx::service_context()->manifest = $manifest;
/** Алиасы имен бд */
Fx::service_context()->namespace = array();
foreach ($manifest['baseCollection'] as $k => $v) {
    Fx::service_context()->namespace[$k] = Fx::service_context()->config['db']['sys_namespace'] . $k;
}
Fx::service_context()->dict = $lang;
if (system_static) {
    Fx::cStatic()->set('template/js/jq.js');
    Fx::cStatic()->set('template/js/underscore.js');
    Fx::cStatic()->set('plugin/ckeditor/ckeditor.js');
    Fx::cStatic()->set('plugin/ckeditor/config.js');
    Fx::cStatic()->set('plugin/ckeditor/adapters/jquery.js');
    Fx::cStatic()->set('template/js/lib.js');
    Fx::cStatic()->set('template/js/datepicker.js');
    Fx::cStatic()->set('template/js/main.js');
    Fx::cStatic()->set('template/js/struct.js');
    Fx::cStatic()->set('template/tpl/blocks/table/table.js');
    Fx::cStatic()->set('template/tpl/blocks/project/project.js');
    Fx::cStatic()->set('template/tpl/blocks/object/object.js');
    Fx::cStatic()->set('template/js/setting.js');
    Fx::cStatic()->set('template/css/reset.css');
Ejemplo n.º 10
0
         throw new Exception('not found', 404);
     }
 } else {
     Fx::context()->template[] = 'home';
 }
 switch (trim(strtolower(Fx::service_context()->config['templating']))) {
     case 'twig':
         require_once Fx::service_context()->config['folder']['sys'] . '/templating/Twig/Autoloader.php';
         Twig_Autoloader::register();
         $loader = new Twig_Loader_Filesystem(root . '/template/');
         $twig = new Twig_Environment($loader, array('debug' => true));
         $twig->addExtension(new Twig_Extension_Debug());
         require_once Fx::service_context()->config['folder']['template'] . '/main.php';
         $render = '';
         foreach (Fx::context()->template as $v) {
             $filePHP = Fx::service_context()->config['folder']['template'] . '/php/' . $v . '.php';
             $fileHTML = 'twig/' . $v . '.twig';
             if (file_exists($filePHP)) {
                 require_once $filePHP;
                 $render .= $twig->render($fileHTML, (array) Fx::context());
             } else {
                 throw new Exception("Error Processing Request", 404);
             }
         }
         if (isset($_GET['show']) && $_GET['show'] == 'glob') {
             header('Content-Type: text/html');
             debug(Fx::context());
         } else {
             echo $render;
         }
         break;
Ejemplo n.º 11
0
<?php

Fx::context()->selfId = isset($_GET['id']) ? (int) $_GET['id'] : false;
if (Fx::context()->selfId && !count(Fx::db()->find(Fx::service_context()->namespace['construct_db'], array('id' => Fx::context()->selfId)))) {
    throw new Exception('not found', 404);
}
// Левое меню
require_once sys . '/template/php/project-menu.php';
$tables = Fx::db()->find(Fx::service_context()->namespace['struct_db']);
$rowslist = Fx::db()->find(Fx::service_context()->namespace['struct_td']);
$selfItem = Fx::db()->extract(Fx::db()->go(array('event' => 'find', 'from' => Fx::service_context()->namespace['construct_db'], 'where' => array('parent' => Fx::context()->selfId), 'order' => 'num')));
$rows = array();
foreach ($rowslist as $k => $v) {
    if (!isset($rows[$v['parent']])) {
        $rows[$v['parent']] = array();
    }
    $rows[$v['parent']][$v['code']] = $v;
}
$tabl = array();
foreach ($tables as $v) {
    if (isset($rows[$v['id']])) {
        $v['rows'] = $rows[$v['id']];
    }
    $tabl[$v['code']] = $v;
}
$selfList = array();
$selfList[] = '<ul class="js-sortable-list">';
foreach ($selfItem as $k => $j) {
    $id = $j['ref'] > 0 ? $j['ref'] : $j['id'];
    $item = Fx::db()->findOne($j['object'], array('id' => $id));
    if (is_array($item)) {
Ejemplo n.º 12
0
<?php

$leftMenu = Fx::db()->find(Fx::service_context()->namespace['struct_db']);
$text = array('<h3>Объекты</h3><ul>');
foreach ($leftMenu as $v) {
    $active = isset($_GET['id']) && $_GET['id'] == $v['id'] ? ' class="active"' : '';
    $text[] = '<li' . $active . '><a href="?mode=object&id=' . $v['id'] . '">' . $v['name'] . '</a></li>';
}
Fx::context()->leftMenu .= implode("\n", $text) . '</ul>';
Fx::context()->leftMenu .= '<a href="?mode=object" class="btn mt_mini"><span class="btn-in">Создать объект</span></a>';
// Текущий объект
$paramObject = '';
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
    $objectParam = Fx::db()->find(Fx::service_context()->namespace['struct_db'], array('id' => $id));
    $td = Fx::db()->find(Fx::service_context()->namespace['struct_td'], array('parent' => $id));
    if (is_array($objectParam) && is_array($td) && count($objectParam) && count($td)) {
        $len = count($td);
        $paramObject = array();
        foreach ($td as $k => $v) {
            $paramObject[] = Fx::io()->buffer(sys . '/template/tpl/template/object_item.html', array('key' => $k, 'value' => $v, 'zIndex' => $len - $k, 'manifest' => $manifest));
        }
        $paramObject = implode("\n", $paramObject);
    } else {
        throw new Exception('not found', 404);
    }
}
Ejemplo n.º 13
0
function removeElem($id, $object = '')
{
    while (true) {
        if ($object == '') {
            $object = Fx::db()->find(Fx::service_context()->namespace['construct_db'], array('$or' => array('id' => $id, 'ref' => $id)));
        }
        Fx::db()->remove($object[0]['object'], array('id' => $id));
        Fx::db()->remove(Fx::service_context()->namespace['construct_db'], array('id' => $id));
        $path = root . '/' . Fx::service_context()->config['folder']['files'] . '/' . $id . '/';
        Fx::io()->del($path);
        $find = Fx::db()->find(Fx::service_context()->namespace['construct_db'], array('parent' => $id));
        if (count($find)) {
            foreach ($find as $v) {
                removeElem($v['id'], array($v));
            }
        } else {
            break;
        }
    }
}
Ejemplo n.º 14
0
    Fx::context()->selfId = Fx::context()->parent_object;
}
$pathGist = sys . '/template/tpl/gist-elem/';
$tablParam = array();
$tableName = isset($_GET['name']) ? $_GET['name'] : '';
$objectValue = array();
if (isset($_GET['id']) && (int) $_GET['id'] > 0) {
    $selfObject = Fx::db()->find(Fx::service_context()->namespace['construct_db'], array('id' => (int) $_GET['id']));
    if (count($selfObject)) {
        $tableName = $selfObject[0]['object'];
        $objectValue = Fx::db()->find($tableName, array('id' => $selfObject[0]['id']));
        $objectValue = $objectValue[0];
    }
}
if ($tableName != '') {
    $tabl = Fx::db()->find(Fx::service_context()->namespace['struct_db'], array('code' => $tableName));
    $tablParam = $tabl[0];
} else {
    setSystemMessage('error', 'Не заданы параметры для редактирования');
    load_url();
}
$row = Fx::db()->find(Fx::service_context()->namespace['struct_td'], array('parent' => $tablParam['id']));
$result = array();
foreach ($row as $key => $v) {
    $result[] = loadParam($key, array('row' => $v, 'value' => isset($objectValue[$v['code']]) ? $objectValue[$v['code']] : ''), $manifest, $pathGist . $v['type'] . '.html');
}
// Шаблоны
$template = Fx::db()->find(Fx::service_context()->namespace['marker']);
// Левое меню
require_once sys . '/template/php/project-menu.php';
$isShowSystem = Fx::context()->struct_db[$tableName]['show_sistem'] == '1';
Ejemplo n.º 15
0
 public function migrate($post)
 {
     $tables = Fx::db()->tables_info();
     $tables = array_keys($tables['table']);
     $prefix = Fx::service_context()->config['db']['sys_namespace'];
     $collections = array_keys(Fx::service_context()->manifest['baseCollection']);
     $isTrue = 0;
     $isFalse = 0;
     foreach ($collections as $v) {
         if (!in_array($prefix . $v, $tables)) {
             if (Fx::db()->createCollection(array('name' => $prefix . $v, 'row' => Fx::service_context()->manifest['baseCollection'][$v]))) {
                 $isTrue++;
             } else {
                 $isFalse++;
             }
         }
     }
     echo 'Создано таблиц ' . $isTrue . ', не смогли создать таблиц ' . $isFalse;
 }
Ejemplo n.º 16
0
<?php

access(0);
// Root
Fx::context()->users = Fx::db()->find(Fx::service_context()->namespace['user']);
Ejemplo n.º 17
0
<?php

access(0, 1);
// Root / Admin
$markerList = Fx::db()->find(Fx::service_context()->namespace['marker']);
$templateList = Fx::db()->find(Fx::service_context()->namespace['template']);
Ejemplo n.º 18
0
 private function saveHistoryLink()
 {
     $history_link = Fx::db()->find(Fx::service_context()->namespace['history-link'], array('link' => $_SERVER['REQUEST_URI']));
     if (!count($history_link)) {
         Fx::db()->insert(Fx::service_context()->namespace['history-link'], array('link' => $_SERVER['REQUEST_URI']));
     }
 }