Exemplo n.º 1
0
} else {
    $blog = new ArtefactTypeBlog($id);
}
if (!empty($blog)) {
    $blog->check_permission();
}
if (!isset($limit)) {
    $limit = param_integer('limit', 5);
}
if (!isset($setlimit)) {
    $setlimit = 0;
}
if (!isset($offset)) {
    $offset = param_integer('offset', 0);
}
$posts = ArtefactTypeBlogPost::get_posts($id, $limit, $offset);
$template = 'artefact:blog:posts.tpl';
$pagination = array('baseurl' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $id, 'id' => 'blogpost_pagination', 'jsonscript' => 'artefact/blog/view/index.json.php', 'datatable' => 'postlist', 'setlimit' => $setlimit);
ArtefactTypeBlogPost::render_posts($posts, $template, array(), $pagination);
$strpublished = json_encode(get_string('published', 'artefact.blog'));
$strdraft = json_encode(get_string('draft', 'artefact.blog'));
$strchangepoststatuspublish = json_encode(get_string('publish', 'artefact.blog'));
$strchangepoststatusunpublish = json_encode(get_string('unpublish', 'artefact.blog'));
$js = <<<EOF
function changepoststatus_success(form, data) {

    if (\$('changepoststatus_' + data.id + '_currentpoststatus').value === "0") {
        removeElementClass(\$('posttitle_' + data.id), 'draft');
        addElementClass(\$('posttitle_' + data.id), 'published');
        \$('poststatus' + data.id).innerHTML = {$strpublished};
        \$('changepoststatus_' + data.id + '_submit').innerHTML = '<span class="prs icon icon-times text-danger"></span> ' + {$strchangepoststatusunpublish};
Exemplo n.º 2
0
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package    mahara
 * @subpackage artefact-blog
 * @author     Catalyst IT Ltd
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
 *
 */
define('INTERNAL', 1);
define('JSON', 1);
require dirname(dirname(dirname(dirname(__FILE__)))) . '/init.php';
safe_require('artefact', 'blog');
json_headers();
$id = param_integer('id');
$limit = param_integer('limit', ArtefactTypeBlog::pagination);
$offset = param_integer('offset', 0);
list($count, $data) = ArtefactTypeBlogPost::get_posts($USER, $id, $limit, $offset);
$result = array('error' => false, 'count' => $count, 'limit' => $limit, 'offset' => $offset, 'data' => $data);
echo json_encode($result);