function post_to_json($post, $tojson = true) { global $settings; global $_DB_TAGS; global $_DB_CATEGORIES; // Permalink $post['permalink'] = Url::post($post, true); // Get tags $post['tags'] = $_DB_TAGS->get_by_idpost(array('id_post' => $post['id'])); // Category $category = $_DB_CATEGORIES->get(array('id' => $post['id_cat'])); array_push($post['tags'], array('name' => $category['name'], 'name_human' => $category['name'])); /* The above array_push line may need to be rewritten. $post['tags'] now has the following structure... Array ( [0] => Array ( [name] => startrek [name_human] => star trek ) [1] => Array ( [name] => icecream [name_human] => ice cream ) ) */ // Content // Src images relatives to absolute $domain = $settings['url']; $post['content'] = preg_replace("/(src)\\=\"([^(http|data:image)])(\\/)?/", "\$1=\"{$domain}\$2", $post['content'][0]); // Unset unset($post['read_more']); unset($post['filename']); unset($post['id_cat']); unset($post['id_user']); unset($post['mode']); unset($post['draft']); unset($post['visits']); unset($post['allow_comments']); if ($tojson) { return json_encode($post); } return $post; }
</tr> </thead> <tbody> <?php //print_r($data); if ($data['num'] > 0) { foreach ($data['posts'] as $p) { # code... //print_r($p); //echo $p->id; if ($p->status == '0') { $status = UNPUBLISHED; } else { $status = PUBLISHED; } echo "\n <tr>\n <td>{$p->id}</td>\n <td><a href=\"" . Url::post($p->id) . "\" target=\"_new\">{$p->title}</a></td>\n <td>" . Categories::name($p->cat) . "</td>\n <td>" . Date::format($p->date) . "</td>\n <td>{$status}</td>\n <td>\n <a href=\"index.php?page=posts&act=edit&id={$p->id}&token=" . TOKEN . "\" class=\"label label-success\">" . EDIT . "</a> \n <a href=\"index.php?page=posts&act=del&id={$p->id}&token=" . TOKEN . "\" class=\"label label-danger\" \n onclick=\"return confirm('Are you sure you want to delete this item?');\">" . DELETE . "</a>\n </td>\n <td>\n <input type=\"checkbox\" name=\"post_id[]\" value=\"{$p->id}\" id=\"select\">\n </td>\n </tr>\n "; } } else { echo "\n <tr>\n <td>\n " . NO_POST_FOUND . "\n </td>\n </tr>"; } ?> </tbody> <tfoot> <th><?php echo ID; ?> </th> <th><?php echo TITLE; ?>
?> </h1> <hr class="small"> <span class="subheading"><?php echo Options::get('siteslogan'); ?> </span> </div> </div> </div> </div> </header> <!-- Main Content --> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1"> <?php if ($data['num'] > 0) { foreach ($data['posts'] as $p) { # code... echo "\n <div class=\"post-preview\">\n <h2 class=\"post-title\"><a href=\"" . Url::post($p->id) . "\">{$p->title}</a></h2>\n \n <p class=\"post-subtitle\">" . Posts::format($p->content, $p->id) . "</p>\n <p class=\"post-meta\">" . Date::format($p->date) . " by <a href=\"#\">{$p->author}</a></p>\n </div>\n "; } echo $data['paging']; } else { echo "No Post to show"; } ?> </div> </div>
public static function mailto($text = false) { global $post; $text = $text === false ? '' : $text; $url = str_replace('&', '&', Url::post($post, true)); return 'mailto:?subject=' . rawurlencode(Blog::name() . ' - ' . $text) . '&body=' . urlencode($url); }
public static function format($post, $id) { // split post for readmore... $post = Typo::Xclean($post); $more = explode('[[--readmore--]]', $post); //print_r($more); if (count($more) > 1) { $post = explode('[[--readmore--]]', $post); $post = $post[0] . " <a href=\"" . Url::post($id) . "\">" . READ_MORE . "</a>"; } else { $post = $post; } $post = Hooks::filter('post_content_filter', $post); return $post; }
public static function url($row) { $url = Url::post($row); return $url; }
public static function googleplus($text = false) { global $post; $text = $text === false ? '' : $text; $url = Url::post($post, true); return 'https://plus.google.com/share?url=' . urlencode($text . ' ' . $url); }
</em> <?php echo Site::$desc; ?> </p> </div> <div class="sidebar-module"> <h4>Recent Post</h4> <ol class="list-unstyled"> <?php $recent = Posts::recent(10); $num = Db::$num_rows; if ($num > 0) { foreach ($recent as $r) { # code... echo "<li><a href=\"" . Url::post($r->id) . "\">{$r->title}</a></li>\n "; } } else { echo "No Post to Show"; } ?> </ol> </div> <div class="sidebar-module"> <h4>Elsewhere</h4> <ol class="list-unstyled"> <li><a href="#">GitHub</a></li> <li><a href="#">Twitter</a></li> <li><a href="#">Facebook</a></li> </ol> </div>
public static function tweet_link() { global $post; $url = Url::post($post, true); return 'https://twitter.com/share?url=' . urlencode($url); }
<h3 class="panel-title"><i class="fa fa-file-text-o"></i> <?php echo LATEST_POST; ?> </h3> </div> <div class="panel-body"> <ul class="list-group"> <?php $post = Posts::recent(5, 'post'); //print_r($post); if (isset($post['error'])) { echo "<li class=\"list-group-item\">{$post['error']}</li>"; } else { foreach ($post as $p) { # code... echo "\n <li class=\"list-group-item\">\n <a href=\"" . Url::post($p->id) . "\" target=\"_blank\">\n {$p->title} \n </a>\n <small class=\"badge\">{$p->author}</small>\n \n </li>"; } } ?> </ul> </div> </div> </div> <div class="col-md-6"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><i class="fa fa-bar-chart"></i> <?php echo STATISTIC; ?> </h3> </div>
<div class="col-sm-8 blog-main"> <?php if (isset($data['posts'][0]->title)) { foreach ($data['posts'] as $p) { # code... echo "\n <div class=\"blog-post\">\n <h2 class=\"blog-post-title\"><a href=\"" . Url::post($p->id) . "\">{$p->title}</a></h2>\n <p class=\"blog-post-meta\">" . Date::format($p->date) . " by <a href=\"#\">{$p->author}</a></p>\n " . Posts::content($p->content) . "\n </div>\n <hr />\n <div class=\"col-sm-12\">\n <div class=\"row\">\n <h3>Comments</h3>\n <div class=\"fb-comments\" data-href=\"http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}\" data-width=\"100%\" data-numposts=\"5\" data-colorscheme=\"light\"></div>\n </div>\n </div>\n "; } } else { //echo "Error, Post not found."; Control::error('404'); } ?> </div> <?php Theme::theme('rightside', $data);
public static function framasphere($title = false) { global $post; $title = $title === false ? '' : $title; $url = Url::post($post, true); return 'https://framasphere.org/bookmarklet?url=' . urlencode($url) . '&title=' . urlencode($title); }