Inheritance: extends AbstractModel
 public function get()
 {
     if ($this->flag['search']) {
         if (isset($_GET['q']) && $_GET['q'] != '') {
             // Fetch Search Query
             $query = F3::scrub($_GET['q']);
             $search = new SearchModel();
             // Fetch Search Results
             if ($this->results = $search->items($query)) {
                 // Reroute if one match
                 if (count($this->results) == 1 && $this->redirect) {
                     F3::reroute('/loot/' . $this->results[0]['urlname']);
                 }
                 $this->title = "Search: \"" . $query . "\" - Diablo 2 Database";
                 $this->heading = "Search: \"" . $query . "\"";
                 F3::set('NOTIFY.success', "Rejoice! " . count($this->results) . " matches found!");
                 $this->render('search.php');
             } else {
                 $this->heading = "Search: \"" . $query . "\"";
                 F3::set('NOTIFY.warning', "Nothing found in the database. Try the <a href=/loot/>Loot Directory</a>.");
                 $this->render('blank.php');
             }
         } else {
             F3::reroute('/');
         }
     } else {
         F3::set('NOTIFY.warning', "Search is temporarily disabled. Please try again later.");
         $this->render('blank.php');
     }
 }
Example #2
0
 function __construct()
 {
     $model = new SearchModel();
     $data['list'] = $model->ListObjects();
     $data['page'] = $model->GetPage();
     require_once '_View/ListView.php';
     var_dump($_POST);
     //print_r($_POST);
 }
Example #3
0
 private function doSearch()
 {
     if (empty($this->engines)) {
         $this->messages[] = 'Please choose either, or both, search engines';
         return '';
     }
     $m = new SearchModel($this->engines);
     return $m->run($this->parameters);
 }
 /**
  * Default search functionality.
  *
  * @since 2.0.0
  * @access public
  * @param int $Page Page number.
  */
 public function index($Page = '')
 {
     $this->addJsFile('search.js');
     $this->title(t('Search'));
     saveToConfig('Garden.Format.EmbedSize', '160x90', false);
     Gdn_Theme::section('SearchResults');
     list($Offset, $Limit) = offsetLimit($Page, c('Garden.Search.PerPage', 20));
     $this->setData('_Limit', $Limit);
     $Search = $this->Form->getFormValue('Search');
     $Mode = $this->Form->getFormValue('Mode');
     if ($Mode) {
         $this->SearchModel->ForceSearchMode = $Mode;
     }
     try {
         $ResultSet = $this->SearchModel->Search($Search, $Offset, $Limit);
     } catch (Gdn_UserException $Ex) {
         $this->Form->addError($Ex);
         $ResultSet = array();
     } catch (Exception $Ex) {
         LogException($Ex);
         $this->Form->addError($Ex);
         $ResultSet = array();
     }
     Gdn::userModel()->joinUsers($ResultSet, array('UserID'));
     // Fix up the summaries.
     $SearchTerms = explode(' ', Gdn_Format::text($Search));
     foreach ($ResultSet as &$Row) {
         $Row['Summary'] = SearchExcerpt(Gdn_Format::plainText($Row['Summary'], $Row['Format']), $SearchTerms);
         $Row['Summary'] = Emoji::instance()->translateToHtml($Row['Summary']);
         $Row['Format'] = 'Html';
     }
     $this->setData('SearchResults', $ResultSet, true);
     $this->setData('SearchTerm', Gdn_Format::text($Search), true);
     if ($ResultSet) {
         $NumResults = count($ResultSet);
     } else {
         $NumResults = 0;
     }
     if ($NumResults == $Offset + $Limit) {
         $NumResults++;
     }
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->Pager = $PagerFactory->GetPager('MorePager', $this);
     $this->Pager->MoreCode = 'More Results';
     $this->Pager->LessCode = 'Previous Results';
     $this->Pager->ClientID = 'Pager';
     $this->Pager->configure($Offset, $Limit, $NumResults, 'dashboard/search/%1$s/%2$s/?Search=' . Gdn_Format::url($Search));
     //		if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
     //         $this->setJson('LessRow', $this->Pager->toString('less'));
     //         $this->setJson('MoreRow', $this->Pager->toString('more'));
     //         $this->View = 'results';
     //      }
     $this->canonicalUrl(url('search', true));
     $this->render();
 }
