Source for file hotword_lib.php
Documentation is available at hotword_lib.php
* @version $Header: /cvsroot/bitweaver/_bit_hotwords/hotword_lib.php,v 1.8 2007/01/06 09:46:15 squareing Exp $
* @version $Header: /cvsroot/bitweaver/_bit_hotwords/hotword_lib.php,v 1.8 2007/01/06 09:46:15 squareing Exp $
* @return Data array of hotwords
* [data] is the actual array of words
* [cant] is a count of the number of entries in [data]
function list_hotwords($offset = 0, $max_records = - 1, $sort_mode = 'word_desc', $find = '') {
$mid = " where UPPER(`word`) like ?";
$bindvars = array($findesc);
$query = "select * from `". BIT_DB_PREFIX. "hotwords` $mid order by ". $this->mDb->convertSortmode($sort_mode);
$query_cant = "select count(*) from `". BIT_DB_PREFIX. "hotwords` $mid";
$result = $this->mDb->query($query,$bindvars,$max_records,$offset);
$cant = $this->mDb->getOne($query_cant,$bindvars);
while ($res = $result->fetchRow()) {
* @param word Word to be replaced by link
* @param url Url to be used with that word
$query = "delete from `". BIT_DB_PREFIX. "hotwords` where `word`=?";
$result = $this->mDb->query($query,array($word));
$query = "insert into `". BIT_DB_PREFIX. "hotwords`(`word`,`url`) values(?,?)";
$result = $this->mDb->query($query,array($word,$url));
* @param word Word to be removed
$query = "delete from `". BIT_DB_PREFIX. "hotwords` where `word`=?";
$result = $this->mDb->query($query,array($word));
* @param line Text to be modified by adding links
* @param words Words to be replaced by links
* @return String with hotword link
$hotw_nw = ($gBitSystem->isFeatureActive( 'hotwords_new_window' )) ? "onkeypress='popUpWin(this.href,'fullScreen',0,0);' onclick='popUpWin(this.href,'fullScreen',0,0);return false;'" : '';
foreach ($words as $word => $url) {
// \b is a word boundary, \s is a space char
$line = preg_replace("/^$word(\b)/i","<a href=\"$url\" $hotw_nw>$word</a>$1",$line);
$line = preg_replace("/\s$word(\b)/i"," <a href=\"$url\" $hotw_nw>$word</a>$1",$line);
* @return Array of hotwords
static $retHotwords = NULL;
if( !isset ( $retHotwords ) ) {
$query = "select * from `". BIT_DB_PREFIX. "hotwords`";
$result = $this->mDb->query($query, array());
while ($res = $result->fetchRow()) {
$retHotwords[$res["word"]] = $res["url"];
* @global HotwordsLib Hotwords library
|