Beispiel #1
0
 private function parsePageContent($page)
 {
     if ($page instanceof ormPage && $page->active) {
         page::assign('page_id', $page->id);
         $pages = ormPages::getActiveId();
         while (list($num, $id) = each($pages)) {
             page::assign('page_id' . $num, $id);
         }
         page::globalVar('h1', $page->h1);
         page::globalVar('title', $page->title);
         if ($page->keywords) {
             page::globalVar('keywords', $page->keywords);
         }
         if ($page->description) {
             page::globalVar('description', $page->description);
         }
         if ($page->template2_id != 0) {
             $content = page::macros('structure')->objView($page->id);
         } else {
             $content = $page->content;
         }
         $templ_name = ($templ = templates::get($page->template_id)) ? $templ->getFile() : 'default';
         system::$defTemplate = '/structure/' . $templ_name . '.tpl';
         if (empty($content)) {
             $content = ' ';
         }
         return $content;
     }
 }
Beispiel #2
0
 /**
  * @return stirng
  * @param string $templ_name - Шаблон оформления
  * @desc МАКРОС: Выводит форму подписки на рассылки
  */
 function form($templ_name = 'default')
 {
     $templ_file = '/subscription/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('subscription.form', $templ_file);
     }
     $list = '';
     $sel = new ormSelect('subscription');
     $sel->where('lang', '=', languages::curId());
     $sel->where('domain', '=', domains::curId());
     $sel->where('active', '=', 1);
     $num = 0;
     while ($obj = $sel->getObject()) {
         page::assign('obj.id', $obj->id);
         page::assign('obj.name', $obj->name);
         $num++;
         page::assign('obj.num', $num);
         page::assign('class-first', $num == 1 ? 'first' : '');
         page::assign('class-last', $num == $sel->getObjectCount() ? 'last' : '');
         page::assign('class-odd', $num % 2 == 0 ? 'odd' : '');
         page::assign('class-even', $num % 2 != 0 ? 'even' : '');
         page::assign('class-third', $num % 3 == 0 ? 'third' : '');
         $list .= page::parse($TEMPLATE['list']);
     }
     // Парсим текст сообщения об ошибке
     page::parseError('subscription');
     if (empty($list)) {
         return page::parse($TEMPLATE['empty']);
     } else {
         page::assign('list', $list);
         return page::parse($TEMPLATE['frame']);
     }
 }
Beispiel #3
0
 public function addAction()
 {
     if (user::isGuest() && reg::getKey('/comments/only_reg')) {
         system::stop();
     }
     if (user::isGuest() && !system::validCapcha('random_image')) {
         system::json(array('error' => 1, 'data' => lang::get('FEEDBACK_ERROR1')));
     }
     // Добавляем новый комментарий
     $comment = new comment();
     $comment->setParentId(system::POST('parent_id'));
     $comment->setObjId(system::POST('obj_id'));
     $comment->setUserName(system::POST('username'));
     $comment->setEmail(system::POST('email'));
     $comment->setText(system::POST('text'));
     $comment->setSendEmail(system::POST('send_email'));
     $obj_id = $comment->save();
     if ($obj_id) {
         page::assign('current_url', system::POST('back_url'));
         $html = page::macros('comments')->view($comment->id());
         system::json(array('error' => 0, 'data' => $html));
     } else {
         system::json(array('error' => 2, 'data' => $comment->getErrorListText(' ')));
     }
     if (!empty($_POST['back_url']) && !system::isAjax()) {
         system::redirect($_POST['back_url'] . '#comment' . $obj_id, true);
     } else {
         system::stop();
     }
 }
Beispiel #4
0
 public function defAction()
 {
     if (file_exists(MODUL_DIR . '/users/template/settings.tpl')) {
         include MODUL_DIR . '/users/template/settings.tpl';
     }
     ui::newButton(lang::get('BTN_SAVE_ONLY'), "javascript:sendForm('save');");
     page::assignArray(lang::get('USERS_FORM_FIELD'));
     page::assign('errorCountBlock', reg::getKey('/users/errorCountBlock'));
     // page::assign('errorCountCapcha', reg::getKey('/users/errorCountCapcha'));
     ui::CheckBox('gzip', 1, reg::getKey('/core/gzip'), lang::get('USERS_FORM_FIELD', 9));
     ui::CheckBox('reg', 1, reg::getKey('/users/reg'), lang::get('USERS_FORM_FIELD', 11));
     ui::CheckBox('activation', 1, reg::getKey('/users/activation'), lang::get('USERS_FORM_FIELD', 28));
     ui::CheckBox('confirm', 1, reg::getKey('/users/confirm'), lang::get('USERS_FORM_FIELD', 35));
     ui::CheckBox('ask_email', 1, reg::getKey('/users/ask_email'), lang::get('USERS_FORM_FIELD', 9));
     //авторизация чере соц. сети
     ui::CheckBox('twitter_bool', 1, reg::getKey('/users/twitter_bool'), lang::get('USERS_FORM_FIELD', 40));
     page::assign('twitter_id', reg::getKey('/users/twitter_id'));
     page::assign('twitter_secret', reg::getKey('/users/twitter_secret'));
     ui::CheckBox('vk_bool', 1, reg::getKey('/users/vk_bool'), lang::get('USERS_FORM_FIELD', 42));
     page::assign('vk_id', reg::getKey('/users/vk_id'));
     page::assign('vk_secret', reg::getKey('/users/vk_secret'));
     ui::CheckBox('ok_bool', 1, reg::getKey('/users/ok_bool'), lang::get('USERS_FORM_FIELD', 45));
     page::assign('ok_id', reg::getKey('/users/ok_id'));
     page::assign('ok_public', reg::getKey('/users/ok_public'));
     page::assign('ok_secret', reg::getKey('/users/ok_secret'));
     ui::CheckBox('facebook_bool', 1, reg::getKey('/users/facebook_bool'), lang::get('USERS_FORM_FIELD', 41));
     page::assign('facebook_id', reg::getKey('/users/facebook_id'));
     page::assign('facebook_secret', reg::getKey('/users/facebook_secret'));
     ui::CheckBox('yandex_bool', 1, reg::getKey('/users/yandex_bool'), lang::get('USERS_FORM_FIELD', 43));
     ui::CheckBox('google_bool', 1, reg::getKey('/users/google_bool'), lang::get('USERS_FORM_FIELD', 44));
     return page::parse($TEMPLATE['frame']);
 }
Beispiel #5
0
 function upd()
 {
     // Устанавливаем кнопки для формы
     ui::setCancelButton('/comments/list');
     ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
     ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
     if (file_exists(MODUL_DIR . '/comments/template/comment.tpl')) {
         include MODUL_DIR . '/comments/template/comment.tpl';
     }
     if (!($obj = comments::get(system::url(2)))) {
         system::redirect('/comments/list');
     }
     if ($obj->getUserId() != 0 && user::issetRight('user_upd', 'users')) {
         $url = system::au() . '/users/user_upd/' . $obj->getUserId();
         page::assign('user_link', $url);
         page::fParse('user_name', $TEMPLATE['user_link']);
     } else {
         page::fParse('user_name', $TEMPLATE['user_name']);
     }
     page::assign('obj.id', $obj->id());
     page::assign('obj.username', $obj->getUserName());
     page::assign('obj.email', $obj->getEmail());
     page::assign('obj.text', $obj->getText());
     page::assign('obj.date', date('d.m.Y H:i', strtotime($obj->getPublDate())));
     page::assign('obj.parram', $obj->getParram());
     ui::CheckBox('active', 1, $obj->isActive(), 'Проверен');
     // Информация о странице
     if ($page = ormPages::get($obj->getObjId())) {
         page::assign('page.id', $page->id);
         page::assign('page.url', $page->url);
         page::assign('page.name', $page->name);
     }
     return page::parse($TEMPLATE['frame']);
 }
