/**
  * Method to get the custom field options.
  * Use the query attribute to supply a query to generate the list.
  *
  * @return  array  The field option objects.
  *
  * @since   11.1
  */
 protected function getOptions()
 {
     $options = array();
     // Initialize some field attributes.
     $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value';
     $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name'];
     $translate = $this->element['translate'] ? (string) $this->element['translate'] : false;
     $query = (string) $this->element['query'];
     // Get the database object.
     $db = Factory::getDBO();
     // Set the query and get the result list.
     $db->setQuery($query);
     $items = $db->loadObjectlist();
     // Build the field options.
     if (!empty($items)) {
         foreach ($items as $item) {
             if ($translate == true) {
                 $options[] = Html::_('select.option', $item->{$key}, JText::_($item->{$value}));
             } else {
                 $options[] = Html::_('select.option', $item->{$key}, $item->{$value});
             }
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
 /**
  * Constructor.
  *
  * @param   array  &$options  Log object options.
  *
  * @since   11.1
  */
 public function __construct(array &$options)
 {
     // Call the parent constructor.
     parent::__construct($options);
     // The name of the text file defaults to 'error.php' if not explicitly given.
     if (empty($this->options['text_file'])) {
         $this->options['text_file'] = 'error.php';
     }
     // The name of the text file path defaults to that which is set in configuration if not explicitly given.
     if (empty($this->options['text_file_path'])) {
         $this->options['text_file_path'] = Factory::getConfig()->get('log_path');
     }
     // False to treat the log file as a php file.
     if (empty($this->options['text_file_no_php'])) {
         $this->options['text_file_no_php'] = false;
     }
     // Build the full path to the log file.
     $this->path = $this->options['text_file_path'] . '/' . $this->options['text_file'];
     // Use the default entry format unless explicitly set otherwise.
     if (!empty($this->options['text_entry_format'])) {
         $this->format = (string) $this->options['text_entry_format'];
     }
     // Build the fields array based on the format string.
     $this->parseFields();
 }
 /**
  * Constructor.
  *
  * @param   array  &$options  Log object options.
  *
  * @since   11.1
  */
 public function __construct(array &$options)
 {
     // Call the parent constructor.
     parent::__construct($options);
     // If both the database object and driver options are empty we want to use the system database connection.
     if (empty($this->options['db_driver'])) {
         $this->dbo = Factory::getDBO();
         $this->driver = null;
         $this->host = null;
         $this->user = null;
         $this->password = null;
         $this->database = null;
         $this->prefix = null;
     } else {
         $this->dbo = null;
         $this->driver = empty($this->options['db_driver']) ? 'mysqli' : $this->options['db_driver'];
         $this->host = empty($this->options['db_host']) ? '127.0.0.1' : $this->options['db_host'];
         $this->user = empty($this->options['db_user']) ? 'root' : $this->options['db_user'];
         $this->password = empty($this->options['db_pass']) ? '' : $this->options['db_pass'];
         $this->database = empty($this->options['db_database']) ? 'logging' : $this->options['db_database'];
         $this->prefix = empty($this->options['db_prefix']) ? 'jos_' : $this->options['db_prefix'];
     }
     // The table name is independent of how we arrived at the connection object.
     $this->table = empty($this->options['db_table']) ? '#__log_entries' : $this->options['db_table'];
 }
 /**
  * Class constructor
  *
  * @param   array  $options  Associative array of options
  *
  * @since  11.1
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
     // Set document type
     $this->_type = 'opensearch';
     // Set mime type
     $this->_mime = 'application/opensearchdescription+xml';
     // Add the URL for self updating
     $update = new Opensearch\Url();
     $update->type = 'application/opensearchdescription+xml';
     $update->rel = 'self';
     $update->template = Route::_(Uri::getInstance());
     $this->addUrl($update);
     // Add the favicon as the default image
     // Try to find a favicon by checking the template and root folder
     $app = Factory::getApplication();
     $dirs = array(JPATH_THEMES . '/' . $app->getTemplate(), JPATH_BASE);
     foreach ($dirs as $dir) {
         if (file_exists($dir . '/favicon.ico')) {
             $path = str_replace(JPATH_BASE . '/', '', $dir);
             $path = str_replace('\\', '/', $path);
             $favicon = new Opensearch\Image();
             $favicon->data = Uri::base() . $path . '/favicon.ico';
             $favicon->height = '16';
             $favicon->width = '16';
             $favicon->type = 'image/vnd.microsoft.icon';
             $this->addImage($favicon);
             break;
         }
     }
 }
 /**
  * Constructor.
  *
  * @param   Registry  $options      JOAuth2Client options object
  * @param   Http      $http         The HTTP client object
  * @param   Input     $input        The input object
  * @param   Web       $application  The application object
  *
  * @since   12.3
  */
 public function __construct(Registry $options = null, Http $http = null, Input $input = null, Web $application = null)
 {
     $this->options = isset($options) ? $options : new Registry();
     $this->http = isset($http) ? $http : new Http($this->options);
     $this->input = isset($input) ? $input : Factory::getApplication()->input;
     $this->application = isset($application) ? $application : new Web();
 }
 /**
  * Method to get a list of options for a list input.
  *
  * @return	array		An array of JHtml options.
  *
  * @since   11.4
  */
 protected function getOptions()
 {
     $folder = $this->element['folder'];
     if (!empty($folder)) {
         // Get list of plugins
         $db = Factory::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 = Factory::getLanguage();
         foreach ($options as $i => $item) {
             $source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value;
             $extension = 'plg_' . $folder . '_' . $item->value;
             $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, false) || $lang->load($extension . '.sys', $source, null, false, false) || $lang->load($extension . '.sys', JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) || $lang->load($extension . '.sys', $source, $lang->getDefault(), false, false);
             $options[$i]->text = Text::_($item->text);
         }
     } else {
         Log::add(Text::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'), Log::WARNING, 'jerror');
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
 /**
  * Constructor
  *
  * @param   string  $basepath       Base Path of the adapters
  * @param   string  $classprefix    Class prefix of adapters
  * @param   string  $adapterfolder  Name of folder to append to base path
  *
  * @since   11.1
  */
 public function __construct($basepath, $classprefix = null, $adapterfolder = null)
 {
     $this->_basepath = $basepath;
     $this->_classprefix = $classprefix ? $classprefix : 'J';
     $this->_adapterfolder = $adapterfolder ? $adapterfolder : 'adapters';
     $this->_db = Factory::getDBO();
 }
 /**
  * Renders a module script and returns the results as a string
  *
  * @param   mixed   $module   The name of the module to render
  * @param   array   $attribs  Associative array of values
  * @param   string  $content  If present, module information from the buffer will be used
  *
  * @return  string  The output of the script
  *
  * @since   11.1
  */
 public function render($module, $attribs = array(), $content = null)
 {
     if (!is_object($module)) {
         $title = isset($attribs['title']) ? $attribs['title'] : null;
         $module = JModuleHelper::getModule($module, $title);
         if (!is_object($module)) {
             if (is_null($content)) {
                 return '';
             } else {
                 /**
                  * If module isn't found in the database but data has been pushed in the buffer
                  * we want to render it
                  */
                 $tmp = $module;
                 $module = new stdClass();
                 $module->params = null;
                 $module->module = $tmp;
                 $module->id = 0;
                 $module->user = 0;
             }
         }
     }
     // Get the user and configuration object
     // $user = JFactory::getUser();
     $conf = Factory::getConfig();
     // Set the module content
     if (!is_null($content)) {
         $module->content = $content;
     }
     // Get module parameters
     $params = new Registry();
     $params->loadString($module->params);
     // Use parameters from template
     if (isset($attribs['params'])) {
         $template_params = new Registry();
         $template_params->loadString(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
         $params->merge($template_params);
         $module = clone $module;
         $module->params = (string) $params;
     }
     $contents = '';
     // Default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the
     // module instead
     $cachemode = $params->get('cachemode', 'oldstatic');
     if ($params->get('cache', 0) == 1 && $conf->get('caching') >= 1 && $cachemode != 'id' && $cachemode != 'safeuri') {
         // Default to itemid creating method and workarounds on
         $cacheparams = new stdClass();
         $cacheparams->cachemode = $cachemode;
         $cacheparams->class = 'JModuleHelper';
         $cacheparams->method = 'renderModule';
         $cacheparams->methodparams = array($module, $attribs);
         $contents = JModuleHelper::ModuleCache($module, $params, $cacheparams);
     } else {
         $contents = JModuleHelper::renderModule($module, $attribs);
     }
     return $contents;
 }
 /**
  * Constructor
  *
  * @param   JAdapter         $parent   Parent object
  * @param   JDatabaseDriver  $db       Database object
  * @param   array            $options  Configuration Options
  *
  * @since   11.1
  */
 public function __construct(Adapter $parent, Driver $db, array $options = array())
 {
     // Set the properties from the options array that is passed in
     $this->setProperties($options);
     // Set the parent and db in case $options for some reason overrides it.
     $this->parent = $parent;
     // Pull in the global dbo in case something happened to it.
     $this->db = $db ?: Factory::getDBO();
 }
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function render()
 {
     if (Factory::$application->input->get('success', false)) {
         Factory::$application->enqueueMessage("Sweet! You've setup your database successfully. Check out the <a href=\"news\">Sample Page</a>", 'success');
     }
     $this->renderer->set('success', Factory::$application->input->get('success', false));
     $this->renderer->set('logo', DEFAULT_THEME . '/images/logo.png');
     $this->renderer->set('config', Factory::getConfig());
     return parent::render();
 }
 /**
  * Constructor
  *
  * @param   array  $options  Optional parameters.
  *
  * @since   11.1
  * @throws  RuntimeException
  */
 public function __construct($options = array())
 {
     if (!self::isSupported()) {
         throw new RuntimeException('Memcache Extension is not available', 404);
     }
     parent::__construct($options);
     $config = Factory::getConfig();
     // This will be an array of loveliness
     // @todo: multiple servers
     $this->_servers = array(array('host' => $config->get('memcache_server_host', 'localhost'), 'port' => $config->get('memcache_server_port', 11211)));
 }
 /**
  * Method to test the email address and optionally check for uniqueness.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  * @param   JRegistry         $input    An optional JRegistry object with the entire data set to validate against the entire form.
  * @param   JForm             $form     The form object for which the field is being tested.
  *
  * @return  boolean  True if the value is valid, false otherwise.
  *
  * @since   11.1
  */
 public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
 {
     // If the field is empty and not required, the field is valid.
     $required = (string) $element['required'] == 'true' || (string) $element['required'] == 'required';
     if (!$required && empty($value)) {
         return true;
     }
     // If the tld attribute is present, change the regular expression to require at least 2 characters for it.
     $tld = (string) $element['tld'] == 'tld' || (string) $element['tld'] == 'required';
     if ($tld) {
         $this->regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]{2,})$';
     }
     // Determine if the multiple attribute is present
     $multiple = (string) $element['multiple'] == 'true' || (string) $element['multiple'] == 'multiple';
     if ($multiple) {
         $values = explode(',', $value);
     }
     if (!$multiple) {
         // Test the value against the regular expression.
         if (!parent::test($element, $value, $group, $input, $form)) {
             return false;
         }
     } else {
         foreach ($values as $value) {
             // Test the value against the regular expression.
             if (!parent::test($element, $value, $group, $input, $form)) {
                 return false;
             }
         }
     }
     // Check if we should test for uniqueness. This only can be used if multiple is not true
     $unique = (string) $element['unique'] == 'true' || (string) $element['unique'] == 'unique';
     if ($unique && !$multiple) {
         // Get the database object and a new query object.
         $db = Factory::getDBO();
         $query = $db->getQuery(true);
         // Build the query.
         $query->select('COUNT(*)');
         $query->from('#__users');
         $query->where('email = ' . $db->quote($value));
         // Get the extra field check attribute.
         $userId = $form instanceof Form ? $form->getValue('id') : '';
         $query->where($db->quoteName('id') . ' <> ' . (int) $userId);
         // Set and query the database.
         $db->setQuery($query);
         $duplicate = (bool) $db->loadResult();
         if ($duplicate) {
             return false;
         }
     }
     return true;
 }
 /**
  * This method processes a string and replaces all accented UTF-8 characters by unaccented
  * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercase.
  *
  * @param   string  $string  String to process
  *
  * @return  string  Processed string
  *
  * @since   11.1
  */
 public static function stringURLSafe($string)
 {
     // Remove any '-' from the string since they will be used as concatenaters
     $str = str_replace('-', ' ', $string);
     $lang = Factory::getLanguage();
     $str = $lang->transliterate($str);
     // Trim white spaces at beginning and end of alias and make lowercase
     $str = trim(String::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;
 }
 /**
  * Get a list of users.
  *
  * @return  string
  *
  * @since   11.4
  */
 public static function userlist()
 {
     // Get the database object and a new query object.
     $db = Factory::getDBO();
     $query = $db->getQuery(true);
     // Build the query.
     $query->select('a.id AS value, a.name AS text');
     $query->from('#__users AS a');
     $query->where('a.block = 0');
     $query->order('a.name');
     // Set the query and load the options.
     $db->setQuery($query);
     $items = $db->loadObjectList();
     return $items;
 }
 /**
  * Get and prepare system message data for output
  *
  * @return  array  An array contains system message
  *
  * @since   12.2
  */
 private function getData()
 {
     // Initialise variables.
     $lists = array();
     // Get the message queue
     $messages = Factory::getApplication()->getMessageQueue();
     // Build the sorted message list
     if (is_array($messages) && !empty($messages)) {
         foreach ($messages as $msg) {
             if (isset($msg['type']) && isset($msg['message'])) {
                 $lists[$msg['type']][] = $msg['message'];
             }
         }
     }
     return $lists;
 }
 /**
  * Translates an internal Joomla URL to a humanly readible URL.
  *
  * @param   string   $url    Absolute or Relative URI to Joomla resource.
  * @param   boolean  $xhtml  Replace & by &amp; for XML compilance.
  * @param   integer  $ssl    Secure state for the resolved URI.
  *                             1: Make URI secure using global secure site URI.
  *                             2: Make URI unsecure using the global unsecure site URI.
  *
  * @return  The translated humanly readible URL.
  *
  * @since   11.1
  */
 public static function _($url, $xhtml = true, $ssl = null)
 {
     if (!self::$_router) {
         // Get the router.
         self::$_router = Factory::getApplication()->getRouter();
         // Make sure that we have our router
         if (!self::$_router) {
             return null;
         }
     }
     if (strpos($url, '&') !== 0 && strpos($url, 'index.php') !== 0) {
         return $url;
     }
     // Build route.
     $uri = self::$_router->build($url);
     $url = $uri->toString(array('path', 'query', 'fragment'));
     // Replace spaces.
     $url = preg_replace('/\\s/u', '%20', $url);
     /*
      * Get the secure/unsecure URLs.
      *
      * If the first 5 characters of the BASE are 'https', then we are on an ssl connection over
      * https and need to set our secure URL to the current request URL, if not, and the scheme is
      * 'http', then we need to do a quick string manipulation to switch schemes.
      */
     if ((int) $ssl) {
         $uri = Uri::getInstance();
         // Get additional parts.
         static $prefix;
         if (!$prefix) {
             $prefix = $uri->toString(array('host', 'port'));
         }
         // Determine which scheme we want.
         $scheme = (int) $ssl === 1 ? 'https' : 'http';
         // Make sure our URL path begins with a slash.
         if (!preg_match('#^/#', $url)) {
             $url = '/' . $url;
         }
         // Build the URL.
         $url = $scheme . '://' . $prefix . $url;
     }
     if ($xhtml) {
         $url = htmlspecialchars($url);
     }
     return $url;
 }
 /**
  * Method to test the username for uniqueness.
  *
  * @param   SimpleXMLElement  $element  The SimpleXMLElement object representing the <field /> tag for the form field object.
  * @param   mixed             $value    The form field value to validate.
  * @param   string            $group    The field name group control value. This acts as as an array container for the field.
  *                                      For example if the field has name="foo" and the group value is set to "bar" then the
  *                                      full field name would end up being "bar[foo]".
  * @param   JRegistry         $input    An optional JRegistry object with the entire data set to validate against the entire form.
  * @param   JForm             $form     The form object for which the field is being tested.
  *
  * @return  boolean  True if the value is valid, false otherwise.
  *
  * @since   11.1
  */
 public function test(SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
 {
     // Get the database object and a new query object.
     $db = Factory::getDBO();
     $query = $db->getQuery(true);
     // Build the query.
     $query->select('COUNT(*)');
     $query->from('#__users');
     $query->where('username = '******'id') : '';
     $query->where($db->quoteName('id') . ' <> ' . (int) $userId);
     // Set and query the database.
     $db->setQuery($query);
     $duplicate = (bool) $db->loadResult();
     if ($duplicate) {
         return false;
     }
     return true;
 }
 /**
  * Render the document.
  *
  * @param   boolean  $cache   If true, cache the output
  * @param   array    $params  Associative array of attributes
  *
  * @return  The rendered data
  *
  * @since   12.1
  */
 public function render($cache = false, $params = array())
 {
     // Get the image type
     $type = Factory::getApplication()->input->get('type', 'png');
     switch ($type) {
         case 'jpg':
         case 'jpeg':
             $this->_mime = 'image/jpeg';
             break;
         case 'gif':
             $this->_mime = 'image/gif';
             break;
         case 'png':
         default:
             $this->_mime = 'image/png';
             break;
     }
     $this->_charset = null;
     parent::render();
     return $this->getBuffer();
 }
 /**
  * Method to get the time zone field option groups.
  *
  * @return  array  The field option objects as a nested array in groups.
  *
  * @since   11.1
  */
 protected function getGroups()
 {
     $groups = array();
     $keyField = $this->element['key_field'] ? (string) $this->element['key_field'] : 'id';
     $keyValue = $this->form->getValue($keyField);
     // If the timezone is not set use the server setting.
     if (strlen($this->value) == 0 && empty($keyValue)) {
         $this->value = Factory::getConfig()->get('offset');
     }
     // Get the list of time zones from the server.
     $zones = DateTimeZone::listIdentifiers();
     // Build the group lists.
     foreach ($zones as $zone) {
         // Time zones not in a group we will ignore.
         if (strpos($zone, '/') === false) {
             continue;
         }
         // Get the group/locale from the timezone.
         list($group, $locale) = explode('/', $zone, 2);
         // Only use known groups.
         if (in_array($group, self::$zones)) {
             // Initialize the group if necessary.
             if (!isset($groups[$group])) {
                 $groups[$group] = array();
             }
             // Only add options where a locale exists.
             if (!empty($locale)) {
                 $groups[$group][$zone] = Html::_('select.option', $zone, str_replace('_', ' ', $locale), 'value', 'text', false);
             }
         }
     }
     // Sort the group lists.
     ksort($groups);
     foreach ($groups as $zone => &$location) {
         sort($location);
     }
     // Merge any additional groups in the XML definition.
     $groups = array_merge(parent::getGroups(), $groups);
     return $groups;
 }
 /**
  * Function to convert a static time into a relative measurement
  *
  * @param   string  $date  The date to convert
  * @param   string  $unit  The optional unit of measurement to return
  *                         if the value of the diff is greater than one
  * @param   string  $time  An optional time to compare to, defaults to now
  *
  * @return  string  The converted time string
  *
  * @since   11.3
  */
 public static function relative($date, $unit = null, $time = null)
 {
     if (is_null($time)) {
         // Get now
         $time = Factory::getDate('now');
     }
     // Get the difference in seconds between now and the time
     $diff = strtotime($time) - strtotime($date);
     // Less than a minute
     if ($diff < 60) {
         return Text::_('JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE');
     }
     // Round to minutes
     $diff = round($diff / 60);
     // 1 to 59 minutes
     if ($diff < 60 || $unit == 'minute') {
         return Text::plural('JLIB_HTML_DATE_RELATIVE_MINUTES', $diff);
     }
     // Round to hours
     $diff = round($diff / 60);
     // 1 to 23 hours
     if ($diff < 24 || $unit == 'hour') {
         return Text::plural('JLIB_HTML_DATE_RELATIVE_HOURS', $diff);
     }
     // Round to days
     $diff = round($diff / 24);
     // 1 to 6 days
     if ($diff < 7 || $unit == 'day') {
         return Text::plural('JLIB_HTML_DATE_RELATIVE_DAYS', $diff);
     }
     // Round to weeks
     $diff = round($diff / 7);
     // 1 to 4 weeks
     if ($diff <= 4 || $unit == 'week') {
         return Text::plural('JLIB_HTML_DATE_RELATIVE_WEEKS', $diff);
     }
     // Over a month, return the absolute time
     return Html::_('date', $date);
 }
 /**
  * Update the database configuration
  *
  * @return  boolean
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function updateDatabase()
 {
     $input = Factory::$application->input;
     $oldConfig = Factory::getConfig();
     $file = JPATH_CONFIGURATION . '/config.json';
     // Verify the configuration exists and is readable.
     if (!is_readable($file)) {
         throw new \RuntimeException('Configuration file does not exist or is unreadable.');
     }
     $config = json_decode(file_get_contents($file));
     $config->database->driver = $input->get('driver', $oldConfig->get('database.driver'));
     $config->database->user = $input->get('user', $oldConfig->get('database.user'));
     $config->database->password = $input->get('password', $oldConfig->get('database.password'));
     $config->database->name = $input->get('name', $oldConfig->get('database.name'));
     $config->database->host = $input->get('host', $oldConfig->get('database.host'));
     $config->database->prefix = $input->get('prefix', $oldConfig->get('database.prefix'));
     file_put_contents($file, json_encode($config));
     Factory::$application->loadConfiguration();
     if ($input->get('install_sample_data')) {
         $this->installSampleData();
     }
     return true;
 }
 /**
  * Load the JavaScript behavior.
  *
  * @param   string  $group   The pane identifier.
  * @param   array   $params  Array of options.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected static function _loadBehavior($group, $params = array())
 {
     static $loaded = array();
     if (!array_key_exists($group, $loaded)) {
         // Get the JInput object
         $input = Factory::getApplication()->input;
         $loaded[$group] = true;
         // Include mootools framework.
         Html::_('behavior.framework', true);
         $document = Factory::getDocument();
         $display = isset($params['startOffset']) && isset($params['startTransition']) && $params['startTransition'] ? (int) $params['startOffset'] : null;
         $show = isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']) ? (int) $params['startOffset'] : null;
         $opt['onActive'] = "\\function(toggler, i) {toggler.addClass('pane-toggler-down');" . "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_" . $group . "',\$\$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}";
         $opt['onBackground'] = "\\function(toggler, i) {toggler.addClass('pane-toggler');" . "toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if(\$\$('div#" . $group . ".pane-sliders > .panel > h3').length==\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}";
         $opt['duration'] = isset($params['duration']) ? (int) $params['duration'] : 300;
         $opt['display'] = isset($params['useCookie']) && $params['useCookie'] ? $input->cookie->get('jpanesliders_' . $group, $display, 'integer') : $display;
         $opt['show'] = isset($params['useCookie']) && $params['useCookie'] ? $input->cookie->get('jpanesliders_' . $group, $show, 'integer') : $show;
         $opt['opacity'] = isset($params['opacityTransition']) && $params['opacityTransition'] ? 'true' : 'false';
         $opt['alwaysHide'] = isset($params['allowAllClose']) && !$params['allowAllClose'] ? 'false' : 'true';
         $options = Html::getJSObject($opt);
         $js = "window.addEvent('domready', function(){ new Fx.Accordion(\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler'), \$\$('div#" . $group . ".pane-sliders > .panel > div.pane-slider'), " . $options . "); });";
         $document->addScriptDeclaration($js);
     }
 }
 /**
  * Load the application object.
  *
  * @return  JApplicationBase  The application object.
  *
  * @since   12.1
  */
 protected function loadApplication()
 {
     return Factory::getApplication();
 }
 /**
  * Render the feed.
  *
  * @param   string  $name     The name of the element to render
  * @param   array   $params   Array of values
  * @param   string  $content  Override the output of the renderer
  *
  * @return  string  The output of the script
  *
  * @see JDocumentRenderer::render()
  * @since   11.1
  */
 public function render($name = '', $params = null, $content = null)
 {
     $app = Factory::getApplication();
     // Gets and sets timezone offset from site configuration
     $tz = new DateTimeZone($app->getCfg('offset'));
     $now = Factory::getDate();
     $now->setTimeZone($tz);
     $data = $this->_doc;
     $uri = Uri::getInstance();
     $url = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
     $syndicationURL = Route::_('&format=feed&type=atom');
     if ($app->getCfg('sitename_pagetitles', 0) == 1) {
         $title = Text::sprintf('JPAGETITLE', $app->getCfg('sitename'), $data->title);
     } elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
         $title = Text::sprintf('JPAGETITLE', $data->title, $app->getCfg('sitename'));
     } else {
         $title = $data->title;
     }
     $feed_title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
     $feed = "<feed xmlns=\"http://www.w3.org/2005/Atom\" ";
     if ($data->language != "") {
         $feed .= " xml:lang=\"" . $data->language . "\"";
     }
     $feed .= ">\n";
     $feed .= "\t<title type=\"text\">" . $feed_title . "</title>\n";
     $feed .= "\t<subtitle type=\"text\">" . htmlspecialchars($data->description, ENT_COMPAT, 'UTF-8') . "</subtitle>\n";
     if (empty($data->category) === false) {
         if (is_array($data->category)) {
             foreach ($data->category as $cat) {
                 $feed .= "\t<category term=\"" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\" />\n";
             }
         } else {
             $feed .= "\t<category term=\"" . htmlspecialchars($data->category, ENT_COMPAT, 'UTF-8') . "\" />\n";
         }
     }
     $feed .= "\t<link rel=\"alternate\" type=\"text/html\" href=\"" . $url . "\"/>\n";
     $feed .= "\t<id>" . str_replace(' ', '%20', $data->getBase()) . "</id>\n";
     $feed .= "\t<updated>" . htmlspecialchars($now->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</updated>\n";
     if ($data->editor != "") {
         $feed .= "\t<author>\n";
         $feed .= "\t\t<name>" . $data->editor . "</name>\n";
         if ($data->editorEmail != "") {
             $feed .= "\t\t<email>" . htmlspecialchars($data->editorEmail, ENT_COMPAT, 'UTF-8') . "</email>\n";
         }
         $feed .= "\t</author>\n";
     }
     $feed .= "\t<generator uri=\"http://joomla.org\" version=\"1.6\">" . $data->getGenerator() . "</generator>\n";
     $feed .= '	<link rel="self" type="application/atom+xml" href="' . str_replace(' ', '%20', $url . $syndicationURL) . "\"/>\n";
     for ($i = 0, $count = count($data->items); $i < $count; $i++) {
         $feed .= "\t<entry>\n";
         $feed .= "\t\t<title>" . htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT, 'UTF-8') . "</title>\n";
         $feed .= '		<link rel="alternate" type="text/html" href="' . $url . $data->items[$i]->link . "\"/>\n";
         if ($data->items[$i]->date == "") {
             $data->items[$i]->date = $now->toUnix();
         }
         $itemDate = Factory::getDate($data->items[$i]->date);
         $itemDate->setTimeZone($tz);
         $feed .= "\t\t<published>" . htmlspecialchars($itemDate->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</published>\n";
         $feed .= "\t\t<updated>" . htmlspecialchars($itemDate->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</updated>\n";
         if (empty($data->items[$i]->guid) === true) {
             $feed .= "\t\t<id>" . str_replace(' ', '%20', $url . $data->items[$i]->link) . "</id>\n";
         } else {
             $feed .= "\t\t<id>" . htmlspecialchars($data->items[$i]->guid, ENT_COMPAT, 'UTF-8') . "</id>\n";
         }
         if ($data->items[$i]->author != "") {
             $feed .= "\t\t<author>\n";
             $feed .= "\t\t\t<name>" . htmlspecialchars($data->items[$i]->author, ENT_COMPAT, 'UTF-8') . "</name>\n";
             if ($data->items[$i]->authorEmail != "") {
                 $feed .= "\t\t\t<email>" . htmlspecialchars($data->items[$i]->authorEmail, ENT_COMPAT, 'UTF-8') . "</email>\n";
             }
             $feed .= "\t\t</author>\n";
         }
         if ($data->items[$i]->description != "") {
             $feed .= "\t\t<summary type=\"html\">" . htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8') . "</summary>\n";
             $feed .= "\t\t<content type=\"html\">" . htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8') . "</content>\n";
         }
         if (empty($data->items[$i]->category) === false) {
             if (is_array($data->items[$i]->category)) {
                 foreach ($data->items[$i]->category as $cat) {
                     $feed .= "\t\t<category term=\"" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\" />\n";
                 }
             } else {
                 $feed .= "\t\t<category term=\"" . htmlspecialchars($data->items[$i]->category, ENT_COMPAT, 'UTF-8') . "\" />\n";
             }
         }
         if ($data->items[$i]->enclosure != null) {
             $feed .= "\t\t<link rel=\"enclosure\" href=\"" . $data->items[$i]->enclosure->url . "\" type=\"" . $data->items[$i]->enclosure->type . "\"  length=\"" . $data->items[$i]->enclosure->length . "\" />\n";
         }
         $feed .= "\t</entry>\n";
     }
     $feed .= "</feed>\n";
     return $feed;
 }
 /**
  * After the session has been started we need to populate it with some default values.
  *
  * @return  void
  *
  * @since   12.2
  */
 public function afterSessionStart()
 {
     $session = Factory::getSession();
     if ($session->isNew()) {
         $session->set('registry', new Registry('session'));
         $session->set('user', new User());
     }
 }
    /**
     * Load the JavaScript behavior.
     *
     * @param   string  $group   The pane identifier.
     * @param   array   $params  Array of options.
     *
     * @return  void
     *
     * @since   11.1
     */
    protected static function _loadBehavior($group, $params = array())
    {
        static $loaded = array();
        if (!array_key_exists((string) $group, $loaded)) {
            // Include MooTools framework
            Html::_('behavior.framework', true);
            $opt['onActive'] = isset($params['onActive']) ? '\\' . $params['onActive'] : null;
            $opt['onBackground'] = isset($params['onBackground']) ? '\\' . $params['onBackground'] : null;
            $opt['display'] = isset($params['startOffset']) ? (int) $params['startOffset'] : null;
            $opt['useStorage'] = isset($params['useCookie']) && $params['useCookie'] ? 'true' : 'false';
            $opt['titleSelector'] = "dt.tabs";
            $opt['descriptionSelector'] = "dd.tabs";
            $options = Html::getJSObject($opt);
            $js = '	window.addEvent(\'domready\', function(){
						$$(\'dl#' . $group . '.tabs\').each(function(tabs){
							new JTabs(tabs, ' . $options . ');
						});
					});';
            $document = Factory::getDocument();
            $document->addScriptDeclaration($js);
            Html::_('script', 'system/tabs.js', false, true);
            $loaded[(string) $group] = true;
        }
    }
 /**
  * Allows the application to load a custom or default identity.
  *
  * The logic and options for creating this object are adequately generic for default cases
  * but for many applications it will make sense to override this method and create an identity,
  * if required, based on more specific needs.
  *
  * @param   JUser  $identity  An optional identity object. If omitted, the factory user is created.
  *
  * @return  JApplicationBase This method is chainable.
  *
  * @since   12.1
  */
 public function loadIdentity(User $identity = null)
 {
     $this->identity = $identity === null ? Factory::getUser() : $identity;
     return $this;
 }
 /**
  * Get a list of the user groups.
  *
  * @return  array
  *
  * @since   11.1
  */
 protected function getUserGroups()
 {
     $db = Factory::getDBO();
     $query = $db->getQuery(true);
     $query->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level, a.parent_id')->from('#__usergroups AS a')->leftJoin($db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt')->group('a.id, a.title, a.lft, a.rgt, a.parent_id')->order('a.lft ASC');
     $db->setQuery($query);
     $options = $db->loadObjectList();
     return $options;
 }
 /**
  * Test to see if the cache storage is available.
  *
  * @return  boolean  True on success, false otherwise.
  *
  * @since   12.1
  */
 public static function isSupported()
 {
     $conf = Factory::getConfig();
     return is_writable($conf->get('cache_path', JPATH_CACHE));
 }
 /**
  * Break us out of any containing iframes
  *
  * @return  void
  *
  * @since   11.1
  */
 public static function noframes()
 {
     // Only load once
     if (isset(self::$loaded[__METHOD__])) {
         return;
     }
     // Include MooTools framework
     self::framework();
     $js = "window.addEvent('domready', function () {if (top == self) {document.documentElement.style.display = 'block'; }" . " else {top.location = self.location; }});";
     $document = Factory::getDocument();
     $document->addStyleDeclaration('html { display:none }');
     $document->addScriptDeclaration($js);
     Response::setHeader('X-Frames-Options', 'SAME-ORIGIN');
     self::$loaded[__METHOD__] = true;
 }