当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_String::stripPathChars方法代码示例

本文整理汇总了PHP中CRM_Utils_String::stripPathChars方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_String::stripPathChars方法的具体用法?PHP CRM_Utils_String::stripPathChars怎么用?PHP CRM_Utils_String::stripPathChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_String的用法示例。


在下文中一共展示了CRM_Utils_String::stripPathChars方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testStripPathChars

 public function testStripPathChars()
 {
     $testSet = array('' => '', NULL => NULL, 'civicrm' => 'civicrm', 'civicrm/dashboard' => 'civicrm/dashboard', 'civicrm/contribute/transact' => 'civicrm/contribute/transact', 'civicrm/<hack>attempt</hack>' => 'civicrm/_hack_attempt_/hack_', 'civicrm dashboard & force = 1,;' => 'civicrm_dashboard___force___1__');
     foreach ($testSet as $in => $expected) {
         $out = CRM_Utils_String::stripPathChars($in);
         $this->assertEquals($out, $expected, "Output does not match");
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:8,代码来源:StringTest.php

示例2: url

 /**
  * Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)
  *
  * @param $path     string   The path being linked to, such as "civicrm/add"
  * @param $query    string   A query string to append to the link.
  * @param $absolute boolean  Whether to force the output to be an absolute link (beginning with http:).
  *                           Useful for links that will be displayed outside the site, such as in an
  *                           RSS feed.
  * @param $fragment string   A fragment identifier (named anchor) to append to the link.
  * @param $htmlize  boolean  whether to convert to html eqivalant
  * @param $frontend boolean  a gross joomla hack
  *
  * @return string            an HTML string containing a link to the given path.
  * @access public
  *
  */
 function url($path = NULL, $query = NULL, $absolute = FALSE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $script = '';
     $separator = $htmlize ? '&amp;' : '&';
     $pageID = '';
     $path = CRM_Utils_String::stripPathChars($path);
     //this means wp function we are trying to use is not available,
     //so load bootStrap
     if (!function_exists('get_option')) {
         $this->loadBootStrap();
     }
     $permlinkStructure = get_option('permalink_structure');
     if ($config->userFrameworkFrontend) {
         if ($permlinkStructure != '') {
             global $post;
             $script = get_permalink($post->ID);
         }
         // when shortcode is included in page
         // also make sure we have valid query object
         global $wp_query;
         if (method_exists($wp_query, 'get')) {
             if (get_query_var('page_id')) {
                 $pageID = "{$separator}page_id=" . get_query_var('page_id');
             } elseif (get_query_var('p')) {
                 // when shortcode is inserted in post
                 $pageID = "{$separator}p=" . get_query_var('p');
             }
         }
     }
     if (isset($fragment)) {
         $fragment = '#' . $fragment;
     }
     if (!isset($config->useFrameworkRelativeBase)) {
         $base = parse_url($config->userFrameworkBaseURL);
         $config->useFrameworkRelativeBase = $base['path'];
     }
     $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
     if (is_admin() && !$frontend || $forceBackend) {
         $base .= 'wp-admin/admin.php';
     } elseif (defined('CIVICRM_UF_WP_BASEPAGE')) {
         $base .= CIVICRM_UF_WP_BASEPAGE;
     } elseif (isset($config->wpBasePage)) {
         $base .= $config->wpBasePage;
     }
     if (isset($path)) {
         if (isset($query)) {
             if ($permlinkStructure != '' && ($pageID || $script != '')) {
                 return $script . '?page=CiviCRM' . $separator . 'q=' . $path . $pageID . $separator . $query . $fragment;
             } else {
                 return $base . '?page=CiviCRM' . $separator . 'q=' . $path . $pageID . $separator . $query . $fragment;
             }
         } else {
             if ($permlinkStructure != '' && ($pageID || $script != '')) {
                 return $script . '?page=CiviCRM' . $separator . 'q=' . $path . $pageID . $fragment;
             } else {
                 return $base . '?page=CiviCRM' . $separator . 'q=' . $path . $pageID . $fragment;
             }
         }
     } else {
         if (isset($query)) {
             if ($permlinkStructure != '' && ($pageID || $script != '')) {
                 return $script . '?' . $query . $pageID . $fragment;
             } else {
                 return $base . $script . '?' . $query . $pageID . $fragment;
             }
         } else {
             return $base . $fragment;
         }
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:87,代码来源:WordPress.php

示例3: url

 /**
  * Generate an internal CiviCRM URL (copied from DRUPAL/includes/common.inc#url)
  *
  * @param $path     string   The path being linked to, such as "civicrm/add"
  * @param $query    string   A query string to append to the link.
  * @param $absolute boolean  Whether to force the output to be an absolute link (beginning with http:).
  *                           Useful for links that will be displayed outside the site, such as in an
  *                           RSS feed.
  * @param $fragment string   A fragment identifier (named anchor) to append to the link.
  * @param $htmlize  boolean  whether to convert to html eqivalant
  * @param $frontend boolean  a gross joomla hack
  *
  * @return string            an HTML string containing a link to the given path.
  * @access public
  *
  */
 function url($path = NULL, $query = NULL, $absolute = FALSE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $script = 'index.php';
     $path = CRM_Utils_String::stripPathChars($path);
     if (isset($fragment)) {
         $fragment = '#' . $fragment;
     }
     if (!isset($config->useFrameworkRelativeBase)) {
         $base = parse_url($config->userFrameworkBaseURL);
         $config->useFrameworkRelativeBase = $base['path'];
     }
     $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
     $separator = $htmlize ? '&amp;' : '&';
     if (!$config->cleanURL) {
         if (isset($path)) {
             if (isset($query)) {
                 return $base . $script . '?q=' . $path . $separator . $query . $fragment;
             } else {
                 return $base . $script . '?q=' . $path . $fragment;
             }
         } else {
             if (isset($query)) {
                 return $base . $script . '?' . $query . $fragment;
             } else {
                 return $base . $fragment;
             }
         }
     } else {
         if (isset($path)) {
             if (isset($query)) {
                 return $base . $path . '?' . $query . $fragment;
             } else {
                 return $base . $path . $fragment;
             }
         } else {
             if (isset($query)) {
                 return $base . $script . '?' . $query . $fragment;
             } else {
                 return $base . $fragment;
             }
         }
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:60,代码来源:Drupal6.php

示例4: url

 /**
  * @inheritDoc
  */
 public function url($path = NULL, $query = NULL, $absolute = FALSE, $fragment = NULL, $frontend = FALSE, $forceBackend = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $script = '';
     $separator = '&';
     $wpPageParam = '';
     $fragment = isset($fragment) ? '#' . $fragment : '';
     $path = CRM_Utils_String::stripPathChars($path);
     //this means wp function we are trying to use is not available,
     //so load bootStrap
     if (!function_exists('get_option')) {
         $this->loadBootStrap();
         // FIXME: Why bootstrap in url()? Generally want to define 1-2 strategic places to put bootstrap
     }
     if ($config->userFrameworkFrontend) {
         if (get_option('permalink_structure') != '') {
             global $post;
             $script = get_permalink($post->ID);
         }
         // when shortcode is included in page
         // also make sure we have valid query object
         global $wp_query;
         if (method_exists($wp_query, 'get')) {
             if (get_query_var('page_id')) {
                 $wpPageParam = "page_id=" . get_query_var('page_id');
             } elseif (get_query_var('p')) {
                 // when shortcode is inserted in post
                 $wpPageParam = "p=" . get_query_var('p');
             }
         }
     }
     $base = $this->getBaseUrl($absolute, $frontend, $forceBackend);
     if (!isset($path) && !isset($query)) {
         // FIXME: This short-circuited codepath is the same as the general one below, except
         // in that it ignores "permlink_structure" /  $wpPageParam / $script . I don't know
         // why it's different (and I can only find two obvious use-cases for this codepath,
         // of which at least one looks gratuitous). A more ambitious person would simply remove
         // this code.
         return $base . $fragment;
     }
     if (!$forceBackend && get_option('permalink_structure') != '' && ($wpPageParam || $script != '')) {
         $base = $script;
     }
     $queryParts = array();
     if (isset($path)) {
         $queryParts[] = 'page=CiviCRM';
         $queryParts[] = "q={$path}";
     }
     if ($wpPageParam) {
         $queryParts[] = $wpPageParam;
     }
     if (isset($query)) {
         $queryParts[] = $query;
     }
     return $base . '?' . implode($separator, $queryParts) . $fragment;
 }
开发者ID:sarehag,项目名称:civicrm-core,代码行数:59,代码来源:WordPress.php

示例5: url

 /**
  * @inheritDoc
  */
 public function url($path = NULL, $query = NULL, $absolute = FALSE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $separator = $htmlize ? '&amp;' : '&';
     $Itemid = '';
     $script = '';
     $path = CRM_Utils_String::stripPathChars($path);
     if ($config->userFrameworkFrontend) {
         $script = 'index.php';
         if (JRequest::getVar("Itemid")) {
             $Itemid = "{$separator}Itemid=" . JRequest::getVar("Itemid");
         }
     }
     if (isset($fragment)) {
         $fragment = '#' . $fragment;
     }
     $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase;
     if (!empty($query)) {
         $url = "{$base}{$script}?option=com_civicrm{$separator}task={$path}{$Itemid}{$separator}{$query}{$fragment}";
     } else {
         $url = "{$base}{$script}?option=com_civicrm{$separator}task={$path}{$Itemid}{$fragment}";
     }
     // gross hack for joomla, we are in the backend and want to send a frontend url
     if ($frontend && $config->userFramework == 'Joomla') {
         // handle both joomla v1.5 and v1.6, CRM-7939
         $url = str_replace('/administrator/index2.php', '/index.php', $url);
         $url = str_replace('/administrator/index.php', '/index.php', $url);
         // CRM-8215
         $url = str_replace('/administrator/', '/index.php', $url);
     } elseif ($forceBackend) {
         if (defined('JVERSION')) {
             $joomlaVersion = JVERSION;
         } else {
             $jversion = new JVersion();
             $joomlaVersion = $jversion->getShortVersion();
         }
         if (version_compare($joomlaVersion, '1.6') >= 0) {
             $url = str_replace('/index.php', '/administrator/index.php', $url);
         }
     }
     return $url;
 }
开发者ID:nyimbi,项目名称:civicrm-core,代码行数:45,代码来源:Joomla.php


注:本文中的CRM_Utils_String::stripPathChars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。