[ Index ]

PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10)

title

Body

[close]

/include/inc_lib/ -> news.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2010 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6  
   7  This script is part of PHPWCMS. The PHPWCMS web content management system is
   8  free software; you can redistribute it and/or modify it under the terms of
   9  the GNU General Public License as published by the Free Software Foundation;
  10  either version 2 of the License, or (at your option) any later version.
  11  
  12  The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13  A copy is found in the textfile GPL.txt and important notices to the license
  14  from the author is found in LICENSE.txt distributed with these scripts.
  15  
  16  This script is distributed in the hope that it will be useful, but WITHOUT ANY
  17  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18  PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19  
  20  This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  /**
  31   * phpwcmsNews class
  32   */
  33  class phpwcmsNews {
  34  
  35      var $news                = array();
  36      var $news_total            = 0;
  37      var $where                = array('status' => 'cnt_status != 9');
  38      var $order_by            = array('cnt_startdate DESC');
  39      var $sql                = '';
  40      var $limit                = 0;
  41      var $start_at            = 0;
  42      var $select                = '*';
  43      var $base_url            = '';
  44      var $base_url_decoded    = '';
  45      var $data                = array();
  46      
  47      
  48  	function phpwcmsNews() {
  49  
  50          global $BL;
  51          global $phpwcms;
  52          
  53          $this->BL                = &$BL;
  54          $this->phpwcms            = &$phpwcms;
  55          $this->base_url            = PHPWCMS_URL.'phpwcms.php?do=articles&amp;p=3';
  56          $this->base_url_decoded    = PHPWCMS_URL.'phpwcms.php?do=articles&p=3';
  57          
  58      }
  59      
  60  	function formAction() {
  61      
  62          return $this->base_url.'&amp;cntid='.$this->data['cnt_id'].'&amp;action=edit';
  63      
  64      }
  65      
  66  	function _where() {
  67      
  68          $sql = '';
  69          
  70          if(is_array($this->where) && count($this->where)) {
  71              
  72              foreach($this->where as $value) {
  73              
  74                  $value = trim($value);
  75              
  76                  if(strtoupper(substr($value, 0, 2)) == 'OR') {
  77                  
  78                      $sql .= ' '.$value;
  79                  
  80                  } elseif(strtoupper(substr($value, 0, 3)) == 'AND') {
  81                  
  82                      $sql .= ' '.$value;
  83                  
  84                  } else {
  85                  
  86                      $sql .= ' AND '.$value;
  87                  }
  88              
  89              }
  90          
  91          } elseif(is_string($this->where) ) {
  92          
  93              $sql = ' ' . $this->where;
  94          
  95          }
  96          
  97          return $sql;
  98          
  99      }
 100  
 101      /**
 102       * set array with news
 103       */
 104  	function getNews() {
 105      
 106          $this->news = array();
 107      
 108          $sql  = 'SELECT '.$this->select.' FROM '.DB_PREPEND.'phpwcms_content WHERE ';
 109          $sql .= "cnt_module = 'news'";
 110          
 111          $sql .= $this->_where();
 112          
 113          if(is_array($this->order_by) && count($this->order_by)) {
 114          
 115              $sql .= ' ORDER BY '.implode(',', $this->order_by);
 116          
 117          }
 118          
 119          if($this->limit > 0) {
 120              
 121              $this->start_at = intval($this->start_at);
 122              $this->limit    = intval($this->limit);
 123              
 124              $sql .= ' LIMIT ' . $this->start_at . ',' . $this->limit;
 125              
 126          }
 127          
 128          $this->sql = $sql;
 129                  
 130          $news = _dbQuery($sql);
 131          
 132          $this->news = isset($news[0]) ? $news : array();
 133          
 134          $this->setQueryDefaults();
 135  
 136      }
 137      
 138  	function countAll() {
 139      
 140          $sql  = 'SELECT COUNT(cnt_id) FROM '.DB_PREPEND.'phpwcms_content WHERE ';
 141          $sql .= "cnt_module = 'news'" . $this->_where();
 142          
 143          $this->news_total = _dbCount($sql);
 144          
 145          return $this->news_total;
 146  
 147      }
 148      
 149  	function getPagination() {
 150      
 151          initMootools();
 152      
 153          $paginate = '<input type="hidden" name="page" id="filterPage" value="' . $this->filter_page . '" />';
 154      
 155          if( $this->limit > 0 && $this->news_total > $this->limit ) {
 156              
 157              $current_page    = $this->filter_page + 1;
 158              $max_page        = ceil($this->news_total / $this->limit);
 159              
 160              if($current_page > $max_page) {
 161                  $current_page = $max_page;
 162                  $this->filter_page    = $max_page - 1;
 163                  $this->start_at        = $this->filter_page * $this->limit;
 164              }
 165          
 166              $prev_page        = $this->filter_page - 1;
 167              if($prev_page < 0) {
 168                  $prev_page = 0;
 169              }
 170              $next_page        = $current_page;
 171              if($next_page >= $max_page) {
 172                  $next_page = $max_page - 1;
 173              }
 174              
 175              $paginate .= '<img src="img/famfamfam/action_back.gif" alt="" border="0"';    
 176              if($current_page == 1) {
 177                  $paginate .= ' class="inactive"';
 178              } else {
 179                  $paginate .= ' onclick="$(\'filterPage\').value='.$prev_page.';$(\'paginate\').submit();"';
 180              }
 181              $paginate .= ' /></td><td>';
 182              
 183              $paginate .= '&nbsp;<b>' . $current_page . '</b>/' . $max_page . '&nbsp;';
 184              
 185              $paginate .= '</td><td><img src="img/famfamfam/action_forward.gif" alt="" border="0"';
 186              if($current_page == $max_page) {
 187                  $paginate .= ' class="inactive"';
 188              } else {
 189                  $paginate .= ' onclick="$(\'filterPage\').value='.$next_page.';$(\'paginate\').submit();"';
 190              }
 191              $paginate .= ' />';
 192          
 193          } else {
 194          
 195              $this->start_at        = 0;
 196              $this->filter_page    = 0;
 197          
 198          }
 199      
 200          return $paginate;
 201      }
 202      
 203  	function setQueryDefaults() {
 204      
 205          $this->select    = '*';
 206          $this->order_by    = array('cnt_livedate');
 207          $this->sql        = '';
 208          $this->limit    = 0;
 209          $this->start_at    = 0;
 210  
 211      }
 212      
 213  	function filter() {
 214      
 215          // filter defaults
 216          // 0 = all with deleted
 217          // 1 = all active
 218          // 2 = all inactive
 219      
 220          $status    = isset($_SESSION['PAGE_FILTER']['news']['status']) ? intval($_SESSION['PAGE_FILTER']['news']['status']) : 0;
 221          $filter    = isset($_SESSION['PAGE_FILTER']['news']['filter']) ? $_SESSION['PAGE_FILTER']['news']['filter'] : '';
 222          $page    = isset($_SESSION['PAGE_FILTER']['news']['page']) ? intval($_SESSION['PAGE_FILTER']['news']['page']) : 0;
 223      
 224          if(isset($_POST['filter'])) {
 225              
 226              $active        = empty($_POST['showactive']) ? false : true;
 227              $inactive    = empty($_POST['showinactive']) ? false : true;
 228              $filter        = clean_slweg($_POST['filter']);
 229              $page        = empty($_POST['page']) ? 0 : intval($_POST['page']);
 230              
 231              if($active && $inactive) {
 232                  $status = 0;
 233              } elseif($active) {
 234                  $status = 1;
 235              } elseif($inactive) {
 236                  $status = 2;
 237              }
 238              
 239              if(!isset($_SESSION['PAGE_FILTER'])) {
 240                  $_SESSION['PAGE_FILTER'] = array();
 241              }
 242              
 243              $_SESSION['PAGE_FILTER']['news'] = array(
 244              
 245                              'status'    => $status,
 246                              'filter'    => $filter,
 247                              'page'        => $page
 248                      );
 249              
 250          }
 251  
 252          switch($status) {
 253              case 0:        $this->where['status'] = 'cnt_status IN (1,0)';
 254                          break;
 255              case 1:        $this->where['status'] = 'cnt_status = 1';
 256                          break;
 257              case 2:        $this->where['status'] = 'cnt_status = 0';
 258                          break;
 259          }
 260          
 261          if($filter != '') {
 262              $this->where['filter']  = "CONCAT(cnt_name,' ',cnt_title,' ',cnt_subtitle,' ',cnt_teasertext,' ',cnt_text) LIKE '%";
 263              $this->where['filter'] .= mysql_real_escape_string($filter)."%'";
 264          }
 265          
 266          $this->filter_status    = $status;
 267          $this->filter            = $filter;
 268          $this->filter_page        = $page;
 269          
 270          $this->limit            = setItemsPerPage();
 271          $this->start_at            = $page * $this->limit;
 272      
 273      }
 274      
 275  
 276  	function listBackend() {
 277      
 278          $this->select   = '*, ';
 279          $this->select  .= 'IF(UNIX_TIMESTAMP(cnt_livedate)<=0, cnt_created, UNIX_TIMESTAMP(cnt_livedate)) AS cnt_startdate, ';
 280          $this->select  .= 'UNIX_TIMESTAMP(cnt_killdate) AS cnt_enddate, ';
 281          $this->select  .= 'IF(cnt_sort=0, IF(UNIX_TIMESTAMP(cnt_livedate)<=0, cnt_created, UNIX_TIMESTAMP(cnt_livedate)), cnt_sort) AS cnt_sortdate';
 282          
 283          //$this->where        = array();
 284          $this->order_by    = array('cnt_prio DESC', 'cnt_sortdate DESC');
 285          
 286          $this->getNews();
 287      
 288          $list = array();
 289          
 290          $x = 0;
 291          
 292          if(count($this->news)) {
 293          
 294              $list[] = '<table cellpadding="0" cellspacing="0" border="0" summary="" class="listing">';
 295              $list[] = '<tr class="header">';
 296  
 297              $list[] = '<th class="column colfirst news">'.$this->BL['be_title'].'</th>';
 298              $list[] = '<th class="column">'.$this->BL['be_article_cnt_start'].'</th>';
 299              $list[] = '<th class="column">'.$this->BL['be_article_cnt_end'].'</th>';
 300              $list[] = '<th class="column">'.$this->BL['be_sort_date'].'</th>';
 301              $list[] = '<th class="column">Prio</th>';
 302              $list[] = '<th class="column collast">&nbsp;</th>';
 303              
 304              $list[] = '</tr>';
 305          
 306              foreach($this->news as $news) {
 307              
 308                  $list[] = '<tr class="row'.($x%2?' alt':'').'">';
 309              
 310                  $news['live'] = $news['cnt_startdate'];
 311                  $news['kill'] = strtotime($news['cnt_killdate']);
 312                  
 313                  $news['live'] = $news['live'] == false ? $this->BL['be_func_struct_empty'] : date($this->BL['be_shortdatetime'], $news['live']);
 314                  $news['kill'] = $news['kill'] == false ? $this->BL['be_func_struct_empty'] : date($this->BL['be_shortdatetime'], $news['kill']);
 315                  
 316                  $list[] = '<td class="column colfirst news">'.html_specialchars($news['cnt_name']).'</td>';
 317                  $list[] = '<td class="column">'.$news['live'].'</td>';
 318                  $list[] = '<td class="column">'.$news['kill'].'</td>';
 319                  $list[] = '<td class="column">'.date($this->BL['be_shortdatetime'], $news['cnt_sortdate']).'</td>';
 320                  $list[] = '<td class="column">'.$news['cnt_prio'].'</td>';
 321                  $list[] = '<td class="column collast">
 322                  
 323                      <a href="'.$this->base_url.'&amp;cntid='.$news['cnt_id'].'&amp;action=edit">'.    
 324                      '<img src="img/button/edit_22x13.gif" border="0" alt="" /></a>'.
 325      
 326                      '<a href="'.$this->base_url.'&amp;cntid='.$news['cnt_id'].'&amp;status='.
 327                      ($news['cnt_status'] ? '0' : '1').'">'.
 328                      '<img src="img/button/aktiv_12x13_'.$news['cnt_status'].'.gif" border="0" alt="" /></a>'.
 329      
 330                      '<a href="'.$this->base_url.'&amp;cntid='.$news['cnt_id'].'&amp;status=9'.
 331                      '" title="'.$this->BL['be_delete_dataset'].' '.html_specialchars($news['cnt_name']).'" onclick="return confirm(\''.
 332                      $this->BL['be_delete_dataset'].' \n'.js_singlequote($news['cnt_name']).'\');">'.
 333                      '<img src="img/button/trash_13x13_1.gif" border="0" alt=""></a>    
 334                  
 335                  </td>';
 336              
 337                  $list[] = '</tr>';
 338              
 339              
 340                  $x++;
 341              }
 342          
 343              
 344              $list[] = '</table>';
 345          }
 346          
 347          
 348          return implode(LF, $list);
 349      }
 350      
 351  	function getFiles($mode='backend') {
 352          
 353          if( is_array($this->data['cnt_files']['id']) && count($this->data['cnt_files']['id'])) {
 354          
 355              $where  = 'f_id IN (' . implode(',', $this->data['cnt_files']['id']) . ') AND ';
 356              $where .= 'f_kid=1 AND f_trash=0';
 357              if($mode !== 'backend') {
 358                  $where .= ' AND f_aktiv=1 AND f_public=1';
 359              }
 360                  
 361              $result = _dbGet('phpwcms_file', '*', $where);
 362              
 363              // now sort result
 364              if(isset($result[0])) {
 365              
 366                  $data = array();
 367                  foreach($this->data['cnt_files']['id'] as $value) {
 368                      $value = intval($value);
 369                      $data[$value] = array();
 370                  }
 371                  foreach($result as $value) {
 372                      $id = intval($value['f_id']);
 373                      $data[ $id ] = $value;
 374                  }
 375                  return $data;
 376              
 377              } else {
 378              
 379                  return array();
 380  
 381              }
 382                          
 383          } else {
 384          
 385              return array();
 386          
 387          }
 388      }
 389      
 390  	function edit() {
 391      
 392          $this->newsId    = intval($_GET['cntid']);
 393          $this->data        = array();
 394      
 395          if(isset($_GET['status'])) {
 396          
 397              $status = intval($_GET['status']);
 398              
 399              switch($status) {
 400              
 401                  case 0:
 402                  case 1:
 403                  case 9:        _dbUpdate('phpwcms_content', array('cnt_status'=>$status), 'cnt_id='.$this->newsId);
 404                              set_status_message( 
 405                                      $status == 9 ? $this->BL['be_action_deleted'] : $this->BL['be_action_status'], 
 406                                      'success', 
 407                                      array('ID'=>$this->newsId)
 408                                  );
 409                              break;
 410                              
 411                  default:    set_status_message($this->BL['be_action_notvalid'], 'warning');
 412              
 413              }
 414              
 415              headerRedirect( $this->base_url_decoded );
 416  
 417          }
 418          
 419          $start_date    = 0;
 420          $end_date    = 0;
 421  
 422          $this->data = array(    'cnt_id'                => 0,
 423                                  'cnt_pid'                => 0,
 424                                  'cnt_status'            => 0,
 425                                  'cnt_livedate'            => '0000-00-00 00:00:00',
 426                                  'cnt_killdate'            => '0000-00-00 00:00:00',
 427                                  'cnt_archive_status'    => 1,
 428                                  'cnt_alias'                => '',
 429                                  'cnt_name'                => '',
 430                                  'cnt_title'                => '',
 431                                  'cnt_subtitle'            => '',
 432                                  'cnt_editor'            => '',
 433                                  'cnt_place'                => '',
 434                                  'cnt_teasertext'        => '',
 435                                  'cnt_text'                => '',
 436                                  'cnt_duplicate'            => 0,
 437                                  'cnt_lang'                => '',
 438                                  'cnt_prio'                => 0,
 439                                  'cnt_readmore'            => 1,
 440          
 441                                  'cnt_image'                => array(    'id'            => 0,
 442                                                                      'name'            => '',
 443                                                                      'zoom'            => 0,
 444                                                                      'lightbox'        => 0,
 445                                                                      'caption'        => '',
 446                                                                      'link'            => ''
 447                                                                   ),
 448                                                                   
 449                                  'cnt_files'                => array(    'id'            => array(),
 450                                                                      'caption'        => ''
 451                                                                   ),
 452                                  'cnt_link'                => '',
 453                                  'cnt_linktext'            => '',
 454                                  'cnt_category'            => '',
 455                                  'cnt_livedate'            => '',
 456                                  'cnt_killdate'            => '',
 457                                  'cnt_sort'                => 0
 458                                  
 459                                );
 460                                
 461          
 462          // check form post
 463          if( isset($_POST['cnt_name']) ) {
 464      
 465              $post        = $this->getPostData();
 466              $post_error    = false;
 467              
 468              if(!empty($_POST['cnt_duplicate'])) {
 469                  $this->newsId            = 0;
 470                  $duplicate                = 1;
 471                  $post['cnt_created']    = now();
 472              } else {
 473                  $duplicate                = 0;
 474              }
 475              
 476              // 1st check if we have a name because it's mandatory
 477              if($post['cnt_name'] == '') {
 478              
 479                  $post_error    = true;
 480                  
 481                  set_status_message($this->BL['be_news_name_mandatory'], 'warning');
 482                  
 483                  $post['cnt_duplicate'] = $duplicate;
 484          
 485              }
 486              
 487              // do db work
 488              if($post_error === false) {
 489              
 490                  $values = $post;
 491                  $values['cnt_object'] = serialize($values['cnt_object']);
 492                  
 493                  $success = false;
 494              
 495                  // store new dataset
 496                  if($this->newsId == 0) {
 497                  
 498                      $result = _dbInsert('phpwcms_content', $values);
 499                      if(isset($result['INSERT_ID'])) {
 500                          $this->newsId    = $result['INSERT_ID'];
 501                          $success        = true;
 502                          
 503                          set_status_message($this->BL['be_successfully_saved'] . LF . $post['cnt_name'], 'success');
 504                      }
 505                  
 506                  // update existing dataset
 507                  } else {
 508                  
 509                      $result = _dbUpdate('phpwcms_content', $values, 'cnt_id='.$this->newsId);
 510                      if($result != false) {
 511                          $success = true;
 512                          
 513                          set_status_message($this->BL['be_successfully_updated'] . LF . $post['cnt_name'], 'success');
 514                      }
 515                  
 516                  }
 517                  
 518                  // if success
 519                  if($success) {
 520                  
 521                      // save categories
 522                      if($this->newsId) {
 523                  
 524                          _dbSaveCategories($post['cnt_object']['cnt_category'], 'news', $this->newsId, ',');
 525  
 526                      }
 527                  
 528                      // redirect to form again
 529                      if($this->newsId && isset($_POST['submit'])) {
 530                          headerRedirect( $this->base_url_decoded . '&cntid='.$this->newsId.'&action=edit' );
 531                          
 532                      // back to listing
 533                      } else {
 534                          headerRedirect( $this->base_url_decoded );
 535                      }
 536                  
 537                  // error while storing data
 538                  } else {
 539                  
 540                      set_status_message($BL['be_error_while_save'].trim( html_specialchars(' '.mysql_errno().': '.mysql_error() ) ), 'warning');
 541                  
 542                  }
 543              
 544              }
 545              
 546              
 547              $this->data = array_merge($this->data, $post);
 548  
 549  
 550          } elseif($this->newsId > 0) {
 551          
 552              $result = _dbGet('phpwcms_content', '*', 'cnt_status!=9 AND cnt_id='.$this->newsId, '', '', '1');
 553              if(isset($result[0])) {
 554  
 555                  $result[0]['cnt_object'] = @unserialize($result[0]['cnt_object']);
 556                  if(is_array($result[0]['cnt_object']['cnt_image'])) {
 557                      $result[0]['cnt_image'] = array_merge($this->data['cnt_image'], $result[0]['cnt_object']['cnt_image']);
 558                  }
 559                  if(is_array($result[0]['cnt_object']['cnt_files'])) {
 560                      $result[0]['cnt_files'] = array_merge($this->data['cnt_files'], $result[0]['cnt_object']['cnt_files']);
 561                  }
 562                  if(isset($result[0]['cnt_object']['cnt_link'])) {
 563                      $result[0]['cnt_link'] = $result[0]['cnt_object']['cnt_link'];
 564                  }
 565                  if(isset($result[0]['cnt_object']['cnt_linktext'])) {
 566                      $result[0]['cnt_linktext'] = $result[0]['cnt_object']['cnt_linktext'];
 567                  }
 568                  if(isset($result[0]['cnt_object']['cnt_category'])) {
 569                      $result[0]['cnt_category'] = $result[0]['cnt_object']['cnt_category'];
 570                  }
 571                  if(isset($result[0]['cnt_object']['cnt_readmore'])) {
 572                      $result[0]['cnt_readmore'] = $result[0]['cnt_object']['cnt_readmore'];
 573                  }
 574                  
 575                  $this->data = array_merge($this->data, $result[0]);
 576              
 577              } else {
 578              
 579                  set_status_message($this->BL['be_data_select_failed'], 'warning');
 580                  headerRedirect( $this->base_url_decoded );
 581              }
 582  
 583          }
 584          
 585          $start_date    = strtotime( $this->data['cnt_livedate'] );
 586          $end_date    = strtotime( $this->data['cnt_killdate'] );
 587          $sort_date    = intval($this->data['cnt_sort']);
 588          
 589          if(!$start_date) {
 590              $this->data['cnt_date_start'] = '';
 591              $this->data['cnt_time_start'] = '';
 592          } else {
 593              $this->data['cnt_date_start'] = date($this->BL['default_date'], $start_date);
 594              $this->data['cnt_time_start'] = date($this->BL['default_time'], $start_date);
 595          }
 596          
 597          if(!$end_date) {
 598              $this->data['cnt_date_end'] = '';
 599              $this->data['cnt_time_end'] = '';
 600          } else {
 601              $this->data['cnt_date_end'] = date($this->BL['default_date'], $end_date);
 602              $this->data['cnt_time_end'] = date($this->BL['default_time'], $end_date);
 603          }
 604          
 605          // sort date
 606          if($sort_date == 0) {
 607              $this->data['cnt_sort_date'] = '';
 608              $this->data['cnt_sort_time'] = '';
 609          } else {
 610              $this->data['cnt_sort_date'] = date($this->BL['default_date'], $sort_date);
 611              $this->data['cnt_sort_time'] = date($this->BL['default_time'], $sort_date);
 612          }
 613  
 614      }
 615  
 616  	function getPostData() {
 617          
 618          $post = array();
 619          
 620          // do only when news ID is known
 621          if( $this->newsId == 0 ) {
 622              
 623              $post['cnt_created']    = now();
 624          
 625          }
 626          
 627          $post['cnt_pid']            = 0;
 628          $post['cnt_type']            = '';
 629          $post['cnt_module']            = 'news';
 630          $post['cnt_changed']        = time();
 631          
 632          //$duplicate                    = empty($_POST['cnt_duplicate']) ? 0 : 1;
 633          
 634          $post['cnt_status']            = empty($_POST['cnt_status']) ? 0 : 1;
 635          $post['cnt_archive_status']    = empty($_POST['cnt_archive_status']) ? 0 : 1;
 636          $post['cnt_prio']            = empty($_POST['cnt_prio']) ? 0 : intval($_POST['cnt_prio']);
 637          
 638          $temp_time                    = isset($_POST['calendar_start_time']) ? _getTime($_POST['calendar_start_time']) : '';
 639          $temp_date                    = isset($_POST['calendar_start_date']) ? _getDate($_POST['calendar_start_date']) : '';
 640          $post['cnt_livedate']        = $temp_date.' '.$temp_time;
 641          
 642          $temp_time                    = isset($_POST['calendar_end_time']) ? _getTime($_POST['calendar_end_time']) : '';
 643          $temp_date                    = isset($_POST['calendar_end_date']) ? _getDate($_POST['calendar_end_date']) : '';
 644          $post['cnt_killdate']        = $temp_date.' '.$temp_time;
 645          
 646          $temp_time                    = isset($_POST['sort_time']) ? _getTime($_POST['sort_time']) : '';
 647          $temp_date                    = isset($_POST['sort_date']) ? _getDate($_POST['sort_date']) : '';
 648          $post['cnt_sort']            = intval( strtotime($temp_date.' '.$temp_time) );
 649          
 650          $post['cnt_name']            = isset($_POST['cnt_name']) ? clean_slweg($_POST['cnt_name']) : '';
 651          $post['cnt_title']            = isset($_POST['cnt_title']) ? clean_slweg($_POST['cnt_title']) : '';
 652          
 653          if($post['cnt_name'] == '' && $post['cnt_title'] != '') {
 654              $post['cnt_name'] = $post['cnt_title'];
 655          } elseif($post['cnt_name'] != '' && $post['cnt_title'] == '') {
 656              $post['cnt_title'] = $post['cnt_name'];
 657          }
 658          
 659          $post['cnt_alias']            = isset($_POST['cnt_alias']) ? clean_slweg($_POST['cnt_alias']) : '';
 660          if($post['cnt_alias'] == '') {
 661              $post['cnt_alias'] = empty($post['cnt_title']) ? $post['cnt_name'] : $post['cnt_title'];
 662          }
 663          $post['cnt_alias']            = proof_alias($this->newsId, $post['cnt_alias'], 'CONTENT');
 664          
 665          $post['cnt_subtitle']        = isset($_POST['cnt_subtitle']) ? clean_slweg($_POST['cnt_subtitle']) : '';
 666          $post['cnt_editor']            = isset($_POST['cnt_editor']) ? clean_slweg($_POST['cnt_editor']) : '';
 667          $post['cnt_place']            = isset($_POST['cnt_place']) ? clean_slweg($_POST['cnt_place']) : '';
 668          $post['cnt_teasertext']        = isset($_POST['cnt_teasertext']) ? clean_slweg($_POST['cnt_teasertext']) : '';
 669          $post['cnt_text']            = isset($_POST['cnt_text']) ? slweg($_POST['cnt_text']) : '';
 670          
 671          $category                    = isset($_POST['cnt_category']) ? decode_entities(clean_slweg($_POST['cnt_category'])) : '';
 672          $category                    = trim( trim( preg_replace('/\s+/', ' ', $category), ',' ) );
 673          
 674          $post['cnt_lang']            = isset($_POST['cnt_lang']) ? preg_replace('/[^a-z\-]/', '', strtolower($_POST['cnt_lang'])) : '';
 675          
 676          
 677          $post['cnt_object']            = array(     'cnt_image'        => array(), 
 678                                                  'cnt_files'        => array(), 
 679                                                  'cnt_link'        => '', 
 680                                                  'cnt_linktext'    => '', 
 681                                                  'cnt_category'    => '',
 682                                                  'cnt_readmore'    => 0
 683                                              );
 684          
 685          $post['cnt_object']['cnt_image']['id']            = isset($_POST['cnt_image_id']) ? intval($_POST['cnt_image_id']) : '';
 686          $post['cnt_object']['cnt_image']['name']        = isset($_POST['cnt_image_name']) ? clean_slweg($_POST['cnt_image_name']) : '';
 687          $post['cnt_object']['cnt_image']['zoom']        = empty($_POST['cnt_image_zoom']) ? 0 : 1;
 688          $post['cnt_object']['cnt_image']['lightbox']    = empty($_POST['cnt_image_lightbox']) ? 0 : 1;
 689          $post['cnt_object']['cnt_image']['caption']        = isset($_POST['cnt_image_caption']) ? clean_slweg($_POST['cnt_image_caption']) : '';
 690          $post['cnt_object']['cnt_image']['link']        = isset($_POST['cnt_image_link']) ? clean_slweg($_POST['cnt_image_link']) : '';
 691          
 692          $post['cnt_object']['cnt_files']['id']            = isset($_POST['cnt_files']) && is_array($_POST['cnt_files']) && count($_POST['cnt_files']) ? $_POST['cnt_files'] : array();
 693          $post['cnt_object']['cnt_files']['caption']        = isset($_POST['cnt_file_caption']) ? clean_slweg($_POST['cnt_file_caption'], 0, false) : '';
 694  
 695          $post['cnt_object']['cnt_link']                    = isset($_POST['cnt_link']) ? clean_slweg($_POST['cnt_link']) : '';
 696          $post['cnt_object']['cnt_linktext']                = isset($_POST['cnt_linktext']) ? clean_slweg($_POST['cnt_linktext']) : '';
 697          
 698          $post['cnt_object']['cnt_category']                = $category;
 699          
 700          $post['cnt_object']['cnt_readmore']                = empty($_POST['cnt_readmore']) ? 0 : 1;
 701          
 702          return $post;
 703      
 704      }
 705  
 706  
 707  }
 708  
 709  
 710  ?>


Generated: Tue Nov 16 22:51:00 2010 Cross-referenced by PHPXref 0.7