本文整理汇总了PHP中core_text::strpos方法的典型用法代码示例。如果您正苦于以下问题:PHP core_text::strpos方法的具体用法?PHP core_text::strpos怎么用?PHP core_text::strpos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_text
的用法示例。
在下文中一共展示了core_text::strpos方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_strpos
/**
* Tests the static strpos method.
*/
public function test_strpos()
{
$str = "Žluťoučký koníček";
$this->assertSame(10, core_text::strpos($str, 'koníč'));
}
示例2: list_participants
/**
* Retrieves the list of students to be graded for the assignment.
*
* @param int $assignid the assign instance id
* @param int $groupid the current group id
* @param string $filter search string to filter the results.
* @param int $skip Number of records to skip
* @param int $limit Maximum number of records to return
* @param bool $onlyids Only return user ids.
* @return array of warnings and status result
* @since Moodle 3.1
* @throws moodle_exception
*/
public static function list_participants($assignid, $groupid, $filter, $skip, $limit, $onlyids)
{
global $DB, $CFG;
require_once $CFG->dirroot . "/mod/assign/locallib.php";
require_once $CFG->dirroot . "/user/lib.php";
$params = self::validate_parameters(self::list_participants_parameters(), array('assignid' => $assignid, 'groupid' => $groupid, 'filter' => $filter, 'skip' => $skip, 'limit' => $limit, 'onlyids' => $onlyids));
$warnings = array();
list($assign, $course, $cm, $context) = self::validate_assign($params['assignid']);
require_capability('mod/assign:view', $context);
$assign->require_view_grades();
$participants = $assign->list_participants_with_filter_status_and_group($params['groupid']);
$result = array();
$index = 0;
foreach ($participants as $record) {
// Preserve the fullname set by the assignment.
$fullname = $record->fullname;
$searchable = $fullname;
$match = false;
if (empty($filter)) {
$match = true;
} else {
$filter = core_text::strtolower($filter);
$value = core_text::strtolower($searchable);
if (is_string($value) && core_text::strpos($value, $filter) !== false) {
$match = true;
}
}
if ($match) {
$index++;
if ($index <= $params['skip']) {
continue;
}
if ($params['limit'] > 0 && $index - $params['skip'] > $params['limit']) {
break;
}
// Now we do the expensive lookup of user details because we completed the filtering.
if (!$assign->is_blind_marking() && !$params['onlyids']) {
$userdetails = user_get_user_details($record, $course);
} else {
$userdetails = array('id' => $record->id);
}
$userdetails['fullname'] = $fullname;
$userdetails['submitted'] = $record->submitted;
$userdetails['requiregrading'] = $record->requiregrading;
if (!empty($record->groupid)) {
$userdetails['groupid'] = $record->groupid;
}
if (!empty($record->groupname)) {
$userdetails['groupname'] = $record->groupname;
}
$result[] = $userdetails;
}
}
return $result;
}
示例3: split_words
/**
* Splits text into words.
* Note: This is not really intended to be public as such, but it needs to be called
* within ousearch_search.
* @param string $text Text to split
* @param bool $query If true, text is treated as a query (preserve +, -,
* and ")
* @param bool $positions If true, returns positions
* @return array If $positions is false, returns an array of words. If it
* is true, returns a two-element array, first being an array of words,
* second being a corresponding array of start positions of each word
* (in characters) with one extra value holding end position/length
* in characters
*/
public static function split_words($text, $query = false, $positions = false)
{
// Treat single right quote as apostrophe.
$text = str_replace("’", "'", $text);
// Words include all letters, numbers, and apostrophes. Though this is
// expressed with Unicode it is likely to work properly only for English and
// some other European languages.
$text = preg_replace($query ? '/[^\\pL\\pN\\x27+"-]/u' : '/[^\\pL\\pN\\x27]/u', '_', core_text::strtolower($text));
if (!$positions) {
$text = preg_replace('/\\x27+(_|$)/u', '_', $text);
$text = preg_replace('/(^|_)\\x27+/u', '_', $text);
$text = preg_replace('/_+/u', '_', $text);
$result = explode('_', $text);
$words = array();
foreach ($result as $word) {
if ($word !== '') {
$words[] = $word;
}
}
return $words;
} else {
$text = self::replace_with_underline('/\\x27+(_|$)/u', $text);
$text = self::replace_with_underline('/(^|_)\\x27+/u', $text);
$words = array();
$positions = array();
$pos = 0;
while ($pos < core_text::strlen($text)) {
if (core_text::substr($text, $pos, 1) === '_') {
$pos++;
continue;
}
$nextunderline = core_text::strpos($text, '_', $pos + 1);
if ($nextunderline === false) {
$nextunderline = core_text::strlen($text);
}
$words[] = core_text::substr($text, $pos, $nextunderline - $pos);
$positions[] = $pos;
$pos = $nextunderline + 1;
}
$positions[] = core_text::strlen($text);
return array($words, $positions);
}
}
示例4: rcontent_get_urlviewresults_link
function rcontent_get_urlviewresults_link($urlviewresults)
{
if (core_text::strpos($urlviewresults, 'http://') === false && core_text::strpos($urlviewresults, 'https://') === false) {
$urlviewresults = 'http://' . $urlviewresults;
}
return '<a href="' . $urlviewresults . '" target="_blank">' . get_string('rcontent:viewresult', 'rcontent') . '</a>';
}
示例5: game_strpos
function game_strpos($haystack, $needle, $offset = 0)
{
if (game_get_moodle_version() >= '02.08') {
return core_text::strpos($haystack, $needle, $offset);
}
if (game_get_moodle_version() >= '02.04') {
return textlib::strpos($haystack, $needle, $offset);
}
return textlib_get_instance()->strpos($haystack, $needle, $offset);
}
示例6: list_participants
/**
* Retrieves the list of students to be graded for the assignment.
*
* @param int $assignid the assign instance id
* @param int $groupid the current group id
* @param string $filter search string to filter the results.
* @param int $skip Number of records to skip
* @param int $limit Maximum number of records to return
* @param bool $onlyids Only return user ids.
* @param bool $includeenrolments Return courses where the user is enrolled.
* @return array of warnings and status result
* @since Moodle 3.1
* @throws moodle_exception
*/
public static function list_participants($assignid, $groupid, $filter, $skip, $limit, $onlyids, $includeenrolments) {
global $DB, $CFG;
require_once($CFG->dirroot . "/mod/assign/locallib.php");
require_once($CFG->dirroot . "/user/lib.php");
$params = self::validate_parameters(self::list_participants_parameters(),
array(
'assignid' => $assignid,
'groupid' => $groupid,
'filter' => $filter,
'skip' => $skip,
'limit' => $limit,
'onlyids' => $onlyids,
'includeenrolments' => $includeenrolments
));
$warnings = array();
list($assign, $course, $cm, $context) = self::validate_assign($params['assignid']);
require_capability('mod/assign:view', $context);
$assign->require_view_grades();
$participants = array();
if (groups_group_visible($params['groupid'], $course, $cm)) {
$participants = $assign->list_participants_with_filter_status_and_group($params['groupid']);
}
$userfields = user_get_default_fields();
if (!$params['includeenrolments']) {
// Remove enrolled courses from users fields to be returned.
$key = array_search('enrolledcourses', $userfields);
if ($key !== false) {
unset($userfields[$key]);
} else {
throw new moodle_exception('invaliduserfield', 'error', '', 'enrolledcourses');
}
}
$result = array();
$index = 0;
foreach ($participants as $record) {
// Preserve the fullname set by the assignment.
$fullname = $record->fullname;
$searchable = $fullname;
$match = false;
if (empty($filter)) {
$match = true;
} else {
$filter = core_text::strtolower($filter);
$value = core_text::strtolower($searchable);
if (is_string($value) && (core_text::strpos($value, $filter) !== false)) {
$match = true;
}
}
if ($match) {
$index++;
if ($index <= $params['skip']) {
continue;
}
if (($params['limit'] > 0) && (($index - $params['skip']) > $params['limit'])) {
break;
}
// Now we do the expensive lookup of user details because we completed the filtering.
if (!$assign->is_blind_marking() && !$params['onlyids']) {
$userdetails = user_get_user_details($record, $course, $userfields);
} else {
$userdetails = array('id' => $record->id);
}
$userdetails['fullname'] = $fullname;
$userdetails['submitted'] = $record->submitted;
$userdetails['requiregrading'] = $record->requiregrading;
if (!empty($record->groupid)) {
$userdetails['groupid'] = $record->groupid;
}
if (!empty($record->groupname)) {
$userdetails['groupname'] = $record->groupname;
}
$result[] = $userdetails;
}
}
return $result;
}
示例7: moodle_url
$PAGE->navbar->add(get_string('modulenameplural', 'rcontent'), new moodle_url('/mod/rcontent/index.php', array('id' => $course->id)));
$PAGE->navbar->add($rcontent->name);
$PAGE->set_url($url);
//call to autentification web services
require_once $CFG->dirroot . '/local/rcommon/WebServices/AuthenticateContent.php';
$rcontent->module = 'rcontent';
$rcontent->cmid = $cm->id;
$return = AuthenticateUserContent($rcontent);
if ($return->AutenticarUsuarioContenidoResult->Codigo <= 0 || !isset($return->AutenticarUsuarioContenidoResult->URL) || empty($return->AutenticarUsuarioContenidoResult->URL)) {
print_error(get_string('error_authentication', 'local_rcommon') . $return->AutenticarUsuarioContenidoResult->Codigo . ', ' . $return->AutenticarUsuarioContenidoResult->Descripcion);
}
$url = $return->AutenticarUsuarioContenidoResult->URL;
if ($rcontent->popup == 1) {
$options = $rcontent->popup_options;
if (core_text::strpos($options, ',height') !== false) {
$options = core_text::substr($options, 0, core_text::strpos($options, ',height'));
}
$PAGE->requires->data_for_js('rcontentplayerdata', array('cwidth' => str_replace('%', '', $rcontent->width), 'cheight' => str_replace('%', '', $rcontent->height), 'popupoptions' => $options, 'courseid' => $rcontent->course, 'launch' => true, 'launch_url' => $url), true);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($rcontent->name));
$content = '<a target="_blank" href="' . $url . '">' . get_string('popupblockedlinkname', 'rcontent') . '</a>';
echo $OUTPUT->box(get_string('popupblocked', 'rcontent', $content));
$PAGE->requires->js('/mod/rcontent/view.js');
$PAGE->requires->js_init_call('M.mod_rcontentform.init');
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($rcontent->name));
$framesize = get_config('rcontent', 'framesize');
echo '<iframe height="' . $framesize . 'px" width="100%" src="' . $url . '" id="rcontent_iframe"> <a href="' . $url . '" target="_blank">Resource</a></iframe>';
echo '<script type="text/javascript">
//<![CDATA[
示例8: _satisfies_match
/**
* Test whether a course shortname matches a string. Use regex if indicated by the admin settings.
*
* @param string $coursename The shortname of a course
* @param string $teststring The string to match against
* @return bool
*/
private function _satisfies_match($coursename, $teststring)
{
if ($this->fclconfig->useregex == BLOCK_FILTERED_COURSE_LIST_FALSE) {
$satisfies = core_text::strpos($coursename, $teststring) !== false ?: false;
} else {
$teststring = str_replace('`', '', $teststring);
$satisfies = preg_match("`{$teststring}`i", $coursename) == 1 ?: false;
}
return $satisfies;
}
示例9: rcontent_get_urlviewresults_link
if ($rcontentuser->urlviewresults != "") {
$href = rcontent_get_urlviewresults_link($rcontentuser->urlviewresults);
}
// Show update activity link
if ($canupdatescore) {
$href .= ' | ' . rcontent_get_uploadscore_link($id, $rcontentuser->userid, $rcontentuser->attempt, $rcontentuser->id);
}
if (!empty($href)) {
$row[] = $href;
$showhreffield = true;
}
// Filter by status
if ($filterby != '' && $status[0] != $filterby || $status[1] == '') {
$realstat = $status[0] != '' ? get_string($status[0], 'rcontent') : '';
$stat = $filterby != '' ? get_string($filterby, 'rcontent') : $realstat;
$fieldstoreset = core_text::strpos($row[0], '<input') === false ? array(3 => "", 4 => "", 5 => $stat, 6 => "", 7 => "", 8 => "") : array(4 => "", 5 => "", 6 => $stat, 7 => "", 8 => "", 9 => "");
foreach ($fieldstoreset as $key => $val) {
$row[$key] = $val;
}
}
$table->data[] = $row;
// If original status is POR_CORREGIR set background to red
if ($status[1] == "POR_CORREGIR") {
$table->rowclasses[] = 'uuerror';
} else {
$table->rowclasses[] = '';
}
}
if (isset($table->data) && count($table->data) > 0) {
// Now the theader
$table->head = array();
示例10: AuthenticateUserContent
/**
* Web Service to authenticate users credentials
* @param object $data -> mod values
* @return obj -> web service response
*/
function AuthenticateUserContent($data, $usr_creden = false, $showurl = true)
{
global $CFG, $DB, $USER, $OUTPUT;
$from = optional_param('from', '', PARAM_TEXT);
if (!isset($data->bookid) || ($book = $DB->get_record('rcommon_books', array('id' => $data->bookid))) == false) {
print_error(get_string('nobookid', 'local_rcommon'));
//save error on bd
} elseif (($publisher = $DB->get_record('rcommon_publisher', array('id' => $book->publisherid))) == false) {
print_error(get_string('nopublisher', 'local_rcommon'));
//save error on bd
}
if (!$usr_creden) {
$usr_creden = credentials::get_by_user_isbn($USER->id, $book->isbn);
}
if (!$usr_creden) {
// Moved $url variable to use it also in the else clause and changed the default behavior
/*set url*/
if (isset($_SERVER)) {
$SERVER_NAME = $_SERVER['SERVER_NAME'];
$SERVER_PORT = $_SERVER['SERVER_PORT'];
$SCRIPT_NAME = $_SERVER['REQUEST_URI'];
$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
} elseif (isset($HTTP_SERVER_VARS)) {
$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
$SCRIPT_NAME = $HTTP_SERVER_VARS['REQUEST_URI'];
$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
}
if ($SERVER_PORT == 80) {
$SERVER_PORT = '';
} else {
$SERVER_PORT = ':' . $SERVER_PORT;
}
if ($HTTPS == '1' || $HTTPS == 'on') {
$SCHEME = 'https';
} else {
$SCHEME = 'http';
}
$url = "{$SCHEME}://{$SERVER_NAME}{$SERVER_PORT}{$SCRIPT_NAME}";
redirect($CFG->wwwroot . '/local/rcommon/formInsert.php?url=' . base64_encode($url) . '&isbn=' . $book->isbn);
exit;
//save error on bd
} else {
if (!empty($data->unitid) && ($unit = $DB->get_record('rcommon_books_units', array('id' => $data->unitid))) == false) {
print_error(get_string('nounit', 'block_rcommon'));
//save error on bd
} else {
if (!empty($data->activityid) && ($activ = $DB->get_record('rcommon_books_activities', array('id' => $data->activityid))) == false) {
print_error('noactivity', 'block_rcommon');
//save error on bd
}
}
}
//look for the group if he has anyone assigned
$grupo = $DB->get_recordset_sql("SELECT GRUPO.id\r\n FROM {user} USERS\r\n JOIN {role_assignments} ra ON ra.userid = USERS.id\r\n JOIN {role} r ON ra.roleid = r.id\r\n JOIN {context} con ON ra.contextid = con.id\r\n JOIN {course} COURSE ON COURSE.id = con.instanceid\r\n AND con.contextlevel =50\r\n JOIN {groups} GRUPO ON GRUPO.courseid = COURSE.id\r\n JOIN {groups_members} MEMBER ON MEMBER.groupid = GRUPO.id\r\n AND MEMBER.userid = USERS.id\r\n WHERE COURSE.id = {$data->course}\r\n AND USERS.id = {$USER->id}");
foreach ($grupo as $grp) {
$grupoid = $grp->id;
}
try {
$client = get_marsupial_ws_client($publisher, true);
$params = new stdClass();
$params->Credencial = new SoapVar($usr_creden->credentials, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$params->ISBN = new SoapVar($book->isbn, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$params->IdUsuario = new SoapVar($usr_creden->euserid, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
//$params->NombreApe = new SoapVar($USER->firstname." ".$USER->lastname, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
//convert rcommon_teacherroles to array
$rcommon_teacherroles = explode(',', get_config('rcommon', 'teacherroles'));
//get user role
// To avoid problems because in some cases the courseid was null
$context = context_course::instance($data->course);
$iduserrole = array();
if ($roles = get_user_roles($context, $USER->id)) {
foreach ($roles as $role) {
$iduserrole = $role->roleid;
}
}
//set role string
$rolestring = "ESTUDIANTE";
if (in_array($iduserrole, $rcommon_teacherroles)) {
$rolestring = "PROFESOR";
}
//check if the web service is prepared to receive rol parameter
$parsed_wsdl = rcommon_get_wsdl($publisher->urlwsauthentication . '?wsdl');
if (core_text::strpos($parsed_wsdl, 'name="Rol"') && $rolestring == "PROFESOR") {
$params->Rol = new SoapVar($rolestring, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
}
$params->IdCurso = new SoapVar($data->course, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$centerid = isset($CFG->center) ? $CFG->center : '';
$params->IdCentro = new SoapVar($centerid, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$params->URLResultado = new SoapVar("{$CFG->wwwroot}/mod/rcontent/WebServices/wsSeguimiento.php", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$params->IdContenidoLMS = new SoapVar($data->id, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$unitid = isset($unit->code) ? $unit->code : '';
$params->IdUnidad = new SoapVar($unitid, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
$activid = isset($activ->code) ? $activ->code : '';
$params->IdActividad = new SoapVar($activid, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema");
//.........这里部分代码省略.........
示例11: stdClass
$record = new stdClass();
$record->code = $fromform->code;
$record->name = empty($fromform->name) ? $fromform->code : $fromform->name;
$record->urlwsauthentication = str_replace("\\", "/", $fromform->urlwsauthentication);
$record->urlwsbookstructure = str_replace("\\", "/", $fromform->urlwsbookstructure);
$record->username = $fromform->username;
$record->password = $fromform->password;
$record->timemodified = time();
//extra controls
if (empty($record->name)) {
print_error(get_string('savekoemptyvalues', 'local_rcommon'), $CFG->wwwroot . '/local/rcommon/publishers.php');
}
if (!empty($record->urlwsauthentication) && ($pos = core_text::strpos(core_text::strtolower($record->urlwsauthentication), '?wsdl'))) {
$record->urlwsauthentication = core_text::substr($record->urlwsauthentication, 0, $pos);
}
if (!empty($record->urlwsbookstructure) && ($pos = core_text::strpos(core_text::strtolower($record->urlwsbookstructure), '?wsdl'))) {
$record->urlwsbookstructure = core_text::substr($record->urlwsbookstructure, 0, $pos);
}
//do save
if (empty($publisher)) {
$record->timecreated = $record->timemodified;
if (!$DB->insert_record('rcommon_publisher', $record)) {
redirect($CFG->wwwroot . '/local/rcommon/publishers.php?action=edit&publisher=' . $publisher, get_string('saveko', 'local_rcommon'), 5);
}
} else {
$record->id = $publisher;
if (!$DB->update_record('rcommon_publisher', $record)) {
redirect($CFG->wwwroot . '/local/rcommon/publishers.php?action=edit&publisher=' . $publisher, get_string('saveko', 'local_rcommon'), 5);
}
}
redirect($CFG->wwwroot . '/local/rcommon/publishers.php', get_string('saveok', 'local_rcommon'), 2);