Example #5
0
 function __construct()
 {
     $model = new SearchModel();
     $data['object'] = $model->ObjectData();
     if ($data['object'] !== NULL) {
         require_once '_View/HeaderView.php';
         require_once '_View/HeaderBanerView.php';
         require_once '_View/ObjectView.php';
         require_once '_View/FooterView.php';
     } else {
         echo 'Nie ma takiego obiektu';
     }
 }
Example #6
0
 function actionIndex($params = '')
 {
     $objUsers = new UserModel();
     $latestLogins = $objUsers->getRecentLogins(true);
     $objBlog = new BlogModel();
     $latestComments = $objBlog->getComments(array('status' => 'pending', 'limit' => '5'));
     $objSearch = new SearchModel();
     $popularSearches = $objSearch->getPopular(array('startDate' => date("Y-m-d", strtotime('-1 Month')), 'endDate' => date("Y-m-d"), 'howMany' => 5));
     $this->view->assign('latestLogins', $latestLogins);
     $this->view->assign('latestComments', $latestComments);
     $this->view->assign('popularSearches', $popularSearches);
     $this->view->assign('content', $this->view->fetch('tpl/home/index.tpl'));
     $this->finish();
 }
 public function Instance()
 {
     if (!isset(SearchModel::$_instance)) {
         SearchModel::$_instance = new SearchModel();
     }
     return SearchModel::$_instance;
 }
 public static function searchResult()
 {
     require_once 'Search.model.php';
     require_once 'Upload.model.php';
     require_once 'User.model.php';
     $data = array();
     if (isset($_POST['searchProduct'])) {
         $searchProduct = $_POST['searchField'];
         $category = $_POST['category'];
         $state = $_POST['state'];
         $sort = $_POST['sort'];
         $query = SearchModel::searchQuery($searchProduct, $category, $state, $sort);
         try {
             $searchresult = SearchModel::getSearchResult($searchProduct, $category, $state, $sort);
             $data['template'] = 'searchResult.html';
             $data['products'] = $searchresult;
             $data['states'] = UserModel::getStates();
             $data['categories'] = UploadModel::getCategories();
         } catch (Exception $e) {
             $data['error'] = $e->getMessage();
             $data['template'] = 'error.html';
             $data['states'] = UserModel::getStates();
             $data['categories'] = UploadModel::getCategories();
         }
     } else {
         $searchCheck = Self::searchCheck();
         $data['redirect'] = 'error.html';
     }
     return $data;
 }
 public function searchAction()
 {
     $page_data = $this->index('basic_page');
     $request = new Request();
     if ($request->isPost()) {
         $search = new SearchModel($request);
         if (!$search->isSmall()) {
             if (!$search->isLarge()) {
                 $search_data = $search->search();
             } else {
                 Session::setFlash(__t('long_inquiry'));
             }
         } else {
             Session::setFlash(__t('short_inquiry'));
         }
     }
     $search_array = array();
     if (isset($search_data)) {
         foreach ($search_data as $material_type) {
             foreach ($material_type as $val) {
                 $search_array[] = $val;
             }
         }
     }
     $items_count = count($search_array);
     $items_per_page = Config::get('search_per_page');
     $request = new Request();
     $currentPage = $request->get('page') ? (int) $request->get('page') : 1;
     $data_pagination = self::getPagination($items_count, $items_per_page, $currentPage);
     if ($items_count) {
         $data_search_page = array_chunk($search_array, $items_per_page, true);
         if (isset($data_search_page[$currentPage - 1])) {
             $data_search_page = $data_search_page[$currentPage - 1];
         } else {
             throw new Exception('Page (' . Router::getUri() . ') not found', 404);
         }
     } else {
         $data_search_page = null;
     }
     $data_url = explode('?', Router::getUri());
     $lang = Router::getLanguage() == Config::get('default_language') ? '' : Router::getLanguage() . '/';
     //    $search_request = $search->getSearchRequest();
     $args = array('page_data' => $page_data, 'data_search' => $data_search_page, 'data_pagination' => $data_pagination, 'data_url' => $data_url[0], 'lang' => $lang, 'items_count' => $items_count, 'img' => $page_data['img']);
     return $this->render($args);
 }
