<?php

/* This File is part of Camila PHP Framework
   Copyright (C) 2006-2009 Umberto Bresciani
   
   Camila PHP Framework is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   Camila PHP Framework is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with Camila PHP Framework; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
require '../camila/header.php';
require CAMILA_DIR . 'datagrid/configurator.class.php';
$configurator = new configurator();
$configurator->configure_table($_REQUEST['camila_custom'], false, $_REQUEST['camila_returl']);
require '../camila/footer.php';
Beispiel #2
0
function XLS_import2($file, $table, $db)
{
    $filename = basename($file);
    $sequence = intval(substr($filename, 0, strpos($filename, '_')));
    $res = $db->Execute('select id from ' . CAMILA_TABLE_WORKT . ' where filename=' . $db->qstr($filename));
    if ($res === false) {
        camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg());
    }
    $id = $res->fields['id'];
    $result = array();
    $configurator = new configurator();
    $configurator->filename = $file;
    $configurator->sheetnum = 0;
    $configurator->interactive = false;
    $db->SetFetchMode(ADODB_FETCH_ASSOC);
    $configurator->db = $db;
    $configurator->configure_table($id, false);
    $record = array();
    $res = $db->Execute('select * from ' . CAMILA_TABLE_WORKT . ' where id=' . $db->qstr($id));
    if ($res === false) {
        camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg());
    }
    $record['short_title'] = $res->fields['short_title'];
    $record['full_title'] = $res->fields['full_title'];
    $record['label_order'] = $sequence;
    $scriptname = $res->fields['scriptname'];
    $category = $res->fields['category'];
    $updateSQL = $db->AutoExecute(CAMILA_TABLE_PLANG, $record, 'UPDATE', 'page_url=' . $db->qstr($scriptname) . ' and lang=' . $db->qstr($_REQUEST['lang']));
    if (!$updateSQL) {
        camila_information_text(camila_get_translation('camila.worktable.db.error'));
    }
    if (trim($category) != '') {
        $res = $db->Execute('select page_url from ' . CAMILA_TABLE_PLANG . ' where short_title=' . $db->qstr($category) . ' AND page_url LIKE ' . $db->qstr('cf_app.php?cat%') . ' and lang=' . $db->qstr($_REQUEST['lang']));
        if ($res === false) {
            camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg());
        }
        $cat_url = '-';
        if ($res->RecordCount() == 0) {
            $res = $db->Execute('select page_url from ' . CAMILA_TABLE_PLANG . ' where full_title<>' . $db->qstr('-') . ' AND page_url LIKE ' . $db->qstr('cf_app.php?cat%') . ' and lang=' . $db->qstr($_REQUEST['lang']));
            if ($res === false) {
                camila_error_page(camila_get_translation('camila.sqlerror') . ' ' . $db->ErrorMsg());
            }
            $cat_url = $res->fields['page_url'];
            $record = array();
            $record['label_order'] = $sequence;
            $record['short_title'] = $category;
            $record['full_title'] = '-';
            $updateSQL = $db->AutoExecute(CAMILA_TABLE_PLANG, $record, 'UPDATE', 'page_url=' . $db->qstr($cat_url) . ' and lang=' . $db->qstr($_REQUEST['lang']));
            if (!$updateSQL) {
                camila_information_text(camila_get_translation('camila.worktable.db.error'));
            }
        } else {
            $cat_url = $res->fields['page_url'];
        }
        $record = array();
        $record['parent'] = $cat_url;
        $updateSQL = $db->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $db->qstr($scriptname));
        if (!$updateSQL) {
            camila_information_text(camila_get_translation('camila.worktable.db.error'));
        }
        $record = array();
        $record['visible'] = 'yes';
        $updateSQL = $db->AutoExecute(CAMILA_TABLE_PAGES, $record, 'UPDATE', 'url=' . $db->qstr($cat_url));
        if (!$updateSQL) {
            camila_information_text(camila_get_translation('camila.worktable.db.error'));
        }
    }
    $result['result'] = 2;
    //success
    $result['processed'] = 1;
    $result['failed'] = 0;
    return $result;
}