Пример #1
0
function render_entity($dbc, $keywords)
{
    $query = "SELECT * FROM def where name = '{$keywords}'";
    $result = mysqli_query($dbc, $query) or die('Error querying database.');
    if ($row = mysqli_fetch_array($result)) {
        render_content($row);
    }
}
Пример #2
0
//for breadcrumbs
$blockid = required_param('blockid', PARAM_INT);
// Next look for optional variables.
$id = optional_param('id', 0, PARAM_INT);
//error handling
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
    print_error('invalidcourse', 'block_comments_and_ratings', $courseid);
}
// for geting $cm later on
$modinfo = get_fast_modinfo($course);
//moodle require_login method which handles lots of things in background
require_login($course);
//$PAGE settings from PAGE_API
$PAGE->set_url(new moodle_url('/blocks/comments_and_ratings/view.php', array('id' => $courseid)));
$PAGE->set_context(context_course::instance($courseid));
$PAGE->set_title('Comments And Ratings');
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_pagelayout('course');
$PAGE->set_pagetype('course-view-' . $course->format);
$PAGE->set_cacheable(false);
//Creating breadcrumbs
$settingsnode = $PAGE->settingsnav->add(get_string('commentsandratingssettings', 'block_comments_and_ratings'));
$editurl = new moodle_url('/blocks/comments_and_ratings/view.php', array('id' => $id, 'courseid' => $courseid, 'blockid' => $blockid));
$editnode = $settingsnode->add(get_string('editpage', 'block_comments_and_ratings'), $editurl);
$editnode->make_active();
print $OUTPUT->header();
render_title($course, $PAGE->title);
render_content($course, $modinfo, $PAGE->context);
//Moze se dodati jos sta god padne na pamet.
//Npr rejtinzi
print $OUTPUT->footer();
Пример #3
0
    <?php 
$relation_tab_id = 'docs';
include_once "./relation_header.php";
//$query = "SELECT * FROM resource where title like '%$keywords%' or description like '%$keywords%' ORDER BY title ASC LIMIT 0,10";
// Calculate pagination information
$cur_page = isset($_GET['page']) ? $_GET['page'] : 1;
$results_per_page = 10;
// number of results per page
$skip = ($cur_page - 1) * $results_per_page;
$total = get_total($docs, $dbc);
$num_pages = ceil($total / $results_per_page);
echo '<p></p>';
echo '<p><font color="gray">该语义关系出现于如下' . $total . '篇文献之中:</font></p>';
echo '<hr>';
$query = build_query($docs) . " LIMIT {$skip}, {$results_per_page}";
$result = mysqli_query($dbc, $query) or die('Error querying database.');
while ($row = mysqli_fetch_array($result)) {
    render_content($row);
}
if ($num_pages > 1) {
    generate_page_links($id, $cur_page, $num_pages);
}
?>

</div>
<!-- Example row of columns -->