Beispiel #6
0
 public function proc_upd()
 {
     $obj = ormPages::get(system::POST('obj_id'));
     $obj->tabuList('pseudo_url', 'h1', 'keywords', 'title', 'description', 'active', 'is_home_page', 'view_in_menu', 'view_submenu', 'in_search', 'in_index', 'in_new_window', 'other_link', 'img_act', 'img_no_act', 'img_h1');
     $obj->loadFromPost();
     // Публикация на сайте
     if (system::POST('publ', isBool)) {
         if ($obj->isInheritor('faq') && $obj->newVal('answer') == '') {
             ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), lang::get('FEEDBACK_MSG_3'));
             ui::selectErrorFields(array('select' => '', 'focus' => 'answer'));
         } else {
             $obj->active = 1;
         }
     }
     $obj_id = $obj->save();
     // Если объект не сохранился, выводим пользователю текст ошибки.
     if ($obj_id === false) {
         system::savePostToSession();
         ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), $obj->getErrorListText());
         ui::selectErrorFields($obj->getErrorFields());
         system::redirect('/feedback/message_upd/' . $_POST['obj_id']);
     }
     if (system::POST('send_to_email', isBool) && !$obj->send_answer_to_user && ($form_obj = ormObjects::get($obj->form_id))) {
         if ($form_obj->send_answer) {
             if ($obj->answer != '') {
                 $fields = $obj->getClass()->loadFields();
                 while (list($num, $field) = each($fields)) {
                     if (!empty($field['f_sname'])) {
                         page::assign($field['f_sname'], $obj->__get($field['f_sname']));
                     }
                 }
                 page::assign('site_name', domains::curDomain()->getSiteName());
                 page::assign('base_email', domains::curDomain()->getEmail());
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->answer_sender_address);
                 $mail->FromName = $this->parse($form_obj->answer_sender_name);
                 $mail->AddAddress($obj->email);
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->answer_subject);
                 $mail->Body = $this->parse($form_obj->answer_template);
                 $mail->Send();
                 // Помечаем, что ответ отправлен
                 $obj->send_answer_to_user = 1;
                 $obj->save();
                 ui::MessageBox(lang::get('FEEDBACK_MSG_1'), '');
             } else {
                 ui::MessageBox(lang::get('TEXT_MESSAGE_ERROR'), lang::get('FEEDBACK_MSG_2'));
                 ui::selectErrorFields(array('select' => '', 'focus' => 'answer'));
             }
         }
     }
     // Если данные изменились корректно перенаправляем на соответствующию страницу
     if ($_POST['parram'] == 'apply') {
         system::redirect('/feedback/message_upd/' . $obj_id);
     } else {
         system::redirect('/feedback');
     }
 }
Beispiel #7
0
 public function unsubscribeAction()
 {
     if (system::issetUrl(2) && system::issetUrl(3)) {
         if (($obj = ormObjects::get(system::url(2))) && $obj->isInheritor('subscription')) {
             mailingProcess::delEmailById(system::url(3), $obj->id);
             page::assign('name', $obj->name);
             return page::parse(lang::get('SUBSCRIPTION_MSG2'));
         }
     }
     return ormPages::get404();
 }
Beispiel #8
0
 public function defAction()
 {
     if (file_exists(MODUL_DIR . '/subscription/template/settings.tpl')) {
         include MODUL_DIR . '/subscription/template/settings.tpl';
     }
     ui::newButton(lang::get('BTN_SAVE_ONLY'), "javascript:sendForm('save');");
     page::assignArray(lang::get('SUBSCRIBE_TEXT_SETTINGS'));
     page::assign('count_mails_day', reg::getKey('/subscription/count_mails_day'));
     page::assign('count_mails', reg::getKey('/subscription/count_mails'));
     return page::parse($TEMPLATE['frame']);
 }
Beispiel #9
0
 public function defAction()
 {
     if (file_exists(MODUL_DIR . '/comments/template/settings.tpl')) {
         include MODUL_DIR . '/comments/template/settings.tpl';
     }
     ui::newButton(lang::get('BTN_SAVE_ONLY'), "javascript:sendForm('save');");
     page::assignArray(lang::get('ESHOP_TEXT_SETTINGS'));
     ui::CheckBox('only_reg', 1, reg::getKey('/comments/only_reg'), lang::get('COMMENT_ONLY_REG'));
     ui::CheckBox('com_moderation', 1, reg::getKey('/comments/com_moderation'), lang::get('COMMENT_COM_MODERATION'));
     page::assign('text_length', reg::getKey('/comments/text_length'));
     return page::parse($TEMPLATE['frame']);
 }
Beispiel #10
0
 function view()
 {
     // Устанавливаем кнопки для формы
     ui::setCancelButton('/eshop/list');
     ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
     ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
     if (file_exists(MODUL_DIR . '/eshop/template/order.tpl')) {
         include MODUL_DIR . '/eshop/template/order.tpl';
     }
     if (!($obj = ormObjects::get(system::url(2), 'eshop_order'))) {
         system::redirect('/eshop/list');
     }
     $order = new eShopOrder($obj);
     // Вывод информации о товарах
     function getGoodsName($val, $obj)
     {
         if ($obj = ormPages::get($val, 'goods')) {
             return '<a href="' . $obj->url . '" target="_blank">' . $obj->name . '</a>';
         }
     }
     function getPrice($val, $obj)
     {
         return '&nbsp;&nbsp;&nbsp;&nbsp;' . $obj->cost * $obj->count . ' руб.';
     }
     $sel = new ormSelect('eshop_goods');
     $sel->where('parents', '=', $obj->id);
     $table = new ormMultiForm('goods');
     $table->setData($sel);
     $table->insideForm();
     $table->addColumn('goods_id', 0, 400, 0, false, 'getGoodsName');
     $table->addColumn('cost', 0, 100, 0, false);
     $table->addColumn('count', 0, 100);
     $table->addColumn('id', 'Общая стоимость', 100, 0, false, 'getPrice');
     $table->withoutAdditions();
     page::assign('goods_list', $table->getHTML());
     page::assign('order.number', $order->getNumber());
     page::assign('order.cost', $order->getCost());
     page::assign('order.cost_all', $order->getTotalCost());
     page::assign('order.delivery_price', $order->getDeliveryPrice());
     page::assign('order.delivery', $order->_delivery);
     $obj->parseAllFields();
     page::assign('obj.id', $order->id);
     page::assign('obj.date', date('d.m.Y в H:i', strtotime($obj->date)));
     page::assign('user_link', '/mpanel/users/user_upd/' . $order->getUserId());
     ui::SelectBox('state', ormObjects::getObjectsByClass('eshop_status'), $obj->state, 200);
     ui::CheckBox('is_payment', 1, $obj->is_payment, 'Оплачено');
     // Создаем форму и выводим ее на страницу
     // $form = new ormEditForm($obj, $right);
     //return $form->getHTML();
     return page::parse($TEMPLATE['frame']);
 }
