本文整理匯總了PHP中JApplicationHelper::stringURLSafe方法的典型用法代碼示例。如果您正苦於以下問題:PHP JApplicationHelper::stringURLSafe方法的具體用法?PHP JApplicationHelper::stringURLSafe怎麽用?PHP JApplicationHelper::stringURLSafe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JApplicationHelper
的用法示例。
在下文中一共展示了JApplicationHelper::stringURLSafe方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: check
/**
* Method to perform sanity checks on the JTable instance properties to ensure
* they are safe to store in the database. Child classes should override this
* method to make sure the data they are storing in the database is safe and
* as expected before storage.
*
* @return boolean True if the instance is sane and able to be stored in the database.
*
* @since 2.5
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
if (trim($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');
}
$params = new Registry($this->params);
$nullDate = $this->_db->getNullDate();
$d1 = $params->get('d1', $nullDate);
$d2 = $params->get('d2', $nullDate);
// Check the end date is not earlier than the start date.
if ($d2 > $nullDate && $d2 < $d1) {
// Swap the dates.
$params->set('d1', $d2);
$params->set('d2', $d1);
$this->params = (string) $params;
}
return true;
}
示例2: check
/**
* Overloaded check function
*
* @return boolean
*
* @see JTable::check
* @since 1.5
*/
public function check()
{
// Set name
$this->name = htmlspecialchars_decode($this->name, ENT_QUOTES);
// Set alias
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
if (empty($this->alias)) {
$this->alias = JApplicationHelper::stringURLSafe($this->name);
}
// Check the publish down date is not earlier than publish up.
if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) {
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
// Set ordering
if ($this->state < 0) {
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
} elseif (empty($this->ordering)) {
// Set ordering to last if ordering was 0
$this->ordering = self::getNextOrder($this->_db->quoteName('catid') . '=' . $this->_db->quote($this->catid) . ' AND state>=0');
}
if (empty($this->publish_up)) {
$this->publish_up = $this->getDbo()->getNullDate();
}
if (empty($this->publish_down)) {
$this->publish_down = $this->getDbo()->getNullDate();
}
if (empty($this->modified)) {
$this->modified = $this->getDbo()->getNullDate();
}
return true;
}
示例3: check
/**
* Overloaded check function
*
* @return boolean True on success, false on failure
*
* @see JTable::check()
* @since 11.1
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
$this->menutype = JApplicationHelper::stringURLSafe($this->menutype);
if (empty($this->menutype)) {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENUTYPE_EMPTY'));
return false;
}
// Sanitise data.
if (trim($this->title) == '') {
$this->title = $this->menutype;
}
// Check for unique menutype.
$query = $this->_db->getQuery(true)->select('COUNT(id)')->from($this->_db->quoteName('#__menu_types'))->where($this->_db->quoteName('menutype') . ' = ' . $this->_db->quote($this->menutype))->where($this->_db->quoteName('id') . ' <> ' . (int) $this->id);
$this->_db->setQuery($query);
if ($this->_db->loadResult()) {
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENUTYPE_EXISTS', $this->menutype));
return false;
}
return true;
}
示例4: store
public function store($updateNulls = false)
{
$isNew = false;
if (!$this->id) {
// New document
$this->downloaded = 0;
$isNew = true;
}
if (isset($this->alias) && isset($this->name) && $this->alias == "") {
$this->alias = preg_replace("/ /", "-", strtolower($this->name));
}
if (version_compare(JVERSION, '3.0', '>=')) {
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
} else {
$this->alias = JApplication::stringURLSafe($this->alias);
}
// Trigger events to osdownloads plugins
$dispatcher = $this->getDispatcher();
$pluginResults = $dispatcher->trigger('onOSDownloadsBeforeSaveFile', array(&$this, $isNew));
$result = false;
if ($pluginResults !== false) {
$result = parent::store($updateNulls);
$dispatcher->trigger('onOSDownloadsAfterSaveFile', array($result, &$this));
}
return $result;
}
示例5: getData
/**
* @see https://www.warcraftlogs.com/v1/docs#!/Reports/
* @throws RuntimeException
*
* @return stdClass
*/
public function getData($api_key)
{
$uri = new JUri();
$this->params->set('realm', str_replace("'", '', $this->params->get('realm')));
$this->params->set('guild', str_replace(' ', '+', $this->params->get('guild')));
$uri->setPath('/v1/reports/guild/' . $this->params->get('guild') . '/' . JApplicationHelper::stringURLSafe($this->params->get('realm')) . '/' . $this->params->get('region'));
$uri->setVar('api_key', $api_key);
return $this->getRemote($uri);
}
示例6: toSlug
/**
* Convert a string into a slug (alias), suitable for use in URLs. Please
* note that transliteration support is rudimentary at this stage.
*
* @param string $value A string to convert to slug
*
* @return string The slug
*
* @deprecated 3.0 Use \JApplicationHelper::stringURLSafe instead
*
* @codeCoverageIgnore
*/
public static function toSlug($value)
{
if (class_exists('\\JLog')) {
\JLog::add('FOF30\\Utils\\String::toSlug is deprecated. Use \\JApplicationHelper::stringURLSafe instead', \JLog::WARNING, 'deprecated');
}
if (!class_exists('\\JApplicationHelper')) {
\JLoader::import('cms.application.helper');
}
return \JApplicationHelper::stringURLSafe($value);
}
示例7: check
public function check()
{
if (trim($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');
}
return true;
}
示例8: getData
/**
* @return mixed
*/
public function getData()
{
$this->url = 'http://guildox.com/api/guild/' . $this->params->get('region') . '/' . JApplicationHelper::stringURLSafe($this->params->get('realm')) . '/' . $this->params->get('guild');
$result = $this->getRemote($this->url);
$result->body = json_decode($result->body);
if ($result->code != 200) {
$msg = JText::sprintf('Server Error: %s', JHtml::_('link', $this->url, $result->code, array('target' => '_blank')));
throw new RuntimeException($msg);
}
return $result;
}
示例9: getData
/**
* @return mixed
*/
public function getData()
{
$this->url = 'http://www.wowprogress.com/guild/' . $this->params->get('region') . '/' . JApplicationHelper::stringURLSafe($this->params->get('realm')) . '/' . $this->params->get('guild') . '/json_rank';
$result = $this->getRemote($this->url);
$result->body = json_decode($result->body);
if (empty($result->body) || $result->code != 200) {
$msg = JText::sprintf('invalid response: %s', JHtml::_('link', $this->url, $result->code, array('target' => '_blank')));
throw new RuntimeException($msg);
}
return $result;
}
示例10: check
/**
* Overloaded check method to ensure data integrity.
*
* @return boolean True on success.
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Check for valid name.
if (trim($this->name) == '') {
$this->setError(JText::_('COM_NEWSFEEDS_WARNING_PROVIDE_VALID_NAME'));
return false;
}
if (empty($this->alias)) {
$this->alias = $this->name;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
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 ((int) $this->publish_down > 0 && $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 not empty
if (!empty($this->metakey)) {
// Array of characters to remove
$bad_characters = array("\n", "\r", "\"", "<", ">");
// Remove bad characters
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
// Create array using commas as delimiter
$keys = explode(',', $after_clean);
$clean_keys = array();
foreach ($keys as $key) {
if (trim($key)) {
// Ignore blank keywords
$clean_keys[] = trim($key);
}
}
// Put array back together delimited by ", "
$this->metakey = implode(", ", $clean_keys);
}
// Clean up description -- eliminate quotes and <> brackets
if (!empty($this->metadesc)) {
// Only process if not empty
$bad_characters = array("\"", "<", ">");
$this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
}
return true;
}
示例11: check
/**
* Overloaded check function
*
* @return boolean True on success, false on failure
*
* @see JTable::check()
* @since 3.1
*/
public function check()
{
if (trim($this->core_title) == '') {
$this->setError(JText::_('JLIB_CMS_WARNING_PROVIDE_VALID_NAME'));
return false;
}
if (trim($this->core_alias) == '') {
$this->core_alias = $this->core_title;
}
$this->core_alias = JApplicationHelper::stringURLSafe($this->core_alias);
if (trim(str_replace('-', '', $this->core_alias)) == '') {
$this->core_alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
// Not Null sanity check
if (empty($this->core_images)) {
$this->core_images = '{}';
}
if (empty($this->core_urls)) {
$this->core_urls = '{}';
}
// Check the publish down date is not earlier than publish up.
if ($this->core_publish_down > $this->_db->getNullDate() && $this->core_publish_down < $this->core_publish_up) {
// Swap the dates.
$temp = $this->core_publish_up;
$this->core_publish_up = $this->core_publish_down;
$this->core_publish_down = $temp;
}
// Clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->core_metakey)) {
// Only process if not empty
// Array of characters to remove
$bad_characters = array("\n", "\r", "\"", "<", ">");
// Remove bad characters
$after_clean = StringHelper::str_ireplace($bad_characters, "", $this->core_metakey);
// Create array using commas as delimiter
$keys = explode(',', $after_clean);
$clean_keys = array();
foreach ($keys as $key) {
if (trim($key)) {
// Ignore blank keywords
$clean_keys[] = trim($key);
}
}
// Put array back together delimited by ", "
$this->core_metakey = implode(", ", $clean_keys);
}
return true;
}
示例12: getComponentsWithConfig
/**
* Returns an array of all components with configuration options.
* Optionally return only those components for which the current user has 'core.manage' rights.
*
* @param boolean $authCheck True to restrict to components where current user has 'core.manage' rights.
*
* @return array
*
* @since 3.0
*/
public static function getComponentsWithConfig($authCheck = true)
{
$result = array();
$components = self::getAllComponents();
$user = JFactory::getUser();
// Remove com_config from the array as that may have weird side effects
$components = array_diff($components, array('com_config'));
foreach ($components as $component) {
if (self::hasComponentConfig($component) && (!$authCheck || $user->authorise('core.manage', $component))) {
self::loadLanguageForComponent($component);
$result[$component] = JApplicationHelper::stringURLSafe(JText::_($component)) . '_' . $component;
}
}
asort($result);
return array_keys($result);
}
示例13: check
/**
* Overrides the automated table checks to handle the 'hash' column for faster searching
*
* @return $this|DataModel
*/
public function check()
{
// Create a slug if there is a title and an empty slug
if ($this->hasField('title') && $this->hasField('slug') && !$this->slug) {
$this->slug = \JApplicationHelper::stringURLSafe($this->title);
}
// Create the SHA-1 hash of the slug for faster searching (make sure the hash column is CHAR(64) to take
// advantage of MySQL's optimised searching for fixed size CHAR columns)
if ($this->hasField('hash') && $this->hasField('slug')) {
$this->hash = sha1($this->slug);
}
// Reset cached values
$this->resetTreeCache();
// Run the parent checks
parent::check();
return $this;
}
示例14: check
/**
* Method to perform sanity checks on the JTable instance properties to ensure
* they are safe to store in the database. Child classes should override this
* method to make sure the data they are storing in the database is safe and
* as expected before storage.
*
* @return boolean True if the instance is sane and able to be stored in the database.
*
* @since 2.5
*/
public function check()
{
if (trim($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 end date is not earlier than start up.
if ($this->d2 > $this->_db->getNullDate() && $this->d2 < $this->d1) {
// Swap the dates.
$temp = $this->d1;
$this->d1 = $this->d2;
$this->d2 = $temp;
}
return true;
}
示例15: check
/**
* Overloaded check function
*
* @return boolean
*
* @see JTable::check
* @since 1.5
*/
public function check()
{
try {
parent::check();
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
// Set name
$this->name = htmlspecialchars_decode($this->name, ENT_QUOTES);
// Set alias
if (trim($this->alias) == '') {
$this->alias = $this->name;
}
$this->alias = JApplicationHelper::stringURLSafe($this->alias, $this->language);
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 > $this->_db->getNullDate() && $this->publish_down < $this->publish_up) {
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
// Set ordering
if ($this->state < 0) {
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
} elseif (empty($this->ordering)) {
// Set ordering to last if ordering was 0
$this->ordering = self::getNextOrder($this->_db->quoteName('catid') . '=' . $this->_db->quote($this->catid) . ' AND state>=0');
}
if (empty($this->publish_up)) {
$this->publish_up = $this->getDbo()->getNullDate();
}
if (empty($this->publish_down)) {
$this->publish_down = $this->getDbo()->getNullDate();
}
if (empty($this->modified)) {
$this->modified = $this->getDbo()->getNullDate();
}
return true;
}