2004-05-30 13:43:42 +00:00
< ? php
/*
$Id $
This code is part of LDAP Account Manager ( http :// www . sourceforge . net / projects / lam )
2007-11-22 19:50:26 +00:00
Copyright ( C ) 2003 - 2006 Michael Duergner
Copyright ( C ) 2007 Roland Gruber
2004-05-30 13:43:42 +00:00
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
Manages creating / changing of pdf structures .
*/
2005-06-21 20:58:32 +00:00
/**
* Displays the main page of the PDF editor where the user can select the displayed entries .
*
2007-10-24 17:31:14 +00:00
* @ author Michael Duergner
2005-06-21 20:58:32 +00:00
* @ author Roland Gruber
* @ package PDF
*/
2006-03-26 17:51:25 +00:00
/** security functions */
include_once ( " ../../lib/security.inc " );
2005-07-27 18:06:55 +00:00
/** access to PDF configuration files */
2004-05-31 09:38:59 +00:00
include_once ( '../../lib/pdfstruct.inc' );
2005-07-27 18:06:55 +00:00
/** LDAP object */
2004-05-31 09:38:59 +00:00
include_once ( '../../lib/ldap.inc' );
2005-07-27 18:06:55 +00:00
/** LAM configuration */
2004-05-31 09:38:59 +00:00
include_once ( '../../lib/config.inc' );
2005-07-27 18:06:55 +00:00
/** module functions */
2004-05-31 09:38:59 +00:00
include_once ( '../../lib/modules.inc' );
2005-07-27 18:06:55 +00:00
/** XML functions */
2004-05-30 13:43:42 +00:00
include_once ( '../../lib/xml_parser.inc' );
// start session
2006-03-26 17:51:25 +00:00
startSecureSession ();
2004-05-30 13:43:42 +00:00
2007-12-30 13:15:39 +00:00
// die if no write access
if ( ! checkIfWriteAccessIsAllowed ()) die ();
2004-05-30 13:43:42 +00:00
setlanguage ();
// check if user is logged in, if not go to login
if ( ! $_SESSION [ 'ldap' ] || ! $_SESSION [ 'ldap' ] -> server ()) {
metaRefresh ( " ../login.php " );
exit ;
}
2004-06-03 14:26:48 +00:00
// Write $_POST variables to $_GET when form was submitted via post
2004-05-31 09:38:59 +00:00
if ( isset ( $_POST [ 'type' ])) {
$_GET = $_POST ;
2004-08-03 19:07:31 +00:00
if ( $_POST [ 'pdfname' ] == '' ) {
unset ( $_GET [ 'pdfname' ]);
}
2004-05-30 13:43:42 +00:00
}
2004-05-31 09:38:59 +00:00
2005-06-21 20:58:32 +00:00
2004-06-03 14:26:48 +00:00
// Abort and go back to main pdf structure page
2004-05-31 09:38:59 +00:00
if ( isset ( $_GET [ 'abort' ])) {
metarefresh ( 'pdfmain.php' );
exit ;
}
2005-07-06 13:48:55 +00:00
// set new logo and headline
if (( isset ( $_GET [ 'headline' ])) && ( $_GET [ 'logoFile' ] != $_SESSION [ 'currentPageDefinitions' ][ 'filename' ])) {
$_SESSION [ 'currentPageDefinitions' ][ 'filename' ] = $_GET [ 'logoFile' ];
}
if (( isset ( $_GET [ 'headline' ])) && ( $_GET [ 'headline' ] != $_SESSION [ 'currentPageDefinitions' ][ 'headline' ])) {
$_SESSION [ 'currentPageDefinitions' ][ 'headline' ] = str_replace ( '<' , '' , str_replace ( '>' , '' , $_GET [ 'headline' ]));
}
2004-06-03 14:26:48 +00:00
// Check if pdfname is valid, then save current structure to file and go to
// main pdf structure page
2005-07-06 13:48:55 +00:00
if ( isset ( $_GET [ 'submit' ])) {
2005-07-27 18:06:55 +00:00
echo $_SESSION [ 'header' ];
echo " <title>LDAP Account Manager</title> " ;
2007-11-22 19:50:26 +00:00
echo " <link rel= \" stylesheet \" type= \" text/css \" href= \" ../../style/layout.css \" > \n " ;
echo " <link rel= \" stylesheet \" type= \" text/css \" href= \" ../../style/type_ " . $_GET [ 'type' ] . " .css \" > \n " ;
2005-07-27 18:06:55 +00:00
echo " </head> " ;
echo " <body> " ;
2005-07-27 18:27:24 +00:00
if ( ! isset ( $_GET [ 'pdfname' ]) || ! preg_match ( '/[a-zA-Z0-9\-\_]+/' , $_GET [ 'pdfname' ])) {
2005-07-27 18:06:55 +00:00
StatusMessage ( 'ERROR' , _ ( 'PDF-structure name not valid' ), _ ( 'The name for that PDF-structure you submitted is not valid. A valid name must constist at least of one of the following characters \'a-z\',\'A-Z\',\'0-9\',\'_\',\'-\',\'.\'.' ));
2004-06-03 14:26:48 +00:00
}
else {
2005-07-27 18:06:55 +00:00
$return = savePDFStructureDefinitions ( $_GET [ 'type' ], $_GET [ 'pdfname' ]);
if ( $return == 'ok' ) {
StatusMessage ( 'INFO' , _ ( " PDF structure was successfully saved. " ), $_GET [ 'pdfname' ]);
}
elseif ( $return == 'no perms' ){
StatusMessage ( 'ERROR' , _ ( " Could not save PDF profile, access denied. " ), $_GET [ 'pdfname' ]);
}
2004-06-03 14:26:48 +00:00
}
2007-11-22 19:50:26 +00:00
echo ( " <br><a href= \" pdfmain.php \" > " . _ ( " Back to PDF Editor " ) . " </a> " );
2005-07-27 18:06:55 +00:00
echo " </body></html> " ;
exit ;
2004-05-31 09:38:59 +00:00
}
2008-03-16 14:06:32 +00:00
// add a new text field
elseif ( isset ( $_GET [ 'add_text' ])) {
2004-06-03 14:26:48 +00:00
// Check if text for static text field is specified
2008-03-16 14:06:32 +00:00
if ( ! isset ( $_GET [ 'text_text' ]) || ( $_GET [ 'text_text' ] == '' )) {
2004-06-03 14:26:48 +00:00
StatusMessage ( 'ERROR' , _ ( 'No static text specified' ), _ ( 'The static text must contain at least one character.' ));
}
else {
2008-03-16 14:06:32 +00:00
$entry = array ( array ( 'tag' => 'TEXT' , 'type' => 'complete' , 'level' => '2' , 'value' => $_GET [ 'text_text' ]));
// Insert new field in structure
array_splice ( $_SESSION [ 'currentPDFStructure' ], $_GET [ 'add_text_position' ], 0 , $entry );
}
}
// add a new section with text headline
elseif ( isset ( $_GET [ 'add_sectionText' ])) {
// Check if name for new section is specified when needed
if ( ! isset ( $_GET [ 'section_text' ]) || ( $_GET [ 'section_text' ] == '' )) {
StatusMessage ( 'ERROR' , _ ( 'No section text specified' ), _ ( 'The headline for a new section must contain at least one character.' ));
}
else {
$attributes = array ();
$attributes [ 'NAME' ] = $_GET [ 'section_text' ];
$entry = array ( array ( 'tag' => 'SECTION' , 'type' => 'open' , 'level' => '2' , 'attributes' => $attributes ), array ( 'tag' => 'SECTION' , 'type' => 'close' , 'level' => '2' ));
2004-06-03 14:26:48 +00:00
// Insert new field in structure
2008-03-16 14:06:32 +00:00
array_splice ( $_SESSION [ 'currentPDFStructure' ], $_GET [ 'add_sectionText_position' ], 0 , $entry );
2004-05-31 09:38:59 +00:00
}
}
2008-03-16 14:06:32 +00:00
// Add a new section with item as headline
elseif ( isset ( $_GET [ 'add_section' ])) {
$attributes = array ();
$attributes [ 'NAME' ] = '_' . $_GET [ 'section_item' ];
$entry = array ( array ( 'tag' => 'SECTION' , 'type' => 'open' , 'level' => '2' , 'attributes' => $attributes ), array ( 'tag' => 'SECTION' , 'type' => 'close' , 'level' => '2' ));
// Insert new field in structure
array_splice ( $_SESSION [ 'currentPDFStructure' ], $_GET [ 'add_section_position' ], 0 , $entry );
}
2004-06-03 14:26:48 +00:00
// Add a new value field
2008-03-23 14:20:23 +00:00
elseif ( isset ( $_GET [ 'add_new_field' ])) {
$field = array ( 'tag' => 'ENTRY' , 'type' => 'complete' , 'level' => '3' , 'attributes' => array ( 'NAME' => $_GET [ 'new_field' ]));
$pos = 0 ;
// Find begin section to insert into
while ( $pos < $_GET [ 'add_field_position' ]) {
next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
2004-05-31 09:38:59 +00:00
}
2008-03-23 14:20:23 +00:00
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
// End of section to insert into
while ( $current && $current [ 'tag' ] != 'SECTION' && $current [ 'type' ] != 'close' ) {
2004-05-31 09:38:59 +00:00
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
}
2008-03-23 14:20:23 +00:00
// Insert new entry before closing section tag
array_splice ( $_SESSION [ 'currentPDFStructure' ], $pos , 0 , array ( $field ));
2004-05-31 09:38:59 +00:00
}
2004-06-03 14:26:48 +00:00
// Change section headline
elseif ( isset ( $_GET [ 'change' ])) {
$alter = explode ( '_' , $_GET [ 'change' ]);
$newvalue = $_GET [ 'section_' . $alter [ 0 ]];
2008-12-27 13:06:42 +00:00
if ( isset ( $alter [ 1 ]) && ( $alter [ 1 ] == 'item' ) && ( $newvalue [ 0 ] != '_' )) {
2004-06-03 14:26:48 +00:00
$newvalue = '_' . $newvalue ;
}
$_SESSION [ 'currentPDFStructure' ][ $alter [ 0 ]][ 'attributes' ][ 'NAME' ] = $newvalue ;
}
// Remove section, static text or value entry from structure
2004-05-31 09:38:59 +00:00
elseif ( isset ( $_GET [ 'remove' ])) {
$start = 0 ;
2004-06-03 14:26:48 +00:00
// Find element to remove
2004-05-31 09:38:59 +00:00
while ( $start < $_GET [ 'remove' ]) {
next ( $_SESSION [ 'currentPDFStructure' ]);
$start ++ ;
}
$remove = current ( $_SESSION [ 'currentPDFStructure' ]);
2004-06-03 14:26:48 +00:00
// We have a section to remove
2004-05-31 09:38:59 +00:00
if ( $remove [ 'tag' ] == " SECTION " ) {
$end = $start ;
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$end ++ ;
2004-06-03 14:26:48 +00:00
// Find end of section to remove
2004-05-31 09:38:59 +00:00
while ( $current && $current [ 'tag' ] != 'SECTION' && $current [ 'type' ] != 'close' ) {
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$end ++ ;
}
2004-06-03 14:26:48 +00:00
// Remove complete section with all value entries in it from structure
2004-05-31 09:38:59 +00:00
array_splice ( $_SESSION [ 'currentPDFStructure' ], $start , $end - $start + 1 );
}
2004-06-03 14:26:48 +00:00
// We have a value entry to remove
2004-05-31 09:38:59 +00:00
elseif ( $remove [ 'tag' ] == " ENTRY " ) {
array_splice ( $_SESSION [ 'currentPDFStructure' ], $start , 1 );
}
2004-06-03 14:26:48 +00:00
// We hava a static text to remove
2004-05-31 09:38:59 +00:00
elseif ( $remove [ 'tag' ] == " TEXT " ) {
array_splice ( $_SESSION [ 'currentPDFStructure' ], $start , 1 );
}
}
2004-06-03 14:26:48 +00:00
// Move a section, static text or value entry upwards
2004-05-31 09:38:59 +00:00
elseif ( isset ( $_GET [ 'up' ])) {
$tmp = $_SESSION [ 'currentPDFStructure' ][ $_GET [ 'up' ]];
$prev = $_SESSION [ 'currentPDFStructure' ][ $_GET [ 'up' ] - 1 ];
2004-06-03 14:26:48 +00:00
// We have a section or static text to move
if ( $tmp [ 'tag' ] == 'SECTION' || $tmp [ 'tag' ] == 'TEXT' ) {
2004-05-31 12:19:42 +00:00
$pos = 0 ;
$borders = array ();
$current = current ( $_SESSION [ 'currentPDFStructure' ]);
2004-06-03 14:26:48 +00:00
// Add borders of sections and static text entry to array
2004-05-31 12:19:42 +00:00
if ( $current [ 'tag' ] == 'SECTION' ) {
$borders [ $current [ 'type' ]][] = $pos ;
}
2004-06-03 14:26:48 +00:00
elseif ( $current [ 'tag' ] == 'TEXT' ) {
$borders [ 'open' ][] = $pos ;
$borders [ 'close' ][] = $pos ;
}
// Find all sections and statci text fields before the section or static
// text entry to move upwards
2004-05-31 12:19:42 +00:00
while ( $pos < $_GET [ 'up' ]) {
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
if ( $current [ 'tag' ] == 'SECTION' ) {
$borders [ $current [ 'type' ]][] = $pos ;
}
2004-06-03 14:26:48 +00:00
elseif ( $current [ 'tag' ] == 'TEXT' ) {
$borders [ 'open' ][] = $pos ;
$borders [ 'close' ][] = $pos ;
}
2004-05-31 12:19:42 +00:00
}
2004-06-03 14:26:48 +00:00
// Move only when not topmost element
2004-05-31 12:19:42 +00:00
if ( count ( $borders [ 'close' ]) > 0 ) {
2004-06-03 14:26:48 +00:00
// We have a section to move up
if ( $current [ 'tag' ] == 'SECTION' ) {
2004-05-31 12:19:42 +00:00
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
2004-06-03 14:26:48 +00:00
// Find end of section to move
while ( $current && $current [ 'tag' ] != 'SECTION' && $current [ 'type' ] != 'close' ) {
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
}
$borders [ 'close' ][] = $pos ;
2004-05-31 12:19:42 +00:00
}
2004-06-03 14:26:48 +00:00
// Calculate the entries to move and move them
2004-05-31 12:19:42 +00:00
$cut_start = $borders [ 'open' ][ count ( $borders [ 'open' ]) - 1 ];
$cut_count = $borders [ 'close' ][ count ( $borders [ 'close' ]) - 1 ] - $borders [ 'open' ][ count ( $borders [ 'open' ]) - 1 ] + 1 ;
$insert_pos = $borders [ 'open' ][ count ( $borders [ 'open' ]) - 2 ];
$tomove = array_splice ( $_SESSION [ 'currentPDFStructure' ], $cut_start , $cut_count );
array_splice ( $_SESSION [ 'currentPDFStructure' ], $insert_pos , 0 , $tomove );
}
2004-05-31 09:38:59 +00:00
}
2004-06-03 14:26:48 +00:00
// We have a value entry to move; move it only if its not the topmost
// entry in this section
2004-05-31 09:38:59 +00:00
elseif ( $tmp [ 'tag' ] == 'ENTRY' && $prev [ 'tag' ] == 'ENTRY' ) {
2004-06-03 14:26:48 +00:00
$_SESSION [ 'currentPDFStructure' ][ $_GET [ 'up' ]] = $prev ;
2004-05-31 09:38:59 +00:00
$_SESSION [ 'currentPDFStructure' ][ $_GET [ 'up' ] - 1 ] = $tmp ;
}
}
2004-06-03 14:26:48 +00:00
// Move a section, static text field or value entry downwards
2004-05-31 09:38:59 +00:00
elseif ( isset ( $_GET [ 'down' ])) {
$tmp = $_SESSION [ 'currentPDFStructure' ][ $_GET [ 'down' ]];
$next = $_SESSION [ 'currentPDFStructure' ][ $_GET [ 'down' ] + 1 ];
2004-06-03 14:26:48 +00:00
// We have a section or static text to move
if ( $tmp [ 'tag' ] == 'SECTION' || $tmp [ 'tag' ] == 'TEXT' ) {
2004-05-31 12:19:42 +00:00
$pos = 0 ;
$current = current ( $_SESSION [ 'currentPDFStructure' ]);
2004-06-03 14:26:48 +00:00
// Find section or static text entry to move
2004-05-31 12:19:42 +00:00
while ( $pos < $_GET [ 'down' ]) {
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
}
$borders = array ();
2004-06-03 14:26:48 +00:00
// We have a section to move
if ( $current [ 'tag' ] == 'SECTION' ){
$borders [ $current [ 'type' ]][] = $pos ;
2004-05-31 12:19:42 +00:00
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
2004-06-03 14:26:48 +00:00
// Find end of section to move
while ( $current && $current [ 'tag' ] != 'SECTION' && $current [ 'type' ] != 'close' ) {
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
}
$borders [ 'close' ][] = $pos ;
}
// We have a static text entry to move
elseif ( $current [ 'tag' ] == 'TEXT' ) {
$borders [ 'open' ][] = $pos ;
$borders [ 'close' ][] = $pos ;
2004-05-31 12:19:42 +00:00
}
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
2004-06-03 14:26:48 +00:00
// Find next section or static text entry in structure
2004-05-31 12:19:42 +00:00
if ( $current ) {
2004-06-03 14:26:48 +00:00
// Next is a section
if ( $current [ 'tag' ] == 'SECTION' ) {
$borders [ $current [ 'type' ]][] = $pos ;
2004-05-31 12:19:42 +00:00
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
2004-06-03 14:26:48 +00:00
// Find end of this section
while ( $current && $current [ 'tag' ] != 'SECTION' && $current [ 'type' ] != 'close' ) {
if ( $current [ 'tag' ] == 'SECTION' ) {
$borders [ $current [ 'type' ]][] = $pos ;
}
$current = next ( $_SESSION [ 'currentPDFStructure' ]);
$pos ++ ;
}
}
// Next is static text entry
elseif ( $current [ 'tag' ] == 'TEXT' ) {
$borders [ 'open' ][] = $pos ;
2004-05-31 12:19:42 +00:00
}
$borders [ 'close' ][] = $pos ;
}
2004-06-03 14:26:48 +00:00
// Move only downwars if not bottenmost element of this structure
2004-05-31 12:19:42 +00:00
if ( count ( $borders [ 'open' ]) > 1 ) {
2004-06-03 14:26:48 +00:00
// Calculate entries to move and move them
2004-05-31 12:19:42 +00:00
$cut_start = $borders [ 'open' ][ count ( $borders [ 'open' ]) - 1 ];
$cut_count = $borders [ 'close' ][ count ( $borders [ 'close' ]) - 1 ] - $borders [ 'open' ][ count ( $borders [ 'open' ]) - 1 ] + 1 ;
$insert_pos = $borders [ 'open' ][ count ( $borders [ 'open' ]) - 2 ];
$tomove = array_splice ( $_SESSION [ 'currentPDFStructure' ], $cut_start , $cut_count );
array_splice ( $_SESSION [ 'currentPDFStructure' ], $insert_pos , 0 , $tomove );
}
2004-05-31 09:38:59 +00:00
}
2004-06-03 14:26:48 +00:00
// We have a value entry to move; move it only if it is not the bottmmost
// element of this section.
2004-05-31 09:38:59 +00:00
elseif ( $tmp [ 'tag' ] == 'ENTRY' && $next [ 'tag' ] == 'ENTRY' ) {
$_SESSION [ 'currentPDFStructure' ][ $_GET [ 'down' ]] = $_SESSION [ 'currentPDFStructure' ][ $_GET [ 'down' ] + 1 ];
$_SESSION [ 'currentPDFStructure' ][ $_GET [ 'down' ] + 1 ] = $tmp ;
}
2004-05-30 13:43:42 +00:00
}
2005-06-21 20:58:32 +00:00
2004-06-03 14:26:48 +00:00
// Load PDF structure from file if it is not defined in session
2004-05-31 09:38:59 +00:00
if ( ! isset ( $_SESSION [ 'currentPDFStructure' ])) {
2004-06-03 14:26:48 +00:00
// Load structure file to be edit
2007-10-24 17:31:14 +00:00
if ( isset ( $_GET [ 'edit' ])) {
2004-08-03 19:07:31 +00:00
$load = loadPDFStructureDefinitions ( $_GET [ 'type' ], $_GET [ 'edit' ]);
$_SESSION [ 'currentPDFStructure' ] = $load [ 'structure' ];
$_SESSION [ 'currentPageDefinitions' ] = $load [ 'page_definitions' ];
2005-07-27 18:06:55 +00:00
$_GET [ 'pdfname' ] = $_GET [ 'edit' ];
2004-05-31 09:38:59 +00:00
}
2004-06-03 14:26:48 +00:00
// Load default structure file when creating a new one
2004-05-31 09:38:59 +00:00
else {
2004-08-03 19:07:31 +00:00
$load = loadPDFStructureDefinitions ( $_GET [ 'type' ]);
$_SESSION [ 'currentPDFStructure' ] = $load [ 'structure' ];
$_SESSION [ 'currentPageDefinitions' ] = $load [ 'page_definitions' ];
2004-05-31 09:38:59 +00:00
}
}
2004-06-03 14:26:48 +00:00
// Load available fields from modules when not set in session
2004-05-31 09:38:59 +00:00
if ( ! isset ( $_SESSION [ 'availablePDFFields' ])) {
$_SESSION [ 'availablePDFFields' ] = getAvailablePDFFields ( $_GET [ 'type' ]);
}
2004-06-03 14:26:48 +00:00
// Create the values for the dropdown boxes for section headline defined by
// value entries and fetch all available modules
2004-05-31 09:38:59 +00:00
$modules = array ();
2004-06-03 14:26:48 +00:00
$section_items_array = array ();
2004-05-31 09:38:59 +00:00
$section_items = '' ;
foreach ( $_SESSION [ 'availablePDFFields' ] as $module => $values ) {
$modules [] = $module ;
foreach ( $values as $attribute ) {
2004-06-03 14:26:48 +00:00
$section_items_array [] = $module . '_' . $attribute ;
2005-06-21 20:58:32 +00:00
$section_items .= " <option> " . $module . '_' . $attribute . " </option> \n " ;
2004-05-31 09:38:59 +00:00
}
}
$modules = join ( ',' , $modules );
2004-05-30 13:43:42 +00:00
2004-08-03 19:07:31 +00:00
$logoFiles = getAvailableLogos ();
$logos = '<option value="none"' . (( $_SESSION [ 'currentPageDefinitions' ][ 'filename' ] == 'none' ) ? ' selected="selected"' : '' ) . '>' . _ ( 'No logo' ) . " </option> \n " ;
foreach ( $logoFiles as $logoFile ) {
2005-06-21 20:58:32 +00:00
$logos .= " <option value= \" " . $logoFile [ 'filename' ] . " \" " . (( $_SESSION [ 'currentPageDefinitions' ][ 'filename' ] == $logoFile [ 'filename' ] || ( ! isset ( $_SESSION [ 'currentPageDefinitions' ][ 'filename' ]) && $logoFile [ 'filename' ] == 'printLogo.jpg' )) ? ' selected="selected"' : '' ) . '>' . $logoFile [ 'filename' ] . ' (' . $logoFile [ 'infos' ][ 0 ] . ' x ' . $logoFile [ 'infos' ][ 1 ] . " )</option> \n " ;
2004-08-03 19:07:31 +00:00
}
2004-05-30 13:43:42 +00:00
// print header
echo $_SESSION [ 'header' ];
2004-08-03 19:07:31 +00:00
// TODO Change enctype of form
2004-05-30 13:43:42 +00:00
?>
< title > LDAP Account Manager </ title >
< link rel = " stylesheet " type = " text/css " href = " ../../style/layout.css " >
2007-11-22 19:50:26 +00:00
< link rel = " stylesheet " type = " text/css " href = " ../../style/type_<?php echo $_GET['type'] ; ?>.css " >
2004-05-30 13:43:42 +00:00
</ head >
< body >
< br >
< form action = " pdfpage.php " method = " post " >
2009-08-23 12:50:06 +00:00
< table >
2004-08-03 19:07:31 +00:00
< tr >
2008-03-16 20:56:48 +00:00
<!-- print current structure -->
< td align = " left " valign = " top " >
2007-11-22 19:50:26 +00:00
< fieldset class = " <?php echo $_GET['type'] ; ?>edit " >
2004-08-03 19:07:31 +00:00
< legend >
2008-03-16 20:56:48 +00:00
< b >< ? php if ( isset ( $_GET [ 'pdfname' ])) echo $_GET [ 'pdfname' ]; ?> </b>
2004-08-03 19:07:31 +00:00
</ legend >
2008-03-16 11:02:16 +00:00
< BR >
< b >< ? php echo _ ( 'Headline' ); ?> :</b>
< input type = " text " name = " headline " value = " <?php echo ((isset( $_SESSION['currentPageDefinitions'] ['headline'])) ? $_SESSION['currentPageDefinitions'] ['headline'] : 'LDAP Account Manager'); ?> " >
& nbsp ; & nbsp ; & nbsp ; & nbsp ;
< b >< ? php echo _ ( 'Logo' ); ?> :</b>
< select name = " logoFile " size = " 1 " >
< ? php echo $logos ; ?>
</ select >
2008-03-16 20:56:48 +00:00
< BR >< HR >< BR >
2008-03-23 14:20:23 +00:00
< table width = " 100% " >
2004-05-30 13:43:42 +00:00
< ? php
2004-06-03 14:26:48 +00:00
$sections = '<option value="0">' . _ ( 'Beginning' ) . " </option> \n " ;
2008-03-23 10:57:34 +00:00
$nonTextSections = '' ;
2004-06-03 14:26:48 +00:00
// Print every entry in the current structure
2004-05-31 09:38:59 +00:00
foreach ( $_SESSION [ 'currentPDFStructure' ] as $key => $entry ) {
2004-06-03 14:26:48 +00:00
// Create the up/down/remove links
2008-03-23 14:20:23 +00:00
$links = " <td width=18> \n <a href= \" pdfpage.php?type= " . $_GET [ 'type' ] . " &up= " . $key .
2007-10-24 17:31:14 +00:00
( isset ( $_GET [ 'pdfname' ]) ? '&pdfname=' . $_GET [ 'pdfname' ] : '' ) .
( isset ( $_GET [ 'headline' ]) ? '&headline=' . $_GET [ 'headline' ] : '' ) .
( isset ( $_GET [ 'logoFile' ]) ? '&logoFile=' . $_GET [ 'logoFile' ] : '' ) . " \" > " .
2005-06-21 20:58:32 +00:00
" <img src= \" ../../graphics/up.gif \" alt= \" " . _ ( " Up " ) . " \" border= \" 0 \" ></a> \n </td> \n " .
2008-03-23 14:20:23 +00:00
" <td width=18> \n <a href= \" pdfpage.php?type= " . $_GET [ 'type' ] . " &down= " . $key .
2007-10-24 17:31:14 +00:00
( isset ( $_GET [ 'pdfname' ]) ? '&pdfname=' . $_GET [ 'pdfname' ] : '' ) .
( isset ( $_GET [ 'headline' ]) ? '&headline=' . $_GET [ 'headline' ] : '' ) .
( isset ( $_GET [ 'logoFile' ]) ? '&logoFile=' . $_GET [ 'logoFile' ] : '' ) . " \" > " .
2005-06-21 20:58:32 +00:00
" <img src= \" ../../graphics/down.gif \" alt= \" " . _ ( " Down " ) . " \" border= \" 0 \" ></a> \n </td> \n " .
2008-03-23 14:20:23 +00:00
" <td width=18> \n <a href= \" pdfpage.php?type= " . $_GET [ 'type' ] . " &remove= " . $key .
2007-10-24 17:31:14 +00:00
( isset ( $_GET [ 'pdfname' ]) ? '&pdfname=' . $_GET [ 'pdfname' ] : '' ) .
( isset ( $_GET [ 'headline' ]) ? '&headline=' . $_GET [ 'headline' ] : '' ) .
( isset ( $_GET [ 'logoFile' ]) ? '&logoFile=' . $_GET [ 'logoFile' ] : '' ) . " \" > " .
2008-03-23 14:20:23 +00:00
" <img src= \" ../../graphics/delete.gif \" alt= \" " . _ ( " Remove " ) . " \" border= \" 0 \" ></a> \n </td> \n " .
2009-08-23 12:50:06 +00:00
" <td width= \" 100% \" > </td> " ;
2004-05-30 13:43:42 +00:00
// We have a new section to start
if ( $entry [ 'tag' ] == " SECTION " && $entry [ 'type' ] == " open " ) {
$name = $entry [ 'attributes' ][ 'NAME' ];
2008-03-23 10:57:34 +00:00
if ( preg_match ( " /^_[a-zA-Z_]+/ " , $name )) {
$section_headline = substr ( $name , 1 );
}
else {
$section_headline = $name ;
}
$nonTextSections .= '<option value="' . $key . '">' . $section_headline . " </option> \n " ;
2004-05-30 13:43:42 +00:00
?>
< tr >
2009-08-23 12:50:06 +00:00
< td nowrap colspan = " 2 " >
2004-06-03 14:26:48 +00:00
< ? php
// Section headline is a value entry
2007-12-28 15:57:43 +00:00
if ( preg_match ( " /^_[a-zA-Z_]+/ " , $name )) {
2004-06-03 14:26:48 +00:00
?>
< select name = " section_<?php echo $key ;?> " >
< ? php
foreach ( $section_items_array as $item ) {
?>
< option value = " _<?php echo $item ;?> " < ? php echo (( substr ( $name , 1 ) == $item ) ? ' selected' : '' ); ?> ><?php echo $item;?></option>
< ? php
}
?>
</ select >
< button type = " submit " name = " change " value = " <?php echo $key ;?>_item " >< ? php echo _ ( 'Change' ); ?> </button>
< ? php
}
// Section headline is a user text
else {
?>
2008-03-23 10:57:34 +00:00
< input type = " text " name = " section_<?php echo $key ;?> " value = " <?php echo $section_headline ;?> " >& nbsp ; & nbsp ; < button type = " submit " name = " change " value = " <?php echo $key ;?> " >< ? php echo _ ( 'Change' ); ?> </button>
2004-06-03 14:26:48 +00:00
< ? php
}
?>
2004-05-30 13:43:42 +00:00
</ td >
2009-08-23 12:50:06 +00:00
< td width = " 20 " >& nbsp ; </ td >
2004-05-30 13:43:42 +00:00
< ? php echo $links ; ?>
</ tr >
< ? php
}
// We have a section to end
elseif ( $entry [ 'tag' ] == " SECTION " && $entry [ 'type' ] == " close " ) {
2007-12-28 15:57:43 +00:00
if ( preg_match ( " /^_[a-zA-Z_]+/ " , $name )) {
2004-06-03 14:26:48 +00:00
$section_headline = substr ( $name , 1 );
}
else {
$section_headline = $name ;
}
// Add current section for dropdown box needed for the position when inserting a new
// section or static text entry
$sections .= '<option value="' . ( $key + 1 ) . '">' . $section_headline . " </option> \n " ;
2004-05-30 13:43:42 +00:00
?>
< tr >
2008-03-23 14:20:23 +00:00
< td colspan = " 7 " >
2004-05-30 13:43:42 +00:00
< br >
</ td >
</ tr >
< ? php
}
// We have to include a static text.
elseif ( $entry [ 'tag' ] == " TEXT " ) {
2004-06-03 14:26:48 +00:00
// Add current satic text for dropdown box needed for the position when inserting a new
// section or static text entry
$sections .= '<option value="' . ( $key + 1 ) . '">' . _ ( 'Static text' ) . " </option> \n " ;
?>
2004-05-30 13:43:42 +00:00
< tr >
2008-04-15 14:35:43 +00:00
< td nowrap colspan = " 2 " width = " 400 " >
2004-05-30 13:43:42 +00:00
< b >< ? php echo _ ( 'Static text' ); ?> </b>
</ td >
< td width = " 20 " >
</ td >
< ? php echo $links ; ?>
</ tr >
< tr >
2008-03-23 14:20:23 +00:00
< td colspan = " 7 " >
< br >
2004-05-30 13:43:42 +00:00
</ td >
2008-03-23 14:20:23 +00:00
</ tr >
< tr >
2004-05-30 13:43:42 +00:00
< td >
</ td >
2008-03-23 14:20:23 +00:00
< td colspan = " 6 " >
< ? php echo $entry [ 'value' ]; ?>
2004-05-30 13:43:42 +00:00
</ td >
</ tr >
2004-05-31 12:19:42 +00:00
< tr >
2008-03-23 14:20:23 +00:00
< td colspan = " 7 " >
2004-05-31 12:19:42 +00:00
< br >
</ td >
</ tr >
< ? php
2004-05-30 13:43:42 +00:00
}
// We have to include an entry from the account
elseif ( $entry [ 'tag' ] == " ENTRY " ) {
// Get name of current entry
$name = $entry [ 'attributes' ][ 'NAME' ];
?>
< tr >
< td width = " 20 " >
</ td >
< td >
< ? php echo $name ; ?>
</ td >
< td width = " 20 " >
</ td >
< ? php echo $links ; ?>
</ tr >
< ? php
}
}
2004-06-03 14:26:48 +00:00
// Print the boxes for adding new sections and static text entries
// Print save and abort buttons
2004-05-30 13:43:42 +00:00
?>
</ table >
2005-06-21 20:58:32 +00:00
</ fieldset >
< p >& nbsp ; </ p >
</ td >
</ tr >
< tr >
< td colspan = " 3 " >
2007-11-22 19:50:26 +00:00
< fieldset class = " <?php echo $_GET['type'] ; ?>edit " >
2004-05-31 09:38:59 +00:00
< legend >
2008-03-16 14:06:32 +00:00
< b >< ? php echo _ ( 'New section' ); ?> </b>
</ legend >< BR >
2005-06-21 20:58:32 +00:00
< table >
2004-05-31 09:38:59 +00:00
< tr >
< td >
2007-11-22 19:50:26 +00:00
< fieldset class = " <?php echo $_GET['type'] ; ?>edit " >
2004-05-31 12:19:42 +00:00
< legend >
2004-06-03 14:26:48 +00:00
< b >< ? php echo _ ( " Section " ); ?> </b>
2004-05-31 12:19:42 +00:00
</ legend >
2004-06-03 14:26:48 +00:00
< table align = " left " width = " 100% " >
2004-05-31 12:19:42 +00:00
< tr >
< td >
2008-03-16 14:06:32 +00:00
< ? php echo _ ( " Headline " ); ?> : <input type="text" name="section_text">
2004-05-31 12:19:42 +00:00
</ td >
2008-03-16 14:06:32 +00:00
< td >
< B >< ? php echo _ ( 'Position' ); ?> : </B>
< select name = " add_sectionText_position " >
< ? php echo $sections ; ?>
</ select >
2004-05-31 12:19:42 +00:00
</ td >
< td >
2008-03-16 14:06:32 +00:00
< input type = " submit " name = " add_sectionText " value = " <?php echo _('Add');?> " >
2004-05-31 12:19:42 +00:00
</ td >
2008-03-16 14:06:32 +00:00
</ tr >
< tr >
2004-06-03 14:26:48 +00:00
< td >
2008-03-16 14:06:32 +00:00
< ? php echo _ ( " Headline " ); ?> :
2004-06-03 14:26:48 +00:00
< select name = " section_item " >
< ? php echo $section_items ; ?>
2008-03-16 14:06:32 +00:00
</ select >& nbsp ; & nbsp ; & nbsp ;
</ td >
< td >
< B >< ? php echo _ ( 'Position' ); ?> : </B>
< select name = " add_section_position " >
< ? php echo $sections ; ?>
2004-06-03 14:26:48 +00:00
</ select >
2004-05-31 12:19:42 +00:00
</ td >
2008-03-16 14:06:32 +00:00
< td >
< input type = " submit " name = " add_section " value = " <?php echo _('Add');?> " >
</ td >
2004-05-31 12:19:42 +00:00
</ tr >
</ table >
</ fieldset >
</ td >
2004-06-03 14:26:48 +00:00
</ tr >
< tr >
2009-08-23 12:50:06 +00:00
< td colspan = " 2 " >& nbsp ; </ td >
2004-05-31 12:19:42 +00:00
</ tr >
< tr >
< td >
2007-11-22 19:50:26 +00:00
< fieldset class = " <?php echo $_GET['type'] ; ?>edit " >
2004-05-31 12:19:42 +00:00
< legend >
2008-03-16 14:06:32 +00:00
< b >< ? php echo _ ( " Text field " ); ?> </b>
2004-05-31 12:19:42 +00:00
</ legend >
< table width = " 100% " >
< tr >
2008-03-16 14:06:32 +00:00
< td >
< textarea name = " text_text " rows = " 3 " cols = " 40 " ></ textarea >& nbsp ; & nbsp ; & nbsp ;
</ td >
< td >
< B >< ? php echo _ ( 'Position' ); ?> : </B>
< select name = " add_text_position " >
< ? php echo $sections ; ?>
</ select >
2004-05-31 12:19:42 +00:00
</ td >
< td >
2008-03-16 14:06:32 +00:00
< input type = " submit " name = " add_text " value = " <?php echo _('Add');?> " >
2004-05-31 12:19:42 +00:00
</ td >
</ tr >
</ table >
</ fieldset >
</ td >
</ tr >
</ table >
</ fieldset >
2005-06-21 20:58:32 +00:00
</ td >
</ tr >
2008-03-23 10:57:34 +00:00
< tr >
< td colspan = " 3 " >
< fieldset class = " <?php echo $_GET['type'] ; ?>edit " >
< legend >
< b >< ? php echo _ ( 'New field' ); ?> </b>
</ legend >< BR >
2008-03-23 14:20:23 +00:00
< select name = " new_field " >
< ? php
foreach ( $_SESSION [ 'availablePDFFields' ] as $module => $fields ) {
2009-08-23 12:50:06 +00:00
if ( isset ( $fields ) && is_array ( $fields ) && ( sizeof ( $fields ) > 0 )) {
2008-04-28 18:01:15 +00:00
sort ( $fields );
2009-08-23 12:50:06 +00:00
if ( $module != 'main' ) {
$title = getModuleAlias ( $module , $_GET [ 'type' ]);
2008-03-23 14:20:23 +00:00
}
2009-08-23 12:50:06 +00:00
else {
$title = _ ( 'Main' );
}
echo " <optgroup label= \" $title\ " > \n " ;
foreach ( $fields as $field ) {
echo " <option value= \" " . $module . " _ " . $field . " \" label= \" $field\ " > $field </ option > \n " ;
}
echo " </optgroup> \n " ;
}
2008-03-23 14:20:23 +00:00
}
?>
</ select >
2008-03-23 10:57:34 +00:00
< B >< ? php echo _ ( 'Position' ); ?> : </B>
2008-03-23 14:20:23 +00:00
< select name = " add_field_position " >
2008-03-23 10:57:34 +00:00
< ? php echo $nonTextSections ; ?>
</ select >
2008-03-23 14:20:23 +00:00
< input type = " submit " name = " add_new_field " value = " <?php echo _('Add');?> " >
</ fieldset >
< p >& nbsp ; </ p >
2008-03-23 10:57:34 +00:00
</ td >
</ tr >
2005-06-21 20:58:32 +00:00
< tr >
< td colspan = " 3 " >
2007-11-22 19:50:26 +00:00
< fieldset class = " <?php echo $_GET['type'] ; ?>edit " >
2004-05-31 09:38:59 +00:00
< legend >
2006-03-04 10:49:55 +00:00
< b >< ? php echo _ ( " Save " ); ?> </b>
2008-03-23 14:20:23 +00:00
</ legend >< BR >
2004-05-31 09:38:59 +00:00
< table border = " 0 " align = " left " >
2004-07-16 06:33:37 +00:00
< ? php
2007-10-24 17:31:14 +00:00
if ( ! isset ( $_GET [ 'pdfname' ]) || ( $_GET [ 'pdfname' ] == '' )) {
2004-07-16 06:33:37 +00:00
?>
2004-05-31 09:38:59 +00:00
< tr >
< td >
< b >< ? php echo _ ( " Structure name " ); ?> :</b>
</ td >
< td >
2007-10-24 17:31:14 +00:00
< input type = " text " name = " pdfname " value = " <?php if (isset( $_GET['edit'] )) echo $_GET['edit'] ;?> " >
2004-05-31 09:38:59 +00:00
</ td >
< td >
< a href = " ../help.php?HelpNumber=360 " target = " lamhelp " >< ? php echo _ ( " Help " ); ?> </a>
</ td >
</ tr >
< tr >
< td colspan = " 3 " >
2007-10-24 17:31:14 +00:00
& nbsp ;
2004-05-31 09:38:59 +00:00
</ td >
</ tr >
2004-07-16 06:33:37 +00:00
< ? php
}
?>
2004-05-31 09:38:59 +00:00
< tr >
< td >
2004-07-16 06:33:37 +00:00
< ? php
if ( isset ( $_GET [ 'pdfname' ])) {
?>
2007-10-24 17:31:14 +00:00
< input type = " hidden " name = " pdfname " value = " <?php if (isset( $_GET['pdfname'] )) echo $_GET['pdfname'] ; ?> " >
2004-07-16 06:33:37 +00:00
< ? php
}
?>
2004-05-31 09:38:59 +00:00
< input type = " submit " name = " submit " value = " <?php echo _( " Save " );?> " >
</ td >
< td >
2006-03-04 10:49:55 +00:00
< input type = " submit " name = " abort " value = " <?php echo _( " Cancel " );?> " >
2004-05-31 09:38:59 +00:00
</ td >
< td >
2007-10-24 17:31:14 +00:00
& nbsp ;
2004-05-31 09:38:59 +00:00
</ td >
</ tr >
</ table >
2004-05-30 13:43:42 +00:00
</ fieldset >
</ td >
</ tr >
</ table >
2004-05-31 09:38:59 +00:00
< input type = " hidden " name = " modules " value = " <?php echo $modules ;?> " >
< input type = " hidden " name = " type " value = " <?php echo $_GET['type'] ;?> " >
2004-05-30 13:43:42 +00:00
</ form >
</ body >
</ html >
< ? php
?>