Beispiel #11
0
 private function createTree($parent, $TEMPLATE)
 {
     $items = '';
     while ($obj = ormClasses::getInheritor($parent)) {
         page::assign('subitem', $this->createTree($obj->id(), $TEMPLATE));
         page::assign('obj.id', $obj->id());
         page::assign('obj.url', system::au() . '/constructor/class_upd/' . $obj->id());
         page::assign('obj.name', $obj->getName());
         page::assign('obj.sname', $obj->getSName());
         page::assign('obj.parent', $obj->getParentId());
         $pach = '/css_mpanel/tree/images/classes/';
         $ico = file_exists(ROOT_DIR . $pach . $obj->getSName() . '.png') ? $obj->getSName() . '.png' : 'file1.gif';
         page::assign('obj.ico', $pach . $ico);
         $rights = '';
         reset($this->rights);
         while (list($right, $pict) = each($this->rights)) {
             $modul = $right == 'values' ? 'reference' : 'constructor';
             if (user::issetRight($right, $modul) || $pict == 'empty') {
                 if ($pict == 'empty') {
                     $rights .= page::parse($TEMPLATE['empty_right']);
                 } else {
                     $parse = true;
                     if ($right == 'values') {
                         $parse = $obj->isInheritor('handbook') && $obj->getSName() != 'handbook';
                     }
                     if ($right == 'class_del') {
                         $parse = !$obj->isSystem();
                     }
                     if ($parse) {
                         $del_button = $right == 'class_del' ? 'class="del_button"' : '';
                         page::assign('del_button', $del_button);
                         page::assign('right.url', system::au() . '/' . $modul . '/' . $right);
                         page::assign('right.title', lang::right($right, $modul));
                         page::assign('right.class', $pict);
                         $rights .= page::parse($TEMPLATE['right']);
                     } else {
                         $rights .= page::parse($TEMPLATE['empty_right']);
                     }
                 }
             }
         }
         page::assign('rights', $rights);
         $items .= page::parse($TEMPLATE['item']);
     }
     if (!empty($items)) {
         page::assign('items', $items);
         return page::parse($TEMPLATE['frame_items']);
     }
 }
Beispiel #12
0
 public function defAction()
 {
     if (file_exists(MODUL_DIR . '/eshop/template/settings.tpl')) {
         include MODUL_DIR . '/eshop/template/settings.tpl';
     }
     ui::newButton(lang::get('BTN_SAVE_ONLY'), "javascript:sendForm('save');");
     page::assignArray(lang::get('ESHOP_TEXT_SETTINGS'));
     ui::SelectBox('fisrt_state', ormObjects::getObjectsByClass('eshop_status'), reg::getKey('/eshop/fisrt_state'));
     ui::CheckBox('only_reg', 1, reg::getKey('/eshop/only_reg'), lang::get('ESHOP_TEXT_SETTINGS', 1));
     ui::CheckBox('check_count', 1, reg::getKey('/eshop/check_count'), lang::get('ESHOP_TEXT_SETTINGS', 2));
     ui::CheckBox('dubl_to_email', 1, reg::getKey('/eshop/dubl_to_email'), lang::get('ESHOP_TEXT_SETTINGS', 3));
     //page::assign('nds', reg::getKey('/eshop/nds'));
     page::assign('min_count', reg::getKey('/eshop/min_count'));
     return page::parse($TEMPLATE['frame']);
 }
Beispiel #13
0
 /**
  * @return HTML
  * @param int $form_id - ID формы обратной связи. Форма предварительно должна быть создана в настройках модуля "Обратная связь".
  * @param string $templ_name - Шаблон оформления
  * @desc МАКРОС: Автоватически генерирует форму обратной связи (добавления отзыва, вопрос-ответа и пр.)
  */
 public function autoForm($form_id, $templ_name = 'default')
 {
     if ($form_obj = ormObjects::get($form_id, 'feedback_form')) {
         $obj = new ormPage();
         $obj->setClass($form_obj->form_class);
         $form = new ormEditForm($obj, languages::pre() . '/feedback/send_message');
         $form->tabuList('pseudo_url', 'h1', 'keywords', 'title', 'description', 'active', 'is_home_page', 'view_in_menu', 'view_submenu', 'in_search', 'answer', 'in_index', 'in_new_window', 'other_link', 'img_act', 'img_no_act', 'img_h1');
         page::assign('form_id', $form_obj->id);
         if ($form_obj->captcha) {
             $form->showCaptcha();
         }
         // Парсим текст сообщения
         page::parseError('feedback');
         return $form->getHTML('feedback/' . $templ_name);
     }
 }
Beispiel #14
0
 public function defAction()
 {
     if (file_exists(MODUL_DIR . '/structure/template/settings.tpl')) {
         include MODUL_DIR . '/structure/template/settings.tpl';
     }
     //  ui::newButton(lang::get('BTN_SAVE_ONLY'), "javascript:sendForm('save');");
     ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
     ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
     if (isset($_SESSION['STRUCTURE_LIST_FLAG']) && $_SESSION['STRUCTURE_LIST_FLAG']) {
         ui::setCancelButton('/structure/list');
     } else {
         ui::setCancelButton('/structure/tree');
     }
     // Основные настройки
     page::assignArray(lang::get('STRUCTURE_FORM_FIELD'));
     page::assign('title_prefix', reg::getKey(ormPages::getPrefix() . '/title_prefix'));
     page::assign('keywords', reg::getKey(ormPages::getPrefix() . '/keywords'));
     page::assign('description', reg::getKey(ormPages::getPrefix() . '/description'));
     ui::CheckBox('cur_date', 1, reg::getKey('/structure/' . domains::curId() . '/cur_date'), lang::get('STRUCTURE_FORM_FIELD', 4));
     ui::CheckBox('no_view_no_edit', 1, reg::getKey(ormPages::getPrefix() . '/no_view_no_edit'), lang::get('STRUCTURE_FORM_FIELD', 7));
     ui::CheckBox('view_as_tree', 1, reg::getKey(ormPages::getPrefix() . '/view_as_tree'), lang::get('STRUCTURE_FORM_FIELD', 18));
     ui::CheckBox('auto_index', 1, reg::getKey(ormPages::getPrefix('search') . '/auto_index'), lang::get('STRUCTURE_FORM_FIELD', 19));
     $file = ROOT_DIR . '/robots_part_' . domains::curDomain()->getName() . '.txt';
     $robots = file_exists($file) ? file_get_contents($file) : '';
     page::assign('robots', $robots);
     // Форма редактирования шаблонов страниц
     $form = new uiMultiForm('page_tpl');
     $form->insideForm();
     $form->setData(templates::getByDestination());
     $form->addColumn('t_name', lang::get('STRUCTURE_TABLE_FIELD_5'), 300);
     $form->addColumn('t_file', lang::get('STRUCTURE_TABLE_FIELD_6'), 300, lang::get('STRUCTURE_TABLE_FIELD_7'));
     page::assign('page_tpl', $form->getHTML());
     // Форма редактирования шаблонов объектов
     $form = new uiMultiForm('obj_tpl');
     $form->insideForm();
     $form->setData(templates::getByDestination(1));
     $form->addColumn('t_name', lang::get('STRUCTURE_TABLE_FIELD_5'), 300);
     $form->addColumn('t_file', lang::get('STRUCTURE_TABLE_FIELD_6'), 300, lang::get('STRUCTURE_TABLE_FIELD_7'));
     page::assign('obj_tpl', $form->getHTML());
     // Управление отображением
     $classes = ormClasses::getPagesClassList();
     ui::SelectBox('no_view_classes', $classes, reg::getList(ormPages::getPrefix() . '/no_view'), 600, '&nbsp;', '', 'selectbox_multi_big');
     ui::SelectBox('no_edit_classes', $classes, reg::getList(ormPages::getPrefix() . '/no_edit'), 600, '&nbsp;', '', 'selectbox_multi_big');
     return page::parse($TEMPLATE['frame']);
 }