Example #10
0
 function actionAutocomplete($params = '')
 {
     $returnResults = array();
     if (!empty($params['term'])) {
         $objSearch = new SearchModel();
         $searchResults = $objSearch->performSearch($params['term'], array('dontsave' => true));
         if (!empty($searchResults)) {
             foreach ($searchResults as $result) {
                 $record = new stdClass();
                 $record->title = $result['title'];
                 $record->url = $result['url'];
                 $record->desc = $result['description'];
                 $returnResults[] = $record;
             }
         }
     }
     echo json_encode($returnResults);
 }
 protected function getSearchInfoOrErr($search)
 {
     //Создание необходимых объектов:
     $objForModels = new SearchModel();
     //Проверка POST переменных:
     $search = $this->getCheckVal([$search]);
     //Проверка формата и  введённых данных:
     if (!$this->checkSearchFormat($search[0])) {
         return 'noFormat';
     }
     //Поиск данных ID тем по запросу в базе:
     $search = $objForModels->getThemeIDBySearch($search[0]);
     //Проверка информации запроса в базе:
     if (empty($search)) {
         return 'noDataBySearch';
     }
     //Выборка тем по найденным ID:
     return $objForModels->getDataBySearch($search);
 }
 /**
  * Applies additional dependencies special for sql search criteria.
  * 
  * @return CDataProvider data provider
  *
  * @see SearchModel::fetch()
  */
 public function fetch()
 {
     $dataProvider = parent::fetch();
     if ($dataProvider instanceof CActiveDataProvider) {
         $criteria = $dataProvider->criteria;
         if (empty($criteria->order)) {
             $this->applySort($criteria);
         }
     }
     return $dataProvider;
 }
Example #13
0
 public function qAction()
 {
     $q = urldecode($this->strVal(3));
     $page = $this->intVal(4);
     if ($page == 0) {
         $page = 1;
     }
     $size = 10;
     $begin = ($page - 1) * $size;
     $searchModel = new SearchModel();
     $ret = $searchModel->search($q, $begin, $size);
     $retArray = json_decode($ret, true);
     $count = $retArray["hits"]["total"];
     $pageControl = ToolModel::pageControl($page, $count, $size, "<a href='/search/q/{$q}/#page#/'>");
     $this->_mainContent->assign("pageControl", $pageControl);
     $this->_mainContent->assign("results", $retArray);
     $this->_mainContent->assign("search", $retArray);
     $this->_view->assign("search_q", $q);
     $this->_mainContent->assign("search_q", $q);
     $this->display();
     //var_dump($retArray);
 }
 /**
  * Default search functionality.
  *
  * @since 2.0.0
  * @access public
  * @param int $Page Page number.
  */
 public function index($Page = '')
 {
     $this->addJsFile('search.js');
     $this->title(t('Search'));
     saveToConfig('Garden.Format.EmbedSize', '160x90', false);
     Gdn_Theme::section('SearchResults');
     list($Offset, $Limit) = offsetLimit($Page, c('Garden.Search.PerPage', 20));
     $this->setData('_Limit', $Limit);
     $Search = $this->Form->getFormValue('Search');
     $Mode = $this->Form->getFormValue('Mode');
     if ($Mode) {
         $this->SearchModel->ForceSearchMode = $Mode;
     }
     try {
         $ResultSet = $this->SearchModel->search($Search, $Offset, $Limit);
     } catch (Gdn_UserException $Ex) {
         $this->Form->addError($Ex);
         $ResultSet = array();
     } catch (Exception $Ex) {
         LogException($Ex);
         $this->Form->addError($Ex);
         $ResultSet = array();
     }
     Gdn::userModel()->joinUsers($ResultSet, array('UserID'));
     // Fix up the summaries.
     $SearchTerms = explode(' ', Gdn_Format::text($Search));
     foreach ($ResultSet as &$Row) {
         $Row['Summary'] = searchExcerpt(htmlspecialchars(Gdn_Format::plainText($Row['Summary'], $Row['Format'])), $SearchTerms);
         $Row['Summary'] = Emoji::instance()->translateToHtml($Row['Summary']);
         $Row['Format'] = 'Html';
     }
     $this->setData('SearchResults', $ResultSet, true);
     $this->setData('SearchTerm', Gdn_Format::text($Search), true);
     $this->setData('_CurrentRecords', count($ResultSet));
     $this->canonicalUrl(url('search', true));
     $this->render();
 }
