/** * @param null $url */ function save($url = null) { if (!JSession::checkToken('post')) { $this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirect(KunenaRoute::_($this->baseurl, false)); return; } $properties = $this->config->getProperties(); //Todo: fix depricated value foreach (JRequest::get('post', JREQUEST_ALLOWHTML) as $postsetting => $postvalue) { if (\Joomla\String\String::strpos($postsetting, 'cfg_') === 0) { //remove cfg_ and force lower case if (is_array($postvalue)) { $postvalue = implode(',', $postvalue); } $postname = \Joomla\String\String::strtolower(\Joomla\String\String::substr($postsetting, 4)); // No matter what got posted, we only store config parameters defined // in the config class. Anything else posted gets ignored. if (array_key_exists($postname, $properties)) { $this->config->set($postname, $postvalue); } } } $this->config->save(); $this->app->enqueueMessage(JText::_('COM_KUNENA_CONFIGSAVED')); if (empty($url)) { $this->setRedirect(KunenaRoute::_($this->kunenabaseurl, false)); return; } $this->setRedirect(KunenaRoute::_($url, false)); }
/** * Method to set up the document properties * * @return void */ protected function setDocument() { $this->document->setTitle($this->documentTitle); // Add scripts JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); $this->document->addScript('../media/' . $this->option . '/js/admin/' . String::strtolower($this->getName()) . '.js'); }
/** * Method to set up the document properties * * @return void */ protected function setDocument() { $this->document->setTitle($this->documentTitle); // Load language string in JavaScript JText::script('COM_GAMIFICATION_DELETE_IMAGE_QUESTION'); // Add scripts JHtml::_('behavior.tooltip'); JHtml::_('behavior.formvalidation'); $this->document->addScript('../media/' . $this->option . '/js/admin/' . String::strtolower($this->getName()) . '.js'); }
/** * Prepare document */ protected function prepareDocument() { //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); // Prepare page heading $this->prepearePageHeading(); // Prepare page heading $this->prepearePageTitle(); // Meta Description if ($this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } // Meta keywords if ($this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } // Scripts JHtml::_('behavior.tooltip'); $this->document->addScript('media/' . $this->option . '/js/site/' . String::strtolower($this->getName()) . '.js'); }
/** * Sets an inflected word in the cache. * * @param string $singular The singular form of the word. * @param string $plural The plural form of the word. If omitted, it is assumed the singular and plural are identical. * * @return void * * @since 1.0 */ private function setCache($singular, $plural = null) { $singular = String::strtolower($singular); if ($plural === null) { $plural = $singular; } else { $plural = String::strtolower($plural); } $this->cache[$singular] = $plural; }
/** * Check for valid payment gateway. * * @param string $gateway * * @return bool */ protected function isValidPaymentGateway($gateway) { $value1 = String::strtolower($this->paymentService); $value2 = String::strtolower($gateway); if (String::strcmp($value1, $value2) != 0) { return false; } return true; }
/** * Common function to process the search filter for a query * * @param DatabaseQuery $query DatabaseQuery object * @param string $filter Filter string * * @return DatabaseQuery * * @since 1.0 */ private function processSearchFilter(DatabaseQuery $query, $filter) { $db = $this->getDb(); // Clean filter variable $filter = $db->quote('%' . $db->escape(String::strtolower($filter), true) . '%', false); // Check the author, title, and publish_up fields $query->where('(' . $db->quoteName('a.title') . ' LIKE ' . $filter . ' OR ' . $db->quoteName('a.description') . ' LIKE ' . $filter . ' OR ' . $db->quoteName('a.issue_number') . ' LIKE ' . $filter . ')'); return $query; }
/** * Transliterate function * * This method processes a string and replaces all accented UTF-8 characters by unaccented * ASCII-7 "equivalents". * * @param string $string The string to transliterate. * * @return string The transliteration of the string. * * @since 1.0 */ public function transliterate($string) { if ($this->transliterator !== null) { return call_user_func($this->transliterator, $string); } $string = Transliterate::utf8_latin_to_ascii($string); $string = String::strtolower($string); return $string; }
/** * This method implements unicode slugs instead of transliteration. * * @param string $string String to process * * @return string Processed string * * @since 11.1 */ public static function stringURLUnicodeSlug($string) { // Replace double byte whitespaces by single byte (East Asian languages) $str = preg_replace('/\\xE3\\x80\\x80/', ' ', $string); // Remove any '-' from the string as they will be used as concatenator. // Would be great to let the spaces in but only Firefox is friendly with this $str = str_replace('-', ' ', $str); // Replace forbidden characters by whitespaces $str = preg_replace('#[:\\#\\*"@+=;!><&\\.%()\\]\\/\'\\\\|\\[]#', " ", $str); // Delete all '?' $str = str_replace('?', '', $str); // Trim white spaces at beginning and end of alias and make lowercase $str = trim(String::strtolower($str)); // Remove any duplicate whitespace and replace whitespaces by hyphens $str = preg_replace('#\\x20+#', '-', $str); return $str; }
/** * Transliterate function * * This method processes a string and replaces all accented UTF-8 characters by unaccented * ASCII-7 "equivalents". * * @param string $string The string to transliterate. * * @return string The transliteration of the string. * * @since 1.0 * @throws \RuntimeException */ public function transliterate($string) { if ($this->transliterator !== null) { return call_user_func($this->transliterator, $string); } $string = Transliterate::utf8_latin_to_ascii($string); $lowercaseString = String::strtolower($string); // String can return false if there isn't a fully valid UTF-8 string entered if ($lowercaseString == false) { throw new \RuntimeException('Invalid UTF-8 was detected in the string "%s"', $lowercaseString); } return $lowercaseString; }
/** * Method to set up the document properties * * @return void */ protected function setDocument() { $this->document->setTitle(JText::_('COM_GAMIFICATION_RANKS_MANAGER')); // Load language string in JavaScript JText::script('COM_GAMIFICATION_SEARCH_IN_TITLE_TOOLTIP'); // Scripts JHtml::_('bootstrap.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('formbehavior.chosen', 'select'); $this->document->addScript('../media/' . $this->option . '/js/admin/' . String::strtolower($this->getName()) . '.js'); }
/** * Creates an alpha index with all items which are loaded in the sitemap * * @param array $data_array - Keywords list array with all articles which are included in the output * @param int $count_match - Number for the IDs which have to be unique * * @return array - HTML output of the alpha index and all first letters of allowed keywords for the creation of the anchors */ private function createAlphaIndex($data_array, $count_match) { $data_keys_array = array_unique(array_map(array($this, 'firstCharAlphaIndex'), array_keys($data_array))); $data_range = array(); if ($this->eks_parameters['alpha'] === 'cyrillic') { foreach (range(chr(0xc0), chr(0xdf)) as $char) { $data_range[] = iconv('CP1251', 'UTF-8', $char); } } else { $data_range = range('A', 'Z'); } $html = '<div class="eks_alphaindex">'; foreach ($data_range as $value) { if (in_array($value, $data_keys_array)) { $html .= '<a href="#eks_' . String::strtolower($value) . '_' . $count_match . '">' . $value . '</a> '; } else { $html .= $value . ' '; } } $html .= '</div>'; $return = array($html, $data_keys_array); return $return; }
/** * Get an item by alias * * @param string $alias The alias of the category * * @return object * * @since 1.0 */ public function getByAlias($alias = '') { $db = $this->getDb(); $query = $db->getQuery(true); $projectId = $this->getProject()->project_id; $query->select('*')->from('#__issues_categories')->where($db->quoteName('project_id') . '=' . $projectId); $filter = new InputFilter(); $alias = $filter->clean($alias, 'cmd'); if ($alias) { $alias = $db->quote('%' . $db->escape(String::strtolower($alias), true) . '%', false); $query->where($db->quoteName('alias') . ' LIKE ' . $alias); } $item = $db->setQuery($query)->loadObject(); return $item; }
/** * @return bool * @throws KunenaInstallerException */ public function migrateAvatars() { $stats = $this->getAvatarStatus(); static $dirs = array('media/kunena/avatars', 'images/fbfiles/avatars', 'components/com_fireboard/avatars'); $query = "SELECT COUNT(*) FROM #__kunena_users\n\t\t\tWHERE userid>{$this->db->quote($stats->current)} AND avatar != '' AND avatar NOT LIKE 'gallery/%' AND avatar NOT LIKE 'users/%'"; $this->db->setQuery($query); $count = $this->db->loadResult(); if ($this->db->getErrorNum()) { throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum()); } if (!$stats->current && !$count) { return true; } $query = "SELECT userid, avatar FROM #__kunena_users\n\t\t\tWHERE userid>{$this->db->quote($stats->current)} AND avatar != '' AND avatar NOT LIKE 'gallery/%' AND avatar NOT LIKE 'users/%'"; $this->db->setQuery($query, 0, 1023); $users = $this->db->loadObjectList(); if ($this->db->getErrorNum()) { throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum()); } foreach ($users as $user) { $userid = $stats->current = $user->userid; $avatar = $user->avatar; $count--; $file = $newfile = ''; foreach ($dirs as $dir) { if (!JFile::exists(JPATH_ROOT . "/{$dir}/{$avatar}")) { continue; } $file = JPATH_ROOT . "/{$dir}/{$avatar}"; break; } if ($file) { $file = JPath::clean($file, '/'); // Make sure to copy only supported fileformats $match = preg_match('/\\.(gif|jpg|jpeg|png)$/ui', $file, $matches); if ($match) { $ext = \Joomla\String\String::strtolower($matches[1]); // Use new format: users/avatar62.jpg $newfile = "users/avatar{$userid}.{$ext}"; $destpath = KUNENA_INSTALLER_MEDIAPATH . "/avatars/{$newfile}"; if (JFile::exists($destpath)) { $success = true; } else { @chmod($file, 0644); $success = JFile::copy($file, $destpath); } if ($success) { $stats->migrated++; } else { $this->addStatus("User: {$userid}, Avatar copy failed: {$file} to {$destpath}", true); $stats->failed++; } } else { $this->addStatus("User: {$userid}, Avatar type not supported: {$file}", true); $stats->failed++; $success = true; } } else { // $this->addStatus ( "User: {$userid}, Avatar file was not found: {$avatar}", true ); $stats->missing++; $success = true; } if ($success) { $query = "UPDATE #__kunena_users SET avatar={$this->db->quote($newfile)} WHERE userid={$this->db->quote($userid)}"; $this->db->setQuery($query); $this->db->execute(); if ($this->db->getErrorNum()) { throw new KunenaInstallerException($this->db->getErrorMsg(), $this->db->getErrorNum()); } } if ($this->checkTimeout()) { break; } } $this->setAvatarStatus($stats); if ($count) { $this->addStatus(JText::sprintf('COM_KUNENA_MIGRATE_AVATARS', $count), true, '', 'avatar'); } else { $this->addStatus(JText::sprintf('COM_KUNENA_MIGRATE_AVATARS_DONE', $stats->migrated, $stats->missing, $stats->failed), true, '', 'avatar'); } return !$count; }