Example #1
0
 function Init($name = '', $settings = '')
 {
     $params = unserialize_params($settings);
     $this->settings['name'] = $name;
     $this->SetSettings(combine_arrays($this->GetSettings(), $params));
     if ($this->settings['urlprefix'] == '') {
         $this->settings['urlprefix'] = content_url_get_full();
     }
     $s = $this->settings['urlprefix'];
     if (preg_match('/\\?/', $s)) {
         if (!preg_match('/\\?$/', $s)) {
             $s .= '&';
         }
     } else {
         $s .= '?';
     }
     $this->settings['urlprefix'] = $s;
     if ($this->settings['pageid'] == '') {
         $this->settings['pageid'] = 'page';
     }
     $this->topStencil = $this->bottomStencil = $this->defaultStencil;
     if ($this->settings['perpage'] == '') {
         $this->settings['perpage'] = 1;
     }
 }
Example #2
0
 function stencil_pagintation($count, $current = 0, $url_prefix = '', $pageid = 'pageid')
 {
     if ($url_prefix == '') {
         $url_prefix = content_url_get_full();
     }
     $res = '<div class="pagintation">Страницы: ';
     if (isset($GLOBALS[$pageid])) {
         $current = $GLOBALS[$pageid];
     }
     if ($current < 0) {
         $current = 0;
     }
     if ($current >= $count) {
         $current = $count - 1;
     }
     for ($i = 0; $i < $count; $i++) {
         if ($i != $current) {
             $t = '<a href="' . $url_prefix . ($url_prefix[strlen($url_prefix) - 1] == '?' ? '' : '&') . $pageid . '=' . $i . '">' . ($i + 1) . '</a>';
         } else {
             $t = '[' . ($i + 1) . ']';
         }
         $res .= $t;
     }
     $res .= '</div>';
     return $res;
 }
Example #3
0
 function editor_add_function($title, $function, $name = 'default', $args = '')
 {
     global $editor_functions;
     global $editor_menus, $editor_function, $editor_usage, $id;
     if ($editor_usage[$title][$function][$name]) {
         return;
     }
     //if (isset ($editor_function[$name][$function])) return;
     $fid = count($editor_functions[$name]);
     $editor_menus[$name]->AppendItem($title, content_url_get_full() . '&function=' . $fid . '&' . $args, $function);
     $editor_functions[$name][] = array('title' => $title, 'function' => $function);
     $editor_usage[$title][$function][$name] = true;
 }
Example #4
0
 function PAGE_Submit()
 {
     global $action;
     $WT_contest_id = $_SESSION['WT_contest_id'];
     $manage = $this->IsContestJudge();
     redirector_add_skipvar('action', 'submit');
     $contest = WT_contest_by_id($WT_contest_id);
     if ($action == 'submit') {
         $url = content_url_get_full();
         if ($contest['settings']['compilers'][WT_receive_compiler_from_selector()]) {
             if ($this->Problem_AccessibleForSubmit($_POST['problem_id'], user_id(), false)) {
                 if ($this->PutSolution($WT_contest_id, user_id(), $_POST['problem_id'], WT_receive_compiler_from_selector(), stripslashes($_POST['src']))) {
                     redirect($url);
                 }
             }
         }
     }
     $this->gateway->AppendNavigation('Посылка решения задачи', '.?page=submit');
     if (WT_contest_running($WT_contest_id) || $manage) {
         $this->CPrintLn(stencil_formo());
         $list = $this->GetProblemsAtContest($WT_contest_id);
         $this->InsertTemplate('submit_form', array('list' => $list, 'contest' => $contest, 'data' => $this));
         $this->CPrintLn(stencil_formc());
     }
 }
Example #5
0
 function Editor_Scripts()
 {
     global $act;
     if ($act == 'save') {
         $this->settings['script'] = manage_template_receive_from_selector('display');
         $this->SaveSettings();
     }
     $full = content_url_get_full();
     formo('title=Настройка скриптов');
     settings_formo($full . '&act=save');
     println('Скрипт отображения статьи:');
     manage_template_draw_selector_for_script('display', $this->settings['script']);
     settings_formc('');
     formc();
 }
Example #6
0
 function Editor_ManageScripts()
 {
     global $act;
     formo('title=Управление скрптами отображения списка публикаций;');
     if ($act == 'save') {
         $this->settings['script'] = manage_template_receive_from_selector($this->GetClassName() . '_list');
         $this->settings['itemScript'] = manage_template_receive_from_selector($this->GetClassName() . '_short');
         $this->settings['fullScript'] = manage_template_receive_from_selector($this->GetClassName() . '_full');
         $this->SaveSettings();
     }
     settings_formo(content_url_get_full() . '&act=save');
     println('Скрипт отображения списка публикаций:');
     manage_template_draw_selector_for_script($this->GetClassName() . '_list', $this->settings['script']);
     println('<div id="hr"></div>');
     println('Скрипт отображения публикации:');
     manage_template_draw_selector_for_script($this->GetClassName() . '_short', $this->settings['itemScript']);
     println('<div id="hr"></div>');
     if ($this->settings['detailed']) {
         println('Скрипт отображения подробной публикации:');
         manage_template_draw_selector_for_script($this->GetClassName() . '_full', $this->settings['fullScript']);
         println('<div id="hr"></div>');
     }
     settings_formc();
     formc();
 }
