term_parent.inc File Reference

(1.1.2.6 2008/05/27 20:21:14 sdboyer)


Detailed Description

Plugin to provide an relationship handler for term parent

Definition in file term_parent.inc.

Go to the source code of this file.

Functions

 panels_term_parent_context ($context=NULL, $conf)
 panels_term_parent_panels_relationships ()
 panels_term_parent_settings_form ($conf)


Function Documentation

panels_term_parent_context ( context = NULL,
conf 
)

Return a new context based on an existing context

Definition at line 27 of file term_parent.inc.

References panels_context_create(), and panels_context_create_empty().

00027                                                             {
00028   // If unset it wants a generic, unfilled context, which is just NULL
00029   if (empty($context->data)) {
00030     return panels_context_create_empty('term');
00031   }
00032 
00033   if (isset($context->data)) {
00034     $result = db_fetch_array(db_query("SELECT t1.* FROM {term_hierarchy} t1 INNER JOIN {term_hierarchy} t2 ON t1.tid = t2.parent WHERE t2.tid = %d", $context->data->tid));
00035 
00036     // If top level term, keep looking up until we see a top level.
00037     if ($conf['type'] == 'top') {
00038       // If looking for top level, and there are no parents at all, make sure
00039       // the current term is the 'top level'.
00040       if (empty($result)) {
00041         $result['tid'] = $context->data->tid;
00042       }
00043       while (!empty($result['parent'])) {
00044         $result = db_fetch_array(db_query("SELECT * FROM {term_hierarchy} WHERE tid = %d", $result['parent']));
00045       }
00046     }
00047 
00048     // load the term
00049     if ($result) {
00050       $term = taxonomy_get_term($result['tid']);
00051       return panels_context_create('term', $term);
00052     }
00053   }
00054 }

Here is the call graph for this function:

panels_term_parent_panels_relationships (  ) 

Definition at line 11 of file term_parent.inc.

00011                                                    {
00012   $args['term_parent'] = array(
00013     'title' => t("Term parent"),
00014     'keyword' => 'parent_term',
00015     'description' => t('Adds a taxonomy term parent from a term context.'),
00016     'required context' => new panels_required_context(t('Term'), 'term'),
00017     'context' => 'panels_term_parent_context',
00018     'settings form' => 'panels_term_parent_settings_form',
00019     'settings form validate' => 'panels_term_parent_settings_form_validate',
00020   );
00021   return $args;
00022 }

panels_term_parent_settings_form ( conf  ) 

Settings form for the relationship

Definition at line 59 of file term_parent.inc.

00059                                                  {
00060   $form['type'] = array(
00061     '#type' => 'select',
00062     '#title' => t('Relationship type'),
00063     '#options' => array('parent' => t('Immediate parent'), 'top' => t('Top level term')),
00064     '#default_value' => $conf['type'],
00065   );
00066 
00067   return $form;
00068 }


Generated on Sun Feb 5 05:00:25 2012 for Panels 2 by  doxygen 1.5.6