Ejemplo n.º 1
0
 private function copyItem_($parent, $id)
 {
     $CONSTRUCT = Fx::service_context()->namespace['construct_db'];
     $copy_object = Fx::db()->findOne($CONSTRUCT, array('id' => $id));
     $copy_item = Fx::db()->findOne($copy_object['object'], array('id' => $copy_object['id']));
     $rows = $this->db_rows[$copy_object['object']]['rows'];
     $back_id = $copy_object['id'];
     unset($copy_object['id']);
     $copy_object['parent'] = $parent;
     $copy_object['num'] = count(Fx::db()->find($CONSTRUCT, array('parent' => $parent)));
     Fx::db()->insert($CONSTRUCT, $copy_object);
     Fx::service_context()->copyId = $copy_item['id'] = Fx::db()->lastId();
     $this->copyFolderElement_($back_id, Fx::service_context()->copyId);
     foreach ($rows as $v) {
         if (in_array($v['type'], array('file', 'image'))) {
             if (!isset($copy_item[$v['code']])) {
                 continue;
             }
             if (empty($copy_item[$v['code']])) {
                 continue;
             }
             $file = explode('/', $copy_item[$v['code']]);
             $file = array_pop($file);
             $file = '/' . Fx::service_context()->config['folder']['files'] . '/' . Fx::service_context()->copyId . '/' . $file;
             $copy_item[$v['code']] = file_exists(root . $file) ? $file : '';
         }
     }
     Fx::db()->insert($copy_object['object'], $copy_item);
     Fx::db()->getList(array('parent' => $id), function ($item) {
         Fx::lib()->copyItem(Fx::service_context()->copyId, $item['id']);
     });
 }
Ejemplo n.º 2
0
 public function pasteItem($post, $get)
 {
     $parent = (int) $get['id'];
     if (isset($_SESSION['copyItem']) && count($_SESSION['copyItem'])) {
         $id = $_SESSION['copyItem'];
         $event = 'copy';
         $_SESSION['copyItem'] = array();
     } else {
         if (isset($_SESSION['moveItem']) && count($_SESSION['moveItem'])) {
             $id = $_SESSION['moveItem'];
             $event = 'move';
             $_SESSION['moveItem'] = array();
         } else {
             throw new Exception();
         }
     }
     foreach ($id as $v) {
         if ($event == 'move') {
             $num = count(Fx::db()->find(Fx::service_context()->namespace['construct_db'], array('parent' => $parent)));
             Fx::db()->update(Fx::service_context()->namespace['construct_db'], array('parent' => $parent, 'num' => $num, 'date' => time()), array('id' => (int) $v));
         } else {
             Fx::lib()->copyItem($parent, (int) $v);
         }
     }
     load_url();
 }
Ejemplo n.º 3
0
<?php

header("Content-Type: text/html; charset=utf-8");
error_reporting(E_ALL);
try {
    define('root', $_SERVER['DOCUMENT_ROOT']);
    if (!file_exists(root . '/config.php')) {
        require_once 'install/index.php';
        die;
    }
    define('system_static', false);
    define('connect_to_db', false);
    require_once 'config.php';
    define('sys', root . '/' . $config['folder']['sys']);
    require_once sys . '/requerid.php';
    Fx::lib()->rewrite();
    Fx::context()->path = Fx::db()->path($_SERVER['REQUEST_URI']);
    if (Fx::context()->path === false) {
        throw new Exception('Not found', 404);
    }
    Fx::context()->template = array();
    if (count(Fx::context()->path) > 0) {
        Fx::context()->self_object = end(Fx::context()->path);
        if ((int) Fx::context()->self_object['marker'] !== 0) {
            $marker = Fx::db()->find(Fx::service_context()->namespace['marker'], array('id' => Fx::context()->self_object['marker']));
            $marker = explode(',', $marker[0]['template_id']);
            foreach ($marker as $v) {
                $template = Fx::db()->find(Fx::service_context()->namespace['template'], array('id' => $v));
                Fx::context()->template[] = $template[0]['name'];
            }
        } else {