コード例 #1
0
ファイル: config.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * @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));
 }
コード例 #2
0
 /**
  * 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');
 }
コード例 #3
0
ファイル: activity.php プロジェクト: Ruud68/Kunena-Forum
 public function onAfterReply($message)
 {
     if (\Joomla\String\String::strlen($message->message) > $this->params->get('activity_points_limit', 0)) {
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('com_kunena.thread.reply');
     }
     // Get users who have subscribed to the topic, excluding current user.
     $acl = KunenaAccess::getInstance();
     $subscribers = $acl->getSubscribers($message->catid, $message->thread, KunenaAccess::TOPIC_SUBSCRIPTION, false, false, array($message->userid));
     foreach ($subscribers as $userid) {
         $actor = CFactory::getUser($message->userid);
         $target = CFactory::getUser($userid);
         $params = new CParameter('');
         $params->set('actorName', $actor->getDisplayName());
         $params->set('recipientName', $target->getDisplayName());
         $params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null));
         // {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification
         $params->set('title', $message->displayField('subject'));
         // (title) tag in language file
         $params->set('title_url', $message->getPermaUrl());
         // Make the title in notification - linkable
         $params->set('message', $message->displayField('message'));
         // (message) tag in language file
         $params->set('actor', $actor->getDisplayName());
         // Actor in the stream
         $params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id);
         // Actor Link
         // Finally, send notifications
         CNotificationLibrary::add('kunena_reply', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TEXT'), '', $params);
     }
     // Activity stream
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $message->userid;
     $act->target = 0;
     // no target
     $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>'));
     $act->content = $this->buildContent($message);
     $act->app = 'kunena.thread.reply';
     $act->cid = $message->thread;
     $act->access = $this->getAccess($message->getCategory());
     // Comments and like support
     $act->comment_id = $message->thread;
     $act->comment_type = 'kunena.thread.reply';
     $act->like_id = $message->thread;
     $act->like_type = 'kunena.thread.reply';
     // Do not add private activities
     if ($act->access > 20) {
         return;
     }
     CFactory::load('libraries', 'activities');
     $table = CActivityStream::add($act);
     if (is_object($table)) {
         $table->like_id = $table->id;
         $table->store();
     }
 }
コード例 #4
0
 /**
  * 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');
 }
コード例 #5
0
 /**
  * Validates the value.
  *
  * @param   scalar  $value  The value to validate.
  *
  * @return  boolean
  *
  * @since   1.0
  */
 protected function doIsValid($value)
 {
     $min = $this->getOption('min');
     $max = $this->getOption('max');
     if ($min && String::strlen($value) < $min) {
         $this->addError(self::TOO_SHORT);
         return false;
     }
     if ($max && String::strlen($value) > $max) {
         $this->addError(self::TOO_LONG);
         return false;
     }
     return true;
 }
コード例 #6
0
 /**
  * Method to test an external url for a valid parts.
  *
  * @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
  * @link    http://www.w3.org/Addressing/URL/url-spec.txt
  * @see	    Jstring
  */
 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;
     }
     $urlParts = String::parse_url($value);
     // See http://www.w3.org/Addressing/URL/url-spec.txt
     // Use the full list or optionally specify a list of permitted schemes.
     if ($element['schemes'] == '') {
         $scheme = array('http', 'https', 'ftp', 'ftps', 'gopher', 'mailto', 'news', 'prospero', 'telnet', 'rlogin', 'tn3270', 'wais', 'url', 'mid', 'cid', 'nntp', 'tel', 'urn', 'ldap', 'file', 'fax', 'modem', 'git');
     } else {
         $scheme = explode(',', $element['schemes']);
     }
     /*
      * This rule is only for full URLs with schemes because parse_url does not parse
      * accurately without a scheme.
      * @see http://php.net/manual/en/function.parse-url.php
      */
     if ($urlParts && !array_key_exists('scheme', $urlParts)) {
         return false;
     }
     $urlScheme = (string) $urlParts['scheme'];
     $urlScheme = strtolower($urlScheme);
     if (in_array($urlScheme, $scheme) == false) {
         return false;
     }
     // For some schemes here must be two slashes.
     if (($urlScheme == 'http' || $urlScheme == 'https' || $urlScheme == 'ftp' || $urlScheme == 'sftp' || $urlScheme == 'gopher' || $urlScheme == 'wais' || $urlScheme == 'gopher' || $urlScheme == 'prospero' || $urlScheme == 'telnet' || $urlScheme == 'git') && substr($value, strlen($urlScheme), 3) !== '://') {
         return false;
     }
     // The best we can do for the rest is make sure that the strings are valid UTF-8
     // and the port is an integer.
     if (array_key_exists('host', $urlParts) && !String::valid((string) $urlParts['host'])) {
         return false;
     }
     if (array_key_exists('port', $urlParts) && !is_int((int) $urlParts['port'])) {
         return false;
     }
     if (array_key_exists('path', $urlParts) && !String::valid((string) $urlParts['path'])) {
         return false;
     }
     return true;
 }
