Example #1
0
        cot_log("Wrong validation URL", 'sec');
        cot_redirect(cot_url('message', 'msg=157', '', true));
    }
}
$mskin = cot_tplfile('users.register', 'module');
/* === Hook === */
foreach (cot_getextplugins('users.register.main') as $pl) {
    include $pl;
}
/* ===== */
$out['subtitle'] = $L['aut_registertitle'];
$out['head'] .= $R['code_noindex'];
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
require_once cot_incfile('forms');
$t->assign(array('USERS_REGISTER_TITLE' => $L['aut_registertitle'], 'USERS_REGISTER_SUBTITLE' => $L['aut_registersubtitle'], 'USERS_REGISTER_ADMINEMAIL' => $cot_adminemail, 'USERS_REGISTER_SEND' => cot_url('users', 'm=register&a=add'), 'USERS_REGISTER_USER' => cot_inputbox('text', 'rusername', $ruser['user_name'], array('size' => 24, 'maxlength' => 100)), 'USERS_REGISTER_EMAIL' => cot_inputbox('text', 'ruseremail', $ruser['user_email'], array('size' => 24, 'maxlength' => 64)), 'USERS_REGISTER_PASSWORD' => cot_inputbox('password', 'rpassword1', '', array('size' => 12, 'maxlength' => 32)), 'USERS_REGISTER_PASSWORDREPEAT' => cot_inputbox('password', 'rpassword2', '', array('size' => 12, 'maxlength' => 32)), 'USERS_REGISTER_COUNTRY' => cot_selectbox_countries($ruser['user_country'], 'rcountry'), 'USERS_REGISTER_TIMEZONE' => cot_selectbox_timezone($ruser['user_timezone'], 'rusertimezone'), 'USERS_REGISTER_GENDER' => cot_selectbox_gender($ruser['user_gender'], 'rusergender'), 'USERS_REGISTER_BIRTHDATE' => cot_selectbox_date(0, 'short', 'ruserbirthdate', cot_date('Y', $sys['now']), cot_date('Y', $sys['now']) - 100, false)));
// Extra fields
if (!empty(cot::$extrafields[cot::$db->users])) {
    foreach (cot::$extrafields[cot::$db->users] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $exfld_val = cot_build_extrafields('ruser' . $exfld['field_name'], $exfld, $ruser['user_' . $exfld['field_name']]);
        $exfld_title = cot_extrafield_title($exfld, 'user_');
        $t->assign(array('USERS_REGISTER_' . $uname => $exfld_val, 'USERS_REGISTER_' . $uname . '_TITLE' => $exfld_title, 'USERS_REGISTER_EXTRAFLD' => $exfld_val, 'USERS_REGISTER_EXTRAFLD_TITLE' => $exfld_title));
        $t->parse('MAIN.EXTRAFLD');
    }
}
/* === Hook === */
foreach (cot_getextplugins('users.register.tags') as $pl) {
    include $pl;
}
/* ===== */
Example #2
0
if (empty($rpage['page_cat']) && !empty($c)) {
    $rpage['page_cat'] = $c;
    $usr['isadmin'] = cot_auth('page', $rpage['page_cat'], 'A');
}
$out['subtitle'] = $L['page_addsubtitle'];
$out['head'] .= $R['code_noindex'];
$sys['sublocation'] = $structure['page'][$c]['title'];
$mskin = cot_tplfile(array('page', 'add', $structure['page'][$rpage['page_cat']]['tpl']));
/* === Hook === */
foreach (cot_getextplugins('page.add.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
$pageadd_array = array('PAGEADD_PAGETITLE' => $L['page_addtitle'], 'PAGEADD_SUBTITLE' => $L['page_addsubtitle'], 'PAGEADD_ADMINEMAIL' => "mailto:" . $cfg['adminemail'], 'PAGEADD_FORM_SEND' => cot_url('page', 'm=add&a=add&c=' . $c), 'PAGEADD_FORM_CAT' => cot_selectbox_structure('page', $rpage['page_cat'], 'rpagecat'), 'PAGEADD_FORM_CAT_SHORT' => cot_selectbox_structure('page', $rpage['page_cat'], 'rpagecat', $c), 'PAGEADD_FORM_KEYWORDS' => cot_inputbox('text', 'rpagekeywords', $rpage['page_keywords'], array('size' => '32', 'maxlength' => '255')), 'PAGEADD_FORM_METATITLE' => cot_inputbox('text', 'rpagemetatitle', $rpage['page_metatitle'], array('size' => '64', 'maxlength' => '255')), 'PAGEADD_FORM_METADESC' => cot_textarea('rpagemetadesc', $rpage['page_metadesc'], 2, 64, array('maxlength' => '255')), 'PAGEADD_FORM_ALIAS' => cot_inputbox('text', 'rpagealias', $rpage['page_alias'], array('size' => '32', 'maxlength' => '255')), 'PAGEADD_FORM_TITLE' => cot_inputbox('text', 'rpagetitle', $rpage['page_title'], array('size' => '64', 'maxlength' => '255')), 'PAGEADD_FORM_DESC' => cot_textarea('rpagedesc', $rpage['page_desc'], 2, 64, array('maxlength' => '255')), 'PAGEADD_FORM_AUTHOR' => cot_inputbox('text', 'rpageauthor', $rpage['page_author'], array('size' => '24', 'maxlength' => '100')), 'PAGEADD_FORM_OWNER' => cot_build_user($usr['id'], htmlspecialchars($usr['name'])), 'PAGEADD_FORM_OWNERID' => $usr['id'], 'PAGEADD_FORM_DATE' => cot_selectbox_date($sys['now'], 'long', 'rpagedate'), 'PAGEADD_FORM_BEGIN' => cot_selectbox_date($sys['now'], 'long', 'rpagebegin'), 'PAGEADD_FORM_EXPIRE' => cot_selectbox_date(0, 'long', 'rpageexpire'), 'PAGEADD_FORM_FILE' => cot_selectbox($rpage['page_file'], 'rpagefile', range(0, 2), array($L['No'], $L['Yes'], $L['Members_only']), false), 'PAGEADD_FORM_URL' => cot_inputbox('text', 'rpageurl', $rpage['page_url'], array('size' => '56', 'maxlength' => '255')), 'PAGEADD_FORM_SIZE' => cot_inputbox('text', 'rpagesize', $rpage['page_size'], array('size' => '56', 'maxlength' => '255')), 'PAGEADD_FORM_TEXT' => cot_textarea('rpagetext', $rpage['page_text'], 24, 120, '', 'input_textarea_editor'), 'PAGEADD_FORM_PARSER' => cot_selectbox($cfg['page']['parser'], 'rpageparser', $parser_list, $parser_list, false));
$t->assign($pageadd_array);
// Extra fields
foreach ($cot_extrafields[$db_pages] as $exfld) {
    $uname = strtoupper($exfld['field_name']);
    $exfld_val = cot_build_extrafields('rpage' . $exfld['field_name'], $exfld, $rpage['page_' . $exfld['field_name']]);
    $exfld_title = isset($L['page_' . $exfld['field_name'] . '_title']) ? $L['page_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
    $t->assign(array('PAGEADD_FORM_' . $uname => $exfld_val, 'PAGEADD_FORM_' . $uname . '_TITLE' => $exfld_title, 'PAGEADD_FORM_EXTRAFLD' => $exfld_val, 'PAGEADD_FORM_EXTRAFLD_TITLE' => $exfld_title));
    $t->parse('MAIN.EXTRAFLD');
}
// Error and message handling
cot_display_messages($t);
/* === Hook === */
foreach (cot_getextplugins('page.add.tags') as $pl) {
    include $pl;
}
Example #3
0
    }
    if (!cot_error_found()) {
        $t->parse('MAIN.RESULTS');
    }
    $rs_url_path = array();
    foreach ($rs as $k => $v) {
        if (is_array($v)) {
            foreach ($v as $sk => $sv) {
                $rs_url_path['rs[' . $k . '][' . $sk . ']'] = $sv;
            }
        } else {
            $rs_url_path['rs[' . $k . ']'] = $v;
        }
    }
    $pagenav = cot_pagenav('plug', array('e' => 'search', 'sq' => $sq, 'tab' => $tab) + $rs_url_path, $d, array_sum($totalitems), $cfg_maxitems);
}
// Search title
$crumbs = array(array(cot_url('plug', 'e=search'), $L['plu_search']));
if (!empty($tab)) {
    $crumbs[] = array(cot_url('plug', 'e=search&tab=' . $tab), $L['plu_tabs_' . $tab]);
}
$out['head'] .= $R['code_noindex'];
$search_subtitle = empty($tab) ? $L['plu_search'] : $L['plu_tabs_' . $tab] . ' - ' . $L['plu_search'];
$out['subtitle'] = empty($sq) ? $search_subtitle : htmlspecialchars(strip_tags($sq)) . ' - ' . $L['plu_result'];
$t->assign(array('PLUGIN_TITLE' => cot_breadcrumbs($crumbs, $cfg['breadcrumb'], true), 'PLUGIN_SEARCH_ACTION' => cot_url('plug', 'e=search&tab=' . $tab), 'PLUGIN_SEARCH_TEXT' => cot_inputbox('text', 'sq', htmlspecialchars($sq), 'size="32" maxlength="' . $cfg['plugin']['search']['maxsigns'] . '"'), 'PLUGIN_SEARCH_USER' => cot_inputbox('text', 'rs[setuser]', htmlspecialchars($rs['setuser']), 'class="userinput" size="32"'), 'PLUGIN_SEARCH_DATE_SELECT' => cot_selectbox($rs['setlimit'], 'rs[setlimit]', range(0, 5), array($L['plu_any_date'], $L['plu_last_2_weeks'], $L['plu_last_1_month'], $L['plu_last_3_month'], $L['plu_last_1_year'], $L['plu_need_datas']), false), 'PLUGIN_SEARCH_DATE_FROM' => cot_selectbox_date($rs['setfrom'], 'short', 'rfrom', cot_date('Y', $sys['now']) + 1), 'PLUGIN_SEARCH_DATE_TO' => cot_selectbox_date($rs['setto'], 'short', 'rto', cot_date('Y', $sys['now']) + 1), 'PLUGIN_SEARCH_FOUND' => array_sum($totalitems) > 0 ? array_sum($totalitems) : '', 'PLUGIN_PAGEPREV' => $pagenav['prev'], 'PLUGIN_PAGENEXT' => $pagenav['next'], 'PLUGIN_PAGENAV' => $pagenav['main']));
cot_display_messages($t);
/* === Hook === */
foreach (cot_getextplugins('search.tags') as $pl) {
    include $pl;
}
/* ===== */
Example #4
0
 /**
  * Редактирование рассылки
  * @return string
  * @throws Exception
  */
 public function editAction()
 {
     global $cot_extrafields, $admintitle, $adminpath;
     $id = cot_import('id', 'G', 'INT');
     // id Рассылки
     $act = cot_import('act', 'G', 'ALP');
     if (empty($act)) {
         $act = cot_import('act', 'P', 'ALP');
     }
     $adminpath[] = array(cot_url('admin', array('m' => 'subscribe')), cot::$L['subscribe_subscribes']);
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.admin.edit.first') as $pl) {
         include $pl;
     }
     /* ===== */
     if (!$id) {
         $item = new subscribe_model_Subscribe();
         $admintitle = cot::$L['subscribe_add_new'];
         $adminpath[] = array(cot_url('admin', array('m' => 'subscribe', 'a' => 'edit')), $admintitle);
     } else {
         $item = subscribe_model_Subscribe::getById($id);
         if (!$item) {
             cot_error(cot::$L['subscribe_err_not_found']);
             cot_redirect(cot_url('admin', array('m' => 'subscribe'), '', true));
         }
         if ($act == 'clone') {
             $id = null;
             $item = clone $item;
             $admintitle = cot::$L['subscribe_add_new'];
             $adminpath[] = array(cot_url('admin', array('m' => 'subscribe', 'a' => 'edit')), $admintitle);
         } else {
             $admintitle = $item->title . " [" . cot::$L['Edit'] . "]";
             $adminpath[] = array(cot_url('admin', array('m' => 'subscribe', 'a' => 'edit', 'id' => $item->id)), $admintitle);
         }
     }
     // Сохранение
     if ($act == 'save') {
         unset($_POST['id'], $_POST['user'], $_POST['x'], $_POST['act']);
         /* === Hook === */
         foreach (cot_getextplugins('subscribe.admin.save.first') as $pl) {
             include $pl;
         }
         /* ===== */
         $data = $_POST;
         $data['next_run'] = cot_import_date('next_run');
         if (!empty($data['next_run'])) {
             $data['next_run'] = date('Y-m-d H:i:s', $data['next_run']);
         }
         $item->setData($data);
         /* === Hook === */
         foreach (cot_getextplugins('subscribe.admin.save.validate') as $pl) {
             include $pl;
         }
         /* ===== */
         // There is some errors
         if (!$item->validate() || cot_error_found()) {
             $urlParams = array('m' => 'subscribe', 'a' => 'edit');
             if ($item->id > 0) {
                 $urlParams['id'] = $item->id;
             }
             cot_redirect(cot_url('admin', $urlParams, '', true));
         }
         $isNew = $item->id == 0;
         // Перерасчет времени следующего запуска
         // Делать это в админке при редактировании рассылки и при выполнении рассылки
         // А то могут быть коллизии
         $recalculate = true;
         if (!empty($item->next_run)) {
             $tmp = strtotime($item->next_run);
             if ($tmp > cot::$sys['now']) {
                 $recalculate = false;
             }
         }
         if ($recalculate) {
             $item->next_run = $item->getNextRunDate();
         }
         // Сохранение
         if ($item->save()) {
             cot_message(cot::$L['Saved']);
             $urlParams = array('m' => 'subscribe', 'a' => 'edit', 'id' => $item->id);
             $redirectUrl = cot_url('admin', $urlParams, '', true);
             /* === Hook === */
             foreach (cot_getextplugins('subscribe.admin.save.done') as $pl) {
                 include $pl;
             }
             /* ===== */
             // Редирект на станицу рассылки
             cot_redirect($redirectUrl);
         }
     }
     // 'input_textarea_editor', 'input_textarea_medieditor', 'input_textarea_minieditor', ''
     $editor = 'input_textarea_editor';
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.admin.edit.main') as $pl) {
         include $pl;
     }
     /* ===== */
     $nextRun = 0;
     if (!empty($item->next_run)) {
         $nextRun = strtotime($item->next_run);
     }
     $formElements = array('hidden' => array('element' => cot_inputbox('hidden', 'act', 'save')), 'title' => array('element' => cot_inputbox('text', 'title', $item->rawValue('title')), 'required' => true, 'label' => subscribe_model_Subscribe::fieldLabel('title')), 'alias' => array('element' => cot_inputbox('text', 'alias', $item->rawValue('alias')), 'label' => subscribe_model_Subscribe::fieldLabel('alias')), 'admin_note' => array('element' => cot_textarea('admin_note', $item->rawValue('admin_note'), 5, 120, ''), 'label' => subscribe_model_Subscribe::fieldLabel('admin_note')), 'from_mail' => array('element' => cot_inputbox('text', 'from_mail', $item->rawValue('from_mail')), 'label' => subscribe_model_Subscribe::fieldLabel('from_mail'), 'hint' => cot::$L['subscribe_from_mail_hint']), 'from_title' => array('element' => cot_inputbox('text', 'from_title', $item->rawValue('from_title')), 'label' => subscribe_model_Subscribe::fieldLabel('from_title')), 'subject' => array('element' => cot_inputbox('text', 'subject', $item->rawValue('subject')), 'label' => subscribe_model_Subscribe::fieldLabel('subject')), 'description' => array('element' => cot_textarea('description', $item->rawValue('description'), 5, 120, '', $editor), 'label' => subscribe_model_Subscribe::fieldLabel('description')), 'content_url' => array('element' => cot_inputbox('text', 'content_url', $item->rawValue('content_url')), 'label' => subscribe_model_Subscribe::fieldLabel('content_url'), 'hint' => cot::$L['subscribe_content_url_hint']), 'text' => array('element' => cot_textarea('text', $item->rawValue('text'), 5, 120, '', $editor), 'label' => subscribe_model_Subscribe::fieldLabel('text'), 'hint' => cot::$L['subscribe_text_hint']), 'next_run' => array('element' => cot_selectbox_date($nextRun, 'long', 'next_run'), 'label' => subscribe_model_Subscribe::fieldLabel('next_run'), 'hint' => cot::$L['subscribe_next_run_hint'] . " " . cot::$usr['timetext']), 'sched_mday' => array('element' => cot_inputbox('text', 'sched_mday', $item->rawValue('sched_mday')), 'label' => subscribe_model_Subscribe::fieldLabel('sched_mday'), 'hint' => cot::$L['subscribe_sched_mday_hint']), 'sched_wday' => array('element' => cot_inputbox('text', 'sched_wday', $item->rawValue('sched_wday')), 'label' => subscribe_model_Subscribe::fieldLabel('sched_wday'), 'hint' => cot::$L['subscribe_sched_wday_hint']), 'sched_time' => array('element' => cot_inputbox('text', 'sched_time', $item->rawValue('sched_time')), 'label' => subscribe_model_Subscribe::fieldLabel('sched_time'), 'hint' => cot::$L['subscribe_sched_time_hint']), 'active' => array('element' => cot_checkbox($item->rawValue('active'), 'active', subscribe_model_Subscribe::fieldLabel('active'))), 'periodical' => array('element' => cot_checkbox($item->rawValue('periodical'), 'periodical', subscribe_model_Subscribe::fieldLabel('periodical'))), 'sort' => array('element' => cot_inputbox('text', 'sort', $item->rawValue('sort')), 'label' => subscribe_model_Subscribe::fieldLabel('sort')));
     if (!empty($cot_extrafields[cot::$db->subscribe])) {
         // Extra fields for subscribe
         foreach ($cot_extrafields[cot::$db->subscribe] as $exfld) {
             $fName = $exfld['field_name'];
             $formElements[$fName] = array('element' => cot_build_extrafields($fName, $exfld, $item->rawValue($fName)));
             if ($exfld['field_type'] !== 'checkbox') {
                 isset(cot::$L['subscribe_' . $exfld['field_name'] . '_title']) ? cot::$L['subscribe_' . $exfld['field_name'] . '_title'] : subscribe_model_Subscribe::fieldLabel($fName);
             }
         }
     }
     $subscribers = subscribe_model_Subscriber::count(array(array('subscribe', $item->id)));
     $activeSubscribers = subscribe_model_Subscriber::count(array(array('subscribe', $item->id), array('active', 1)));
     $actionParams = array('m' => 'subscribe', 'a' => 'edit');
     if ($item->id > 0) {
         $actionParams['id'] = $item->id;
     }
     $template = array('subscribe', 'admin', 'edit');
     $view = new View();
     $view->page_title = $admintitle;
     $view->item = $item;
     $view->subscribers = $subscribers;
     $view->activeSubscribers = $activeSubscribers;
     $view->formElements = $formElements;
     $view->formAction = cot_url('admin', $actionParams);
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.admin.edit.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Example #5
0
$title_params = array('EDIT' => $L['Edit'], 'NAME' => $urr['user_name']);
$out['subtitle'] = cot_title('{EDIT} - {NAME}', $title_params);
$out['head'] .= $R['code_noindex'];
$mskin = cot_tplfile(array('users', 'edit', $usr['maingrp']), 'module');
/* === Hook === */
foreach (cot_getextplugins('users.edit.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
require_once cot_incfile('forms');
$protected = $sys['protecttopadmin'] ? array('disabled' => 'disabled') : array();
$editor_class = $cfg['users']['usertextimg'] ? 'minieditor' : '';
$delete_pfs = cot_module_active('pfs') ? cot_checkbox(false, 'ruserdelpfs', $L['PFS']) : '';
$t->assign(array('USERS_EDIT_TITLE' => cot_breadcrumbs(array(array(cot_url('users'), $L['Users']), array(cot_url('users', 'm=details&id=' . $urr['user_id'] . '&u=' . $urr['user_name']), $urr['user_name']), array(cot_url('users', 'm=edit&id=' . $urr['user_id']), $L['Edit'])), $cfg['homebreadcrumb']), 'USERS_EDIT_DETAILSLINK' => cot_url('users', 'm=details&id=' . $urr['user_id']), 'USERS_EDIT_EDITLINK' => cot_url('users', 'm=edit&id=' . $urr['user_id']), 'USERS_EDIT_SUBTITLE' => $L['useed_subtitle'], 'USERS_EDIT_SEND' => cot_url('users', 'm=edit&a=update&' . cot_xg() . '&id=' . $urr['user_id']), 'USERS_EDIT_ID' => $urr['user_id'], 'USERS_EDIT_NAME' => cot_inputbox('text', 'rusername', $urr['user_name'], array('size' => 32, 'maxlength' => 100) + $protected), 'USERS_EDIT_ACTIVE' => $user_form_active, 'USERS_EDIT_BANNED' => $user_form_banned, 'USERS_EDIT_THEME' => cot_inputbox('text', 'rusertheme', $urr['user_theme'], array('size' => 32, 'maxlength' => 32)), 'USERS_EDIT_LANG' => cot_inputbox('text', 'ruserlang', $urr['user_lang'], array('size' => 32, 'maxlength' => 32)), 'USERS_EDIT_NEWPASS' => cot_inputbox('password', 'rusernewpass', '', array('size' => 12, 'maxlength' => 32, 'autocomplete' => 'off') + $protected), 'USERS_EDIT_MAINGRP' => cot_build_group($urr['user_maingrp']), 'USERS_EDIT_GROUPS' => cot_build_groupsms($urr['user_id'], $usr['isadmin'], $urr['user_maingrp']), 'USERS_EDIT_COUNTRY' => cot_selectbox_countries($urr['user_country'], 'rusercountry'), 'USERS_EDIT_EMAIL' => cot_inputbox('text', 'ruseremail', $urr['user_email'], array('size' => 32, 'maxlength' => 64)), 'USERS_EDIT_HIDEEMAIL' => cot_radiobox($urr['user_hideemail'], 'ruserhideemail', array(1, 0), array($L['Yes'], $L['No'])), 'USERS_EDIT_TEXT' => cot_textarea('rusertext', $urr['user_text'], 4, 56, array('class' => $editor_class)), 'USERS_EDIT_GENDER' => cot_selectbox_gender($urr['user_gender'], 'rusergender'), 'USERS_EDIT_BIRTHDATE' => cot_selectbox_date(cot_date2stamp($urr['user_birthdate']), 'short', 'ruserbirthdate', cot_date('Y', $sys['now']), cot_date('Y', $sys['now']) - 100, false), 'USERS_EDIT_TIMEZONE' => cot_selectbox_timezone($urr['user_timezone'], 'rusertimezone'), 'USERS_EDIT_REGDATE' => cot_date('datetime_medium', $urr['user_regdate']), 'USERS_EDIT_REGDATE_STAMP' => $urr['user_regdate'], 'USERS_EDIT_LASTLOG' => cot_date('datetime_medium', $urr['user_lastlog']), 'USERS_EDIT_LASTLOG_STAMP' => $urr['user_lastlog'], 'USERS_EDIT_LOGCOUNT' => $urr['user_logcount'], 'USERS_EDIT_LASTIP' => cot_build_ipsearch($urr['user_lastip']), 'USERS_EDIT_DELETE' => $sys['user_istopadmin'] ? cot_radiobox(0, 'ruserdelete', array(1, 0), array($L['Yes'], $L['No'])) . $delete_pfs : $L['na']));
// Extra fields
foreach ($cot_extrafields[$db_users] as $exfld) {
    $tag = strtoupper($exfld['field_name']);
    $t->assign(array('USERS_EDIT_' . $tag => cot_build_extrafields('ruser' . $exfld['field_name'], $exfld, $urr['user_' . $exfld['field_name']]), 'USERS_EDIT_' . $tag . '_TITLE' => isset($L['user_' . $exfld['field_name'] . '_title']) ? $L['user_' . $exfld['field_name'] . '_title'] : $exfld['field_description']));
}
// Error and message reporting
cot_display_messages($t);
/* === Hook === */
foreach (cot_getextplugins('users.edit.tags') as $pl) {
    include $pl;
}
/* ===== */
$t->parse('MAIN');
$t->out('MAIN');
require_once $cfg['system_dir'] . '/footer.php';
Example #6
0
 public function editAction()
 {
     global $structure, $cot_extrafields, $db_structure;
     $id = cot_import('id', 'G', 'INT');
     // id Объявления
     $c = cot_import('c', 'G', 'TXT');
     $act = cot_import('act', 'G', 'ALP');
     if (empty($act)) {
         $act = cot_import('act', 'P', 'ALP');
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.first') as $pl) {
         include $pl;
     }
     /* ===== */
     // Права на любую категорию доски объявлений
     list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', 'any');
     cot_block(cot::$usr['auth_write']);
     if (!$c || !isset($structure['advboard'][$c])) {
         cot_die_message(404, TRUE);
     }
     $category = $structure['advboard'][$c];
     $category['config'] = cot::$cfg['advboard']['cat_' . $c];
     $category['code'] = $c;
     // Extra fields for structure
     foreach ($cot_extrafields[$db_structure] as $exfld) {
         $uname = $exfld['field_name'];
         $val = $structure['advboard'][$c][$exfld['field_name']];
         $category[$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
         $category[$uname] = cot_build_extrafields_data('structure', $exfld, $val);
         $category[$uname . '_value'] = $val;
     }
     $published = 0;
     if (!$id) {
         $advert = new advboard_model_Advert();
         $advert->category = $c;
         $advert->user = cot::$usr['id'];
     } else {
         $advert = advboard_model_Advert::getById($id);
         if (!$advert) {
             cot_die_message(404, TRUE);
         }
         if (!cot::$usr['isadmin']) {
             if ($advert->user != cot::$usr['id']) {
                 cot_die_message(404, TRUE);
             }
         }
         if ($c != $advert->category && isset($structure['advboard'][$advert->category])) {
             $tmp = array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id);
             if (!empty($act)) {
                 $tmp['act'] = $act;
             }
             cot_redirect(cot_url('advboard', array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id), '', true));
         }
         if ($act == 'clone') {
             $id = null;
             $advert = clone $advert;
             // Установить статус и пользователя нового объекта
             $advert->user = cot::$usr['id'];
             $advert->state = advboard_model_Advert::DRAFT;
         }
         $published = $advert->state < 2 ? 1 : 0;
     }
     //Проверим права на категорию:
     list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin'], cot::$usr['auth_upload']) = cot_auth('advboard', $c, 'RWA1');
     if ($structure['advboard'][$c]['locked'] && !cot::$usr['isadmin']) {
         cot_die_message(602, TRUE);
     } elseif ($advert->id == 0) {
         // Если у пользователя нет прав на подачу объявления, то ищем категорию куда он может подать оьбъявление
         if (!cot::$usr['auth_write']) {
             foreach ($structure['advboard'] as $catCode => $catRow) {
                 $auth_write = cot_auth('advboard', $catCode, 'W');
                 if ($auth_write) {
                     cot_redirect(cot_url('advboard', array('c' => $catCode, 'a' => 'edit'), '', true));
                 }
             }
         }
         cot_block(cot::$usr['auth_write']);
     }
     // Владелец объявления
     $user = array();
     if ($advert->user > 0) {
         $user = cot_user_data($advert->user);
     }
     $periodItems = adv_periodItems($c);
     // Сохранение
     if ($act == 'save') {
         unset($_POST['id'], $_POST['user']);
         cot_shield_protect();
         /* === Hook === */
         foreach (cot_getextplugins('advboard.save.first') as $pl) {
             include $pl;
         }
         /* ===== */
         // импортировать даты
         $begin = (int) cot_import_date('begin');
         $expire = (int) cot_import_date('expire');
         if ($begin == 0) {
             $begin = !empty($advert->begin) ? $advert->begin : cot::$sys['now'];
         }
         // Пересчитать период публикации объявления
         if ($expire == 0 && cot::$cfg['advboard']['cat_' . $c]['maxPeriod'] > 0) {
             $period = cot_import('period', 'P', 'INT');
             $maxPeriod = max($periodItems);
             if (empty($period)) {
                 $period = $maxPeriod;
             }
             if (!cot::$usr['isadmin'] && $period > $maxPeriod) {
                 $period = $maxPeriod;
             }
             if ($period > 0) {
                 $expire = $begin + $period * 86400;
             }
         }
         if ($category['config']['title_require']) {
             $advert->setValidator('title', 'required');
         }
         // Валидатор 'allowemptytext'
         if (!$category['config']['allowemptytext']) {
             $advert->setValidator('text', 'required');
         }
         if ($category['config']['phone_require']) {
             // проверить надичие заполненного поля в профиле пользователя - владельца
             if (empty($user['user_phone'])) {
                 $advert->setValidator('phone', 'required');
             }
         }
         if ($category['config']['city_require']) {
             // Проверить наличие заполненного города (id или названия) в профиле владельца
             if (empty($user['user_city_name']) && empty($user['user_city'])) {
                 if (cot_plugin_active('regioncity')) {
                     $advert->setValidator('city', function ($value) {
                         $value = (int) $value;
                         if ($value == 0) {
                             return cot::$L['field_required'] . ': ' . advboard_model_Advert::fieldLabel('city');
                         }
                         return true;
                     });
                 } else {
                     $advert->setValidator('city_name', 'required');
                 }
             }
         }
         if (cot::$usr['id'] == 0) {
             $advert->setValidator('person', 'required');
             // Email
             $email = cot_import('email', 'P', 'TXT');
             if (cot::$cfg['advboard']['guestEmailRequire']) {
                 if ($email == '') {
                     cot_error(cot::$L['advboard_err_noemail'], 'email');
                 }
             }
             if ($email != '') {
                 $tmp = advert_checkEmail($email);
                 if ($tmp !== true) {
                     cot_error($tmp, 'email');
                 }
             }
             // Капча
             if (cot::$cfg['advboard']['guestUseCaptcha']) {
                 $verify = cot_import('verify', 'P', 'TXT');
                 if (!cot_captcha_validate($verify)) {
                     cot_error(cot::$L['captcha_verification_failed'], 'verify');
                 }
             }
         }
         $advert->setData($_POST);
         $advert->begin = $begin;
         $advert->expire = $expire;
         if (!cot::$usr['isadmin']) {
             if (!cot::$cfg['advboard']['cat_' . $c]['allowSticky']) {
                 $advert->sticky = 0;
             }
             if (cot::$usr['id'] == 0) {
                 $advert->sticky = 0;
             }
             // гости не дают срочных объявлений
         }
         $advert->category = $c;
         if (empty($advert->user) || !cot::$usr['isadmin']) {
             $advert->user = cot::$usr['id'];
         }
         $published = cot_import('published', 'P', 'BOL');
         if (!$published) {
             $advert->state = advboard_model_Advert::DRAFT;
         } elseif (cot::$usr['isadmin'] || cot_auth('advboard', $c, '2')) {
             $advert->state = advboard_model_Advert::PUBLISHED;
         } else {
             $advert->state = advboard_model_Advert::AWAITING_MODERATION;
         }
         /* === Hook === */
         foreach (cot_getextplugins('advboard.save.validate') as $pl) {
             include $pl;
         }
         /* ===== */
         // There is some errors
         if (!$advert->validate() || cot_error_found()) {
             $urlParams = array('c' => $c, 'a' => 'edit');
             if ($advert->id > 0) {
                 $urlParams['id'] = $advert->id;
             }
             cot_redirect(cot_url('advboard', $urlParams, '', true));
         }
         if (empty($advert->sort)) {
             $advert->sort = cot::$sys['now'];
         }
         $isNew = $advert->id == 0;
         // Сохранение
         if ($advert->save()) {
             // Для незарега запомним id страницы для чтого, чтобы он мог ее отредактировать в пределах сесии
             if ($isNew) {
                 if (cot::$usr['id'] == 0) {
                     if (empty($_SESSION['advboard'])) {
                         $_SESSION['advboard'] = array();
                     }
                     if (!in_array($id, $_SESSION['advboard'])) {
                         $_SESSION['advboard'][] = $advert->id;
                     }
                 }
                 if ($advert->state == advboard_model_Advert::PUBLISHED) {
                     cot_message(cot::$L['advboard_created']);
                 }
             } else {
                 if ($advert->state == advboard_model_Advert::PUBLISHED) {
                     cot_message(cot::$L['advboard_updated']);
                 }
             }
             if ($advert->state == advboard_model_Advert::AWAITING_MODERATION) {
                 cot_message(cot::$L['advboard_awaiting_moderation']);
             } elseif ($advert->state == advboard_model_Advert::DRAFT) {
                 cot_message(cot::$L['Saved']);
             }
             $redirectUrl = $advert->getUrl(true);
             /* === Hook === */
             foreach (cot_getextplugins('advboard.save.done') as $pl) {
                 include $pl;
             }
             /* ===== */
             // Редирект на станицу объявления
             cot_redirect($redirectUrl);
         }
     }
     $crumbs = cot_structure_buildpath('advboard', $c);
     if (cot::$cfg['advboard']['firstCrumb']) {
         array_unshift($crumbs, array(cot_url('advboard'), cot::$L['advboard_ads']));
     }
     if (!$id) {
         $crumbs[] = $title = cot::$L['advboard_add_new'];
         cot::$out['subtitle'] = $title;
     } else {
         $crumbs[] = array($advert->url, $advert->title);
         $crumbs[] = cot::$L['Edit'];
         $title = cot::$L['advboard_advert'] . ' #' . $advert->id;
         if (!empty($advert->title)) {
             $title = $advert->title;
         }
         $title .= ': ' . cot::$L['Edit'];
         if (!empty(cot::$out['subtitle'])) {
             $title .= ' - ' . cot::$out['subtitle'];
         }
         cot::$out['subtitle'] = $title;
     }
     // Elemets placeholders
     $placeHolder_Person = '';
     $placeHolder_Phone = '';
     $placeHolder_Email = '';
     $placeHolder_City = '';
     //if($advboard->user == cot::$usr['id'] && cot::$usr['id'] > 0) {
     if (!empty($user)) {
         // Контакное лицо
         $placeHolder_Person = cot_user_full_name($user);
         // Телефон
         if (!empty($user['user_phone'])) {
             $placeHolder_Phone = $user['user_phone'];
         }
         // email
         if (!$user['user_hideemail']) {
             $placeHolder_Email = $user['user_email'];
         }
         // город
         if (!empty($user['user_city_name'])) {
             $placeHolder_City = $user['user_city_name'];
         }
     }
     // 'input_textarea_editor', 'input_textarea_medieditor', 'input_textarea_minieditor', ''
     $editor = 'input_textarea_editor';
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.main') as $pl) {
         include $pl;
     }
     /* ===== */
     $minYear = date('Y');
     $maxYear = $minYear + 30;
     $price = $advert->rawValue('price');
     if ($price <= 0) {
         $price = '';
     }
     $formElements = array('hidden' => array('element' => cot_inputbox('hidden', 'act', 'save')), 'category' => array('element' => cot_selectbox_structure('advboard', $advert->category, 'category'), 'label' => advboard_model_Advert::fieldLabel('category')), 'price' => array('element' => cot_inputbox('text', 'price', $price), 'label' => advboard_model_Advert::fieldLabel('price'), 'hint' => cot::$L['advboard_price_hint']), 'title' => array('element' => cot_inputbox('text', 'title', $advert->rawValue('title')), 'required' => true, 'label' => advboard_model_Advert::fieldLabel('title')), 'description' => array('element' => cot_inputbox('text', 'description', $advert->rawValue('description')), 'label' => advboard_model_Advert::fieldLabel('description')), 'text' => array('element' => cot_textarea('text', $advert->rawValue('text'), 5, 120, '', $editor), 'label' => advboard_model_Advert::fieldLabel('text')), 'person' => array('element' => cot_inputbox('text', 'person', $advert->rawValue('person'), array('class' => 'form-control', 'placeholder' => $placeHolder_Person)), 'label' => advboard_model_Advert::fieldLabel('person'), 'required' => cot::$usr['id'] == 0), 'email' => array('element' => cot_inputbox('text', 'email', $advert->rawValue('email'), array('class' => 'form-control', 'placeholder' => $placeHolder_Email)), 'label' => advboard_model_Advert::fieldLabel('email')), 'city' => array('element' => cot_inputbox('text', 'city_name', $advert->rawValue('city_name'), array('class' => 'form-control', 'placeholder' => $placeHolder_City)), 'label' => advboard_model_Advert::fieldLabel('city_name'), 'required' => $category['config']['city_require']), 'phone' => array('element' => cot_inputbox('text', 'phone', $advert->rawValue('phone'), array('class' => 'form-control', 'placeholder' => $placeHolder_Phone)), 'label' => advboard_model_Advert::fieldLabel('phone'), 'required' => $category['config']['phone_require']), 'sticky' => array('element' => cot_checkbox($advert->sticky, 'sticky', advboard_model_Advert::fieldLabel('sticky')), 'label' => advboard_model_Advert::fieldLabel('sticky')), 'published' => array('element' => cot_checkbox($published, 'published', cot::$L['advboard_published'] . '?'), 'label' => cot::$L['advboard_published'] . '?'), 'begin' => array('element' => cot_selectbox_date($advert->begin, 'long', 'begin', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('begin')), 'expire' => array('element' => cot_selectbox_date($advert->expire, 'long', 'expire', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('expire')), 'sort' => array('element' => cot_selectbox_date($advert->sort, 'long', 'sort', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('sort')), 'period' => array('element' => cot_selectbox('', 'period', $periodItems, array(), false), 'label' => cot::$L['advboard_period']));
     if (!empty($cot_extrafields[cot::$db->advboard])) {
         // Extra fields for ads
         foreach ($cot_extrafields[cot::$db->advboard] as $exfld) {
             $fName = $exfld['field_name'];
             $formElements[$fName] = array('element' => cot_build_extrafields($fName, $exfld, $advert->rawValue($fName)));
             if ($exfld['field_type'] !== 'checkbox') {
                 $formElements[$fName]['label'] = isset(cot::$L['advboard_' . $exfld['field_name'] . '_title']) ? cot::$L['advboard_' . $exfld['field_name'] . '_title'] : advboard_model_Advert::fieldLabel($fName);
             }
         }
     }
     if (cot_plugin_active('regioncity')) {
         $formElements['city']['element'] = rec_select2_city('city', $advert->rawValue('city'), true, array('class' => 'form-control', 'placeholder' => $placeHolder_City));
     }
     if ($category['config']['city_require']) {
         $formElements['city']['required'] = true;
     }
     if ($category['config']['phone_require']) {
         $formElements['phone']['required'] = true;
     }
     // Hints
     if (!empty($user)) {
         // Контакное лицо
         $formElements['person']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . cot_user_full_name($user);
         // Телефон
         if (!empty($user['user_phone'])) {
             $formElements['phone']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_phone'];
         }
         // email
         if (!$user['user_hideemail']) {
             $formElements['email']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_email'];
         }
         // город
         if (!empty($user['user_city_name'])) {
             $formElements['city']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_city_name'];
         }
     }
     if (!cot::$usr['isadmin']) {
         unset($formElements['begin']);
         unset($formElements['expire']);
         unset($formElements['sort']);
         if (cot::$usr['id'] == 0) {
             if (cot::$cfg['advboard']['guestEmailRequire']) {
                 $formElements['email']['required'] = true;
             }
             // Гости не дают срочных объявлений
             unset($formElements['sticky']);
             // Капча
             if (cot::$cfg['advboard']['guestUseCaptcha']) {
                 $formElements['verify'] = array('element' => cot_inputbox('text', 'verify'), 'img' => cot_captcha_generate(), 'label' => cot::$L['advboard_captcha'], 'required' => true);
             }
         }
         if (!cot::$cfg['advboard']['cat_' . $c]['allowSticky'] && isset($formElements['sticky'])) {
             unset($formElements['sticky']);
         }
     } else {
         // Администратор напрямую указывает дату окончания публикации
         unset($formElements['period']);
     }
     $actionParams = array('a' => 'edit', 'c' => $advert->category);
     if ($advert->id > 0) {
         $actionParams['id'] = $advert->id;
     }
     $view = new View();
     $view->breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     $view->page_title = $title;
     $view->category = $category;
     $view->advert = $advert;
     $view->user = $user;
     $view->formElements = $formElements;
     $view->formAction = cot_url('advboard', $actionParams);
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render(array('advboard', 'edit', $structure['advboard'][$c]['tpl']));
 }
Example #7
0
$urr = $sql->fetch();
$out['subtitle'] = $L['Profile'];
$out['head'] .= $R['code_noindex'];
$mskin = cot_tplfile(array('users', 'profile'), 'module');
/* === Hook === */
foreach (cot_getextplugins('users.profile.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
require_once cot_incfile('forms');
$protected = !$cfg['users']['useremailchange'] ? array('disabled' => 'disabled') : array();
$profile_form_email = cot_inputbox('text', 'ruseremail', $urr['user_email'], array('size' => 32, 'maxlength' => 64) + $protected);
$editor_class = $cfg['users']['usertextimg'] ? 'minieditor' : '';
$t->assign(array('USERS_PROFILE_TITLE' => cot_rc_link(cot_url('users', 'm=profile'), $L['pro_title']), 'USERS_PROFILE_SUBTITLE' => $L['pro_subtitle'], 'USERS_PROFILE_DETAILSLINK' => cot_url('users', 'm=details&id=' . $urr['user_id']), 'USERS_PROFILE_EDITLINK' => cot_url('users', 'm=edit&id=' . $urr['user_id']), 'USERS_PROFILE_FORM_SEND' => cot_url('users', "m=profile&a=update&" . cot_xg()), 'USERS_PROFILE_ID' => $urr['user_id'], 'USERS_PROFILE_NAME' => htmlspecialchars($urr['user_name']), 'USERS_PROFILE_MAINGRP' => cot_build_group($urr['user_maingrp']), 'USERS_PROFILE_GROUPS' => cot_build_groupsms($urr['user_id'], FALSE, $urr['user_maingrp']), 'USERS_PROFILE_COUNTRY' => cot_selectbox_countries($urr['user_country'], 'rusercountry'), 'USERS_PROFILE_TEXT' => cot_textarea('rusertext', $urr['user_text'], 8, 56, array('class' => $editor_class)), 'USERS_PROFILE_EMAIL' => $profile_form_email, 'USERS_PROFILE_EMAILPASS' => cot_inputbox('password', 'rmailpass', '', array('size' => 12, 'maxlength' => 32, 'autocomplete' => 'off')), 'USERS_PROFILE_HIDEEMAIL' => cot_radiobox($urr['user_hideemail'], 'ruserhideemail', array(1, 0), array($L['Yes'], $L['No'])), 'USERS_PROFILE_THEME' => cot_selectbox_theme($urr['user_theme'], $urr['user_scheme'], 'rusertheme'), 'USERS_PROFILE_LANG' => cot_selectbox_lang($urr['user_lang'], 'ruserlang'), 'USERS_PROFILE_GENDER' => cot_selectbox_gender($urr['user_gender'], 'rusergender'), 'USERS_PROFILE_BIRTHDATE' => cot_selectbox_date(cot_date2stamp($urr['user_birthdate']), 'short', 'ruserbirthdate', cot_date('Y', $sys['now']), cot_date('Y', $sys['now']) - 100, false), 'USERS_PROFILE_TIMEZONE' => cot_selectbox_timezone($urr['user_timezone'], 'rusertimezone'), 'USERS_PROFILE_REGDATE' => cot_date('datetime_medium', $urr['user_regdate']), 'USERS_PROFILE_REGDATE_STAMP' => $urr['user_regdate'], 'USERS_PROFILE_LASTLOG' => cot_date('datetime_medium', $urr['user_lastlog']), 'USERS_PROFILE_LASTLOG_STAMP' => $urr['user_lastlog'], 'USERS_PROFILE_LOGCOUNT' => $urr['user_logcount'], 'USERS_PROFILE_ADMINRIGHTS' => '', 'USERS_PROFILE_OLDPASS' => cot_inputbox('password', 'roldpass', '', array('size' => 12, 'maxlength' => 32)), 'USERS_PROFILE_NEWPASS1' => cot_inputbox('password', 'rnewpass1', '', array('size' => 12, 'maxlength' => 32, 'autocomplete' => 'off')), 'USERS_PROFILE_NEWPASS2' => cot_inputbox('password', 'rnewpass2', '', array('size' => 12, 'maxlength' => 32, 'autocomplete' => 'off'))));
// Extra fields
if (!empty(cot::$extrafields[cot::$db->users])) {
    foreach (cot::$extrafields[cot::$db->users] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $exfld_val = cot_build_extrafields('ruser' . $exfld['field_name'], $exfld, $urr['user_' . $exfld['field_name']]);
        $exfld_title = cot_extrafield_title($exfld, 'user_');
        $t->assign(array('USERS_PROFILE_' . $uname => $exfld_val, 'USERS_PROFILE_' . $uname . '_TITLE' => $exfld_title, 'USERS_PROFILE_EXTRAFLD' => $exfld_val, 'USERS_PROFILE_EXTRAFLD_TITLE' => $exfld_title));
        $t->parse('MAIN.EXTRAFLD');
    }
}
/* === Hook === */
foreach (cot_getextplugins('users.profile.tags') as $pl) {
    include $pl;
}
/* ===== */
<?php

/* ====================
[BEGIN_COT_EXT]
Hooks=tools
[END_COT_EXT]
==================== */
/**
 * Administration panel for UI date/time picker
 *
 * @package ui_datetime
 * @author Andrey Matsovkin
 * @copyright Copyright (c) 2008-2013
 * @license Distributed under BSD License.
 */
if (!defined('COT_CODE') && !defined('COT_PLUG')) {
    die('Wrong URL (' . array_pop(explode("\\", __FILE__)) . ').');
}
//require_once cot_incfile('ui_datetime', 'plug');
$plug_name = 'ui_datetime';
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', $plug_name);
cot_block($usr['isadmin']);
$adminhelp = $adminhelp1;
require_once cot_incfile('forms');
$tt = new XTemplate(cot_tplfile($plug_name . '.tools', 'plug'));
$std_date = cot_selectbox_date(time(), 'short', 'testdate');
$std_time = cot_selectbox_date(time(), 'time', 'testtime');
$std_datetime = cot_selectbox_date(time(), '', 'testdatetime');
$std_datetime_combined = cot_selectbox_date(time(), 'combined', 'testdatetimecmb');
$tt->parse();
$plugin_body .= $tt->text();
Example #9
0
 /**
  * основная статистика кликов и показов
  */
 public function indexAction()
 {
     global $admintitle, $adminpath, $structure;
     $admintitle = cot::$L['brs_tracks'];
     $adminpath[] = array(cot_url('admin', array('m' => 'brs', 'n' => 'track')), cot::$L['brs_tracks']);
     $sortFields = array('b.title' => cot::$L['Title'], 'b.category' => cot::$L['Category'], 'b.client' => cot::$L['brs_client'], 't.type' => cot::$L['Type'], 't.track_count' => cot::$L['Count'], 't.date' => cot::$L['Date']);
     $sort = cot_import('s', 'G', 'TXT');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $f = cot_import('f', 'G', 'ARR');
     // filters
     $f['date_from'] = cot_import_date('f_df', true, false, 'G');
     $f['date_to'] = cot_import_date('f_dt', true, false, 'G');
     $maxrowsperpage = cot::$cfg['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for banners list
     $sort = empty($sort) ? 't.date' : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? 'desc' : $way;
     $urlParams = array('m' => 'brs', 'n' => 'track');
     if ($sort != 't.date') {
         $urlParams['s'] = $sort;
     }
     if ($way != 'desc') {
         $urlParams['w'] = $way;
     }
     $where = array();
     $params = array();
     if (!empty($f)) {
         foreach ($f as $key => $val) {
             $val = trim(cot_import($val, 'D', 'TXT'));
             if (empty($val) && $val !== '0') {
                 continue;
             }
             if (in_array($key, array('b.title'))) {
                 $kkey = str_replace('.', '_', $key);
                 $params[$kkey] = "%{$val}%";
                 $where['filter'][] = "{$key} LIKE :{$kkey}";
                 $urlParams["f[{$key}]"] = $val;
             } elseif ($key == 'date_from') {
                 if ($f[$key] == 0) {
                     continue;
                 }
                 $where['filter'][] = "t.date >= '" . date('Y-m-d H:i:s', $f[$key]) . "'";
                 $urlParams["f_df[year]"] = cot_date('Y', $f[$key]);
                 $urlParams["f_df[month]"] = cot_date('m', $f[$key]);
                 $urlParams["f_df[day]"] = cot_date('d', $f[$key]);
             } elseif ($key == 'date_to') {
                 if ($f[$key] == 0) {
                     continue;
                 }
                 $where['filter'][] = "t.date <= '" . date('Y-m-d H:i:s', $f[$key]) . "'";
                 $urlParams["f_dt[year]"] = cot_date('Y', $f[$key]);
                 $urlParams["f_dt[month]"] = cot_date('m', $f[$key]);
                 $urlParams["f_dt[day]"] = cot_date('d', $f[$key]);
             } else {
                 $kkey = str_replace('.', '_', $key);
                 $params[$kkey] = $val;
                 $where['filter'][] = "{$key} = :{$kkey}";
                 $urlParams["f[{$key}]"] = $val;
             }
         }
         empty($where['filter']) || ($where['filter'] = implode(' AND ', $where['filter']));
     } else {
         $f = array();
     }
     $orderby = "{$sort} {$way}";
     $where = array_filter($where);
     $where = $where ? 'WHERE ' . implode(' AND ', $where) : '';
     $sql = "SELECT `t`.`date`, `t`.`type` , `t`.`track_count`, `t`.`banner`, b.title, b.category, cl.title as client_title,\n                cl.id as client_id\n            FROM " . cot::$db->banner_tracks . " AS t\n            LEFT JOIN " . cot::$db->banners . " AS b ON b.id=t.banner\n            LEFT JOIN " . cot::$db->banner_clients . " AS cl ON cl.id=b.client\n            {$where} ORDER BY {$orderby} LIMIT {$d}, {$maxrowsperpage}";
     $sqlCount = "SELECT COUNT(*)\n            FROM " . cot::$db->banner_tracks . " AS t\n            LEFT JOIN " . cot::$db->banners . " AS b ON b.id=t.banner\n            LEFT JOIN " . cot::$db->banner_clients . " AS cl ON cl.id=b.client\n            {$where}";
     $totallines = cot::$db->query($sqlCount, $params)->fetchColumn();
     $sqllist = cot::$db->query($sql, $params);
     // Без Ajax, а то дата пропадает (UI datetime)
     $pagenav = cot_pagenav('admin', $urlParams, $d, $totallines, $maxrowsperpage);
     $track_types = array(1 => cot::$L['brs_impressions'], 2 => cot::$L['brs_clicks']);
     $items = $sqllist->fetchAll();
     if ($items) {
         foreach ($items as $key => $itemRow) {
             $items[$key]['categoryTitle'] = '';
             if (!empty($itemRow['category']) && !empty($structure['brs'][$itemRow['category']])) {
                 $items[$key]['categoryTitle'] = $structure['brs'][$itemRow['category']]['title'];
             }
             $items[$key]['track_typeTitle'] = $track_types[$itemRow['type']];
         }
     }
     $clients = brs_model_Client::keyValPairs();
     if (!$clients) {
         $clients = array();
     }
     $filterForm = array('hidden' => cot_inputbox('hidden', 'n', 'track'), 'title' => array('element' => cot_inputbox('text', 'f[b.title]', $f['b.title']), 'label' => brs_model_Banner::fieldLabel('title')), 'category' => array('element' => brs_selectbox_structure('brs', $f['b.category'], 'f[b.category]', '', false, false, true), 'label' => brs_model_Banner::fieldLabel('category')), 'client' => array('element' => cot_selectbox($f['b.client'], 'f[b.client]', array_keys($clients), array_values($clients)), 'label' => brs_model_Banner::fieldLabel('client')), 'type' => array('element' => cot_selectbox($f['t.type'], 'f[t.type]', array_keys($track_types), array_values($track_types)), 'label' => cot::$L['Type']), 'date_from' => array('element' => cot_selectbox_date($f['date_from'], 'short', 'f_df'), 'label' => cot::$L['brs_from']), 'date_to' => array('element' => cot_selectbox_date($f['date_to'], 'short', 'f_dt'), 'label' => cot::$L['brs_to']), 'sort' => array('element' => cot_selectbox($sort, 's', array_keys($sortFields), array_values($sortFields), false), 'label' => cot::$L['adm_sort']), 'way' => array('element' => cot_selectbox($way, 'w', array('asc', 'desc'), array(cot::$L['Ascending'], cot::$L['Descending']), false)));
     if (isset(cot::$cfg['plugin']['urleditor']) && cot::$cfg['plugin']['urleditor']['preset'] != 'handy') {
         $filterForm['hidden'] .= cot_inputbox('hidden', 'm', 'brs');
     }
     $template = array('brs', 'admin', 'track');
     $view = new View();
     $view->page_title = $admintitle;
     $view->fistNumber = $d + 1;
     $view->items = $items;
     $view->clients = $clients;
     $view->track_types = $track_types;
     $view->totalitems = $totallines;
     $view->filterForm = $filterForm;
     $view->pagenav = $pagenav;
     //        $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->filter = $f;
     /* === Hook === */
     foreach (cot_getextplugins('brs.admin.track.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Example #10
0
/**
 * Returns Extra fields edit fields
 *
 * @param string $name Variable name
 * @param array $extrafields Extra fields data
 * @param string $data Existing data for fields
 * @return string
 */
function cot_build_extrafields($name, $extrafield, $data)
{
    global $L, $R, $cfg, $pl;
    $data = $data == null ? $extrafield['field_default'] : $data;
    switch ($extrafield['field_type']) {
        case 'input':
        case 'inputint':
        case 'currency':
        case 'double':
            $result = cot_inputbox('text', $name, $data, '', $extrafield['field_html']);
            break;
        case 'textarea':
            $result = cot_textarea($name, $data, 4, 56, '', $extrafield['field_html']);
            break;
        case 'select':
            $extrafield['field_variants'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_variants']);
            $opt_array = explode(",", $extrafield['field_variants']);
            $ii = 0;
            $options_titles = $options_values = array();
            foreach ($opt_array as $var) {
                $ii++;
                $var = trim($var);
                $options_titles[$ii] = !empty($L[$extrafield['field_name'] . '_' . $var]) ? $L[$extrafield['field_name'] . '_' . $var] : $var;
                $options_values[$ii] = $var;
            }
            $result = cot_selectbox(trim($data), $name, $options_values, $options_titles, false, '', $extrafield['field_html']);
            break;
        case 'radio':
            $extrafield['field_variants'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_variants']);
            $opt_array = explode(",", $extrafield['field_variants']);
            $options_titles = $options_values = array();
            if (count($opt_array) > 0) {
                $ii = 0;
                foreach ($opt_array as $var) {
                    $ii++;
                    $var = trim($var);
                    $options_titles[$ii] = !empty($L[$extrafield['field_name'] . '_' . $var]) ? $L[$extrafield['field_name'] . '_' . $var] : $var;
                    $options_values[$ii] = $var;
                }
            }
            $result = cot_radiobox(trim($data), $name, $options_values, $options_titles, '', '', $extrafield['field_html']);
            break;
        case 'checkbox':
            $result = cot_checkbox($data, $name, $extrafield['field_description'], '', '1', $extrafield['field_html']);
            break;
        case 'datetime':
            global $sys;
            $extrafield['field_params'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_params']);
            list($min, $max, $format) = explode(",", $extrafield['field_params'], 3);
            $max = (int) $max > 0 ? $max : 2030;
            $min = (int) $min > 0 ? $min : 2000;
            $data = mb_substr($data, 0, 1) == "+" ? $sys['now'] + (int) mb_substr($data, 1) : $data;
            $data = mb_substr($data, 0, 1) == "-" ? $sys['now'] - (int) mb_substr($data, 1) : $data;
            $result = cot_selectbox_date((int) $data, 'long', $name, (int) $max, (int) $min, true, $extrafield['field_html']);
            break;
        case 'country':
            global $cot_countries;
            $result = cot_selectbox_countries(trim($data), $name, true, '', $extrafield['field_html']);
            break;
        case 'range':
            $extrafield['field_params'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_params']);
            list($min, $max) = explode(',', $extrafield['field_params'], 2);
            $result = cot_selectbox(trim($data), $name, range((int) $min, (int) $max), range((int) $min, (int) $max), true, '', $extrafield['field_html']);
            break;
        case 'checklistbox':
            $extrafield['field_variants'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_variants']);
            $opt_array = explode(",", $extrafield['field_variants']);
            $options_titles = $options_values = array();
            if (count($opt_array) > 0) {
                $ii = 0;
                foreach ($opt_array as $var) {
                    $ii++;
                    $var = trim($var);
                    $options_titles[$ii] = !empty($L[$extrafield['field_name'] . '_' . $var]) ? $L[$extrafield['field_name'] . '_' . $var] : $var;
                    $options_values[$ii] = $var;
                }
            }
            if (!is_array($data)) {
                $data = trim(str_replace(array(' , ', ', ', ' ,'), ',', $data));
                $data = explode(',', $data);
            }
            $result = cot_checklistbox($data, $name, $options_values, $options_titles, '', '', true, $extrafield['field_html']);
            break;
        case 'file':
            $extrafield['field_params'] = !empty($extrafield['field_params']) ? $extrafield['field_params'] : $cfg['extrafield_files_dir'];
            $extrafield['field_params'] .= mb_substr($extrafield['field_params'], -1) == '/' ? '' : '/';
            $data_filepath = $extrafield['field_params'] . htmlspecialchars($data);
            /* === Hook === */
            foreach (cot_getextplugins('extrafields.build.file') as $pl) {
                include $pl;
            }
            /* ===== */
            $result = cot_filebox($name, htmlspecialchars($data), $data_filepath, 'rdel_' . $name, '', $extrafield['field_html']);
            break;
        default:
            $result = '';
            break;
    }
    return $result;
}
Example #11
0
}
$pag = $row_page;
$pag['page_status'] = cot_page_status($pag['page_state'], $pag['page_begin'], $pag['page_expire']);
cot_block($usr['isadmin'] || $usr['auth_write'] && $usr['id'] == $pag['page_ownerid']);
$out['subtitle'] = $L['page_edittitle'];
$out['head'] .= $R['code_noindex'];
$sys['sublocation'] = $structure['page'][$pag['page_cat']]['title'];
$mskin = cot_tplfile(array('page', 'edit', $structure['page'][$pag['page_cat']]['tpl']));
/* === Hook === */
foreach (cot_getextplugins('page.edit.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
$pageedit_array = array('PAGEEDIT_PAGETITLE' => $L['page_edittitle'], 'PAGEEDIT_SUBTITLE' => $L['page_editsubtitle'], 'PAGEEDIT_FORM_SEND' => cot_url('page', "m=edit&a=update&id=" . $pag['page_id']), 'PAGEEDIT_FORM_ID' => $pag['page_id'], 'PAGEEDIT_FORM_STATE' => $pag['page_state'], 'PAGEEDIT_FORM_STATUS' => $pag['page_status'], 'PAGEEDIT_FORM_LOCALSTATUS' => $L['page_status_' . $pag['page_status']], 'PAGEEDIT_FORM_CAT' => cot_selectbox_structure('page', $pag['page_cat'], 'rpagecat'), 'PAGEEDIT_FORM_CAT_SHORT' => cot_selectbox_structure('page', $pag['page_cat'], 'rpagecat', $c), 'PAGEEDIT_FORM_KEYWORDS' => cot_inputbox('text', 'rpagekeywords', $pag['page_keywords'], array('size' => '32', 'maxlength' => '255')), 'PAGEEDIT_FORM_METATITLE' => cot_inputbox('text', 'rpagemetatitle', $pag['page_metatitle'], array('size' => '64', 'maxlength' => '255')), 'PAGEEDIT_FORM_METADESC' => cot_textarea('rpagemetadesc', $pag['page_metadesc'], 2, 64, array('maxlength' => '255')), 'PAGEEDIT_FORM_ALIAS' => cot_inputbox('text', 'rpagealias', $pag['page_alias'], array('size' => '32', 'maxlength' => '255')), 'PAGEEDIT_FORM_TITLE' => cot_inputbox('text', 'rpagetitle', $pag['page_title'], array('size' => '64', 'maxlength' => '255')), 'PAGEEDIT_FORM_DESC' => cot_textarea('rpagedesc', $pag['page_desc'], 2, 64, array('maxlength' => '255')), 'PAGEEDIT_FORM_AUTHOR' => cot_inputbox('text', 'rpageauthor', $pag['page_author'], array('size' => '24', 'maxlength' => '100')), 'PAGEEDIT_FORM_DATE' => cot_selectbox_date($pag['page_date'], 'long', 'rpagedate') . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_DATENOW' => cot_checkbox(0, 'rpagedatenow'), 'PAGEEDIT_FORM_BEGIN' => cot_selectbox_date($pag['page_begin'], 'long', 'rpagebegin') . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_EXPIRE' => cot_selectbox_date($pag['page_expire'], 'long', 'rpageexpire') . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_UPDATED' => cot_date('datetime_full', $pag['page_updated']) . ' ' . $usr['timetext'], 'PAGEEDIT_FORM_FILE' => cot_selectbox($pag['page_file'], 'rpagefile', range(0, 2), array($L['No'], $L['Yes'], $L['Members_only']), false), 'PAGEEDIT_FORM_URL' => cot_inputbox('text', 'rpageurl', $pag['page_url'], array('size' => '56', 'maxlength' => '255')), 'PAGEEDIT_FORM_SIZE' => cot_inputbox('text', 'rpagesize', $pag['page_size'], array('size' => '56', 'maxlength' => '255')), 'PAGEEDIT_FORM_TEXT' => cot_textarea('rpagetext', $pag['page_text'], 24, 120, '', 'input_textarea_editor'), 'PAGEEDIT_FORM_DELETE' => cot_radiobox(0, 'rpagedelete', array(1, 0), array($L['Yes'], $L['No'])), 'PAGEEDIT_FORM_PARSER' => cot_selectbox($pag['page_parser'], 'rpageparser', cot_get_parsers(), cot_get_parsers(), false));
if ($usr['isadmin']) {
    $pageedit_array += array('PAGEEDIT_FORM_OWNERID' => cot_inputbox('text', 'rpageownerid', $pag['page_ownerid'], array('size' => '24', 'maxlength' => '24')), 'PAGEEDIT_FORM_PAGECOUNT' => cot_inputbox('text', 'rpagecount', $pag['page_count'], array('size' => '8', 'maxlength' => '8')), 'PAGEEDIT_FORM_FILECOUNT' => cot_inputbox('text', 'rpagefilecount', $pag['page_filecount'], array('size' => '8', 'maxlength' => '8')));
}
$t->assign($pageedit_array);
// Extra fields
foreach ($cot_extrafields[$db_pages] as $exfld) {
    $uname = strtoupper($exfld['field_name']);
    $exfld_val = cot_build_extrafields('rpage' . $exfld['field_name'], $exfld, $pag['page_' . $exfld['field_name']]);
    $exfld_title = isset($L['page_' . $exfld['field_name'] . '_title']) ? $L['page_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
    $t->assign(array('PAGEEDIT_FORM_' . $uname => $exfld_val, 'PAGEEDIT_FORM_' . $uname . '_TITLE' => $exfld_title, 'PAGEEDIT_FORM_EXTRAFLD' => $exfld_val, 'PAGEEDIT_FORM_EXTRAFLD_TITLE' => $exfld_title));
    $t->parse('MAIN.EXTRAFLD');
}
// Error and message handling
cot_display_messages($t);
/* === Hook === */
Example #12
0
 /**
  * Создание / редактирование купона
  * @todo произвольный урл баннера
  * @return string
  */
 public function editAction()
 {
     global $admintitle, $adminpath, $structure, $cot_import_filters;
     $adminpath[] = array(cot_url('admin', array('m' => 'brs')), cot::$L['brs_banners']);
     if (empty($structure['brs'])) {
         cot_error(cot::$L['brs_category_no']);
     }
     $id = cot_import('id', 'G', 'INT');
     $act = cot_import('act', 'P', 'ALP');
     if (!$id) {
         $id = 0;
         $item = new brs_model_Banner();
         $admintitle = $title = cot::$L['brs_banner_new'];
         $adminpath[] = array(cot_url('admin', array('m' => 'brs', 'a' => 'edit')), cot::$L['brs_banner_new']);
     } else {
         $item = brs_model_Banner::getById($id);
         if (!$item) {
             cot_error(cot::$L['brs_err_not_found']);
             cot_redirect(cot_url('admin', array('m' => 'brs'), '', true));
         }
         $title = htmlspecialchars($item->title) . ' [' . cot::$L['Edit'] . ']';
         $admintitle = cot::$L['brs_banner_edit'];
         $adminpath[] = array(cot_url('admin', array('m' => 'brs', 'a' => 'edit', 'id' => $id)), $title);
     }
     if ($act == 'save') {
         unset($_POST['id']);
         $data = $_POST;
         $nullDate = date('Y-m-d H:i:s', 0);
         // 1970-01-01 00:00:00
         // Импортируем файл
         $file = brs_importFile('file', $item->file);
         $delFile = cot_import('del_file', 'P', 'BOL') ? 1 : 0;
         if ($delFile) {
             $data['file'] = '';
         }
         // Импортируем даты
         $data['publish_up'] = cot_import_date('publish_up');
         if (!empty($data['publish_up'])) {
             $data['publish_up'] = date('Y-m-d H:i:s', $data['publish_up']);
         } else {
             $data['publish_up'] = $nullDate;
         }
         $data['publish_down'] = cot_import_date('publish_down');
         if (!empty($data['publish_down'])) {
             $data['publish_down'] = date('Y-m-d H:i:s', $data['publish_down']);
         } else {
             $data['publish_down'] = $nullDate;
         }
         $bannerType = cot_import('banner_type', 'P', 'INT');
         unset($data['banner_type']);
         if (isset($data['client'])) {
             $data['client'] = (int) $data['client'];
         }
         // Отключим html-фильтры для установк произвольного кода:
         $tmp = $cot_import_filters['HTM'] = array();
         $item->setData($data);
         if ($bannerType == brs_model_Banner::TYPE_CUSTOM) {
             $item->type = $bannerType;
         }
         $cot_import_filters['HTM'] = $tmp;
         if (!empty($file)) {
             $fileProps = brs_fileProperties($file);
             if (empty($fileProps)) {
                 $item->type = brs_model_Banner::TYPE_UNKNOWN;
                 cot_error(cot::$L['brs_err_inv_file_type'], 'file');
             } else {
                 if (empty($item->width)) {
                     $item->width = $fileProps['width'];
                 }
                 if (empty($item->height)) {
                     $item->height = $fileProps['height'];
                 }
                 if ($item->type != brs_model_Banner::TYPE_CUSTOM) {
                     $item->type = $fileProps['type'];
                 }
                 if ($fileProps['type'] == brs_model_Banner::TYPE_UNKNOWN) {
                     $item->type = brs_model_Banner::TYPE_UNKNOWN;
                     cot_error(cot::$L['brs_err_inv_file_type'], 'file');
                 }
             }
         } elseif ($bannerType != brs_model_Banner::TYPE_CUSTOM) {
             // Если файл не передан
             if ($delFile) {
                 $item->type = brs_model_Banner::TYPE_UNKNOWN;
             } elseif (!empty($item->file)) {
                 $item->type = brs_type($item->file);
             }
         }
         $item->validate();
         $backUrl = array('m' => 'brs', 'a' => 'edit');
         if ($item->id > 0) {
             $backUrl['id'] = $item->id;
         }
         if (!cot_error_found()) {
             if (!empty($file)) {
                 $item->file = $file;
             }
             if ($id = $item->save()) {
                 cot_message(cot::$L['Saved']);
             } else {
                 // Удалим загруженный файл
                 if (!empty($file) && file_exists($file)) {
                     unlink($file);
                 }
             }
             $backUrl['id'] = $item->id;
             cot_redirect(cot_url('admin', $backUrl, '', true));
         } else {
             // Удалим загруженный файл
             if (!empty($file) && file_exists($file)) {
                 unlink($file);
             }
             cot_redirect(cot_url('admin', $backUrl, '', true));
         }
     }
     $deleteUrl = '';
     if ($item->id > 0) {
         $deleteUrl = cot_confirm_url(cot_url('admin', array('m' => 'brs', 'a' => 'delete', 'id' => $item->id)), 'admin');
     }
     $types = array('0' => cot::$L['brs_type_file'], brs_model_Banner::TYPE_CUSTOM => cot::$L['brs_custom_code']);
     $clients = brs_model_Client::keyValPairs();
     if (!$clients) {
         $clients = array();
     }
     $purchase = array(brs_model_Client::PURCHASE_DEFAULT => cot::$L['brs_client_default'], brs_model_Client::PURCHASE_UNLIMITED => cot::$L['brs_unlimited'], brs_model_Client::PURCHASE_YEARLY => cot::$L['brs_pt_yearly'], brs_model_Client::PURCHASE_MONTHLY => cot::$L['brs_pt_monthly'], brs_model_Client::PURCHASE_WEEKLY => cot::$L['brs_pt_weekly'], brs_model_Client::PURCHASE_DAILY => cot::$L['brs_pt_daily']);
     $track = array(-1 => cot::$L['brs_client_default'], 0 => cot::$L['No'], 1 => cot::$L['Yes']);
     $formFile = cot_inputbox('file', 'file', $item->file);
     if (!empty($item->file)) {
         $formFile .= cot_checkbox(false, 'del_file', cot::$L['Delete']);
     }
     $published = $item->published;
     if ($item->id == 0 && !isset($_POST['published'])) {
         $published = 1;
     }
     $showForm = true;
     if (empty($structure['brs'])) {
         $showForm = false;
     }
     $bannerType = 0;
     if ($item->type == brs_model_Banner::TYPE_CUSTOM) {
         $bannerType = brs_model_Banner::TYPE_CUSTOM;
     }
     /* === Hook === */
     foreach (cot_getextplugins('brs.admin.edit.main') as $pl) {
         include $pl;
     }
     /* ===== */
     $formElements = array('hidden' => array('element' => cot_inputbox('hidden', 'act', 'save')), 'title' => array('element' => cot_inputbox('text', 'title', $item->rawValue('title')), 'required' => true, 'label' => brs_model_Banner::fieldLabel('title')), 'category' => array('element' => cot_selectbox_structure('brs', $item->rawValue('category'), 'category', '', false, false), 'required' => true, 'label' => brs_model_Banner::fieldLabel('category')), 'type' => array('element' => cot_selectbox($bannerType, 'banner_type', array_keys($types), array_values($types), false), 'label' => brs_model_Banner::fieldLabel('type')), 'file' => array('element' => $formFile, 'label' => brs_model_Banner::fieldLabel('file')), 'width' => array('element' => cot_inputbox('text', 'width', $item->width), 'label' => brs_model_Banner::fieldLabel('width')), 'height' => array('element' => cot_inputbox('text', 'height', $item->height), 'label' => brs_model_Banner::fieldLabel('height')), 'alt' => array('element' => cot_inputbox('text', 'alt', $item->alt), 'label' => brs_model_Banner::fieldLabel('alt')), 'customcode' => array('element' => cot_textarea('customcode', $item->customcode, 5, 60), 'label' => brs_model_Banner::fieldLabel('customcode')), 'clickurl' => array('element' => cot_inputbox('text', 'clickurl', $item->clickurl), 'label' => brs_model_Banner::fieldLabel('clickurl')), 'description' => array('element' => cot_textarea('description', $item->description, 5, 60), 'label' => brs_model_Banner::fieldLabel('description')), 'sticky' => array('element' => cot_checkbox($item->sticky, 'sticky', brs_model_Banner::fieldLabel('sticky')), 'hint' => cot::$L['brs_sticky_tip']), 'publish_up' => array('element' => cot_selectbox_date(cot_date2stamp($item->publish_up, 'auto'), 'long', 'publish_up'), 'label' => brs_model_Banner::fieldLabel('publish_up')), 'publish_down' => array('element' => cot_selectbox_date(cot_date2stamp($item->publish_down, 'auto'), 'long', 'publish_down'), 'label' => brs_model_Banner::fieldLabel('publish_down')), 'imptotal' => array('element' => cot_inputbox('text', 'imptotal', $item->imptotal), 'label' => brs_model_Banner::fieldLabel('imptotal'), 'hint' => '0 - ' . cot::$L['brs_unlimited']), 'impressions' => array('element' => cot_inputbox('text', 'impressions', $item->impressions), 'label' => brs_model_Banner::fieldLabel('impressions')), 'clicks' => array('element' => cot_inputbox('text', 'clicks', $item->clicks), 'label' => brs_model_Banner::fieldLabel('clicks')), 'client' => array('element' => cot_selectbox($item->rawValue('client'), 'client', array_keys($clients), array_values($clients), true), 'label' => brs_model_Banner::fieldLabel('client')), 'purchase_type' => array('element' => cot_selectbox($item->rawValue('purchase_type'), 'purchase_type', array_keys($purchase), array_values($purchase), false), 'label' => brs_model_Banner::fieldLabel('purchase_type')), 'track_impressions' => array('element' => cot_selectbox($item->rawValue('track_impressions'), 'track_impressions', array_keys($track), array_values($track), false), 'label' => brs_model_Banner::fieldLabel('track_impressions'), 'hint' => cot::$L['brs_track_impressions_hint']), 'track_clicks' => array('element' => cot_selectbox($item->rawValue('track_clicks'), 'track_clicks', array_keys($track), array_values($track), false), 'label' => brs_model_Banner::fieldLabel('track_clicks'), 'hint' => cot::$L['brs_track_clicks_hint']), 'published' => array('element' => cot_checkbox($published, 'published', brs_model_Banner::fieldLabel('published'))));
     // Превью загруженного файла
     $banner_image = '';
     if (!empty($item->file)) {
         $type = $item->type;
         $imgArr = array(brs_model_Banner::TYPE_IMAGE, brs_model_Banner::TYPE_FLASH);
         if (in_array($item->type, $imgArr)) {
             $w = $item->width;
             $h = $item->height;
         } else {
             $fileProps = brs_fileProperties($item->file);
             if (!empty($fileProps)) {
                 $type = $fileProps['type'];
                 $w = $fileProps['width'];
                 $h = $fileProps['height'];
             }
         }
         if (in_array($type, $imgArr)) {
             // расчитаем размеры картинки:
             if ($h > 100) {
                 $k = $w / $h;
                 $h = 100;
                 $w = intval($h * $k);
             }
             if ($type == brs_model_Banner::TYPE_IMAGE) {
                 $rc = 'banner_image_admin';
             } elseif ($type == brs_model_Banner::TYPE_FLASH) {
                 $rc = 'banner_flash_admin';
             }
             $image = cot_rc($rc, array('file' => $item->file, 'alt' => $item->alt, 'width' => $w, 'height' => $h));
             $banner_image = cot_rc('admin_banner', array('banner' => $image));
         } else {
             // Просто выведем путь к файлу:
             $banner_image = cot_rc('admin_banner', array('banner' => $item->file));
         }
     }
     // /Превью загруженного файла
     $actionParams = array('m' => 'brs', 'a' => 'edit');
     if ($item->id > 0) {
         $actionParams['id'] = $item->id;
     }
     $template = array('brs', 'admin', 'edit');
     $view = new View();
     $view->page_title = $title;
     $view->showForm = $showForm;
     $view->item = $item;
     $view->deleteUrl = $deleteUrl;
     $view->banner_image = $banner_image;
     $view->formElements = $formElements;
     $view->formAction = cot_url('admin', $actionParams);
     /* === Hook === */
     foreach (cot_getextplugins('brs.admin.edit.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }