Пример #1
0
 /**
  * Get an instance of the RepoSearch
  * @return RepoSearch
  */
 public static function instance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Пример #2
0
<?php

define("DIR_BASE", dirname(__FILE__) . "/");
// Register a basic autoloader
spl_autoload_register("autoload");
function autoload($class_name)
{
    $file = DIR_BASE . "class/" . $class_name . '.php';
    if (file_exists($file)) {
        require DIR_BASE . "class/" . $class_name . '.php';
    }
}
// Register the different searches
RepoSearch::instance()->register("Github");
RepoSearch::instance()->register("BitBucket");
RepoSearch::instance()->register("Freshmeat");
Пример #3
0
<?php
/**
 * A basic page to display search results.
 * Ideally this should be in a template.
 */

require(dirname (__FILE__) . "/../init.php");

$resultArray = array();
if( isset($_GET['term']) )
{
	$resultArray = RepoSearch::instance()->search(urlencode($_GET['term']));
}

if( count($resultArray) > 0 )
{
	$li = '';
	foreach( $resultArray as $result )
	{
		$li .= '<li><a href="' . $result->url . '">' . $result->name . '</a> on ' . $result->type . '</li>';
	}
	
	?>
		<h1>Results</h1>
		<ul class="result clearfix">
			<?=$li?>
		</ul>
	<?
	
}