No {$this->english}s found.
\n";
}
/**
* this draws the rows for each object. calls drawHeaderRow() on teh object,
* and then drawRow() on each object in teh result set. each object is
* wrapped in a div of class $class.
*
* @param $rs an array of objects to draw.
* @param $class the css class to wrap the objects in.
*/
function drawRows($rs, $class = null)
{
//init our flag
$flag = true;
//what class is it?
if ($class === null)
$class = "contentRow " . strtolower($this->objectType);
//did we get anything?
if (count($rs))
{
//draw out header and loop
$this->object->drawHeaderRow();
foreach ($rs AS $ar)
{
//can we view it?
$this->object = $ar;
if ($this->object->canView())
{
//our row flags
if ($flag)
$classRow = "onRow";
else
$classRow = "offRow";
//draw our object
echo "\n";
$this->object->drawHeaderLine();
foreach ($rs AS $ar)
{
$id = strtolower($this->objectType) . "Line-$ar->id";
$this->object = $ar;
if ($this->object->canView())
{
echo "\n
\n";
$this->object->drawLine();
echo "
\n";
}
}
echo "
";
}
}
/**
* search for a user's content..
*
* @param $userId the id of the user.
* @param $limit max results to get.
*
* @return the result set.
*/
function userSearch($userId, $limit = null)
{
return $this->search(array(
'user_id' => $userId
), $limit);
}
/**
* search for objects. you can call this to do custom searches.
*
* @param $params a keyed array of parameters to search on.
* @param $limit the maximum results to return. defaults to numRows, pass -1 for unlimited.
*
* @return the result set.
*/
public function search($params = array(), $limit = null)
{
//know your limit!
if ($limit == -1)
$limit = 99999999;
//set it!
if ($limit !== null)
$params['num_results'] = $limit;
//prep it!
$this->initSearch($params);
//now actually search
return $this->getSearchResult();
}
/**
* just like search, except all you get is a count of objects. use this
* when you only want the count (a cheap query) and not an array of the
* results.
*
* @param $params a keyed array of parameters to search on.
* @param $cache do we use the cache of teh count or start fresh?
*
* @return the count of objects that match.
*/
public function searchCount($params = array(), $cache = true)
{
//save our old cache setting.
$oldCache = self::$cacheSearchCount;
//set our new one.
self::$cacheSearchCount = $cache;
//prep it!
$this->initSearch($params);
//save it back in now
self::$cacheSearchCount = $oldCache;
//now actually search
return $this->numResults;
}
/**
* generate our rss. uses the feedcreator class.
*
* @param $params a keyed array of parameters as for search used to search for rss items.
* @param $useCached boolean of whether we want to cache. default: true
*
* @return the UniversialFeedCreator object.
*/
function generateRss($params = array(), $useCached = true)
{
require_once("lib/feedcreator.class.php");
//create the object
$rss = new UniversalFeedCreator();
//do we use cached?
if ($useCached)
$rss->useCached(); // use cached version if age<1 hour
$rss->title = $this->pageTitle . " - " . Config::get('site_name');
$rss->description = $this->object->english . " feed";
$item->descriptionHtmlSyndicated = true;
//get our links...
$rss->link = "http://" . Config::get('site_hostname');
$rss->syndicationURL = "http://" . Config::get('site_hostname') . $_SERVER["PHP_SELF"];
//do our search
$rs = $this->search($params);
if (count($rs))
{
foreach ($rs AS $ob)
{
$item = $ob->getRssItem();
$rss->addItem($item);
}
}
return $rss;
}
/**
* get our public data. actually its an array of the object's public data... but same diff.
*
* @param $params a keyed array of parameters to search on. same as search()
*
* @return an array of public data. woot!
*/
function getPublicData($params)
{
//get our search results.
$results = array();
$rs = $this->search($params);
if (count($rs))
foreach ($rs AS $ob)
$results[] = $ob->getPublicData();
//format our data.
$data = array(
'runtime' => '%%BJ_RUNTIME%%',
'queries' => '%%BJ_QUERIES%%',
'cachehits' => '%%BJ_CACHE_HITS%%',
'page' => $this->resultPage,
'startrow' => $this->startRow,
'endrow' => $this->endRow,
'totalresults' => $this->numResults,
'resultsperpage' => $this->numRows
);
$data['Results'] = $results;
return $data;
}
/**
* This function determines admin status. (passes off to object->isAdmin())
* @return true if they are admin, false if not.
*/
public function isAdmin()
{
return (bool)$this->object->isAdmin();
}
/**
* create our search form for searching.
*
* @return returns a Form object that does searching.
*/
public function createSearchForm($query = null)
{
$form = new Form(new OneLineLayout());
$form->action = $this->getUrl(".search");
$form->onSubmit = "return objectManagerSearch('$form->name')";
$form->add('TextField', 'query', array(
'title' => '',
'width' => '50%',
'required' => true
));
$form->addSubmit('Search ' . ucfirst(get_class($this)));
//if null.. default to our param
if ($query === null)
$query = $this->params('query');
//set our data.
if ($query)
$form->setData(array(
'query' => $query
));
return $form;
}
/**
* draw our search form for doing fulltext searches
*/
public function drawSearchForm()
{
$this->needsJs('lib/js/basejumper.js');
echo "object) . "Search\">\n";
$form = $this->createSearchForm();
$form->draw();
echo "
";
}
}