コード例 #7
0
 /**
  * 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');
 }
コード例 #8
0
 /**
  * Overloaded check method to ensure data integrity.
  *
  * @return  boolean  True on success.
  *
  * @since   1.5
  */
 public function check()
 {
     /*
      * Clean up keywords -- eliminate extra spaces between phrases
      * and cr (\r) and lf (\n) characters from string
      */
     if (!empty($this->metakey)) {
         // Array of characters to remove
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         $after_clean = String::str_ireplace($bad_characters, "", $this->metakey);
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             // Ignore blank keywords
             if (trim($key)) {
                 $clean_keys[] = trim($key);
             }
         }
         // Put array back together delimited by ", "
         $this->metakey = implode(", ", $clean_keys);
     }
     return true;
 }
コード例 #9
0
 /**
  * Returns an array of options
  *
  * @param   string   $sql  	SQL with 'ordering' AS value and 'name field' AS text
  * @param   integer  $chop  The length of the truncated headline
  *
  * @return  array  An array of objects formatted for JHtml list processing
  *
  * @since   11.1
  */
 public static function genericordering($sql, $chop = 30)
 {
     $db = Factory::getDbo();
     $options = array();
     $db->setQuery($sql);
     $items = $db->loadObjectList();
     if (empty($items)) {
         $options[] = Html::_('select.option', 1, Text::_('JOPTION_ORDER_FIRST'));
         return $options;
     }
     $options[] = Html::_('select.option', 0, '0 ' . Text::_('JOPTION_ORDER_FIRST'));
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $items[$i]->text = Text::_($items[$i]->text);
         if (String::strlen($items[$i]->text) > $chop) {
             $text = String::substr($items[$i]->text, 0, $chop) . "...";
         } else {
             $text = $items[$i]->text;
         }
         $options[] = Html::_('select.option', $items[$i]->value, $items[$i]->value . '. ' . $text);
     }
     $options[] = Html::_('select.option', $items[$i - 1]->value + 1, $items[$i - 1]->value + 1 . ' ' . Text::_('JOPTION_ORDER_LAST'));
     return $options;
 }
コード例 #10
0
ファイル: IssuesModel.php プロジェクト: dextercowley/jissues
 /**
  * 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;
 }
コード例 #11
0
 /**
  * Redirect to another URL.
  *
  * If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently"
  * or "303 See Other" code in the header pointing to the new location. If the headers have already been
  * sent this will be accomplished using a JavaScript statement.
  *
  * @param   string   $url    The URL to redirect to. Can only be http/https URL
  * @param   boolean  $moved  True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function redirect($url, $moved = false)
 {
     // Check for relative internal links.
     if (preg_match('#^index\\.php#', $url)) {
         $url = $this->get('uri.base.full') . $url;
     }
     // Perform a basic sanity check to make sure we don't have any CRLF garbage.
     $url = preg_split("/[\r\n]/", $url);
     $url = $url[0];
     /*
      * Here we need to check and see if the URL is relative or absolute.  Essentially, do we need to
      * prepend the URL with our base URL for a proper redirect.  The rudimentary way we are looking
      * at this is to simply check whether or not the URL string has a valid scheme or not.
      */
     if (!preg_match('#^[a-z]+\\://#i', $url)) {
         // Get a JURI instance for the requested URI.
         $uri = new Uri($this->get('uri.request'));
         // Get a base URL to prepend from the requested URI.
         $prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
         // We just need the prefix since we have a path relative to the root.
         if ($url[0] == '/') {
             $url = $prefix . $url;
         } else {
             $parts = explode('/', $uri->toString(array('path')));
             array_pop($parts);
             $path = implode('/', $parts) . '/';
             $url = $prefix . $path . $url;
         }
     }
     // If the headers have already been sent we need to send the redirect statement via JavaScript.
     if ($this->checkHeadersSent()) {
         echo "<script>document.location.href='{$url}';</script>\n";
     } else {
         // We have to use a JavaScript redirect here because MSIE doesn't play nice with utf-8 URLs.
         if ($this->client->engine == Web\WebClient::TRIDENT && !String::is_ascii($url)) {
             $html = '<html><head>';
             $html .= '<meta http-equiv="content-type" content="text/html; charset=' . $this->charSet . '" />';
             $html .= '<script>document.location.href=\'' . $url . '\';</script>';
             $html .= '</head><body></body></html>';
             echo $html;
         } else {
             // All other cases use the more efficient HTTP header for redirection.
             $this->header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other');
             $this->header('Location: ' . $url);
             $this->header('Content-Type: text/html; charset=' . $this->charSet);
             // Send other headers that may have been set.
             $this->sendHeaders();
         }
     }
     // Close the application after the redirect.
     $this->close();
 }
