Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created July 12, 2011 04:05
Show Gist options
  • Save michaeltwofish/1077378 to your computer and use it in GitHub Desktop.
Save michaeltwofish/1077378 to your computer and use it in GitHub Desktop.
/**
* Add the page parent control to the publish page
*
* @param FormUI $form The publish page form
* @param Post $post The post being edited
*
*/
public function action_form_publish ( $form, $post )
{
if ( $form->content_type->value == Post::type( 'imprint' ) ) {
$form->append( 'fieldset', 'imprint_controls', 'Enter details of IMPRINT edition' );
$form->move_before($form->imprint_controls, $form->title);
$form->imprint_controls->append( 'file', 'cover', 'null:null', 'Cover', 'formcontrol_file' );
}
}
/**
* Handle saving of imprint posts
* @param Post $post The post being updated
* @param FormUI $form. The form from the publish page
*/
public function action_publish_post( $post, $form )
{
if ( $post->content_type == Post::type( 'imprint' ) ) {
// uploaded file is availabel at $form->cover->tmp_file
$target = Site::get_dir('user').'/files/somefilename.foo';
$result = move_uploaded_file($form->cover->tmp_file, $target);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment