[ Index ]

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

title

Body

[close]

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

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2012 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 || $news['live'] <= 0 ? $this->BL['be_func_struct_empty'] : date($this->BL['be_shortdatetime'], $news['live']);
 314                  $news['kill'] = phpwcms_strtotime($news['cnt_killdate'], $this->BL['be_shortdatetime'], $this->BL['be_func_struct_empty']);
 315                  $news['sort'] = $news['cnt_sortdate'] == false || $news['cnt_sortdate'] <= 0 ? $this->BL['be_func_struct_empty'] : date($this->BL['be_shortdatetime'], $news['cnt_sortdate']);
 316                  
 317                  $list[] = '<td class="column colfirst news">'.html_specialchars($news['cnt_name']).'</td>';
 318                  $list[] = '<td class="column">'.$news['live'].'</td>';
 319                  $list[] = '<td class="column">'.$news['kill'].'</td>';
 320                  $list[] = '<td class="column">'.$news['sort'].'</td>';
 321                  $list[] = '<td class="column">'.$news['cnt_prio'].'</td>';
 322                  $list[] = '<td class="column collast">
 323                  
 324                      <a href="'.$this->base_url.'&amp;cntid='.$news['cnt_id'].'&amp;action=edit">'.    
 325                      '<img src="img/button/edit_22x13.gif" border="0" alt="" /></a>'.
 326      
 327                      '<a href="'.$this->base_url.'&amp;cntid='.$news['cnt_id'].'&amp;status='.
 328                      ($news['cnt_status'] ? '0' : '1').'">'.
 329                      '<img src="img/button/aktiv_12x13_'.$news['cnt_status'].'.gif" border="0" alt="" /></a>'.
 330      
 331                      '<a href="'.$this->base_url.'&amp;cntid='.$news['cnt_id'].'&amp;status=9'.
 332                      '" title="'.$this->BL['be_delete_dataset'].' '.html_specialchars($news['cnt_name']).'" onclick="return confirm(\''.
 333                      $this->BL['be_delete_dataset'].' \n'.js_singlequote($news['cnt_name']).'\');">'.
 334                      '<img src="img/button/trash_13x13_1.gif" border="0" alt=""></a>    
 335                  
 336                  </td>';
 337              
 338                  $list[] = '</tr>';
 339              
 340              
 341                  $x++;
 342              }
 343          
 344              
 345              $list[] = '</table>';
 346          }
 347          
 348          
 349          return implode(LF, $list);
 350      }
 351      
 352  	function getFiles($mode='backend') {
 353          
 354          if( is_array($this->data['cnt_files']['id']) && count($this->data['cnt_files']['id'])) {
 355          
 356              $where  = 'f_id IN (' . implode(',', $this->data['cnt_files']['id']) . ') AND ';
 357              $where .= 'f_kid=1 AND f_trash=0';
 358              if($mode !== 'backend') {
 359                  $where .= ' AND f_aktiv=1 AND f_public=1';
 360              }
 361                  
 362              $result = _dbGet('phpwcms_file', '*', $where);
 363              
 364              // now sort result
 365              if(isset($result[0])) {
 366              
 367                  $data = array();
 368                  foreach($this->data['cnt_files']['id'] as $value) {
 369                      $value = intval($value);
 370                      $data[$value] = array();
 371                  }
 372                  foreach($result as $value) {
 373                      $id = intval($value['f_id']);
 374                      $data[ $id ] = $value;
 375                  }
 376                  return $data;
 377              
 378              } else {
 379              
 380                  return array();
 381  
 382              }
 383                          
 384          } else {
 385          
 386              return array();
 387          
 388          }
 389      }
 390      
 391  	function edit() {
 392      
 393          $this->newsId    = intval($_GET['cntid']);
 394          $this->data        = array();
 395      
 396          if(isset($_GET['status'])) {
 397          
 398              $status = intval($_GET['status']);
 399              
 400              switch($status) {
 401              
 402                  case 0:
 403                  case 1:
 404                  case 9:        _dbUpdate('phpwcms_content', array('cnt_status'=>$status), 'cnt_id='.$this->newsId);
 405                              set_status_message( 
 406                                      $status == 9 ? $this->BL['be_action_deleted'] : $this->BL['be_action_status'], 
 407                                      'success', 
 408                                      array('ID'=>$this->newsId)
 409                                  );
 410                              break;
 411                              
 412                  default:    set_status_message($this->BL['be_action_notvalid'], 'warning');
 413              
 414              }
 415              
 416              headerRedirect( $this->base_url_decoded );
 417  
 418          }
 419          
 420          $start_date    = 0;
 421          $end_date    = 0;
 422  
 423          $this->data = array(    'cnt_id'                => 0,
 424                                  'cnt_pid'                => 0,
 425                                  'cnt_status'            => 0,
 426                                  'cnt_livedate'            => '0000-00-00 00:00:00',
 427                                  'cnt_killdate'            => '0000-00-00 00:00:00',
 428                                  'cnt_archive_status'    => 1,
 429                                  'cnt_alias'                => '',
 430                                  'cnt_name'                => '',
 431                                  'cnt_title'                => '',
 432                                  'cnt_subtitle'            => '',
 433                                  'cnt_editor'            => '',
 434                                  'cnt_place'                => '',
 435                                  'cnt_teasertext'        => '',
 436                                  'cnt_text'                => '',
 437                                  'cnt_duplicate'            => 0,
 438                                  'cnt_lang'                => '',
 439                                  'cnt_prio'                => 0,
 440                                  'cnt_readmore'            => 1,
 441          
 442                                  'cnt_image'                => array(    'id'            => 0,
 443                                                                      'name'            => '',
 444                                                                      'zoom'            => 0,
 445                                                                      'lightbox'        => 0,
 446                                                                      'caption'        => '',
 447                                                                      'link'            => ''
 448                                                                   ),
 449                                                                   
 450                                  'cnt_files'                => array(    'id'            => array(),
 451                                                                      'caption'        => ''
 452                                                                   ),
 453                                  'cnt_link'                => '',
 454                                  'cnt_linktext'            => '',
 455                                  'cnt_category'            => '',
 456                                  'cnt_livedate'            => '',
 457                                  'cnt_killdate'            => '',
 458                                  'cnt_sort'                => 0
 459                                  
 460                                );
 461                                
 462          
 463          // check form post
 464          if( isset($_POST['cnt_name']) ) {
 465      
 466              $post        = $this->getPostData();
 467              $post_error    = false;
 468              
 469              if(!empty($_POST['cnt_duplicate'])) {
 470                  $this->newsId            = 0;
 471                  $duplicate                = 1;
 472                  $post['cnt_created']    = now();
 473              } else {
 474                  $duplicate                = 0;
 475              }
 476              
 477              // 1st check if we have a name because it's mandatory
 478              if($post['cnt_name'] == '') {
 479              
 480                  $post_error    = true;
 481                  
 482                  set_status_message($this->BL['be_news_name_mandatory'], 'warning');
 483                  
 484                  $post['cnt_duplicate'] = $duplicate;
 485          
 486              }
 487              
 488              // do db work
 489              if($post_error === false) {
 490              
 491                  $values = $post;
 492                  $values['cnt_object'] = serialize($values['cnt_object']);
 493                  
 494                  $success = false;
 495              
 496                  // store new dataset
 497                  if($this->newsId == 0) {
 498                  
 499                      $result = _dbInsert('phpwcms_content', $values);
 500                      if(isset($result['INSERT_ID'])) {
 501                          $this->newsId    = $result['INSERT_ID'];
 502                          $success        = true;
 503                          
 504                          set_status_message($this->BL['be_successfully_saved'] . LF . $post['cnt_name'], 'success');
 505                      }
 506                  
 507                  // update existing dataset
 508                  } else {
 509                  
 510                      $result = _dbUpdate('phpwcms_content', $values, 'cnt_id='.$this->newsId);
 511                      if($result != false) {
 512                          $success = true;
 513                          
 514                          set_status_message($this->BL['be_successfully_updated'] . LF . $post['cnt_name'], 'success');
 515                      }
 516                  
 517                  }
 518                  
 519                  // if success
 520                  if($success) {
 521                  
 522                      // save categories
 523                      if($this->newsId) {
 524                  
 525                          _dbSaveCategories($post['cnt_object']['cnt_category'], 'news', $this->newsId, ',');
 526  
 527                      }
 528                  
 529                      // redirect to form again
 530                      if($this->newsId && isset($_POST['submit'])) {
 531                          headerRedirect( $this->base_url_decoded . '&cntid='.$this->newsId.'&action=edit' );
 532                          
 533                      // back to listing
 534                      } else {
 535                          headerRedirect( $this->base_url_decoded );
 536                      }
 537                  
 538                  // error while storing data
 539                  } else {
 540                  
 541                      set_status_message($BL['be_error_while_save'].trim( html_specialchars(' '.mysql_errno().': '.mysql_error() ) ), 'warning');
 542                  
 543                  }
 544              
 545              }
 546              
 547              
 548              $this->data = array_merge($this->data, $post);
 549  
 550  
 551          } elseif($this->newsId > 0) {
 552          
 553              $result = _dbGet('phpwcms_content', '*', 'cnt_status!=9 AND cnt_id='.$this->newsId, '', '', '1');
 554              if(isset($result[0])) {
 555  
 556                  $result[0]['cnt_object'] = @unserialize($result[0]['cnt_object']);
 557                  if(is_array($result[0]['cnt_object']['cnt_image'])) {
 558                      $result[0]['cnt_image'] = array_merge($this->data['cnt_image'], $result[0]['cnt_object']['cnt_image']);
 559                  }
 560                  if(is_array($result[0]['cnt_object']['cnt_files'])) {
 561                      $result[0]['cnt_files'] = array_merge($this->data['cnt_files'], $result[0]['cnt_object']['cnt_files']);
 562                  }
 563                  if(isset($result[0]['cnt_object']['cnt_link'])) {
 564                      $result[0]['cnt_link'] = $result[0]['cnt_object']['cnt_link'];
 565                  }
 566                  if(isset($result[0]['cnt_object']['cnt_linktext'])) {
 567                      $result[0]['cnt_linktext'] = $result[0]['cnt_object']['cnt_linktext'];
 568                  }
 569                  if(isset($result[0]['cnt_object']['cnt_category'])) {
 570                      $result[0]['cnt_category'] = $result[0]['cnt_object']['cnt_category'];
 571                  }
 572                  if(isset($result[0]['cnt_object']['cnt_readmore'])) {
 573                      $result[0]['cnt_readmore'] = $result[0]['cnt_object']['cnt_readmore'];
 574                  }
 575                  
 576                  $this->data = array_merge($this->data, $result[0]);
 577              
 578              } else {
 579              
 580                  set_status_message($this->BL['be_data_select_failed'], 'warning');
 581                  headerRedirect( $this->base_url_decoded );
 582              }
 583  
 584          }
 585          
 586          $start_date    = strtotime( $this->data['cnt_livedate'] );
 587          $end_date    = strtotime( $this->data['cnt_killdate'] );
 588          $sort_date    = intval($this->data['cnt_sort']);
 589          
 590          if($start_date <= 0) {
 591              $this->data['cnt_livedate']        = '0000-00-00 00:00:00';
 592              $this->data['cnt_date_start']    = '';
 593              $this->data['cnt_time_start']    = '';
 594          } else {
 595              $this->data['cnt_date_start']    = date($this->BL['default_date'], $start_date);
 596              $this->data['cnt_time_start']    = date($this->BL['default_time'], $start_date);
 597          }
 598          
 599          if($end_date <= 0) {
 600              $this->data['cnt_killdate']        = '0000-00-00 00:00:00';
 601              $this->data['cnt_date_end']        = '';
 602              $this->data['cnt_time_end']        = '';
 603          } else {
 604              $this->data['cnt_date_end']        = date($this->BL['default_date'], $end_date);
 605              $this->data['cnt_time_end']        = date($this->BL['default_time'], $end_date);
 606          }
 607          
 608          // sort date
 609          if($sort_date <= 0) {
 610              $this->data['cnt_sort']            = 0;
 611              $this->data['cnt_sort_date']    = '';
 612              $this->data['cnt_sort_time']    = '';
 613          } else {
 614              $this->data['cnt_sort_date']    = date($this->BL['default_date'], $sort_date);
 615              $this->data['cnt_sort_time']    = date($this->BL['default_time'], $sort_date);
 616          }
 617  
 618      }
 619  
 620  	function getPostData() {
 621          
 622          $post = array();
 623          
 624          // do only when news ID is known
 625          if( $this->newsId == 0 ) {
 626              
 627              $post['cnt_created']    = now();
 628          
 629          }
 630          
 631          $post['cnt_pid']            = 0;
 632          $post['cnt_type']            = '';
 633          $post['cnt_module']            = 'news';
 634          $post['cnt_changed']        = time();
 635          
 636          //$duplicate                    = empty($_POST['cnt_duplicate']) ? 0 : 1;
 637          
 638          $post['cnt_status']            = empty($_POST['cnt_status']) ? 0 : 1;
 639          $post['cnt_archive_status']    = empty($_POST['cnt_archive_status']) ? 0 : 1;
 640          $post['cnt_prio']            = empty($_POST['cnt_prio']) ? 0 : intval($_POST['cnt_prio']);
 641          
 642          $temp_time                    = isset($_POST['calendar_start_time']) ? _getTime($_POST['calendar_start_time']) : '';
 643          $temp_date                    = isset($_POST['calendar_start_date']) ? _getDate($_POST['calendar_start_date']) : '';
 644          $post['cnt_livedate']        = $temp_date.' '.$temp_time;
 645          
 646          $temp_time                    = isset($_POST['calendar_end_time']) ? _getTime($_POST['calendar_end_time']) : '';
 647          $temp_date                    = isset($_POST['calendar_end_date']) ? _getDate($_POST['calendar_end_date']) : '';
 648          $post['cnt_killdate']        = $temp_date.' '.$temp_time;
 649          
 650          $temp_time                    = isset($_POST['sort_time']) ? _getTime($_POST['sort_time']) : '';
 651          $temp_date                    = isset($_POST['sort_date']) ? _getDate($_POST['sort_date']) : '';
 652          $post['cnt_sort']            = intval( strtotime($temp_date.' '.$temp_time) );
 653          
 654          $post['cnt_name']            = isset($_POST['cnt_name']) ? clean_slweg($_POST['cnt_name']) : '';
 655          $post['cnt_title']            = isset($_POST['cnt_title']) ? clean_slweg($_POST['cnt_title']) : '';
 656          
 657          if($post['cnt_name'] == '' && $post['cnt_title'] != '') {
 658              $post['cnt_name'] = $post['cnt_title'];
 659          } elseif($post['cnt_name'] != '' && $post['cnt_title'] == '') {
 660              $post['cnt_title'] = $post['cnt_name'];
 661          }
 662          
 663          $post['cnt_alias']            = isset($_POST['cnt_alias']) ? clean_slweg($_POST['cnt_alias']) : '';
 664          if($post['cnt_alias'] == '') {
 665              $post['cnt_alias'] = empty($post['cnt_title']) ? $post['cnt_name'] : $post['cnt_title'];
 666          }
 667          $post['cnt_alias']            = proof_alias($this->newsId, $post['cnt_alias'], 'CONTENT');
 668          
 669          $post['cnt_subtitle']        = isset($_POST['cnt_subtitle']) ? clean_slweg($_POST['cnt_subtitle']) : '';
 670          $post['cnt_editor']            = isset($_POST['cnt_editor']) ? clean_slweg($_POST['cnt_editor']) : '';
 671          $post['cnt_place']            = isset($_POST['cnt_place']) ? clean_slweg($_POST['cnt_place']) : '';
 672          $post['cnt_teasertext']        = isset($_POST['cnt_teasertext']) ? clean_slweg($_POST['cnt_teasertext']) : '';
 673          $post['cnt_text']            = isset($_POST['cnt_text']) ? slweg($_POST['cnt_text']) : '';
 674          
 675          $category                    = isset($_POST['cnt_category']) ? decode_entities(clean_slweg($_POST['cnt_category'])) : '';
 676          $category                    = trim( trim( preg_replace('/\s+/', ' ', $category), ',' ) );
 677          
 678          $post['cnt_lang']            = isset($_POST['cnt_lang']) ? preg_replace('/[^a-z\-]/', '', strtolower($_POST['cnt_lang'])) : '';
 679          
 680          
 681          $post['cnt_object']            = array(     'cnt_image'        => array(), 
 682                                                  'cnt_files'        => array(), 
 683                                                  'cnt_link'        => '', 
 684                                                  'cnt_linktext'    => '', 
 685                                                  'cnt_category'    => '',
 686                                                  'cnt_readmore'    => 0
 687                                              );
 688          
 689          $post['cnt_object']['cnt_image']['id']            = isset($_POST['cnt_image_id']) ? intval($_POST['cnt_image_id']) : '';
 690          $post['cnt_object']['cnt_image']['name']        = isset($_POST['cnt_image_name']) ? clean_slweg($_POST['cnt_image_name']) : '';
 691          $post['cnt_object']['cnt_image']['zoom']        = empty($_POST['cnt_image_zoom']) ? 0 : 1;
 692          $post['cnt_object']['cnt_image']['lightbox']    = empty($_POST['cnt_image_lightbox']) ? 0 : 1;
 693          $post['cnt_object']['cnt_image']['caption']        = isset($_POST['cnt_image_caption']) ? clean_slweg($_POST['cnt_image_caption']) : '';
 694          $post['cnt_object']['cnt_image']['link']        = isset($_POST['cnt_image_link']) ? clean_slweg($_POST['cnt_image_link']) : '';
 695          
 696          $post['cnt_object']['cnt_files']['id']            = isset($_POST['cnt_files']) && is_array($_POST['cnt_files']) && count($_POST['cnt_files']) ? $_POST['cnt_files'] : array();
 697          $post['cnt_object']['cnt_files']['caption']        = isset($_POST['cnt_file_caption']) ? clean_slweg($_POST['cnt_file_caption'], 0, false) : '';
 698  
 699          $post['cnt_object']['cnt_link']                    = isset($_POST['cnt_link']) ? clean_slweg($_POST['cnt_link']) : '';
 700          $post['cnt_object']['cnt_linktext']                = isset($_POST['cnt_linktext']) ? clean_slweg($_POST['cnt_linktext']) : '';
 701          
 702          $post['cnt_object']['cnt_category']                = $category;
 703          
 704          $post['cnt_object']['cnt_readmore']                = empty($_POST['cnt_readmore']) ? 0 : 1;    
 705      
 706          return $post;
 707      
 708      }
 709  
 710  
 711  }
 712  
 713  
 714  ?>


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