b2evolution PHP Cross Reference Blogging Systems

Source: /inc/items/views/_file_create_posts.form.php - 176 lines - 5729 bytes - Summary - Text - Print

Description: This file implements the UI for make posts from images in file upload. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI for make posts from images in file upload.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   *
  10   * {@internal License choice
  11   * - If you have received this file as part of a package, please find the license.txt file in
  12   *   the same folder or the closest folder above for complete license terms.
  13   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  14   *   then you must choose one of the following licenses before using the file:
  15   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  16   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  17   * }}
  18   *
  19   * {@internal Open Source relicensing agreement:
  20   * EVO FACTORY grants Francois PLANQUE the right to license
  21   * EVO FACTORY contributions to this file and the b2evolution project
  22   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  23   * }}
  24   *
  25   * @package admin
  26   *
  27   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  28   *
  29   * @version $Id: _file_create_posts.form.php 6136 2014-03-08 07:59:48Z manuel $
  30   */
  31  
  32  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  33  
  34  /**
  35   * @var Settings
  36   */
  37  
  38  load_class( 'items/model/_item.class.php', 'Item' );
  39  load_class( 'files/model/_filelist.class.php', 'FileList' );
  40  
  41  global $post_extracats , $fm_FileRoot , $edited_Item;
  42  $edited_Item= new Item();
  43  
  44  $Form = new Form( NULL, 'pre_post_publish' );
  45  
  46  $Form->begin_form( 'fform', T_('Posts preview') );
  47  $Form->hidden_ctrl();
  48  
  49  $images_list = param( 'fm_selected', 'array/string' );
  50  foreach( $images_list as $key => $item )
  51  {
  52      $Form->hidden( 'fm_selected['.$key.']', $item );
  53  }
  54  // fp> TODO: cleanup all this crap:
  55  $Form->hidden( 'confirmed', get_param( 'confirmed' ) );
  56  $Form->hidden( 'md5_filelist', get_param( 'md5_filelist' ) );
  57  $Form->hidden( 'md5_cwd', get_param( 'md5_cwd' ) );
  58  $Form->hidden( 'locale', get_param( 'locale' ) );
  59  $Form->hidden( 'blog', get_param( 'blog' ) );
  60  $Form->hidden( 'mode', get_param( 'mode' ) );
  61  $Form->hidden( 'root', get_param( 'root' ) );
  62  $Form->hidden( 'path', get_param( 'path' ) );
  63  $Form->hidden( 'fm_mode', get_param( 'fm_mode' ) );
  64  $Form->hidden( 'linkctrl', get_param( 'linkctrl' ) );
  65  $Form->hidden( 'linkdata', get_param( 'linkdata' ) );
  66  $Form->hidden( 'iframe_name', get_param( 'iframe_name' ) );
  67  $Form->hidden( 'fm_filter', get_param( 'fm_filter' ) );
  68  $Form->hidden( 'fm_filter_regex', get_param( 'fm_filter_regex' ) );
  69  $Form->hidden( 'iframe_name', get_param( 'iframe_name' ) );
  70  $Form->hidden( 'fm_flatmode', get_param( 'fm_flatmode' ) );
  71  $Form->hidden( 'fm_order', get_param( 'fm_order' ) );
  72  $Form->hidden( 'fm_orderasc', get_param( 'fm_orderasc' ) );
  73  $Form->hidden( 'crumb_file', get_param( 'crumb_file' ) );
  74  
  75  $post_extracats = array();
  76  $post_counter = 0;
  77  
  78  
  79  /**
  80   * Get the categories list
  81   *
  82   * @param integer Parent category ID
  83   * @param integer Level
  84   * @return array Categories
  85   */
  86  function fcpf_categories_select( $parent_category_ID = -1, $level = 0 )
  87  {
  88      global $blog, $DB;
  89      $result_Array = array();
  90  
  91      $SQL = new SQL();
  92      $SQL->SELECT( 'cat_ID, cat_name' );
  93      $SQL->FROM( 'T_categories' );
  94      $SQL->WHERE( 'cat_blog_ID = '.$DB->quote( $blog ) );
  95      if( $parent_category_ID == -1 )
  96      {
  97          $SQL->WHERE_and( 'cat_parent_ID IS NULL' );
  98      }
  99      else
 100      {
 101          $SQL->WHERE( 'cat_parent_ID = '.$DB->quote( $parent_category_ID ) );
 102      }
 103      $SQL->ORDER_BY( 'cat_name' );
 104      $categories = $DB->get_results( $SQL->get() );
 105  
 106      if( ! empty( $categories ) )
 107      {
 108          foreach( $categories as $category )
 109          {
 110              $result_Array[] = array(
 111                      'value' => $category->cat_ID,
 112                      'label' => str_repeat( '&nbsp;&nbsp;&nbsp;', $level ).$category->cat_name
 113                  );
 114  
 115              $child_Categories_opts = fcpf_categories_select( $category->cat_ID, $level + 1 );
 116              if( $child_Categories_opts != '' )
 117              {
 118                  foreach( $child_Categories_opts as $cat )
 119                  {
 120                      $result_Array[] = $cat;
 121                  }
 122              }
 123          }
 124      }
 125      return $result_Array;
 126  }
 127  
 128  $FileCache = & get_FileCache();
 129  
 130  // Get the categories
 131  $categories = fcpf_categories_select();
 132  
 133  foreach( $images_list as $item )
 134  {
 135      $File = & $FileCache->get_by_root_and_path( $fm_FileRoot->type,  $fm_FileRoot->in_type_ID, urldecode( $item ), true );
 136      $title = $File->get( 'title' );
 137      if( empty( $title ) )
 138      {
 139          $title = basename( urldecode( $File->get( 'name' ) ) );
 140      }
 141      $Form->begin_fieldset( T_('Post #').( $post_counter + 1 ).get_manual_link( 'creating-posts-from-files' ) );
 142      $Form->text_input( 'post_title['.$post_counter.']', $title, 40, T_('Post title') );
 143  
 144      if( $post_counter != 0 )
 145      { // The posts after first
 146          if( $post_counter == 1 )
 147          { // Add new option to select a category from previous post
 148              $categories = array_merge(
 149                  array(
 150                      array(
 151                          'value' => 'same',
 152                          'label' => T_('Same as above').'<br />',
 153                      )
 154                  ), $categories );
 155          }
 156          // Use the same category for all others after first
 157          $selected_category_ID = 'same';
 158      }
 159      else
 160      { // First post, Use a default category as selected on load form
 161          global $Blog;
 162          $selected_category_ID = isset( $Blog ) ? $Blog->get_default_cat_ID() : 1;
 163      }
 164  
 165      $Form->radio_input( 'category['.$post_counter.']', $selected_category_ID, $categories, T_('Category'), array( 'suffix' => '<br />' ) );
 166      $Form->info( T_('Post content'), '<img src="'.$fm_FileRoot->ads_url.urldecode( $item ).'" width="200" />' );
 167  
 168      $Form->end_fieldset();
 169  
 170      $post_counter++;
 171  }
 172  $edited_Item = NULL;
 173  
 174  $Form->end_form( array( array( 'submit', 'actionArray[make_posts_from_files]', T_('Make posts'), 'ActionButton') ) );
 175  
 176  ?>

title

Description

title

Description

title

Description

title

title

Body