Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JCategories

Liste de tous les membres

Fonctions membres publiques

 __construct ($options)
 get ($id= 'root', $forceload=false)

Fonctions membres publiques statiques

static getInstance ($extension, $options=array())

Attributs publics statiques

static $instances = array()

Fonctions membres protégées

 _load ($id)

Attributs protégés

 $_nodes
 $_checkedCategories
 $_extension = null
 $_table = null
 $_field = null
 $_key = null
 $_statefield = null
 $_options = null

Description détaillée

Définition à la ligne 19 du fichier categories.php.


Documentation des constructeurs et destructeur

JCategories::__construct (   $options)

Class constructor

Paramètres:
array$optionsArray of options
Depuis:
11.1

Définition à la ligne 100 du fichier categories.php.

{
$this->_extension = $options['extension'];
$this->_table = $options['table'];
$this->_field = (isset($options['field']) && $options['field']) ? $options['field'] : 'catid';
$this->_key = (isset($options['key']) && $options['key']) ? $options['key'] : 'id';
$this->_statefield = (isset($options['statefield'])) ? $options['statefield'] : 'state';
$options['access'] = (isset($options['access'])) ? $options['access'] : 'true';
$options['published'] = (isset($options['published'])) ? $options['published'] : 1;
$this->_options = $options;
return true;
}

Documentation des fonctions membres

JCategories::_load (   $id)
protected

Load method

Paramètres:
integer$idId of category to load
Renvoie:
void
Depuis:
11.1

Définition à la ligne 207 du fichier categories.php.

Références JFactory\getDbo(), et JFactory\getUser().

{
$user = JFactory::getUser();
$extension = $this->_extension;
// Record that has this $id has been checked
$this->_checkedCategories[$id] = true;
$query = $db->getQuery(true);
// Right join with c for category
$query->select('c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time,
c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level,
c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id,
c.path, c.published, c.rgt, c.title, c.modified_user_id, c.version');
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('c.alias', '!=', '0');
$case_when .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $c_id . ' END as slug';
$query->select($case_when)
->from('#__categories as c')
->where('(c.extension=' . $db->quote($extension) . ' OR c.extension=' . $db->quote('system') . ')');
if ($this->_options['access'])
{
$query->where('c.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
}
if ($this->_options['published'] == 1)
{
$query->where('c.published = 1');
}
$query->order('c.lft');
// Note: s for selected id
if ($id != 'root')
{
// Get the selected category
$query->join('LEFT', '#__categories AS s ON (s.lft <= c.lft AND s.rgt >= c.rgt) OR (s.lft > c.lft AND s.rgt < c.rgt)')
->where('s.id=' . (int) $id);
}
$subQuery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ' .
'ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = ' . $db->quote($extension) .
' AND parent.published != 1 GROUP BY cat.id) ';
$query->join('LEFT', $subQuery . 'AS badcats ON badcats.id = c.id')
->where('badcats.id is null');
// Note: i for item
if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1)
{
if ($this->_options['published'] == 1)
{
$query->join(
'LEFT',
$db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id AND i.' . $this->_statefield . ' = 1'
);
}
else
{
$query->join('LEFT', $db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id');
}
$query->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems');
}
// Group by
$query->group(
'c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time,
c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level,
c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id,
c.path, c.published, c.rgt, c.title, c.modified_user_id, c.version'
);
// Get the results
$db->setQuery($query);
$results = $db->loadObjectList('id');
$childrenLoaded = false;
if (count($results))
{
// Foreach categories
foreach ($results as $result)
{
// Deal with root category
if ($result->id == 1)
{
$result->id = 'root';
}
// Deal with parent_id
if ($result->parent_id == 1)
{
$result->parent_id = 'root';
}
// Create the node
if (!isset($this->_nodes[$result->id]))
{
// Create the JCategoryNode and add to _nodes
$this->_nodes[$result->id] = new JCategoryNode($result, $this);
// If this is not root and if the current node's parent is in the list or the current node parent is 0
if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id == 1))
{
// Compute relationship between node and its parent - set the parent in the _nodes field
$this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]);
}
// If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0),
// then remove the node from the list
if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0))
{
unset($this->_nodes[$result->id]);
continue;
}
if ($result->id == $id || $childrenLoaded)
{
$this->_nodes[$result->id]->setAllLoaded();
$childrenLoaded = true;
}
}
elseif ($result->id == $id || $childrenLoaded)
{
// Create the JCategoryNode
$this->_nodes[$result->id] = new JCategoryNode($result, $this);
if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id))
{
// Compute relationship between node and its parent
$this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]);
}
if (!isset($this->_nodes[$result->parent_id]))
{
unset($this->_nodes[$result->id]);
continue;
}
if ($result->id == $id || $childrenLoaded)
{
$this->_nodes[$result->id]->setAllLoaded();
$childrenLoaded = true;
}
}
}
}
else
{
$this->_nodes[$id] = null;
}
}