Example #15
0
 public function searchByDate($time)
 {
     //tim kiem theo thoi gian
     if (empty(self::$conn)) {
         self::$conn = $this->connectPdo();
     }
     $sql = "SELECT content,subject,username,name,email,image,diary.id,user.id,time_on FROM diary,user WHERE diary.user_id=user.id AND time_on=?";
     $stmt = self::$conn->prepare($sql);
     $stmt->bindParam(1, $time);
     $stmt->execute();
     $stmt->setFetchMode(PDO::FETCH_ASSOC);
     $i = 0;
     $diary = array(array());
     while ($row = $stmt->fetch()) {
         $diary[$i++] = $row;
     }
     $i--;
     return $diary;
 }
Example #16
0
 public function __construct($engine)
 {
     parent::__construct($engine);
     $this->_cms = IndexModel::Instance();
     $this->_search = SearchModel::Instance();
     $this->_head->addStyleFile('jquery.ui.all.css', 'screen', true, '/css/jquery-ui/');
     // JqueryUI CSS
     $this->_head->addStyleFile('style.main.css', 'screen', true, '/css/');
     $this->_head->addStyleFile('news.css', 'screen', true, '/css/');
     $this->_head->addStyleFile('colorbox.css', 'screen', true, '/css/');
     $this->_head->addScriptFile('base.js', true, '/scripts/');
     $this->_head->addScriptFile('jquery.colorbox.js', true, '/scripts/');
     $this->_head->addScriptFile('cufon-yui.js', true, '/scripts/');
     $this->_head->addScriptFile('Myriad_Pro.font.js', true, '/scripts/');
     $this->_head->addScriptFile('jquery.uniform.min.js', true, '/scripts/cms/');
     // JqueryUI JS
     $this->_head->title = $this->_config->meta_data->title;
     $this->_head->keywords = $this->_config->meta_data->keywords;
     $this->_head->description = $this->_config->meta_data->description;
 }
