/** * add new search entry * * @param String $keywordString * @param String $URL * * @return Int */ public static function add_entry($keywordString, $URL = "") { if ($member = Member::currentUser()) { if ($member->IsShopAdmin()) { return -1; } } $obj = new GoogleCustomSearchPage_Record(); $obj->Title = $keywordString; $obj->URL = $URL; return $obj->write(); }
public function init() { parent::init(); //register any search if (isset($_GET["search"])) { $searchString = Convert::raw2sql($_GET["search"]); $forwardto = ""; if (isset($_GET["forwardto"])) { $forwardto = Convert::raw2sql($_GET["forwardto"]); } GoogleCustomSearchPage_Record::add_entry($searchString, $forwardto); } if ($this->request->param("Action") != "recordsearch") { Requirements::themedCSS('GoogleCustomSearchPage'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript('googlecustomsearch/javascript/GoogleCustomSearchPage.js'); $cxKey = Config::inst()->get("GoogleCustomSearchExt", "cx_key"); Requirements::customScript("\n\t\t\t\t\tGoogleCustomSearchPage.cxKey = '" . $cxKey . "';\n\t\t\t\t", "GoogleCustomSearchPage"); } else { echo "registered ..."; } }