Beispiel #15
0
 public function defAction()
 {
     if (file_exists(MODUL_DIR . '/search/template/forms.tpl')) {
         include MODUL_DIR . '/search/template/forms.tpl';
         ui::newButton(lang::get('SEARCH_BTN_INDEX'), "javascript:startIndex();");
         ui::newButton(lang::get('SEARCH_BTN_CLEAR'), "javascript:sendForm('clear');");
         page::assign('count_page', searchIndex::getCountPages());
         page::assign('count_words', searchIndex::getCountWords());
         $d = reg::getKey(ormPages::getPrefix('search') . '/index_date');
         if (empty($d)) {
             $d = '-';
         }
         page::assign('index_date', $d);
         page::assign('text1', lang::get('SEARCH_TEXT_1'));
         page::assign('text2', lang::get('SEARCH_TEXT_2'));
         page::assign('text3', lang::get('SEARCH_TEXT_3'));
         page::assign('text4', lang::get('SEARCH_TEXT_4'));
         return page::parse($TEMPLATE['frame']);
     }
 }
Beispiel #16
0
 public function upd()
 {
     if (file_exists(MODUL_DIR . '/constructor/template/fgroup.tpl')) {
         include MODUL_DIR . '/constructor/template/fgroup.tpl';
     }
     if (system::action() == "upd") {
         // форма обновления информации
         $group = new ormFieldsGroup(system::url(2));
         if ($group->id() == '') {
             system::stop();
         }
         page::assign('obj.group_name', $group->getName());
         page::assign('obj.group_sname', $group->getSName());
         page::assign('obj.id', $group->id());
         $view = $group->getView();
         $system = $group->getSystem();
         page::assign('right', 'fgroup_proc_upd');
     } else {
         if (system::action() == "add") {
             // форма добавления информации
             if (system::issetUrl(2)) {
                 // Проверяем существует ли родитель?
                 $class = new ormClass(system::url(2));
                 if ($class->id() == '') {
                     system::stop();
                 }
             }
             $view = 1;
             $system = 0;
             page::assign('obj.id', system::url(2));
             page::assign('right', 'fgroup_proc_add');
         }
     }
     page::assignArray(lang::get('CONSTR_FORM_FIELD2'));
     page::assignSavingPost();
     ui::CheckBox('group_view', 1, $view, lang::get('CONSTR_FORM_FIELD2', 3));
     ui::CheckBox('group_system', 1, $system, lang::get('CONSTR_FORM_FIELD2', 4));
     echo page::parse($TEMPLATE['frame'], 1);
     system::stop();
 }
Beispiel #17
0
 function upd()
 {
     // Устанавливаем кнопки для формы
     ui::setCancelButton('/eshop/delivery');
     ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
     ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
     if (system::action() == "upd") {
         if (!($obj = ormObjects::get(system::url(2), 'eshop_delivery_method'))) {
             system::redirect('/eshop/delivery');
         }
         $right = 'delivery_proc_upd';
     } else {
         if (system::action() == "add") {
             $obj = new ormObject();
             $obj->setClass('eshop_delivery_method');
             $right = 'delivery_proc_add';
         }
     }
     page::assign('right', $right);
     // Создаем форму и выводим ее на страницу
     $form = new ormEditForm($obj, $right);
     return $form->getHTML();
 }
Beispiel #18
0
 public function upd()
 {
     if (file_exists(MODUL_DIR . '/constructor/template/separator.tpl')) {
         include MODUL_DIR . '/constructor/template/separator.tpl';
     }
     if (system::action() == "upd") {
         // форма обновления информации
         $obj = new ormField(system::url(2));
         if ($obj->id() == '') {
             system::stop();
         }
         page::assign('obj.fname', $obj->getName());
         $max_size = $obj->getMaxSize() != '' ? $obj->getMaxSize() : 0;
         page::assign('obj.max_size', $max_size);
         page::assign('obj.id', $obj->id());
         page::assign('right', 'separator_proc_upd');
     } else {
         if (system::action() == "add") {
             // форма добавления информации
             if (system::issetUrl(2)) {
                 // Проверяем существует ли родитель?
                 $group = new ormFieldsGroup(system::url(2));
                 if ($group->id() == '') {
                     system::stop();
                 }
             }
             page::assign('obj.id', system::url(2));
             page::assign('right', 'separator_proc_add');
             page::assign('obj.max_size', 0);
         }
     }
     page::assignArray(lang::get('CONSTR_FORM_FIELD3'));
     page::assignSavingPost();
     echo page::parse($TEMPLATE['frame'], 1);
     system::stop();
 }
Beispiel #19
0
 /**
  * @return HTML
  * @param int $obj_id - ID раздела, для которого необходимо вывести теги.
  * @param string $templ_name - Шаблон оформления.
  * @desc МАКРОС: Выводит список тегов для указанной страницы.
  */
 public function tags($obj_id, $templ_name = 'tags')
 {
     $templ_file = '/search/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('search.tags', $templ_file);
     }
     $tags = tags::getTagsForObject($obj_id);
     $list = '';
     while (list($num, $tag) = each($tags)) {
         page::assign('obj.id', $tag['id']);
         page::assign('obj.name', $tag['name']);
         page::assign('obj.count', $tag['count']);
         page::assign('obj.url', '/search/tag/' . $tag['id']);
         $list .= !empty($num) ? page::parse($TEMPLATE['separator']) : '';
         $list .= page::parse($TEMPLATE['list']);
     }
     if (!empty($list)) {
         page::assign('list', $list);
         return page::parse($TEMPLATE['frame']);
     } else {
         return page::parse($TEMPLATE['empty']);
     }
 }
Beispiel #20
0
 /**
  * @return HTML
  * @param int $comment_id - ID комментария
  * @param string $templ_name - Шаблон оформления комментария
  * @desc МАКРОС: Выводит информацию об указанном комментарии
  */
 public function view($comment_id, $templ_name = 'tree')
 {
     $templ_file = '/comments/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('comments.view', $templ_file);
     }
     if ($comment = comments::get($comment_id)) {
         if ($comment->isActive() || reg::getKey('/comments/show_noactive')) {
             page::assign('obj.id', $comment->id());
             page::assign('obj.parent_id', $comment->getParentId());
             page::assign('obj.user_id', $comment->getUserId());
             page::assign('obj.publ_date', $comment->getPublDate());
             page::assign('obj.username', $comment->getUserName());
             page::assign('obj.email', $comment->getEmail());
             page::assign('obj.text', $comment->getText());
             page::assign('obj.rate', $comment->getRate());
             if (isset($_SESSION['comments_rate'][$comment->id()])) {
                 page::fParse('rate', $TEMPLATE['rate_change']);
             } else {
                 page::fParse('rate', $TEMPLATE['rate']);
             }
             page::assign('list', '');
             return page::parse($TEMPLATE['list']);
         }
     }
 }
