[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/include/inc_module/mod_feedimport/inc/ -> processing.inc.php (source)

   1  <?php
   2  // ----------------------------------------------------------------
   3  // obligate check for phpwcms constants
   4  if (!defined('PHPWCMS_ROOT')) {
   5     die("You Cannot Access This Script Directly, Have a Nice Day.");
   6  }
   7  // ----------------------------------------------------------------
   8  
   9  // set fields SBW gas rates
  10  $plugin['fields'] = array(
  11      'cnt_name'                                => 'STRING', // The feed source name
  12      'cnt_text'                                => 'STRING', // Feed source URL
  13      'cnt_object-structure_level_id'            => 'SELECT',
  14      'cnt_object-article_template_detail'    => 'SELECT',
  15      'cnt_object-article_template_list'        => 'SELECT',
  16      'cnt_object-feed_cache'                    => 'CHECK',
  17      'cnt_object-feed_cache_timeout'            => 'SELECT',
  18      'cnt_object-activate_after_import'        => 'CHECK',
  19      'cnt_object-author_id'                    => 'SELECT',
  20      'cnt_object-author_name'                => 'STRING',
  21      'cnt_object-source_link_add'            => 'CHECK',
  22      'cnt_object-source_link_text'            => 'STRING',
  23      'cnt_object-import_status_email'        => 'STRING',
  24      'cnt_status'                            => 'CHECK', // Inactive = 0, Active = 1, Deleted = 9
  25      'cnt_prio'                                => 'HIDDEN' // put in interval timeout here if enabled
  26  );
  27  
  28  
  29  $plugin['id']                                            = isset($_GET['edit']) ? intval($_GET['edit']) : 0;
  30  $plugin['fields_cnt_object-structure_level_id']            = array('-2' => $BLM['cnt_object-structure_empty'], '-1' => ' ', 0 => $BL['be_admin_struct_index']) + struct_select_menu(0, 0, 0, 'array');
  31  $plugin['fields_cnt_object-article_template_detail']    = feedimport_article_templates(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/article');
  32  $plugin['fields_cnt_object-article_template_list']        = feedimport_article_templates(PHPWCMS_TEMPLATE.'inc_cntpart/articlesummary/list');
  33  $plugin['fields_cnt_object-author_id']                    = feedimport_article_authors();
  34  $plugin['fields_cnt_object-feed_cache_timeout']            = array(
  35      60 => '1 '.$BL['be_date_minute'],
  36      300 => '5 '.$BL['be_date_minutes'],
  37      900 => '15 '.$BL['be_date_minutes'],
  38      1800 => '30 '.$BL['be_date_minutes'],
  39      3600 => '1 '.$BL['be_date_hour'],
  40      14400 => '4 '.$BL['be_date_hours'] . ' (' . $BL['be_admin_tmpl_default'] . ')',
  41      43200 => '12 '.$BL['be_date_hours'],
  42      86400 => '1 '.$BL['be_date_day'],
  43      172800 => '2 '.$BL['be_date_days'],
  44      604800 => '1 '.$BL['be_date_week'],
  45      1209600 => '2 '.$BL['be_date_weeks'],
  46      2592000 => '1 '.$BL['be_date_month']
  47  );
  48  
  49  // process post form
  50  if(isset($_POST['cnt_name'])) {
  51  
  52      $plugin['data'] = array(
  53          'id'    => intval($_POST['id']),
  54          'ref'    => MODULE_KEY
  55      );
  56  
  57      foreach($plugin['fields'] as $key => $value) {
  58      
  59          switch($value) {
  60          
  61              case 'RADIO':
  62              case 'HIDDEN':
  63              case 'TEXTAREA':
  64              case 'SELECT':    
  65              case 'STRING':        $plugin['data'][$key] = isset($_POST[$key]) ? clean_slweg($_POST[$key]) : '';
  66                                  break;
  67                              
  68              case 'CHECK':        $plugin['data'][$key] = empty($_POST[$key]) ? 0 : 1;
  69                                  break;
  70                              
  71              case 'FLOAT':        $plugin['data'][$key] = empty($_POST[$key]) ? 0 : floatval($_POST[$key]);
  72                                  break;
  73          
  74              case 'MULTICHECK':
  75              case 'MULTISELECT':    $plugin['data'][$key] = isset($_POST[$key]) && is_array($_POST[$key]) && count($_POST[$key]) ? ' '.implode(' , ', $_POST[$key]).' ' : '';
  76                                  break;
  77              
  78              case 'FILE':        $plugin['file_'.$key] =  empty($_POST['file_'.$key]) ? '' : clean_slweg($_POST['file_'.$key]);
  79              case 'HIDDENINT':
  80              case 'DATESELECT':
  81              case 'INT':
  82                                  $plugin['data'][$key] = empty($_POST[$key]) ? 0 : intval($_POST[$key]);
  83                                  break;
  84              
  85              case 'DECIMAL':        $plugin['data'][$key] = empty($_POST[$key]) ? 0 : clean_preformatted_number($_POST[$key], 'DEC2MET');
  86                                  break;
  87          
  88          }
  89      
  90      }
  91      
  92      if(empty($plugin['data']['cnt_name'])) {
  93          $plugin['error']['cnt_name'] = $BLM['error_name'];    
  94      }
  95      if(empty($plugin['data']['cnt_text'])) {
  96          $plugin['error']['cnt_text'] = $BLM['error_url'];    
  97      } elseif(!is_feed_available($plugin['data']['cnt_text'])) {
  98          $plugin['error']['cnt_text'] = $BLM['error_url_notvalid'];    
  99      }
 100      if($plugin['data']['cnt_object-structure_level_id'] == '-2' || $plugin['data']['cnt_object-structure_level_id'] == '-1') {
 101          $plugin['error']['cnt_structure_level_id'] = $BLM['error_structure_level_id'];    
 102      }
 103      
 104      $plugin['data']['cnt_prio'] = $plugin['data']['cnt_object-feed_cache'] ? $plugin['data']['cnt_object-feed_cache_timeout'] : 0;
 105  
 106      
 107      if(!isset($plugin['error'])) {
 108          
 109          $data = array(
 110              'cnt_module'    => MODULE_KEY,
 111              'cnt_changed'    => now(),
 112              'cnt_sort'        => now()
 113          );
 114          $data_serialize    = array();
 115          
 116          foreach($plugin['fields'] as $key => $value) {
 117          
 118              if($value == 'DISABLED' || $value == 'TEXT') {
 119                  continue;
 120              }
 121              
 122              $val = $plugin['data'][$key];
 123              $key = explode('-', $key, 2);
 124              
 125              if(isset($key[1])) {
 126                  $data[ $key[0] ][ $key[1] ] = $val;
 127              } else {
 128                  $data[ $key[0] ] = $val;
 129              }
 130              
 131              if(is_array($data[ $key[0] ]) || is_object($data[ $key[0] ])) {
 132                  $data_serialize[$key[0]] = $key[0];
 133              }
 134  
 135          }
 136          
 137          if(count($data_serialize)) {
 138              foreach($data_serialize as $value) {
 139                  $data[$value] = serialize($data[$value]);
 140              }
 141          }
 142      
 143          if($plugin['data']['id']) {
 144          
 145              // UPDATE
 146              $result = _dbUpdate('phpwcms_content', $data, 'cnt_id='.$plugin['data']['id'].' AND cnt_module='._dbEscape(MODULE_KEY));
 147          
 148          } else {
 149          
 150              // INSERT
 151              $data['cnt_created']    = now();
 152              $result                    = _dbInsert('phpwcms_content', $data);
 153          
 154          }
 155          
 156          // Back to module listing
 157          if(isset($_POST['save'])) {    
 158              headerRedirect(MODULE_HREF_DECODE);
 159          }
 160          
 161          // set ID
 162          if(!empty($result['INSERT_ID'])) {
 163              $plugin['data']['id']    = $result['INSERT_ID'];
 164              $plugin['id']            = $result['INSERT_ID'];
 165          }
 166      
 167      } else {
 168      
 169          set_status_message( implode(LF, $plugin['error']), 'warning' );
 170      
 171      }
 172  
 173  }
 174  
 175  // try to read entry from database
 176  if($plugin['id'] && !isset($plugin['error'])) {
 177  
 178      $plugin['data'] = _dbGet('phpwcms_content', '*', 'cnt_status!=9 AND cnt_module='._dbEscape(MODULE_KEY).' AND cnt_id='.$plugin['id']);
 179      if(isset($plugin['data'][0])) {
 180          $plugin['data'] = $plugin['data'][0];
 181          $plugin['data']['cnt_object'] = @unserialize($plugin['data']['cnt_object']);
 182          $plugin['data']['id'] = $plugin['data']['cnt_id'];
 183          if(count($plugin['data']['cnt_object'])) {
 184              foreach($plugin['data']['cnt_object'] as $key => $value) {
 185                  $plugin['data']['cnt_object-'.$key] = $value;
 186              }
 187          }
 188          
 189          $plugin['fields']['cnt_object-feed_import_trigger_url']    = 'STRING-DISABLED';
 190          $plugin['data']['cnt_object-feed_import_trigger_url']    = PHPWCMS_URL . 'index.php?feedimport='.md5($plugin['data']['cnt_id'].$plugin['data']['cnt_text']);
 191          
 192          
 193      } else {
 194          $plugin['data'] = false;
 195          set_status_message( sprintf($BLM['error_false_id'], $plugin['id']), 'warning' );
 196          headerRedirect(MODULE_HREF_DECODE);
 197      }
 198  }
 199  
 200  // default values
 201  if(empty($plugin['data'])) {
 202  
 203      $plugin['data'] = array( 'id' => 0 );
 204  
 205      foreach($plugin['fields'] as $key => $value) {
 206      
 207          switch($value) {
 208          
 209              case 'RADIO':
 210              case 'HIDDEN':
 211              case 'DATESELECT':
 212              case 'TEXTAREA':
 213              case 'SELECT':
 214              case 'STRING':        $plugin['data'][$key] = '';
 215                                  break;
 216              
 217              case 'INT':
 218              case 'FILE':
 219              case 'DECIMAL':
 220              case 'HIDDENINT':
 221              case 'FLOAT':
 222              case 'CHECK':        $plugin['data'][$key] = 0;
 223                                  break;
 224              
 225              case 'MULTICHECK':
 226              case 'MULTISELECT':    $plugin['data'][$key] = array();
 227                                  break;
 228                          
 229          }
 230      
 231      }
 232  
 233  }
 234  
 235  if(empty($plugin['data']['cnt_object-feed_cache_timeout'])) {
 236      $plugin['data']['cnt_object-feed_cache_timeout'] = 14400;
 237  }
 238  if(empty($plugin['data']['cnt_object-author_name'])) {
 239      list($plugin['data']['cnt_object-author_name']) = explode(' (', current($plugin['fields_cnt_object-author_id']));
 240  }
 241  if(empty($plugin['data']['cnt_object-source_link_text'])) {
 242      list($plugin['data']['cnt_object-source_link_text']) = '@@Source@@';
 243  }
 244  if(empty($plugin['data']['cnt_object-import_status_email'])) {
 245      list($plugin['data']['cnt_object-import_status_email']) = '';
 246  }
 247  
 248  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1