コード例 #12
0
ファイル: Field.php プロジェクト: ZerGabriel/joomla-framework
 /**
  * Method to instantiate the form field object.
  *
  * @param   Form  $form  The form to attach to the form field object.
  *
  * @since   1.0
  */
 public function __construct(Form $form = null)
 {
     // If there is a form passed into the constructor set the form and form control properties.
     if ($form instanceof Form) {
         $this->form = $form;
         $this->formControl = $form->getFormControl();
     }
     // Detect the field type if not set
     if (!isset($this->type)) {
         $parts = Normalise::fromCamelCase(get_called_class(), true);
         if ($parts[0] == 'J') {
             $this->type = String::ucfirst($parts[count($parts) - 1], '_');
         } else {
             $this->type = String::ucfirst($parts[0], '_') . String::ucfirst($parts[count($parts) - 1], '_');
         }
     }
 }
コード例 #13
0
ファイル: weblink.php プロジェクト: grlf/eyedock
 /**
  * Overloaded check method to ensure data integrity.
  *
  * @return  boolean  True on success.
  *
  * @since   1.5
  */
 public function check()
 {
     if (JFilterInput::checkAttribute(array('href', $this->url))) {
         $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_PROVIDE_URL'));
         return false;
     }
     // check for valid name
     if (trim($this->title) == '') {
         $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE'));
         return false;
     }
     // Check for existing name
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select($db->quoteName('id'))->from($db->quoteName('#__weblinks'))->where($db->quoteName('title') . ' = ' . $db->quote($this->title))->where($db->quoteName('catid') . ' = ' . (int) $this->catid);
     $db->setQuery($query);
     $xid = (int) $db->loadResult();
     if ($xid && $xid != (int) $this->id) {
         $this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_NAME'));
         return false;
     }
     if (empty($this->alias)) {
         $this->alias = $this->title;
     }
     $this->alias = JApplicationHelper::stringURLSafe($this->alias);
     if (trim(str_replace('-', '', $this->alias)) == '') {
         $this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
     }
     // Check the publish down date is not earlier than publish up.
     if ($this->publish_down > $db->getNullDate() && $this->publish_down < $this->publish_up) {
         $this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
         return false;
     }
     /*
      * Clean up keywords -- eliminate extra spaces between phrases
      * and cr (\r) and lf (\n) characters from string
      */
     if (!empty($this->metakey)) {
         // Array of characters to remove
         $bad_characters = array("\n", "\r", "\"", "<", ">");
         $after_clean = String::str_ireplace($bad_characters, "", $this->metakey);
         $keys = explode(',', $after_clean);
         $clean_keys = array();
         foreach ($keys as $key) {
             // Ignore blank keywords
             if (trim($key)) {
                 $clean_keys[] = trim($key);
             }
         }
         // Put array back together delimited by ", "
         $this->metakey = implode(", ", $clean_keys);
     }
     return true;
 }
