function display($tpl = null) { $mainframe = MFactory::getApplication(); $option = MRequest::getCmd('option'); $document = MFactory::getDocument(); $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css'); MToolBarHelper::title(MText::_('MiwoSQL') . ' - ' . MText::_('COM_MIWOSQL_SAVED_QUERIES'), 'miwosql'); MToolBarHelper::editList(); MToolBarHelper::deleteList(); // ACL if (version_compare(MVERSION, '1.6.0', 'ge') && MFactory::getUser()->authorise('core.admin', 'com_miwosql')) { MToolBarHelper::divider(); MToolBarHelper::preferences('com_miwosql', '550'); } $this->mainframe = MFactory::getApplication(); $this->option = MRequest::getWord('option'); $filter_order = $mainframe->getUserStateFromRequest($option . '.queries.filter_order', 'filter_order', 'title', 'string'); $filter_order_Dir = $mainframe->getUserStateFromRequest($option . '.queries.filter_order_Dir', 'filter_order_Dir', '', 'word'); $search = $mainframe->getUserStateFromRequest($option . '.queries.search', 'search', '', 'string'); // table ordering $lists['order_Dir'] = $filter_order_Dir; $lists['order'] = $filter_order; // search filter $lists['search'] = $search; $this->lists = $lists; $this->items = $this->get('Data'); $this->pagination = $this->get('Pagination'); parent::display($tpl); }
public function display($tpl = null) { $document = MFactory::getDocument(); $document->addStyleSheet(MURL_MIWOSQL . '/admin/assets/css/miwosql.css'); // Toolbar MToolBarHelper::title(MText::_('MiwoSQL') . ' - ' . MText::_('COM_MIWOSQL_RUN_QUERY'), 'miwosql'); if (MiwosqlHelper::is30()) { MToolBarHelper::custom('run', 'play.png', 'play.png', MText::_('COM_MIWOSQL_RUN_QUERY'), false); MToolBarHelper::divider(); MToolBarHelper::custom('savequery', 'folder-close.png', 'folder-close.png', MText::_('COM_MIWOSQL_SAVE_QUERY'), false); MToolBarHelper::divider(); MToolBarHelper::custom('csv', 'upload.png', 'upload.png', MText::_('COM_MIWOSQL_EXPORT_CSV'), false); } else { MToolBarHelper::custom('run', 'run.png', 'run.png', MText::_('COM_MIWOSQL_RUN_QUERY'), false); MToolBarHelper::divider(); MToolBarHelper::custom('savequery', 'savequery.png', 'savequery.png', MText::_('COM_MIWOSQL_SAVE_QUERY'), false); MToolBarHelper::divider(); MToolBarHelper::custom('csv', 'csv.png', 'csv.png', MText::_('COM_MIWOSQL_EXPORT_CSV'), false); } // ACL if (version_compare(MVERSION, '1.6.0', 'ge') && MFactory::getUser()->authorise('core.admin', 'com_miwosql')) { MToolBarHelper::divider(); MToolBarHelper::preferences('com_miwosql', '550'); } $this->data = $this->get('Data'); $this->tables = $this->get('Tables'); $this->prefix = $this->get('Prefix'); parent::display($tpl); }
protected function getInput() { // Initialize some field attributes. $format = $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d'; // Build the attributes array. $attributes = array(); if ($this->element['size']) { $attributes['size'] = (int) $this->element['size']; } if ($this->element['maxlength']) { $attributes['maxlength'] = (int) $this->element['maxlength']; } if ($this->element['class']) { $attributes['class'] = (string) $this->element['class']; } if ((string) $this->element['readonly'] == 'true') { $attributes['readonly'] = 'readonly'; } if ((string) $this->element['disabled'] == 'true') { $attributes['disabled'] = 'disabled'; } if ($this->element['onchange']) { $attributes['onchange'] = (string) $this->element['onchange']; } // Handle the special case for "now". if (strtoupper($this->value) == 'NOW') { $this->value = strftime($format); } // Get some system objects. $config = MFactory::getConfig(); $user = MFactory::getUser(); // If a known filter is given use it. switch (strtoupper((string) $this->element['filter'])) { case 'SERVER_UTC': // Convert a date to UTC based on the server timezone. if (intval($this->value)) { // Get a date object based on the correct timezone. $date = MFactory::getDate($this->value, 'UTC'); $date->setTimezone(new DateTimeZone($config->get('offset'))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; case 'USER_UTC': // Convert a date to UTC based on the user timezone. if (intval($this->value)) { // Get a date object based on the correct timezone. $date = MFactory::getDate($this->value, 'UTC'); $date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset')))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; } return MHtml::_('calendar', $this->value, $this->name, $this->id, $format, $attributes); }
protected function getOptions() { // Initialise variables. $options = array(); $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope']; $published = (string) $this->element['published']; $name = (string) $this->element['name']; // Load the category options for a given extension. if (!empty($extension)) { // Filter over published state or not depending upon if it is present. if ($published) { $options = MHtml::_('category.options', $extension, array('filter.published' => explode(',', $published))); } else { $options = MHtml::_('category.options', $extension); } // Verify permissions. If the action attribute is set, then we scan the options. if ((string) $this->element['action']) { // Get the current user object. $user = MFactory::getUser(); // For new items we want a list of categories you are allowed to create in. if (!$this->form->getValue($name)) { foreach ($options as $i => $option) { // To take save or create in a category you need to have create rights for that category // unless the item is already in that category. // Unset the option if the user isn't authorised for it. In this field assets are always categories. if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true) { unset($options[$i]); } } } else { $categoryOld = $this->form->getValue($name); foreach ($options as $i => $option) { // If you are only allowed to edit in this category but not edit.state, you should not get any // option to change the category. if ($user->authorise('core.edit.state', $extension . '.category.' . $categoryOld) != true) { if ($option->value != $categoryOld) { unset($options[$i]); } } elseif ($user->authorise('core.create', $extension . '.category.' . $option->value) != true && $option->value != $categoryOld) { unset($options[$i]); } } } } if (isset($this->element['show_root'])) { array_unshift($options, MHtml::_('select.option', '0', MText::_('MGLOBAL_ROOT'))); } } else { MError::raiseWarning(500, MText::_('MLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
public static function published($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb', $publish_up = null, $publish_down = null) { if (is_array($prefix)) { $options = $prefix; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } $states = array(1 => array('unpublish', 'MPUBLISHED', 'MLIB_HTML_UNPUBLISH_ITEM', 'MPUBLISHED', false, 'publish', 'publish'), 0 => array('publish', 'MUNPUBLISHED', 'MLIB_HTML_PUBLISH_ITEM', 'MUNPUBLISHED', false, 'unpublish', 'unpublish'), 2 => array('unpublish', 'MARCHIVED', 'MLIB_HTML_UNPUBLISH_ITEM', 'MARCHIVED', false, 'archive', 'archive'), -2 => array('publish', 'MTRASHED', 'MLIB_HTML_PUBLISH_ITEM', 'MTRASHED', false, 'trash', 'trash')); // Special state for dates if ($publish_up || $publish_down) { $nullDate = MFactory::getDBO()->getNullDate(); $nowDate = MFactory::getDate()->toUnix(); $tz = new DateTimeZone(MFactory::getUser()->getParam('timezone', MFactory::getConfig()->get('offset'))); $publish_up = $publish_up != $nullDate ? MFactory::getDate($publish_up, 'UTC')->setTimeZone($tz) : false; $publish_down = $publish_down != $nullDate ? MFactory::getDate($publish_down, 'UTC')->setTimeZone($tz) : false; // Create tip text, only we have publish up or down settings $tips = array(); if ($publish_up) { $tips[] = MText::sprintf('MLIB_HTML_PUBLISHED_START', $publish_up->format(MDate::$format, true)); } if ($publish_down) { $tips[] = MText::sprintf('MLIB_HTML_PUBLISHED_FINISHED', $publish_down->format(MDate::$format, true)); } $tip = empty($tips) ? false : implode('<br/>', $tips); // Add tips and special titles foreach ($states as $key => $state) { // Create special titles for published items if ($key == 1) { $states[$key][2] = $states[$key][3] = 'MLIB_HTML_PUBLISHED_ITEM'; if ($publish_up > $nullDate && $nowDate < $publish_up->toUnix()) { $states[$key][2] = $states[$key][3] = 'MLIB_HTML_PUBLISHED_PENDING_ITEM'; $states[$key][5] = $states[$key][6] = 'pending'; } if ($publish_down > $nullDate && $nowDate > $publish_down->toUnix()) { $states[$key][2] = $states[$key][3] = 'MLIB_HTML_PUBLISHED_EXPIRED_ITEM'; $states[$key][5] = $states[$key][6] = 'expired'; } } // Add tips to titles if ($tip) { $states[$key][1] = MText::_($states[$key][1]); $states[$key][2] = MText::_($states[$key][2]) . '::' . $tip; $states[$key][3] = MText::_($states[$key][3]) . '::' . $tip; $states[$key][4] = true; } } return self::state($states, $value, $i, array('prefix' => $prefix, 'translate' => !$tip), $enabled, true, $checkbox); } return self::state($states, $value, $i, $prefix, $enabled, true, $checkbox); }
public static function usergroups($name, $selected, $checkSuperAdmin = false) { static $count; $count++; $isSuperAdmin = MFactory::getUser()->authorise('core.admin'); $db = MFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.*, COUNT(DISTINCT b.id) AS level'); $query->from($db->quoteName('#__usergroups') . ' AS a'); $query->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt'); $query->group('a.id, a.title, a.lft, a.rgt, a.parent_id'); $query->order('a.lft ASC'); $db->setQuery($query); $groups = $db->loadObjectList(); // Check for a database error. if ($db->getErrorNum()) { MError::raiseNotice(500, $db->getErrorMsg()); return null; } $html = array(); $html[] = '<ul class="checklist usergroups">'; for ($i = 0, $n = count($groups); $i < $n; $i++) { $item =& $groups[$i]; // If checkSuperAdmin is true, only add item if the user is superadmin or the group is not super admin if (!$checkSuperAdmin || $isSuperAdmin || !MAccess::checkGroup($item->id, 'core.admin')) { // Setup the variable attributes. $eid = $count . 'group_' . $item->id; // Don't call in_array unless something is selected $checked = ''; if ($selected) { $checked = in_array($item->id, $selected) ? ' checked="checked"' : ''; } $rel = $item->parent_id > 0 ? ' rel="' . $count . 'group_' . $item->parent_id . '"' : ''; // Build the HTML for the item. $html[] = ' <li>'; $html[] = ' <input type="checkbox" name="' . $name . '[]" value="' . $item->id . '" id="' . $eid . '"'; $html[] = ' ' . $checked . $rel . ' />'; $html[] = ' <label for="' . $eid . '">'; $html[] = ' ' . str_repeat('<span class="gi">|—</span>', $item->level) . $item->title; $html[] = ' </label>'; $html[] = ' </li>'; } } $html[] = '</ul>'; return implode("\n", $html); }
public static function checkedOut(&$row, $i, $identifier = 'id') { $user = MFactory::getUser(); $userid = $user->get('id'); $result = false; if ($row instanceof MTable) { $result = $row->isCheckedOut($userid); } else { $result = MTable::isCheckedOut($userid, $row->checked_out); } $checked = ''; if ($result) { $checked = MHtmlGrid::_checkedOut($row); } else { if ($identifier == 'id') { $checked = MHtml::_('grid.id', $i, $row->{$identifier}); } else { $checked = MHtml::_('grid.id', $i, $row->{$identifier}, $result, $identifier); } } return $checked; }
public function checkout($pk = null) { // Only attempt to check the row in if it exists. if ($pk) { $user = MFactory::getUser(); // Get an instance of the row to checkout. $table = $this->getTable(); if (!$table->load($pk)) { $this->setError($table->getError()); return false; } // Check if this is the user having previously checked out the row. if ($table->checked_out > 0 && $table->checked_out != $user->get('id')) { $this->setError(MText::_('MLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH')); return false; } // Attempt to check the row out. if (!$table->checkout($user->get('id'), $pk)) { $this->setError($table->getError()); return false; } } return true; }
public function logout($userid = null, $options = array()) { // Get a user object from the MApplication. $user = MFactory::getUser($userid); // Build the credentials array. $parameters['username'] = $user->get('username'); $parameters['id'] = $user->get('id'); // Set clientid in the options array if it hasn't been set already. if (!isset($options['clientid'])) { $options['clientid'] = $this->getClientId(); } // Import the user plugin group. MPluginHelper::importPlugin('user'); // OK, the credentials are built. Lets fire the onLogout event. $results = $this->triggerEvent('onUserLogout', array($parameters, $options)); // Check if any of the plugins failed. If none did, success. if (!in_array(false, $results, true)) { // Use domain and path set in config for cookie if it exists. $cookie_domain = $this->getCfg('cookie_domain', ''); $cookie_path = $this->getCfg('cookie_path', '/'); setcookie(self::getHash('MLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain); return true; } // Trigger onUserLoginFailure Event. $this->triggerEvent('onUserLogoutFailure', array($parameters)); return false; }
public static function getFormToken($forceNew = false) { $user = MFactory::getUser(); $session = MFactory::getSession(); $hash = MApplication::getHash($user->get('id', 0) . $session->getToken($forceNew)); return $hash; }
public function authorise($id) { $menu = $this->getItem($id); $user = MFactory::getUser(); if ($menu) { return in_array((int) $menu->access, $user->getAuthorisedViewLevels()); } else { return true; } }
<?php /** * @package MiwoSQL * @copyright 2009-2012 Mijosoft LLC, www.mijosoft.com * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html */ // no direct access defined('MIWI') or die('Restricted access'); if (version_compare(MVERSION, '1.6.0', 'ge')) { if (!MFactory::getUser()->authorise('core.manage', 'com_miwosql')) { return MError::raiseWarning(404, MText::_('MERROR_ALERTNOAUTHOR')); } } require_once MPATH_COMPONENT . '/mvc/model.php'; require_once MPATH_COMPONENT . '/mvc/view.php'; require_once MPATH_COMPONENT . '/mvc/controller.php'; require_once MPATH_COMPONENT . '/toolbar.php'; require_once MPATH_COMPONENT . '/helpers/helper.php'; MTable::addIncludePath(MPATH_COMPONENT . '/tables'); if ($controller = MRequest::getWord('controller')) { $path = MPATH_COMPONENT . '/controllers/' . $controller . '.php'; if (file_exists($path)) { require_once $path; } else { $controller = ''; } } $classname = 'MiwosqlController' . ucfirst($controller); $controller = new $classname(); $controller->execute(MRequest::getCmd('task'));
public function authorise($task) { // Only do access check if the aco section is set if ($this->_acoSection) { // If we have a section value set that trumps the passed task. if ($this->_acoSectionValue) { // We have one, so set it and lets do the check $task = $this->_acoSectionValue; } // Get the MUser object for the current user and return the authorization boolean $user = MFactory::getUser(); return $user->authorise($this->_acoSection, $task); } else { // Nothing set, nothing to check... so obviously it's ok :) return true; } }
public function publish(&$pks, $value = 1) { $dispatcher = MEventDispatcher::getInstance(); $user = MFactory::getUser(); $table = $this->getTable(); $pks = (array) $pks; // Include the content plugins for the change of state event. MPluginHelper::importPlugin('content'); // Access checks. foreach ($pks as $i => $pk) { $table->reset(); if ($table->load($pk)) { if (!$this->canEditState($table)) { // Prune items that you can't change. unset($pks[$i]); MLog::add(MText::_('MLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), MLog::WARNING, 'merror'); return false; } } } // Attempt to change the state of the records. if (!$table->publish($pks, $value, $user->get('id'))) { $this->setError($table->getError()); return false; } $context = $this->option . '.' . $this->name; // Trigger the onContentChangeState event. $result = $dispatcher->trigger($this->event_change_state, array($context, $pks, $value)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } // Clear the component's cache $this->cleanCache(); return true; }
public function save($updateOnly = false) { // Allow an exception to be thrown. try { // If user is made a Super Admin group and user is NOT a Super Admin // // @todo ACL - this needs to be acl checked // $my = MFactory::getUser(); //are we creating a new user $isNew = empty($this->id); // If we aren't allowed to create new users return if ($isNew && $updateOnly) { return true; } // Get the old user $oldUser = new MUser($this->id); // Fire the onUserBeforeSave event. MPluginHelper::importPlugin('user'); $dispatcher = MDispatcher::getInstance(); $result = $dispatcher->trigger('onUserBeforeSave', array($oldUser->getProperties(), $isNew, $this->getProperties())); if (in_array(false, $result, true)) { // Plugin will have to raise its own error or throw an exception. return false; } ////////////////////////////////////// //todo:: update old user ////////////////////////////////////// register_new_user($this->username, $this->email); // Fire the onUserAfterSave event $dispatcher->trigger('onUserAfterSave', array($this->getProperties(), $isNew, $result, $this->getError())); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } return $result; }
protected function filterField($element, $value) { // Make sure there is a valid SimpleXMLElement. if (!$element instanceof SimpleXMLElement) { return false; } // Get the field filter type. $filter = (string) $element['filter']; // Process the input value based on the filter. $return = null; switch (strtoupper($filter)) { // Access Control Rules. case 'RULES': $return = array(); foreach ((array) $value as $action => $ids) { // Build the rules array. $return[$action] = array(); foreach ($ids as $id => $p) { if ($p !== '') { $return[$action][$id] = $p == '1' || $p == 'true' ? true : false; } } } break; // Do nothing, thus leaving the return value as null. // Do nothing, thus leaving the return value as null. case 'UNSET': break; // No Filter. // No Filter. case 'RAW': $return = $value; break; // Filter the input as an array of integers. // Filter the input as an array of integers. case 'INT_ARRAY': // Make sure the input is an array. if (is_object($value)) { $value = get_object_vars($value); } $value = is_array($value) ? $value : array($value); MArrayHelper::toInteger($value); $return = $value; break; // Filter safe HTML. // Filter safe HTML. case 'SAFEHTML': $return = MFilterInput::getInstance(null, null, 1, 1)->clean($value, 'string'); break; // Convert a date to UTC based on the server timezone offset. // Convert a date to UTC based on the server timezone offset. case 'SERVER_UTC': if (intval($value) > 0) { // Get the server timezone setting. $offset = MFactory::getConfig()->get('offset'); // Return an SQL formatted datetime string in UTC. $return = MFactory::getDate($value, $offset)->toSql(); } else { $return = ''; } break; // Convert a date to UTC based on the user timezone offset. // Convert a date to UTC based on the user timezone offset. case 'USER_UTC': if (intval($value) > 0) { // Get the user timezone setting defaulting to the server timezone setting. $offset = MFactory::getUser()->getParam('timezone', MFactory::getConfig()->get('offset')); // Return a MySQL formatted datetime string in UTC. $return = MFactory::getDate($value, $offset)->toSql(); } else { $return = ''; } break; // Ensures a protocol is present in the saved field. Only use when // the only permitted protocols requre '://'. See MFormRuleUrl for list of these. // Ensures a protocol is present in the saved field. Only use when // the only permitted protocols requre '://'. See MFormRuleUrl for list of these. case 'URL': if (empty($value)) { return false; } $value = MFilterInput::getInstance()->clean($value, 'html'); $value = trim($value); // <>" are never valid in a uri see http://www.ietf.org/rfc/rfc1738.txt. $value = str_replace(array('<', '>', '"'), '', $value); // Check for a protocol $protocol = parse_url($value, PHP_URL_SCHEME); // If there is no protocol and the relative option is not specified, // we assume that it is an external URL and prepend http://. if ($element['type'] == 'url' && !$protocol && !$element['relative'] || !$element['type'] == 'url' && !$protocol) { $protocol = 'http'; // If it looks like an internal link, then add the root. if (substr($value, 0) == 'index.php') { $value = MURI::root() . $value; } // Otherwise we treat it is an external link. // Put the url back together. $value = $protocol . '://' . $value; } elseif (!$protocol && $element['relative']) { $host = MURI::getInstance('SERVER')->gethost(); // If it starts with the host string, just prepend the protocol. if (substr($value, 0) == $host) { $value = 'http://' . $value; } else { $value = MURI::root() . $value; } } $return = $value; break; case 'TEL': $value = trim($value); // Does it match the NANP pattern? if (preg_match('/^(?:\\+?1[-. ]?)?\\(?([2-9][0-8][0-9])\\)?[-. ]?([2-9][0-9]{2})[-. ]?([0-9]{4})$/', $value) == 1) { $number = (string) preg_replace('/[^\\d]/', '', $value); if (substr($number, 0, 1) == 1) { $number = substr($number, 1); } if (substr($number, 0, 2) == '+1') { $number = substr($number, 2); } $result = '1.' . $number; } elseif (preg_match('/^\\+(?:[0-9] ?){6,14}[0-9]$/', $value) == 1) { $countrycode = substr($value, 0, strpos($value, ' ')); $countrycode = (string) preg_replace('/[^\\d]/', '', $countrycode); $number = strstr($value, ' '); $number = (string) preg_replace('/[^\\d]/', '', $number); $result = $countrycode . '.' . $number; } elseif (preg_match('/^\\+[0-9]{1,3}\\.[0-9]{4,14}(?:x.+)?$/', $value) == 1) { if (strstr($value, 'x')) { $xpos = strpos($value, 'x'); $value = substr($value, 0, $xpos); } $result = str_replace('+', '', $value); } elseif (preg_match('/[0-9]{1,3}\\.[0-9]{4,14}$/', $value) == 1) { $result = $value; } else { $value = (string) preg_replace('/[^\\d]/', '', $value); if ($value != null && strlen($value) <= 15) { $length = strlen($value); // if it is fewer than 13 digits assume it is a local number if ($length <= 12) { $result = '.' . $value; } else { // If it has 13 or more digits let's make a country code. $cclen = $length - 12; $result = substr($value, 0, $cclen) . '.' . substr($value, $cclen); } } else { $result = ''; } } $return = $result; break; default: // Check for a callback filter. if (strpos($filter, '::') !== false && is_callable(explode('::', $filter))) { $return = call_user_func(explode('::', $filter), $value); } elseif (function_exists($filter)) { $return = call_user_func($filter, $value); } else { $return = MFilterInput::getInstance()->clean($value, $filter); } break; } return $return; }
public static function date($input = 'now', $format = null, $tz = true, $gregorian = false) { // Get some system objects. if (!($offset = MFactory::getWOption('timezone_string'))) { $offset = self::getTimezoneString(); } $user = MFactory::getUser(); // UTC date converted to user time zone. if ($tz === true) { // Get a date object based on UTC. $date = MFactory::getDate($input, 'UTC'); // Set the correct time zone based on the user configuration. $date->setTimeZone(new DateTimeZone($user->getParam('timezone', $offset))); } elseif ($tz === false) { // Get a date object based on UTC. $date = MFactory::getDate($input, 'UTC'); // Set the correct time zone based on the server configuration. $date->setTimeZone(new DateTimeZone($offset)); } elseif ($tz === null) { $date = MFactory::getDate($input); } else { // Get a date object based on UTC. $date = MFactory::getDate($input, 'UTC'); // Set the correct time zone based on the server configuration. $date->setTimeZone(new DateTimeZone($tz)); } // If no format is given use the default locale based format. if (!$format) { $format = MText::_('DATE_FORMAT_LC1'); } elseif (MFactory::getLanguage()->hasKey($format)) { $format = MText::_($format); } if ($gregorian) { return $date->format($format, true); } else { return $date->calendar($format, true); } }