commit 83074070a4cfc49bcfa31cd1530931c5d7a41b70
parent 147e747128543b5ff79d6e9072aadc447ca8af40
Author: dankert <devnull@localhost>
Date: Mon, 12 Apr 2004 18:16:23 +0200
*** empty log message ***
Diffstat:
element.php | | | 259 | ------------------------------------------------------------------------------- |
file.php | | | 339 | ------------------------------------------------------------------------------- |
template.php | | | 507 | ------------------------------------------------------------------------------- |
3 files changed, 0 insertions(+), 1105 deletions(-)
diff --git a/element.php b/element.php
@@ -1,258 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// DaCMS Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program 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.
-//
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.1 2003-09-25 20:26:25 dankert
-// *** empty log message ***
-//
-// ---------------------------------------------------------------------------
-
-$conf = parse_ini_file( 'config.ini.php',true );
-
-require_once( $conf['directories']['incldir'].
- '/config.inc.'.
- $conf['global']['ext'] );
-
-session_start();
-
-
-include( "DB.php" );
-
-include( "$conf_incldir/language.inc.$conf_php" );
-include( "$conf_incldir/theme.inc.$conf_php" );
-include( "$conf_incldir/db.inc.$conf_php" );
-include( "$conf_incldir/page.inc.$conf_php" );
-include( "$conf_incldir/request.inc.$conf_php" );
-
-request_into_session('elementid');
-request_into_session('elementaction');
-
-session_write_close();
-
-$var = array();
-
-// Datenbank Verbindung
-$db = db_connection();
-
-
-// Ändern des Element-Typs
-//
-if ($REQ['elementaction'] == 'changetype')
-{
- // SQL-Befehl
- $sql = "UPDATE $t_element ".
- "SET type='".$REQ['type']."' ".
- "WHERE id=".$SESS['elementid'];
- echo $sql;
- $res = $db->query($sql);
- #if ($res->isError()) die ('fehler');
- #$res->free();
-
- $elementaction = 'edit';
-}
-
-
-
-if ($elementaction == 'edit')
-{
- $sql = "SELECT * FROM $t_element WHERE id=".$SESS['elementid'];
- $res = $db->query($sql);
- $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
- $res->free();
-
- $var['action'] = 'template.'.$conf_php;
- $var['self' ] = 'element.'.$conf_php;
- $var['name'] = $row['name'];
- $var['desc'] = $row['desc'];
-
- $var['type'] = array();
- $var['type']['include'] = '';
- $var['type']['date'] = '';
- $var['type']['text'] = '';
- $var['type']['longtext'] = '';
- $var['type']['number'] = '';
- $var['type']['link'] = '';
- $var['type']['file'] = '';
- $var['type']['resize'] = '';
- $var['type']['code'] = '';
- $var['type']['info'] = '';
- $var['type']['infodate'] = '';
- $var['type']['code'] = '';
-
- foreach( $var['type'] as $k=>$t )
- {
- $var['type'][ $k ] = lang('EL_'.$k);
- }
-
- $var['default_type'] = $row['type'];
-
-
- // Eigenschaften Info-Datum
- if ($row['type'] == 'infodate' )
- {
- $var['subtype'] = array();
- $var['subtype']['date_published'] = '';
- $var['subtype']['date_saved' ] = '';
- foreach( $var['subtype'] as $k=>$t )
- {
- $var['subtype'][ $k ] = lang($k);
-
- if ( $k == $row['subtype'] )
- $var['act_subtype'] = $k;
- }
- }
-
-
- // Eigenschaften allg. Info-Element
- if ($row['type'] == 'info' )
- {
- $var['subtype'] = array();
- $var['subtype']['id_db'] = '';
- $var['subtype']['id_project'] = '';
- $var['subtype']['id_page'] = '';
- $var['subtype']['id_user'] = '';
- $var['subtype']['id_pageuser'] = '';
- $var['subtype']['id_projectmodel'] = '';
- $var['subtype']['id_language'] = '';
- $var['subtype']['name_db'] = '';
- $var['subtype']['name_project'] = '';
- $var['subtype']['name_page'] = '';
- $var['subtype']['name_user'] = '';
- $var['subtype']['fullname_user'] = '';
- $var['subtype']['mail_user'] = '';
- $var['subtype']['name_pageuser'] = '';
- foreach( $var['subtype'] as $k=>$t )
- {
- $var['subtype'][ $k ] = lang($k);
-
- if ( $k == $row['subtype'] )
- $var['act_subtype'] = $k;
- }
- }
-
-
- // Eigenschaften Info-Datum und allg. Datum
- if ($row['type'] == 'infodate' || $row['type'] == 'date')
- {
- $ini_date_format = parse_ini_file( $conf_languagedir.'/dateformat.ini.'.$conf_php );
- $var['dateformat'] = array();
- foreach($ini_date_format as $idx=>$d)
- {
- $var['dateformat'][$idx] = date($d);
-
- if ( $d == $row['dateformat'] )
- $var['act_dateformat'] = $idx;
- }
-
- }
-
-
- // Eigenschaften verkleinertes Bild
- if ($row['type'] == 'resize')
- {
- // Alle Ordner ermitteln
- $var['folder'] = array();
- $var['folder']['null'] = '<'.lang('ROOT_DIRECTORY').'>';
-
- $sql = "SELECT * FROM $t_folder ".
- "WHERE projectid=".$SESS['projectid'];
- $res_f = $db->Query($sql);
- while( $row_f = $res_f->fetchRow() )
- {
- $var['folder'][$row_f['id']] = implode('/',folder_path($row_f['id'],false));
- }
- asort( $var['folder'] );
-
- $var['act_folderid'] = isset($row['folderid' ]) ? $row['folderid'] : '';
-
- $var['width'] = isset($row['width']) ? $row['width'] : '';
- $var['height'] = isset($row['height']) ? $row['height'] : '';
- }
-
-
- // Eigenschaften Datei
- if ($row['type'] == 'file')
- {
- // Alle Ordner ermitteln
- $var['folder'] = array();
- $var['folder']['null'] = '<'.lang('ROOT_DIRECTORY').'>';
-
- $sql = "SELECT * FROM $t_folder ".
- "WHERE projectid=".$SESS['projectid'];
- $res_f = $db->Query($sql);
- while( $row_f = $res_f->fetchRow() )
- {
- $var['folder'][$row_f['id']] = implode('/',folder_path($row_f['id'],false));
- }
- asort( $var['folder'] );
-
- $var['act_folderid'] = isset($row['folderid' ]) ? $row['folderid'] : '';
- $var['extension'] = isset($row['extension']) ? $row['extension'] : '';
- }
-
-
- // Eigenschaften Text und Text-Absatz
- if ($row['type'] == 'text' )
- {
- $var['default_text'] = isset($row['default_text']) ? $row['default_text'] : '';
- $var['wiki'] = isset($row['wiki' ]) ? $row['wiki' ] : '';
- $var['html'] = isset($row['html' ]) ? $row['html' ] : '';
- }
-
-
- // Eigenschaften PHP-Code
- if ($row['type'] == 'code' )
- {
- $var['code'] = isset($row['code']) ? $row['code'] : '';
- }
-
-
- // Eigenschaften Text und Text-Absatz
- if ($row['type'] == 'longtext')
- {
- $var['default_longtext'] = isset($row['default_text']) ? $row['default_text'] : '';
- $var['wiki'] = isset($row['wiki' ]) ? $row['wiki' ] : '';
- $var['html'] = isset($row['html' ]) ? $row['html' ] : '';
- }
-
-
-
- // Eigenschaften Zahl
- if ($row['type'] == 'number')
- {
- $var['decimals'] = isset($row['decimals' ]) ? $row['decimals' ] : '';
- $var['dec_point'] = isset($row['dec_point' ]) ? $row['dec_point' ] : '';
- $var['thousand_sep'] = isset($row['thousand_sep']) ? $row['thousand_sep'] : '';
- }
-
-
- // Eigenschaften Link auf Seite
- if ($row['type'] == 'link')
- {
- $var['default_link'] = $row['default_link'];
- }
-
- //print_r($var);
- output('element',$var);
-}
-
-
-?>-
\ No newline at end of file
diff --git a/file.php b/file.php
@@ -1,338 +0,0 @@
-<?php
-/*
- DaCMS Content Management System
- Copyright (C) 2002,2003 Jan Dankert, jd@jandankert.de
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- $Id$
-
- $Log$
- Revision 1.1 2003-09-25 20:07:15 dankert
- *** empty log message ***
-
-*/
-
-$conf = parse_ini_file( 'config.ini.php',true );
-
-require_once( $conf['directories']['incldir'].
- '/config.inc.'.
- $conf['global']['ext'] );
-
-session_start();
-
-
-include( "DB.php" );
-
-include( "$conf_incldir/language.inc.$conf_php" );
-include( "$conf_incldir/theme.inc.$conf_php" );
-include( "$conf_incldir/request.inc.$conf_php" );
-include( "$conf_incldir/db.inc.$conf_php" );
-include( "$conf_incldir/file.inc.$conf_php" );
-include( "$conf_incldir/page.inc.$conf_php" );
-include( "$conf_incldir/ftp.inc.$conf_php" );
-
-request_into_session('fileid');
-request_into_session('fileaction');
-
-if (!isset($SESS['fileaction']))
- $SESS['fileaction'] = 'show';
-
-// Verbindung zur Datenbank
-//
-$db = new DB( $conf['database_'.$SESS['dbid']] );
-
-$var = array();
-
-if ( $SESS['fileaction'] == 'replace' )
-{
- $fileHandle = fopen($FILES['file']['tmp_name'],'r');
- $fileContent = fread($fileHandle,filesize($FILES['file']['tmp_name']));
- $fileSize = strlen($fileContent);
- $fileContent = addslashes($fileContent);
-
- $filename = $FILES['file']['name'];
- $extension = '';
- $p = strrpos($filename,'.');
- if ($p!==false)
- {
- $extension = substr( $filename,$p+1 );
- $filename = substr( $filename,0,$p );
- }
-
- $sql = "UPDATE $t_file SET ".
- "folderid='".$SESS['folderid']."',".
- "filename='$filename',".
- "extension='$extension',".
- "size='".$fileSize."',".
- "lastchange_date=".time().",".
- "lastchange_userid='".$SESS['user']['id']."',".
- "value='".$fileContent."' ".
- "WHERE id=".$SESS['fileid'];
- $res = $db->query($sql);
- if (DB::isError($db)) die ($db->getMessage());
-
- $SESS['fileaction'] = 'prop';
- $var['tree_refresh'] = true;
-}
-
-
-if ( $SESS['fileaction'] == 'move' )
-{
- $t_file = $conf_db_prefix.'file';
-
- // Hauptverzeichnis (folderid=NULL) oder sonstiger Ordner
- if ($REQ['folderid'] == 'null')
- $f_id = 'NULL';
- else $f_id = "'".$REQ['folderid']."'";
- $sql = "UPDATE $t_file SET ".
- "lastchange_date=".time().",".
- "lastchange_userid='".$SESS['user']['id']."',".
- "folderid=$f_id ".
- "WHERE id=".$SESS['fileid'];
- $res = $db->query($sql);
-
- $SESS['fileaction'] = 'prop';
- $var['tree_refresh'] = true;
-}
-
-
-if ( $SESS['fileaction'] == 'savevalue' )
-{
- $sql = "UPDATE $t_file SET ".
- "lastchange_date=".time().",".
- "lastchange_userid='".$SESS['user']['id']."',".
- "value='".$REQ['value']."'".
- "WHERE id=".$SESS['fileid'];
- $res = $db->query($sql);
-
- $SESS['fileaction'] = 'prop';
-}
-
-
-if ( $SESS['fileaction'] == 'save' )
-{
- // Falls Name leer, dann Dateinamen dafür benutzen
- if ( $REQ['name'] == '' )
- $REQ['name'] = $REQ['filename'];
-
- // Wenn Dateiname gefüllt, dann Datenbank-Update
- if ( $REQ['filename'] != '' )
- {
- $sql = "UPDATE $t_file SET ".
- "lastchange_date=".time().",".
- "lastchange_userid='".$SESS['user']['id']."',".
- "filename='".$REQ['filename']."',".
- "name='".$REQ['name']."',".
- "extension='".$REQ['extension']."', ".
- "`desc`='".$REQ['desc']."' ".
- "WHERE id=".$SESS['fileid'];
- $res = $db->query($sql);
- }
-
- $SESS['fileaction'] = 'edit';
- $var['tree_refresh'] = true;
-}
-
-
-if ( $SESS['fileaction'] == 'show' )
-{
- $mime_types = parse_ini_file( "$conf_languagedir/mime-types.ini.$conf_php" );
-
- $sql = "SELECT extension,value FROM $t_file ".
- "WHERE id=".$SESS['fileid'];
- $res = $db->query($sql);
-
- $row = & $res->fetchRow(DB_FETCHMODE_ASSOC);
-
- $mime = $mime_types[ strtolower($row['extension']) ];
- if ( $mime == '' )
- $mime = 'application/octet-stream';
-
- header('Content-Type: '.$mime);
-
- echo $row['value'];
-
- $res->free();
-}
-
-
-if ( $SESS['fileaction'] == 'showresize' )
-{
- $mime_types = parse_ini_file( "$conf_languagedir/mime-types.ini.$conf_php" );
-
- $file = new File();
- $file->fileid = $SESS['fileid'];
- $file->load();
- $file->resize( $REQ['width'],$REQ['height']);
-
- $mime = $mime_types[ strtolower($file->extension) ];
- if ( $mime == '' )
- $mime = 'application/octet-stream';
-
- header('Content-Type: '.$mime);
-
- readfile( $file->tmpfile );
-}
-
-
-if ( $SESS['fileaction'] == 'edit' )
-{
- $mime_types = parse_ini_file( "$conf_languagedir/mime-types.ini.$conf_php" );
-
- $t_file = $conf_db_prefix.'file';
- $sql = "SELECT name,filename,extension,`desc`,size,create_date,create_userid,lastchange_date,lastchange_userid FROM $t_file ".
- "WHERE id=".$SESS['fileid'];
- $row = $db->getRow($sql);
-
- $mime = $mime_types[ $row['extension'] ];
- if ( $mime == '' )
- $mime = 'application/octet-stream';
-
- $var = array_merge( $var,$row );
- $var['mime'] = $mime;
-
- if ( substr($mime,0,5) == 'text/' )
- $var['src_url'] = 'file.'.$conf_php.'?fileaction=src';
-
- $sql = "SELECT name,fullname,mail ".
- "FROM $t_user ".
- "WHERE id=".$var['lastchange_userid'];
- $row = $db->getRow($sql);
- $var['lastchange_user'] = $row;
- $var['lastchange_user']['url'] = 'main.'.$conf_php.'?action=user&useraction=show&userid='.$var['lastchange_userid'];
-
- $sql = "SELECT name,fullname,mail ".
- "FROM $t_user ".
- "WHERE id=".$var['create_userid'];
- $row = $db->getRow($sql);
- $var['create_user'] = $row;
- $var['create_user']['url'] = 'main.'.$conf_php.'?action=user&useraction=show&userid='.$var['create_userid'];
-
- // Alle Ordner ermitteln
- $var['act_folderid'] = $SESS['folderid'];
- $var['folder'] = array();
- $var['folder']['null'] = '<'.lang('ROOT_DIRECTORY').'>';
-
- $sql = "SELECT * FROM $t_folder ".
- "WHERE projectid=".$SESS['projectid'];
- $res_f = $db->Query($sql);
- while( $row_f = $res_f->fetchRow() )
- {
- $var['folder'][$row_f['id']] = implode('/',folder_path($row_f['id']));
- }
-
- output( 'file_edit',$var );
-}
-
-
-if ( $SESS['fileaction'] == 'src' )
-{
- $sql = "SELECT value FROM $t_file ".
- "WHERE id=".$SESS['fileid'];
-
- $var['value'] = $db->getOne($sql);
-
- $SESS['fileaction'] = 'edit';
-
- output( 'file_src',$var );
-}
-
-
-if ( $SESS['fileaction'] == 'prop' )
-{
- $mime_types = parse_ini_file( "$conf_languagedir/mime-types.ini.$conf_php" );
-
- $sql = "SELECT filename,extension,`desc`,size,create_date,create_userid,lastchange_date,lastchange_userid ".
- "FROM $t_file ".
- "WHERE id=".$SESS['fileid'];
-
- $row = $db->getRow($sql);
- $var = array_merge( $var,$row );
-
- $sql = "SELECT name,fullname,mail ".
- "FROM $t_user ".
- "WHERE id=".$row['lastchange_userid'];
- $row = $db->getRow($sql);
- $var['lastchange_user'] = $row;
- $var['lastchange_user']['url'] = 'action.'.$conf_php.'?action=user&useraction=show&userid='.$row['id'];
-
- $sql = "SELECT name,fullname,mail ".
- "FROM $t_user ".
- "WHERE id=".$row['create_userid'];
- $row = $db->getRow($sql);
- $var['create_user'] = $row;
- $var['create_user']['url'] = 'action.'.$conf_php.'?action=user&useraction=show&userid='.$row['id'];
-
- $mime = $mime_types[ $row['extension'] ];
- if ( $mime == '' )
- $mime = 'application/octet-stream';
-
- $var['mime'] = $mime;
- output( 'file_prop',$var );
-}
-
-
-if ( $SESS['fileaction'] == "pub" )
-{
- $var['filenames'] = array();
- // Projektdaten ermitteln
- $sql = "SELECT * FROM $t_project WHERE id=".$SESS['projectid'];
- $row = $db->getRow( $sql );
-
- $is_ftp = false;
-
- if ( $row['ftp_url'] != '' )
- {
- $ftp = new Ftp( $row['ftp_url'] );
- $is_ftp = true;
- }
-
- $file = new File();
- $file->fileid = $SESS['fileid'];
-
- $file->load();
-
- $source = $file->tmpfile;
- $dest = $row['target_dir'].'/'.$file->full_filename();
-
- $var['filenames'][] = $file->full_filename();
-
- if (!copy( $source,$dest ));
- {
- mkdirs( dirname($dest) );
-
- if (!copy( $source,$dest ))
- {
- // error
- }
- }
-
- if ( $is_ftp )
- {
- $dest = $file->full_filename();
- $ftp->put( $source,$dest,FTP_ASCII );
- }
-
- if ( $is_ftp )
- {
- $ftp->close();
- }
-
- output('file_publish',$var);
-}
-
-
-?>-
\ No newline at end of file
diff --git a/template.php b/template.php
@@ -1,506 +0,0 @@
-<?php
-// ---------------------------------------------------------------------------
-// $Id$
-// ---------------------------------------------------------------------------
-// DaCMS Content Management System
-// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
-//
-// This program 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.
-//
-// This program 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 this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// ---------------------------------------------------------------------------
-// $Log$
-// Revision 1.1 2003-10-02 21:44:44 dankert
-// erste Version
-//
-// ---------------------------------------------------------------------------
-
-$conf = parse_ini_file( 'config.ini.php',true );
-
-require_once( $conf['directories']['incldir'].
- '/config.inc.'.
- $conf['global']['ext'] );
-
-session_start();
-
-
-include( "DB.php" );
-
-include( "$conf_incldir/language.inc.$conf_php" );
-include( "$conf_incldir/theme.inc.$conf_php" );
-include( "$conf_incldir/request.inc.$conf_php" );
-include( "$conf_incldir/db.inc.$conf_php" );
-
-request_into_session('tplaction');
-request_into_session('elementaction');
-request_into_session('templateid');
-request_into_session('templatemodelid');
-
-$var = array();
-
-$db = db_connection();
-
-// Zugriff nur für Administratoren gestattet
-if ( $SESS['user']['is_admin'] != '1' )
- die('access denied');
-
-// Speichern des Quelltextes
-//
-if ( $SESS['tplaction'] == 'srcsave' )
-{
- $text = $REQ['src'];
-
- $sql = "SELECT * FROM $t_element WHERE templateid=".$SESS['templateid'];
- $res = $db->query($sql);
-
- if ($res->numRows() > 0)
- {
- while( $el = $res->fetchRow() )
- {
- // Falls dieses Element hinzugefügt werden soll
- if ($REQ['addelement']=='1' && $REQ['elementid']==$el['id'])
- {
- $text .= "\n".'{{'.$el['id'].'}}';
- }
-
- if ($REQ['addicon']=='1' && $REQ['iconid']==$el['id'])
- {
- $text .= "\n".'{{->'.$el['id'].'}}';
- }
-
- $text = str_replace('%%'.$el['name'].'%%' ,'{{'.$el['id'].'}}',$text );
- $text = str_replace('%%->'.$el['name'].'%%','{{->'.$el['id'].'}}',$text );
- }
- }
- $res->free();
-
- // Speichern des Quelltextes
- //
- $sql = "UPDATE $t_templatemodel ".
- "SET text='".$text."' ".
- "WHERE id=".$REQ['templatemodelid'];
- $res = $db->query($sql);
- //echo "$sql";
- if (DB::isError($db)) die ($db->getMessage());
-
-
- // Wenn Element hinzugefügt wurde, dann bleibt es beim Quelltext-Modus.
- // Sonst wird zur Anzeige umgeschaltet
-
- if ($REQ['addelement']=='1' || $REQ['addicon']=='1')
- {
- $SESS['tplaction'] = 'src';
- }
- else
- {
- $SESS['tplaction'] = 'show';
- }
-}
-
-
-// Speichern des Namens
-//
-if ( $SESS['tplaction'] == 'propsave' )
-{
- if ( $REQ['name'] != '' )
- {
- $sql = "UPDATE $t_template ".
- "SET name='".$REQ['name']."' ".
- "WHERE id=".$SESS['templateid'];
- $res = $db->query($sql);
- }
-
- $var['tree_refresh'] = true;
- $SESS['tplaction'] = 'show';
-}
-
-
-// Speichern der Dateiendung
-//
-if ( $SESS['tplaction'] == 'extensionsave' )
-{
- if ( $REQ['extension'] != '' )
- {
- $sql = "UPDATE $t_templatemodel ".
- " SET extension='".$REQ['extension']."' ".
- " WHERE templateid=".$SESS['templateid'].
- " AND projectmodelid=".$SESS['projectmodelid'];
- $res = $db->query($sql);
- }
-
- $SESS['tplaction'] = 'show';
-}
-
-
-if ( !isset($SESS['tplaction']))
- $SESS['tplaction'] = 'show';
-
-
-if ( $SESS['tplaction'] != 'list' )
-{
- $sql = "SELECT * FROM $t_templatemodel ".
- " WHERE templateid=".$SESS['templateid'].
- " AND projectmodelid=".$SESS['projectmodelid'];
- $res = $db->query( $sql );
-
- // Wenn Templatevariante nicht vorhanden, diese anlegen
- if ( $res->numRows() == 0 )
- {
- $sql = "INSERT INTO $t_templatemodel ".
- " (templateid,projectmodelid,text)".
- " VALUES(".$SESS['templateid'].",".$SESS['projectmodelid'].",'<html>\n</html>')";
- $res = $db->query( $sql );
-
- $sql = "SELECT * FROM $t_templatemodel ".
- " WHERE templateid=".$SESS['templateid'].
- " AND projectmodelid=".$SESS['projectmodelid'];
- $res = $db->query( $sql );
- }
-
- $row = $res->fetchRow();
-}
-
-
-
-// Element hinzufügen
-//
-if ( $SESS['tplaction'] == 'addelement' )
-{
- if ( $REQ['name'] != '' )
- {
- $sql = new Sql('INSERT INTO {t_element} (templateid,name,type) '.
- 'VALUES ({templateid},{name},{type})');
- $sql->setInt ( 'templateid',$SESS['templateid'] );
- $sql->setString( 'name' ,$REQ['name'] );
- $sql->setString( 'type' ,'text' );
-
- $res = $db->query( $sql->query );
- }
-
- $var['tree_refresh'] = true;
- $SESS['tplaction'] = 'el';
-}
-
-
-if ( $REQ['elementaction'] == 'rename' )
-{
- if ($REQ['delete'] == '1')
- {
- // Alle Inhalte mit diesem Element löschen
- $sql = new Sql('DELETE FROM {t_value} '.
- ' WHERE elementid={elementid}' );
- $sql->setInt( 'elementid',$SESS['elementid'] );
- $db->query($sql->query);
-
- // Element löschen
- $sql = new Sql('DELETE FROM {t_element} '.
- ' WHERE id={elementid}' );
- $sql->setInt( 'elementid',$SESS['elementid'] );
- $db->query($sql->query);
-
-
- $SESS['tplaction'] = 'el';
- }
- else
- {
- $t_element = $conf_db_prefix.'element';
- $sql = "UPDATE $t_element ".
- "SET name='".$REQ['name']."',`desc`='".$REQ['desc']."' ".
- "WHERE id=".$SESS['elementid'];
- $res = $db->query($sql);
- }
-
- $var['tree_refresh'] = true;
- $SESS['tplaction'] = 'el';
-}
-
-
-if ( $REQ['elementaction'] == 'save' )
-{
- $ini_date_format = parse_ini_file( $conf_languagedir.'/dateformat.ini.'.$conf_php );
- $dateformat = (isset($REQ['dateformat'])) ? "'".addslashes($ini_date_format[$REQ['dateformat']])."'" : 'null';
- $width = (isset($REQ['width'])) ? "'".intval($REQ['width'])."'" : 'null';
- $height = (isset($REQ['height'])) ? "'".intval($REQ['height'])."'" : 'null';
- $subtype = (isset($REQ['subtype'])) ? "'".$REQ['subtype']."'" : 'null';
- $default_text = (isset($REQ['default_text'])) ? "'".$REQ['default_text']."'" : 'null';
- $wiki = (isset($REQ['wiki'])) ? '1' : 'null';
- $html = (isset($REQ['html'])) ? '1' : 'null';
- $decimals = (isset($REQ['decimals'])) ? intval($REQ['decimals']) : 'null';
- $dec_point = (isset($REQ['dec_point'])) ? "'".$REQ['dec_point' ]."'" : 'null';
- $thousand_sep = (isset($REQ['thousand_sep'])) ? "'".$REQ['thousand_sep']."'" : 'null';
- $extension = (isset($REQ['extension' ])) ? "'".$REQ['extension' ]."'" : 'null';
- $folderid = (isset($REQ['folderid' ])) ? "'".$REQ['folderid' ]."'" : 'null';
- $code = (isset($REQ['code' ])) ? "'".$REQ['code' ]."'" : 'null';
-
- $sql = "UPDATE $t_element ".
- " SET dateformat=$dateformat,".
- " width=$width,".
- " height=$height,".
- " wiki=$wiki,".
- " html=$html,".
- " subtype=$subtype,".
- " default_text=$default_text,".
- " decimals=$decimals,".
- " dec_point=$dec_point,".
- " thousand_sep=$thousand_sep,".
- " extension=$extension,".
- " folderid=$folderid,".
- " code=$code".
- " WHERE id=".$SESS['elementid'];
- $res = $db->query($sql);
- //echo "$sql";
- $SESS['tplaction'] = 'el';
-}
-
-
-session_write_close();
-
-
-// Löschen des Templates
-//
-if ( $SESS['tplaction'] == 'confirmdel' )
-{
- $var['extension'] = $row['extension'];
- $sql = "SELECT name FROM $t_template WHERE id=".$SESS['templateid'];
- $var['name'] = $db->getOne( $sql );
-
- // von diesem Template abhängige Seiten ermitteln
- //
- $sql = "SELECT * FROM $t_page WHERE templateid=".$SESS['templateid'];
- $res = $db->query($sql);
-
- $var['templateid'] = $SESS['templateid'];
-
- output('template_confirmdel',$var);
-}
-
-
-// Löschen des Templates
-//
-if ( $SESS['tplaction'] == 'del' )
-{
- $var['extension'] = $row['extension'];
- $sql = "SELECT name FROM $t_template WHERE id=".$SESS['templateid'];
- $var['name'] = $db->getOne( $sql );
-
- // von diesem Template abhängige Seiten ermitteln
- //
- $sql = "SELECT * FROM $t_page WHERE templateid=".$SESS['templateid'];
- $res = $db->query($sql);
- if ( $res->numRows() > 0 )
- $var['confirm' ] = false;
- else $var['confirm' ] = true;
-
- $var['templateid'] = $SESS['templateid'];
-
- output('template_del',$var);
-}
-
-
-// Anzeige der Template-Eigenschaften
-//
-if ( $SESS['tplaction'] == 'prop' )
-{
- $var['extension'] = $row['extension'];
- $sql = "SELECT name FROM $t_template WHERE id=".$SESS['templateid'];
- $var['name'] = $db->getOne( $sql );
-
- // von diesem Template abhängige Seiten ermitteln
- //
- $sql = "SELECT * FROM $t_page WHERE templateid=".$SESS['templateid'];
- $res = $db->query($sql);
-
- $var['pages'] = array();
- while( $row = $res->fetchRow(DB_FETCHMODE_ASSOC) )
- {
- $pageid = $row['id'];
- $var['pages'][$pageid] = array();
- $var['pages'][$pageid]['name'] = $row['name'];
- $var['pages'][$pageid]['url' ] = 'main.'.$conf_php.'?action=page&pageid='.$pageid;
- }
- $res->free();
-
- output('template_prop',$var);
-}
-
-
-// Bearbeiten
-//
-if ( $SESS['tplaction'] == 'show' )
-{
- $c = array( 'include' =>'lime',
- 'longtext'=>'lime',
- 'date' =>'blue',
- 'info' =>'white',
- 'infodate'=>'white',
- 'text' =>'lime',
- 'link' =>'fuchsia',
- 'number' =>'lime',
- 'file' =>'red',
- 'resize' =>'red',
- 'icon' =>'yellow' );
-
- $sql = "SELECT * FROM $t_element WHERE templateid=".$SESS['templateid'];
- $res = $db->query($sql);
-
- $row['text'] = htmlentities($row['text']);
- $row['text'] = str_replace("\n",'<br>',$row['text']);
-
- $elinh = array();
-
- if ($res->numRows() > 0)
- {
- while( $el = $res->fetchRow() )
- {
- $row['text'] = str_replace('{{'.$el['id'].'}}',
- '<a href="element.'.$conf_php.'?elementaction=edit'.
- '&elementid='.$el['id'].
- '&elementaction=edit&'.session_name().'='.session_id().'" style="background-color:'.
- $c[$el['type']].'" target="cms_main_main">%%'.
- $el['name'].'%%</a>',
- $row['text'] );
- $row['text'] = str_replace('{{->'.$el['id'].'}}',
- '<a href="element.'.$conf_php.'?elementaction=edit'.
- '&elementid='.$el['id'].
- '&elementaction=edit&'.session_name().'='.session_id().'" style="background-color:'.
- $c[$el['type']].'" target="cms_main_main">%%->'.
- $el['name'].'%%</a>',
- $row['text'] );
- }
- }
- $res->free();
-
-
- //$row['text'] = str_replace('<','<strong><</strong>',$row['text']);
- //$row['text'] = str_replace('>','<strong>></strong>',$row['text']);
-
- $var['form_action'] = $PHP_SELF;
- $var['text'] = $row['text'];
-
- output('template_show',$var);
-}
-
-
-// Anzeigen der Template-Elemente
-//
-if ( $SESS['tplaction'] == 'el' )
-{
- $sql = "SELECT * FROM $t_element WHERE templateid=".$SESS['templateid'].' ORDER BY name ASC';
- $res = $db->query($sql);
-
- $var['action'] = 'template.'.$conf_php;
- $var['el'] = array();
-
- while( $row = $res->fetchRow(DB_FETCHMODE_ASSOC) )
- {
- $id = $row['id' ];
- $var['el'][$id] = array();
- $var['el'][$id]['url' ] = 'element.'.$conf_php.'?elementaction=edit&elementid='.$id;
- $var['el'][$id]['name'] = $row['name'];
- $var['el'][$id]['desc'] = $row['desc'];
- $var['el'][$id]['type'] = $row['type'];
- }
- $res->free();
-
- output('template_el',$var);
-}
-
-
-
-// Anzeigen des Template-Quellcodes
-//
-if ( $SESS['tplaction'] == 'src' )
-{
- $sql = "SELECT * FROM $t_element".
- " WHERE templateid=".$SESS['templateid'].
- " ORDER BY name";
- $res = $db->query($sql);
-
- $var['elements'] = array();
-
- if ($res->numRows() > 0)
- {
- while( $el = $res->fetchRow() )
- {
- $var['elements'][$el['id']] = $el['name'];
-
- if ( $el['type'] != 'info' &&
- $el['type'] != 'infodate' &&
- $el['type'] != 'code' )
- $var['icon_elements'][$el['id']] = lang('icon').' '.$el['name'];
-
- $row['text'] = str_replace('{{'.$el['id'].'}}',
- '%%'.$el['name'].'%%',
- $row['text'] );
- $row['text'] = str_replace('{{->'.$el['id'].'}}',
- '%%->'.$el['name'].'%%',
- $row['text'] );
- }
- }
- $res->free();
-
- $var['form_action'] = $PHP_SELF;
- $var['templatemodelid'] = htmlentities($row['id']);
- $var['text'] = htmlentities($row['text']);
-
- output('template_src',$var);
-}
-
-
-// Hinzufügen eines Templates
-if ( $SESS['tplaction'] == 'add' )
-{
- if ( $REQ['name'] != '' )
- {
- $sql = "INSERT INTO $t_template".
- " (name,projectid) VALUES('".$REQ['name']."',".$SESS['projectid'].")";
- $res = $db->query($sql);
- }
- $var['tree_refresh'] = true;
-
- $SESS['tplaction'] = 'list';
-}
-
-
-
-// Anzeigen des Template-Quellcodes
-//
-if ( $SESS['tplaction'] == 'list' )
-{
- $sql = new SQL( "SELECT * FROM {t_template}".
- " WHERE projectid={projectid} ".
- " ORDER BY name" );
- $sql->setVar( 'projectid',$SESS['projectid'] );
- $res = $db->query( $sql->query );
-
- $var['templates'] = array();
-
- if ($res->numRows() > 0)
- {
- while( $tpl = $res->fetchRow() )
- {
- $var['templates'][$tpl['id']] = array();
- $var['templates'][$tpl['id']]['name'] = $tpl['name'];
- $var['templates'][$tpl['id']]['url'] = 'main.'.$conf_php.'?action=template&tplaction=show&templateid='.$tpl['id'];
- }
- }
- $res->free();
-
- $var['form_action'] = $PHP_SELF;
- $var['templatemodelid'] = htmlentities($row['id']);
- $var['text'] = htmlentities($row['text']);
-
- output('template_list',$var);
-}
-
-?>-
\ No newline at end of file