Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Xirt committed Oct 30, 2014
1 parent 0ff08ee commit 479bc2d
Show file tree
Hide file tree
Showing 19 changed files with 918 additions and 0 deletions.
62 changes: 62 additions & 0 deletions admin/components/com_search/controllers/ComponentController.php
@@ -0,0 +1,62 @@
<?php

/**
* Controller for the XirtCMS Search Component
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class ComponentController extends XController {

/**
* Method executed on initialization to load Model
*/
protected function _init() {
global $xCom;

$this->_model = new $this->_model;

if (in_array($this->_action, array("edit"))) {

// Load existing data
$this->_model->load($xCom->name);
if (!isset($this->_model->id)) {

trigger_error("[Controller] Component not found", E_USER_NOTICE);
exit;

}

}

}


/**
* Modifies the data in the Model
*/
protected function edit() {

$config = (object) array();
$config->search_type = XTools::getParam("x_search_type", 0, _INT);
$config->recording = XTools::getParam("x_recording", 0, _INT);
$config->default_value = XTools::getParam("x_default_value", "", _STRING);
$config->default_limit = XTools::getParam("x_default_limit", 10, _INT);
$config->default_method = XTools::getParam("x_default_method", 0, _INT);
$config->titlelength = XTools::getParam("x_titlelength", 250, _INT);
$config->textlength = XTools::getParam("x_textlength", 100, _INT);
$config->node_id = XTools::getParam("x_node_id", 0, _INT);

// Save the right default method
$method = "x_default_method_" . $config->search_type;
$config->default_method = XTools::getParam($method, 0, _INT);

$this->_model->set("config", $config);
$this->_model->save();

}

}
?>
13 changes: 13 additions & 0 deletions admin/components/com_search/controllers/PanelController.php
@@ -0,0 +1,13 @@
<?php

/**
* Controller for the panel
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class PanelController extends XController {
}
?>
78 changes: 78 additions & 0 deletions admin/components/com_search/controllers/TermController.php
@@ -0,0 +1,78 @@
<?php

/**
* Controller for XirtCMS Search Terms
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class TermController extends XController {

/**
* Method executed on initialization to load Model
*/
protected function _init() {

$this->_model = new $this->_model;

if (in_array($this->_action, array("show", "edit", "delete"))) {

// Load existing data
$this->_model->load(XTools::getParam("id", 0, _INT));
if (!isset($this->_model->id)) {

trigger_error("[Controller] Search Term not found", E_USER_NOTICE);
exit;

}

}

}


/**
* Shows the data in the Model
*/
protected function show() {
}


/**
* Adds the data in the Model
*/
protected function add() {

$this->_model->set("impressions", XTools::getParam("nx_impressions", 0, _INT));
$this->_model->set("term", XTools::getParam("nx_term"));
$this->_model->set("uri", XTools::getParam("nx_uri"));
$this->_model->set("language", XTools::getParam("nx_language"));
$this->_model->add();

}


/**
* Modifies the data in the Model
*/
protected function edit() {

$this->_model->set("impressions", XTools::getParam("x_impressions", 0, _INT));
$this->_model->set("term", XTools::getParam("x_term"));
$this->_model->set("uri", XTools::getParam("x_uri"));
$this->_model->save();

}


/**
* Deletes the data in the Model
*/
protected function delete() {
$this->_model->delete();
}

}
?>
21 changes: 21 additions & 0 deletions admin/components/com_search/controllers/TermsController.php
@@ -0,0 +1,21 @@
<?php

/**
* Controller for XirtCMS Search Terms
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class TermsController extends XController {

/**
* Show the model
*/
protected function show() {
$this->_model->load(XTools::getParam("iso"));
}

}
?>
Binary file added admin/components/com_search/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 64 additions & 0 deletions admin/components/com_search/index.com.php
@@ -0,0 +1,64 @@
<?php

/**
* Manager for XirtCMS Search Terms
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class Component extends XComponent {

/**
* Handles any normal requests
*/
function showNormal() {
new PanelController("PanelModel", "PanelView", "show");
}


/**
* Handles any AJAX requests
*/
function showAjax() {

switch (XTools::getParam("task")) {

/*
* View methods
*/
case "show_content_list":
new TermsController("TermsModel", "TermsView", "show");
return;

case "show_item":
new TermController("TermModel", "TermView", "show");
return;


/*
* Modify methods
*/
case "add_item":
new TermController("TermModel", null, "add");
return;

case "edit_item":
new TermController("TermModel", null, "edit");
return;

case "edit_config":
new ComponentController("ComponentModel", null, "edit");
return;

case "remove_item":
new TermController("TermModel", null, "delete");
return;

}

}

}
?>
66 changes: 66 additions & 0 deletions admin/components/com_search/models/ComponentModel.php
@@ -0,0 +1,66 @@
<?php

/**
* Controller for the XirtCMS Search Component
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class ComponentModel extends XItemModel {

/**
* Loads item information from the database
*/
public function load($type) {
$this->loadFromDatabase("#__components", $type);
}


/**
* Loads item information from the database
*
* @param $table The table containing the information
* @param $type The type of the item in the database
*/
public function loadFromDatabase($table, $type) {
global $xDb;

// Database query
$query = "SELECT * " .
"FROM %s " .
"WHERE type = :type ";
$query = sprintf($query, $table);

// Retrieve data
$stmt = $xDb->prepare($query);
$stmt->bindParam(":type", $type, PDO::PARAM_STR);
$stmt->execute();

// Populate instance
if ($dbRow = $stmt->fetchObject()) {

foreach ($dbRow as $attrib => $value) {
$this->set($attrib, $value);
}

$this->config = json_decode($this->config);

}

}


/**
* Saves changes to the item to the database
*/
public function save() {

$this->set("config", json_encode($this->config));
parent::saveToDatabase("#__components");

}

}
?>
31 changes: 31 additions & 0 deletions admin/components/com_search/models/PanelModel.php
@@ -0,0 +1,31 @@
<?php

/**
* Model for the panel
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class PanelModel extends XComponentModel {

/**
* Method to load data
*/
public function load() {

$this->_includeLanguages();
$this->_includeConfiguration();

}

private function _includeConfiguration() {
global $xCom;

$this->configuration = $xCom->xConf;

}

}
?>
45 changes: 45 additions & 0 deletions admin/components/com_search/models/TermModel.php
@@ -0,0 +1,45 @@
<?php

/**
* Model for a XirtCMS Search Term
*
* @author A.G. Gideonse
* @version 2.0
* @copyright XirtCMS 2010 - 2014
* @package XirtCMS
*/
class TermModel extends XItemModel {

/**
* Loads item information from the database
*/
public function load($id) {
parent::loadFromDatabase("#__search", $id);
}


/**
* Saves changes to the item to the database
*/
public function add() {
parent::addToDatabase("#__search");
}


/**
* Saves changes to the item to the database
*/
public function save() {
parent::saveToDatabase("#__search");
}


/**
* Removes item from the database
*/
public function delete() {
parent::deleteFromDatabase("#__search");
}

}
?>

0 comments on commit 479bc2d

Please sign in to comment.