Example #17
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
require_once "Libs/autoload.php";
$config = new Config();
$webPage = new PJSWebPage($config->getTitle() . ' - Delete Search');
$act = Tools::Param('act');
if ("Delete Search" === $act) {
    $searchModel = new SearchModel();
    $searchModel->populateFromForm();
    if (!$searchModel->validateForDelete()) {
        $searchView = new SearchFormView('Delete Search', $searchModel);
        $body = "<h2>Invalid data</h2>\n" . $searchView->getForm();
    } else {
        $searchController = new SearchController();
        $searchController->delete($searchModel);
        $body = "Deleted search # " . $searchModel->getId() . "<br />\n";
    }
} else {
    $searchController = new SearchController();
    $searchModel = $searchController->get(Tools::param('id'));
    $searchView = new SearchFormView('Delete Search', $searchModel);
    $body = $searchView->getForm();
}
Example #18
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
require_once "Libs/autoload.php";
$config = new Config();
$webPage = new PJSWebPage($config->getTitle() . ' - Edit Search');
$act = Tools::Param('act');
if ("Edit Search" === $act) {
    $searchModel = new SearchModel();
    $searchModel->populateFromForm();
    if (!$searchModel->validateForUpdate()) {
        $view = new SearchFormView('Edit Search', $searchModel);
        $body = "<h2>Invalid data</h2>\n" . $view->getForm();
    } else {
        $searchController = new SearchController();
        $newId = $searchController->update($searchModel);
        if ($newId > 0) {
            $body = "Edited search: " . $searchModel->getSearchName() . " as # " . $newId . "<br />\n";
        }
    }
} else {
    $searchController = new SearchController();
    $searchModel = $searchController->get(Tools::param('id'));
    $view = new SearchFormView('Edit Search', $searchModel);
 public function index()
 {
     $this->View->render('search/index', array('search' => SearchModel::getSearchResults(Request::post('query'))));
 }
Example #20
0
 public function __construct()
 {
     parent::__construct();
 }
Example #21
0
require_once ROOT_PATH . "public/includes/navsearch.php";
require_once ROOT_PATH . "app/model/list.class.php";
require_once ROOT_PATH . "app/model/searchmodel.php";
?>

	
	 <section class="container content-section text-center">
<?php 
if (isset($_POST['search'])) {
    $find = $_POST['search'];
    if ($find == null) {
        echo "Nothing Entered";
    } else {
        //for accepting character from 0-9 and a-z  only
        $find = preg_replace("#[^0-9a-z]#i", "", $find);
        $results = new SearchModel();
        if ($results->find($find) == null) {
            echo "No search results found";
        } else {
            $id = 1;
            ?>
           <div class="row">
            <div class="col-lg-8 col-lg-offset-2">
                <h2>Search Results</h2>
                 <div class="row">
            
            <?php 
            foreach ($results->find($find) as $user) {
                ?>
              <div class="col-sm-6 col-md-4">
              <a href="<?php 
Example #22
0
 public function showAction()
 {
     $id = $this->intVal(3);
     $threadModel = new ThreadModel();
     $userModel = new UserModel();
     $reputation = $userModel->reputation($this->userid);
     if ($_POST) {
         if (!$this->isEmailValidated) {
             header("location: /home/");
             die;
         }
         if ($reputation < 0) {
             header("location: /home/");
             die;
         }
         if ($this->userid > 0) {
             if (strlen($_POST["content"]) > 0) {
                 $data = array();
                 $time = time();
                 $data["threadid"] = $id;
                 $data["name"] = $this->username;
                 $data["userid"] = $this->userid;
                 $data["content"] = $_POST["content"];
                 $data["createdate"] = $time;
                 $data["updatedate"] = $time;
                 $replys = $threadModel->newReply($data);
                 if ($replys) {
                     $thread = array();
                     $thread["id"] = $id;
                     $thread["replys"] = $replys;
                     $thread["updatedate"] = $time;
                     $thread["lastreply"] = $data["name"];
                     $thread["lastreplyid"] = $data["userid"];
                     $threadModel->updateThread($thread);
                 }
                 header("location: /thread/show/{$id}/");
                 die;
             }
         }
     }
     header('Pragma: ');
     header("cache-control: s-maxage=600");
     $cacheModel = new FilecacheModel();
     $thread = $threadModel->threadById($id);
     if (!$thread || $thread["del"] == 1) {
         header("HTTP/1.1 301 Moved Permanently");
         header("location: /home/");
         die;
     }
     $replysCount = $threadModel->replysCountById($id);
     $replys = $threadModel->replysById($id);
     $voteInfo = $threadModel->voteInfo($id);
     $userVote = $threadModel->userVote($id, $this->userid);
     //limit10replys
     $isBot = ToolModel::isBot();
     if ($this->userid == 0 && !$isBot && $replysCount > 10) {
         $replys = array_slice($replys, 0, 10);
     }
     if (!$this->userid) {
         $this->_mainContent->assign("userid", 0);
     } else {
         $this->_mainContent->assign("userid", $this->userid);
     }
     if ($this->userid) {
         $userModel = new UserModel();
         $userInfo = $userModel->userInfo($this->userid);
         $reputation = $userInfo["reputation"];
     } else {
         $reputation = 0;
     }
     $this->_mainContent->assign("reputation", $reputation);
     $this->_mainContent->assign("thread", $thread);
     $this->_mainContent->assign("replysCount", $replysCount);
     $this->_mainContent->assign("replys", $replys);
     $this->_mainContent->assign("voteInfo", $voteInfo);
     $this->_mainContent->assign("userVote", $userVote);
     $searchModel = new SearchModel();
     $ret = $searchModel->search($thread["title"], 0, 11);
     $relativeThread = json_decode($ret, true);
     $this->_mainContent->assign("relativeThread", $relativeThread["hits"]["hits"]);
     $toplist = $cacheModel->getCache("toplist", "toplist");
     if (!$toplist) {
         $toplistModel = new ToplistModel();
         $toplist = $toplistModel->toplist();
         $cacheModel->createCache("toplist", "toplist", $toplist);
     }
     $this->_mainContent->assign("toplist", $toplist);
     if (isset($this->isEmailValidated)) {
         $this->_mainContent->assign("isEmailValidated", $this->isEmailValidated);
     }
     $this->_mainContent->assign("reputation", $reputation);
     $this->setTitle($thread["title"]);
     $this->display();
 }
Example #23
0
 public function search()
 {
     $keyword = $this->route_vars['keyword'];
     $pageno = 0;
     if (isset($this->route_vars['pageno'])) {
         $pageno = $this->route_vars['pageno'] - 1;
     }
     $page = new SuggestionsSearchResultsPage($this->_model->getLoggedInMember());
     $page->keyword = $keyword;
     $searchModel = new SearchModel();
     $suggestions = $searchModel->searchSuggestions($keyword);
     $count = count($suggestions);
     $page->suggestions = $suggestions;
     $page->pager = $this->getPager('search/' . $keyword, $count, $pageno);
     return $page;
 }
Example #24
0
			</h4>
			<p><?php 
            SearchModel::mana_replace($value->description);
            ?>
</p>
			<p><em><?php 
            echo htmlentities($value->flavor);
            ?>
</em></p>
		</div>
	</div>

	<div class="clearfix"></div>

			<?php 
            SearchModel::getItemInventory($value->name);
            if (!isset($stock)) {
                ?>
			<div class="table-responsive col-lg-12 listings">
		            <table class="table table-striped table-hover table-bordered">
		                <tbody>
		                    <?php 
                foreach ($this->item as $key => $k) {
                    ?>
		                      <tr>
		                          <td><?php 
                    echo htmlentities($k->product_id);
                    ?>
</td>
		                          <td><?php 
                    echo htmlentities($k->product_name);
Example #25
0
 public function search($args)
 {
     $cat = new RetrieveModel();
     $dat = new SearchModel();
     EStructure::view("search", $cat->getCategories(), $dat->search());
 }
";
    var uncheckAllTextTranslation = "<?php 
echo $words->getSilent('SearchMembersUncheckAll');
?>
";
    var noneSelectedTextTranslation = "<?php 
echo $words->getSilent('SearchMembersNoneSelected');
?>
";
    var selectedTextTranslation = "<?php 
echo $words->getSilent('SearchMembersSelected');
?>
";
</script><?php 
$orderBy = array();
$orderArray = SearchModel::getOrderByArray();
foreach ($orderArray as $key => $order) {
    $orderBy[$key] = $words->getSilent($orderArray[$key]['WordCode'] . 'Asc');
    $orderBy[$key + 1] = $words->getSilent($orderArray[$key]['WordCode'] . 'Desc');
}
$layoutbits = new MOD_layoutbits();
// The whole page is in one form to be able to fill the fields with the correct content even
// when switching between pages of the result
?>
<div class="row"><!--  around form -->
<?php 
if (count($this->errors) > 0) {
    echo '<div class="error">';
    foreach ($this->errors as $error) {
        echo '<p>' . $words->get($error) . '</p>';
    }
Example #27
0
require_once 'controller/RegisterController.php';
require_once 'controller/SearchController.php';
require_once 'controller/UserProfileController.php';
require_once 'controller/SettingsController.php';
require_once 'controller/MainController.php';
//MAKE SURE ERRORS ARE SHOWN... MIGHT WANT TO TURN THIS OFF ON A PUBLIC SERVER
error_reporting(E_ALL);
ini_set('display_errors', 'On');
//Initialize session
session_start();
//Create models
$db = new Database();
$dal = new UserDAL($db);
$loginModel = new LoginModel($dal);
$registerModel = new RegisterModel($dal);
$searchModel = new SearchModel($dal);
$settingsModel = new SettingsModel($dal);
//CREATE OBJECTS OF THE VIEWS
$loginView = new LoginView($loginModel);
$registerView = new RegisterView($registerModel);
$searchView = new SearchView();
$userProfileView = new UserProfileView();
$settingsView = new SettingsView();
$layoutView = new LayoutView();
//Create controllers
$loginController = new LoginController($loginView, $loginModel);
$registerController = new RegisterController($registerView, $loginView, $registerModel);
$searchController = new SearchController($searchView, $userProfileView, $searchModel);
$userProfileController = new UserProfileController($userProfileView);
$settingsController = new SettingsController($settingsView, $settingsModel);
$mainController = new MainController($registerController, $loginController, $searchController, $userProfileController, $settingsController, $layoutView, $settingsView);
Example #28
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */
require_once "Libs/autoload.php";
$config = new Config();
$webPage = new PJSWebPage($config->getTitle() . "Searches - Add Search");
$body = '';
$act = Tools::Param('act');
if ("Add Search" === $act) {
    $model = new SearchModel();
    $model->populateFromForm();
    if (!$model->validateForAdd()) {
        $view = new SearchFormView('Add Search', $model);
        $body = "<h2>Invalid data</h2>\n" . $view->getForm();
    } else {
        $searchController = new SearchController();
        $newId = $searchController->add($model);
        if ($newId > 0) {
            $body = "Added search # " . $newId . "<br />\n";
        }
    }
} else {
    $body = "";
    $view = new SearchFormView("Add Search", null);
    $body = $view->getForm();
Example #29
0
    /**
     * @param SearchModel $model
     * @see ControllerBase::update()
     */
    public function update($model)
    {
        if ($model->validateForUpdate()) {
            try {
                $query = <<<SQL
UPDATE search
   SET engineName = ?
     , searchName = ?
     , url = ?
 WHERE id = ?
SQL;
                $id = $model->getId();
                $engineName = $model->getEngineName();
                $searchName = $model->getSearchName();
                $url = $model->getUrl();
                $stmt = $this->_dbh->prepare($query);
                if (!$stmt) {
                    throw new ControllerException('Prepared statement failed for ' . $query);
                }
                if (!$stmt->bind_param('sssi', $engineName, $searchName, $url, $id)) {
                    throw new ControllerException('Binding parameters for prepared statement failed.');
                }
                if (!$stmt->execute()) {
                    throw new ControllerException('Failed to execute UPDATE statement. (' . $this->_dbh->error . ')');
                }
                /**
                 * @SuppressWarnings checkAliases
                 */
                if (!$stmt->close()) {
                    throw new ControllerException('Something broke while trying to close the prepared statement.');
                }
                return $id;
            } catch (Exception $e) {
                throw new ControllerException($e->getMessage());
            }
        } else {
            throw new ControllerException("Invalid data.");
        }
    }
 /**
  * Add the searches for vanilla to the search model.
  * @param SearchModel $SearchModel
  */
 public function Search($SearchModel)
 {
     $SearchModel->AddSearch($this->DiscussionSql($SearchModel));
     $SearchModel->AddSearch($this->CommentSql($SearchModel));
 }