/**
 * Generate the json data to be plotted in the graph
 * TODO: Ugly code, need to revise  
 * 
 * The data is an array of graph coordinates, which in our case is in this form
 * ([time], [number of likes/comments])  
 * 
 * @param $period
 *   The period to calculate the most popular status (by month, e.g. 6 or 12 months)
 */
function generate_data($statuses, $period = null) {
  $oldest_status = get_oldest($statuses);  
  $oldest_year = get_year($oldest_status['updated_time']); // year of the oldest status    
  $newest_status = get_newest($statuses);  
  $newest_year = get_year($newest_status['updated_time']); // year of the most recent status     
      
  // Currently the graph can only plot time period of 2, 3, 4, 6
  // So make it 12 months if an invalid number is passed
  if (($period == null) || ($period > 12) || ((12 % $period) != 0)) {
  	$period = 12;
  }
  
  $from = "01-01-$oldest_year";
  
  $data = array();  
  for ($year = $oldest_year; $year <= $newest_year + 1; $year++) {  	
  	$to = "01-01-$year";  	
  	for ($month = 1 + $period; $month <= 12 + 1; $month += $period) {
      if ($to != $from) {  	      	    	    	    	  
  	    $most_popular = get_most_popular($statuses, '', $from, $to);
  	    if ($most_popular) {
  	      $popularity = $most_popular['like_count'] + $most_popular['comment_count']; 
   	    }
  	    else {
  	      $popularity = 0;
  	    }    	    	    	 
  	    // Notes: The Flot API can only accept time data as Javascript timestamp
  	    // We need to pass a valid date string and generate timestamp at front end  	      	  
  	    $data['plot_data'][] = array(date('M j, Y', strtotime("$to")), $popularity);
  	    $data['status_data'][] = array(
  	      'status' => status_format_js($most_popular),
  	      'from' => $from,
  	      'to' => $to,
  	    );  	    
  	    
  	    if ($year == $newest_year + 1) {  	      
  	      break;	
  	    }
  	  } 
  	  $next = $month + 1; 	    	    	 
  	  $from = $to;
  	  $to = "01-$month-$year";
  	}  	
  }	  
  return $data;
}
Esempio n. 2
0
?>
<div class="blog">
    <div class="container">
        <h2><?php 
echo ucfirst($_GET['t']);
?>
</h2>
        <div class="single-inline">
            <?php 
if (isset($_GET['t'])) {
    $display = 4;
    $start = isset($_GET['s']) && filter_var($_GET['s'], FILTER_VALIDATE_INT, array('min_range' => 1)) ? $_GET['s'] : 0;
    $type = $_GET['t'];
    switch ($type) {
        case 'newest':
            $result = get_newest($start, $display);
            break;
        case 'topmonth':
            $result = get_topmonth($start, $display);
            break;
        case 'topweek':
            $result = get_topweek($start, $display);
            break;
        case 'eSport':
            $result = get_news_type($type, $start, $display);
            break;
        case 'news':
            $result = get_news_type($type, $start, $display);
            break;
        case 'review':
            $result = get_news_type($type, $start, $display);
Esempio n. 3
0
# \\param fmt
# \\return
# \\description
# \\see func1 func2 [S[apps/plugin.c]]
#
# Markup:
# [W[wiki url]]
# [S[svn url]]
# [F[function]]
# [[url]]
# %BR%
# =code=

MOO;

foreach(get_newest() as $line)
{
    echo "\n".clean_func($line["func"])."\n";

    if(strlen($line["group"]) > 0)
        echo "    \\group ".$line["group"]."\n";

    if(strlen($line["cond"]) > 2)
        echo "    \\conditions "._simplify($line["cond"])."\n";

    foreach(get_args($line["func"]) as $param)
    {
        if(strlen($param) > 0 && $param != "...")
        {
            $param = split_var($param);
            $param = $param[1];
Esempio n. 4
0
				<p style="height: 10px;"></p>
			</div>
			
			<div class="newest_youth">
					<?php 
$t = array("Weibliche A", "Männliche A", "Weibliche B", "Männliche B", "Weibliche C", "Männliche C", "Männliche D", "Männliche E", "Minis");
$c = 0;
$html = '<table>';
foreach ($t as $k) {
    $c++;
    if ($c % 2 == 1) {
        $color = '#ccc';
    } else {
        $color = '#fff';
    }
    $bericht = get_newest($k);
    $html .= '<tr style="background-color: ' . $color . '; font-weight: 800;">';
    $html .= '<td><a href="bericht.php?id=' . $bericht['id'] . '">' . $k . '</a></td></tr>';
    $html .= '<tr style="background-color: ' . $color . ';">';
    $html .= '<td style="padding-left: 20px; padding-right: 20px;"><a href="bericht.php?id=' . $bericht['id'] . '">' . $bericht['titel'] . '</a></td></tr>';
}
$html .= '</table>';
echo $html;
?>
					<p style="height: 10px;"></p>
				</div>
			
		</div>
		<p style="width: 1000px;"></p>
	</div>
	<footer>
Esempio n. 5
0
<?
require_once("functions.php");

$input = file_get_contents($argv[1]);

$input = parse_documentation($input);

/* Format input */
foreach($input as $rootname => $rootel)
{
    foreach($rootel as $name => $el)
        $input[$name] = $el;
    unset($input[$rootname]);
}

$new = get_newest();

/* Format new */
foreach($new as $name => $el)
{
    unset($new[$name]);
    $name = clean_func($el["func"]);
    
    $new[$name] = array(
                    "group" => array($el["group"]),
                    "description" => array("")
    );
    
    if(strlen($el["cond"]) > 2)
        $new[$name]["conditions"][0] = $el["cond"];