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); }
private function copyFolderElement_($from, $to) { $pathFrom = Fx::io()->path(root, Fx::service_context()->config['folder']['files'], $from); $pathTo = Fx::io()->path(root, Fx::service_context()->config['folder']['files'], $to); if (is_dir($pathFrom)) { Fx::io()->copy($pathFrom, $pathTo); } }
/** * @param string $prefix * @return array */ public function getScript($prefix = '') { $result = array(); foreach ($this->paths as $v) { $mime = Fx::io()->mime($v); if (in_array($mime, array('js'))) { $result[] = '<script src="' . $prefix . $v . '" type="text/javascript"></script>'; } } return $result; }
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; }
public function pushToSiteMapXML($post) { if (isset($post['text'])) { Fx::io()->write(Fx::io()->path(root, 'sitemap.xml'), $post['text']); } load_url(); }
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); } } load_url(); } else { load_url(); } } require_once 'main.html';
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)) { $selfList[] = Fx::io()->buffer(sys . '/template/tpl/blocks/project-list-item.html', array('index' => $k + 1, 'id' => $id, 'ref' => $j['ref'], 'num' => $j['num'], 'object' => $j, 'date' => date('d.m.Y G:i (s)', $j['date']), 'data' => $item, 'name' => isset($item['name']) && $item['name'] != '' ? $item['name'] : 'undefiend-' . $j['id'], 'hide-icon' => $j['hide'] == 1 ? 'icon-eye-off' : 'icon-eye', 'icon' => $tabl[$j['object']]['icon'], 'data-list' => $tabl[$j['object']]['rows'])); } } $selfList[] = '</ul>';
<?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); } }
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; } } }
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>'; } } } $leftMenu = new Path(Fx::context()->path); $elemId = isset($_GET['id']) ? '&parent=' . $_GET['id'] : ''; Fx::context()->create_element_button = Fx::io()->buffer(sys . '/template/tpl/blocks/project/create-element-button.html', array('object' => Fx::context()->struct_db, 'elemID' => $elemId)); Fx::context()->left_menu_items = array(); Fx::context()->left_menu_items[] = array('name' => 'Структура проекта', 'block' => '<ul class="project-menu-list">' . $leftMenu->result . '</ul>' . Fx::context()->create_element_button); Fx::context()->leftMenu .= Fx::io()->buffer(sys . '/template/tpl/blocks/project/project-menu.html', Fx::context()->left_menu_items); // Формируем хлебные крошки $crumbs = array(); foreach (Fx::context()->path as $v) { $find = Fx::db()->find($v['object'], array('id' => $v['id'])); $crumbs[$v['id']] = isset($find[0]['name']) && $find[0]['name'] != '' ? $find[0]['name'] : 'undefiend-' . $v['id']; }
} } } } } if (isset($_GET['extension']) && $_GET['extension'] !== '' && $extView !== '') { $php = $extController; $tpl = $extView; } /** Рендерим страници */ try { if (file_exists($php)) { require_once $php; } ob_start(); require_once $tpl; Fx::context()->content = ob_get_contents(); ob_end_clean(); require_once 'template/main.html'; } catch (Exception $e) { Fx::context()->leftMenu = ''; $param = array('code' => $e->getCode(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()); if ($e->getCode() === 403) { $param['text'] = 'Доступ запрещен'; } if ($e->getCode() === 404) { $param['text'] = 'Такая страница не существует'; } Fx::context()->content = Fx::io()->buffer(sys . '/template/error.html', $param); require_once 'template/main.html'; }