+ Voici le graphe d'appel pour cette fonction :

JCategories::get (   $id = 'root',
  $forceload = false 
)

Loads a specific category and all its children in a JCategoryNode object

Paramètres:
mixed$idan optional id integer or equal to 'root'
boolean$forceloadTrue to force the _load method to execute
Renvoie:
mixed JCategoryNode object or null if $id is not valid
Depuis:
11.1

Définition à la ligne 166 du fichier categories.php.

{
if ($id !== 'root')
{
$id = (int) $id;
if ($id == 0)
{
$id = 'root';
}
}
// If this $id has not been processed yet, execute the _load method
if ((!isset($this->_nodes[$id]) && !isset($this->_checkedCategories[$id])) || $forceload)
{
$this->_load($id);
}
// If we already have a value in _nodes for this $id, then use it.
if (isset($this->_nodes[$id]))
{
return $this->_nodes[$id];
}
// If we processed this $id already and it was not valid, then return null.
elseif (isset($this->_checkedCategories[$id]))
{
return null;
}
return false;
}
static JCategories::getInstance (   $extension,
  $options = array() 
)
static

Returns a reference to a JCategories object

Paramètres:
string$extensionName of the categories extension
array$optionsAn array of options
Renvoie:
JCategories JCategories object
Depuis:
11.1

Définition à la ligne 124 du fichier categories.php.

{
$hash = md5($extension . serialize($options));
if (isset(self::$instances[$hash]))
{
return self::$instances[$hash];
}
$parts = explode('.', $extension);
$component = 'com_' . strtolower($parts[0]);
$section = count($parts) > 1 ? $parts[1] : '';
$classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories';
if (!class_exists($classname))
{
$path = JPATH_SITE . '/components/' . $component . '/helpers/category.php';
if (is_file($path))
{
include_once $path;
}
else
{
return false;
}
}
self::$instances[$hash] = new $classname($options);
return self::$instances[$hash];
}

Documentation des données membres

JCategories::$_checkedCategories
protected

Définition à la ligne 43 du fichier categories.php.

JCategories::$_extension = null
protected

Définition à la ligne 51 du fichier categories.php.

JCategories::$_field = null
protected

Définition à la ligne 67 du fichier categories.php.

JCategories::$_key = null
protected

Définition à la ligne 75 du fichier categories.php.

JCategories::$_nodes
protected

Définition à la ligne 35 du fichier categories.php.

JCategories::$_options = null
protected

Définition à la ligne 91 du fichier categories.php.

JCategories::$_statefield = null
protected

Définition à la ligne 83 du fichier categories.php.

JCategories::$_table = null
protected

Définition à la ligne 59 du fichier categories.php.

JCategories::$instances = array()
static

Définition à la ligne 27 du fichier categories.php.


La documentation de cette classe a été générée à partir du fichier suivant :