本文整理汇总了PHP中Hubzero\Utility\String类的典型用法代码示例。如果您正苦于以下问题:PHP String类的具体用法?PHP String怎么用?PHP String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* Highlight some text
*
* @param string $text Text to find phrases in
* @param integer $phrase Phrase to highlight
* @param array $options Options for highlighting
* @return string
* @throws \InvalidArgumentException If no text was passed
*/
public function __invoke($text = null, $phrase = null, $options = array())
{
if (null === $text) {
throw new \InvalidArgumentException(__METHOD__ . '(); No text passed.');
}
return String::highlight($text, $phrase, $options);
}
示例2: __invoke
/**
* Obfuscate some text
*
* @param string $text Text to obfuscate
* @return string
* @throws \InvalidArgumentException If no text passed
*/
public function __invoke($text = null)
{
if (null === $text) {
throw new \InvalidArgumentException(__METHOD__ . '(); No text passed.');
}
return String::obfuscate($text);
}
示例3: __invoke
/**
* Truncate some text
*
* @param string $text Text to truncate
* @param integer $length Length to truncate to
* @param array $options Options
* @return string
* @throws \InvalidArgumentException If no text is passed or length isn't a positive integer
*/
public function __invoke($text = null, $length = null, $options = array())
{
if (null === $text) {
throw new \InvalidArgumentException(__METHOD__ . '(); No text passed.');
}
if (!$length || !is_numeric($length)) {
throw new \InvalidArgumentException(__METHOD__ . '(); Length must be an integer');
}
return String::truncate($text, $length, $options);
}
示例4: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($scope_id = 0)
{
$this->set('scope_id', $scope_id);
$this->_segments['id'] = $scope_id;
$this->_segments['active'] = 'blog';
$this->_item = Profile::getInstance($scope_id);
$config = Plugin::params('members', 'blog');
$id = String::pad($this->get('scope_id'));
$this->set('path', str_replace('{{uid}}', $id, $config->get('uploadpath', '/site/members/{{uid}}/blog')));
$this->set('scope', $this->get('scope_id') . '/blog');
$this->set('option', $this->_segments['option']);
}
示例5: check
/**
* Validate data
*
* @return boolean True if data is valid
*/
public function check()
{
$this->message = trim($this->message);
if ($this->message == '') {
$this->setError(Lang::txt('SUPPORT_ERROR_BLANK_FIELD'));
return false;
}
$this->title = trim($this->title);
if (!$this->title) {
$this->title = String::truncate($this->message, 250);
}
return true;
}
示例6: __construct
/**
* Constructor
*
* @param integer $scope_id Scope ID (group, course, etc.)
* @return void
*/
public function __construct($scope_id = 0)
{
$this->set('scope_id', $scope_id);
include_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'courses.php';
$offering = \Components\Courses\Models\Offering::getInstance($this->get('scope_id'));
$course = \Components\Courses\Models\Course::getInstance($offering->get('course_id'));
$this->_segments['gid'] = $course->get('alias');
$this->_segments['offering'] = $offering->alias();
$this->_segments['active'] = 'discussions';
if (Request::getVar('active') == 'outline') {
$this->_segments['active'] = 'outline';
}
$this->_name = String::truncate($course->get('alias'), 50) . ': ' . String::truncate($offering->get('alias'), 50);
}
示例7: parse
/**
* Parse Document Content
*
* @return void
*/
public function parse()
{
// check to make sure we have content
if (!$this->get('document')) {
App::abort(406, '\\Components\\Groups\\Helpers\\Document: Requires document to parse');
}
// parse content
// get all group includes
if (preg_match_all('#<group:include([^>]*)/>#', $this->get('document'), $matches)) {
// get number of matches
$count = count($matches[1]);
//loop through each match
for ($i = 0; $i < $count; $i++) {
$attribs = String::parseAttributes($matches[1][$i]);
$type = isset($attribs['type']) ? strtolower(trim($attribs['type'])) : null;
$name = isset($attribs['name']) ? $attribs['name'] : $type;
unset($attribs['type']);
$params = $attribs;
$this->_tags[$matches[0][$i]] = array('type' => $type, 'name' => $name, 'params' => $params);
}
}
// return this
return $this;
}
示例8: content
/**
* Get the content of the entry
*
* @param string $as Format to return state in [text, number]
* @param integer $shorten Number of characters to shorten text to
* @return string
*/
public function content($as = 'parsed', $shorten = 0)
{
$as = strtolower($as);
$options = array();
switch ($as) {
case 'parsed':
$content = $this->get('comment.parsed', null);
if ($content === null) {
$config = array('option' => $this->get('option', 'com_projects'), 'scope' => $this->get('scope'), 'pagename' => $this->get('alias'), 'pageid' => 0, 'filepath' => $this->get('path'), 'domain' => '');
$content = str_replace(array('\\"', "\\'"), array('"', "'"), (string) $this->get('comment', ''));
$this->importPlugin('content')->trigger('onContentPrepare', array($this->_context, &$this, &$config));
$this->set('comment.parsed', (string) $this->get('comment', ''));
$this->set('comment', $content);
return $this->content($as, $shorten);
}
$options['html'] = true;
break;
case 'clean':
$content = strip_tags($this->content('parsed'));
break;
case 'raw':
default:
$content = str_replace(array('\\"', "\\'"), array('"', "'"), $this->get('comment'));
$content = preg_replace('/^(<!-- \\{FORMAT:.*\\} -->)/i', '', $content);
break;
}
if ($shorten) {
$content = \Hubzero\Utility\String::truncate($content, $shorten, $options);
}
return $content;
}
示例9: transferItem
/**
* Retrieves a row from the database
*
* @param string $refid ID of the database table row
* @param string $category Element type (determines table to look in)
* @param string $parent If the element has a parent element
* @return array
*/
public function transferItem($from_type, $from_id, $to_type, $rid = 0, $deactivate = 1)
{
$upconfig = Component::params('com_members');
$this->banking = $upconfig->get('bankAccounts');
$database = App::get('db');
if ($from_type == NULL or $from_id == NULL or $to_type == NULL) {
$this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_MISSING_INFO'));
return false;
}
if ($from_type == $to_type) {
$this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_CATEGORIES_MUST_BE_DIFFERENT'));
return false;
}
// collectors
$author = '';
$subject = '';
$body = '';
$tags = '';
$owner = '';
// name of group owning the item
$anonymous = 0;
// get needed scripts
include_once PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'models' . DS . 'ticket.php';
include_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'models' . DS . 'question.php';
include_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'models' . DS . 'wishlist.php';
$wconfig = Component::params('com_wishlist');
$admingroup = $wconfig->get('group') ? $wconfig->get('group') : 'hubadmin';
// Get needed scripts & initial data
switch ($from_type) {
// Transfer from a Support Ticket
case 'ticket':
$row = new \Components\Support\Models\Ticket($from_id);
if ($row->exists()) {
$author = $row->get('login');
$subject = $row->content('raw', 200);
// max 200 characters
$body = $row->get('summary');
$owner = $row->get('group');
// If we are de-activating original item
if ($deactivate) {
$row->set('status', 2);
$row->set('resolved', 'transfered');
}
$tags = $row->tags('string');
} else {
$this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_ITEM_NOT_FOUND'));
return false;
}
break;
// Transfer from a Question
// Transfer from a Question
case 'question':
$row = new \Components\Answers\Models\Question($from_id);
if ($row->exists()) {
$author = $row->get('created_by');
$subject = $row->subject('raw', 200);
// max 200 characters
$body = $row->get('question');
$anonymous = $row->get('anonymous');
// If we are de-activating original item
if ($deactivate) {
$row->set('state', 2);
$row->set('reward', 0);
}
$tags = $row->tags('string');
} else {
$this->setError(Lang::txt('PLG_SUPPORT_TRANSFER_ERROR_ITEM_NOT_FOUND'));
return false;
}
break;
// Transfer from a Wish
// Transfer from a Wish
case 'wish':
$row = new \Components\Wishlist\Tables\Wish($database);
$row->load($from_id);
if ($row->id) {
$author = $row->proposed_by;
$subject = \Hubzero\Utility\String::truncate($row->subject, 200);
// max 200 characters
$body = $row->about;
$anonymous = $row->anonymous;
// If we are de-activating original item
if ($deactivate) {
$row->status = 2;
$row->ranking = 0;
// also delete all previous votes for this wish
$objR = new \Components\Wishlist\Tables\Rank($database);
$objR->remove_vote($from_id);
}
// get owner
$objG = new \Components\Wishlist\Tables\OwnerGroup($database);
$nativegroups = $objG->get_owner_groups($row->wishlist, $admingroup, '', 1);
//.........这里部分代码省略.........
示例10: _process
/**
* Process data
*
* @return void
*/
protected function _process()
{
// New project?
$new = $this->model->exists() ? false : true;
// Are we in setup?
$setup = $new || $this->model->inSetup() ? true : false;
// Incoming
$private = Request::getInt('private', 1);
// Save section
switch ($this->section) {
case 'describe':
case 'info':
// Incoming
$name = trim(Request::getVar('name', '', 'post'));
$title = trim(Request::getVar('title', '', 'post'));
$name = preg_replace('/ /', '', $name);
$name = strtolower($name);
// Clean up title from any scripting
$title = preg_replace('/\\s+/', ' ', $title);
$title = $this->_txtClean($title);
// Check incoming data
if ($setup && $new && !$this->model->check($name, $this->model->get('id'))) {
$this->setError(Lang::txt('COM_PROJECTS_ERROR_NAME_INVALID_OR_EMPTY'));
return false;
} elseif (!$title) {
$this->setError(Lang::txt('COM_PROJECTS_ERROR_TITLE_SHORT_OR_EMPTY'));
return false;
}
if ($this->model->exists()) {
$this->model->set('modified', Date::toSql());
$this->model->set('modified_by', User::get('id'));
} else {
$this->model->set('alias', $name);
$this->model->set('created', Date::toSql());
$this->model->set('created_by_user', User::get('id'));
$this->model->set('owned_by_group', $this->_gid);
$this->model->set('owned_by_user', User::get('id'));
$this->model->set('private', $this->config->get('privacy', 1));
}
$this->model->set('title', \Hubzero\Utility\String::truncate($title, 250));
$this->model->set('about', trim(Request::getVar('about', '', 'post', 'none', 2)));
$this->model->set('type', Request::getInt('type', 1, 'post'));
// save advanced permissions
if (isset($_POST['private'])) {
$this->model->set('private', $private);
}
if ($setup && !$this->model->exists()) {
// Copy params from default project type
$objT = $this->model->table('Type');
$this->model->set('params', $objT->getParams($this->model->get('type')));
}
// Save changes
if (!$this->model->store()) {
$this->setError($this->model->getError());
return false;
}
// Save owners for new projects
if ($new) {
$this->_identifier = $this->model->get('alias');
// Group owners
$objO = $this->model->table('Owner');
if ($this->_gid) {
if (!$objO->saveOwners($this->model->get('id'), User::get('id'), 0, $this->_gid, 0, 1, 1, '', $split_group_roles = 0)) {
$this->setError(Lang::txt('COM_PROJECTS_ERROR_SAVING_AUTHORS') . ': ' . $objO->getError());
return false;
}
// Make sure project creator is manager
$objO->reassignRole($this->model->get('id'), $users = array(User::get('id')), 0, 1);
} elseif (!$objO->saveOwners($this->model->get('id'), User::get('id'), User::get('id'), $this->_gid, 1, 1, 1)) {
$this->setError(Lang::txt('COM_PROJECTS_ERROR_SAVING_AUTHORS') . ': ' . $objO->getError());
return false;
}
}
break;
case 'team':
if ($new) {
return false;
}
// Save team
$content = Event::trigger('projects.onProject', array($this->model, 'save', array('team')));
if (isset($content[0]) && $this->next == $this->section) {
if (isset($content[0]['msg']) && !empty($content[0]['msg'])) {
$this->_setNotification($content[0]['msg']['message'], $content[0]['msg']['type']);
}
}
break;
case 'settings':
if ($new) {
return false;
}
// Save privacy
if (isset($_POST['private'])) {
$this->model->set('private', $private);
// Save changes
if (!$this->model->store()) {
//.........这里部分代码省略.........
示例11: out
/**
* Static method for formatting results
*
* @param object $row Database row
* @return string HTML
*/
public static function out($row)
{
$row->href = Route::url($row->href);
$month = Date::of($row->publish_up)->toLocal('M');
$day = Date::of($row->publish_up)->toLocal('d');
$year = Date::of($row->publish_up)->toLocal('Y');
// Start building the HTML
$html = "\t" . '<li class="event">' . "\n";
$html .= "\t\t" . '<p class="event-date"><span class="month">' . $month . '</span> <span class="day">' . $day . '</span> <span class="year">' . $year . '</span></p>' . "\n";
$html .= "\t\t" . '<p class="title"><a href="' . $row->href . '">' . stripslashes($row->title) . '</a></p>' . "\n";
if ($row->ftext) {
$row->ftext = str_replace('[[BR]]', '', $row->ftext);
// Remove tags to prevent tables from being displayed within a table.
$row->ftext = strip_tags($row->ftext);
$html .= "\t\t" . \Hubzero\Utility\String::truncate(\Hubzero\Utility\Sanitize::stripAll(stripslashes($row->ftext)), 200) . "\n";
}
$html .= "\t\t" . '<p class="href">' . Request::base() . trim($row->href, '/') . '</p>' . "\n";
$html .= "\t" . '</li>' . "\n";
// Return output
return $html;
}
示例12: ucfirst
}
?>
<?php
if ($this->row->isComplete()) {
?>
» <span class="indlist completedtd"><a href="<?php
echo Route::url($url) . '/?state=1';
?>
"><?php
echo ucfirst(Lang::txt('PLG_PROJECTS_TODO_COMPLETED'));
?>
</a></span> <?php
}
?>
» <span class="itemname"><?php
echo \Hubzero\Utility\String::truncate($this->row->get('content'), 60);
?>
</span>
</h3>
</div>
<div class="pinboard">
<section class="section intropage">
<div class="grid">
<div class="col span8">
<div id="td-item" class="<?php
echo $class;
?>
">
<span class="pin"> </span>
<div class="todo-content">
示例13:
<?php
if ($this->params->get('access_email', 2) == 0 || $this->params->get('access_email', 2) == 1 && $loggedin || $this->params->get('access_email', 2) == 2 && $isUser) {
?>
<li class="profile-email field">
<div class="field-content">
<div class="key"><?php
echo Lang::txt('PLG_GROUPS_PROFILE_EMAIL');
?>
</div>
<div class="value">
<a class="email" href="mailto:<?php
echo \Hubzero\Utility\String::obfuscate($this->profile->get('email'));
?>
" rel="nofollow">
<?php
echo \Hubzero\Utility\String::obfuscate($this->profile->get('email'));
?>
</a>
</div>
</div>
</li>
<?php
}
?>
<?php
}
?>
<?php
if ($this->registration->ORCID != REG_HIDE && $this->profile->get('orcid')) {
?>
示例14:
</td>
<td>
<span class="<?php
echo $class;
?>
hasTip" title="<?php
echo $status;
?>
"> </span>
</td>
<td>
<a href="<?php
echo Route::url('index.php?option=com_projects&task=edit&id[]=' . $row->project_id);
?>
"><?php
echo \Hubzero\Utility\String::truncate($row->project_title, 50);
?>
</a>
</td>
<td>
<a href="<?php
echo Route::url('index.php?option=' . $this->option . '&controller=' . $this->controller . '&task=versions&id=' . $row->id . $filterstring);
?>
"><?php
echo $this->escape($row->versions);
?>
</a>
</td>
<td>
<?php
echo $this->escape($row->base);
示例15:
$html .= "\t\t\t" . '<td>' . $breeze . '</td>' . "\n";
}
$html .= "\t\t\t" . '<td>' . $videoi . '</td>' . "\n";
$html .= "\t\t\t" . '<td>' . $pdf . '</td>' . "\n";
$html .= "\t\t\t" . '<td>' . $supp . '</td>' . "\n";
$html .= "\t\t\t" . '<td>' . $exercises . '</td>' . "\n";
} else {
//$html .= "\t\t\t".'<td colspan="5">'.Lang::txt('Currently unavilable').'</td>'."\n";
$html .= "\t\t\t" . '<td colspan="5"> </td>' . "\n";
}
$html .= "\t\t" . '</tr>' . "\n";
if ($child->standalone == 1) {
if ($child->type != 31 && $child->introtext) {
$html .= "\t\t" . '<tr class="' . $o . '">' . "\n";
$html .= "\t\t\t" . '<td colspan="6">';
$html .= \Hubzero\Utility\String::truncate(stripslashes($child->introtext), 200) . '<br /><br />';
$html .= "\t\t\t" . '</td>' . "\n";
$html .= "\t\t" . '</tr>' . "\n";
}
}
}
echo $html;
?>
</tbody>
</table>
<?php
}
}
?>
</section><!-- / .main section -->
<?php