* @version DS-E V/2.5 */ require_once 'common.php'; require_once(LIB_PATH.'jslib.lib.php'); $access_control->su_check(access_control::SU_RIGHT_EDITORWORLD,true); $str_out = get_title('`&Tutorial'); $str_self = basename(__FILE__); switch( $_GET['op'] ){ case 'del': db_query('DELETE FROM tutorial WHERE id='.(int)$_GET['id']); jslib_http_command('/mb Eintrag gelöscht!'); exit(); break; case 'edit': if(isset($_GET['id'])) { $t = db_fetch_assoc(db_query('SELECT * FROM tutorial WHERE id='.(int)$_GET['id'])); } addnav('Zurück', $str_self ); $form = array( 'Tutorial bearbeiten,title', 'id' => 'ID,viewonly', 'number' => 'Schritt Nummer,int', 'section' => 'Gültig in section,text,255', 'text' => 'Text,textarea,50,10', 'code' => 'Ausgeführter Code,textarea,60,10', 'condition' => 'Bedingung(en),text,255', ); $sl = $str_self.'?op=save&id='.$_GET['id']; addnav('',$sl); $str_out .= '
'.generateform( $form, $t ).'
'; //PHP Code in {{ }} evaluieren und anschließend im Originaltext ersetzen preg_match_all('/{{(.*)}}/sU',$t['text'],$arr_matches,PREG_SET_ORDER); foreach($arr_matches as $arr_match) { $arr_match[1] = eval($arr_match[1]); $t['text'] = str_replace($arr_match[0],$arr_match[1],$t['text']); } $str_out .= '


Vorschau

'.$t['text']; break; default: switch( $_GET['op'] ){ case 'save': $res = db_query('SELECT * FROM tutorial WHERE id='.(int)$_GET['id']); if (db_num_rows($res)) { $sql = 'UPDATE `tutorial` SET '; $sql .= '`number`="'.(int)$_POST['number'].'", `section`="'.$_POST['section'].'",`text`="'.addstripslashes($_POST['text']).'", `code`="'.addstripslashes($_POST['code']).'", `condition`="'.addstripslashes($_POST['condition']).'" '; $sql .= 'WHERE id='.(int)$_GET['id']; db_query($sql); } else { $arr_insert = array( 'number'=>(int)$_POST['number'], 'section'=>$_POST['section'], 'text'=>addstripslashes($_POST['text']), 'code'=>addstripslashes($_POST['code']), 'condition'=>addstripslashes($_POST['condition'])); db_insert('tutorial',$arr_insert); } break; } $str_out .= ''; $str_out .= ''; addpregnav('/'.$str_self.'\?op=(edit|del)&id=\d+/'); $res = db_query('SELECT * FROM tutorial ORDER BY number ASC'); while($t = db_fetch_assoc($res)) { $str_trclass = ($str_trclass == 'trlight' ? 'trdark' : 'trlight'); $str_out .= ''; } $str_out .= '
Nr. Section Bedingung Aktion
    Text  
'.$t['number'].' '.$t['section'].' '.htmlentities($t['condition']).' [ Edit ] [ Del ]
    '.$t['text'].'
'.htmlentities($t['code']).'
 
'; break; } page_header('Tutorial-Editor'); grotto_nav(); addnav('Optionen'); addnav('Neu', $str_self.'?op=edit' ); output( $str_out ); page_footer(); ?>