<!-- /container -->
<?php 
include_once "./foot.php";
Пример #4
0
    case preg_match('#^/document/\\d+#', $uri):
        $selfPath .= '/document/';
        $title = '';
        require 'controller/document.php';
        $tpl = 'document';
        break;
    case preg_match('#^/document/add#', $uri):
        $title = 'New document';
        $selfPath .= '/document/add';
        require 'controller/add.php';
        $tpl = 'add';
        break;
    case preg_match('#^/document/edit#', $uri):
        require 'controller/add.php';
        $tpl = 'add';
        $title = 'edit';
        $selfPath .= '/document/edit';
        break;
    case preg_match('#^/document/remove#', $uri):
        require 'controller/remove.php';
        break;
    default:
        $tpl = '404';
        $title = '404';
        $selfPath .= '404';
        break;
}
$data['title'] = $title;
$data['selfPath'] = $selfPath;
render_content($tpl, $data);
Пример #5
0
function content_content(&$a, $update = 0)
{
    require_once 'include/conversation.php';
    // Currently security is based on the logged in user
    if (!local_user()) {
        return;
    }
    $arr = array('query' => $a->query_string);
    call_hooks('content_content_init', $arr);
    $datequery = $datequery2 = '';
    $group = 0;
    $nouveau = false;
    if ($a->argc > 1) {
        for ($x = 1; $x < $a->argc; $x++) {
            if (is_a_date_arg($a->argv[$x])) {
                if ($datequery) {
                    $datequery2 = escape_tags($a->argv[$x]);
                } else {
                    $datequery = escape_tags($a->argv[$x]);
                    $_GET['order'] = 'post';
                }
            } elseif ($a->argv[$x] === 'new') {
                $nouveau = true;
            } elseif (intval($a->argv[$x])) {
                $group = intval($a->argv[$x]);
                $def_acl = array('allow_gid' => '<' . $group . '>');
            }
        }
    }
    $o = '';
    $contact_id = $a->cid;
    require_once 'include/acl_selectors.php';
    $cid = x($_GET, 'cid') ? intval($_GET['cid']) : 0;
    $star = x($_GET, 'star') ? intval($_GET['star']) : 0;
    $bmark = x($_GET, 'bmark') ? intval($_GET['bmark']) : 0;
    $order = x($_GET, 'order') ? notags($_GET['order']) : 'comment';
    $liked = x($_GET, 'liked') ? intval($_GET['liked']) : 0;
    $conv = x($_GET, 'conv') ? intval($_GET['conv']) : 0;
    $spam = x($_GET, 'spam') ? intval($_GET['spam']) : 0;
    $nets = x($_GET, 'nets') ? $_GET['nets'] : '';
    $cmin = x($_GET, 'cmin') ? intval($_GET['cmin']) : 0;
    $cmax = x($_GET, 'cmax') ? intval($_GET['cmax']) : 99;
    $file = x($_GET, 'file') ? $_GET['file'] : '';
    if (x($_GET, 'search') || x($_GET, 'file')) {
        $nouveau = true;
    }
    if ($cid) {
        $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
    }
    if ($nets) {
        $r = q("select id from contact where uid = %d and network = '%s' and self = 0", intval(local_user()), dbesc($nets));
        $str = '';
        if (count($r)) {
            foreach ($r as $rr) {
                $str .= '<' . $rr['id'] . '>';
            }
        }
        if (strlen($str)) {
            $def_acl = array('allow_cid' => $str);
        }
    }
    $sql_options = $star ? " and starred = 1 " : '';
    $sql_options .= $bmark ? " and bookmark = 1 " : '';
    $sql_nets = $nets ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '';
    $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$sql_options} ) ";
    if ($group) {
        $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
        if (!count($r)) {
            if ($update) {
                killme();
            }
            notice(t('No such group') . EOL);
            goaway($a->get_baseurl(true) . '/network');
            // NOTREACHED
        }
        $contacts = expand_groups(array($group));
        if (is_array($contacts) && count($contacts)) {
            $contact_str = implode(',', $contacts);
        } else {
            $contact_str = ' 0 ';
            info(t('Group is empty'));
        }
        $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND ( `contact-id` IN ( {$contact_str} ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) ";
        $o = replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Group: %s'), $r[0]['name']))) . $o;
    } elseif ($cid) {
        $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d \n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
        if (count($r)) {
            $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 {$sql_options} AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
        } else {
            killme();
        }
    }
    $sql_extra3 = '';
    if ($datequery) {
        $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
    }
    if ($datequery2) {
        $sql_extra3 .= protect_sprintf(sprintf(" AND item.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
    }
    $sql_extra2 = $nouveau ? '' : " AND `item`.`parent` = `item`.`id` ";
    $sql_extra3 = $nouveau ? '' : $sql_extra3;
    $sql_table = "`item`";
    if (x($_GET, 'search')) {
        $search = escape_tags($_GET['search']);
        if (strpos($search, '#') === 0) {
            $tag = true;
            $search = substr($search, 1);
        }
        if (get_config('system', 'only_tag_search')) {
            $tag = true;
        }
        if ($tag) {
            //$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
            //	dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
            //$sql_table = "`term` INNER JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
            $sql_extra = "";
            $sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
        } else {
            if (get_config('system', 'use_fulltext_engine')) {
                $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
            } else {
                $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
            }
        }
    }
    if (strlen($file)) {
        $sql_extra .= file_tag_file_query('item', unxmlify($file));
    }
    if ($conv) {
        $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
        $myurl = substr($myurl, strpos($myurl, '://') + 3);
        $myurl = str_replace('www.', '', $myurl);
        $diasp_url = str_replace('/profile/', '/u/', $myurl);
        $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($myurl)));
    }
    $pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
    if ($nouveau) {
        // "New Item View" - show all items unthreaded in reverse created date order
        $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,\n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,\n\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM {$sql_table} INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1\n\t\t\tAND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\t\t{$simple_update}\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t{$sql_extra} {$sql_nets}\n\t\t\tORDER BY `item`.`received` DESC {$pager_sql} ", intval($_SESSION['uid']));
    } else {
        // Normal conversation view
        if ($order === 'post') {
            $ordering = "`created`";
        } else {
            $ordering = "`commented`";
        }
        $start = dba_timer();
        $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`\n\t\t\tFROM {$sql_table} INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\tAND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` = `item`.`id`\n\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets}\n\t\t\tORDER BY `item`.{$ordering} DESC {$pager_sql} ", intval(local_user()));
        $first = dba_timer();
        // Then fetch all the children of the parents that are on this page
        $parents_arr = array();
        $parents_str = '';
        if (count($r)) {
            foreach ($r as $rr) {
                if (!in_array($rr['item_id'], $parents_arr)) {
                    $parents_arr[] = $rr['item_id'];
                }
            }
            $parents_str = implode(', ', $parents_arr);
            $items = q("SELECT `item`.*, `item`.`id` AS `item_id`,\n\t\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,\n\t\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\t\tFROM {$sql_table} INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\t\tAND `item`.`moderated` = 0\n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\tAND `item`.`parent` IN ( %s )\n\t\t\t\t{$sql_extra} ", intval(local_user()), dbesc($parents_str));
            $second = dba_timer();
            $items = conv_sort($items, $ordering);
        } else {
            $items = array();
        }
    }
    logger('parent dba_timer: ' . sprintf('%01.4f', $first - $start));
    logger('child  dba_timer: ' . sprintf('%01.4f', $second - $first));
    // Set this so that the conversation function can find out contact info for our wall-wall items
    $a->page_contact = $a->contact;
    $mode = $nouveau ? 'network-new' : 'network';
    $o = render_content($a, $items, $mode, false);
    header('Content-type: application/json');
    echo json_encode($o);
    killme();
}
Пример #6
0
    $category_id = (int) $args['category_id'];
    $category = isset($args['category_id']) ? $args['category_id'] : Category::getFirst();
    $categories = CategoryRender::render($category_id, $partial_category);
    $articles = PostRender::renderForCategory($category_id, $partial_article);
    $category = new Category($category_id);
    render_content(['articles' => $articles, 'category' => $categories]);
});
// render a post
Route::get('show_post', function ($args) {
    $partial_article = file_get_contents(ROOT . '/templates/' . THEME . '/partials/article.html');
    $partial_category = file_get_contents(ROOT . '/templates/' . THEME . '/partials/category.html');
    $post_id = isset($args['post_id']) ? (int) $args['post_id'] : NULL;
    $post = new Post($post_id);
    $articles = PostRender::renderPost(new Post($post_id), $partial_article);
    $categories = CategoryRender::render($post->category_id, $partial_category);
    render_content(['articles' => $articles, 'category' => $categories]);
});
// default action
Route::get('', function ($args) {
    $category_id = 1;
    $year = !empty($args['year']) ? (int) $args['year'] : date('Y');
    Route::run('show_category', ['category_id' => $category_id, 'year' => $year]);
});
// render page content
function render_content($replaces)
{
    $content = new Content(1);
    $layout_content = file_get_contents(ROOT . '/templates/' . THEME . '/layout.html');
    $layout_content = str_replace('{theme}', THEME, $layout_content);
    $layout_content = str_replace('{url}', $_SERVER['SCRIPT_NAME'], $layout_content);
    $layout_content = str_replace('{title}', $content->title, $layout_content);
Пример #7
0
function render_html($pdf_file, $au)
{
    global $lock;
    ?>

    <html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" media="screen, projection" href="opraf.css" />
	<script src="opraf.js"></script>
	<title>Korektury <?php 
    ee($pdf_file);
    ?>
</title>
	</head>

	<body <?php 
    if ($lock) {
        ?>
class='locked'<?php 
    }
    ?>
>

	<h1>Korektury <?php 
    ee($pdf_file);
    ?>
    <?php 
    if ($locked) {
        echo "&ndash; Od " . $lock["cas"] . " zanáší " . $lock["au"] . " korektury.";
    }
    ?>
    </h1>
	<i>Klikni na chybu, napiš komentář</i>  |
	<a href="?action=ls">ls</a> |
	<a href="?action=doc">help</a> |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
	<a href="https://mam.mff.cuni.cz/">hlavní stránka</a> |
	<a href="https://mam.mff.cuni.cz/admin">admin</a> |
	<a href="https://mam.mff.cuni.cz/wiki">wiki</a> |
	<hr/>

	<div id="commform-div">
	<form action='' onsubmit='save_scroll(this)' id="commform" method="POST">
	  <input size="8" name="au" value="<?php 
    ee($au);
    ?>
"/>
	  <input type=submit value="Oprav!"/>
	  <button type="button" onclick="close_commform()">Zavřít</button>
	  <br/>
	  <textarea onkeypress="textarea_onkey(event);" id="commform-text" cols=40 rows=10 name="txt"></textarea>
	  <br/>
	  <input type="hidden" size="3" name="pdf" value=<?php 
    eeq($pdf_file);
    ?>
/>
	  <input type="hidden" size="3" id="commform-x" name="x"/>
	  <input type="hidden" size="3" id="commform-y" name="y"/>
	  <input type="hidden" size="3" id="commform-img-id" name="img-id"/>
	  <input type="hidden" size="3" id="commform-id" name="id"/>
	  <input type="hidden" size="3" id="commform-action" name="action"/>
	  <input type="hidden" size="3" id="commform-action" name="scroll"/>
	</form>
	</div>
	<?php 
    render_content();
    ?>
</body> </html>
<?php 
}