>
------------------------------------------------------------------------------
See main.inc.php for release information
--------------------------------------------------------------------------- */
if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
load_language('plugin.lang', ASE_PATH);
class RBCallBackASEKeyword extends GPCSearchCallback {
/**
* the getImageId returns the name of the image id attribute
* return String
*/
static public function getImageId()
{
return("ase_pitk.id");
}
/**
* the getSelect function must return an attribute list separated with a comma
*
* "att1, att2, att3, att4"
*/
static public function getSelect($param="")
{
$returned="";
if($param['searchName']=='y')
{
$returned=" ase_pitk.name AS optName";
};
if($param['searchDesc']=='y')
{
$returned.=($returned==''?'':',')." ase_pitk.comment AS optDesc";
};
if($param['searchFileName']=='y')
{
$returned.=($returned==''?'':',')." ase_pitk.file AS optFileName";
};
return($returned);
}
/**
* the getFrom function must return a tables list separated with a comma
*
* "table1, (table2 left join table3 on table2.key = table3.key), table4"
*/
static public function getFrom($param="")
{
global $prefixeTable;
return(IMAGES_TABLE." ase_pitk ");
}
/**
* the getWhere function must return a ready to use where clause
*
* "(att1 = value0 OR att2 = value1) AND att4 LIKE value2 "
*/
static public function getWhere($param="")
{
global $user;
$clauses=array();
if($param['searchName']=='y')
{
$clauses[]=self::getWhereClause('name', $param['keyword'], $param['optIgnoreCase'], $param['optWholeWords']);
}
if($param['searchDesc']=='y')
{
$clauses[]=self::getWhereClause('comment', $param['keyword'], $param['optIgnoreCase'], $param['optWholeWords']);
}
if($param['searchFileName']=='y')
{
$clauses[]=self::getWhereClause('file', $param['keyword'], $param['optIgnoreCase'], $param['optWholeWords']);
}
$returned=implode(' OR ', $clauses);
return($returned);
}
static private function getWhereClause($target, $keyword, $case, $wwords)
{
if($target=='file' and $case=='y')
{
$returned="LOWER(ase_pitk.$target) REGEXP ";
$keyword=strtolower($keyword);
}
else
{
$returned="ase_pitk.$target REGEXP ";
}
if($case=='n') $returned.=" BINARY ";
if($wwords=='n')
{
$returned.=" '$keyword'";
}
else
{
$returned.=" '[[:<:]]".$keyword."[[:>:]]'";
}
return($returned);
}
/**
* the getJoin function must return a ready to use where allowing to join the
* IMAGES table (key : id) with given conditions
*
* "att3 = pit.id "
*/
static public function getJoin($param="")
{
return("ase_pitk.id = pit.id");
}
/**
* the getFilter function must return a ready to use where clause
* this where clause is used to filter the cache when the used tables can
* return more than one result
*
* the filter can be empty, can be equal to the where clause, or can be equal
* to a sub part of the where clause
*
*/
static public function getFilter($param="")
{
return("");
}
/**
* this function is called by the request builder, allowing to display plugin
* data with a specific format
*
* @param Array $attributes : array of ('attribute_name' => 'attribute_value')
* @return String : HTML formatted value
*/
static public function formatData($attributes)
{
/* attributes is an array :
* Array(
* 'csColors' => 'color1,color2,color3,...,colorN',
* 'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
* );
*/
$returned="";
if(array_key_exists('optName', $attributes))
{
$returned.="".l10n('ase_optName')." : ".$attributes['optName'];
}
if(array_key_exists('optDesc', $attributes))
{
$returned.=($returned==''?'':'
')."".l10n('ase_optDesc')." : ".$attributes['optDesc'];
}
if(array_key_exists('optFileName', $attributes))
{
$returned.=($returned==''?'':'
')."".l10n('ase_optFileName')." : ".$attributes['optFileName'];
}
return($returned);
}
/**
* this function is called by the request builder to make the search page, and
* must return the HTML & JS code of the dialogbox used to select criterion
*
* Notes :
* - the dialogbox is a JS object with a public method 'show'
* - when the method show is called, one parameter is given by the request
* builder ; the parameter is an object defined as this :
* {
* cBuilder: an instance of the criteriaBuilder object used in the page,
* eventOK : a callback function, called when the OK button is pushed
* id:
* }
*
*
*
*
* @param String $mode : can take 'admin' or 'public' values, allowing to
* return different interface if needed
* @return String : HTML formatted value
*/
static public function getInterfaceContent($mode='admin')
{
return(ASE_functions::dialogBoxASEKeyword());
}
/**
* this function returns the label displayed in the criterion menu
*
* @return String : label displayed in the criterions menu
*/
static public function getInterfaceLabel()
{
return(l10n('ase_add_keyword'));
}
/**
* this function returns the name of the dialog box class
*
* @return String : name of the dialogbox class
*/
static public function getInterfaceDBClass()
{
return('dialogChooseASEKeywordBox');
}
}
?>