[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> articles.php (source)

   1  <?php
   2  /*

   3  $Id: articles.php 17 2006-08-04 18:04:08Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    require ('includes/application_top.php');
  14    require (DIR_FCKEDITOR . 'fckeditor.php');
  15    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  16  
  17    if (tep_not_null($action)) {
  18      switch ($action) {
  19        case 'setflag':
  20          if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
  21            if (isset($HTTP_GET_VARS['aID'])) {
  22              tep_set_article_status($HTTP_GET_VARS['aID'], $HTTP_GET_VARS['flag']);
  23            }
  24  
  25            if (USE_CACHE == 'true') {
  26              tep_reset_cache_block('topics');
  27            }
  28          }
  29  
  30          tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $HTTP_GET_VARS['tPath'] . '&aID=' . $HTTP_GET_VARS['aID']));
  31          break;
  32        case 'new_topic':
  33        case 'edit_topic':
  34          $HTTP_GET_VARS['action']=$HTTP_GET_VARS['action'] . '_ACD';
  35          break;
  36        case 'insert_topic':
  37        case 'update_topic':
  38          if ( ($HTTP_POST_VARS['edit_x']) || ($HTTP_POST_VARS['edit_y']) ) {
  39            $HTTP_GET_VARS['action'] = 'edit_topic_ACD';
  40          } else {
  41          if (isset($HTTP_POST_VARS['topics_id'])) $topics_id = tep_db_prepare_input($HTTP_POST_VARS['topics_id']);
  42            if ($topics_id == '') {
  43              $topics_id = tep_db_prepare_input($HTTP_GET_VARS['tID']);
  44              }
  45          $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);
  46  
  47          $sql_data_array = array('sort_order' => $sort_order);
  48  
  49          if ($action == 'insert_topic') {
  50            $insert_sql_data = array('parent_id' => $current_topic_id,
  51                                     'date_added' => 'now()');
  52  
  53            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  54  
  55            tep_db_perform(TABLE_TOPICS, $sql_data_array);
  56  
  57            $topics_id = tep_db_insert_id();
  58          } elseif ($action == 'update_topic') {
  59            $update_sql_data = array('last_modified' => 'now()');
  60  
  61            $sql_data_array = array_merge($sql_data_array, $update_sql_data);
  62  
  63            tep_db_perform(TABLE_TOPICS, $sql_data_array, 'update', "topics_id = '" . (int)$topics_id . "'");
  64          }
  65  
  66          $languages = tep_get_languages();
  67          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  68  
  69            $language_id = $languages[$i]['id'];
  70  
  71            $sql_data_array = array('topics_name' => tep_db_prepare_input($HTTP_POST_VARS['topics_name'][$language_id]),
  72                                    'topics_heading_title' => tep_db_prepare_input($HTTP_POST_VARS['topics_heading_title'][$language_id]),
  73                                    'topics_description' => tep_db_prepare_input($HTTP_POST_VARS['topics_description'][$language_id]));
  74  
  75            if ($action == 'insert_topic') {
  76              $insert_sql_data = array('topics_id' => $topics_id,
  77                                       'language_id' => $languages[$i]['id']);
  78  
  79              $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  80  
  81              tep_db_perform(TABLE_TOPICS_DESCRIPTION, $sql_data_array);
  82            } elseif ($action == 'update_topic') {
  83              tep_db_perform(TABLE_TOPICS_DESCRIPTION, $sql_data_array, 'update', "topics_id = '" . (int)$topics_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
  84            }
  85          }
  86  
  87          if (USE_CACHE == 'true') {
  88            tep_reset_cache_block('topics');
  89          }
  90  
  91          tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $topics_id));
  92          break;
  93          }
  94        case 'delete_topic_confirm':
  95          if (isset($HTTP_POST_VARS['topics_id'])) {
  96            $topics_id = tep_db_prepare_input($HTTP_POST_VARS['topics_id']);
  97  
  98            $topics = tep_get_topic_tree($topics_id, '', '0', '', true);
  99            $articles = array();
 100            $articles_delete = array();
 101  
 102            for ($i=0, $n=sizeof($topics); $i<$n; $i++) {
 103              $article_ids_query = tep_db_query("select articles_id from " . TABLE_ARTICLES_TO_TOPICS . " where topics_id = '" . (int)$topics[$i]['id'] . "'");
 104  
 105              while ($article_ids = tep_db_fetch_array($article_ids_query)) {
 106                $articles[$article_ids['articles_id']]['topics'][] = $topics[$i]['id'];
 107              }
 108            }
 109  
 110            reset($articles);
 111            while (list($key, $value) = each($articles)) {
 112              $topic_ids = '';
 113  
 114              for ($i=0, $n=sizeof($value['topics']); $i<$n; $i++) {
 115                $topic_ids .= "'" . (int)$value['topics'][$i] . "', ";
 116              }
 117              $topic_ids = substr($topic_ids, 0, -2);
 118  
 119              $check_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES_TO_TOPICS . " where articles_id = '" . (int)$key . "' and topics_id not in (" . $topic_ids . ")");
 120              $check = tep_db_fetch_array($check_query);
 121              if ($check['total'] < '1') {
 122                $articles_delete[$key] = $key;
 123              }
 124            }
 125  
 126  // removing topics can be a lengthy process

 127            tep_set_time_limit(0);
 128            for ($i=0, $n=sizeof($topics); $i<$n; $i++) {
 129              tep_remove_topic($topics[$i]['id']);
 130            }
 131  
 132            reset($articles_delete);
 133            while (list($key) = each($articles_delete)) {
 134              tep_remove_article($key);
 135            }
 136          }
 137  
 138          if (USE_CACHE == 'true') {
 139            tep_reset_cache_block('topics');
 140          }
 141  
 142          tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath));
 143          break;
 144        case 'delete_article_confirm':
 145          if (isset($HTTP_POST_VARS['articles_id']) && isset($HTTP_POST_VARS['article_topics']) && is_array($HTTP_POST_VARS['article_topics'])) {
 146            $article_id = tep_db_prepare_input($HTTP_POST_VARS['articles_id']);
 147            $article_topics = $HTTP_POST_VARS['article_topics'];
 148  
 149            for ($i=0, $n=sizeof($article_topics); $i<$n; $i++) {
 150              tep_db_query("delete from " . TABLE_ARTICLES_TO_TOPICS . " where articles_id = '" . (int)$article_id . "' and topics_id = '" . (int)$article_topics[$i] . "'");
 151            }
 152  
 153            $article_topics_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES_TO_TOPICS . " where articles_id = '" . (int)$article_id . "'");
 154            $article_topics = tep_db_fetch_array($article_topics_query);
 155  
 156            if ($article_topics['total'] == '0') {
 157              tep_remove_article($article_id);
 158            }
 159          }
 160  
 161          if (USE_CACHE == 'true') {
 162            tep_reset_cache_block('topics');
 163          }
 164  
 165          tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath));
 166          break;
 167        case 'move_topic_confirm':
 168          if (isset($HTTP_POST_VARS['topics_id']) && ($HTTP_POST_VARS['topics_id'] != $HTTP_POST_VARS['move_to_topic_id'])) {
 169            $topics_id = tep_db_prepare_input($HTTP_POST_VARS['topics_id']);
 170            $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_topic_id']);
 171  
 172            $path = explode('_', tep_get_generated_topic_path_ids($new_parent_id));
 173  
 174            if (in_array($topics_id, $path)) {
 175              $messageStack->add_session(ERROR_CANNOT_MOVE_TOPIC_TO_PARENT, 'error');
 176  
 177              tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $topics_id));
 178            } else {
 179              tep_db_query("update " . TABLE_TOPICS . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where topics_id = '" . (int)$topics_id . "'");
 180  
 181              if (USE_CACHE == 'true') {
 182                tep_reset_cache_block('topics');
 183              }
 184  
 185              tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $new_parent_id . '&tID=' . $topics_id));
 186            }
 187          }
 188  
 189          break;
 190        case 'move_article_confirm':
 191          $articles_id = tep_db_prepare_input($HTTP_POST_VARS['articles_id']);
 192          $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_topic_id']);
 193  
 194          $duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES_TO_TOPICS . " where articles_id = '" . (int)$articles_id . "' and topics_id = '" . (int)$new_parent_id . "'");
 195          $duplicate_check = tep_db_fetch_array($duplicate_check_query);
 196          if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_ARTICLES_TO_TOPICS . " set topics_id = '" . (int)$new_parent_id . "' where articles_id = '" . (int)$articles_id . "' and topics_id = '" . (int)$current_topic_id . "'");
 197  
 198          if (USE_CACHE == 'true') {
 199            tep_reset_cache_block('topics');
 200          }
 201  
 202          tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $new_parent_id . '&aID=' . $articles_id));
 203          break;
 204        case 'insert_article':
 205        case 'update_article':
 206          if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {
 207            $action = 'new_article';
 208          } else {
 209            if (isset($HTTP_GET_VARS['aID'])) $articles_id = tep_db_prepare_input($HTTP_GET_VARS['aID']);
 210            $articles_date_available = tep_db_prepare_input($HTTP_POST_VARS['articles_date_available']);
 211  
 212            $articles_date_available = (date('Y-m-d') < $articles_date_available) ? $articles_date_available : 'null';
 213  
 214            $sql_data_array = array('articles_date_available' => $articles_date_available,
 215                                    'articles_status' => tep_db_prepare_input($HTTP_POST_VARS['articles_status']),
 216                                    'authors_id' => tep_db_prepare_input($HTTP_POST_VARS['authors_id']));
 217  
 218            if ($action == 'insert_article') {
 219              // If expected article then articles_date _added becomes articles_date_available

 220              if (isset($HTTP_POST_VARS['articles_date_available']) && tep_not_null($HTTP_POST_VARS['articles_date_available'])) {
 221                $insert_sql_data = array('articles_date_added' => tep_db_prepare_input($HTTP_POST_VARS['articles_date_available']));
 222              } else {
 223                $insert_sql_data = array('articles_date_added' => 'now()');
 224              }
 225              $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
 226  
 227              tep_db_perform(TABLE_ARTICLES, $sql_data_array);
 228              $articles_id = tep_db_insert_id();
 229  
 230              tep_db_query("insert into " . TABLE_ARTICLES_TO_TOPICS . " (articles_id, topics_id) values ('" . (int)$articles_id . "', '" . (int)$current_topic_id . "')");
 231            } elseif ($action == 'update_article') {
 232              $update_sql_data = array('articles_last_modified' => 'now()');
 233              // If expected article then articles_date _added becomes articles_date_available

 234              if (isset($HTTP_POST_VARS['articles_date_available']) && tep_not_null($HTTP_POST_VARS['articles_date_available'])) {
 235                $update_sql_data = array('articles_date_added' => tep_db_prepare_input($HTTP_POST_VARS['articles_date_available']));
 236              }
 237  
 238              $sql_data_array = array_merge($sql_data_array, $update_sql_data);
 239  
 240              tep_db_perform(TABLE_ARTICLES, $sql_data_array, 'update', "articles_id = '" . (int)$articles_id . "'");
 241            }
 242  
 243            $languages = tep_get_languages();
 244            for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 245              $language_id = $languages[$i]['id'];
 246  
 247              $sql_data_array = array('articles_name' => tep_db_prepare_input($HTTP_POST_VARS['articles_name'][$language_id]),
 248                                      'articles_description' => tep_db_prepare_input($HTTP_POST_VARS['articles_description'][$language_id]),
 249                                      'articles_url' => tep_db_prepare_input($HTTP_POST_VARS['articles_url'][$language_id]),
 250                                      'articles_head_title_tag' => tep_db_prepare_input($HTTP_POST_VARS['articles_head_title_tag'][$language_id]),
 251                                      'articles_head_desc_tag' => tep_db_prepare_input($HTTP_POST_VARS['articles_head_desc_tag'][$language_id]),
 252                                      'articles_head_keywords_tag' => tep_db_prepare_input($HTTP_POST_VARS['articles_head_keywords_tag'][$language_id]));
 253  
 254              if ($action == 'insert_article') {
 255                $insert_sql_data = array('articles_id' => $articles_id,
 256                                         'language_id' => $language_id);
 257  
 258                $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
 259  
 260                tep_db_perform(TABLE_ARTICLES_DESCRIPTION, $sql_data_array);
 261              } elseif ($action == 'update_article') {
 262                tep_db_perform(TABLE_ARTICLES_DESCRIPTION, $sql_data_array, 'update', "articles_id = '" . (int)$articles_id . "' and language_id = '" . (int)$language_id . "'");
 263              }
 264            }
 265  
 266            if (USE_CACHE == 'true') {
 267              tep_reset_cache_block('topics');
 268            }
 269  
 270            tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $articles_id));
 271          }
 272          break;
 273        case 'copy_to_confirm':
 274          if (isset($HTTP_POST_VARS['articles_id']) && isset($HTTP_POST_VARS['topics_id'])) {
 275            $articles_id = tep_db_prepare_input($HTTP_POST_VARS['articles_id']);
 276            $topics_id = tep_db_prepare_input($HTTP_POST_VARS['topics_id']);
 277  
 278            if ($HTTP_POST_VARS['copy_as'] == 'link') {
 279              if ($topics_id != $current_topic_id) {
 280                $check_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES_TO_TOPICS . " where articles_id = '" . (int)$articles_id . "' and topics_id = '" . (int)$topics_id . "'");
 281                $check = tep_db_fetch_array($check_query);
 282                if ($check['total'] < '1') {
 283                  tep_db_query("insert into " . TABLE_ARTICLES_TO_TOPICS . " (articles_id, topics_id) values ('" . (int)$articles_id . "', '" . (int)$topics_id . "')");
 284                }
 285              } else {
 286                $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_TOPIC, 'error');
 287              }
 288            } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
 289              $article_query = tep_db_query("select articles_date_available, authors_id from " . TABLE_ARTICLES . " where articles_id = '" . (int)$articles_id . "'");
 290              $article = tep_db_fetch_array($article_query);
 291  
 292              tep_db_query("insert into " . TABLE_ARTICLES . " (articles_date_added, articles_date_available, articles_status, authors_id) values (now(), '" . tep_db_input($article['articles_date_available']) . "', '0', '" . (int)$article['authors_id'] . "')");
 293              $dup_articles_id = tep_db_insert_id();
 294  
 295              $description_query = tep_db_query("select language_id, articles_name, articles_description, articles_url, articles_head_title_tag, articles_head_desc_tag, articles_head_keywords_tag from " . TABLE_ARTICLES_DESCRIPTION . " where articles_id = '" . (int)$articles_id . "'");
 296              while ($description = tep_db_fetch_array($description_query)) {
 297                tep_db_query("insert into " . TABLE_ARTICLES_DESCRIPTION . " (articles_id, language_id, articles_name, articles_description, articles_url, articles_head_title_tag, articles_head_desc_tag, articles_head_keywords_tag, articles_viewed) values ('" . (int)$dup_articles_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['articles_name']) . "', '" . tep_db_input($description['articles_description']) . "', '" . tep_db_input($description['articles_url']) . "', '" . tep_db_input($description['articles_head_title_tag']) . "', '" . tep_db_input($description['articles_head_desc_tag']) . "', '" . tep_db_input($description['articles_head_keywords_tag']) . "', '0')");
 298              }
 299  
 300              tep_db_query("insert into " . TABLE_ARTICLES_TO_TOPICS . " (articles_id, topics_id) values ('" . (int)$dup_articles_id . "', '" . (int)$topics_id . "')");
 301              $articles_id = $dup_articles_id;
 302            }
 303  
 304            if (USE_CACHE == 'true') {
 305              tep_reset_cache_block('topics');
 306            }
 307          }
 308  
 309          tep_redirect(tep_href_link(FILENAME_ARTICLES, 'tPath=' . $topics_id . '&aID=' . $articles_id));
 310          break;
 311      }
 312    }
 313  
 314  // check if the catalog image directory exists

 315    if (is_dir(DIR_FS_CATALOG_IMAGES)) {
 316      if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
 317    } else {
 318      $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
 319    }
 320  ?>
 321  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 322  <html <?php echo HTML_PARAMS; ?>>
 323  <head>
 324  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 325  <?php
 326  // BOF: WebMakers.com Changed: Header Tag Controller v1.0

 327  // Replaced by header_tags.php

 328  if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
 329    require(DIR_WS_INCLUDES . 'header_tags.php');
 330  } else {
 331  ?>
 332    <title><?php echo TITLE ?></title>
 333  <?php
 334  }
 335  // EOF: WebMakers.com Changed: Header Tag Controller v1.0

 336  ?>
 337  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 338  <script language="javascript" src="includes/general.js"></script>
 339  </head>
 340  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
 341  <div id="spiffycalendar" class="text"></div>
 342  <!-- header //-->
 343  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 344  <!-- header_eof //-->
 345  
 346  <!-- body //-->
 347  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 348    <tr>
 349      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 350  <!-- left_navigation //-->
 351  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 352  <!-- left_navigation_eof //-->
 353      </table></td>
 354  <!-- body_text //-->
 355       <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 356   <?php
 357     //----- new_topic / edit_topic  -----

 358    if ($HTTP_GET_VARS['action'] == 'new_topic_ACD' || $HTTP_GET_VARS['action'] == 'edit_topic_ACD') {
 359      if ( ($HTTP_GET_VARS['tID']) && (!$HTTP_POST_VARS) ) {
 360        $topics_query = tep_db_query("select t.topics_id, td.topics_name, td.topics_heading_title, td.topics_description, t.parent_id, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.topics_id = '" . $HTTP_GET_VARS['tID'] . "' and t.topics_id = td.topics_id and td.language_id = '" . $languages_id . "' order by t.sort_order, td.topics_name");
 361        $topic = tep_db_fetch_array($topics_query);
 362  
 363        $tInfo = new objectInfo($topic);
 364      } elseif ($HTTP_POST_VARS) {
 365        $tInfo = new objectInfo($HTTP_POST_VARS);
 366        $topics_name = $HTTP_POST_VARS['topics_name'];
 367        $topics_heading_title = $HTTP_POST_VARS['topics_heading_title'];
 368        $topics_description = $HTTP_POST_VARS['topics_description'];
 369        $topics_url = $HTTP_POST_VARS['topics_url'];
 370      } else {
 371        $tInfo = new objectInfo(array());
 372      }
 373  
 374      $languages = tep_get_languages();
 375  
 376      $text_new_or_edit = ($HTTP_GET_VARS['action']=='new_topic_ACD') ? TEXT_INFO_HEADING_NEW_TOPIC : TEXT_INFO_HEADING_EDIT_TOPIC;
 377  ?>
 378        <tr>
 379          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 380            <tr>
 381              <td class="pageHeading"><?php echo sprintf($text_new_or_edit, tep_output_generated_topic_path($current_topic_id)); ?></td>
 382              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 383            </tr>
 384          </table></td>
 385        </tr>
 386        <tr>
 387          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 388        </tr>
 389        <tr><?php echo tep_draw_form('new_topic', FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $HTTP_GET_VARS['tID'] . '&action=new_topic_preview', 'post', 'enctype="multipart/form-data"'); ?>
 390          <td><table border="0" cellspacing="0" cellpadding="2">
 391  <?php
 392      for ($i=0; $i<sizeof($languages); $i++) {
 393  ?>
 394            <tr>
 395              <td class="main"><?php if ($i == 0) echo TEXT_EDIT_TOPICS_NAME; ?></td>
 396              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('topics_name[' . $languages[$i]['id'] . ']', (($topics_name[$languages[$i]['id']]) ? stripslashes($topics_name[$languages[$i]['id']]) : tep_get_topic_name($tInfo->topics_id, $languages[$i]['id']))); ?></td>
 397            </tr>
 398  <?php
 399      }
 400  ?>
 401            <tr>
 402              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 403            </tr>
 404  <?php
 405      for ($i=0; $i<sizeof($languages); $i++) {
 406  ?>
 407            <tr>
 408              <td class="main"><?php if ($i == 0) echo TEXT_EDIT_TOPICS_HEADING_TITLE; ?></td>
 409              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('topics_heading_title[' . $languages[$i]['id'] . ']', (($topics_name[$languages[$i]['id']]) ? stripslashes($topics_name[$languages[$i]['id']]) : tep_get_topic_heading_title($tInfo->topics_id, $languages[$i]['id']))); ?></td>
 410            </tr>
 411  <?php
 412      }
 413  ?>
 414            <tr>
 415              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 416            </tr>
 417  <?php
 418      for ($i=0; $i<sizeof($languages); $i++) {
 419  ?>
 420            <tr>
 421              <td class="main" valign="top"><?php if ($i == 0) echo TEXT_EDIT_TOPICS_DESCRIPTION; ?></td>
 422              <td><table border="0" cellspacing="0" cellpadding="0">
 423                <tr>
 424                  <td class="main" valign="top"><?php if (ARTICLE_WYSIWYG_ENABLE == 'Enable') {
 425  // Line Changed - MOD: Ajustable Editor Window

 426                       echo tep_draw_fckeditor('topics_description[' . $languages[$i]['id'] . ']', HTML_AREA_WYSIWYG_EDITOR_WIDTH, HTML_AREA_WYSIWYG_EDITOR_HEIGHT, (isset($topics_description[$languages[$i]['id']]) ? $topics_description[$languages[$i]['id']] : tep_get_topic_description($tInfo->topics_id, $languages[$i]['id']))) . '</td>' ;
 427                 } else { echo tep_draw_textarea_field('topics_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($topics_description[$languages[$i]['id']]) ? $topics_description[$languages[$i]['id']] : tep_get_topic_description($tInfo->topics_id, $languages[$i]['id']))) . '</td>' ;
 428                }
 429                ?>
 430               </tr>
 431              </table></td>
 432            </tr>
 433  <?php
 434      }
 435  ?>
 436            <tr>
 437              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 438            </tr>
 439            <tr>
 440              <td class="main"><?php echo TEXT_EDIT_SORT_ORDER; ?></td>
 441              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('sort_order', $tInfo->sort_order, 'size="2"'); ?></td>
 442            </tr>
 443            <tr>
 444              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 445            </tr>
 446          </table></td>
 447        </tr>
 448        <tr>
 449          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 450        </tr>
 451        <tr>
 452          <td class="main" align="right"><?php echo tep_draw_hidden_field('topics_date_added', (($tInfo->date_added) ? $tInfo->date_added : date('Y-m-d'))) . tep_draw_hidden_field('parent_id', $tInfo->parent_id) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $HTTP_GET_VARS['tID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
 453        </form></tr>
 454  
 455  <?php
 456  
 457    //----- new_topic_preview -----

 458    } elseif ($HTTP_GET_VARS['action'] == 'new_topic_preview') {
 459      if ($HTTP_POST_VARS) {
 460        $tInfo = new objectInfo($HTTP_POST_VARS);
 461        $topics_name = $HTTP_POST_VARS['topics_name'];
 462        $topics_heading_title = $HTTP_POST_VARS['topics_heading_title'];
 463        $topics_description = $HTTP_POST_VARS['topics_description'];
 464      } else {
 465        $topic_query = tep_db_query("select t.topics_id, td.language_id, td.topics_name, td.topics_heading_title, td.topics_description, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.topics_id = td.topics_id and t.topics_id = '" . $HTTP_GET_VARS['tID'] . "'");
 466        $topic = tep_db_fetch_array($topic_query);
 467  
 468        $tInfo = new objectInfo($topic);
 469      }
 470  
 471      $form_action = ($HTTP_GET_VARS['tID']) ? 'update_topic' : 'insert_topic';
 472  
 473      echo tep_draw_form($form_action, FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $HTTP_GET_VARS['tID'] . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');
 474  
 475      $languages = tep_get_languages();
 476      for ($i=0; $i<sizeof($languages); $i++) {
 477        if ($HTTP_GET_VARS['read'] == 'only') {
 478          $tInfo->topics_name = tep_get_topic_name($tInfo->topics_id, $languages[$i]['id']);
 479          $tInfo->topics_heading_title = tep_get_topic_heading_title($tInfo->topics_id, $languages[$i]['id']);
 480          $tInfo->topics_description = tep_get_topic_description($tInfo->topics_id, $languages[$i]['id']);
 481        } else {
 482          $tInfo->topics_name = tep_db_prepare_input($topics_name[$languages[$i]['id']]);
 483          $tInfo->topics_heading_title = tep_db_prepare_input($topics_heading_title[$languages[$i]['id']]);
 484          $tInfo->topics_description = tep_db_prepare_input($topics_description[$languages[$i]['id']]);
 485        }
 486  ?>
 487        <tr>
 488          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 489            <tr>
 490              <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . $tInfo->topics_heading_title; ?></td>
 491            </tr>
 492          </table></td>
 493        </tr>
 494        <tr>
 495          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 496        </tr>
 497        <tr>
 498          <td class="main"><?php echo $tInfo->topics_description; ?></td>
 499        </tr>
 500  
 501  <?php
 502      }
 503      if ($HTTP_GET_VARS['read'] == 'only') {
 504        if ($HTTP_GET_VARS['origin']) {
 505          $pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);
 506          if ($pos_params != false) {
 507            $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);
 508            $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);
 509          } else {
 510            $back_url = $HTTP_GET_VARS['origin'];
 511            $back_url_params = '';
 512          }
 513        } else {
 514          $back_url = FILENAME_ARTICLES;
 515          $back_url_params = 'tPath=' . $tPath . '&tID=' . $tInfo->topics_id;
 516        }
 517  ?>
 518        <tr>
 519          <td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
 520        </tr>
 521  <?php
 522      } else {
 523  ?>
 524        <tr>
 525          <td align="right" class="smallText">
 526  <?php
 527  /* Re-Post all POST'ed variables */

 528        reset($HTTP_POST_VARS);
 529        while (list($key, $value) = each($HTTP_POST_VARS)) {
 530          if (!is_array($HTTP_POST_VARS[$key])) {
 531            echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
 532          }
 533        }
 534        $languages = tep_get_languages();
 535        for ($i=0; $i<sizeof($languages); $i++) {
 536          echo tep_draw_hidden_field('topics_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($topics_name[$languages[$i]['id']])));
 537          echo tep_draw_hidden_field('topics_heading_title[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($topics_heading_title[$languages[$i]['id']])));
 538          echo tep_draw_hidden_field('topics_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($topics_description[$languages[$i]['id']])));
 539        }
 540  
 541        echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . '&nbsp;&nbsp;';
 542  
 543        if ($HTTP_GET_VARS['tID']) {
 544          echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
 545        } else {
 546          echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
 547        }
 548        echo '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $HTTP_GET_VARS['tID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
 549  ?></td>
 550        </form></tr>
 551  <?php
 552      }
 553    } elseif ($action == 'new_article') {
 554      $parameters = array('articles_name' => '',
 555                         'articles_description' => '',
 556                         'articles_url' => '',
 557                         'articles_head_title_tag' => '',
 558                         'articles_head_desc_tag' => '',
 559                         'articles_head_keywords' => '',
 560                         'articles_id' => '',
 561                         'articles_date_added' => '',
 562                         'articles_last_modified' => '',
 563                         'articles_date_available' => '',
 564                         'articles_status' => '',
 565                         'authors_id' => '');
 566  
 567      $aInfo = new objectInfo($parameters);
 568  
 569      if (isset($HTTP_GET_VARS['aID']) && empty($HTTP_POST_VARS)) {
 570        $article_query = tep_db_query("select ad.articles_name, ad.articles_description, ad.articles_url, ad.articles_head_title_tag, ad.articles_head_desc_tag, ad.articles_head_keywords_tag, a.articles_id, a.articles_date_added, a.articles_last_modified, date_format(a.articles_date_available, '%Y-%m-%d') as articles_date_available, a.articles_status, a.authors_id from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = '" . (int)$HTTP_GET_VARS['aID'] . "' and a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "'");
 571        $article = tep_db_fetch_array($article_query);
 572  
 573        $aInfo->objectInfo($article);
 574      } elseif (tep_not_null($HTTP_POST_VARS)) {
 575        $aInfo->objectInfo($HTTP_POST_VARS);
 576        $articles_name = $HTTP_POST_VARS['articles_name'];
 577        $articles_description = $HTTP_POST_VARS['articles_description'];
 578        $articles_url = $HTTP_POST_VARS['articles_url'];
 579        $articles_head_title_tag = $HTTP_POST_VARS['articles_head_title_tag'];
 580        $articles_head_desc_tag = $HTTP_POST_VARS['articles_head_desc_tag'];
 581        $articles_head_keywords_tag = $HTTP_POST_VARS['articles_head_keywords_tag'];
 582      }
 583  
 584      $authors_array = array(array('id' => '', 'text' => TEXT_NONE));
 585      $authors_query = tep_db_query("select authors_id, authors_name from " . TABLE_AUTHORS . " order by authors_name");
 586      while ($authors = tep_db_fetch_array($authors_query)) {
 587        $authors_array[] = array('id' => $authors['authors_id'],
 588                                       'text' => $authors['authors_name']);
 589      }
 590  
 591      $languages = tep_get_languages();
 592  
 593      if (!isset($aInfo->articles_status)) $aInfo->articles_status = '1';
 594      switch ($aInfo->articles_status) {
 595        case '0': $in_status = false; $out_status = true; break;
 596        case '1':
 597        default: $in_status = true; $out_status = false;
 598      }
 599  ?>
 600  <link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
 601  <script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
 602  <script language="javascript">
 603  <!--
 604    var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_article", "articles_date_available","btnDate1","<?php echo $aInfo->articles_date_available; ?>",scBTNMODE_CUSTOMBLUE);
 605  -->
 606  </script>
 607      <?php echo tep_draw_form('new_article', FILENAME_ARTICLES, 'tPath=' . $tPath . (isset($HTTP_GET_VARS['aID']) ? '&aID=' . $HTTP_GET_VARS['aID'] : '') . '&action=article_preview', 'post', 'enctype="multipart/form-data"'); ?>
 608      <table border="0" width="100%" cellspacing="0" cellpadding="2">
 609        <tr>
 610          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 611            <tr>
 612              <td class="pageHeading"><?php echo sprintf(TEXT_NEW_ARTICLE, tep_output_generated_topic_path($current_topic_id)); ?></td>
 613              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 614            </tr>
 615          </table></td>
 616        </tr>
 617        <tr>
 618          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 619        </tr>
 620        <tr>
 621          <td><table border="0" cellspacing="0" cellpadding="2">
 622            <tr>
 623              <td class="main"><?php echo TEXT_ARTICLES_STATUS; ?></td>
 624              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_radio_field('articles_status', '0', $out_status) . '&nbsp;' . TEXT_ARTICLE_NOT_AVAILABLE . '&nbsp;' . tep_draw_radio_field('articles_status', '1', $in_status) . '&nbsp;' . TEXT_ARTICLE_AVAILABLE; ?></td>
 625            </tr>
 626            <tr>
 627              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 628            </tr>
 629            <tr>
 630              <td class="main"><?php echo TEXT_ARTICLES_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>
 631              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;'; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>
 632            </tr>
 633            <tr>
 634              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 635            </tr>
 636            <tr>
 637            <tr>
 638              <td class="main"><?php echo TEXT_ARTICLES_AUTHOR; ?></td>
 639              <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_pull_down_menu('authors_id', $authors_array, $aInfo->authors_id); ?></td>
 640            </tr>
 641            <tr>
 642              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 643            </tr>
 644  <?php
 645      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 646  ?>
 647            <tr>
 648              <td class="main"><?php if ($i == 0) echo TEXT_ARTICLES_NAME; ?></td>
 649              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('articles_name[' . $languages[$i]['id'] . ']', (isset($articles_name[$languages[$i]['id']]) ? $articles_name[$languages[$i]['id']] : tep_get_articles_name($aInfo->articles_id, $languages[$i]['id'])), 'size="35"'); ?></td>
 650            </tr>
 651  <?php
 652      }
 653  ?>
 654            <tr>
 655              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 656            </tr>
 657  <?php
 658      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 659  ?>
 660            <tr bgcolor="#ffffcc">
 661              <td class="main"><?php if ($i == 0) echo TEXT_ARTICLES_HEAD_TITLE_TAG; ?></td>
 662              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('articles_head_title_tag[' . $languages[$i]['id'] . ']', (isset($articles_head_title_tag[$languages[$i]['id']]) ? $articles_head_title_tag[$languages[$i]['id']] : tep_get_articles_head_title_tag($aInfo->articles_id, $languages[$i]['id'])), 'size="35"'); ?></td>
 663            </tr>
 664  <?php
 665      }
 666  ?>
 667            <tr bgcolor="#ffffcc">
 668              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 669            </tr>
 670  <?php
 671      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 672  ?>
 673            <tr bgcolor="#ffffcc">
 674              <td class="main" valign="top"><?php if ($i == 0) echo sprintf(TEXT_ARTICLES_HEAD_DESC_TAG, MAX_ARTICLE_ABSTRACT_LENGTH); ?></td>
 675              <td><table border="0" cellspacing="0" cellpadding="0">
 676                <tr>
 677                  <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
 678                  <td class="main"><?php echo tep_draw_textarea_field('articles_head_desc_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($articles_head_desc_tag[$languages[$i]['id']]) ? $articles_head_desc_tag[$languages[$i]['id']] : tep_get_articles_head_desc_tag($aInfo->articles_id, $languages[$i]['id']))); ?></td>
 679                </tr>
 680              </table></td>
 681            </tr>
 682  <?php
 683      }
 684  ?>
 685            <tr bgcolor="#ffffcc">
 686              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 687            </tr>
 688  <?php
 689      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 690  ?>
 691            <tr bgcolor="#ffffcc">
 692              <td class="main" valign="top"><?php if ($i == 0) echo TEXT_ARTICLES_HEAD_KEYWORDS_TAG; ?></td>
 693              <td><table border="0" cellspacing="0" cellpadding="0">
 694                <tr>
 695                  <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
 696                  <td class="main"><?php echo tep_draw_textarea_field('articles_head_keywords_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($articles_head_keywords_tag[$languages[$i]['id']]) ? $articles_head_keywords_tag[$languages[$i]['id']] : tep_get_articles_head_keywords_tag($aInfo->articles_id, $languages[$i]['id']))); ?></td>
 697                </tr>
 698              </table></td>
 699            </tr>
 700  <?php
 701      }
 702  ?>
 703            <tr>
 704              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 705            </tr>
 706  
 707  <?php
 708      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 709  ?>
 710            <tr>
 711              <td class="main" valign="top"><?php if ($i == 0) echo TEXT_ARTICLES_DESCRIPTION; ?></td>
 712              <td><table border="0" cellspacing="0" cellpadding="0">
 713                <tr>
 714                  <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
 715                  <td class="main"><?php if (ARTICLE_WYSIWYG_ENABLE == 'Enable') {
 716                       echo tep_draw_fckeditor('articles_description[' . $languages[$i]['id'] . ']', '550', '300', (isset($articles_description[$languages[$i]['id']]) ? $articles_description[$languages[$i]['id']] : tep_get_articles_description($aInfo->articles_id, $languages[$i]['id']))) . '</td>' ;
 717                 } else { echo tep_draw_textarea_field('articles_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($articles_description[$languages[$i]['id']]) ? $articles_description[$languages[$i]['id']] : tep_get_articles_description($aInfo->articles_id, $languages[$i]['id']))) . '</td>' ;
 718                }
 719                ?>
 720  
 721                </tr>
 722              </table></td>
 723            </tr>
 724  <?php
 725      }
 726  ?>
 727            <tr>
 728              <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 729            </tr>
 730  <?php
 731      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 732  ?>
 733            <tr>
 734              <td class="main"><?php if ($i == 0) echo TEXT_ARTICLES_URL . '<br><small>' . TEXT_ARTICLES_URL_WITHOUT_HTTP . '</small>'; ?></td>
 735              <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('articles_url[' . $languages[$i]['id'] . ']', (isset($articles_url[$languages[$i]['id']]) ? $articles_url[$languages[$i]['id']] : tep_get_articles_url($aInfo->articles_id, $languages[$i]['id'])), 'size="35"'); ?></td>
 736            </tr>
 737  <?php
 738      }
 739  ?>
 740          </table></td>
 741        </tr>
 742        <tr>
 743          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 744        </tr>
 745        <tr>
 746          <td class="main" align="right"><?php echo tep_draw_hidden_field('articles_date_added', (tep_not_null($aInfo->articles_date_added) ? $aInfo->articles_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . (isset($HTTP_GET_VARS['aID']) ? '&aID=' . $HTTP_GET_VARS['aID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
 747        </tr>
 748      </table></form>
 749  <?php
 750    //MaxiDVD Added WYSIWYG HTML Area Box + Admin Function v1.7 - 2.2 MS2 Articles Description HTML - </form>

 751    if (ARTICLE_WYSIWYG_ENABLE == 'Enable') {
 752  ?>
 753              <script language="JavaScript1.2" defer>
 754               var config = new Object();  // create new config object

 755               config.width = "<?php echo ARTICLE_MANAGER_WYSIWYG_WIDTH; ?>px";
 756               config.height = "<?php echo ARTICLE_MANAGER_WYSIWYG_HEIGHT; ?>px";
 757               config.bodyStyle = 'background-color: <?php echo ARTICLE_MANAGER_WYSIWYG_BG_COLOUR; ?>; font-family: "<?php echo ARTICLE_MANAGER_WYSIWYG_FONT_TYPE; ?>"; color: <?php echo ARTICLE_MANAGER_WYSIWYG_FONT_COLOUR; ?>; font-size: <?php echo ARTICLE_MANAGER_WYSIWYG_FONT_SIZE; ?>pt;';
 758               config.debug = <?php echo ARTICLE_MANAGER_WYSIWYG_DEBUG; ?>;
 759            <?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
 760               editor_generate('articles_description[<?php echo $languages[$i]['id']; ?>]',config);
 761            <?php } ?>
 762               config.height = "35px";
 763               config.bodyStyle = 'background-color: white; font-family: Arial; color: black; font-size: 12px;';
 764               config.toolbar = [ ['InsertImageURL'] ];
 765               config.OscImageRoot = '<?php trim(HTTP_SERVER . DIR_WS_CATALOG_IMAGES) ?>';
 766              </script>
 767  <?php
 768    }
 769    } elseif ($action == 'article_preview') {
 770      if (tep_not_null($HTTP_POST_VARS)) {
 771        $aInfo = new objectInfo($HTTP_POST_VARS);
 772        $articles_name = $HTTP_POST_VARS['articles_name'];
 773        $articles_description = $HTTP_POST_VARS['articles_description'];
 774        $articles_url = $HTTP_POST_VARS['articles_url'];
 775        $articles_head_title_tag = $HTTP_POST_VARS['articles_head_title_tag'];
 776        $articles_head_desc_tag = $HTTP_POST_VARS['articles_head_desc_tag'];
 777        $articles_head_keywords_tag = $HTTP_POST_VARS['articles_head_keywords_tag'];
 778      } else {
 779        $article_query = tep_db_query("select a.articles_id, ad.language_id, ad.articles_name, ad.articles_description, ad.articles_url, ad.articles_head_title_tag, ad.articles_head_desc_tag, ad.articles_head_keywords_tag, a.articles_date_added, a.articles_last_modified, a.articles_date_available, a.articles_status, a.authors_id  from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = ad.articles_id and a.articles_id = '" . (int)$HTTP_GET_VARS['aID'] . "'");
 780        $article = tep_db_fetch_array($article_query);
 781  
 782        $aInfo = new objectInfo($article);
 783      }
 784  
 785      $form_action = (isset($HTTP_GET_VARS['aID'])) ? 'update_article' : 'insert_article';
 786  
 787      echo tep_draw_form($form_action, FILENAME_ARTICLES, 'tPath=' . $tPath . (isset($HTTP_GET_VARS['aID']) ? '&aID=' . $HTTP_GET_VARS['aID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');
 788  
 789      $languages = tep_get_languages();
 790      for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 791        if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
 792          $aInfo->articles_name = tep_get_articles_name($aInfo->articles_id, $languages[$i]['id']);
 793          $aInfo->articles_description = tep_get_articles_description($aInfo->articles_id, $languages[$i]['id']);
 794          $aInfo->articles_url = tep_get_articles_url($aInfo->articles_id, $languages[$i]['id']);
 795          $aInfo->articles_head_title_tag = tep_get_articles_head_title_tag($aInfo->articles_id, $languages[$i]['id']);
 796          $aInfo->articles_head_desc_tag = tep_get_articles_head_desc_tag($aInfo->articles_id, $languages[$i]['id']);
 797          $aInfo->articles_head_keywords_tag = tep_get_articles_head_keywords_tag($aInfo->articles_id, $languages[$i]['id']);
 798        } else {
 799          $aInfo->articles_name = tep_db_prepare_input($articles_name[$languages[$i]['id']]);
 800          $aInfo->articles_description = tep_db_prepare_input($articles_description[$languages[$i]['id']]);
 801          $aInfo->articles_url = tep_db_prepare_input($articles_url[$languages[$i]['id']]);
 802          $aInfo->articles_head_title_tag = tep_db_prepare_input($articles_head_title_tag[$languages[$i]['id']]);
 803          $aInfo->articles_head_desc_tag = tep_db_prepare_input($articles_head_desc_tag[$languages[$i]['id']]);
 804          $aInfo->articles_head_keywords_tag = tep_db_prepare_input($articles_head_keywords_tag[$languages[$i]['id']]);
 805        }
 806  ?>
 807      <table border="0" width="100%" cellspacing="0" cellpadding="2">
 808        <tr>
 809          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 810            <tr>
 811              <td class="pageHeading" colspan="2"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . $aInfo->articles_name; ?></td>
 812            </tr>
 813          </table></td>
 814        </tr>
 815  <?php
 816        if ($aInfo->articles_description) {
 817  ?>
 818        <tr>
 819          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 820        </tr>
 821        <tr>
 822          <td class="main"><?php echo $aInfo->articles_description; ?></td>
 823        </tr>
 824  <?php
 825        }
 826  ?>
 827  <?php
 828        if ($aInfo->articles_url) {
 829  ?>
 830        <tr>
 831          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 832        </tr>
 833        <tr>
 834          <td class="main"><?php echo sprintf(TEXT_ARTICLE_MORE_INFORMATION, $aInfo->articles_url); ?></td>
 835        </tr>
 836  <?php
 837        }
 838  ?>
 839        <tr>
 840          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 841        </tr>
 842  <?php
 843        if ($aInfo->articles_date_available > date('Y-m-d')) {
 844  ?>
 845        <tr>
 846          <td align="center" class="smallText"><?php echo sprintf(TEXT_ARTICLE_DATE_AVAILABLE, tep_date_long($aInfo->articles_date_available)); ?></td>
 847        </tr>
 848  <?php
 849        } else {
 850  ?>
 851        <tr>
 852          <td align="center" class="smallText"><?php echo sprintf(TEXT_ARTICLE_DATE_ADDED, tep_date_long($aInfo->articles_date_added)); ?></td>
 853        </tr>
 854  <?php
 855        }
 856  ?>
 857        <tr>
 858          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
 859        </tr>
 860  <?php
 861      }
 862  
 863      if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {
 864        if (isset($HTTP_GET_VARS['origin'])) {
 865          $pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);
 866          if ($pos_params != false) {
 867            $back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);
 868            $back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);
 869          } else {
 870            $back_url = $HTTP_GET_VARS['origin'];
 871            $back_url_params = '';
 872          }
 873        } else {
 874          $back_url = FILENAME_ARTICLES;
 875          $back_url_params = 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id;
 876        }
 877  ?>
 878        <tr>
 879          <td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>
 880        </tr>
 881  <?php
 882      } else {
 883  ?>
 884        <tr>
 885          <td align="right" class="smallText">
 886  <?php
 887  /* Re-Post all POST'ed variables */

 888        reset($HTTP_POST_VARS);
 889        while (list($key, $value) = each($HTTP_POST_VARS)) {
 890          if (!is_array($HTTP_POST_VARS[$key])) {
 891            echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
 892          }
 893        }
 894        $languages = tep_get_languages();
 895        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 896          echo tep_draw_hidden_field('articles_name[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($articles_name[$languages[$i]['id']])));
 897          echo tep_draw_hidden_field('articles_description[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($articles_description[$languages[$i]['id']])));
 898          echo tep_draw_hidden_field('articles_url[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($articles_url[$languages[$i]['id']])));
 899          echo tep_draw_hidden_field('articles_head_title_tag[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($articles_head_title_tag[$languages[$i]['id']])));
 900          echo tep_draw_hidden_field('articles_head_desc_tag[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($articles_head_desc_tag[$languages[$i]['id']])));
 901          echo tep_draw_hidden_field('articles_head_keywords_tag[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($articles_head_keywords_tag[$languages[$i]['id']])));
 902        }
 903  
 904        echo tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . '&nbsp;&nbsp;';
 905  
 906        if (isset($HTTP_GET_VARS['aID'])) {
 907          echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
 908        } else {
 909          echo tep_image_submit('button_insert.gif', IMAGE_INSERT);
 910        }
 911        echo '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . (isset($HTTP_GET_VARS['aID']) ? '&aID=' . $HTTP_GET_VARS['aID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
 912  ?></td>
 913        </tr>
 914      </table></form>
 915  <?php
 916      }
 917    } else {
 918  ?>
 919      <table border="0" width="100%" cellspacing="0" cellpadding="2">
 920        <tr>
 921          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 922            <tr>
 923              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 924              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
 925              <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 926                <tr>
 927                  <td class="smallText" align="right">
 928  <?php
 929      echo tep_draw_form('search', FILENAME_ARTICLES, '', 'get');
 930      echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search');
 931      echo '</form>';
 932  ?>
 933                  </td>
 934                </tr>
 935                <tr>
 936                  <td class="smallText" align="right">
 937  <?php
 938      echo tep_draw_form('goto', FILENAME_ARTICLES, '', 'get');
 939      echo HEADING_TITLE_GOTO . ' ' . tep_draw_pull_down_menu('tPath', tep_get_topic_tree(), $current_topic_id, 'onChange="this.form.submit();"');
 940      echo '</form>';
 941  ?>
 942                  </td>
 943                </tr>
 944              </table></td>
 945            </tr>
 946          </table></td>
 947        </tr>
 948        <tr>
 949          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 950            <tr>
 951              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 952                <tr class="dataTableHeadingRow">
 953                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_TOPICS_ARTICLES; ?></td>
 954                  <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
 955                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 956                </tr>
 957  <?php
 958      $topics_count = 0;
 959      $rows = 0;
 960      if (isset($HTTP_GET_VARS['search'])) {
 961        $search = tep_db_prepare_input($HTTP_GET_VARS['search']);
 962  
 963        $topics_query = tep_db_query("select t.topics_id, td.topics_name, t.parent_id, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.topics_id = td.topics_id and td.language_id = '" . (int)$languages_id . "' and td.topics_name like '%" . tep_db_input($search) . "%' order by t.sort_order, td.topics_name");
 964      } else {
 965        $topics_query = tep_db_query("select t.topics_id, td.topics_name, t.parent_id, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.parent_id = '" . (int)$current_topic_id . "' and t.topics_id = td.topics_id and td.language_id = '" . (int)$languages_id . "' order by t.sort_order, td.topics_name");
 966      }
 967      while ($topics = tep_db_fetch_array($topics_query)) {
 968        $topics_count++;
 969        $rows++;
 970  
 971  // Get parent_id for subtopics if search

 972        if (isset($HTTP_GET_VARS['search'])) $tPath= $topics['parent_id'];
 973  
 974        if ((!isset($HTTP_GET_VARS['tID']) && !isset($HTTP_GET_VARS['aID']) || (isset($HTTP_GET_VARS['tID']) && ($HTTP_GET_VARS['tID'] == $topics['topics_id']))) && !isset($tInfo) && (substr($action, 0, 3) != 'new')) {
 975          $topic_childs = array('childs_count' => tep_childs_in_topic_count($topics['topics_id']));
 976          $topic_articles = array('articles_count' => tep_articles_in_topic_count($topics['topics_id']));
 977  
 978          $tInfo_array = array_merge($topics, $topic_childs, $topic_articles);
 979          $tInfo = new objectInfo($tInfo_array);
 980        }
 981  
 982        if (isset($tInfo) && is_object($tInfo) && ($topics['topics_id'] == $tInfo->topics_id) ) {
 983          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ARTICLES, tep_get_topic_path($topics['topics_id'])) . '\'">' . "\n";
 984        } else {
 985          echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $topics['topics_id']) . '\'">' . "\n";
 986        }
 987  ?>
 988                  <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ARTICLES, tep_get_topic_path($topics['topics_id'])) . '">' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a>&nbsp;<b>' . $topics['topics_name'] . '</b>'; ?></td>
 989                  <td class="dataTableContent" align="center">&nbsp;</td>
 990                  <td class="dataTableContent" align="right"><?php if (isset($tInfo) && is_object($tInfo) && ($topics['topics_id'] == $tInfo->topics_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $topics['topics_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 991                </tr>
 992  <?php
 993      }
 994  
 995      $articles_count = 0;
 996      if (isset($HTTP_GET_VARS['search'])) {
 997        $articles_query = tep_db_query("select a.articles_id, ad.articles_name, a.articles_date_added, a.articles_last_modified, a.articles_date_available, a.articles_status, a2t.topics_id from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_DESCRIPTION . " ad, " . TABLE_ARTICLES_TO_TOPICS . " a2t where a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and a.articles_id = a2t.articles_id and ad.articles_name like '%" . tep_db_input($search) . "%' order by ad.articles_name");
 998      } else {
 999        $articles_query = tep_db_query("select a.articles_id, ad.articles_name, a.articles_date_added, a.articles_last_modified, a.articles_date_available, a.articles_status from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_DESCRIPTION . " ad, " . TABLE_ARTICLES_TO_TOPICS . " a2t where a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and a.articles_id = a2t.articles_id and a2t.topics_id = '" . (int)$current_topic_id . "' order by ad.articles_name");
1000      }
1001      while ($articles = tep_db_fetch_array($articles_query)) {
1002        $articles_count++;
1003        $rows++;
1004  
1005  // Get topics_id for article if search

1006        if (isset($HTTP_GET_VARS['search'])) $tPath = $articles['topics_id'];
1007  
1008        if ( (!isset($HTTP_GET_VARS['aID']) && !isset($HTTP_GET_VARS['tID']) || (isset($HTTP_GET_VARS['aID']) && ($HTTP_GET_VARS['aID'] == $articles['articles_id']))) && !isset($aInfo) && !isset($tInfo) && (substr($action, 0, 3) != 'new')) {
1009  // find out the rating average from customer reviews

1010          $reviews_query = tep_db_query("select (avg(reviews_rating) / 5 * 100) as average_rating from " . TABLE_ARTICLE_REVIEWS . " where articles_id = '" . (int)$articles['articles_id'] . "'");
1011          $reviews = tep_db_fetch_array($reviews_query);
1012          $aInfo_array = array_merge($articles, $reviews);
1013          $aInfo = new objectInfo($aInfo_array);
1014        }
1015  
1016        if (isset($aInfo) && is_object($aInfo) && ($articles['articles_id'] == $aInfo->articles_id) ) {
1017          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $articles['articles_id'] . '&action=article_preview&read=only') . '\'">' . "\n";
1018        } else {
1019          echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $articles['articles_id']) . '\'">' . "\n";
1020        }
1021  ?>
1022                  <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $articles['articles_id'] . '&action=article_preview&read=only') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a>&nbsp;' . $articles['articles_name']; ?></td>
1023                  <td class="dataTableContent" align="center">
1024  <?php
1025        if ($articles['articles_status'] == '1') {
1026          echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_ARTICLES, 'action=setflag&flag=0&aID=' . $articles['articles_id'] . '&tPath=' . $tPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
1027        } else {
1028          echo '<a href="' . tep_href_link(FILENAME_ARTICLES, 'action=setflag&flag=1&aID=' . $articles['articles_id'] . '&tPath=' . $tPath) . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>&nbsp;&nbsp;' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
1029        }
1030  ?></td>
1031                  <td class="dataTableContent" align="right"><?php if (isset($aInfo) && is_object($aInfo) && ($articles['articles_id'] == $aInfo->articles_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $articles['articles_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
1032                </tr>
1033  <?php
1034      }
1035  
1036      $tPath_back = '';
1037      if (sizeof($tPath_array) > 0) {
1038        for ($i=0, $n=sizeof($tPath_array)-1; $i<$n; $i++) {
1039          if (empty($tPath_back)) {
1040            $tPath_back .= $tPath_array[$i];
1041          } else {
1042            $tPath_back .= '_' . $tPath_array[$i];
1043          }
1044        }
1045      }
1046  
1047      $tPath_back = (tep_not_null($tPath_back)) ? 'tPath=' . $tPath_back . '&' : '';
1048  ?>
1049                <tr>
1050                  <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
1051                    <tr>
1052                      <td class="smallText"><?php echo TEXT_TOPICS . '&nbsp;' . $topics_count . '<br>' . TEXT_ARTICLES . '&nbsp;' . $articles_count; ?></td>
1053                      <td align="right" class="smallText"><?php if (sizeof($tPath_array) > 0) echo '<a href="' . tep_href_link(FILENAME_ARTICLES, $tPath_back . 'tID=' . $current_topic_id) . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>&nbsp;'; if (!isset($HTTP_GET_VARS['search'])) echo '<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&action=new_topic') . '">' . tep_image_button('button_new_topic.gif', IMAGE_NEW_TOPIC) . '</a>&nbsp;<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&action=new_article') . '">' . tep_image_button('button_new_article.gif', IMAGE_NEW_ARTICLE) . '</a>'; ?>&nbsp;</td>
1054                    </tr>
1055                  </table></td>
1056                </tr>
1057              </table></td>
1058  <?php
1059      $heading = array();
1060      $contents = array();
1061      switch ($action) {
1062        case 'new_topic':
1063          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_TOPIC . '</b>');
1064  
1065          $contents = array('form' => tep_draw_form('newtopic', FILENAME_ARTICLES, 'action=insert_topic&tPath=' . $tPath, 'post', 'enctype="multipart/form-data"'));
1066          $contents[] = array('text' => TEXT_NEW_TOPIC_INTRO);
1067  
1068          $topic_inputs_string = '';
1069          $languages = tep_get_languages();
1070          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
1071            $topic_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('topics_name[' . $languages[$i]['id'] . ']');
1072          }
1073  
1074          $contents[] = array('text' => '<br>' . TEXT_TOPICS_NAME . $topic_inputs_string);
1075          $contents[] = array('text' => '<br>' . TEXT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', '', 'size="2"'));
1076          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1077          break;
1078        case 'edit_topic':
1079          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_TOPIC . '</b>');
1080  
1081          $contents = array('form' => tep_draw_form('topics', FILENAME_ARTICLES, 'action=update_topic&tPath=' . $tPath, 'post', 'enctype="multipart/form-data"') . tep_draw_hidden_field('topics_id', $tInfo->topics_id));
1082          $contents[] = array('text' => TEXT_EDIT_INTRO);
1083  
1084          $topic_inputs_string = '';
1085          $languages = tep_get_languages();
1086          for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
1087            $topic_inputs_string .= '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('topics_name[' . $languages[$i]['id'] . ']', tep_get_topic_name($tInfo->topics_id, $languages[$i]['id']));
1088          }
1089  
1090          $contents[] = array('text' => '<br>' . TEXT_EDIT_TOPICS_NAME . $topic_inputs_string);
1091          $contents[] = array('text' => '<br>' . TEXT_EDIT_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', $tInfo->sort_order, 'size="2"'));
1092          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $tInfo->topics_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1093          break;
1094        case 'delete_topic':
1095          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_TOPIC . '</b>');
1096  
1097          $contents = array('form' => tep_draw_form('topics', FILENAME_ARTICLES, 'action=delete_topic_confirm&tPath=' . $tPath) . tep_draw_hidden_field('topics_id', $tInfo->topics_id));
1098          $contents[] = array('text' => TEXT_DELETE_TOPIC_INTRO);
1099          $contents[] = array('text' => '<br><b>' . $tInfo->topics_name . '</b>');
1100          if ($tInfo->childs_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_CHILDS, $tInfo->childs_count));
1101          if ($tInfo->articles_count > 0) $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_ARTICLES, $tInfo->articles_count));
1102          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $tInfo->topics_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1103          break;
1104        case 'move_topic':
1105          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_MOVE_TOPIC . '</b>');
1106  
1107          $contents = array('form' => tep_draw_form('topics', FILENAME_ARTICLES, 'action=move_topic_confirm&tPath=' . $tPath) . tep_draw_hidden_field('topics_id', $tInfo->topics_id));
1108          $contents[] = array('text' => sprintf(TEXT_MOVE_TOPICS_INTRO, $tInfo->topics_name));
1109          $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $tInfo->topics_name) . '<br>' . tep_draw_pull_down_menu('move_to_topic_id', tep_get_topic_tree(), $current_topic_id));
1110          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $tInfo->topics_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1111          break;
1112        case 'delete_article':
1113          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_ARTICLE . '</b>');
1114  
1115          $contents = array('form' => tep_draw_form('articles', FILENAME_ARTICLES, 'action=delete_article_confirm&tPath=' . $tPath) . tep_draw_hidden_field('articles_id', $aInfo->articles_id));
1116          $contents[] = array('text' => TEXT_DELETE_ARTICLE_INTRO);
1117          $contents[] = array('text' => '<br><b>' . $aInfo->articles_name . '</b>');
1118  
1119          $article_topics_string = '';
1120          $article_topics = tep_generate_topic_path($aInfo->articles_id, 'article');
1121          for ($i = 0, $n = sizeof($article_topics); $i < $n; $i++) {
1122            $topic_path = '';
1123            for ($j = 0, $k = sizeof($article_topics[$i]); $j < $k; $j++) {
1124              $topic_path .= $article_topics[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
1125            }
1126            $topic_path = substr($topic_path, 0, -16);
1127            $article_topics_string .= tep_draw_checkbox_field('article_topics[]', $article_topics[$i][sizeof($article_topics[$i])-1]['id'], true) . '&nbsp;' . $topic_path . '<br>';
1128          }
1129          $article_topics_string = substr($article_topics_string, 0, -4);
1130  
1131          $contents[] = array('text' => '<br>' . $article_topics_string);
1132          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1133          break;
1134        case 'move_article':
1135          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_MOVE_ARTICLE . '</b>');
1136  
1137          $contents = array('form' => tep_draw_form('articles', FILENAME_ARTICLES, 'action=move_article_confirm&tPath=' . $tPath) . tep_draw_hidden_field('articles_id', $aInfo->articles_id));
1138          $contents[] = array('text' => sprintf(TEXT_MOVE_ARTICLES_INTRO, $aInfo->articles_name));
1139          $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_TOPICS . '<br><b>' . tep_output_generated_topic_path($aInfo->articles_id, 'article') . '</b>');
1140          $contents[] = array('text' => '<br>' . sprintf(TEXT_MOVE, $aInfo->articles_name) . '<br>' . tep_draw_pull_down_menu('move_to_topic_id', tep_get_topic_tree(), $current_topic_id));
1141          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_move.gif', IMAGE_MOVE) . ' <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1142          break;
1143        case 'copy_to':
1144          $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_COPY_TO . '</b>');
1145  
1146          $contents = array('form' => tep_draw_form('copy_to', FILENAME_ARTICLES, 'action=copy_to_confirm&tPath=' . $tPath) . tep_draw_hidden_field('articles_id', $aInfo->articles_id));
1147          $contents[] = array('text' => TEXT_INFO_COPY_TO_INTRO);
1148          $contents[] = array('text' => '<br>' . TEXT_INFO_CURRENT_TOPICS . '<br><b>' . tep_output_generated_topic_path($aInfo->articles_id, 'article') . '</b>');
1149          $contents[] = array('text' => '<br>' . TEXT_TOPICS . '<br>' . tep_draw_pull_down_menu('topics_id', tep_get_topic_tree(), $current_topic_id));
1150          $contents[] = array('text' => '<br>' . TEXT_HOW_TO_COPY . '<br>' . tep_draw_radio_field('copy_as', 'link', true) . ' ' . TEXT_COPY_AS_LINK . '<br>' . tep_draw_radio_field('copy_as', 'duplicate') . ' ' . TEXT_COPY_AS_DUPLICATE);
1151          $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_copy.gif', IMAGE_COPY) . ' <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
1152          break;
1153  
1154        default:
1155          if ($rows > 0) {
1156            if (isset($tInfo) && is_object($tInfo)) { // topic info box contents
1157              $heading[] = array('text' => '<b>' . $tInfo->topics_name . '</b>');
1158  
1159              $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $tInfo->topics_id . '&action=edit_topic') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $tInfo->topics_id . '&action=delete_topic') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&tID=' . $tInfo->topics_id . '&action=move_topic') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a>');
1160              $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($tInfo->date_added));
1161              if (tep_not_null($tInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($tInfo->last_modified));
1162              $contents[] = array('text' => '<br>' . TEXT_SUBTOPICS . ' ' . $tInfo->childs_count . '<br>' . TEXT_ARTICLES . ' ' . $tInfo->articles_count);
1163            } elseif (isset($aInfo) && is_object($aInfo)) { // article info box contents
1164              $heading[] = array('text' => '<b>' . tep_get_articles_name($aInfo->articles_id, $languages_id) . '</b>');
1165  
1166              $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id . '&action=new_article') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id . '&action=delete_article') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id . '&action=move_article') . '">' . tep_image_button('button_move.gif', IMAGE_MOVE) . '</a> <a href="' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&aID=' . $aInfo->articles_id . '&action=copy_to') . '">' . tep_image_button('button_copy_to.gif', IMAGE_COPY_TO) . '</a>');            $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . tep_date_short($aInfo->articles_date_added));
1167              if (tep_not_null($aInfo->articles_last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . tep_date_short($aInfo->articles_last_modified));
1168              if (date('Y-m-d') < $aInfo->articles_date_available) $contents[] = array('text' => TEXT_DATE_AVAILABLE . ' ' . tep_date_short($aInfo->articles_date_available));
1169              $contents[] = array('text' => '<br>' . TEXT_ARTICLES_AVERAGE_RATING . ' ' . number_format($aInfo->average_rating, 2) . '%');
1170            }
1171          } else { // create topic/article info
1172            $heading[] = array('text' => '<b>' . EMPTY_TOPIC . '</b>');
1173  
1174            $contents[] = array('text' => TEXT_NO_CHILD_TOPICS_OR_ARTICLES);
1175          }
1176          break;
1177      }
1178  
1179      if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
1180        echo '            <td width="25%" valign="top">' . "\n";
1181  
1182        $box = new box;
1183        echo $box->infoBox($heading, $contents);
1184  
1185        echo '            </td>' . "\n";
1186      }
1187  ?>
1188            </tr>
1189          </table></td>
1190        </tr>
1191      </table>
1192  <?php
1193    }
1194  ?>
1195      </td>
1196  <!-- body_text_eof //-->
1197    </tr>
1198  </table>
1199  <!-- body_eof //-->
1200  
1201  <!-- footer //-->
1202  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
1203  <!-- footer_eof //-->
1204  <br>
1205  </body>
1206  </html>
1207  <?php require (DIR_WS_INCLUDES . 'application_bottom.php');
1208  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7