コード例 #14
0
ファイル: ArrayHelper.php プロジェクト: educakanchay/kanchay
 /**
  * Utility function to sort an array of objects on a given field
  *
  * @param   array  $a              An array of objects
  * @param   mixed  $k              The key (string) or a array of key to sort on
  * @param   mixed  $direction      Direction (integer) or an array of direction to sort in [1 = Ascending] [-1 = Descending]
  * @param   mixed  $caseSensitive  Boolean or array of booleans to let sort occur case sensitive or insensitive
  * @param   mixed  $locale         Boolean or array of booleans to let sort occur using the locale language or not
  *
  * @return  array  The sorted array of objects
  *
  * @since   1.0
  */
 public static function sortObjects(array $a, $k, $direction = 1, $caseSensitive = true, $locale = false)
 {
     if (!is_array($locale) || !is_array($locale[0])) {
         $locale = array($locale);
     }
     $sortCase = (array) $caseSensitive;
     $sortDirection = (array) $direction;
     $key = (array) $k;
     $sortLocale = $locale;
     usort($a, function ($a, $b) use($sortCase, $sortDirection, $key, $sortLocale) {
         for ($i = 0, $count = count($key); $i < $count; $i++) {
             if (isset($sortDirection[$i])) {
                 $direction = $sortDirection[$i];
             }
             if (isset($sortCase[$i])) {
                 $caseSensitive = $sortCase[$i];
             }
             if (isset($sortLocale[$i])) {
                 $locale = $sortLocale[$i];
             }
             $va = $a->{$key}[$i];
             $vb = $b->{$key}[$i];
             if ((is_bool($va) || is_numeric($va)) && (is_bool($vb) || is_numeric($vb))) {
                 $cmp = $va - $vb;
             } elseif ($caseSensitive) {
                 $cmp = String::strcmp($va, $vb, $locale);
             } else {
                 $cmp = String::strcasecmp($va, $vb, $locale);
             }
             if ($cmp > 0) {
                 return $direction;
             }
             if ($cmp < 0) {
                 return -$direction;
             }
         }
         return 0;
     });
     return $a;
 }
コード例 #15
0
ファイル: edit.php プロジェクト: Ruud68/Kunena-Forum
										<div>
											<textarea id="user-signature" class="input-xxlarge" name="signature" cols="4" rows="6"
												><?php 
echo $this->escape($this->user->signature);
?>
</textarea>
										</div>
										<div>
											<label><input type="checkbox" value="1" name="deleteSig" /> <?php 
echo JText::_('COM_KUNENA_DELSIG');
?>
											</label>
										</div>
										<div>
											<?php 
echo JText::sprintf('COM_KUNENA_SIGNATURE_LENGTH_COUNTER', intval($this->config->maxsig), '<input id="current_count" class="span1" readonly="readonly" type="text" name="current_count" value="' . (intval($this->config->maxsig) - \Joomla\String\String::strlen($this->user->signature)) . '" />');
?>
										</div>
									</fieldset>
								</div>
								<?php 
