protected function getOptions() { MLog::add('MFormFieldEditors is deprecated. Use MFormFieldPlugins instead (with folder="editors").', MLog::WARNING, 'deprecated'); // Get the database object and a new query object. $db = MFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->quote('editors')); $query->where('enabled = 1'); $query->order('ordering, name'); // Set the query and load the options. $db->setQuery($query); $options = $db->loadObjectList(); $lang = MFactory::getLanguage(); foreach ($options as $i => $option) { $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, null, false, false) || $lang->load('plg_editors_' . $option->value, MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load('plg_editors_' . $option->value, MPATH_PLUGINS . '/editors/' . $option->value, $lang->getDefault(), false, false); $options[$i]->text = MText::_($option->text); } // Check for a database error. if ($db->getErrorNum()) { MError::raiseWarning(500, $db->getErrorMsg()); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialise variables $folder = $this->element['folder']; if (!empty($folder)) { // Get list of plugins $db = MFactory::getDbo(); $query = $db->getQuery(true); $query->select('element AS value, name AS text'); $query->from('#__extensions'); $query->where('folder = ' . $db->q($folder)); $query->where('enabled = 1'); $query->order('ordering, name'); $db->setQuery($query); $options = $db->loadObjectList(); $lang = MFactory::getLanguage(); foreach ($options as $i => $item) { $source = MPATH_PLUGINS . '/' . $folder . '/' . $item->value; $extension = 'plg_' . $folder . '_' . $item->value; $lang->load($extension . '.sys', MPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false); $options[$i]->text = MText::_($item->text); } if ($db->getErrorMsg()) { MError::raiseWarning(500, MText::_('MFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); return ''; } } else { MError::raiseWarning(500, MText::_('MFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
public function loadLanguage($extension = '', $basePath = MPATH_ADMINISTRATOR) { if (empty($extension)) { $extension = 'plg_' . $this->_type . '_' . $this->_name; } $lang = MFactory::getLanguage(); return $lang->load(strtolower($extension), $basePath, null, false, true) || $lang->load(strtolower($extension), MPATH_PLUGINS . '/' . $extension, null, false, true); }
public static function stringURLSafe($string) { // Remove any '-' from the string since they will be used as concatenaters $str = str_replace('-', ' ', $string); $lang = MFactory::getLanguage(); $str = $lang->transliterate($str); // Trim white spaces at beginning and end of alias and make lowercase $str = trim(MString::strtolower($str)); // Remove any duplicate whitespace, and ensure all characters are alphanumeric $str = preg_replace('/(\\s|[^A-Za-z0-9\\-])+/', '-', $str); // Trim dashes at beginning and end of alias $str = trim($str, '-'); return $str; }
public static function renderComponent($option, $params = array()) { $app = MFactory::getApplication(); $lang = MFactory::getLanguage(); if (empty($option)) { throw new Exception(MText::_('MLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404); } // Record the scope $scope = $app->scope; // Set scope to component name $app->scope = $option; // Build the component path. $option = preg_replace('/[^A-Z0-9_\\.-]/i', '', $option); $file = substr($option, 4); // Define component path. define('MPATH_COMPONENT_SITE', MPATH_WP_PLG . '/' . $file . '/site'); define('MPATH_COMPONENT_ADMINISTRATOR', MPATH_WP_PLG . '/' . $file . '/admin'); if (MFactory::getApplication()->isAdmin()) { define('MPATH_COMPONENT', MPATH_COMPONENT_ADMINISTRATOR); } else { define('MPATH_COMPONENT', MPATH_COMPONENT_SITE); } $path = MPATH_COMPONENT . '/' . $file . '.php'; // If component is disabled throw error if (!self::isEnabled($option) || !file_exists($path)) { throw new Exception(MText::_('MLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404); } // Load common and local language files. $lang->load($option, MPATH_COMPONENT, null, false, true); // Handle template preview outlining. $contents = null; // Execute the component. $contents = self::executeComponent($path); // Revert the scope $app->scope = $scope; return $contents; }
public function loadTemplate($tpl = null) { // Clear prior output $this->_output = null; $template = MFactory::getApplication()->getTemplate(); $layout = $this->getLayout(); $layoutTemplate = $this->getLayoutTemplate(); // Create the template file name based on the layout $file = isset($tpl) ? $layout . '_' . $tpl : $layout; // Clean the file name $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file); $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl; // Load the language file for the template $lang = MFactory::getLanguage(); $lang->load('tpl_' . $template, MPATH_BASE, null, false, true) || $lang->load('tpl_' . $template, MPATH_THEMES . "/{$template}", null, false, true); // Change the template folder if alternative layout is in different template if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) { $this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']); } // Load the template script mimport('framework.filesystem.path'); $filetofind = $this->_createFileName('template', array('name' => $file)); $this->_template = MPath::find($this->_path['template'], $filetofind); // If alternate layout can't be found, fall back to default layout if ($this->_template == false) { $filetofind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl))); $this->_template = MPath::find($this->_path['template'], $filetofind); } if ($this->_template != false) { // Unset so as not to introduce into template scope unset($tpl); unset($file); // Never allow a 'this' property if (isset($this->this)) { unset($this->this); } // Start capturing output into a buffer ob_start(); // Include the requested template filename in the local scope // (this will execute the view logic). include $this->_template; // Done with the requested template; get the buffer and // clear it. $this->_output = ob_get_contents(); ob_end_clean(); return $this->_output; } else { return MError::raiseError(500, MText::sprintf('MLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file)); } }
protected function loadField($element, $group = null, $value = null) { // Make sure there is a valid SimpleXMLElement. if (!$element instanceof SimpleXMLElement) { return false; } // Get the field type. $type = $element['type'] ? (string) $element['type'] : 'text'; // Load the MFormField object for the field. $field = $this->loadFieldType($type); // If the object could not be loaded, get a text field object. if ($field === false) { $field = $this->loadFieldType('text'); } // Get the value for the form field if not set. // Default to the translated version of the 'default' attribute // if 'translate_default' attribute if set to 'true' or '1' // else the value of the 'default' attribute for the field. if ($value === null) { $default = (string) $element['default']; if (($translate = $element['translate_default']) && ((string) $translate == 'true' || (string) $translate == '1')) { $lang = MFactory::getLanguage(); if ($lang->hasKey($default)) { $debug = $lang->setDebug(false); $default = MText::_($default); $lang->setDebug($debug); } else { $default = MText::_($default); } } $value = $this->getValue((string) $element['name'], $group, $default); } // Setup the MFormField object. $field->setForm($this); if ($field->setup($element, $value, $group)) { return $field; } else { return false; } }
public function menu() { MFactory::getLanguage()->load('com_' . $this->context, MPATH_ADMINISTRATOR); $title = $this->title; if (empty($this->title)) { $title = MText::_('COM_' . strtoupper($this->context)); } mimport('framework.filesystem.file'); $img = ''; if (MFile::exists(MPATH_WP_PLG . '/' . $this->context . '/admin/assets/images/icon-16-' . $this->context . '.png')) { $img = plugins_url($this->context . '/admin/assets/images/icon-16-' . $this->context . '.png'); } add_menu_page($title, $title, 'manage_options', $this->context, array($this, 'display'), $img, $this->menu_id); if ($this->has_config == true) { add_submenu_page($this->context, MText::_('COM_' . strtoupper($this->context) . '_CPANEL_CONFIGURATION'), MText::_('COM_' . strtoupper($this->context) . '_CPANEL_CONFIGURATION'), 'manage_options', MRoute::_('index.php?option=com_' . $this->context . '&view=config')); } $toolbar_file = MPATH_WP_PLG . '/' . $this->context . '/admin/toolbar.php'; if (file_exists($toolbar_file)) { require_once $toolbar_file; } if (!empty($views)) { foreach ($views as $key => $val) { if (empty($key)) { continue; } add_submenu_page($this->context, $val, $val, 'manage_options', MRoute::_('index.php?option=com_' . $this->context . $key)); } } }
protected function getInput() { // Get the client id. $clientId = $this->element['client_id']; if (is_null($clientId) && $this->form instanceof MForm) { $clientId = $this->form->getValue('client_id'); } $clientId = (int) $clientId; $client = MApplicationHelper::getClientInfo($clientId); // Get the module. $module = (string) $this->element['module']; if (empty($module) && $this->form instanceof MForm) { $module = $this->form->getValue('module'); } $module = preg_replace('#\\W#', '', $module); // Get the template. $template = (string) $this->element['template']; $template = preg_replace('#\\W#', '', $template); // Get the style. if ($this->form instanceof MForm) { $template_style_id = $this->form->getValue('template_style_id'); } $template_style_id = preg_replace('#\\W#', '', $template_style_id); // If an extension and view are present build the options. if ($module && $client) { // Load language file $lang = MFactory::getLanguage(); $lang->load($module . '.sys', $client->path, null, false, false) || $lang->load($module . '.sys', $client->path . '/modules/' . $module, null, false, false) || $lang->load($module . '.sys', $client->path, $lang->getDefault(), false, false) || $lang->load($module . '.sys', $client->path . '/modules/' . $module, $lang->getDefault(), false, false); // Get the database object and a new query object. $db = MFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('element, name'); $query->from('#__extensions as e'); $query->where('e.client_id = ' . (int) $clientId); $query->where('e.type = ' . $db->quote('template')); $query->where('e.enabled = 1'); if ($template) { $query->where('e.element = ' . $db->quote($template)); } if ($template_style_id) { $query->join('LEFT', '#__template_styles as s on s.template=e.element'); $query->where('s.id=' . (int) $template_style_id); } // Set the query and load the templates. $db->setQuery($query); $templates = $db->loadObjectList('element'); // Check for a database error. if ($db->getErrorNum()) { MError::raiseWarning(500, $db->getErrorMsg()); } // Build the search paths for module layouts. $module_path = MPath::clean($client->path . '/modules/' . $module . '/tmpl'); // Prepare array of component layouts $module_layouts = array(); // Prepare the grouped list $groups = array(); // Add the layout options from the module path. if (is_dir($module_path) && ($module_layouts = MFolder::files($module_path, '^[^_]*\\.php$'))) { // Create the group for the module $groups['_'] = array(); $groups['_']['id'] = $this->id . '__'; $groups['_']['text'] = MText::sprintf('MOPTION_FROM_MODULE'); $groups['_']['items'] = array(); foreach ($module_layouts as $file) { // Add an option to the module group $value = MFile::stripExt($file); $text = $lang->hasKey($key = strtoupper($module . '_LAYOUT_' . $value)) ? MText::_($key) : $value; $groups['_']['items'][] = MHtml::_('select.option', '_:' . $value, $text); } } // Loop on all templates if ($templates) { foreach ($templates as $template) { // Load language file $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false); $template_path = MPath::clean($client->path . '/templates/' . $template->element . '/html/' . $module); // Add the layout options from the template path. if (is_dir($template_path) && ($files = MFolder::files($template_path, '^[^_]*\\.php$'))) { foreach ($files as $i => $file) { // Remove layout that already exist in component ones if (in_array($file, $module_layouts)) { unset($files[$i]); } } if (count($files)) { // Create the group for the template $groups[$template->element] = array(); $groups[$template->element]['id'] = $this->id . '_' . $template->element; $groups[$template->element]['text'] = MText::sprintf('MOPTION_FROM_TEMPLATE', $template->name); $groups[$template->element]['items'] = array(); foreach ($files as $file) { // Add an option to the template group $value = MFile::stripExt($file); $text = $lang->hasKey($key = strtoupper('TPL_' . $template->element . '_' . $module . '_LAYOUT_' . $value)) ? MText::_($key) : $value; $groups[$template->element]['items'][] = MHtml::_('select.option', $template->element . ':' . $value, $text); } } } } } // Compute attributes for the grouped list $attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; // Prepare HTML code $html = array(); // Compute the current selected values $selected = array($this->value); // Add a grouped list $html[] = MHtml::_('select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected)); return implode($html); } else { return ''; } }
protected function _fetchTemplate($params = array()) { // Check $directory = isset($params['directory']) ? $params['directory'] : 'templates'; $filter = MFilterInput::getInstance(); $template = $filter->clean($params['template'], 'cmd'); $file = $filter->clean($params['file'], 'cmd'); if (!file_exists($directory . '/' . $template . '/' . $file)) { $template = 'system'; } // Load the language file for the template $lang = MFactory::getLanguage(); // 1.5 or core then 1.6 $lang->load('tpl_' . $template, MPATH_BASE, null, false, false) || $lang->load('tpl_' . $template, $directory . '/' . $template, null, false, false) || $lang->load('tpl_' . $template, MPATH_BASE, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template, $directory . '/' . $template, $lang->getDefault(), false, false); // Assign the variables $this->template = $template; $this->baseurl = MUri::base(true); $this->params = isset($params['params']) ? $params['params'] : new MRegistry(); // Load $this->_template = $this->_loadTemplate($directory . '/' . $template, $file); return $this; }
protected function getInput() { // Initialize variables. // Get the client id. $clientId = $this->element['client_id']; if (is_null($clientId) && $this->form instanceof MForm) { $clientId = $this->form->getValue('client_id'); } $clientId = (int) $clientId; $client = MApplicationHelper::getClientInfo($clientId); // Get the extension. $extn = (string) $this->element['extension']; if (empty($extn) && $this->form instanceof MForm) { $extn = $this->form->getValue('extension'); } $extn = preg_replace('#\\W#', '', $extn); // Get the template. $template = (string) $this->element['template']; $template = preg_replace('#\\W#', '', $template); // Get the style. if ($this->form instanceof MForm) { $template_style_id = $this->form->getValue('template_style_id'); } $template_style_id = preg_replace('#\\W#', '', $template_style_id); // Get the view. $view = (string) $this->element['view']; $view = preg_replace('#\\W#', '', $view); // If a template, extension and view are present build the options. if ($extn && $view && $client) { // Load language file $lang = MFactory::getLanguage(); $lang->load($extn . '.sys', MPATH_ADMINISTRATOR, null, false, false) || $lang->load($extn . '.sys', MPATH_ADMINISTRATOR . '/components/' . $extn, null, false, false) || $lang->load($extn . '.sys', MPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extn . '.sys', MPATH_ADMINISTRATOR . '/components/' . $extn, $lang->getDefault(), false, false); // Get the database object and a new query object. $db = MFactory::getDBO(); $query = $db->getQuery(true); // Build the query. $query->select('e.element, e.name'); $query->from('#__extensions as e'); $query->where('e.client_id = ' . (int) $clientId); $query->where('e.type = ' . $db->quote('template')); $query->where('e.enabled = 1'); if ($template) { $query->where('e.element = ' . $db->quote($template)); } if ($template_style_id) { $query->join('LEFT', '#__template_styles as s on s.template=e.element'); $query->where('s.id=' . (int) $template_style_id); } // Set the query and load the templates. $db->setQuery($query); $templates = $db->loadObjectList('element'); // Check for a database error. if ($db->getErrorNum()) { MError::raiseWarning(500, $db->getErrorMsg()); } // Build the search paths for component layouts. $component_path = MPath::clean($client->path . '/components/' . $extn . '/views/' . $view . '/tmpl'); // Prepare array of component layouts $component_layouts = array(); // Prepare the grouped list $groups = array(); // Add a Use Global option if useglobal="true" in XML file if ($this->element['useglobal'] == 'true') { $groups[MText::_('MOPTION_FROM_STANDARD')]['items'][] = MHtml::_('select.option', '', MText::_('MGLOBAL_USE_GLOBAL')); } // Add the layout options from the component path. if (is_dir($component_path) && ($component_layouts = MFolder::files($component_path, '^[^_]*\\.xml$', false, true))) { // Create the group for the component $groups['_'] = array(); $groups['_']['id'] = $this->id . '__'; $groups['_']['text'] = MText::sprintf('MOPTION_FROM_COMPONENT'); $groups['_']['items'] = array(); foreach ($component_layouts as $i => $file) { // Attempt to load the XML file. if (!($xml = simplexml_load_file($file))) { unset($component_layouts[$i]); continue; } // Get the help data from the XML file if present. if (!($menu = $xml->xpath('layout[1]'))) { unset($component_layouts[$i]); continue; } $menu = $menu[0]; // Add an option to the component group $value = MFile::stripext(MFile::getName($file)); $component_layouts[$i] = $value; $text = isset($menu['option']) ? MText::_($menu['option']) : (isset($menu['title']) ? MText::_($menu['title']) : $value); $groups['_']['items'][] = MHtml::_('select.option', '_:' . $value, $text); } } // Loop on all templates if ($templates) { foreach ($templates as $template) { // Load language file $lang->load('tpl_' . $template->element . '.sys', $client->path, null, false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, null, false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path, $lang->getDefault(), false, false) || $lang->load('tpl_' . $template->element . '.sys', $client->path . '/templates/' . $template->element, $lang->getDefault(), false, false); $template_path = MPath::clean($client->path . '/templates/' . $template->element . '/html/' . $extn . '/' . $view); // Add the layout options from the template path. if (is_dir($template_path) && ($files = MFolder::files($template_path, '^[^_]*\\.php$', false, true))) { // Files with corresponding XML files are alternate menu items, not alternate layout files // so we need to exclude these files from the list. $xml_files = MFolder::files($template_path, '^[^_]*\\.xml$', false, true); for ($j = 0, $count = count($xml_files); $j < $count; $j++) { $xml_files[$j] = MFile::stripext(MFile::getName($xml_files[$j])); } foreach ($files as $i => $file) { // Remove layout files that exist in the component folder or that have XML files if (in_array(MFile::stripext(MFile::getName($file)), $component_layouts) || in_array(MFile::stripext(MFile::getName($file)), $xml_files)) { unset($files[$i]); } } if (count($files)) { // Create the group for the template $groups[$template->name] = array(); $groups[$template->name]['id'] = $this->id . '_' . $template->element; $groups[$template->name]['text'] = MText::sprintf('MOPTION_FROM_TEMPLATE', $template->name); $groups[$template->name]['items'] = array(); foreach ($files as $file) { // Add an option to the template group $value = MFile::stripext(MFile::getName($file)); $text = $lang->hasKey($key = strtoupper('TPL_' . $template->name . '_' . $extn . '_' . $view . '_LAYOUT_' . $value)) ? MText::_($key) : $value; $groups[$template->name]['items'][] = MHtml::_('select.option', $template->element . ':' . $value, $text); } } } } } // Compute attributes for the grouped list $attr = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; // Prepare HTML code $html = array(); // Compute the current selected values $selected = array($this->value); // Add a grouped list $html[] = MHtml::_('select.groupedlist', $groups, $this->name, array('id' => $this->id, 'group.id' => 'id', 'list.attr' => $attr, 'list.select' => $selected)); return implode($html); } else { return ''; } }
public static function renderModule($module, $attribs = array()) { static $chrome; if (constant('MDEBUG')) { MProfiler::getInstance('Application')->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')'); } $app = MFactory::getApplication(); // Record the scope. $scope = $app->scope; // Set scope to component name $app->scope = $module->module; // Get module parameters $params = new MRegistry(); $params->loadString($module->params); // Get module path $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module); $path = MPATH_MODULES . '/' . $module->module . '/' . $module->module . '.php'; // Load the module // $module->user is a check for 1.0 custom modules and is deprecated refactoring if (empty($module->user) && file_exists($path)) { $lang = MFactory::getLanguage(); // 1.5 or Core then 1.6 3PD $lang->load($module->module, MPATH_BASE, null, false, true) || $lang->load($module->module, dirname($path), null, false, true); $content = ''; ob_start(); include $path; $module->content = ob_get_contents() . $content; ob_end_clean(); } // Load the module chrome functions if (!$chrome) { $chrome = array(); } include_once MPATH_MODULES . '/modules.php'; $chromePath = MPATH_THEMES . '/' . $app->getTemplate() . '/html/modules.php'; if (!isset($chrome[$chromePath])) { if (file_exists($chromePath)) { include_once $chromePath; } $chrome[$chromePath] = true; } // Make sure a style is set if (!isset($attribs['style'])) { $attribs['style'] = 'none'; } foreach (explode(' ', $attribs['style']) as $style) { $chromeMethod = 'modChrome_' . $style; // Apply chrome and render module if (function_exists($chromeMethod)) { $module->style = $attribs['style']; ob_start(); $chromeMethod($module, $params, $attribs); $module->content = ob_get_contents(); ob_end_clean(); } } //revert the scope $app->scope = $scope; if (constant('MDEBUG')) { MProfiler::getInstance('Application')->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')'); } return $module->content; }
public static function script($string = null, $jsSafe = false, $interpretBackSlashes = true) { if (is_array($jsSafe)) { if (array_key_exists('interpretBackSlashes', $jsSafe)) { $interpretBackSlashes = (bool) $jsSafe['interpretBackSlashes']; } if (array_key_exists('jsSafe', $jsSafe)) { $jsSafe = (bool) $jsSafe['jsSafe']; } else { $jsSafe = false; } } if ($string !== null) { self::$strings[strtoupper($string)] = MFactory::getLanguage()->_($string, $jsSafe, $interpretBackSlashes); } return self::$strings; }
public static function calendar() { // Only load once if (isset(self::$loaded[__METHOD__])) { return; } $document = MFactory::getDocument(); $tag = MFactory::getLanguage()->getTag(); MHtml::_('stylesheet', 'system/calendar-jos.css', array(' title' => MText::_('MLIB_HTML_BEHAVIOR_GREEN'), ' media' => 'all'), true); MHtml::_('script', $tag . '/calendar.js', false, true); MHtml::_('script', $tag . '/calendar-setup.js', false, true); $translation = self::calendartranslation(); if ($translation) { $document->addScriptDeclaration($translation); } self::$loaded[__METHOD__] = true; }
public static function calendar($value, $name, $id, $format = 'Y-m-d', $attribs = null) { static $done; if ($done === null) { $done = array(); } $readonly = isset($attribs['readonly']) && $attribs['readonly'] == 'readonly'; $disabled = isset($attribs['disabled']) && $attribs['disabled'] == 'disabled'; if (is_array($attribs)) { $attribs = MArrayHelper::toString($attribs); } if (!$readonly && !$disabled) { // Load the calendar behavior self::_('behavior.calendar'); self::_('behavior.tooltip'); // Only display the triggers once for each control. if (!in_array($id, $done)) { $document = MFactory::getDocument(); $document->addScriptDeclaration('jQuery(document).ready(function () { Calendar.setup({ // Id of the input field inputField: "' . $id . '", // Format of the input field ifFormat: "' . $format . '", // Trigger for the calendar (button ID) button: "' . $id . '_img", // Alignment (defaults to "Bl") align: "Tl", singleClick: true, firstDay: ' . MFactory::getLanguage()->getFirstDay() . ' }); });'); $done[] = $id; } return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '') . '" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" ' . $attribs . ' />' . self::_('image', 'system/calendar.png', MText::_('MLIB_HTML_CALENDAR'), array('class' => 'calendar', 'id' => $id . '_img'), true); } else { return '<input type="text" title="' . (0 !== (int) $value ? self::_('date', $value, null, null) : '') . '" value="' . (0 !== (int) $value ? self::_('date', $value, 'Y-m-d H:i:s', null) : '') . '" ' . $attribs . ' /><input type="hidden" name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '" />'; } }