Beispiel #21
0
    /**
     * @return string HTML
     * @param integer $obj - Экземпляр объекта (ormObject, ormPage)
     * @param string $action - Тип действия: "upd" - изменение, "add" - добавление
     * @desc Выводит форму изменения прав доступа для объекта
     */
    public static function getListForObject($obj, $action)
    {
        if (file_exists(MODUL_DIR . '/users/template/right_list_object.tpl')) {
            include MODUL_DIR . '/users/template/right_list_object.tpl';
        }
        if (isset($_POST['query'])) {
            // Формируем список подсказок для пользователя
            $sel = new ormSelect('user');
            $sel->fields('login');
            $sel->where('id', '<>', '29');
            $sel->where('login', 'LIKE', '%' . $_POST['query'] . '%');
            $users = '';
            while ($user = $sel->getObject()) {
                $zapi = $sel->getObjectNum() != 0 ? ', ' : '';
                $users .= $zapi . "'" . $user->login . "'";
            }
            echo "{ query:'" . $_POST['query'] . "', suggestions:[" . $users . "], data:[] }";
            system::stop();
        } else {
            if (isset($_POST['user_name'])) {
                // Добавляем выбранного пользователя в список
                $sel = new ormSelect('user');
                $sel->fields('login');
                $sel->where('id', '<>', '29');
                $sel->where('login', '=', $_POST['user_name']);
                $sel->limit(1);
                $user = $sel->getObject();
                if ($user instanceof ormObject) {
                    page::assign("group.id", $user->id);
                    page::assign("group.name", $user->login);
                    page::assign("checked_edit", '');
                    page::assign("checked_view", 'checked');
                    echo page::parse($TEMPLATE['group']);
                }
                system::stop();
            }
        }
        // Выводим список групп
        $sel = new ormSelect('user_group');
        $sel->where('id', '<>', '32');
        $sel->orderBy('name', asc);
        $groups = $sel->getData();
        $rights = array();
        if ($action == 'upd') {
            $users = db::q('SELECT o_id, login o_name
							FROM <<rights>>, <<objects>>, <<__user>>
							WHERE r_obj_id = "' . $obj->id . '" and
								  r_group_id = o_id and
								  obj_id = o_id and
								  o_class_id <> 33;', records);
            $groups = array_merge($groups, $users);
            $tmp = db::q('SELECT r_state, r_group_id FROM <<rights>> WHERE r_obj_id = "' . $obj->id . '";', records);
            while (list($key, $right) = each($tmp)) {
                $rights[$right['r_group_id']] = $right['r_state'];
            }
            $select_all = count($tmp) == 1 && empty($tmp[0]['r_group_id']) ? $tmp[0]['r_state'] : false;
        } else {
            $select_all = 2;
        }
        $items = '';
        $num = $edit_num = $view_num = 0;
        while (list($key, $group) = each($groups)) {
            $state = isset($rights[$group['o_id']]) ? $rights[$group['o_id']] : 0;
            if ($state == 2) {
                $edit_num++;
            }
            $checked_edit = $state == 2 || $select_all == 2 ? 'checked' : '';
            page::assign("checked_edit", $checked_edit);
            if ($state > 0) {
                $view_num++;
            }
            $checked_view = $state > 0 || $select_all > 0 ? 'checked' : '';
            page::assign("checked_view", $checked_view);
            page::assign("group.id", $group['o_id']);
            page::assign("group.name", $group['o_name']);
            $items .= page::parse($TEMPLATE['group']);
            $num = $key + 1;
        }
        $checked_edit = $select_all == 2 || $num == $edit_num ? 'checked' : '';
        page::assign("checked_edit", $checked_edit);
        $checked_view = $select_all > 0 || $num == $view_num ? 'checked' : '';
        page::assign("checked_view", $checked_view);
        page::assign("text.all_user", lang::get('STRUCTURE_RIGHT_ALL_USER'));
        page::assign("text.title", lang::get('STRUCTURE_RIGHT_TITLE'));
        page::assign("groups", $items);
        return page::parse($TEMPLATE['frame']);
    }
Beispiel #22
0
 public function getHTML($templ_name = 'filters')
 {
     if ($this->getCount() > 0 && file_exists(MODUL_DIR . '/mpanel/template/' . $templ_name . '.tpl')) {
         include MODUL_DIR . '/mpanel/template/' . $templ_name . '.tpl';
         $items = '';
         $num = 0;
         // Строим список фильтров
         reset($this->filters);
         while (list($key, $field) = each($this->filters)) {
             $num++;
             if (isset($this->new_filters[$num])) {
                 if ($this->new_filters[$num][2]) {
                     page::assign('field.name', $this->new_filters[$num][0]);
                     page::assign('field.content', $this->new_filters[$num][1]);
                     $items .= page::parse($TEMPLATE['field_spec']);
                 } else {
                     $items .= $this->new_filters[$num][1];
                 }
             }
             if (!isset($_SESSION['filters_' . $this->prefix][$field['f_sname']])) {
                 $_SESSION['filters_' . $this->prefix][$field['f_sname']] = '';
             }
             if (isset($this->show_filters[$field['f_sname']]) && !empty($this->show_filters[$field['f_sname']][0])) {
                 $field['f_name'] = $this->show_filters[$field['f_sname']][0];
             }
             page::assign('field.name', $field['f_name']);
             if ($field['f_type'] == 50 || $field['f_type'] > 69 && $field['f_type'] < 96) {
                 // Выпадающий список
                 $data = array();
                 if ($field['f_type'] == 50) {
                     $data = lang::get('FILTER_BOOL');
                 } else {
                     if ($field['f_type'] > 69 && $field['f_type'] < 86) {
                         $data = lang::get('FILTER_ISSET');
                     } else {
                         if ($field['f_type'] == 90 || $field['f_type'] == 95) {
                             $data = ormObjects::getObjectsByClass($field['f_list_id']);
                         }
                     }
                 }
                 $element = ui::SelectBox($field['f_sname'], $data, $_SESSION['filters_' . $this->prefix][$field['f_sname']], 172, '&nbsp;', '', 'selectbox_mini');
                 page::assign('element', $element);
                 $items .= page::parse($TEMPLATE['field_select']);
             } else {
                 if (isset($this->show_filters[$field['f_sname']]) && $this->show_filters[$field['f_sname']][1] || ($field['f_type'] == 25 || $field['f_type'] == 30 || $field['f_type'] == 32) && (!isset($this->show_filters[$field['f_sname']]) || $this->show_filters[$field['f_sname']][1] !== false)) {
                     // Выбор промежутка для чисел или дат
                     if (!isset($_SESSION['filters_' . $this->prefix][$field['f_sname'] . '_2'])) {
                         $_SESSION['filters_' . $this->prefix][$field['f_sname'] . '_2'] = '';
                     }
                     page::assign('field.sname', $field['f_sname']);
                     page::assign('field.value', $_SESSION['filters_' . $this->prefix][$field['f_sname']]);
                     page::assign('field.value2', $_SESSION['filters_' . $this->prefix][$field['f_sname'] . '_2']);
                     $items .= page::parse($TEMPLATE['field_period']);
                 } else {
                     // Обычный фильтр - текстовое поле
                     page::assign('field.sname', $field['f_sname']);
                     page::assign('field.value', $_SESSION['filters_' . $this->prefix][$field['f_sname']]);
                     $items .= page::parse($TEMPLATE['field']);
                 }
             }
         }
         $all_count = $num + count($this->new_filters);
         while ($num < $all_count) {
             $num++;
             if (isset($this->new_filters[$num])) {
                 if ($this->new_filters[$num][2]) {
                     page::assign('field.name', $this->new_filters[$num][0]);
                     page::assign('field.content', $this->new_filters[$num][1]);
                     $items .= page::parse($TEMPLATE['field_spec']);
                 } else {
                     $items .= $this->new_filters[$num][1];
                 }
             }
         }
         page::assign('fields', $items);
         return page::parse($TEMPLATE['frame']);
     }
 }
Beispiel #23
0
 private function showAuthForm($error = 0)
 {
     if (file_exists(MODUL_DIR . '/mpanel/template/auth.tpl')) {
         include MODUL_DIR . '/mpanel/template/auth.tpl';
         page::assign('title', lang::get('CMF'));
         if (user::isGuest()) {
             // Пользователь не авторизован
             page::assign('url', system::getCurrentUrl());
             page::assign('login', lang::get('AUTHFORM_LOGIN'));
             page::assign('passw', lang::get('AUTHFORM_PASSW'));
             page::assign('enter', lang::get('AUTHFORM_ENTER'));
             page::assign('error', $error);
             echo page::parse($TEMPLATE['frame']);
         } else {
             // Пользователь авторизован, но не является админом
             page::assign('exit_url', '/users/logout');
             page::assign('user', user::get('name'));
             page::assign('hello', lang::get('AUTHFORM_HELLO'));
             page::assign('big_text', lang::get('AUTHFORM_BIG_TEXT'));
             page::assign('exit_text', lang::get('AUTHFORM_EXIT_TEXT'));
             echo page::parse($TEMPLATE['frame_no_admin']);
         }
         system::stop();
     }
 }
Beispiel #24
0
 public function parseAllFields($prefix = 'obj')
 {
     if ($this->class instanceof ormClass) {
         $this->loadFields();
         $this->loadData();
         if (!empty($prefix)) {
             $prefix .= '.';
         }
         reset($this->fields);
         while (list($key, $field) = each($this->fields)) {
             if ($field['f_type'] > 2) {
                 page::assign($prefix . $key, $this->__get($key));
             }
         }
     }
 }
Beispiel #25
0
 /**
  * @return Сгенерированный HTML
  * @param ormClass $class -  экземпляр ORM-класса, для которого необходимо построить структуру
  * @param String $templ_name - имя шаблона оформления
  * @desc Генерирует структуру полей для класса данных
  */
 function getHTML($class, $templ_name = 'orm_fields_tree')
 {
     if (file_exists(MODUL_DIR . '/mpanel/template/' . $templ_name . '.tpl')) {
         include MODUL_DIR . '/mpanel/template/' . $templ_name . '.tpl';
         $nodes['groups'] = $class->getAllGroups();
         $nodes['fields'] = $class->getAllFields();
         $main_url = system::au() . '/' . system::url(0) . '/';
         page::assign('main_url', $main_url);
         if (is_array($nodes) && isset($nodes['groups']) && isset($nodes['fields'])) {
             $groups = '';
             while (list($key, $node) = each($nodes['groups'])) {
                 // Парсим данные о вложенных полях
                 $fields = '';
                 reset($nodes['fields']);
                 while (list($key, $field) = each($nodes['fields'])) {
                     if ($field['f_group_id'] == $node['fg_id']) {
                         if (empty($field['f_name'])) {
                             $field['f_name'] = '- - - - -';
                         }
                         page::assign('item.id', $field['f_id']);
                         page::assign('item.parent_id', $field['f_group_id']);
                         page::fParse('item.url', $this->rightEdit);
                         page::assign('item.name', $field['f_name']);
                         page::assign('item.sname', $field['f_sname']);
                         page::assign('item.type', lang::get('CONSTR_TYPE_LIST', $field['f_type']));
                         page::assign('star', $field['f_required'] ? '*' : '');
                         page::assign('sh', $field['f_view'] ? 'lshow' : 'lhide');
                         if (empty($field['f_type'])) {
                             page::assign('item.right', $this->getRightForField($TEMPLATE, $field['f_id'], $field['f_type'], $field['f_sname']));
                             $fields .= page::parse($TEMPLATE['separator']);
                         } else {
                             if ($field['f_system'] || $field['f_is_clone']) {
                                 $fields .= page::parse($TEMPLATE['field_not_edit']);
                             } else {
                                 page::assign('item.right', $this->getRightForField($TEMPLATE, $field['f_id'], $field['f_type'], $field['f_sname']));
                                 $fields .= page::parse($TEMPLATE['field_edit']);
                             }
                         }
                     }
                 }
                 page::assign('items', $fields);
                 page::assign('item.id', $node['fg_id']);
                 page::fParse('sub_items', $TEMPLATE['frame_items']);
                 // Парсим данные о группе полей 		fg_view   fg_sname
                 page::assign('item.id', $node['fg_id']);
                 page::assign('item.parent_id', 0);
                 page::fParse('item.url', $this->rightEdit2);
                 page::assign('item.name', $node['fg_name']);
                 page::assign('item.sname', $node['fg_sname']);
                 page::assign('sh', $node['fg_view'] ? ' lshow' : ' lhide');
                 $other = $node['fg_system'] || $node['fg_is_clone'] ? true : false;
                 page::assign('item.right', $this->getRightForGroup($TEMPLATE, $node['fg_id'], $other));
                 $groups .= page::parse($TEMPLATE['groups']);
             }
             page::assign('frame_items', $groups);
         } else {
             page::assign('frame_items', '');
         }
         ui::insertButton('button_new_group', lang::get('BTN_NEW_FGROUP'), 'javascript:changeGroup(' . $class->id() . ', \'add\');');
         return page::parse($TEMPLATE['main']);
     }
 }
Beispiel #26
0
 private function sendEmails()
 {
     $last_email = '';
     // Информация о новом комментарии
     page::assign('username', $this->getUserName());
     page::assign('comment', $this->getText());
     page::assign('comment_id', $this->id());
     // Информация о странице
     if ($page = ormPages::get($this->getObjId())) {
         page::assign('page.id', $page->id);
         page::assign('page.url', $page->url);
         page::assign('page.name', $page->name);
     }
     // Отправляем письмо автору предыдущего коммента
     if ($this->getParentId() != 0) {
         $old_comment = new comment($this->getParentId());
         if ($old_comment->getEmail() != $this->getEmail()) {
             $last_email = $old_comment->getEmail();
             page::assign('old_comment', $old_comment->getText());
             page::assign('name', $old_comment->getUserName());
             system::sendMail('/comments/mails/new_answer.tpl', $last_email);
         }
     }
     // Отправляем письма всем подписавщимся на уведомления
     $sql = 'SELECT c_username, c_email FROM <<comments>>
             WHERE c_obj_id = "' . $this->getObjId() . '" and
                   c_send_email = 1 and
                   c_id <> "' . $this->id() . '"
             GROUP BY c_email;';
     $list = db::q($sql, records);
     if (!empty($list)) {
         while (list($key, $val) = each($list)) {
             if ($val['c_email'] != $last_email && $val['c_email'] != $this->getEmail()) {
                 page::assign('name', $val['c_username']);
                 page::assign('index', str_replace(array('.', '@'), array('_', '__'), $val['c_email']));
                 system::sendMail('/comments/mails/new_comment.tpl', $val['c_email']);
             }
         }
     }
 }
Beispiel #27
0
 private function parseField($obj, $field, $TEMPLATE, $current_id)
 {
     $is_upd = $obj->id == '' ? false : true;
     $is_editable = !isset($field['editable']) || $field['editable'];
     $width = empty($field['width']) ? $this->width : $field['width'];
     page::assign('width', $width);
     if (isset($_SESSION['SAVING_POST']['obj' . $this->form_name]) && ($field['f_type'] < 70 || $field['f_type'] > 85)) {
         $tmp = $_SESSION['SAVING_POST']['obj' . $this->form_name];
         if (isset($tmp[$current_id][$field['f_sname']])) {
             $value = $tmp[$current_id][$field['f_sname']];
         }
     } else {
         $value = '';
     }
     if (empty($value)) {
         if ($field['f_type'] == 105) {
             $value = $obj->__get('_' . $field['f_sname']);
         } else {
             $value = $obj->__get($field['f_sname']);
         }
         $function = !empty($field['funct_name']) ? $field['funct_name'] : '';
         if (!$is_editable) {
             $value = parent::processValue($obj, $field['f_sname'], $field['f_type'], $value, $function);
         }
     }
     if ($is_editable) {
         page::assign('field.id', $field['f_id']);
         page::assign('field.name', $field['f_name']);
         page::assign('field.sname', $field['f_sname']);
         page::assign('field.value', $value);
         $obj_id = $field['f_sname'] . '_' . $current_id;
         $elem_name = 'obj' . $this->form_name . '[' . $current_id . '][' . $field['f_sname'] . ']';
         // Специальная обработка данных
         if ($field['f_type'] == 50) {
             page::assign('element', ui::CheckBox($elem_name, 1, $value, '', '', $obj_id));
         } else {
             if ($field['f_type'] == 32) {
                 if (empty($value) || $value == '0000-00-00 00:00:00') {
                     page::assign('field.date', '');
                     page::assign('field.time', '00:00');
                 } else {
                     page::assign('field.date', date('d.m.Y', strtotime($value)));
                     page::assign('field.time', date('H:i', strtotime($value)));
                 }
             } else {
                 if ($field['f_type'] == 25) {
                     $time = empty($value) || $value == '0000-00-00' ? '' : date('d.m.Y', strtotime($value));
                     page::assign('field.date', $time);
                 } else {
                     if ($field['f_type'] == 30) {
                         $time = empty($value) ? '' : date('H:i:s', strtotime($value));
                         page::assign('field.time', $time);
                     } else {
                         if ($field['f_type'] > 69 && $field['f_type'] < 86) {
                             // файлы
                             if (system::$isAdmin) {
                                 page::assign('element', ui::loadFile($elem_name, $value, 'load_file_mini', $obj_id));
                             } else {
                                 page::fParse('element', '');
                             }
                         } else {
                             if ($field['f_type'] == 90 || $field['f_type'] == 95) {
                                 // Выпадающий список или Список со множественным выбором
                                 // Получаем список объектов справочника
                                 $data = ormObjects::getObjectsByClass($field['f_list_id']);
                                 $multi = $field['f_type'] == 95 ? 'selectbox_multi' : 'selectbox_template';
                                 $empty = !$field['f_required'] ? '&nbsp;' : '';
                                 if ($field['f_quick_add']) {
                                     $width = $width - 22;
                                 }
                                 $min = $field['f_type'] == 95 ? 8 : 30;
                                 page::assign('width_plu', $width - $min);
                                 page::assign('element', ui::SelectBox($elem_name, $data, $value, $width, $empty, '', $multi, $obj_id));
                                 if ($field['f_quick_add']) {
                                     page::fParse('plus', $TEMPLATE['field_' . $field['f_type'] . '_plus']);
                                 } else {
                                     page::assign('plus', '');
                                 }
                             } else {
                                 if ($field['f_type'] == 100) {
                                     // Связь с объектом
                                     page::assign('element', ui::objectLinks($obj, $field['f_id'], '_' . $current_id, $elem_name, $width - 30, 'objectLinks2'));
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Генерируем яву (создаем правила проверки для элементов формы)
         if ($field['f_required'] && ($field['f_type'] == 35 && $this->action == 'add' || $field['f_type'] != 35)) {
             $msg = str_replace('%title%', $field['f_name'], lang::get('CONSTR_BASE_FIELD_E2'));
             $zpt = !empty($this->requred_field) ? ', ' : '';
             $empty = $field['f_type'] == 90 || $field['f_type'] == 95 ? 'null' : '""';
             if ($field['f_type'] == 100) {
                 $this->requred_field .= $zpt . '["' . $obj_id . '", "' . $current_id . '", "' . $msg . '", ' . $empty . ', 1]';
             } else {
                 $this->requred_field .= $zpt . '["' . $obj_id . '", "' . $current_id . '", "' . $msg . '", ' . $empty . ']';
             }
         }
         if ($field['f_type'] == 15) {
             $this->java .= page::parse('rules.push("valid_email,' . $obj_id . ',' . lang::get('CONSTR_BASE_FIELD_E3') . '");');
         }
         if ($field['f_type'] == 20) {
             $this->java .= page::parse('rules.push("reg_exp,' . $obj_id . ',^(((f|ht){1}tp:/)*/[-a-zA-Z0-9@:%_\\+.~#?&//=]+)*$|^\\/{1}, ' . lang::get('CONSTR_BASE_FIELD_E4') . '");');
         }
         if ($field['f_type'] == 40) {
             $this->java .= page::parse('rules.push("digits_only,' . $obj_id . ',' . lang::get('CONSTR_BASE_FIELD_E6') . '");');
         }
         if ($field['f_type'] == 45) {
             $this->java .= page::parse('rules.push("float_only,' . $obj_id . ',' . lang::get('CONSTR_BASE_FIELD_E7') . '");');
         }
         if ($field['f_type'] == 47) {
             $this->java .= page::parse('rules.push("price_only,' . $obj_id . ',' . lang::get('CONSTR_BASE_FIELD_E8') . '");');
         }
         if (isset($TEMPLATE['field_' . $field['f_type']])) {
             $value = page::parse($TEMPLATE['field_' . $field['f_type']]);
         } else {
             $value = str_replace('%title%', $field['f_sname'], lang::get('CONSTR_BASE_FIELD_E5'));
         }
     }
     page::assign('content', $value);
     return page::parse($TEMPLATE['field_frame']);
 }
Beispiel #28
0
 /**
  * @return string
  * @param string $templ_name - Шаблон оформления
  * @desc МАКРОС: Выводит форму второго шага авторизации через соц сети, если требуется указать e-mail или согласиться с правилами.
  */
 function socialAuthConfirm($templ_name = 'social_auth_confirm')
 {
     $templ_file = '/users/' . $templ_name . '.tpl';
     $TEMPLATE = page::getTemplate($templ_file);
     if (!is_array($TEMPLATE)) {
         return page::errorNotFound('users.socialAuthConfirm', $templ_file);
     }
     if (user::isGuest() && !empty($_SESSION['SOCIAL_AUTH_USER_INFO'])) {
         page::assign('obj.email', '');
         foreach ($_SESSION['SOCIAL_AUTH_USER_INFO'] as $key => $val) {
             page::assign('obj.' . $key, $val);
         }
         page::assign('email_block', reg::getKey('/users/ask_email') && empty($_SESSION['SOCIAL_AUTH_USER_INFO']['email']) ? page::parse($TEMPLATE['email']) : '');
         page::assign('confirm_block', reg::getKey('/users/confirm') ? page::parse($TEMPLATE['confirm']) : '');
         // Вывод сообщения об ошибках
         page::parseError('social_auth_confirm');
         return page::parse($TEMPLATE['frame']);
     }
 }
Beispiel #29
0
 public function send_messageAction()
 {
     if ($form_obj = ormObjects::get(system::POST('form_id'))) {
         $issetErrors = false;
         $answer = array();
         // Проверка капчи
         if ($form_obj->captcha && !system::validCapcha('random_image')) {
             $issetErrors = true;
             $answer = array('field' => 'random_image', 'msg' => lang::get('FEEDBACK_ERROR1'));
         }
         // Если указанно куда, добавляем объект в БД
         if (($form_obj->any_sections || $form_obj->section) && !$issetErrors) {
             // Определяем раздел, в который будем добавлять отзыв
             if ($form_obj->any_sections) {
                 $section = system::POST('section_id', isInt);
             } else {
                 $section = $form_obj->section;
                 $section = !empty($section) ? $section[0] : 0;
             }
             // Создаем объект обратной связи
             $obj = new ormPage();
             $obj->setParent($section);
             $obj->setClass($form_obj->form_class);
             $obj->tabuList('pseudo_url', 'h1', 'keywords', 'title', 'description', 'answer', 'active', 'is_home_page', 'view_in_menu', 'view_submenu', 'in_search', 'in_index', 'in_new_window', 'other_link', 'img_act', 'img_no_act', 'img_h1');
             $obj->loadFromPost();
             $obj->active = 0;
             $obj->view_in_menu = 1;
             $obj->view_submenu = 1;
             $obj->in_search = 1;
             $obj->in_index = 1;
             $obj->is_home_page = 0;
             if ($obj->name != '') {
                 $obj->h1 = $obj->name;
                 $obj->title = $obj->name;
             }
             $obj->pseudo_url = rand(1000, 9999);
             $obj->template_id = ($sect = ormPages::get($form_obj->section)) ? $sect->template_id : 1;
             $obj->form_id = $form_obj->id;
             $obj->setRightForAll(2);
             $obj_id = $obj->save();
             if ($obj_id) {
                 $obj->pseudo_url = $obj_id;
                 $obj->save();
                 $obj = new ormPage($obj_id);
             } else {
                 $issetErrors = true;
                 $f = $obj->getErrorFields();
                 $answer = array('field' => $f['focus'], 'msg' => $obj->getErrorListText(' '));
             }
         }
         if (!$issetErrors) {
             // Отправка нужных писем
             page::assign('site_name', domains::curDomain()->getSiteName());
             page::assign('site_url', domains::curDomain()->getName());
             page::assign('base_email', domains::curDomain()->getEmail());
             while (list($key, $val) = each($_POST)) {
                 page::assign($key, system::checkVar($val, isText));
             }
             if (isset($obj)) {
                 $fields = $obj->getClass()->loadFields();
                 foreach ($fields as $field) {
                     if (in_array($field['f_type'], array(70, 75, 80, 85))) {
                         $fsname = $field['f_sname'];
                         $fvalue = $obj->{$fsname};
                         if ($fvalue != '') {
                             page::assign($fsname, $fvalue);
                         }
                     }
                 }
             }
             // Если указан список адресатов, отправляем письма
             if ($form_obj->mailing_list != '') {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->admin_sender_address);
                 $mail->FromName = $this->parse($form_obj->admin_sender_name);
                 /*
                                   if (!empty($this->files))
                 for($i = 0; $i < count($this->files); $i++)
                    $mail->AddAttachment($this->files[$i][0], $this->files[$i][1]);
                 */
                 $mail->AddAddress($form_obj->mailing_list);
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->admin_subject);
                 $mail->Body = $this->parse($form_obj->admin_template);
                 $mail->Send();
             }
             // Если нужно, отправляем уведомление пользователю
             if ($form_obj->send_notice && !$issetErrors) {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->notice_sender_address);
                 $mail->FromName = $this->parse($form_obj->notice_sender_name);
                 $mail->AddAddress(system::POST('email'));
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->notice_subject);
                 $mail->Body = $this->parse($form_obj->notice_template);
                 $mail->Send();
             }
             // Показываем результат
             if (system::isAjax()) {
                 if ($form_obj->msg != '') {
                     $text = $form_obj->msg;
                 } else {
                     $text = lang::get('FEEDBACK_MSG_1');
                 }
                 system::json(array('field' => 0, 'msg' => strip_tags($text)));
             } else {
                 system::redirect('/feedback/ok/' . $form_obj->id);
             }
         } else {
             // Произошли ошибки
             if (system::isAjax()) {
                 system::json($answer);
             } else {
                 system::savePostToSession();
                 system::saveErrorToSession('feedback', $answer);
                 if (empty($_POST['back_url'])) {
                     $_POST['back_url'] = '/structure/map';
                 }
                 system::redirect($_POST['back_url'], true);
             }
         }
         system::stop();
     } else {
         system::stop();
     }
 }
Beispiel #30
0
 private function selItems($TEMPLATE)
 {
     if ($this->hide_empty_columns) {
         while ($obj = $this->select->getObject()) {
             reset($this->columns);
             while (list($key, $column) = each($this->columns)) {
                 $value = $this->getProcValue($obj, $column['field'], $column['funct_name']);
                 if (empty($value)) {
                     if (isset($this->del_columns[$column['field']])) {
                         $this->del_columns[$column['field']]++;
                     } else {
                         $this->del_columns[$column['field']] = 1;
                     }
                 }
             }
         }
         $this->select->reset();
     }
     $items = '';
     while ($obj = $this->select->getObject()) {
         page::assign('id', $obj->id);
         page::assign('table_parent_id', $obj->getParentId());
         page::assign('url', $this->def_right . $obj->id);
         $item_vals = '';
         reset($this->columns);
         while (list($key, $column) = each($this->columns)) {
             if (!isset($this->del_columns[$column['field']]) || $this->del_columns[$column['field']] != $this->count) {
                 // Обработка значений
                 $value = $this->getProcValue($obj, $column['field'], $column['funct_name']);
                 page::assign('value', $value);
                 $first = empty($key) ? ' first' : '';
                 //   $first .= ($column['field'] == 'name') ? ' td_name' : '';
                 page::assign('first', $first);
                 $click = $column['click'] && !empty($this->def_right) ? '' : '_no_click';
                 $item_vals .= page::parse($TEMPLATE['item_val' . $click]);
             }
         }
         page::assign('item_vals', $item_vals);
         page::assign('act', $obj->__get('active') ? 1 : 0);
         $items .= page::parse($TEMPLATE['items']);
     }
     page::assign('items', $items);
 }