forked from Chumper/Datatable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chumper
committed
Sep 5, 2013
0 parents
commit 3ac3738
Showing
14 changed files
with
388 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: php | ||
|
||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
|
||
before_script: | ||
- curl -s http://getcomposer.org/installer | php | ||
- php composer.phar install --dev | ||
|
||
script: phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "chumper/datatable", | ||
"description": "", | ||
"authors": [ | ||
{ | ||
"name": "Nils Plaschke", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"illuminate/support": "4.0.x", | ||
"illuminate/view": "4.0.x", | ||
"illuminate/foundation": "4.0.*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "3.7.*", | ||
"mockery/mockery": "dev-master" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"Chumper\\Datatable": "src/" | ||
} | ||
}, | ||
"minimum-stability": "dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Package Test Suite"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php namespace Chumper\Datatable; | ||
|
||
|
||
class Api { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php namespace Chumper\Datatable; | ||
|
||
use Illuminate\Database\Query\Builder; | ||
|
||
class Datatable { | ||
|
||
public function api(Builder $builder) | ||
{ | ||
return new Api($builder); | ||
} | ||
|
||
public function table() | ||
{ | ||
return new Table; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php namespace Chumper\Datatable; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use View; | ||
|
||
class DatatableServiceProvider extends ServiceProvider { | ||
|
||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = false; | ||
|
||
public function boot() | ||
{ | ||
$this->package('chumper/datatable'); | ||
} | ||
|
||
/** | ||
* Register the service provider. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
$this->app['datatable'] = $this->app->share(function($app) | ||
{ | ||
return new Datatable; | ||
}); | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return array('datatable'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php namespace Chumper\Datatable\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class Datatable extends Facade { | ||
|
||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() { return 'datatable'; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php namespace Chumper\Datatable; | ||
|
||
|
||
use Exception; | ||
use View; | ||
|
||
|
||
class Table { | ||
|
||
private $columns = array(); | ||
private $options = array(); | ||
private $data = array(); | ||
|
||
public function addColumn() | ||
{ | ||
foreach (func_get_args() as $title) | ||
{ | ||
if(is_array($title)) | ||
{ | ||
foreach ($title as $arrayTitle) | ||
{ | ||
$this->columns[] = $arrayTitle; | ||
} | ||
} | ||
else | ||
$this->columns[] = $title; | ||
} | ||
return $this; | ||
} | ||
|
||
public function countColumns() | ||
{ | ||
return count($this->columns); | ||
} | ||
|
||
public function setOptions() | ||
{ | ||
if(func_num_args() == 2) | ||
{ | ||
$this->options[func_get_arg(0)] = func_get_arg(1); | ||
} | ||
else if(func_num_args() == 1 && is_array(func_get_arg(0))) | ||
{ | ||
foreach (func_get_arg(0) as $key => $option) | ||
{ | ||
$this->options[$key] = $option; | ||
} | ||
} | ||
else | ||
throw new Exception('Invalid number of options provided for the method "setOptions"'); | ||
return $this; | ||
} | ||
|
||
public function setData(array $data) | ||
{ | ||
$this->data = $data; | ||
return $this; | ||
} | ||
|
||
public function setUrl($url) | ||
{ | ||
$this->options['sAjaxSource'] = $url; | ||
$this->options['bServerSide'] = true; | ||
return $this; | ||
} | ||
|
||
public function getOptions() | ||
{ | ||
return $this->options; | ||
} | ||
|
||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
|
||
public function render($view = null) | ||
{ | ||
if(is_null($view)) | ||
$view = 'datatable::template'; | ||
|
||
return View::make($view,array( | ||
'options' => $this->getOptions(), | ||
'data' => $this->getData(), | ||
'columns' => $this->columns, | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<table id="users" class="table table-bordered responsive"> | ||
<colgroup> | ||
<col class="con1" /> | ||
</colgroup> | ||
<thead> | ||
<tr> | ||
<th class="head1">Last</th> | ||
<th class="head1">Last</th> | ||
<th class="head1">Last</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
</tbody> | ||
</table> | ||
<script type="text/javascript"> | ||
jQuery(document).ready(function(){ | ||
// dynamic table | ||
jQuery('#users').dataTable({ | ||
"sPaginationType": "full_numbers", | ||
"bProcessing": false, | ||
"bServerSide": true, | ||
"sAjaxSource": "{{ URL::to('auth/users/table') }}" | ||
//"fnDrawCallback": function(oSettings) { | ||
// jQuery.uniform.update(); | ||
//} | ||
}); | ||
}); | ||
</script> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
use Chumper\Datatable\Api; | ||
|
||
class ApiTest extends PHPUnit_Framework_TestCase { | ||
|
||
public function testDummy() | ||
{ | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use Chumper\Datatable\Datatable; | ||
|
||
class DatatableTest extends PHPUnit_Framework_TestCase { | ||
|
||
/** | ||
* @var Datatable | ||
*/ | ||
private $dt; | ||
|
||
protected function setUp() | ||
{ | ||
$this->dt = new Datatable; | ||
$this->mock = Mockery::mock('Illuminate\Database\Query\Builder'); | ||
} | ||
|
||
public function testReturnInstances() | ||
{ | ||
$api = $this->dt->api($this->mock); | ||
|
||
$this->assertInstanceOf('Chumper\Datatable\Api', $api); | ||
|
||
$table = $this->dt->table(); | ||
|
||
$this->assertInstanceOf('Chumper\Datatable\Table', $table); | ||
} | ||
|
||
} |
Oops, something went wrong.