Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ModDisplayVacanciesHelper
- {
- function __construct()
- {
- $app = JFactory::getApplication();
- }
- public function setVacancyIdAjax()
- {
- //Get request data
- $jinput = JFactory::getApplication()->input;
- $vacancy_id = $jinput->get("vacancy_id");
- $session = JFactory::getSession();
- $session->set('vacancy_id', $vacancy_id);
- return $vacancy_id;
- }
- public function createTable($params)
- {
- include_once JPATH_ROOT . '/components/com_content/helpers/route.php';
- $session = JFactory::getSession();
- $session->set('current_page', '0');
- $count = $params->get("count");
- $tableClass = $params->get("table_classes");
- //Connect to the database
- $db = JFactory::getDbo();
- $query = $db->getQuery(true);
- //Set table headers
- $htmlResult = "<table id='vacanciesTable' class='".$tableClass."'>
- <th>Functie</th>
- <th>Specialiteit</th>
- <th>Regio</th>
- <th>Expertise</th>";
- //Build the query
- $query
- ->select($db->quoteName(array('Function', 'SpecialityName', 'RegioName', 'Expertise-1', 'ID')))
- ->from($db->quoteName('vacancies'))
- ->order('Registered DESC');
- $db->setQuery($query);
- $this->vacanciesRows = $db->loadRowList();
- //Add rows to the table
- foreach ($this->vacanciesRows as $index=>$row)
- {
- if( $index == $count)
- break;
- $newRow = $this->createTableRow($row);
- $htmlResult .= $newRow;
- }
- $htmlResult .= "</table>";
- return $htmlResult;
- }
- public function addPagination($params)
- {
- $count = $params->get("count");
- $multiPage = $params->get("multiple_pages");
- //Add controls for changing pages
- if($multiPage)
- {
- jimport('joomla.html.pagination');
- $pagination = new JPagination(count($this->vacanciesRows) , 0, $count);
- echo $pagination->getListFooter();
- }
- }
- private function createTableRow($row)
- {
- $count = count($row);
- $htmlRow = "<tr id=".$row[$count-1]."'>";
- foreach($row as $index=>$element)
- {
- if($index == $count - 1)
- {
- //Dont show the ID in the table
- break;
- }
- $htmlRow .= "<td>".$element."</td>";
- }
- $htmlRow .= "</tr>";
- return $htmlRow;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement