10 defined(
'JPATH_PLATFORM') or die;
12 jimport('joomla.filesystem.folder');
29 protected $type =
'ModuleLayout';
38 protected function getInput()
41 $clientId = $this->element[
'client_id'];
43 if (is_null($clientId) && $this->form instanceof
JForm)
45 $clientId = $this->form->getValue(
'client_id');
47 $clientId = (int) $clientId;
49 $client = JApplicationHelper::getClientInfo($clientId);
52 $module = (string) $this->element[
'module'];
54 if (empty($module) && ($this->form instanceof JForm))
56 $module = $this->form->getValue(
'module');
59 $module = preg_replace(
'#\W#',
'', $module);
62 $template = (string) $this->element[
'template'];
63 $template = preg_replace(
'#\W#',
'', $template);
66 if ($this->form instanceof JForm)
68 $template_style_id = $this->form->getValue(
'template_style_id');
71 $template_style_id = preg_replace(
'#\W#',
'', $template_style_id);
74 if ($module && $client)
79 $lang->load($module .
'.sys', $client->path, null,
false,
false)
80 || $lang->load($module .
'.sys', $client->path .
'/modules/' . $module, null,
false,
false)
81 || $lang->load($module .
'.sys', $client->path, $lang->getDefault(),
false,
false)
82 || $lang->load($module .
'.sys', $client->path .
'/modules/' . $module, $lang->getDefault(),
false,
false);
86 $query = $db->getQuery(
true);
89 $query->select(
'element, name')
90 ->from(
'#__extensions as e')
91 ->where(
'e.client_id = ' . (
int) $clientId)
92 ->where(
'e.type = ' . $db->quote(
'template'))
93 ->where(
'e.enabled = 1');
97 $query->where(
'e.element = ' . $db->quote($template));
100 if ($template_style_id)
102 $query->join(
'LEFT',
'#__template_styles as s on s.template=e.element')
103 ->where(
's.id=' . (
int) $template_style_id);
107 $db->setQuery($query);
108 $templates = $db->loadObjectList(
'element');
111 $module_path =
JPath::clean($client->path .
'/modules/' . $module .
'/tmpl');
114 $module_layouts = array();
120 if (is_dir($module_path) && ($module_layouts =
JFolder::files($module_path,
'^[^_]*\.php$')))
123 $groups[
'_'] = array();
124 $groups[
'_'][
'id'] = $this->
id .
'__';
126 $groups[
'_'][
'items'] = array();
128 foreach ($module_layouts as $file)
131 $value = basename($file,
'.php');
132 $text = $lang->hasKey($key = strtoupper($module .
'_LAYOUT_' . $value)) ?
JText::_($key) : $value;
133 $groups[
'_'][
'items'][] = JHtml::_(
'select.option',
'_:' . $value, $text);
140 foreach ($templates as $template)
143 $lang->load(
'tpl_' . $template->element .
'.sys', $client->path, null,
false,
false)
144 || $lang->load(
'tpl_' . $template->element .
'.sys', $client->path .
'/templates/' . $template->element, null,
false,
false)
145 || $lang->load(
'tpl_' . $template->element .
'.sys', $client->path, $lang->getDefault(),
false,
false)
147 'tpl_' . $template->element .
'.sys', $client->path .
'/templates/' . $template->element, $lang->getDefault(),
151 $template_path =
JPath::clean($client->path .
'/templates/' . $template->element .
'/html/' . $module);
154 if (is_dir($template_path) && ($files =
JFolder::files($template_path,
'^[^_]*\.php$')))
156 foreach ($files as $i => $file)
159 if (in_array($file, $module_layouts))
168 $groups[$template->element] = array();
169 $groups[$template->element][
'id'] = $this->
id .
'_' . $template->element;
170 $groups[$template->element][
'text'] =
JText::sprintf(
'JOPTION_FROM_TEMPLATE', $template->name);
171 $groups[$template->element][
'items'] = array();
173 foreach ($files as $file)
176 $value = basename($file,
'.php');
177 $text = $lang->hasKey($key = strtoupper(
'TPL_' . $template->element .
'_' . $module .
'_LAYOUT_' . $value))
179 $groups[$template->element][
'items'][] = JHtml::_(
'select.option', $template->element .
':' . $value, $text);
186 $attr = $this->element[
'size'] ?
' size="' . (int) $this->element[
'size'] .
'"' :
'';
192 $selected = array($this->value);
196 'select.groupedlist', $groups, $this->name,
197 array(
'id' => $this->
id,
'group.id' =>
'id',
'list.attr' => $attr,
'list.select' => $selected)
200 return implode($html);