/*
	<div class="tab-pane" id="tab2">
		<fieldset>
		<table class="table table-striped">
			<tr>
				<td>Personal Text</td>
				<td><input type="text" maxlength="50" name="personaltext" value="" /></td>
			</tr>
			<tr>
				<td>Birthdate</td>
コード例 #16
0
ファイル: helper.php プロジェクト: andresmaeso/neno
 /**
  * Takes a long string and breaks it into natural chunks and returns an array with the chunks
  * - The method will attempt to break on certain html tags first, then sentence structures and finally spaces if possible
  * - If $string is shorter than $maxChunkLength an array with one entry is returned
  *
  * @param string $string         String to chunk
  * @param int    $maxChunkLength Maximum chunk length
  *
  * @return array
  */
 public static function chunkHTMLString($string, $maxChunkLength)
 {
     $chunks = array();
     //If the given string can fit in the first chunk then just return that
     if (\Joomla\String\String::strlen($string) < $maxChunkLength) {
         $chunks[] = $string;
         return $chunks;
     }
     $cutStrings = array();
     $cutStrings[] = '</div>';
     $cutStrings[] = '</p>';
     $cutStrings[] = '</ul>';
     $cutStrings[] = '</table>';
     $cutStrings[] = '</a>';
     $cutStrings[] = '. ';
     while (\Joomla\String\String::strlen($string) > $maxChunkLength) {
         //Look for the breakpoint that is located last in the substring that is less than max
         $potentialCutPoints = array();
         foreach ($cutStrings as $key => $cutString) {
             $position = strripos(substr($string, 0, $maxChunkLength), $cutString);
             if ($position !== false) {
                 $potentialCutPoints[$position] = $cutString;
             }
         }
         //Select the right most breakpoint
         if (count($potentialCutPoints)) {
             $selectedBreakPoint = max(array_keys($potentialCutPoints));
             $selectedBreakPointString = $potentialCutPoints[$selectedBreakPoint];
             $breakPoint = $selectedBreakPoint + utf8_strlen($selectedBreakPointString);
             //Add the chunk
             $chunks[] = \Joomla\String\String::substr($string, 0, $breakPoint);
         } else {
             //Unable to find a breakpoint, use wordwrap
             $wordWrappedString = wordwrap($string, $maxChunkLength, '|||---NENO---|||', true);
             $wordWrappedArray = explode('|||---NENO---|||', $wordWrappedString);
             $chunks[] = $wordWrappedArray[0];
             $breakPoint = \Joomla\String\String::strlen($wordWrappedArray[0]) + 3;
         }
         //Reduce the string
         $string = \Joomla\String\String::substr($string, $breakPoint);
     }
     //Add the remainder to the last chunk
     $chunks[] = $string;
     return $chunks;
 }
コード例 #17
0
 /**
  * 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;
 }
コード例 #18
0
function kStringURLSafe($str)
{
    return \Joomla\String\String::trim(preg_replace(array('/(\\s|\\xE3\\x80\\x80)+/u', '/[\\$\\&\\+\\,\\/\\:\\;\\=\\?\\@\'\\"\\<\\>\\#\\%\\{\\}\\|\\\\^\\~\\[\\]\\`\\.\\(\\)\\*\\!]/u'), array('-', ''), $str));
}
コード例 #19
0
ファイル: Plugin.php プロジェクト: bharatthakkar/CrowdFunding
 /**
  * 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;
 }
コード例 #20
0
 /**
  * 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');
 }
コード例 #21
0
ファイル: Json.php プロジェクト: grlf/eyedock
 /**
  * Converts an object into a JSON formatted string.
  *
  * @param   object  $object   Data source object.
  * @param   array   $options  Options used by the formatter.
  *
  * @return  string  JSON formatted string.
  *
  * @since   1.0
  */
 public function objectToString($object, $options = array())
 {
     return String::unicode_to_utf8(json_encode($object));
 }
コード例 #22
0
ファイル: categories.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Method to change the title & alias.
  *
  * @param   integer $category_id The id of the category.
  * @param   string  $alias       The alias.
  * @param   string  $name        The name.
  *
  * @return    array  Contains the modified title and alias.
  *
  * @since    2.0.0-BETA2
  */
 protected function _generateNewTitle($category_id, $alias, $name)
 {
     while (KunenaForumCategoryHelper::getAlias($category_id, $alias)) {
         $name = \Joomla\String\String::increment($name);
         $alias = \Joomla\String\String::increment($alias, 'dash');
     }
     return array($name, $alias);
 }
コード例 #23
0
 /**
  * Small helper function to trim UTF-8 encoded strings
  *
  * @param string $utf8string - UTF-8 encoded string
  *
  * @return string - Trimmed UTF-8 encoded string
  */
 private function mb_trim($utf8string)
 {
     return String::trim($utf8string);
 }
コード例 #24
0
ファイル: htraininglog.php プロジェクト: hogeh/htraininglogs
 /**
  * Method to change the title & alias.
  *
  * @param   integer  $category_id  The id of the parent.
  * @param   string   $alias        The alias.
  * @param   string   $name         The title.
  *
  * @return  array  Contains the modified title and alias.
  *
  * @since   3.1
  */
 protected function generateNewTitle($category_id, $alias, $name)
 {
     // Alter the title & alias
     $table = $this->getTable();
     while ($table->load(array('alias' => $alias, 'catid' => $category_id))) {
         if ($name == $table->title) {
             $name = String::increment($name);
         }
         $alias = String::increment($alias, 'dash');
     }
     return array($name, $alias);
 }
