openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 862e8c9984aafd01d3fd80645562a38c1086f341
parent 2b79981d190645b4515e2fb2eb5f5411629b2a76
Author: dankert <devnull@localhost>
Date:   Tue,  5 Oct 2004 12:01:56 +0200

Austauschen einer Vorlage

Diffstat:
objectClasses/Page.class.php | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
themes/default/pages/html/page/prop.tpl.php | 229++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
2 files changed, 186 insertions(+), 103 deletions(-)

diff --git a/objectClasses/Page.class.php b/objectClasses/Page.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.7 2004-07-09 20:57:14 dankert +// Revision 1.8 2004-10-05 10:01:56 dankert +// Austauschen einer Vorlage +// +// Revision 1.7 2004/07/09 20:57:14 dankert // Dynamische Bereiche (IFEMPTY...) // // Revision 1.6 2004/07/07 20:47:22 dankert @@ -423,6 +426,59 @@ class Page extends Object + function replaceTemplate( $newTemplateId,$replaceElementMap ) + { + $oldTemplateId = $this->templateid; + + Logger::debug( 'replacing template of page '.$this->pageid. ' ('.$oldTemplateId.'->'.$newTemplateId.')' ); + $db = db_connection(); + + // Template-id dieser Seite aendern + $this->templateid = $newTemplateId; + + $sql = new Sql('UPDATE {t_page}'. + ' SET templateid ={templateid}'. + ' WHERE objectid={objectid}' ); + $sql->setInt('templateid' ,$this->templateid); + $sql->setInt('objectid' ,$this->objectid ); + $db->query( $sql->query ); + + + // Inhalte umschluesseln, d.h. die Element-Ids aendern + $template = new Template( $oldTemplateId ); + foreach( $template->getElementIds() as $oldElementId ) + { + if ( !isset($replaceElementMap[$oldElementId]) || + intval($replaceElementMap[$oldElementId]) < 1 ) + { + Logger::debug( 'deleting value of elementid '.$oldElementId ); + $sql = new Sql('DELETE FROM {t_value}'. + ' WHERE pageid={pageid}'. + ' AND elementid={elementid}' ); + $sql->setInt('pageid' ,$this->pageid); + $sql->setInt('elementid',$oldElementId ); + + $db->query( $sql->query ); + } + else + { + $newElementId = intval($replaceElementMap[$oldElementId]); + + Logger::debug( 'updating elementid '.$oldElementId.' -> '.$newElementId ); + $sql = new Sql('UPDATE {t_value}'. + ' SET elementid ={newelementid}'. + ' WHERE pageid ={pageid}'. + ' AND elementid={oldelementid}' ); + $sql->setInt('pageid' ,$this->pageid); + $sql->setInt('oldelementid',$oldElementId ); + $sql->setInt('newelementid',$newElementId ); + $db->query( $sql->query ); + } + } + } + + + /** * Ermitteln des Dateinamens dieser Seite * @@ -554,7 +610,7 @@ class Page extends Object } else { - // Wenn Feld gefüllt + // Wenn Feld gef?llt $src = str_replace( '{{IFNOTEMPTY:'.$id.':BEGIN}}','',$src ); $src = str_replace( '{{IFNOTEMPTY:'.$id.':END}}' ,'',$src ); diff --git a/themes/default/pages/html/page/prop.tpl.php b/themes/default/pages/html/page/prop.tpl.php @@ -1,102 +1,129 @@ -<?php include( $tpl_dir.'header.tpl.php') ?> - -<!-- $Id$ --> -<center> - -<form action="<?php echo $self ?>" method="post" target="_self"> - -<input type="hidden" name="action" value="page" /> -<input type="hidden" name="subaction" value="propsave"/> - -<table class="main" width="90%" cellspacing="0" cellpadding="4"> - - <tr> - <th colspan="2"><?php echo lang('PROP') ?></th> - </tr> - - <tr> - <td width="50%" rowspan="2" class="f1"><?php echo lang('name') ?></a></td> - <td width="50%" class="f1"><input type="text" class="name" name="name" size="50" value="<?php echo $name ?>"></td> - </tr> - <tr> - <td width="50%" class="help"><?php echo lang('HELP_NAME') ?></td> - </tr> - <tr> - <td width="50%" rowspan="2" class="f1"><?php echo lang('filename') ?></a></td> - <td width="50%" class="f1"><input type="text" class="filename" name="filename" size="50" value="<?php echo $filename ?>"></td> - </tr> - <tr> - <td width="50%" class="help"><?php echo lang('HELP_FILENAME') ?></td> - </tr> - <tr> - <td width="50%" class="f2"><?php echo lang('description') ?></a></td> - <td width="50%" class="f2"><textarea cols="40" rows="10" name="desc"><?php echo $desc ?></textarea></td> - </tr> - <tr> - <td width="50%" class="f1"><?php echo lang('template') ?></a></td> - <?php if (isset($template_url)) - { ?> - <td width="50%" class="f1"><a href="<?php echo $template_url ?>" target="cms_main"><img src="<?php echo $image_dir ?>icon_tpl.png" border="0" align="left"><?php echo $template_name ?></a></td> - <?php } - else - { ?> - <td width="50%" class="f1"><img src="<?php echo $image_dir ?>icon_tpl.png" align="left"><?php echo $template_name ?></td> - <?php } ?> - </tr> - <tr> - <td width="50%" class="f1"><?php echo lang('full_filename') ?></a></td> - <td width="50%" class="f1"><tt><?php echo $full_filename ?></tt></td> - </tr> - - <?php if ($delete) - { ?> - <tr> - <td class="f1" rowspan="2"><?php echo lang('DELETE') ?></a></td> - <td class="f1"><input type="checkbox" name="delete" value="1"></td> - </tr> - <tr> - <td class="help"><?php echo lang('HELP_PAGE_DELETE') ?></td> - </tr> - <?php } ?> - - <tr> - <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('SAVE') ?>"></td> - </tr> - -</table> - -</form> - - -<form action="<?php echo $self ?>" method="post" target="_self"> - -<input type="hidden" name="action" value="page" /> -<input type="hidden" name="subaction" value="move" /> - -<table class="main" width="90%" cellspacing="0" cellpadding="4"> - - <tr> - <th colspan="2"><?php echo lang('MOVE') ?></th> - </tr> - - <tr> - <td width="50%" class="f1"><?php echo lang('FOLDER') ?></a></td> - <td width="50%" class="f1"><?php echo Html::selectBox('movetoobjectid',$folder,$act_folderobjectid) ?></td> - </tr> - - <tr> - <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('MOVE') ?>"></td> - </tr> - -</table> - -</form> - - -<script name="JavaScript" type="text/javascript"><!-- -document.forms[0].name.focus(); -//--></script> - -</center> - +<?php include( $tpl_dir.'header.tpl.php') ?> + +<!-- $Id$ --> +<center> + +<form action="<?php echo $self ?>" method="post" target="_self"> + +<input type="hidden" name="action" value="page" /> +<input type="hidden" name="subaction" value="propsave"/> + +<table class="main" width="90%" cellspacing="0" cellpadding="4"> + + <tr> + <th colspan="2"><?php echo lang('PROP') ?></th> + </tr> + + <tr> + <td width="50%" rowspan="2" class="f1"><?php echo lang('name') ?></a></td> + <td width="50%" class="f1"><input type="text" class="name" name="name" size="50" value="<?php echo $name ?>"></td> + </tr> + <tr> + <td width="50%" class="help"><?php echo lang('HELP_NAME') ?></td> + </tr> + <tr> + <td width="50%" rowspan="2" class="f1"><?php echo lang('filename') ?></a></td> + <td width="50%" class="f1"><input type="text" class="filename" name="filename" size="50" value="<?php echo $filename ?>"></td> + </tr> + <tr> + <td width="50%" class="help"><?php echo lang('HELP_FILENAME') ?></td> + </tr> + <tr> + <td width="50%" class="f2"><?php echo lang('description') ?></a></td> + <td width="50%" class="f2"><textarea cols="40" rows="10" name="desc"><?php echo $desc ?></textarea></td> + </tr> + <tr> + <td width="50%" class="f1"><?php echo lang('template') ?></a></td> + <?php if (isset($template_url)) + { ?> + <td width="50%" class="f1"><a href="<?php echo $template_url ?>" target="cms_main"><img src="<?php echo $image_dir ?>icon_tpl.png" border="0" align="left"><?php echo $template_name ?></a></td> + <?php } + else + { ?> + <td width="50%" class="f1"><img src="<?php echo $image_dir ?>icon_tpl.png" align="left"><?php echo $template_name ?></td> + <?php } ?> + </tr> + <tr> + <td width="50%" class="f1"><?php echo lang('full_filename') ?></a></td> + <td width="50%" class="f1"><tt><?php echo $full_filename ?></tt></td> + </tr> + + <?php if ($delete) + { ?> + <tr> + <td class="f1" rowspan="2"><?php echo lang('DELETE') ?></a></td> + <td class="f1"><input type="checkbox" name="delete" value="1"></td> + </tr> + <tr> + <td class="help"><?php echo lang('HELP_PAGE_DELETE') ?></td> + </tr> + <?php } ?> + + <tr> + <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('SAVE') ?>"></td> + </tr> + +</table> + +</form> + + +<!-- Vorlage tauschen --> +<form action="<?php echo $self ?>" method="post" target="_self"> + +<input type="hidden" name="action" value="page" /> +<input type="hidden" name="subaction" value="replaceTemplateSelectElements" /> + +<table class="main" width="90%" cellspacing="0" cellpadding="4"> + + <tr> + <th colspan="2"><?php echo lang('PAGE_REPLACE_TEMPLATE') ?></th> + </tr> + + <tr> + <td width="50%" class="f1"><?php echo lang('TEMPLATES') ?></a></td> + <td width="50%" class="f1"><?php echo Html::selectBox('templateid',$templates) ?></td> + </tr> + + <tr> + <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('GLOBAL_REPLACE') ?>"></td> + </tr> + +</table> + +</form> + + +<!-- Verschieben --> +<form action="<?php echo $self ?>" method="post" target="_self"> + +<input type="hidden" name="action" value="page" /> +<input type="hidden" name="subaction" value="move" /> + +<table class="main" width="90%" cellspacing="0" cellpadding="4"> + + <tr> + <th colspan="2"><?php echo lang('MOVE') ?></th> + </tr> + + <tr> + <td width="50%" class="f1"><?php echo lang('FOLDER') ?></a></td> + <td width="50%" class="f1"><?php echo Html::selectBox('movetoobjectid',$folder,$act_folderobjectid) ?></td> + </tr> + + <tr> + <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('MOVE') ?>"></td> + </tr> + +</table> + +</form> + + +<script name="JavaScript" type="text/javascript"><!-- +document.forms[0].name.focus(); +//--></script> + +</center> + <?php include( $tpl_dir.'footer.tpl.php') ?> \ No newline at end of file