Example #7
0
 function Contest_ActionHandler()
 {
     global $act, $uid, $id, $pid, $catid;
     if (!$this->GetAllowed('CONTEST.MANAGE')) {
         return;
     }
     $full = content_url_get_full();
     if ($act == 'savegroups') {
         $this->Contest_UpdateRecievedGroupUsed($id);
     } else {
         if ($act == 'savecompilers') {
             $this->Contest_UpdateRecievedCompilers($id);
         } else {
             if ($act == 'addcat') {
                 $this->Categories_Add($id);
             } else {
                 if ($act == 'delcat') {
                     $this->Categories_Del($uid);
                 } else {
                     if ($act == 'upcat') {
                         $this->Categories_Up($uid);
                     } else {
                         if ($act == 'downcat') {
                             $this->Categories_Down($uid);
                         } else {
                             if ($act == 'createproblem') {
                                 $this->Problems_Create($id, $catid);
                             } else {
                                 if ($act == 'delproblem') {
                                     $this->Problems_Delete($uid);
                                 } else {
                                     if ($act == 'saveproblem') {
                                         $this->Problems_Save($uid);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #8
0
 function OuterHTML()
 {
     $res = '';
     $n = count($this->pages);
     $p = "count={$n};";
     for ($i = 0; $i < $n; $i++) {
         $p .= 'tab' . $i . '=' . prepare_arg($this->pages[$i]['title']) . ';';
     }
     if ($this->settings['name'] == '') {
         $suff = 'tabctrl';
     } else {
         $suff = $this->settings['name'];
     }
     if (isset($GLOBALS[$suff]) && $GLOBALS[$suff] != '') {
         $active = $GLOBALS[$suff];
     } else {
         $active = 0;
     }
     if ($active < 0) {
         $active = 0;
     }
     if ($active >= count($this->pages)) {
         $active = count($this->pages) - 1;
     }
     $p .= ';active=' . $active;
     $url = $this->settings['url'];
     if ($url == '') {
         $url = content_url_get_full();
     }
     $p .= ';url=' . prepare_arg($url);
     $res .= stencil_tabo($p . ';suff=' . prepare_arg($this->settings['name']));
     $res .= $this->pages[$active]['src'];
     $res .= stencil_tabc();
     return $res;
 }
Example #9
0
 function Editor_ContentManage()
 {
     global $act;
     $list = wiki_content_get_list();
     if ($act == 'save') {
         $this->UpdateContentsLookup($list);
     }
     formo('title=Следить за разделами;');
     println('<form action="' . content_url_get_full() . '&act=save" method="post">');
     $this->PrintContents(1, $list);
     settings_form_buttons();
     println('</form>');
     formc();
 }
Example #10
0
        function Editor_LogManage()
        {
            global $active, $act, $CORE;
            $CORE->AddStyle('log');
            if (isset($active)) {
                if ($active == '0') {
                    $this->settings['active'] = false;
                } else {
                    $this->settings['active'] = true;
                }
                $this->UpdateSettings();
            }
            if ($act == 'free') {
                $this->FreeLogs();
            }
            redirector_add_skipvar('act', 'free');
            $url = content_url_get_full();
            $update_active = 'nav (\'' . $url . '&active=' . ($this->settings['active'] ? '0' : '1') . '\');';
            $free_logs = 'cnav (\'Вы уверены что хотите очистить все файлы журналов?\', \'' . $url . '&act=free\');';
            formo('title=Управление сервисом');
            ?>
  <input type="checkbox" class="cb" onclick="<?php 
            echo $update_active;
            ?>
" value="1"<?php 
            echo $this->settings['active'] ? ' checked' : '';
            ?>
>&nbsp;Вести журналирование <i>(если данная опция неактивна, то сервис журналирования продолжит существовать, однако все журналирование будет отключено)</i><div id="hr"></div>
  <button class="block" onclick="<?php 
            echo $free_logs;
            ?>
">Очистить файлы журналов</button>
<?php 
            formc();
        }
Example #11
0
 function Editor_DrawHistory()
 {
     global $action, $id;
     $del = $this->GetAllowed('DELETE');
     $edit = $this->GetAllowed('EDIT');
     if ($action == 'delete') {
         redirector_add_skipvar('id');
         if ($del) {
             $this->DeleteContentById($id);
         }
     } else {
         if ($action == 'rollback') {
             redirector_add_skipvar('action', 'rollback');
             redirector_add_skipvar('id');
             if ($edit) {
                 $this->Rollback($id);
             }
         }
     }
     $q = db_select($this->settings['content'], array('*'), '', 'ORDER BY `timestamp` DESC');
     if (db_affected() > 0) {
         println('<ul id="history">');
         $i = 0;
         while ($r = db_row($q)) {
             $time = format_ltime($r['timestamp']);
             $time = '<a href=".?oldid=' . $r['id'] . '">' . $time . '</a>';
             $user = user_generate_info_string($r['user_id']);
             $actions = '';
             if ($edit) {
                 $actions .= '[<a href=".?wiki=history&action=rollback&id=' . $r['id'] . '">Вернуться к этой версии</a>]';
             }
             if ($del) {
                 $actions .= stencil_ibtnav('minus_s.gif', content_url_get_full() . '&action=delete&id=' . $r['id'], 'Удалить', 'Удалить эту версию статьи?');
             }
             if ($actions != '') {
                 $actions = ' | ' . $actions;
             }
             if ($i < 2) {
                 println('  <li><div class="top">' . $time . ' | ' . $user . ' ' . $actions . '</div></li>');
             } else {
                 println('  <li><div>' . $time . ' | ' . $user . ' ' . $actions . '</div></li>');
             }
             $i++;
         }
         println('</ul>');
     } else {
         println('<span class="contentSub2">' . '<i>Журнал изменений пуст</i></span>');
     }
 }
Example #12
0
 function prepareURL($path = '', $volume = '')
 {
     $url = content_url_get_full();
     if ($path == '') {
         $path = $this->path;
     }
     if ($volume == '') {
         $volume = $this->volume;
     }
     return htmlspecialchars($url) . '&volume=' . htmlspecialchars($volume) . '&path=' . htmlspecialchars($path);
 }