本文整理汇总了PHP中str_replace_first函数的典型用法代码示例。如果您正苦于以下问题:PHP str_replace_first函数的具体用法?PHP str_replace_first怎么用?PHP str_replace_first使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_replace_first函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: replaceAsIsValues
/**
* Производим замену значений, отображаемых "как есть".
*/
private function replaceAsIsValues($html)
{
foreach ($this->ASIS_VALUES as $macros => $value) {
$html = str_replace_first($macros, $value, $html);
}
return $html;
}
开发者ID:ilivanoff,项目名称:www,代码行数:10,代码来源:PageBuilder.php
示例2: lang
/**
* Shortcut function for retrieving single lang value
*
* @access public
* @param string $name
* @return string
*/
function lang($name)
{
// Get function arguments and remove first one.
$args = func_get_args();
if (is_array($args)) {
array_shift($args);
}
// if
// Get value and if we have NULL done!
if (plugin_active('i18n')) {
$value = lang_from_db($name);
} else {
$value = Localization::instance()->lang($name);
}
if (is_null($value)) {
return $value;
}
// if
// We have args? Replace all %s with arguments
if (is_array($args) && count($args)) {
foreach ($args as $arg) {
$value = str_replace_first('%s', $arg, $value);
}
// foreach
}
// if
// Done here...
return $value;
}
开发者ID:bklein01,项目名称:Project-Pier,代码行数:36,代码来源:localization.php
示例3: smarty_block_submit
/**
* Render submit button
*
* @param array $params
* @param string $content
* @param Smarty $smarty
* @param boolean $repeat
* @return string
*/
function smarty_block_submit($params, $content, &$smarty, &$repeat)
{
$params['type'] = 'submit';
$accesskey = array_var($params, 'accesskey', 's');
if ($accesskey) {
$params['accesskey'] = 's';
}
// if
$caption = clean(isset($params['not_lang']) ? $content : lang($content));
if ($accesskey) {
$first = null;
$first_pos = null;
$to_highlight = array(strtolower($accesskey), strtoupper($accesskey));
foreach ($to_highlight as $accesskey_to_highlight) {
if (($pos = strpos($caption, $accesskey_to_highlight)) === false) {
continue;
}
// if
if ($first_pos === null || $pos < $first_pos) {
$first = $accesskey_to_highlight;
$first_pos = $pos;
}
// if
}
// foreach
if ($first !== null) {
$caption = str_replace_first($first, "<u>{$first}</u>", $caption);
}
// if
}
// if
// And done...
return open_html_tag('button', $params) . '<span><span>' . $caption . '</span></span></button>';
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:43,代码来源:block.submit.php
示例4: add
/**
* Add webpage
*
* @access public
* @param void
* @return null
*/
function add() {
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$this->setTemplate('add');
$notAllowedMember = '';
if(!ProjectWebpage::canAdd(logged_user(), active_context(), $notAllowedMember)) {
if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
else flash_error(lang('no context permissions to add',lang("webpages"), $notAllowedMember));
ajx_current("empty");
return;
} // if
$webpage = new ProjectWebpage();
$webpage_data = array_var($_POST, 'webpage');
if(is_array(array_var($_POST, 'webpage'))) {
try {
if(substr_utf($webpage_data['url'],0,7) != 'http://' && substr_utf($webpage_data['url'],0,7) != 'file://' && substr_utf($webpage_data['url'],0,8) != 'https://' && substr_utf($webpage_data['url'],0,6) != 'about:' && substr_utf($webpage_data['url'],0,6) != 'ftp://') {
$webpage_data['url'] = 'http://' . $webpage_data['url'];
}
$webpage->setFromAttributes($webpage_data);
DB::beginWork();
$webpage->save();
$member_ids = json_decode(array_var($_POST, 'members'));
//link it!
$object_controller = new ObjectController();
$object_controller->add_subscribers($webpage);
$object_controller->add_to_members($webpage, $member_ids);
$object_controller->link_to_new_object($webpage);
$object_controller->add_subscribers($webpage);
$object_controller->add_custom_properties($webpage);
ApplicationLogs::createLog($webpage, ApplicationLogs::ACTION_ADD);
DB::commit();
flash_success(lang('success add webpage', $webpage->getObjectName()));
ajx_current("back");
// Error...
} catch(Exception $e) {
DB::rollback();
flash_error($e->getMessage());
ajx_current("empty");
}
}
tpl_assign('webpage', $webpage);
tpl_assign('webpage_data', $webpage_data);
} // add
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:66,代码来源:WebpageController.class.php
示例5: bind_param
public function bind_param($a, $b = false, $c = false, $d = false, $e = false, $f = false, $g = false)
{
$sql = str_replace_first('?', $b, $this->sql);
$sql = str_replace_first('?', $c, $sql);
$sql = str_replace_first('?', $d, $sql);
$sql = str_replace_first('?', $e, $sql);
$sql = str_replace_first('?', $f, $sql);
$sql = str_replace_first('?', $g, $sql);
echo $sql . '<br />';
return true;
}
开发者ID:RobinLinus,项目名称:capira-api,代码行数:11,代码来源:debug.php
示例6: parseItemsOnlyOnce
public function parseItemsOnlyOnce($link, $type)
{
$content = $link->content;
$obj = $link->{$type};
$link_text = $this->getContentLinks($link);
foreach ($obj as $item) {
if (!isContainedInElementsOfArray($item->text, $link_text[1]) && $item->pivot->relevance > 0.5) {
$content = str_replace_first($item->text, '<a href="/' . $type . '/' . $item->slug . ' "class="' . $type . '">' . $item->text . '</a>', $content);
}
}
$link->update(['content' => $content]);
}
开发者ID:sidis405,项目名称:filtr,代码行数:12,代码来源:LinksRepo.php
示例7: lang
function lang($line, $id = '')
{
$CI =& get_instance();
$line = $CI->lang->line($line);
$args = func_get_args();
if (is_array($args)) {
array_shift($args);
}
if (is_array($args) && count($args)) {
foreach ($args as $arg) {
$line = str_replace_first('%s', $arg, $line);
}
}
if ($id != '') {
$line = '<label for="' . $id . '">' . $line . "</label>";
}
return $line;
}
开发者ID:adomasalcore3,项目名称:FlameCMS-2,代码行数:18,代码来源:MY_language_helper.php
示例8: apiReadUrlXml
function apiReadUrlXml($url, $data = [])
{
/* $url = $_REQUEST['url'];//'http://212.38.167.37/resultsproxy/getresultsxml3.aspx';
$data = array( 'loc' => 'ru-RU',
'action' => 'GETSPORTS'
);*/
if (!extension_loaded('curl')) {
throw new \ErrorException('cURL library is not loaded');
}
$ch = curl_init();
$user_agent = 'PHP-STATSANDRESULTS-PROXY/1.0.0';
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
// curl_setopt($ch, CURLINFO_HEADER_OUT, true);
// curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url . (empty($data) ? '' : '?' . http_build_query($data)));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPGET, true);
$result = curl_exec($ch);
curl_close($ch);
return str_replace_first('<?xml version="1.0" encoding="utf-16"?>', '<?xml version="1.0" encoding="utf-8"?>', $result);
}
开发者ID:statsandresults,项目名称:statsandresults,代码行数:23,代码来源:api.php
示例9: prepareString
/**
* Prepare string. Replace every '?' with matching escaped value
*
* @param string $sql
* @param array $arguments Array of arguments
* @return string
*/
static function prepareString($sql, $arguments = null)
{
if (is_array($arguments) && count($arguments)) {
foreach ($arguments as $argument) {
$sql = str_replace_first('?', DB::escape($argument), $sql);
}
// foreach
}
// if
return $sql;
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:18,代码来源:DB.class.php
示例10: export
/**
* This function exports all the data for a given module
* Param $type - module name
* Return type text
*/
function export($type)
{
global $log, $list_max_entries_per_page;
$log->debug("Entering export(" . $type . ") method ...");
global $adb;
$focus = 0;
$content = '';
if ($type != "") {
// vtlib customization: Hook to dynamically include required module file.
// Refer to the logic in setting $currentModule in index.php
$focus = CRMEntity::getInstance($type);
}
$log = LoggerManager::getLogger('export_' . $type);
$db = PearDatabase::getInstance();
$oCustomView = new CustomView("{$type}");
$viewid = $oCustomView->getViewId("{$type}");
$sorder = $focus->getSortOrder();
$order_by = $focus->getOrderBy();
$search_type = $_REQUEST['search_type'];
$export_data = $_REQUEST['export_data'];
if (isset($_SESSION['export_where']) && $_SESSION['export_where'] != '' && $search_type == 'includesearch') {
$where = $_SESSION['export_where'];
}
$query = $focus->create_export_query($where);
if ($search_type != 'includesearch' && $type != 'Calendar') {
$stdfiltersql = $oCustomView->getCVStdFilterSQL($viewid);
$advfiltersql = $oCustomView->getCVAdvFilterSQL($viewid);
if (isset($stdfiltersql) && $stdfiltersql != '') {
$query .= ' and ' . $stdfiltersql;
}
if (isset($advfiltersql) && $advfiltersql != '') {
$query .= ' and ' . $advfiltersql;
}
}
$params = array();
if (($search_type == 'withoutsearch' || $search_type == 'includesearch') && $export_data == 'selecteddata') {
$idstring = explode(";", $_REQUEST['idstring']);
if ($type == 'Accounts' && count($idstring) > 0) {
$query .= ' and vtiger_account.accountid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} elseif ($type == 'Contacts' && count($idstring) > 0) {
$query .= ' and vtiger_contactdetails.contactid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} elseif ($type == 'Potentials' && count($idstring) > 0) {
$query .= ' and vtiger_potential.potentialid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} elseif ($type == 'Leads' && count($idstring) > 0) {
$query .= ' and vtiger_leaddetails.leadid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} elseif ($type == 'Products' && count($idstring) > 0) {
$query .= ' and vtiger_products.productid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} elseif ($type == 'Documents' && count($idstring) > 0) {
$query .= ' and vtiger_notes.notesid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} elseif ($type == 'HelpDesk' && count($idstring) > 0) {
$query .= ' and vtiger_troubletickets.ticketid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} elseif ($type == 'Vendors' && count($idstring) > 0) {
$query .= ' and vtiger_vendor.vendorid in (' . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
} else {
if (count($idstring) > 0) {
// vtlib customization: Hook to make the export feature available for custom modules.
$query .= " and {$focus->table_name}.{$focus->table_index} in (" . generateQuestionMarks($idstring) . ')';
array_push($params, $idstring);
// END
}
}
}
if (isset($order_by) && $order_by != '') {
if ($order_by == 'smownerid') {
$query .= ' ORDER BY user_name ' . $sorder;
} elseif ($order_by == 'lastname' && $type == 'Documents') {
$query .= ' ORDER BY vtiger_contactdetails.lastname ' . $sorder;
} elseif ($order_by == 'crmid' && $type == 'HelpDesk') {
$query .= ' ORDER BY vtiger_troubletickets.ticketid ' . $sorder;
} else {
$tablename = getTableNameForField($type, $order_by);
$tablename = $tablename != '' ? $tablename . "." : '';
if ($adb->dbType == "pgsql") {
$query .= ' GROUP BY ' . $tablename . $order_by;
}
$query .= ' ORDER BY ' . $tablename . $order_by . ' ' . $sorder;
}
}
if ($export_data == 'currentpage') {
$current_page = ListViewSession::getCurrentPage($type, $viewid);
$limit_start_rec = ($current_page - 1) * $list_max_entries_per_page;
if ($limit_start_rec < 0) {
$limit_start_rec = 0;
}
$query .= ' LIMIT ' . $limit_start_rec . ',' . $list_max_entries_per_page;
}
$query = str_replace_first("INNER JOIN vtiger_accounting ON vtiger_crmentity.crmid=vtiger_accounting.accountingid", "INNER JOIN vtiger_accounting ON vtiger_accounting.accountingid = vtiger_crmentity.crmid INNER JOIN vtiger_accounting_payments ON vtiger_accounting_payments.idtransaction=vtiger_accounting.accountingid", $query);
//.........这里部分代码省略.........
开发者ID:jmangarret,项目名称:vtigercrm,代码行数:101,代码来源:ExportPayments.php
示例11: insert_before_file_extension
/**
* Set something before file extension
*
* @access public
* @param string $in Filename
* @param string $insert Insert this
* @return null
*/
function insert_before_file_extension($filename, $insert)
{
return str_replace_first('.', '.' . $insert, $filename);
}
开发者ID:bklein01,项目名称:Project-Pier,代码行数:12,代码来源:files.php
示例12: str_replace_first
<?php
function str_replace_first($from, $to, $subject)
{
$from = '/' . preg_quote($from, '/') . '/';
return preg_replace($from, $to, $subject, 1);
}
spl_autoload_register(function ($classname) {
$classname = str_replace_first('Juborm\\', '', $classname);
$classname = str_replace('\\', '/', $classname);
if (!file_exists("phar://juborm.phar/{$classname}.php")) {
die(print_r($classname, true));
} else {
require_once "phar://juborm.phar/{$classname}.php";
}
}, true, false);
开发者ID:ttmdear,项目名称:juborm,代码行数:16,代码来源:autoload.php
示例13: new_template
/**
* Create a new template
*
*/
function new_template()
{
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$notAllowedMember = '';
if (!ProjectTask::canAdd(logged_user(), active_context(), $notAllowedMember)) {
if (str_starts_with($notAllowedMember, '-- req dim --')) {
flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
} else {
flash_error(lang('no context permissions to add', lang("tasks"), $notAllowedMember));
}
ajx_current("empty");
return;
}
// if
$id = get_id();
$task = ProjectTasks::findById($id);
if (!$task instanceof ProjectTask) {
$task_data = array('is_template' => true);
} else {
$task_data = array('milestone_id' => $task->getMilestoneId(), 'title' => $task->getObjectName(), 'assigned_to' => $task->getAssignedToContactId(), 'parent_id' => $task->getParentId(), 'priority' => $task->getPriority(), 'time_estimate' => $task->getTimeEstimate(), 'text' => $task->getText(), 'is_template' => true, 'copyId' => $task->getId());
// array
if ($task->getStartDate() instanceof DateTimeValue) {
$task_data['start_date'] = $task->getStartDate()->getTimestamp();
}
if ($task->getDueDate() instanceof DateTimeValue) {
$task_data['due_date'] = $task->getDueDate()->getTimestamp();
}
}
$task = new ProjectTask();
tpl_assign('task_data', $task_data);
tpl_assign('task', $task);
$this->setTemplate("add_task");
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:41,代码来源:TaskController.class.php
示例14: copy
function copy() {
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
ajx_set_no_toolbar();
$id = get_id();
$file = ProjectFiles::findById($id);
if (!$file instanceof ProjectFile) {
flash_error("file dnx");
ajx_current("empty");
return;
}
if (!$file->canView(logged_user())) {
flash_error(lang("no access permissions"));
ajx_current("empty");
return;
}
$original_members = $file->getMembers();
$members = $file->getAllowedMembersToAdd(logged_user(), $original_members);
if (!$file->canAdd(logged_user(), $members, $notAllowedMember) ){
if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
else flash_error(lang('no context permissions to add',lang("files"), $notAllowedMember));
ajx_current("empty");
return;
}
try {
DB::beginWork();
$copy = $file->copy();
$copy->setFilename(lang('copy of file', $file->getFilename()));
$copy->save();
$copy->addToMembers($members);
$copy->addToSharingTable();
$rev_data = array();
$rev_data['name'] = $copy->getFilename();
$rev_data['size'] = $file->getFileSize();
$rev_data['type'] = $file->getTypeString();
$rev_data['tmp_name'] = ROOT . '/tmp/' . rand () ;
$handler = fopen($rev_data['tmp_name'], 'w');
$file_content = $file->getLastRevision()->getFileContent();
fputs($handler, $file_content);
fclose($handler);
$copy->handleUploadedFile($rev_data, false, lang("copied from file", $file->getFilename(), $file->getUniqueObjectId()));
DB::commit();
$this->setTemplate('file_details');
tpl_assign('file', $copy);
tpl_assign('last_revision', $copy->getLastRevision());
tpl_assign('revisions', $copy->getRevisions());
tpl_assign('order', null);
tpl_assign('page', null);
ajx_extra_data(array("title" => $copy->getFilename(), 'icon'=>'ico-file'));
ajx_set_no_toolbar(true);
//read object for this user
$copy->setIsRead(logged_user()->getId(),true);
ApplicationReadLogs::createLog($copy, ApplicationReadLogs::ACTION_READ);
} catch (Exception $ex) {
DB::rollback();
flash_error($ex->getMessage());
ajx_current("empty");
}
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:70,代码来源:FilesController.class.php
示例15: add
/**
* Add message
*
* @access public
* @param void
* @return null
*/
function add()
{
$this->setTemplate('add_message');
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current('empty');
return;
}
$notAllowedMember = '';
if (!ProjectMessage::canAdd(logged_user(), active_context(), $notAllowedMember)) {
if (str_starts_with($notAllowedMember, '-- req dim --')) {
flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
} else {
trim($notAllowedMember) == "" ? flash_error(lang('you must select where to keep', lang('the message'))) : flash_error(lang('no context permissions to add', lang("messages"), $notAllowedMember));
}
ajx_current("empty");
return;
}
// if
$message = new ProjectMessage();
tpl_assign('message', $message);
$message_data = array_var($_POST, 'message');
if (!is_array($message_data)) {
// set layout for modal form
if (array_var($_REQUEST, 'modal')) {
$this->setLayout("json");
tpl_assign('modal', true);
}
$message_data = array();
}
// if
tpl_assign('message_data', $message_data);
if (is_array(array_var($_POST, 'message'))) {
foreach ($message_data as $k => &$v) {
$v = remove_scripts($v);
}
try {
if (config_option('untitled_notes')) {
if (!array_var($message_data, "name")) {
$message_data["name"] = lang("untitled note");
}
}
// Aliases
if (config_option("wysiwyg_messages")) {
$message_data['type_content'] = "html";
$message_data['text'] = preg_replace("/[\n|\r|\n\r]/", '', array_var($message_data, 'text'));
} else {
$message_data['type_content'] = "text";
}
$message->setFromAttributes($message_data);
DB::beginWork();
$message->save();
$object_controller = new ObjectController();
$member_ids = json_decode(array_var($_POST, 'members'));
$object_controller->add_to_members($message, $member_ids);
$object_controller->add_subscribers($message);
$object_controller->link_to_new_object($message);
$object_controller->add_custom_properties($message);
DB::commit();
ApplicationLogs::createLog($message, ApplicationLogs::ACTION_ADD);
flash_success(lang('success add message', $message->getObjectName()));
if (array_var($_POST, 'popup', false)) {
ajx_current("reload");
} else {
ajx_current("back");
}
if (array_var($_REQUEST, 'modal')) {
evt_add("reload current panel");
}
ajx_add("overview-panel", "reload");
// Error...
} catch (Exception $e) {
DB::rollback();
$message->setNew(true);
flash_error($e->getMessage());
ajx_current("empty");
}
// try
}
// if
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:88,代码来源:MessageController.class.php
示例16: add
function add() {
if (logged_user()->isGuest()) {
flash_error(lang('no access permissions'));
ajx_current("empty");
return;
}
$notAllowedMember = '';
if(!(ProjectEvent::canAdd(logged_user(), active_context(),$notAllowedMember ))){
if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in)));
else flash_error(lang('no context permissions to add',lang("events"), $notAllowedMember));
ajx_current("empty");
return ;
}
$this->setTemplate('event');
$event = new ProjectEvent();
$event_data = array_var($_POST, 'event');
$event_name = array_var($_GET, 'name'); //if sent from pupup
//var_dump($event_data) ;
$month = isset($_GET['month'])?$_GET['month']:date('n', DateTimeValueLib::now()->getTimestamp() + logged_user()->getTimezone() * 3600);
$day = isset($_GET['day'])?$_GET['day']:date('j', DateTimeValueLib::now()->getTimestamp() + logged_user()->getTimezone() * 3600);
$year = isset($_GET['year'])?$_GET['year']:date('Y', DateTimeValueLib::now()->getTimestamp() + logged_user()->getTimezone() * 3600);
$user_filter = isset($_GET['user_filter']) ? $_GET['user_filter'] : logged_user()->getId();
if(!is_array($event_data)) {
// if data sent from quickadd popup (via get) we se it, else default
if (isset($_GET['start_time'])) $this->parseTime($_GET['start_time'], $hour, $minute);
else {
$hour = isset($_GET['hour']) ? $_GET['hour'] : date('G', DateTimeValueLib::now()->getTimestamp() + logged_user()->getTimezone() * 3600);
$minute = isset($_GET['minute']) ? $_GET['minute'] : round((date('i') / 15), 0) * 15; //0,15,30 and 45 min
}
if(!user_config_option('time_format_use_24')) {
if($hour >= 12){
$pm = 1;
$hour = $hour - 12;
} else $pm = 0;
}
$event_data = array(
'month' => isset($_GET['month']) ? $_GET['month'] : date('n', DateTimeValueLib::now()->getTimestamp() + logged_user()->getTimezone() * 3600),
'year' => isset($_GET['year']) ? $_GET['year'] : date('Y', DateTimeValueLib::now()->getTimestamp() + logged_user()->getTimezone() * 3600),
'day' => isset($_GET['day']) ? $_GET['day'] : date('j', DateTimeValueLib::now()->getTimestamp() + logged_user()->getTimezone() * 3600),
'hour' => $hour,
'minute' => $minute,
'pm' => (isset($pm) ? $pm : 0),
'typeofevent' => isset($_GET['type_id']) ? $_GET['type_id'] : 1,
'name' => $event_name,
'durationhour' => isset($_GET['durationhour']) ? $_GET['durationhour'] : 1,
'durationmin' => isset($_GET['durationmin']) ? $_GET['durationmin'] : 0,
); // array
} // if
tpl_assign('event', $event);
tpl_assign('event_data', $event_data);
tpl_assign('event_related', false);
if (is_array(array_var($_POST, 'event'))) {
try {
$data = $this->getData($event_data);
$event->setFromAttributes($data);
DB::beginWork();
$event->save();
$this->registerInvitations($data, $event);
if (isset($data['confirmAttendance'])) {
$this->change_invitation_state($data['confirmAttendance'], $event->getId(), $user_filter);
}
if (array_var($_POST, 'members')) {
$member_ids = json_decode(array_var($_POST, 'members'));
} else {
$member_ids = array();
$context = active_context();
foreach ($context as $selection) {
if ($selection instanceof Member) $member_ids[] = $selection->getId();
}
}
ApplicationLogs::createLog($event, ApplicationLogs::ACTION_ADD, false, $is_silent);
$object_controller = new ObjectController();
$object_controller->add_to_members($event, $member_ids);
$object_controller->add_subscribers($event);
$object_controller->link_to_new_object($event);
$object_controller->add_custom_properties($event);
$object_controller->add_reminders($event);
if (array_var($_POST, 'popup', false)) {
// create default reminder
$def = explode(",", user_config_option("reminders_events"));
$minutes = array_var($def, 2) * array_var($def, 1);
$reminder = new ObjectReminder();
$reminder->setMinutesBefore($minutes);
$reminder->setType(array_var($def, 0, 'reminder_email'));
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:EventController.class.php
示例17: makeJsonReplacements
/**
* Make the place-holder replacements on a JSON loaded line.
*
* @param string $line
* @param array $replace
* @return string
*/
protected function makeJsonReplacements($line, array $replace)
{
preg_match_all('#:(?:[a-zA-Z1-9]*)#s', $line, $placeholders);
$placeholders = $placeholders[0];
foreach ($placeholders as $i => $key) {
$line = str_replace_first($key, isset($replace[$i]) ? $replace[$i] : $key, $line);
}
return $line;
}
开发者ID:bryanashley,项目名称:framework,代码行数:16,代码来源:Translator.php
示例18: fromHex
/**
* @param string $hex
*
* @return Colour
*/
public static function fromHex(string $hex) : Colour
{
$hex = str_replace_first('#', '', $hex);
return new self(hexdec(substr($hex, 0, 2)), hexdec(substr($hex, 2, 2)), hexdec(substr($hex, 4, 2)));
}
开发者ID:hughgrigg,项目名称:ching-shop,代码行数:10,代码来源:Colour.php
示例19: strpos
$conversation_block .= '</div>';
} else {
$conversation_block = '';
}
if($email->getBodyHtml() != ''){
if (defined('SANDBOX_URL')) {
$html_content = $email->getBodyHtml();
// prevent some outlook malformed tags
if(substr_count($html_content, "<style") != substr_count($html_content, "</style>") && substr_count($html_content, "/* Font Definitions */") >= 1) {
$p1 = strpos($html_content, "/* Font Definitions */", 0);
$html_content1 = substr($html_content, 0, $p1);
$p0 = strrpos($html_content1, "</style>");
$html_content = ($p0 >= 0 ? substr($html_content1, 0, $p0) : $html_content1) . substr($html_content, $p1);
$html_content = str_replace_first("/* Font Definitions */","<style>",$html_content);
}
} else {
$html_content = purify_html($email->getBodyHtml());
}
if (strpos($html_content, "<html") === false) {
if (strpos($html_content, "<body") === false) {
$html_content = "<body>" . $html_content . "</body>";
}
if (strpos($html_content, "<head") === false) {
$html_content = "<head></head>" . $html_content;
}
$html_content = "<html>" . $html_content . "</html>";
}
//$html_content = convert_to_links($html_content); // commented because it can break HTML (e.g. if an URL or email is found on the title of an element)
// links must open in a new tab or window
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:view.php
示例20: make_where_clause
/**
* Make a safely escaped where fragment of SQL out of a plain string or a rails-style
* conditions statement like: array("username=? AND user_id IN ?", $username, array(1, 2, 75, 200))
* @param string $sql SQL to determine query type of
* @return string|boolean one of 'INSERT', 'SELECT', 'UPDATE', 'DELETE', FALSE
*/
private function make_where_clause($where)
{
if (is_array($where)) {
$token = '?';
// todo: move to define()
$safe_token = '?SAFE_TOKEN?';
$where_text = array_shift($where);
// replace ? tokens with a rarer token ?SAFE_TOKEN? to allow ?s in the actual content.. TODO: move to define()
$where_text = str_replace($token, $safe_token, $where_text);
$num_wheres = substr_count($where_text, $safe_token);
if ($num_wheres != count($where)) {
throw new InvalidSQLException("WHERE mismatch:expected {$num_wheres} got " . count($where));
}
for ($i = 0; $i < $num_wheres; $i++) {
$where_text = str_replace_first($safe_token, $this->make_where_val($where[$i]), $where_text);
}
$where = $where_text;
} else {
$where = $this->escape($where, $in_quotes = FALSE);
//unescape single quotes so we can pass in strings like "blah != 'something'"
$where = str_replace("\\'", "'", $where);
}
return $where;
}
开发者ID:stephenhandley,项目名称:temovico,代码行数:30,代码来源:MySQLDatabaseService.php
注:本文中的str_replace_first函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论