/** * Save Poll form * * @param string $type Poll type * @param int $code Poll Code * @return bool * @global CotDB $db */ function cot_poll_save($type = 'index', $code = '') { global $db, $sys, $db_polls, $db_polls_options, $poll_id, $poll_text, $poll_multiple, $poll_state, $poll_options; if (isset($poll_id) && !cot_error_found() && $poll_options) { if ((int) $poll_id > 0) { $db->update($db_polls, array('poll_state' => (int) $poll_state, 'poll_text' => $poll_text, 'poll_multiple' => (int) $poll_multiple), "poll_id = " . (int) $poll_id); $newpoll_id = (int) $poll_id; } else { $db->insert($db_polls, array('poll_type' => $type, 'poll_state' => (int) 0, 'poll_creationdate' => (int) $sys['now'], 'poll_text' => $poll_text, 'poll_multiple' => (int) $poll_multiple, 'poll_code' => (int) $code)); $newpoll_id = $db->lastInsertId(); } foreach ($poll_options as $key => $val) { if (!empty($val)) { $key = mb_substr($key, 2); if ((int) $key > 0 && (int) $poll_id > 0) { $db->update($db_polls_options, array('po_text' => $val), "po_id = '" . (int) $key . "'"); $ids[] = $key; } else { $db->insert($db_polls_options, array('po_pollid' => $newpoll_id, 'po_text' => $val, 'po_count' => 0)); $ids[] = $db->lastInsertId(); } } } if ((int) $poll_id > 0 && count($ids) > 0) { $sql = $db->delete($db_polls_options, "po_pollid = '" . (int) $newpoll_id . "' AND po_id NOT IN ('" . implode("','", $ids) . "')"); } return $newpoll_id; } return false; }
<?php /** * [BEGIN_COT_EXT] * Hooks=users.register.add.validate * [END_COT_EXT] */ /** * plugin User Group Selector for Cotonti Siena * * @package usergroupselector * @version 1.0.0 * @author CMSWorks Team * @copyright Copyright (c) CMSWorks.ru, littledev.ru * @license BSD * */ defined('COT_CODE') or die('Wrong URL.'); require_once cot_langfile('usergroupselector', 'plug'); $usergroup = cot_import('usergroup', 'G', 'ALP'); if (cot_error_found() && !empty($usergroup)) { cot_redirect(cot_url('users', 'm=register&usergroup=' . $usergroup, '', true)); }
exit; } if ($a == 'addpost') { cot_shield_protect(); $offer_post['post_pid'] = (int) $id; $offer_post['post_oid'] = (int) cot_import('oid', 'G', 'INT'); $offer_post['post_userid'] = (int) $usr['id']; $offer_post['post_date'] = (int) $sys['now']; $offer_post['post_text'] = cot_import('posttext', 'P', 'TXT'); $offer = $db->query("SELECT * FROM {$db_projects_offers} AS o \n\t\tLEFT JOIN {$db_users} AS u ON u.user_id=o.offer_userid\n\t\tWHERE offer_id=" . $offer_post['post_oid'] . " LIMIT 1")->fetch(); /* === Hook === */ foreach (cot_getextplugins('projects.offers.addpost.error') as $pl) { include $pl; } /* ===== */ if (!empty($offer_post['post_text']) && (in_array($usr['id'], array($offer['offer_userid'], $item['item_userid'])) || $usr['isadmin']) && !cot_error_found()) { $db->insert($db_projects_posts, $offer_post); if ($usr['id'] == $offer['offer_userid']) { $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']); $rsubject = cot_rc($L['project_added_post_header'], array('prtitle' => $item['item_title'])); $rbody = cot_rc($L['project_added_post_body'], array('user_name' => $item['user_name'], 'postuser_name' => $usr['profile']['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', $urlparams, '', true))); cot_mail($item['user_email'], $rsubject, $rbody); } else { $urlparams = empty($item['item_alias']) ? array('c' => $item['item_cat'], 'id' => $item['item_id']) : array('c' => $item['item_cat'], 'al' => $item['item_alias']); $rsubject = cot_rc($L['project_added_post_header'], array('prtitle' => $item['item_title'])); $rbody = cot_rc($L['project_added_post_body'], array('user_name' => $offer['user_name'], 'postuser_name' => $usr['profile']['user_name'], 'prj_name' => $item['item_title'], 'sitename' => $cfg['maintitle'], 'link' => COT_ABSOLUTE_URL . cot_url('projects', $urlparams, '', true))); cot_mail($offer['user_email'], $rsubject, $rbody); } cot_message($L['offers_add_post'], 'ok'); /* === Hook === */ foreach (cot_getextplugins('projects.offers.addpost.done') as $pl) {
/** * [BEGIN_COT_EXT] * Hooks=search.list * [END_COT_EXT] */ /** * projects module * * @package projects * @version 2.5.2 * @author CMSWorks Team * @copyright Copyright (c) CMSWorks.ru, littledev.ru * @license BSD */ defined('COT_CODE') or die('Wrong URL.'); if ($cfg['projects']['prjsearch'] && ($tab == 'projects' || empty($tab)) && cot_module_active('projects') && !cot_error_found()) { if ($rs['projectssub'][0] != 'all' && count($rs['projectssub']) > 0) { if ($rs['projectssubcat']) { $tempcat = array(); foreach ($rs['projectssub'] as $scat) { $tempcat = array_merge(cot_structure_children('projects', $scat), $tempcat); } $tempcat = array_unique($tempcat); $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')"; } else { $tempcat = array(); foreach ($rs['projectssub'] as $scat) { $tempcat[] = $db->prep($scat); } $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')"; }
/** * Updates a page in the CMS. * @param integer $id Page ID * @param array $rpage Page data * @param array $auth Permissions array * @return boolean TRUE on success, FALSE on error */ function cot_page_update($id, &$rpage, $auth = array()) { global $cache, $cfg, $db, $db_pages, $db_structure, $structure, $L; if (cot_error_found()) { return false; } if (count($auth) == 0) { $auth = cot_page_auth($rpage['page_cat']); } if (!empty($rpage['page_alias'])) { $page_count = $db->query("SELECT COUNT(*) FROM {$db_pages} WHERE page_alias = ? AND page_id != ?", array($rpage['page_alias'], $id))->fetchColumn(); if ($page_count > 0) { $rpage['page_alias'] = $rpage['page_alias'] . rand(1000, 9999); } } $row_page = $db->query("SELECT * FROM {$db_pages} WHERE page_id = ?", $id)->fetch(); if ($row_page['page_cat'] != $rpage['page_cat'] && $row_page['page_state'] == 0) { $db->query("UPDATE {$db_structure} SET structure_count=structure_count-1 WHERE structure_code = ? AND structure_area = 'page'", $row_page['page_cat']); } //$usr['isadmin'] = cot_auth('page', $rpage['page_cat'], 'A'); if ($rpage['page_state'] == 0) { if ($auth['isadmin'] && $cfg['page']['autovalidate']) { if ($row_page['page_state'] != 0 || $row_page['page_cat'] != $rpage['page_cat']) { $db->query("UPDATE {$db_structure} SET structure_count=structure_count+1 WHERE structure_code = ? AND structure_area = 'page'", $rpage['page_cat']); } } else { $rpage['page_state'] = 1; } } if ($rpage['page_state'] != 0 && $row_page['page_state'] == 0) { $db->query("UPDATE {$db_structure} SET structure_count=structure_count-1 WHERE structure_code = ?", $rpage['page_cat']); } $cache && $cache->db->remove('structure', 'system'); if (!$db->update($db_pages, $rpage, 'page_id = ?', $id)) { return false; } cot_extrafield_movefiles(); /* === Hook === */ foreach (cot_getextplugins('page.edit.update.done') as $pl) { include $pl; } /* ===== */ if (($rpage['page_state'] == 0 || $rpage['page_cat'] != $row_page['page_cat']) && $cache) { if ($cfg['cache_page']) { $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$rpage['page_cat']]['path'])); if ($rpage['page_cat'] != $row_page['page_cat']) { $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$row_page['page_cat']]['path'])); } } if ($cfg['cache_index']) { $cache->page->clear('index'); } } return true; }
/** * Updates a product in the CMS. * @param integer $id Product ID * @param array $ritem Product data * @param array $auth Permissions array * @return boolean TRUE on success, FALSE on error */ function cot_market_update($id, &$ritem, $auth = array()) { global $cache, $cfg, $db, $db_market, $db_structure, $structure, $L; if (cot_error_found()) { return false; } if (count($auth) == 0) { $auth = cot_market_auth($ritem['item_cat']); } if (!empty($ritem['item_alias'])) { $prd_count = $db->query("SELECT COUNT(*) FROM {$db_market} WHERE item_alias = ? AND item_id != ?", array($ritem['item_alias'], $id))->fetchColumn(); if ($prd_count > 0) { $ritem['item_alias'] = $ritem['item_alias'] . rand(1000, 9999); } } $item = $db->query("SELECT * FROM {$db_market} WHERE item_id = ?", $id)->fetch(); if (!$cfg['market']['preview']) { $ritem['item_state'] = !$cfg['market']['prevalidate'] || $auth['isadmin'] ? 0 : 2; } else { $ritem['item_state'] = 1; } if (!$db->update($db_market, $ritem, 'item_id = ?', $id)) { return false; } cot_market_sync($item['item_cat']); cot_market_sync($ritem['item_cat']); cot_extrafield_movefiles(); /* === Hook === */ foreach (cot_getextplugins('market.edit.update.done') as $pl) { include $pl; } /* ===== */ return true; }
/** * [BEGIN_COT_EXT] * Hooks=search.list * [END_COT_EXT] */ /** * market module * * @package market * @version 2.5.2 * @author CMSWorks Team * @copyright Copyright (c) CMSWorks.ru, littledev.ru * @license BSD */ defined('COT_CODE') or die('Wrong URL.'); if ($cfg['market']['marketsearch'] && ($tab == 'market' || empty($tab)) && cot_module_active('market') && !cot_error_found()) { if ($rs['marketsub'][0] != 'all' && count($rs['marketsub']) > 0) { if ($rs['marketsubcat']) { $tempcat = array(); foreach ($rs['marketsub'] as $scat) { $tempcat = array_merge(cot_structure_children('market', $scat), $tempcat); } $tempcat = array_unique($tempcat); $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')"; } else { $tempcat = array(); foreach ($rs['marketsub'] as $scat) { $tempcat[] = $db->prep($scat); } $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')"; }
<?php /* ==================== [BEGIN_COT_EXT] Hooks=forums.editpost.update.done [END_COT_EXT] ==================== */ /** * Polls * * @package Polls * @copyright (c) Cotonti Team * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt */ defined('COT_CODE') or die('Wrong URL'); if (!empty($poll) && $poll_id && $is_first_post && !cot_error_found()) { $number = cot_poll_save(); }
/** * Редактирование рассылки * @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); }
<?php /* ==================== [BEGIN_COT_EXT] Hooks=admin.extensions.install.tags [END_COT_EXT] ==================== */ /** * Adds i18n support to tags when installing the tags plugin after i18n * * @package I18n * @copyright (c) Cotonti Team * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt */ defined('COT_CODE') or die('Wrong URL'); if ($code == 'tags' && $result && !cot_error_found()) { include $cfg['plugins_dir'] . '/i18n/setup/i18n.install.php'; }
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'])); }
} elseif ($ret === false) { cot_error(cot_rc('ext_update_error', array('type' => $L['Module'], 'name' => $code))); } } } if (count($cot_plugins_enabled) > 0) { foreach ($cot_plugins_enabled as $code => $plug) { $ret = cot_extension_install($code, false, true); if ($ret === true) { $updated_ext = true; } elseif ($ret === false) { cot_error(cot_rc('ext_update_error', array('type' => $L['Plugin'], 'name' => $code))); } } } if ($new_rev === false || cot_error_found()) { // Display error message $t->assign('UPDATE_TITLE', $L['install_update_error']); } elseif ($new_rev === true && !$updated_config && !$updated_ext) { $t->assign('UPDATE_TITLE', $L['install_update_nothing']); $t->assign('UPDATE_COMPLETED_NOTE', ''); $t->parse('MAIN.COMPLETED'); } else { if ($new_rev === true) { $new_rev = $rev; } else { $db->update($db_updates, array('upd_value' => $new_rev), "upd_param = 'revision'"); } $t->assign('UPDATE_TITLE', cot_rc('install_update_success', array('rev' => $new_rev))); $t->assign('UPDATE_COMPLETED_NOTE', $L['install_complete_note']); $t->parse('MAIN.COMPLETED');
/** * [BEGIN_COT_EXT] * Hooks=search.list * [END_COT_EXT] */ /** * folio module * * @package folio * @version 2.5.2 * @author CMSWorks Team * @copyright Copyright (c) CMSWorks.ru, littledev.ru * @license BSD */ defined('COT_CODE') or die('Wrong URL.'); if ($cfg['folio']['foliosearch'] && ($tab == 'folio' || empty($tab)) && cot_module_active('folio') && !cot_error_found()) { if ($rs['foliosub'][0] != 'all' && count($rs['foliosub']) > 0) { if ($rs['foliosubcat']) { $tempcat = array(); foreach ($rs['foliosub'] as $scat) { $tempcat = array_merge(cot_structure_children('folio', $scat), $tempcat); } $tempcat = array_unique($tempcat); $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')"; } else { $tempcat = array(); foreach ($rs['foliosub'] as $scat) { $tempcat[] = $db->prep($scat); } $where_and['cat'] = "item_cat IN ('" . implode("','", $tempcat) . "')"; }
$rstructure['structure_title'] || cot_error('adm_structure_title_required', 'rstructuretitle'); if (!empty($rtplquick)) { $rstructure['structure_tpl'] = $rtplquick; } elseif ($rtplmode == 3) { $rstructure['structure_tpl'] = cot_import('rtplforced', 'P', 'TXT'); } elseif ($rtplmode == 2) { $rstructure['structure_tpl'] = 'same_as_parent'; } else { $rstructure['structure_tpl'] = ''; } /* === Hook === */ foreach (cot_getextplugins('admin.structure.add.first') as $pl) { include $pl; } /* ===== */ if (!cot_error_found()) { $res = cot_structure_add($n, $rstructure, $is_module); if ($res === true) { cot_extrafield_movefiles(); /* === Hook === */ foreach (cot_getextplugins('admin.structure.add.done') as $pl) { include $pl; } /* ===== */ cot_message('Added'); } elseif (is_array($res)) { cot_error($res[0], $res[1]); } else { cot_error('Error'); } }
/** * Displays redirect page * * @param string $url Target URI */ function cot_redirect($url) { global $cfg, $env, $error_string, $sys; if (cot_error_found() && $_SERVER['REQUEST_METHOD'] == 'POST') { // Save the POST data if (!empty($error_string)) { // Message should not be lost cot_error($error_string); } cot_import_buffer_save(); } if (!cot_url_check($url)) { // No redirects to foreign domains if ($url == '/' || $url == $sys['site_uri']) { $url = COT_ABSOLUTE_URL; } else { if ($url[0] === '/') { $url = mb_substr($url, 1); } $url = COT_ABSOLUTE_URL . $url; } } if (defined('COT_AJAX') && COT_AJAX) { // Save AJAX state, some browsers loose it after redirect (e.g. FireFox 3.6) $sep = strpos($url, '?') === false ? '?' : '&'; $url .= $sep . '_ajax=1'; } if (isset($env['status'])) { $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; header($protocol . ' ' . $env['status']); } if ($cfg['redirmode']) { $output = $cfg['doctype'] . <<<HTM \t\t<html> \t\t<head> \t\t<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> \t\t<meta http-equiv="refresh" content="0; url={$url}" /> \t\t<title>Redirecting...</title></head> \t\t<body>Redirecting to <a href="{$url}">{$url}</a> \t\t</body> \t\t</html> HTM; header('Refresh: 0; URL=' . $url); echo $output; exit; } else { header('Location: ' . $url); exit; } }
/* === Hook === */ foreach (cot_getextplugins('i18n.page.translate.tags') as $pl) { include $pl; } /* =============*/ } elseif ($a == 'edit' && $pag_i18n && ($i18n_admin || $i18n_edit || $usr['id'] == $pag_i18n['ipage_translatorid'])) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Update the translation $pag_i18n['ipage_date'] = $sys['now']; $pag_i18n['ipage_title'] = cot_import('title', 'P', 'TXT'); if (mb_strlen($pag_i18n['ipage_title']) < 2) { cot_error('page_titletooshort', 'rpagetitle'); } $pag_i18n['ipage_desc'] = cot_import('desc', 'P', 'TXT'); $pag_i18n['ipage_text'] = cot_import('translate_text', 'P', 'HTM'); if (cot_error_found()) { cot_redirect(cot_url('plug', "e=i18n&m=page&a=edit&id={$id}&l={$i18n_locale}", '', true)); exit; } $db->update($db_i18n_pages, $pag_i18n, "ipage_id = ? AND ipage_locale = ?", array($id, $i18n_locale)); /* === Hook === */ foreach (cot_getextplugins('i18n.page.edit.update') as $pl) { include $pl; } /* =============*/ cot_message('Updated'); $page_urlp = empty($pag['page_alias']) ? 'c=' . $pag['page_cat'] . "&id={$id}&l={$i18n_locale}" : 'c=' . $pag['page_cat'] . '&al=' . $pag['page_alias'] . '&l=' . $i18n_locale; cot_redirect(cot_url('page', $page_urlp, '', true, false, true)); } $out['subtitle'] = $L['i18n_editing']; $t = new XTemplate(cot_tplfile('i18n.page', 'plug'));
/** * Создание / редактирование купона * @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); }