public function ShowAuto($id, array $options = array())
 {
     $default_options = array("show_photo" => 1, "show_edit" => 1);
     $options = array_merge($default_options, $options);
     if ($this->use_country) {
         $set_array["{country}"] = $this->autos[$id]['country_name'];
         $this->tpl->SetBlock('country');
     }
     if ($this->use_region) {
         $set_array["{region}"] = $this->autos[$id]['region_name'];
         $this->tpl->SetBlock('region');
     }
     if ($this->autos[$id]['city_other']) {
         $set_array["{city}"] = $this->autos[$id]['city_other'];
     } else {
         $set_array["{city}"] = $this->autos[$id]['city_name'];
     }
     $set_array["{mark}"] = $this->autos[$id]['mark_name'];
     if ($this->autos[$id]['model_other']) {
         $set_array["{model}"] = $this->autos[$id]['model_other'];
     } else {
         $set_array["{model}"] = $this->autos[$id]['model_name'];
     }
     foreach ($this->sel_fields as $name => $value) {
         if ($this->autos[$id][$name]) {
             $set_array['{' . $name . '}'] = $value['values'][$this->autos[$id][$name]];
             $this->tpl->SetBlock($name);
         } else {
             $set_array['{' . $name . '}'] = $this->lang['spacer'];
         }
     }
     foreach ($this->checkbox_fields as $name => $value) {
         if ($this->autos[$id][$name]) {
             $set_array['{' . $name . '}'] = $this->lang['field_isset'];
             $this->tpl->SetBlock($name);
         } else {
             $set_array['{' . $name . '}'] = $this->lang['field_not_isset'];
         }
     }
     if ($this->autos[$id]['color']) {
         $set_array["{color}"] = $this->autos[$id]['color'];
         $this->tpl->SetBlock('color');
     }
     $set_array["{race}"] = $this->autos[$id]['race'];
     if ($this->autos[$id]['race']) {
         $this->tpl->SetBlock('race');
     }
     $fields = array("power", "capacity_motor", "contact_person", "phone", "year", "description", "photo_count");
     foreach ($fields as $field) {
         if ($this->autos[$id][$field]) {
             $set_array["{" . $field . "}"] = $this->autos[$id][$field];
             $this->tpl->SetBlock($field);
         } else {
             $set_array["{" . $field . "}"] = $this->lang['spacer'];
         }
     }
     if (!$this->autos[$id]['cost']) {
         $set_array["{cost}"] = $this->lang['cost_dog'];
     } else {
         $set_array["{cost}"] = auto_num_format($this->autos[$id]['cost']) . " " . $this->lang[$this->autos[$id]['currency']];
         if ($this->search_array['currency_defalut'] && $this->search_array['currency_defalut'] != $this->autos[$id]['currency']) {
             $set_array["{cost}"] .= " (" . auto_num_format($this->autos[$id]['cost_search'] * $this->config['currency'][$this->search_array['currency_defalut']]) . " " . $this->lang[$this->search_array['currency_defalut']] . ")";
         }
         if ($this->autos[$id]['auction']) {
             $this->tpl->SetBlock('auction');
         }
     }
     if ($this->autos[$id]['exchange']) {
         $this->tpl->SetBlock('exchange');
     }
     $onclick = "OnClick=\"favorites(this, {$id});return false;\"";
     if (!empty($_COOKIE['auto_favorites']) && preg_match("#(^|\\D){$id}(\\D|\$)#i", $_COOKIE['auto_favorites'])) {
         $set_array['{favorites}'] = "<img {$onclick} class=\"favorites\" src=\"{THEME}/car-market/images/minus.gif\" title=\"{$this->lang['favorites_title']}\" />";
     } else {
         $set_array['{favorites}'] = "<img {$onclick} class=\"favorites\" src=\"{THEME}/car-market/images/plus.gif\" title=\"{$this->lang['favorites_title']}\" />";
     }
     $set_array["{view_count}"] = $this->autos[$id]['view_count'];
     $set_array["{add_date}"] = $this->DateFormat($this->autos[$id]['add_date']);
     $set_array["{id}"] = $id;
     $set_array["{author}"] = $this->autos[$id]['author'];
     $set_array["{cars_of_author}"] = $this->tpl->GetUrl(array('author' => urlencode($this->autos[$id]['author'])), array(), array(), array(), array("use_alt_url" => false, "clear" => 1));
     $set_array["{auto_url}"] = $this->tpl->GetUrl(array("action" => 'auto', "id" => $id));
     $set_array['{checkbox}'] = $this->tpl->InputCheckbox('selected_auto[]', $id);
     $set_array['{compare}'] = "<img src=\"{THEME}/car-market/images/compare_unchecked.gif\" class=\"compare\" id=\"{$id}\" title=\"{$this->lang['compare_title']}\" />";
     $set_array['{send_mail}'] = "<a href=\"{$set_array['{auto_url}']}\" title=\"{$this->lang['mail_title']}\" class=\"mail_friend\" ><img src=\"{THEME}/car-market/images/mail.gif\" /></a>";
     $set_array['[print]'] = "<a target=\"_blank\" class=\"print-link\" href=\"" . $this->GetPrintUrl($id) . "\" title=\"{$this->lang['print_auto']}\" >";
     $set_array['[/print]'] = "</a>";
     if ($this->config['general_mod_rewrite']) {
         $set_array["{author_url}"] = $GLOBALS['config']['http_home_url'] . "/user/" . urlencode($this->autos[$id]['author']) . "/";
     } else {
         $set_array["{author_url}"] = $GLOBALS['PHP_SELF'] . "?subaction=userinfo&user="******"/";
     }
     if ($this->autos[$id]['email']) {
         $set_array['[email]'] = "<a href=\"{$set_array['{auto_url}']}\" title=\"{$this->lang['auto_email_author']}\" OnClick=\"auto_email_send('{$id}');return false;\" >";
         $set_array['[/email]'] = "</a>";
     }
     if ($this->autos[$id]['photo']) {
         $set_array["{isset_photo}"] = $this->lang['isset_photo'];
     }
     if ($options['show_photo'] && !empty($this->autos[$id]['photos'][0]['id'])) {
         $this->tpl->SetBlock('exist_photo');
         $this->tpl->OpenRow('row_photo');
         $i = 1;
         foreach ($this->autos[$id]['photos'] as $photo) {
             if (file_exists(UPLOAD_DIR . $photo['model_id'] . "/" . $photo['image_name'])) {
                 $photo_one = "<img src=\"" . UPLOAD_URL . $photo['model_id'] . "/thumbs/{$photo['image_name']}\" alt=\"{$this->autos[$id]['mark_name']} {$this->autos[$id]['model_name']} photo {$i}\" >";
                 $set_array["{photo_{$i}}"] = "<a class=\"go_big_photo\" href=\"" . UPLOAD_URL . $photo['model_id'] . "/{$photo['image_name']}\" title=\"{$this->autos[$id]['mark_name']} {$this->autos[$id]['model_name']}\" >" . $photo_one . "</a>";
                 $this->tpl->SetRow(array("{photo}" => "<a class=\"lightbox\" href=\"" . UPLOAD_URL . $photo['model_id'] . "/{$photo['image_name']}\" >" . $photo_one . "</a>"), 'row_photo');
                 if ($photo['id'] == $this->autos[$id]['photo']) {
                     $set_array["{big_photo}"] = "<span id=\"big_photo\"><img src=\"" . UPLOAD_URL . $photo['model_id'] . "/{$photo['image_name']}\" alt=\"{$this->autos[$id]['mark_name']} {$this->autos[$id]['model_name']} photo {$i}\" ></span>";
                     $set_array["{photo}"] = "<a class=\"go_big_photo\" href=\"" . UPLOAD_URL . $photo['model_id'] . "/{$photo['image_name']}\" title=\"{$this->autos[$id]['mark_name']} {$this->autos[$id]['model_name']}\" >" . $photo_one . "</a>";
                 }
                 $i++;
             }
         }
         $this->tpl->CloseRow('row_photo');
     } elseif (empty($this->autos[$id]['photos'][0]['id'])) {
         $set_array["{photo}"] = "<img src=\"{THEME}/car-market/images/no_photo.jpg\" alt=\"{$this->autos[$id]['mark_name']} {$this->autos[$id]['model_name']}\" >";
     }
     if (MODER) {
         if (!$this->autos[$id]['allow_site'] && ($this->autos[$id]['exp_date'] > $this->base->timer->cur_time || !$this->autos[$id]['exp_date'])) {
             $set_array['{moder_class}'] = 'moder_new_auto id' . $id;
         } elseif (!$this->autos[$id]['allow_site'] && $this->autos[$id]['exp_date'] < $this->base->timer->cur_time) {
             $set_array['{moder_class}'] = 'moder_old_auto id' . $id;
         } else {
             $set_array['{moder_class}'] = 'id' . $id;
         }
     } else {
         $set_array['{moder_class}'] = 'id' . $id;
     }
     if ($options['show_edit']) {
         if (MODER) {
             $this->tpl->SetBlock('moder')->SetBlock('allow_del');
             $set_array["[edit]"] = "<a id=\"link_admin-{$id}\" onClick=\"dropdownmenu(this, event, ShowMenu('{$id}', '" . ($this->autos[$id]['allow_site'] ? 0 : 1) . "'), '170px');return false;\" target=\"_blank\" href=\"" . $GLOBALS['config']['http_home_url'] . "?do=" . $this->config['general_name_module'] . "&action=edit&id={$id}\">";
             $set_array["[/edit]"] = "</a>";
             $info = '';
             if ($this->autos[$id]['exp_date']) {
                 $info .= $this->lang['exp_date_site_admin'] . " " . date("d.m.Y H:i", $this->autos[$id]['exp_date']) . ";";
             }
             if ($this->autos[$id]['allow_block']) {
                 if ($this->autos[$id]['block_date']) {
                     $info .= " " . $this->lang['block_date_site_admin'] . " " . date("d.m.Y H:i", $this->autos[$id]['block_date']);
                 } else {
                     $info .= " " . $this->lang['block_date_site_admin'] . " " . $this->lang['block_date_unlim'];
                 }
             }
             if ($info) {
                 $set_array["{info}"] = $info;
             }
         } else {
             if (in_array($this->member['group'], $this->config['user_int_allow_edit']) && ($this->member['id'] && $this->member['id'] == $this->autos[$id]['author_id'] || $this->guest_session && $this->guest_session == $this->autos[$id]['guest_session'])) {
                 $set_array["[edit]"] = "<a target=\"_blank\" id=\"link_admin-{$id}\" href=\"" . $GLOBALS['config']['http_home_url'] . "?do=" . $this->config['general_name_module'] . "&action=edit&id={$id}\">";
                 $set_array["[/edit]"] = "</a>";
             }
             if (in_array($this->member['group'], $this->config['user_int_allow_del']) && ($this->member['id'] && $this->member['id'] == $this->autos[$id]['author_id'] || $this->guest_session && $this->guest_session == $this->autos[$id]['guest_session'])) {
                 $this->tpl->SetBlock('allow_del');
             }
         }
     }
     $set_array['{xfields}'] = '';
     foreach ($this->xfields->showFields($this->autos[$id]['xfields']) as $fid => $field) {
         if ($field['value']) {
             $set_array["{xfield_{$fid}_title}"] = $field['title'];
             $set_array["{xfield_{$fid}_descr}"] = $field['description'];
             $set_array["{xfield_{$fid}_value}"] = $field['value'];
             $set_array['{xfields}'] .= $field['title'] . ": " . $field['value'] . "<br />";
             $this->tpl->SetBlock('xfield_' . $fid);
         }
     }
     if ($this->autos[$id]['allow_site']) {
         $set_array['{status}'] = $this->lang['status_on_site'];
     } elseif (!$this->autos[$id]['exp_date'] || $this->autos[$id]['exp_date'] > $this->base->timer->cur_time) {
         $set_array['{status}'] = $this->lang['status_on_moder'];
     } else {
         $set_array['{status}'] = $this->lang['status_old'];
     }
     return $set_array;
 }
Beispiel #2
0
$tpl->CloseTable();
$tpl->OpenTable();
$tpl->OpenSubtable($auto->lang['edit_auto']);
$tpl->OpenForm('', $hidden_array, 'name="form_auto"');
$tpl->echo = FALSE;
echo $tpl->OTable(array("ID", $auto->lang['model'], $auto->lang['city'], $auto->lang['cost'], $auto->lang['auto_contact_person'], $auto->lang['exp_date'], $auto->lang['block_date'], $auto->lang['add_date'], $auto->lang['author'], $tpl->InputCheckbox("master", 1, 0, 'id="master"')), 'id="autos" class="tablesorter"');
if ($auto->autos) {
    $color = '';
    $i = $start;
    foreach ($auto->autos as $auto_one) {
        if (!$auto_one['allow_site']) {
            $color = ' style="color:red"';
        } else {
            $color = '';
        }
        echo $tpl->row(array("<a{$color} href=\"{$PHP_SELF}auto&subaction=edit&id={$auto_one['id']}\"{$color} title=\"{$auto->lang['auto_edit']}\" >{$auto_one['id']} </a>", "<a{$color} href=\"{$PHP_SELF}auto&subaction=edit&id={$auto_one['id']}\"{$color} title=\"{$auto->lang['auto_edit']}\" >{$auto_one['mark_name']} {$auto_one['model_name']} </a>", $auto_one['city_name'], auto_num_format($auto_one['cost']) . " " . $auto->lang[$auto_one['currency']], $auto_one['contact_person'], $auto_one['exp_date'] ? date("d-m-Y H:i", $auto_one['exp_date']) : '&#8212;', $auto_one['block_date'] ? date("d-m-Y H:i", $auto_one['block_date']) : '&#8212;', date("d-m-Y H:i", $auto_one['add_date']), $auto_one['author'], $tpl->InputCheckbox("selected_auto[{$auto_one[id]}]", 1, 0, 'style="display:none"')), false);
        $i++;
    }
    $where_url = array();
    foreach ($where as $field => $value) {
        $where_url["where[{$field}]"] = $value;
    }
    $nav = $tpl->navigation($_REQUEST['page'], $per_page, $auto->autos_count, $tpl->url($where_url, $PHP_SELF . "edit&"));
    $table = $tpl->OTable();
    $table .= $tpl->row(array('align="left"' => $nav, 'align="right"' => $tpl->selection($subaction_array, 'subaction') . " " . $tpl->InputSubmit($auto->lang['btn_submit'])), false);
    $table .= $tpl->CTable();
    echo $tpl->row($table, false, true);
} else {
    echo $tpl->row($auto->lang['no_auto'], true, true);
}
$tpl->echo = TRUE;