1 <?php
 2 /**
 3  * @package    FrameworkOnFramework
 4  * @subpackage form
 5  * @copyright   Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
 6  * @license    GNU General Public License version 2 or later; see LICENSE.txt
 7  */
 8 // Protect from unauthorized access
 9 defined('FOF_INCLUDED') or die;
10 
11 JFormHelper::loadFieldClass('text');
12 
13 /**
14  * Form Field class for the FOF framework
15  * Supports a title field with an optional slug display below it.
16  *
17  * @package  FrameworkOnFramework
18  * @since    2.0
19  */
20 class FOFFormFieldTitle extends FOFFormFieldText implements FOFFormField
21 {
22     /**
23      * Get the rendering of this field type for a repeatable (grid) display,
24      * e.g. in a view listing many item (typically a "browse" task)
25      *
26      * @since 2.0
27      *
28      * @return  string  The field HTML
29      */
30     public function getRepeatable()
31     {
32         // Initialise
33         $slug_format    = '(%s)';
34         $slug_class     = 'small';
35 
36         // Get field parameters
37         if ($this->element['slug_field'])
38         {
39             $slug_field = (string) $this->element['slug_field'];
40         }
41         else
42         {
43             $slug_field = $this->item->getColumnAlias('slug');
44         }
45 
46         if ($this->element['slug_format'])
47         {
48             $slug_format = (string) $this->element['slug_format'];
49         }
50 
51         if ($this->element['slug_class'])
52         {
53             $slug_class = (string) $this->element['slug_class'];
54         }
55 
56         // Get the regular display
57         $html = parent::getRepeatable();
58 
59         $slug = $this->item->$slug_field;
60 
61         $html .= '<br />' . '<span class="' . $slug_class . '">';
62         $html .= JText::sprintf($slug_format, $slug);
63         $html .= '</span>';
64 
65         return $html;
66     }
67 }
68