Browse Source

Merge pull request #69 from Kanti/viewCount

View counter Added by @Kanti.
pull/73/head
Danang Probo Sayekti 11 years ago
parent
commit
711d9e1fa5
11 changed files with 2394 additions and 2490 deletions
  1. +3
    -0
      config/config.ini.example
  2. +8
    -2
      system/admin/admin.php
  3. +2
    -1
      system/admin/views/posts-list.html.php
  4. +2
    -1
      system/admin/views/user-posts.html.php
  5. +967
    -998
      system/htmly.php
  6. +1301
    -1439
      system/includes/functions.php
  7. +47
    -47
      vendor/composer/installed.json
  8. +13
    -1
      vendor/suin/php-rss-writer/README.md
  9. +27
    -0
      vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Item.php
  10. +9
    -0
      vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ItemInterface.php
  11. +15
    -1
      vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ItemTest.php

+ 3
- 0
config/config.ini.example View File

@ -80,5 +80,8 @@ lightbox = "off"
; Set the theme here
views.root = "themes/logs"
;Enable view Counter, the options is "true" and "false". If set to "true", you can see the Counts in Admin page.
views.counter = "true"
; Framework config. No need to edit.
views.layout = "layout"

+ 8
- 2
system/admin/admin.php View File

@ -347,7 +347,9 @@ function get_recent_posts() {
$posts = get_profile($_SESSION[config("site.url")]['user'], 1, 5);
if(!empty($posts)) {
echo '<table class="post-list">';
echo '<tr class="head"><th>Title</th><th>Published</th><th>Tag</th><th>Operations</th></tr>';
echo '<tr class="head"><th>Title</th><th>Published</th>';
if(config("views.counter") == "true") echo '<th>Views</th>';
echo '<th>Tag</th><th>Operations</th></tr>';
$i = 0; $len = count($posts);
foreach($posts as $p) {
if ($i == 0) {
@ -363,6 +365,7 @@ function get_recent_posts() {
echo '<tr class="' . $class . '">';
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
echo '<td>' . date('d F Y', $p->date) . '</td>';
if(config("views.counter") == "true") echo '<td>' . $p->views . '</td>';
echo '<td>' . $p->tag . '</td>';
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
echo '</tr>';
@ -379,7 +382,9 @@ function get_recent_pages() {
if(!empty($posts)) {
krsort($posts);
echo '<table class="post-list">';
echo '<tr class="head"><th>Title</th><th>Operations</th></tr>';
echo '<tr class="head"><th>Title</th>';
if(config("views.counter") == "true") echo '<th>Views</th>';
echo '<th>Operations</th></tr>';
$i = 0; $len = count($posts);
foreach($posts as $p) {
if ($i == 0) {
@ -394,6 +399,7 @@ function get_recent_pages() {
$i++;
echo '<tr class="' . $class . '">';
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
if(config("views.counter") == "true") echo '<td>' . $p->views . '</td>';
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
echo '</tr>';
}


+ 2
- 1
system/admin/views/posts-list.html.php View File

@ -1,7 +1,7 @@
<h2 class="post-index"><?php echo $heading?></h2>
<?php if(!empty($posts)) {?>
<table class="post-list">
<tr class="head"><th>Title</th><th>Published</th><th>Author</th><th>Tag</th><th>Operations</th></tr>
<tr class="head"><th>Title</th><th>Published</th><?php if(config("views.counter") == "true"):?><th>Views</th><?php endif;?><th>Author</th><th>Tag</th><th>Operations</th></tr>
<?php $i = 0; $len = count($posts);?>
<?php foreach($posts as $p):?>
<?php
@ -19,6 +19,7 @@
<tr class="<?php echo $class ?>">
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
<td><?php echo date('d F Y', $p->date) ?></td>
<?php if(config("views.counter") == "true"):?><td><?php echo $p->views ?></td><?php endif;?>
<td><a target="_blank" href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></td>
<td><?php echo $p->tag ?></td>
<td><a href="<?php echo $p->url ?>/edit?destination=admin/posts">Edit</a> <a href="<?php echo $p->url ?>/delete?destination=admin/posts">Delete</a></td>


+ 2
- 1
system/admin/views/user-posts.html.php View File

@ -1,7 +1,7 @@
<h2 class="post-index"><?php echo $heading?></h2>
<?php if(!empty($posts)) {?>
<table class="post-list">
<tr class="head"><th>Title</th><th>Published</th><th>Tag</th><th>Operations</th></tr>
<tr class="head"><th>Title</th><th>Published</th><th>Views</th><th>Tag</th><th>Operations</th></tr>
<?php $i = 0; $len = count($posts);?>
<?php foreach($posts as $p):?>
<?php
@ -19,6 +19,7 @@
<tr class="<?php echo $class ?>">
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
<td><?php echo date('d F Y', $p->date) ?></td>
<td><?php echo $p->views ?></td>
<td><?php echo $p->tag ?></td>
<td><a href="<?php echo $p->url ?>/edit?destination=admin/mine">Edit</a> <a href="<?php echo $p->url ?>/delete?destination=admin/mine">Delete</a></td>
</tr>


+ 967
- 998
system/htmly.php
File diff suppressed because it is too large
View File


+ 1301
- 1439
system/includes/functions.php
File diff suppressed because it is too large
View File


+ 47
- 47
vendor/composer/installed.json View File

@ -1,51 +1,4 @@
[
{
"name": "suin/php-rss-writer",
"version": "1.2",
"version_normalized": "1.2.0.0",
"source": {
"type": "git",
"url": "git://github.com/suin/php-rss-writer.git",
"reference": "1.2"
},
"dist": {
"type": "zip",
"url": "https://github.com/suin/php-rss-writer/zipball/1.2",
"reference": "1.2",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2012-08-23 00:45:18",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Suin\\RSSWriter": "Source"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "suin",
"email": "suinyeze@gmail.com",
"homepage": "https://www.facebook.com/suinyeze",
"role": "Developer, Renaming Specialist"
}
],
"description": "Yet another simple RSS writer library for PHP 5.3 or later.",
"homepage": "https://github.com/suin/php-rss-writer",
"keywords": [
"feed",
"generator",
"rss",
"writer"
]
},
{
"name": "michelf/php-markdown",
"version": "dev-lib",
@ -98,5 +51,52 @@
"keywords": [
"markdown"
]
},
{
"name": "suin/php-rss-writer",
"version": "1.3",
"version_normalized": "1.3.0.0",
"source": {
"type": "git",
"url": "https://github.com/suin/php-rss-writer.git",
"reference": "82812ff988bb470f746d24e153cdc138e8838ff3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/suin/php-rss-writer/zipball/82812ff988bb470f746d24e153cdc138e8838ff3",
"reference": "82812ff988bb470f746d24e153cdc138e8838ff3",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2014-03-12 06:05:28",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Suin\\RSSWriter": "Source"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "suin",
"email": "suinyeze@gmail.com",
"homepage": "https://www.facebook.com/suinyeze",
"role": "Developer, Renaming Specialist"
}
],
"description": "Yet another simple RSS writer library for PHP 5.3 or later.",
"homepage": "https://github.com/suin/php-rss-writer",
"keywords": [
"feed",
"generator",
"rss",
"writer"
]
}
]

+ 13
- 1
vendor/suin/php-rss-writer/README.md View File

@ -2,6 +2,8 @@
`\Suin\RSSWriter` is yet another simple RSS writer library for PHP 5.3 or later. This component is Licensed under MIT license.
This library can also be used to publish Podcasts.
The build status of the current master branch is tracked by Travis CI: [![Build Status](https://secure.travis-ci.org/suin/php-rss-writer.png?branch=master)](http://travis-ci.org/suin/php-rss-writer)
@ -18,6 +20,7 @@ $channel
->url('http://blog.example.com')
->appendTo($feed);
// RSS item
$item = new Item();
$item
->title("Blog Entry Title")
@ -25,6 +28,15 @@ $item
->url('http://blog.example.com/2012/08/21/blog-entry/')
->appendTo($channel);
// Podcast item
$item = new Item();
$item
->title("Some Podcast Entry")
->description("<div>Podcast body</div>")
->url('http://podcast.example.com/2012/08/21/podcast-entry/')
->enclosure('http://link-to-audio-file.com/2013/08/21/podcast.mp3', 4889, 'audio/mpeg')
->appendTo($channel);
echo $feed;
```
@ -81,4 +93,4 @@ If you want to know APIs, please see `FeedInterface`, `ChannelInterface` and `It
## License
MIT license
MIT license

+ 27
- 0
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/Item.php View File

@ -20,6 +20,8 @@ class Item implements \Suin\RSSWriter\ItemInterface
protected $isPermalink;
/** @var int */
protected $pubDate;
/** @var array */
protected $enclosure;
/**
* Set item title
@ -90,6 +92,19 @@ class Item implements \Suin\RSSWriter\ItemInterface
return $this;
}
/**
* Set enclosure
* @param var $url Url to media file
* @param int $length Length in bytes of the media file
* @param var $type Media type, default is audio/mpeg
* @return $this
*/
public function enclosure($url, $length = 0, $type = 'audio/mpeg')
{
$this->enclosure = array('url' => $url, 'length' => $length, 'type' => $type);
return $this;
}
/**
* Append item to the channel
* @param \Suin\RSSWriter\ChannelInterface $channel
@ -137,6 +152,18 @@ class Item implements \Suin\RSSWriter\ItemInterface
$xml->addChild('pubDate', date(DATE_RSS, $this->pubDate));
}
if (is_array($this->enclosure) && (count($this->enclosure) == 3))
{
$element = $xml->addChild('enclosure');
$element->addAttribute('url', $this->enclosure['url']);
$element->addAttribute('type', $this->enclosure['type']);
if ($this->enclosure['length'])
{
$element->addAttribute('length', $this->enclosure['length']);
}
}
return $xml;
}
}

+ 9
- 0
vendor/suin/php-rss-writer/Source/Suin/RSSWriter/ItemInterface.php View File

@ -51,6 +51,15 @@ interface ItemInterface
*/
public function pubDate($pubDate);
/**
* Set enclosure
* @param var $url Url to media file
* @param int $length Length in bytes of the media file
* @param var $type Media type, default is audio/mpeg
* @return $this
*/
public function enclosure($url, $length = 0, $type = 'audio/mpeg');
/**
* Append item to the channel
* @param \Suin\RSSWriter\ChannelInterface $channel


+ 15
- 1
vendor/suin/php-rss-writer/Tests/Suin/RSSWriter/ItemTest.php View File

@ -88,6 +88,15 @@ class ItemTest extends \XoopsUnit\TestCase
$this->assertSame($item, $item->appendTo($channel));
}
public function testEnclosure()
{
$url = uniqid();
$enclosure = array('url' => $url, 'length' => 0, 'type' => 'audio/mpeg');
$item = new Item();
$this->assertSame($item, $item->enclosure($url));
$this->assertAttributeSame($enclosure, 'enclosure', $item);
}
public function testAsXML()
{
$now = time();
@ -104,6 +113,10 @@ class ItemTest extends \XoopsUnit\TestCase
'guid' => "http://inessential.com/2002/09/01.php#a2",
'isPermalink' => true,
'pubDate' => $now,
'enclosure' => array(
'url' => 'http://link-to-audio-file.com/test.mp3',
'length' => 4992,
'type' => 'audio/mpeg')
);
$item = new Item();
@ -122,6 +135,7 @@ class ItemTest extends \XoopsUnit\TestCase
<category domain=\"{$data['categories'][1][1]}\">{$data['categories'][1][0]}</category>
<guid isPermaLink=\"true\">{$data['guid']}</guid>
<pubDate>{$nowString}</pubDate>
<enclosure url=\"{$data['enclosure']['url']}\" length=\"{$data['enclosure']['length']}\" type=\"{$data['enclosure']['type']}\"/>
</item>
";
$this->assertXmlStringEqualsXmlString($expect, $item->asXML()->asXML());
@ -133,7 +147,7 @@ class ItemTest extends \XoopsUnit\TestCase
$nowString = date(DATE_RSS, $now);
$data = array(
'title' => "日本語",
'title' => "Venice Film Festival",
'url' => 'http://nytimes.com/2004/12/07FEST.html',
'description' => "Some of the most heated chatter at the Venice Film Festival this week was about the way that the arrival of the stars at the Palazzo del Cinema was being staged.",
);


Loading…
Cancel
Save