コード例 #25
0
 /**
  * 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;
 }
コード例 #26
0
 /**
  * Callback function for sorting an array of objects on a key
  *
  * @param   array  &$a  An array of objects
  * @param   array  &$b  An array of objects
  *
  * @return  integer  Comparison status
  *
  * @see     ArrayHelper::sortObjects()
  * @since   11.1
  */
 protected static function _sortObjects(&$a, &$b)
 {
     $key = self::$sortKey;
     for ($i = 0, $count = count($key); $i < $count; $i++) {
         if (isset(self::$sortDirection[$i])) {
             $direction = self::$sortDirection[$i];
         }
         if (isset(self::$sortCase[$i])) {
             $caseSensitive = self::$sortCase[$i];
         }
         if (isset(self::$sortLocale[$i])) {
             $locale = self::$sortLocale[$i];
         }
         $va = $a->{$key}[$i];
         $vb = $b->{$key}[$i];
         if ((is_bool($va) || is_numeric($va)) && (is_bool($vb) || is_numeric($vb))) {
             $cmp = $va - $vb;
         } elseif ($caseSensitive) {
             $cmp = String::strcmp($va, $vb, $locale);
         } else {
             $cmp = String::strcasecmp($va, $vb, $locale);
         }
         if ($cmp > 0) {
             return $direction;
         }
         if ($cmp < 0) {
             return -$direction;
         }
     }
     return 0;
 }
コード例 #27
0
 /**
  * Return badge description with possibility
  * to replace placeholders with dynamically generated data.
  *
  * <code>
  * $badgeId    = 1;
  * $badge      = new Gamification\Badge\Badge(\JFactory::getDbo());
  *
  * $data = array(
  *     "name" => "John Dow",
  *     "title" => "..."
  * );
  *
  * echo $badge->getDescription($data);
  * </code>
  *
  * @param array $data
  * @return string
  */
 public function getDescription(array $data = array())
 {
     if (!empty($data)) {
         $result = $this->description;
         foreach ($data as $placeholder => $value) {
             $placeholder = "{" . String::strtoupper($placeholder) . "}";
             $result = str_replace($placeholder, $value, $result);
         }
         return $result;
     } else {
         return $this->description;
     }
 }
コード例 #28
0
ファイル: Categories.php プロジェクト: pashakiz/crowdf
 /**
  * Load categories.
  *
  * <code>
  * $parentId = 2;
  *
  * $options = array(
  *    "offset" => 0,
  *    "limit" => 10,
  *    "order_by" => "a.name",
  *    "order_dir" => "DESC",
  * );
  *
  * $categories   = new Crowdfunding\Categories();
  * $categories->setDb(\JFactory::getDbo());
  *
  * $categories->load($parentId);
  * </code>
  * 
  * @param null|int $parentId Parent ID or "root".
  * @param array $options
  */
 public function load($parentId = null, $options = array())
 {
     $offset = isset($options["offset"]) ? $options["offset"] : 0;
     $limit = isset($options["limit"]) ? $options["limit"] : 0;
     $orderBy = isset($options["order_by"]) ? $options["order_by"] : "a.title";
     $orderDir = isset($options["order_dir"]) ? $options["order_dir"] : "ASC";
     $orderDir = String::strtoupper($orderDir);
     if (!in_array($orderDir, array("ASC", "DESC"))) {
         $orderDir = "ASC";
     }
     $query = $this->db->getQuery(true);
     $query->select("a.id, a.title, a.alias, a.description, a.params, " . $query->concatenate(array("a.id", "a.alias"), ":") . " AS slug")->from($this->db->quoteName("#__categories", "a"))->where("a.extension = " . $this->db->quote($this->_extension));
     if (!is_null($parentId)) {
         $query->where("a.parent_id = " . (int) $parentId);
     }
     $query->order($this->db->quoteName($orderBy) . " " . $orderDir);
     $this->db->setQuery($query, (int) $offset, (int) $limit);
     $this->data = (array) $this->db->loadAssocList("id");
 }
コード例 #29
0
ファイル: Inflector.php プロジェクト: SysBind/joomla-cms
 /**
  * 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;
 }
コード例 #30
0
 /**
  * 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;
 }