You've already forked joomla_test
first commit
This commit is contained in:
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
// Load the base adapter.
|
||||
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
|
||||
|
||||
/**
|
||||
* Renders a list of directories.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class JFormFieldDirectories extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $type = 'Directories';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
$values = array();
|
||||
$options = array();
|
||||
$exclude = array(
|
||||
JPATH_ADMINISTRATOR,
|
||||
JPATH_INSTALLATION,
|
||||
JPATH_LIBRARIES,
|
||||
JPATH_PLUGINS,
|
||||
JPATH_SITE . '/cache',
|
||||
JPATH_SITE . '/components',
|
||||
JPATH_SITE . '/includes',
|
||||
JPATH_SITE . '/language',
|
||||
JPATH_SITE . '/modules',
|
||||
JPATH_THEMES,
|
||||
JFactory::getApplication()->getCfg('log_path'),
|
||||
JFactory::getApplication()->getCfg('tmp_path')
|
||||
);
|
||||
|
||||
// Get the base directories.
|
||||
jimport('joomla.filesystem.folder');
|
||||
$dirs = JFolder::folders(JPATH_SITE, '.', false, true);
|
||||
|
||||
// Iterate through the base directories and find the subdirectories.
|
||||
foreach ($dirs as $dir)
|
||||
{
|
||||
// Check if the directory should be excluded.
|
||||
if (in_array($dir, $exclude))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the child directories.
|
||||
$return = JFolder::folders($dir, '.', true, true);
|
||||
|
||||
// Merge the directories.
|
||||
if (is_array($return))
|
||||
{
|
||||
$values[] = $dir;
|
||||
$values = array_merge($values, $return);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the values to options.
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', str_replace(JPATH_SITE . '/', '', $value), str_replace(JPATH_SITE . '/', '', $values));
|
||||
}
|
||||
|
||||
// Add a null option.
|
||||
array_unshift($options, JHtml::_('select.option', '', '- ' . JText::_('JNONE') . ' -'));
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die();
|
||||
|
||||
JFormHelper::loadFieldClass('list');
|
||||
|
||||
/**
|
||||
* Search Filter field for the Finder package.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class JFormFieldSearchFilter extends JFormFieldList
|
||||
{
|
||||
/**
|
||||
* The form field type.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $type = 'SearchFilter';
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
// Build the query.
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('f.title AS text, f.filter_id AS value')
|
||||
->from($db->quoteName('#__finder_filters') . ' AS f')
|
||||
->where('f.state = 1')
|
||||
->order('f.title ASC');
|
||||
$db->setQuery($query);
|
||||
$options = $db->loadObjectList();
|
||||
|
||||
array_unshift($options, JHtml::_('select.option', '', JText::_('COM_FINDER_SELECT_SEARCH_FILTER'), 'value', 'text'));
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
156
administrator/components/com_finder/models/filter.php
Normal file
156
administrator/components/com_finder/models/filter.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Filter model class for Finder.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderModelFilter extends JModelAdmin
|
||||
{
|
||||
/**
|
||||
* The prefix to use with controller messages.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $text_prefix = 'COM_FINDER';
|
||||
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $context = 'com_finder.filter';
|
||||
|
||||
/**
|
||||
* Custom clean cache method.
|
||||
*
|
||||
* @param string $group The component name. [optional]
|
||||
* @param integer $client_id The client ID. [optional]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function cleanCache($group = 'com_finder', $client_id = 1)
|
||||
{
|
||||
parent::cleanCache($group, $client_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the filter data.
|
||||
*
|
||||
* @return mixed The filter data.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getFilter()
|
||||
{
|
||||
$filter_id = (int) $this->getState('filter.id');
|
||||
|
||||
// Get a FinderTableFilter instance.
|
||||
$filter = $this->getTable();
|
||||
|
||||
// Attempt to load the row.
|
||||
$return = $filter->load($filter_id);
|
||||
|
||||
// Check for a database error.
|
||||
if ($return === false && $filter->getError())
|
||||
{
|
||||
$this->setError($filter->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Process the filter data.
|
||||
if (!empty($filter->data))
|
||||
{
|
||||
$filter->data = explode(',', $filter->data);
|
||||
}
|
||||
elseif (empty($filter->data))
|
||||
{
|
||||
$filter->data = array();
|
||||
}
|
||||
|
||||
// Check for a database error.
|
||||
if ($this->_db->getErrorNum())
|
||||
{
|
||||
$this->setError($this->_db->getErrorMsg());
|
||||
return false;
|
||||
}
|
||||
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form. [optional]
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not. [optional]
|
||||
*
|
||||
* @return mixed A JForm object on success, false on failure
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getForm($data = array(), $loadData = true)
|
||||
{
|
||||
// Get the form.
|
||||
$form = $this->loadForm('com_finder.filter', 'filter', array('control' => 'jform', 'load_data' => $loadData));
|
||||
|
||||
if (empty($form))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JTable object, always creating it.
|
||||
*
|
||||
* @param string $type The table type to instantiate. [optional]
|
||||
* @param string $prefix A prefix for the table class name. [optional]
|
||||
* @param array $config Configuration array for model. [optional]
|
||||
*
|
||||
* @return JTable A database object
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getTable($type = 'Filter', $prefix = 'FinderTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return mixed The data for the form.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
// Check the session for previously entered form data.
|
||||
$data = JFactory::getApplication()->getUserState('com_finder.edit.filter.data', array());
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
$this->preprocessData('com_finder.filter', $data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
136
administrator/components/com_finder/models/filters.php
Normal file
136
administrator/components/com_finder/models/filters.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Filters model class for Finder.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderModelFilters extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An associative array of configuration settings. [optional]
|
||||
*
|
||||
* @since 2.5
|
||||
* @see JController
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'filter_id', 'a.filter_id',
|
||||
'title', 'a.title',
|
||||
'state', 'a.state',
|
||||
'created_by_alias', 'a.created_by_alias',
|
||||
'created', 'a.created',
|
||||
'map_count', 'a.map_count'
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return JDatabaseQuery A JDatabaseQuery object
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select all fields from the table.
|
||||
$query->select('a.*')
|
||||
->from($db->quoteName('#__finder_filters') . ' AS a');
|
||||
|
||||
// Join over the users for the checked out user.
|
||||
$query->select('uc.name AS editor')
|
||||
->join('LEFT', $db->quoteName('#__users') . ' AS uc ON uc.id=a.checked_out');
|
||||
|
||||
// Join over the users for the author.
|
||||
$query->select('ua.name AS user_name')
|
||||
->join('LEFT', $db->quoteName('#__users') . ' AS ua ON ua.id = a.created_by');
|
||||
|
||||
// Check for a search filter.
|
||||
if ($this->getState('filter.search'))
|
||||
{
|
||||
$query->where('( a.title LIKE \'%' . $db->escape($this->getState('filter.search')) . '%\' )');
|
||||
}
|
||||
|
||||
// If the model is set to check item state, add to the query.
|
||||
if (is_numeric($this->getState('filter.state')))
|
||||
{
|
||||
$query->where('a.state = ' . (int) $this->getState('filter.state'));
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order($db->escape($this->getState('list.ordering') . ' ' . $db->escape($this->getState('list.direction'))));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id. [optional]
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.state');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field. [optional]
|
||||
* @param string $direction An optional direction. [optional]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// Load the filter state.
|
||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
|
||||
$this->setState('filter.state', $state);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_finder');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('a.title', 'asc');
|
||||
}
|
||||
}
|
93
administrator/components/com_finder/models/forms/filter.xml
Normal file
93
administrator/components/com_finder/models/forms/filter.xml
Normal file
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form>
|
||||
<fieldset>
|
||||
<field name="filter_id" type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"
|
||||
readonly="true" />
|
||||
|
||||
<field
|
||||
name="title" type="text" id="title"
|
||||
label="JGLOBAL_TITLE" description="COM_FINDER_FILTER_TITLE_DESCRIPTION"
|
||||
size="30" default="" required="true" />
|
||||
|
||||
<field name="alias" type="text" label="JFIELD_ALIAS_LABEL"
|
||||
description="JFIELD_ALIAS_DESC" class="inputbox" size="45" />
|
||||
|
||||
<field name="created" type="calendar" label="JGLOBAL_FIELD_CREATED_LABEL"
|
||||
description="JGLOBAL_FIELD_CREATED_DESC" class="inputbox" size="22"
|
||||
format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
|
||||
|
||||
<field name="modified" type="calendar" class="readonly"
|
||||
label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_FINDER_FIELD_MODIFIED_DESCRIPTION"
|
||||
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
|
||||
|
||||
<field name="created_by" type="user"
|
||||
label="COM_FINDER_FIELD_CREATED_BY_LABEL" description="COM_FINDER_FIELD_CREATED_BY_DESC" />
|
||||
|
||||
<field name="created_by_alias" type="text"
|
||||
label="COM_FINDER_FIELD_CREATED_BY_ALIAS_LABEL" description="COM_FINDER_FIELD_CREATED_BY_ALIAS_DESC"
|
||||
class="inputbox" size="20" />
|
||||
<field name="modified_by" type="user"
|
||||
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
|
||||
<field name="checked_out" type="hidden" filter="unset" />
|
||||
|
||||
<field name="checked_out_time" type="hidden" filter="unset" />
|
||||
|
||||
|
||||
<field name="state" type="list" label="JSTATUS"
|
||||
description="JFIELD_PUBLISHED_DESC" class="inputbox"
|
||||
filter="intval" size="1" default="1" >
|
||||
<option value="1">
|
||||
JPUBLISHED</option>
|
||||
<option value="0">
|
||||
JUNPUBLISHED</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="map_count" type="text" class="readonly"
|
||||
label="COM_FINDER_FILTER_MAP_COUNT" description="COM_FINDER_FILTER_MAP_COUNT_DESCRIPTION"
|
||||
size="10" default="0" readonly="true" />
|
||||
</fieldset>
|
||||
|
||||
<fields name="params">
|
||||
<field
|
||||
name="w1"
|
||||
type="list"
|
||||
label="COM_FINDER_FILTER_WHEN_START_DATE_LABEL"
|
||||
description="COM_FINDER_FILTER_WHEN_START_DATE_DESCRIPTION"
|
||||
default=""
|
||||
filter="string">
|
||||
<option value="">JNONE</option>
|
||||
<option value="-1">COM_FINDER_FILTER_WHEN_BEFORE</option>
|
||||
<option value="0">COM_FINDER_FILTER_WHEN_EXACTLY</option>
|
||||
<option value="1">COM_FINDER_FILTER_WHEN_AFTER</option>
|
||||
</field>
|
||||
|
||||
<field name="d1" type="calendar" class="inputbox"
|
||||
label="COM_FINDER_FILTER_START_DATE_LABEL" description="COM_FINDER_FILTER_START_DATE_DESCRIPTION"
|
||||
size="22" format="%Y-%m-%d" filter="user_utc" />
|
||||
|
||||
<field
|
||||
name="w2"
|
||||
type="list"
|
||||
label="COM_FINDER_FILTER_WHEN_END_DATE_LABEL"
|
||||
description="COM_FINDER_FILTER_WHEN_END_DATE_DESCRIPTION"
|
||||
default=""
|
||||
filter="string">
|
||||
<option value="">JNONE</option>
|
||||
<option value="-1">COM_FINDER_FILTER_WHEN_BEFORE</option>
|
||||
<option value="0">COM_FINDER_FILTER_WHEN_EXACTLY</option>
|
||||
<option value="1">COM_FINDER_FILTER_WHEN_AFTER</option>
|
||||
</field>
|
||||
|
||||
<field name="d2" type="calendar" class="inputbox"
|
||||
label="COM_FINDER_FILTER_END_DATE_LABEL" description="COM_FINDER_FILTER_END_DATE_DESCRIPTION"
|
||||
size="22" format="%Y-%m-%d" filter="user_utc" />
|
||||
|
||||
</fields>
|
||||
</form>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
administrator/components/com_finder/models/index.html
Normal file
1
administrator/components/com_finder/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
410
administrator/components/com_finder/models/index.php
Normal file
410
administrator/components/com_finder/models/index.php
Normal file
@ -0,0 +1,410 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Index model class for Finder.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderModelIndex extends JModelList
|
||||
{
|
||||
/**
|
||||
* The event to trigger after deleting the data.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $event_after_delete = 'onContentAfterDelete';
|
||||
|
||||
/**
|
||||
* The event to trigger before deleting the data.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $event_before_delete = 'onContentBeforeDelete';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An associative array of configuration settings. [optional]
|
||||
*
|
||||
* @since 2.5
|
||||
* @see JController
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'published', 'l.published',
|
||||
'title', 'l.title',
|
||||
'type_id', 'l.type_id',
|
||||
'url', 'l.url',
|
||||
'indexdate', 'l.indexdate'
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
return $user->authorise('core.delete', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to change the state of the record. Defaults to the permission for the component.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
return $user->authorise('core.edit.state', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete one or more records.
|
||||
*
|
||||
* @param array &$pks An array of record primary keys.
|
||||
*
|
||||
* @return boolean True if successful, false if an error occurs.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function delete(&$pks)
|
||||
{
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
$pks = (array) $pks;
|
||||
$table = $this->getTable();
|
||||
|
||||
// Include the content plugins for the on delete events.
|
||||
JPluginHelper::importPlugin('content');
|
||||
|
||||
// Iterate the items to delete each one.
|
||||
foreach ($pks as $i => $pk)
|
||||
{
|
||||
if ($table->load($pk))
|
||||
{
|
||||
if ($this->canDelete($table))
|
||||
{
|
||||
$context = $this->option . '.' . $this->name;
|
||||
|
||||
// Trigger the onContentBeforeDelete event.
|
||||
$result = $dispatcher->trigger($this->event_before_delete, array($context, $table));
|
||||
if (in_array(false, $result, true))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$table->delete($pk))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trigger the onContentAfterDelete event.
|
||||
$dispatcher->trigger($this->event_after_delete, array($context, $table));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Prune items that you can't change.
|
||||
unset($pks[$i]);
|
||||
$error = $this->getError();
|
||||
if ($error)
|
||||
{
|
||||
$this->setError($error);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the component's cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return JDatabaseQuery A JDatabaseQuery object
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('l.*')
|
||||
->select('t.title AS t_title')
|
||||
->from($db->quoteName('#__finder_links') . ' AS l')
|
||||
->join('INNER', $db->quoteName('#__finder_types') . ' AS t ON t.id = l.type_id');
|
||||
|
||||
// Check the type filter.
|
||||
if ($this->getState('filter.type'))
|
||||
{
|
||||
$query->where('l.type_id = ' . (int) $this->getState('filter.type'));
|
||||
}
|
||||
|
||||
// Check for state filter.
|
||||
if (is_numeric($this->getState('filter.state')))
|
||||
{
|
||||
$query->where('l.published = ' . (int) $this->getState('filter.state'));
|
||||
}
|
||||
|
||||
// Check the search phrase.
|
||||
if ($this->getState('filter.search') != '')
|
||||
{
|
||||
$search = $db->escape($this->getState('filter.search'));
|
||||
$query->where(
|
||||
'l.title LIKE ' . $db->quote('%' . $db->escape($search) . '%') . ' OR l.url LIKE ' . $db->quote('%' . $db->escape($search) . '%')
|
||||
. ' OR l.indexdate LIKE ' . $db->quote('%' . $db->escape($search) . '%')
|
||||
);
|
||||
}
|
||||
|
||||
// Handle the list ordering.
|
||||
$ordering = $this->getState('list.ordering');
|
||||
$direction = $this->getState('list.direction');
|
||||
if (!empty($ordering))
|
||||
{
|
||||
$query->order($db->escape($ordering) . ' ' . $db->escape($direction));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the state of the Smart Search plug-ins.
|
||||
*
|
||||
* @return array Array of relevant plug-ins and whether they are enabled or not.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getPluginState()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('name, enabled')
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
||||
->where($db->quoteName('folder') . ' IN(' . $db->quote('system') . ',' . $db->quote('content') . ')')
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote('finder'));
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
$plugins = $db->loadObjectList('name');
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id. [optional]
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.state');
|
||||
$id .= ':' . $this->getState('filter.type');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JTable object, always creating it.
|
||||
*
|
||||
* @param string $type The table type to instantiate. [optional]
|
||||
* @param string $prefix A prefix for the table class name. [optional]
|
||||
* @param array $config Configuration array for model. [optional]
|
||||
*
|
||||
* @return JTable A database object
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getTable($type = 'Link', $prefix = 'FinderTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to purge the index, deleting all links.
|
||||
*
|
||||
* @return boolean True on success, false on failure.
|
||||
*
|
||||
* @since 2.5
|
||||
* @throws Exception on database error
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
|
||||
// Truncate the links table.
|
||||
$db->truncateTable('#__finder_links');
|
||||
|
||||
// Truncate the links terms tables.
|
||||
for ($i = 0; $i <= 15; $i++)
|
||||
{
|
||||
// Get the mapping table suffix.
|
||||
$suffix = dechex($i);
|
||||
|
||||
$db->truncateTable('#__finder_links_terms' . $suffix);
|
||||
}
|
||||
|
||||
// Truncate the terms table.
|
||||
$db->truncateTable('#__finder_terms');
|
||||
|
||||
// Truncate the taxonomy map table.
|
||||
$db->truncateTable('#__finder_taxonomy_map');
|
||||
|
||||
// Delete all the taxonomy nodes except the root.
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__finder_taxonomy'))
|
||||
->where($db->quoteName('id') . ' > 1');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// Truncate the tokens tables.
|
||||
$db->truncateTable('#__finder_tokens');
|
||||
|
||||
// Truncate the tokens aggregate table.
|
||||
$db->truncateTable('#__finder_tokens_aggregate');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field. [optional]
|
||||
* @param string $direction An optional direction. [optional]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// Load the filter state.
|
||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
|
||||
$this->setState('filter.state', $state);
|
||||
|
||||
$type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '', 'string');
|
||||
$this->setState('filter.type', $type);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_finder');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('l.title', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to change the published state of one or more records.
|
||||
*
|
||||
* @param array &$pks A list of the primary keys to change.
|
||||
* @param integer $value The value of the published state. [optional]
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function publish(&$pks, $value = 1)
|
||||
{
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
$user = JFactory::getUser();
|
||||
$table = $this->getTable();
|
||||
$pks = (array) $pks;
|
||||
|
||||
// Include the content plugins for the change of state event.
|
||||
JPluginHelper::importPlugin('content');
|
||||
|
||||
// Access checks.
|
||||
foreach ($pks as $i => $pk)
|
||||
{
|
||||
$table->reset();
|
||||
|
||||
if ($table->load($pk))
|
||||
{
|
||||
if (!$this->canEditState($table))
|
||||
{
|
||||
// Prune items that you can't change.
|
||||
unset($pks[$i]);
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to change the state of the records.
|
||||
if (!$table->publish($pks, $value, $user->get('id')))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
$context = $this->option . '.' . $this->name;
|
||||
|
||||
// Trigger the onContentChangeState event.
|
||||
$result = $dispatcher->trigger('onContentChangeState', array($context, $pks, $value));
|
||||
|
||||
if (in_array(false, $result, true))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the component's cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
21
administrator/components/com_finder/models/indexer.php
Normal file
21
administrator/components/com_finder/models/indexer.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Indexer model class for Finder.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderModelIndexer extends JModelLegacy
|
||||
{
|
||||
}
|
355
administrator/components/com_finder/models/maps.php
Normal file
355
administrator/components/com_finder/models/maps.php
Normal file
@ -0,0 +1,355 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die();
|
||||
|
||||
/**
|
||||
* Maps model for the Finder package.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderModelMaps extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $config An associative array of configuration settings. [optional]
|
||||
*
|
||||
* @since 2.5
|
||||
* @see JController
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'state', 'a.state',
|
||||
'title', 'a.title'
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
return $user->authorise('core.delete', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to change the state of the record. Defaults to the permission for the component.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
return $user->authorise('core.edit.state', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to delete one or more records.
|
||||
*
|
||||
* @param array &$pks An array of record primary keys.
|
||||
*
|
||||
* @return boolean True if successful, false if an error occurs.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function delete(&$pks)
|
||||
{
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
$pks = (array) $pks;
|
||||
$table = $this->getTable();
|
||||
|
||||
// Include the content plugins for the on delete events.
|
||||
JPluginHelper::importPlugin('content');
|
||||
|
||||
// Iterate the items to delete each one.
|
||||
foreach ($pks as $i => $pk)
|
||||
{
|
||||
if ($table->load($pk))
|
||||
{
|
||||
if ($this->canDelete($table))
|
||||
{
|
||||
$context = $this->option . '.' . $this->name;
|
||||
|
||||
// Trigger the onContentBeforeDelete event.
|
||||
$result = $dispatcher->trigger('onContentBeforeDelete', array($context, $table));
|
||||
if (in_array(false, $result, true))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$table->delete($pk))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trigger the onContentAfterDelete event.
|
||||
$dispatcher->trigger('onContentAfterDelete', array($context, $table));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Prune items that you can't change.
|
||||
unset($pks[$i]);
|
||||
$error = $this->getError();
|
||||
if ($error)
|
||||
{
|
||||
$this->setError($error);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the component's cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return JDatabaseQuery A JDatabaseQuery object
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select all fields from the table.
|
||||
$query->select('a.*')
|
||||
->from($db->quoteName('#__finder_taxonomy') . ' AS a');
|
||||
|
||||
// Self-join to get children.
|
||||
$query->select('COUNT(b.id) AS num_children')
|
||||
->join('LEFT', $db->quoteName('#__finder_taxonomy') . ' AS b ON b.parent_id=a.id');
|
||||
|
||||
// Join to get the map links
|
||||
$query->select('COUNT(c.node_id) AS num_nodes')
|
||||
->join('LEFT', $db->quoteName('#__finder_taxonomy_map') . ' AS c ON c.node_id=a.id')
|
||||
|
||||
->group('a.id, a.parent_id, a.title, a.state, a.access, a.ordering');
|
||||
|
||||
// If the model is set to check item state, add to the query.
|
||||
if (is_numeric($this->getState('filter.state')))
|
||||
{
|
||||
$query->where('a.state = ' . (int) $this->getState('filter.state'));
|
||||
}
|
||||
|
||||
// Filter the maps over the branch if set.
|
||||
$branch_id = $this->getState('filter.branch');
|
||||
if (!empty($branch_id))
|
||||
{
|
||||
$query->where('a.parent_id = ' . (int) $branch_id);
|
||||
}
|
||||
|
||||
// Filter the maps over the search string if set.
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search))
|
||||
{
|
||||
$query->where('a.title LIKE ' . $db->quote('%' . $search . '%'));
|
||||
}
|
||||
|
||||
// Handle the list ordering.
|
||||
$ordering = $this->getState('list.ordering');
|
||||
$direction = $this->getState('list.direction');
|
||||
if (!empty($ordering))
|
||||
{
|
||||
$query->order($db->escape($ordering) . ' ' . $db->escape($direction));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model configuration state.
|
||||
*
|
||||
* This is necessary because the model is used by the component and
|
||||
* different modules that might need different sets of data or different
|
||||
* ordering requirements.
|
||||
*
|
||||
* @param string $id A prefix for the store id. [optional]
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.state');
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.branch');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JTable object, always creating it.
|
||||
*
|
||||
* @param string $type The table type to instantiate. [optional]
|
||||
* @param string $prefix A prefix for the table class name. [optional]
|
||||
* @param array $config Configuration array for model. [optional]
|
||||
*
|
||||
* @return JTable A database object
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getTable($type = 'Map', $prefix = 'FinderTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field. [optional]
|
||||
* @param string $direction An optional direction. [optional]
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// Load the filter state.
|
||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
|
||||
$this->setState('filter.state', $state);
|
||||
|
||||
$branch = $this->getUserStateFromRequest($this->context . '.filter.branch', 'filter_branch', '1', 'string');
|
||||
$this->setState('filter.branch', $branch);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_finder');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('a.title', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to change the published state of one or more records.
|
||||
*
|
||||
* @param array &$pks A list of the primary keys to change.
|
||||
* @param integer $value The value of the published state. [optional]
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function publish(&$pks, $value = 1)
|
||||
{
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
$user = JFactory::getUser();
|
||||
$table = $this->getTable();
|
||||
$pks = (array) $pks;
|
||||
|
||||
// Include the content plugins for the change of state event.
|
||||
JPluginHelper::importPlugin('content');
|
||||
|
||||
// Access checks.
|
||||
foreach ($pks as $i => $pk)
|
||||
{
|
||||
$table->reset();
|
||||
|
||||
if ($table->load($pk))
|
||||
{
|
||||
if (!$this->canEditState($table))
|
||||
{
|
||||
// Prune items that you can't change.
|
||||
unset($pks[$i]);
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to change the state of the records.
|
||||
if (!$table->publish($pks, $value, $user->get('id')))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
$context = $this->option . '.' . $this->name;
|
||||
|
||||
// Trigger the onContentChangeState event.
|
||||
$result = $dispatcher->trigger('onContentChangeState', array($context, $pks, $value));
|
||||
|
||||
if (in_array(false, $result, true))
|
||||
{
|
||||
$this->setError($table->getError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the component's cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to purge all maps from the taxonomy.
|
||||
*
|
||||
* @return boolean Returns true on success, false on failure.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function purge()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->delete($db->quoteName('#__finder_taxonomy'))
|
||||
->where($db->quoteName('parent_id') . ' > 1');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
$query->clear()
|
||||
->delete($db->quoteName('#__finder_taxonomy_map'))
|
||||
->where('1');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
71
administrator/components/com_finder/models/statistics.php
Normal file
71
administrator/components/com_finder/models/statistics.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Statistics model class for Finder.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderModelStatistics extends JModelLegacy
|
||||
{
|
||||
/**
|
||||
* Method to get the component statistics
|
||||
*
|
||||
* @return object The component statistics
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
// Initialise
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$data = new JObject;
|
||||
|
||||
$query->select('COUNT(term_id)')
|
||||
->from($db->quoteName('#__finder_terms'));
|
||||
$db->setQuery($query);
|
||||
$data->term_count = $db->loadResult();
|
||||
|
||||
$query->clear()
|
||||
->select('COUNT(link_id)')
|
||||
->from($db->quoteName('#__finder_links'));
|
||||
$db->setQuery($query);
|
||||
$data->link_count = $db->loadResult();
|
||||
|
||||
$query->clear()
|
||||
->select('COUNT(id)')
|
||||
->from($db->quoteName('#__finder_taxonomy'))
|
||||
->where($db->quoteName('parent_id') . ' = 1');
|
||||
$db->setQuery($query);
|
||||
$data->taxonomy_branch_count = $db->loadResult();
|
||||
|
||||
$query->clear()
|
||||
->select('COUNT(id)')
|
||||
->from($db->quoteName('#__finder_taxonomy'))
|
||||
->where($db->quoteName('parent_id') . ' > 1');
|
||||
$db->setQuery($query);
|
||||
$data->taxonomy_node_count = $db->loadResult();
|
||||
|
||||
$query->clear()
|
||||
->select('t.title AS type_title, COUNT(a.link_id) AS link_count')
|
||||
->from($db->quoteName('#__finder_links') . ' AS a')
|
||||
->join('INNER', $db->quoteName('#__finder_types') . ' AS t ON t.id = a.type_id')
|
||||
->group('a.type_id, t.title')
|
||||
->order($db->quoteName('type_title'), 'ASC');
|
||||
$db->setQuery($query);
|
||||
$data->type_list = $db->loadObjectList();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user