Skip to content

Commit

Permalink
Continued Step 2 (do not use)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hurley committed Feb 26, 2013
1 parent 0b447b8 commit 992a967
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 63 deletions.
2 changes: 1 addition & 1 deletion com_lendr/site/controllers/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function execute()
$viewClass = 'LendrViews' . ucfirst($viewName) . ucfirst($viewFormat);
$modelClass = 'LendrModels' . ucfirst($viewName);

if (class_exists($modelClass)===false)
if (false === class_exists($modelClass))
{
$modelClass = 'LendrModelsDefault';
}
Expand Down
7 changes: 1 addition & 6 deletions com_lendr/site/models/book.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ class LendrModelsBook extends LendrModelsDefault

function __construct()
{
$app = JFactory::getApplication();

$this->_book_id = $app->input->get('book_id', null);
$this->_user_id = $app->input->get('user_id', null);
$this->_library_id = $app->input->('library_id', null);

parent::__construct();
}

Expand Down Expand Up @@ -74,7 +69,7 @@ function buildWhere(&$query)
$query->where('b.library_id = ' . (int) $this->_library_id);
}

$query->where('b.published = '. (int) $this->_published);
$query->where('b.published = ' . (int) $this->_published);

return $query;
}
Expand Down
30 changes: 10 additions & 20 deletions com_lendr/site/models/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,18 @@

class LendrModelsDefault extends JModelBase
{
var $__state_set = null;
var $_total = null;
var $_pagination = null;
var $_db = null;
var $id = null;
protected $__state_set = null;
protected $_total = null;
protected $_pagination = null;
protected $_db = null;
protected $id = null;
protected $limitstart = 0;
protected $limit = 10;

function __construct()
{
parent::__construct();
$this->_db = JFactory::getDBO();

$app = JFactory::getApplication();
$ids = $app->input->get("cids",null,'array');

$id = $app->input->get("id");
if ( $id && $id > 0 ){
$this->id = $id;
}else if ( count($ids) == 1 ){
$this->id = $ids[0];
}else{
$this->id = $ids;
}

parent::__construct();
}

/**
Expand Down Expand Up @@ -68,7 +58,7 @@ public function get()
*
* @return array An array of results.
*/
public function list()
public function listItems()
{
$query = $this->buildQuery();
$this->buildWhere($query);
Expand Down
57 changes: 28 additions & 29 deletions com_lendr/site/models/library.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class LendrModelsLibrary extends LendrModelsDefault
{

//Define class level variables
private $_library_id = null;
private $_user_id = null;
private $_published = 1;
var $_library_id = null;
var $_user_id = null;
var $_published = 1;

function __construct()
{
Expand All @@ -19,53 +19,52 @@ function __construct()
parent::__construct();
}

function buildQuery()
function get()
{
$db = JFactory::getDBO();
$query = $db->getQuery(TRUE);

$query->select("l.library_id, l.name, l.description");
$query->from("#__lendr_libraries as l");
$library = parent::get();

$query->select("p.bio, p.avatar");
$query->leftjoin("#__lendr_profiles as p ON p.user_id = l.user_id");

$query->select("u.username, u.name");
$query->leftjoin("#__users as u ON u.id = p.user_id");

return $query;
}

function get()
{
$library = parent::get();

$bookModel = new LendrModelsBook();
$library->books = $bookModel->list();
$library->books = $bookModel->listItems();

return $library;
}

function list()
function listItems()
{

$bookModel = new LendrModelsBook();

$libraries = parent::list();
$libraries = parent::listItems();

$n = count($libraries);

for($i=0;$i<$n;$i++)
{
$library = $libraries[$i];

$bookModel->_library_id = $library->id;
$library->books = $bookModel->list();
$library->books = $bookModel->listItems();
}

return $libraries;
}

function buildQuery()
{
$db = JFactory::getDBO();
$query = $db->getQuery(TRUE);

$query->select("l.library_id, l.name, l.description");
$query->from("#__lendr_libraries as l");

$query->select("p.bio, p.avatar");
$query->leftjoin("#__lendr_profiles as p ON p.user_id = l.user_id");

$query->select("u.username, u.name");
$query->leftjoin("#__users as u ON u.id = p.user_id");

return $query;
}


function buildWhere(&$query)
{

Expand Down
7 changes: 4 additions & 3 deletions com_lendr/site/models/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class LendrModelsProfile extends LendrModelsDefault
{

//Define class level variables
var $_profile_id = null;
var $_user_id = null;
private $_profile_id = null;
private $_user_id = null;

function __construct()
{
Expand Down Expand Up @@ -54,7 +54,8 @@ function get()
{
$profile = parent::get();

$libraryModel = new LendrModelsLibrary()
$libraryModel = new LendrModelsLibrary();

$libraryModel->set('_user_id',$this->_user_id);
$profile->library = $libraryModel->get();

Expand Down
4 changes: 2 additions & 2 deletions com_lendr/site/views/library/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ function render()

//retrieve task list from model
$libraryModel = new LendrModelsLibrary();
$this->libraries = $libraryModel->list();

$this->libraries = $libraryModel->listItems();

//display
return parent::render();
Expand Down
1 change: 1 addition & 0 deletions com_lendr/site/views/profile/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class LendrViewsProfileHtml extends JViewHtml
{
function render()
{

//retrieve task list from model
$profileModel = new LendrModelsProfile();
$this->profile = $profileModel->get();
Expand Down
36 changes: 34 additions & 2 deletions com_lendr/site/views/profile/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,37 @@
</div>
</div>
<div class="row-fluid">
TABS for Library, Wait lists, Wish lists
</div>
<div class="tabbable"> <!-- Only required for left/right tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#libraryTab" data-toggle="tab"><?php echo JText::_('COM_LENDR_LIBRARY'); ?></a></li>
<li><a href="#wishlistTab" data-toggle="tab"><?php echo JText::_('COM_LENDR_WISHLIST'); ?></a></li>
<li><a href="#waitlistTab" data-toggle="tab"><?php echo JText::_('COM_LENDR_WAITLIST'); ?></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="libraryTab">
<table class="table table-striped table-bordered">
<?php for($i=0, $n = count($this->profile->library->books);$i<$n;$i++) {
$book = $this->profile->library->books[$i];
?>
<tr>
<td>
<img src="<?php echo $book->image; ?>" class="media pull-left"><strong><?php echo $book->title; ?></strong><br /><?php echo $book->author; ?>
</td>
<td>
<span class="label label-<?php echo $book->lent ? 'warning' : 'success'; ?>"><?php echo $book->lent ? JText::_('COM_LENDR_LENT') : JText::_('COM_LENDR_AVAILABLE'); ?></span>
</td>
<td>
<a class="btn btn-group"></a>
</td>
</tr>
<?php } ?>
</table>
</div>
<div class="tab-pane" id="wishlistTab">
<p>Howdy, I'm in Section 2.</p>
</div>
<div class="tab-pane" id="waitlistTab">
<p>Howdy, I'm in Section 2.</p>
</div>
</div>
</div></div>

0 comments on commit 992a967

Please sign in to comment.