本文整理汇总了PHP中str_replace_once函数的典型用法代码示例。如果您正苦于以下问题:PHP str_replace_once函数的具体用法?PHP str_replace_once怎么用?PHP str_replace_once使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_replace_once函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: beforeDispatch
/**
* Prepares the default language to use by the script.
*
* ### Detection Methods
*
* This method applies the following detection methods when looking for
* language to use:
*
* - GET parameter: If `locale` GET parameter is present in current request, and
* if it's a valid language code, then will be used as current language and
* also will be persisted on `locale` session for further use.
*
* - URL: If current URL is prefixed with a valid language code and
* `url_locale_prefix` option is enabled, URL's language code will be used.
*
* - Locale session: If `locale` session exists it will be used.
*
* - User session: If user is logged in and has selected a valid preferred
* language it will be used.
*
* - Default: Site's language will be used otherwise.
*
* ### Locale Prefix
*
* If `url_locale_prefix` option is enabled, and current request's URL is not
* language prefixed, user will be redirected to a locale-prefixed version of
* the requested URL (using the language code selected as explained above).
*
* For example:
*
* /article/demo-article.html
*
* Might redirects to:
*
* /en_US/article/demo-article.html
*
* @param \Cake\Event\Event $event containing the request, response and
* additional parameters
* @return void
* @throws \Cake\Network\Exception\InternalErrorException When no valid request
* object could be found
*/
public function beforeDispatch(Event $event)
{
parent::beforeDispatch($event);
$request = Router::getRequest();
if (empty($request)) {
throw new InternalErrorException(__d('cms', 'No request object could be found.'));
}
$locales = array_keys(quickapps('languages'));
$localesPattern = '(' . implode('|', array_map('preg_quote', $locales)) . ')';
$rawUrl = str_replace_once($request->base, '', env('REQUEST_URI'));
$normalizedURL = str_replace('//', '/', "/{$rawUrl}");
if (!empty($request->query['locale']) && in_array($request->query['locale'], $locales)) {
$request->session()->write('locale', $request->query['locale']);
I18n::locale($request->session()->read('locale'));
} elseif (option('url_locale_prefix') && preg_match("/\\/{$localesPattern}\\//", $normalizedURL, $matches)) {
I18n::locale($matches[1]);
} elseif ($request->session()->check('locale') && in_array($request->session()->read('locale'), $locales)) {
I18n::locale($request->session()->read('locale'));
} elseif ($request->is('userLoggedIn') && in_array(user()->locale, $locales)) {
I18n::locale(user()->locale);
} elseif (in_array(option('default_language'), $locales)) {
I18n::locale(option('default_language'));
} else {
I18n::locale(CORE_LOCALE);
}
if (option('url_locale_prefix') && !$request->is('home') && !preg_match("/\\/{$localesPattern}\\//", $normalizedURL)) {
$url = Router::url('/' . I18n::locale() . $normalizedURL, true);
http_response_code(303);
header("Location: {$url}");
die;
}
}
开发者ID:quickapps-plugins,项目名称:cms,代码行数:74,代码来源:LanguageFilter.php
示例2: pluginFile
/**
* Returns the given plugin's file within webroot directory.
*
* @return void
*/
public function pluginFile()
{
if (!empty($this->request->query['file'])) {
$path = $this->request->query['file'];
$path = str_replace_once('#', '', $path);
$file = str_replace('//', '/', ROOT . "/plugins/{$path}");
if ((strpos($file, 'webroot') !== false || strpos($file, '.tmb') !== false) && file_exists($file)) {
$this->response->file($file);
return $this->response;
}
}
die;
}
开发者ID:quickapps-plugins,项目名称:media-manager,代码行数:18,代码来源:ExplorerController.php
示例3: gk_title
/**
*
* Function used to generate the template full title
*
* @return null
*
**/
function gk_title()
{
// The $paged global variable contains the page number of a listing of posts.
// The $page global variable contains the page number of a single post that is paged.
// We'll display whichever one applies, if we're not looking at the first page.
global $paged, $page;
// access to the template object
global $tpl;
// check if the page is a search result
if (is_search()) {
// If we're a search, let's start over:
$title = sprintf(__('Search results for %s', GKTPLNAME), '"' . get_search_query() . '"');
// Add a page number if we're on page 2 or more:
if ($paged >= 2) {
$title .= " " . sprintf(__('Page %s', GKTPLNAME), $paged);
}
// return the title
echo $title;
}
// if user enabled our SEO override
if (get_option($tpl->name . '_seo_use_gk_seo_settings') == 'Y') {
// get values from panel if enabled
$blogname = get_option($tpl->name . '_seo_blogname');
$desc = get_option($tpl->name . '_seo_description');
// create the first part of the title
$prepared = str_replace_once(get_bloginfo('name', 'Display'), '', wp_title('', false));
$title = is_front_page() ? $desc : $prepared;
// return first part with site name without space characters at beginning
echo ltrim($title);
// if showing blogname in title is enabled - show second part
if (get_option($tpl->name . '_seo_use_blogname_in_title') == 'Y') {
// separator defined by user (from recommended list): '|', ',', '-', ' '
echo ' ' . get_option($tpl->name . '_seo_separator_in_title') . ' ';
echo $blogname;
}
} else {
// in other case
// return the standard title
if (is_home()) {
bloginfo('name');
echo ' » ';
bloginfo('description');
} else {
wp_title('|', true, 'right');
}
}
}
开发者ID:piotrkunicki,项目名称:MeetGavernWP-Test,代码行数:54,代码来源:helpers.layout.php
示例4: get_external_post_url
function get_external_post_url($my_permalink){
global $app_url;
// code to get the url of the orginal post for use in the "show external url view"
$permalink_peices = parse_url($my_permalink);
//get the app_url and the preceeding slash
$permalink_app_url = "/". $app_url;
//remove /appname
$external_post_permalink = str_replace_once($permalink_app_url,"",$permalink_peices[path]);
//re-write the post url using the site url
$external_site_url_peices = parse_url(get_bloginfo('wpurl'));
//break apart the external site address and get just the "site.com" part
$external_site_url = $external_site_url_peices[host];
$external_post_url = get_bloginfo('siteurl'). $external_post_permalink;
//return "app url is " . $app_url;
return $external_post_url;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:18,代码来源:config.php
示例5: __construct
/**
* GET REQUEST URI and extract Controller, action and params
*
* @return Request
*/
function __construct()
{
$RR = str_replace('%20', ' ', $_SERVER['REQUEST_URI']);
if (!strcasecmp($_SERVER['REQUEST_METHOD'], 'POST')) {
$this->post_params =& $_POST;
} else {
$this->get_params =& $_GET;
}
if (INSTALL_DIR == '') {
$this->_request = explode('/', str_replace_once('/', '', $RR));
} else {
$this->_request = explode('/', str_replace_once(INSTALL_DIR . '/', '', $RR));
}
$this->_rurl = $_SERVER['SERVER_NAME'];
if (SERVER_NAME != $_SERVER['SERVER_NAME']) {
$this->_segment = str_replace('.' . SERVER_NAME, '', $_SERVER['SERVER_NAME']);
}
$size = count($this->_request) - 3;
$this->_request['action'] = '';
if (isset($this->_request[2])) {
$this->_request['action'] = $this->_request[2];
}
$this->_request['c'] = $this->_request[1];
if ($this->_segment == '') {
if ($this->_request['c'] == '') {
$this->_request['c'] = DEFAULT_CONTROLLER;
}
} else {
if ($this->_request['c'] == '') {
$this->_request['c'] = SHOP_CONTROLLER;
}
}
if ($this->_request['action'] == '') {
$this->_request['action'] = DEFAULT_ACTION;
}
for ($i = 0; $i < $size; $i++) {
$this->_params[] = $this->_request[$i + 3];
}
///$this->_request['PATH_INFO'] = $_SERVER['PATH_INFO'];
// if (! get_magic_quotes_gpc()) {
// $this->removeSlashes($this->_request);
//}
}
开发者ID:kodi,项目名称:dpls-framework,代码行数:48,代码来源:Request.php
示例6: format_address_for_selector
function format_address_for_selector($fields)
{
if (empty($fields)) {
return;
}
// Default format
//$default = "{firstname} {lastname}\n{address_1}\n{address_2}\n{province}, {city} {postcode}";
$default = "{firstname} {lastname}\n{address_1}\n{address_2}\n{province}, {postcode}";
// Fetch country record to determine which format to use
$CI =& get_instance();
//$CI->load->model('location_model');
//$c_data = $CI->location_model->get_country($fields['country_id']);
//if(empty($c_data->address_format))
//{
$formatted = $default;
//} else {
// $formatted = $c_data->address_format;
//}
$formatted = str_replace('{firstname}', $fields['firstname'], $formatted);
$formatted = str_replace('{lastname}', $fields['lastname'], $formatted);
//$formatted = str_replace('{company}', $fields['company'], $formatted);
$formatted = str_replace('{address_1}', $fields['address1'], $formatted);
$formatted = str_replace('{address_2}', $fields['address2'], $formatted);
$formatted = str_replace('{province}', $fields['province'], $formatted);
//$formatted = str_replace('{city}', $fields['city'], $formatted);
//$formatted = str_replace('{city}', $fields['city'], $formatted);
//$formatted = str_replace('{zone}', $fields['zone'], $formatted);
$formatted = str_replace('{postcode}', $fields['zip'], $formatted);
//$formatted = str_replace('{country}', $fields['country'], $formatted);
// tack on the phone number
$formatted .= "\n" . '(' . $fields['phone'] . ')';
// remove any extra new lines resulting from blank company or address line
$formatted = preg_replace('`[\\r\\n]+`', "\n", $formatted);
// take out the last newline character, but only the last one
// (I don't like all this reversing, unreversing, but if you can find a better way to replace right-to-left, let me know)
$formatted = strrev($formatted);
$formatted = str_replace_once("\n", ' ', $formatted);
$formatted = strrev($formatted);
// convert new lines to pipe char
$formatted = str_replace("\n", ' | ', $formatted);
return $formatted;
}
开发者ID:jonyhandoko,项目名称:khayana,代码行数:42,代码来源:formatting_helper.php
示例7: hasNoCompositeRelatives
private static function hasNoCompositeRelatives(Wallop $compObj, $compColumn, $thisRelationTable, $thisId, $thisColumn, array $compIds = null)
{
global $database;
// Initialize the list of ids and the inList
$ids = array();
$inList = '(';
if (isset($compIds)) {
if (empty($compIds)) {
return array();
}
foreach ($compIds as $compId) {
$ids[$compId] = true;
$inList .= $compId . ',';
}
$inList = trim($inList, ',') . ')';
} else {
// If compIds is not set then query from the database the ids
$query = "SELECT `{$compColumn}` FROM `{$thisRelationTable}` ";
$query .= "WHERE `{$thisColumn}` = {$thisId}";
$result = $database->execQuery($query);
if (!$result) {
$staticError = 'Failed to retrieve records of this composite (`' . $thisRelationTable . '`) ';
$staticError .= 'This was likely due to a mismatch between the database structure and the ';
$staticError .= 'columns and/or table name you specified in the constructor of this object!';
self::$staticErrors[] = $staticError;
return false;
}
$rows = $database->getAllRows();
// Returned an empty result set
// Just finish the function and return an empty array
if (!$rows || empty($rows)) {
return array();
}
$i = 0;
$numRows = count($rows);
while ($i != $numRows) {
$row = $rows[$i];
$ids[$row[$compColumn]] = true;
$inList .= $row[$compColumn] . ',';
++$i;
}
$inList = trim($inList, ',') . ')';
unset($rows);
}
// Foreach relation of this composite remove keys from the master array for composites that
// only have any other composite relations to them
$compRelationTypes = array(&$compObj->aggregates, &$compObj->composites);
foreach ($compRelationTypes as $compRelationType) {
foreach ($compRelationType as $compRelationTableName => $compRelation) {
$compRelationData = $compObj->findRelationData($compRelationTableName);
// If this relation has the composite also as a composite relation
$compRelationObj = new $compRelationData['className']();
if (isset($compRelationObj->composites[$thisRelationTable])) {
// Generate relation columns
$relationColumns = $compRelationObj->generateRelationColumns($compRelationTableName, $compObj);
if (!$relationColumns) {
end($compRelationObj->errors);
self::$staticErrors[] = $compRelationObj->errors[key($compRelationObj->errors)];
return false;
}
$compRelationColumn = $relationColumns['this'];
$secondCompColumn = $relationColumns['relative'];
$query = "SELECT `{$secondCompColumn}` ";
$query .= "FROM `{$compRelationTableName}` ";
$query .= "WHERE `{$secondCompColumn}` IN {$inList}";
// Add a claus to not
if ($thisRelationTable == $compRelationTableName) {
$query .= " AND `{$compRelationColumn}` != {$thisId}";
}
$result = $database->execQuery($query);
if (!$result) {
$staticError = 'Failed to retrieve records of this composite (`';
$staticError .= $thisRelationTable . '`) This was likely due to a mismatch between ';
$staticError .= 'the database structure and the columns and/or table name you ';
$staticError .= 'specified in the constructor of this object!';
self::$staticErrors[] = $staticError;
return false;
}
$rows = $database->getAllRows();
$rowId = 0;
$numRows = count($rows);
while ($rowId != $numRows) {
$id = $rows[$rowId][$secondCompColumn];
unset($ids[$id]);
$inList = str_replace_once(',' . $id . ',', ',', $inList, $found);
if (!$found) {
unset($found);
$inList = str_replace_once('(' . $id . ',', '(', $inList, $found);
if (!$found) {
$inList = str_replace_once(',' . $id . ')', ')', $inList);
}
}
++$rowId;
}
}
}
}
$outputArray = array();
foreach ($ids as $id => $unused) {
$outputArray[] = $id;
//.........这里部分代码省略.........
开发者ID:Rybadour,项目名称:Wallop,代码行数:101,代码来源:Wallop_0.2.0.php
示例8: debug_highlight
function debug_highlight($html)
{
return $html;
$h = " " . $html;
$p = 0;
$state = false;
while (true) {
if ($state == "text") {
if ($p2 = strpos($h, "'", $p)) {
$h = str_replace_once("'", "'" . '</span>', $h, $p);
$p = $p2 + 13;
$state = false;
} else {
break;
}
} else {
if ($p2 = strpos($h, "'", $p)) {
$h = str_replace_once("'", "<span class='debug_text'>" . "'", $h, $p);
$p = $p2 + 26;
$state = "text";
} else {
break;
}
}
}
if ($state) {
$h .= '</span>';
}
$p = 0;
$state = false;
while (true) {
if ($state == "text") {
if ($p2 = strpos($h, ''', $p)) {
$h = str_replace_once(''', ''</span>', $h, $p);
$p = $p2 + 13;
$state = false;
} else {
break;
}
} else {
if ($p2 = strpos($h, ''', $p)) {
$h = str_replace_once(''', "<span class='debug_text'>" . ''', $h, $p);
$p = $p2 + 26;
$state = "text";
} else {
break;
}
}
}
if ($state) {
$h .= '</span>';
}
$p = 0;
$state = false;
while (true) {
if ($state == "text") {
if ($p2 = strpos($h, '"', $p)) {
$h = str_replace_once('"', '"</span>', $h, $p);
$p = $p2 + 13;
$state = false;
} else {
break;
}
} else {
if ($p2 = strpos($h, '"', $p)) {
$h = str_replace_once('"', "<span class='debug_text'>" . '"', $h, $p);
$p = $p2 + 26;
$state = "text";
} else {
break;
}
}
}
if ($state) {
$h .= '</span>';
}
$p = 0;
$state = false;
while (true) {
if ($state == "tag") {
if (($p2 = strpos($h, ">", $p)) !== false) {
$h = str_replace_once(">", "></span>", $h, $p);
$p = $p2 + 11;
$state = false;
} else {
break;
}
} else {
if (($p2 = strpos($h, "<", $p)) !== false) {
$h = str_replace_once("<", "<span class='debug_tag'><", $h, $p);
$p = $p2 + 28;
$state = "tag";
} else {
break;
}
}
}
if ($state) {
$h .= '</span>';
}
//.........这里部分代码省略.........
开发者ID:MaxD2,项目名称:ParseMX-Library,代码行数:101,代码来源:parsemx.php
示例9: configure
/**
* Handles a single field instance configuration parameters.
*
* In FormHelper, all fields prefixed with `_` will be considered as columns
* values of the instance being edited. Any other input element will be
* considered as part of the `settings` column.
*
* For example: `_label`, `_required` and `description` maps to `label`,
* `required` and `description`. And `some_input`, `another_input` maps to
* `settings.some_input`, `settings.another_input`
*
* @param int $id The field instance ID to manage
* @return void
* @throws \Cake\ORM\Exception\RecordNotFoundException When no field instance
* was found
*/
public function configure($id)
{
$instance = $this->_getOrThrow($id, ['locked' => false]);
$arrayContext = ['schema' => [], 'defaults' => [], 'errors' => []];
if ($this->request->data()) {
$instance->accessible('*', true);
$instance->accessible(['id', 'eav_attribute', 'handler', 'ordering'], false);
foreach ($this->request->data as $k => $v) {
if (str_starts_with($k, '_')) {
$instance->set(str_replace_once('_', '', $k), $v);
unset($this->request->data[$k]);
}
}
$validator = $this->FieldInstances->validator('settings');
$instance->validateSettings($this->request->data(), $validator);
$errors = $validator->errors($this->request->data(), false);
if (empty($errors)) {
$instance->set('settings', $this->request->data());
$save = $this->FieldInstances->save($instance);
if ($save) {
$this->Flash->success(__d('field', 'Field information was saved.'));
$this->redirect($this->referer());
} else {
$this->Flash->danger(__d('field', 'Your information could not be saved.'));
}
} else {
$this->Flash->danger(__d('field', 'Field settings could not be saved.'));
foreach ($errors as $field => $message) {
$arrayContext['errors'][$field] = $message;
}
}
} else {
$arrayContext['defaults'] = (array) $instance->settings;
$this->request->data = $arrayContext['defaults'];
}
$this->title(__d('field', 'Configure Field'));
$this->set(compact('arrayContext', 'instance'));
}
开发者ID:quickapps-plugins,项目名称:field,代码行数:54,代码来源:FieldUIControllerTrait.php
示例10: function
* Checks if page being rendered is the dashboard.
*
* $request->isDashboard();
*/
Request::addDetector('dashboard', function ($request) {
return !empty($request->params['plugin']) && strtolower($request->params['plugin']) === 'system' && !empty($request->params['controller']) && strtolower($request->params['controller']) === 'dashboard' && !empty($request->params['action']) && strtolower($request->params['action']) === 'index';
});
/**
* Checks if current URL is language prefixed.
*
* $request->isLocalized();
*/
Request::addDetector('localized', function ($request) {
$locales = array_keys(quickapps('languages'));
$localesPattern = '(' . implode('|', array_map('preg_quote', $locales)) . ')';
$url = str_starts_with($request->url, '/') ? str_replace_once('/', '', $request->url) : $request->url;
return preg_match("/^{$localesPattern}\\//", $url);
});
/**
* Checks if visitor user is logged in.
*
* $request->isUserLoggedIn();
*/
Request::addDetector('userLoggedIn', function ($request) {
$sessionExists = $request->session()->check('Auth.User.id');
$sessionContent = $request->session()->read('Auth.User.id');
return $sessionExists && !empty($sessionContent);
});
/**
* Checks if visitor user is logged in and has administrator privileges.
*
开发者ID:quickapps-plugins,项目名称:system,代码行数:31,代码来源:bootstrap.php
示例11: testStrReplaceOnce
public function testStrReplaceOnce()
{
$str = "one one";
$this->assertEquals(str_replace_once("one", "two", $str), "two one");
$this->assertEquals(str_replace_once("three", "two", $str), "one one");
$this->assertEquals(str_replace_once("", "two", $str), "one one");
$this->assertEquals(str_replace_once("one", "", $str), " one");
}
开发者ID:ejz,项目名称:core,代码行数:8,代码来源:CoreTest.php
示例12: get_external_post_url
function get_external_post_url($my_permalink)
{
$my_options = wpbook_getAdminOptions();
$app_url = $my_options['fb_app_url'];
// code to get the url of the orginal post for use in the "show external url view"
$permalink_pieces = parse_url($my_permalink);
//get the app_url and the preceeding slash
$permalink_app_url = "/" . $app_url;
//remove /appname
$external_post_permalink = str_replace_once($permalink_app_url, "", $permalink_pieces[path]);
//re-write the post url using the site url
$external_site_url_pieces = parse_url(get_bloginfo('wpurl'));
//break apart the external site address and get just the "site.com" part
$external_site_url = $external_site_url_pieces[host];
$external_post_url = get_bloginfo('siteurl') . $external_post_permalink;
if (!empty($permalink_pieces[query])) {
$external_post_url = $external_post_url . '?' . $permalink_pieces[query];
}
//return "app url is " . $app_url;
return $external_post_url;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:21,代码来源:wpbook.php
示例13: DBUpdate
public function DBUpdate($tableValue, $obj, $condition, $conditionValues = null)
{
if (!contains($tableValue, "`")) {
$tableValue = '`' . $tableValue . '`';
}
$sql = " update {$tableValue} SET ";
foreach ($obj as $key => $value) {
$sql .= " `{$key}`=";
$type = gettype($value);
switch ($type) {
case "boolean":
$sql .= "'" . ($value ? "true" : "false") . "',";
break;
case "integer":
$sql .= $value . ",";
break;
case "double":
$sql .= $value . ",";
break;
case "NULL":
$sql .= "null,";
break;
case "string":
if (strtolower($value) == "now()") {
$sql .= "now(),";
} else {
$sql .= "'" . myStrEscape($value) . "',";
}
break;
default:
throw new Exception("unknown type:" . $type . " of value:" . $value . " key:" . $key);
break;
}
}
$sql = substr($sql, 0, -1);
$count = substr_count($condition, "?");
$count2 = count($conditionValues);
if ($count != $count2) {
throw new Exception("sql:{$condition} need {$count} values but get {$count2} !");
}
$i = 0;
$index = 0;
for (; $i < $count; $i++) {
$value = $conditionValues[$i];
$type = gettype($value);
switch ($type) {
case "boolean":
$value = $value ? "true" : "false";
break;
case "integer":
case "NULL":
case "double":
break;
case "string":
$value = myStrEscape($value);
break;
default:
throw new Exception("unknown type:" . $type . " of value:" . $value);
break;
}
$condition = str_replace_once($condition, "?", $value);
}
if ($condition != "" && trim($condition) != "") {
$sql .= " where " . $condition;
}
$this->dbSQL = $sql;
$this->DBExecute($this->dbSQL);
}
开发者ID:hxghxg527,项目名称:FamilyDecoration,代码行数:68,代码来源:mysql.class.php
示例14: basicRBsearch
function basicRBsearch($module, $search_field, $search_string)
{
global $log;
$log->debug("Entering basicRBsearch(" . $module . "," . $search_field . "," . $search_string . ") method ...");
global $adb;
global $rb_column_array, $rb_table_col_array;
if ($search_field == 'crmid') {
$column_name = 'crmid';
$table_name = 'vtiger_entity';
$where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
} else {
//Check added for tickets by accounts/contacts in dashboard
$search_field_first = $search_field;
if ($module == 'HelpDesk' && ($search_field == 'contactid' || $search_field == 'account_id')) {
$search_field = "parent_id";
}
//Check ends
$tabid = getTabid($module);
$qry = "select vtiger_field.columnname,tablename from vtiger_field where tabid=? and (fieldname=? or columnname=?) and vtiger_field.presence in (0,2)";
$result = $adb->pquery($qry, array($tabid, $search_field, $search_field));
$noofrows = $adb->num_rows($result);
if ($noofrows != 0) {
$column_name = $adb->query_result($result, 0, 'columnname');
//Check added for tickets by accounts/contacts in dashboard
if ($column_name == 'parent_id') {
if ($search_field_first == 'account_id') {
$search_field_first = 'accountid';
}
if ($search_field_first == 'contactid') {
$search_field_first = 'contact_id';
}
$column_name = $search_field_first;
}
//Check ends
$table_name = $adb->query_result($result, 0, 'tablename');
if ($table_name == "vtiger_crmentity" && $column_name == "smownerid") {
$where = get_usersid($table_name, $column_name, $search_string);
} elseif ($table_name == "vtiger_activity" && $column_name == "status") {
$where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "'";
} elseif ($table_name == "vtiger_pricebook" && $column_name == "active") {
if (stristr('yes', $search_string)) {
$where = "{$table_name}.{$column_name} = 1";
} else {
if (stristr('no', $search_string)) {
$where = "{$table_name}.{$column_name} is NULL";
} else {
//here where condition is added , since the $where query must go as differently so that it must give an empty set, either than Yes or No...
$where = "{$table_name}.{$column_name} = 2";
}
}
} elseif ($table_name == "vtiger_activity" && $column_name == "status") {
$where = "{$table_name}.{$column_name} like '%" . $search_string . "%' or vtiger_activity.eventstatus like '" . formatForSqlLike($search_string) . "'";
}
$sql = "select concat(tablename,':',fieldname) as tablename from vtiger_entityname where entityidfield='{$column_name}' or entityidcolumn='{$column_name}'";
$no_of_rows = $adb->num_rows($adb->query($sql));
if ($no_of_rows >= 1) {
$where = getValuesforRBColumns($column_name, $search_string);
} else {
if (($column_name != "status" || $table_name != 'vtiger_activity') && ($table_name != 'vtiger_crmentity' || $column_name != 'smownerid') && ($table_name != 'vtiger_pricebook' || $column_name != 'active')) {
$tableName = explode(":", $table_name);
$where = "{$table_name}.{$column_name} like '" . formatForSqlLike($search_string) . "'";
}
}
}
}
if ($_REQUEST['type'] == 'entchar') {
$search = array('Un Assigned', '%', 'like');
$replace = array('', '', '=');
$where = str_replace($search, $replace, $where);
}
if ($_REQUEST['type'] == 'alpbt') {
$where = str_replace_once("%", "", $where);
}
$log->debug("Exiting basicRBsearch method ...");
return $where;
}
开发者ID:vtiger-jp,项目名称:vtigercrm-5.1.x-ja,代码行数:76,代码来源:RecycleBinUtils.php
示例15: get
public static function get($name, $as_rule = false)
{
if (is_array($name)) {
if (!isset(self::$links[$name[0]])) {
return false;
}
$value = self::$links[$name[0]];
$link_args = $name;
} else {
if (!isset(self::$links[$name])) {
return false;
}
$value = self::$links[$name];
$link_args = func_get_args();
}
// RETURN FORMATED LINK
if (count($link_args) > 2 || count($link_args) == 2 && !is_bool($link_args[1])) {
$value = str_replace(array("^", "[admin]", "[base]", "[num]", "[alpha]", "[alphanum]", "[any]", '$'), array(self::$base_url . "/", self::$admin_url_path, self::$base_url, "([0-9]+)", "([a-zA-Z]+)", "([A-Za-z0-9]+)", "([A-Za-z0-9_-]+)", ''), $value);
// replace patterns (like: ([something]+) ) with given values
$to_rep = array();
$current_string = '';
for ($i = 0; $i < strlen($value); $i++) {
if ($value[$i] == "(") {
$current_string .= "(";
} elseif ($value[$i] == ")") {
$current_string .= ")";
$to_rep[] = $current_string;
$current_string = "";
} elseif ($current_string != "") {
$current_string .= $value[$i];
}
}
foreach ($to_rep as $i => $v) {
if (isset($link_args[$i + 1])) {
$value = str_replace_once($v, $link_args[$i + 1], $value);
} else {
$value = str_replace_once($v, "", $value);
}
}
} else {
// prepare output link
if ($as_rule == false) {
$value = str_replace(array("^", "[admin]", "[base]", '$'), array(self::$base_url . "/", self::$admin_url_path, self::$base_url, ''), $value);
// remove patterns (like: ([something]+) )
$to_rep = array();
$current_string = '';
for ($i = 0; $i < strlen($value); $i++) {
if ($value[$i] == "(") {
$current_string .= "(";
} elseif ($value[$i] == ")") {
$current_string .= ")";
$to_rep[] = $current_string;
$current_string = "";
} elseif ($current_string != "") {
$current_string .= $value[$i];
}
}
$value = str_replace($to_rep, "", $value);
}
}
// return link
return $value;
}
开发者ID:double-web,项目名称:drawline,代码行数:63,代码来源:include_links.php
示例16: sfput_rewrite_rules
function sfput_rewrite_rules($rules)
{
global $wp_rewrite, $polylang;
if (empty($rules)) {
// Uh? oO
return $rules;
}
$languages = $polylang->model->get_languages_list(array('fields' => 'slug'));
// If Polylang doesn't add the /{default_lang}/ in the URL, no need to modify the rules for this lang, sfput_registered_post_type() took care of it earlier.
if ($polylang->options['hide_default']) {
$languages = array_diff($languages, array($polylang->options['default_lang']));
}
if (empty($languages)) {
return $rules;
}
// The way Polylang built its regex.
$imploded_langs = '(' . implode('|', $languages) . ')/';
$poly_slug = $wp_rewrite->root . ($polylang->options['rewrite'] ? '' : 'language/') . $imploded_langs;
// Post types slugs
$slugs = sfput_get_option('post_types.archive');
$slugs = array_filter($slugs);
if (empty($slugs)) {
return $rules;
}
$post_types = array_keys($slugs);
$post_types = array_combine($post_types, $post_types);
$old_slugs = array_map('sfput_get_post_type_archive_slug', $post_types);
$post_types = implode('|', $post_types);
$new_rules = array();
foreach ($rules as $regex => $rule) {
// Not a Polylang rule
if (strpos($regex, $poly_slug) !== 0) {
$new_rules[$regex] = $rule;
} elseif (preg_match('@[?|&]post_type=(' . $post_types . ')(?:&.*)?$@', $rule, $matches)) {
$post_type = $matches[1];
foreach ($languages as $language) {
$new_regex = str_replace_once($imploded_langs, '(' . $language . ')/', $regex);
$new_regex = str_replace_once('/' . $old_slugs[$post_type] . '/', '/' . $slugs[$post_type][$language] . '/', '/' . $new_regex);
$new_regex = ltrim($new_regex, '/');
$new_rules[$new_regex] = $rule;
}
} else {
$new_rules[$regex] = $rule;
}
}
return $new_rules;
}
开发者ID:MaximeCulea,项目名称:sf-polylang-urls-translation,代码行数:47,代码来源:admin.php
示例17: sanitize
/**
* Sanitizes the given URL by making sure it's suitable for menu links.
*
* @param string $url Item's URL to sanitize
* @return string Valid URL, empty string on error
*/
public function sanitize($url)
{
try {
$url = Router::url($url);
} catch (\Exception $ex) {
return '';
}
if (!str_starts_with($url, '/')) {
return $url;
}
if (str_starts_with($url, $this->baseUrl())) {
$url = str_replace_once($this->baseUrl(), '', $url);
}
return $this->localePrefix($url);
}
开发者ID:quickapps-plugins,项目名称:menu,代码行数:21,代码来源:LinkHelper.php
示例18: contentsAddSiloLinks
function contentsAddSiloLinks($content)
{
if (!$content || !is_string($content)) {
return;
}
//return;
return;
$params = array();
$params[] = array('taxonomy_type', 'category');
// $params[] =array ('taxonomy_value', 'NULL', '<>', 'and' );
$params[] = array('taxonomy_silo_keywords', '', '<>', 'and');
$params[] = array('taxonomy_silo_keywords', 'IS NOT NULL');
// $params[] =array ('taxonomy_value', 'IS NOT NULL' );
$opts = array();
$opts['only_fields'] = array('id', 'taxonomy_silo_keywords', 'taxonomy_type', 'taxonomy_value');
$opts['cache_group'] = 'taxonomy/global';
$opts['cache'] = true;
$opts['debug'] = false;
$categories = CI::model('core')->fetchDbData('firecms_taxonomy', $params, $opts);
if (empty($categories)) {
return $content;
}
//p($categories,1);
//return;
CI::helper('mw_string');
$siloLinks = array();
foreach ($categories as $category) {
if ($category['taxonomy_silo_keywords']) {
$siloLink = array();
$siloLink['keywords'] = array();
$siloLink['url'] = CI::model('taxonomy')->getUrlForIdAndCache($category['id']);
$siloLink['id'] = $category['id'];
$keywords = explode(',', $category['taxonomy_silo_keywords']);
if (!empty($keywords)) {
foreach ($keywords as $keyword) {
$siloLink['keywords_regexp'][] = '/ ' . trim($keyword) . ' /e';
$siloLink['keywords'][] = trim($keyword);
}
$siloLinks[] = $siloLink;
}
}
}
// p ( $siloLinks, 1 );
$linksPerCategory = 1;
$already_replaced = array();
foreach ($siloLinks as $siloLink) {
foreach ($siloLink['keywords'] as $kw_for_replace) {
if (!in_array(strtolower($kw_for_replace), $already_replaced)) {
$already_replaced[] = strtolower($kw_for_replace);
$categoryLink = "<a href='{$siloLink['url']}'
|
请发表评论