projects = $this->get_projects();
if ( !isset( $project_id ) ) {
if ( isset( $_GET['project_id'] ) ) {
$project_id = $_GET['project_id'];
} else {
$keys = array_keys( $this->projects, current( $this->projects ) );
$project_id = $keys[0];
}
}
$this->project_id = $project_id;
$export_step = ( isset( $_POST['export-step'] ) ) ? $_POST['export-step'] : '1';
if ( $export_step != '3' )
$this->display();
}
function display() {
$project_id = $this->project_id;
if ( isset( $_POST['export-step'] ) )
$this->save_session();
$options = get_post_meta( $project_id, 'anthologize_meta', true );
$cdate = !empty( $options['cdate'] ) ? $options['cdate'] : date('Y');
if ( isset( $options['cname'] ) )
$cname = $options['cname'];
else if ( isset( $options['author_name'] ) )
$cname = $options['author_name'];
else
$cname = '';
// Default is Creative Commons
$ctype = !empty( $options['ctype'] ) ? $options['ctype'] : 'cc';
$cctype = !empty( $options['cctype'] ) ? $options['cctype'] : 'by';
// No default for edition number
$edition = isset( $options['edition'] ) ? isset( $options['edition'] ) : false;
if ( isset( $options['authors'] ) )
$authors = $options['authors'];
else if ( isset( $options['author_name'] ) )
$authors = $options['authors'];
else
$authors = '';
$dedication = !empty( $options['dedication'] ) ? $options['dedication'] : '';
$acknowledgements = !empty( $options['acknowledgements'] ) ? $options['acknowledgements'] : '';
?>
$_POST['filetype'] );
// outputParams need to be reset at step 3 so that
// on a refresh null values will overwrite
if ( $_POST['export-step'] == '3' ) {
// filetype has been set different ways in different versions
// This is to be safe
$filetype = isset( $_SESSION['outputParams']['filetype'] ) ? $_SESSION['outputParams']['filetype'] : $_SESSION['filetype'];
$_SESSION['outputParams'] = array( 'format' => $filetype );
}
foreach ( $_POST as $key => $value ) {
if ( $key == 'submit' || $key == 'export-step' )
continue;
if ( $key == '' )
echo "OK";
if ( $_POST['export-step'] == '3' )
$_SESSION['outputParams'][$key] = stripslashes( $value );
else
$_SESSION[$key] = stripslashes( $value );
}
}
function export_format_list() {
global $anthologize_formats;
?>
$fdata ) : ?>
$odata ) {
if ( $oname == 'label' || $oname == 'loader-path' )
continue;
if ( !$odata )
continue;
$default = ( isset( $odata['default'] ) ) ? $odata['default'] : false;
$return .= '';
$return .= '
' . $odata['label'] . '
';
switch( $odata['type'] ) {
case 'checkbox':
$return .= $this->build_checkbox( $oname, $odata['label'] );
break;
case 'dropdown':
$return .= $this->build_dropdown( $oname, $odata['label'], $odata['values'], $default );
break;
// Default is a textbox
default:
$return .= $this->build_textbox( $oname, $odata['label'] );
break;
}
$return .= '
';
}
} else {
$return = __( 'This appears to be an invalid export format. Please try again.', 'anthologize' );
}
echo $return;
}
function build_checkbox( $name, $label ) {
$html = '';
return apply_filters( 'anthologize_build_checkbox', $html, $name, $label );
}
function build_dropdown( $name, $label, $options, $default ) {
// $name is the input name (no spaces, eg 'page-size')
// $label is the input label (for display, eg 'Page Size'. Should be internationalizable, eg __('Page Size', 'anthologize')
// $options is associative array where keys are option values and values are the text displayed in the option field.
// $default is the default option
$html = '';
return apply_filters( 'anthologize_build_dropdown', $html, $name, $label, $options );
}
function build_textbox( $name, $label ) {
$html = '';
return apply_filters( 'anthologize_build_textbox', $html, $name, $label );
}
function load_template() {
// The goggles! Zey do nossing!
// Check anthologize.php for the real handler method load_template, which happens before headers are sent.
}
function get_projects() {
$projects = array();
query_posts( 'post_type=anth_project&orderby=title&order=ASC&posts_per_page=-1' );
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
$projects[get_the_ID()] = get_the_title();
}
}
return $projects;
}
}
endif;