本文整理汇总了PHP中CStringHelper类的典型用法代码示例。如果您正苦于以下问题:PHP CStringHelper类的具体用法?PHP CStringHelper怎么用?PHP CStringHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CStringHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getAllEvents
private function _getAllEvents()
{
$mainframe = JFactory::getApplication();
$rows = $this->model->getEvents();
$items = array();
foreach ($rows as $row) {
$item = new stdClass();
$table =& JTable::getInstance('Event', 'CTable');
$table->bind($row);
$table->thumbnail = $table->getThumbAvatar();
$table->avatar = $table->getAvatar();
$author = CFactory::getUser($table->creator);
$item->id = $row->id;
$item->created = $row->created;
$item->creator = CStringHelper::escape($author->getDisplayname());
$item->title = $row->title;
$item->description = CStringHelper::escape($row->description);
$item->location = CStringHelper::escape($row->location);
$tiem->startdate = $row->startdate;
$item->enddate = $row->enddate;
$item->thumbnail = $table->thumbnail;
$tiem->avatar = $table->avatar;
$item->ticket = $row->ticket;
$item->invited = $row->invitedcount;
$item->confirmed = $row->confirmedcount;
$item->declined = $row->declinedcount;
$item->maybe = $row->maybecount;
$item->latitude = $row->latitude;
$item->longitude = $row->longitude;
$items[] = $item;
}
return $items;
}
示例2: getFieldHTML
public function getFieldHTML($field, $required)
{
$class = $field->required == 1 ? ' required validate-custom-checkbox' : '';
$lists = is_array($field->value) ? $field->value : explode(',', $field->value);
$html = '';
$elementSelected = 0;
$elementCnt = 0;
$style = ' style="margin: 0 5px 5px 0;' . $this->getStyle() . '" ';
$cnt = 0;
CFactory::load('helpers', 'string');
$class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
$html .= '<div class="' . $class . '" style="display: inline-block;" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
if (is_array($field->options)) {
foreach ($field->options as $option) {
$selected = in_array(JString::trim($option), $lists) ? ' checked="checked"' : '';
if (empty($selected)) {
$elementSelected++;
}
$html .= '<label class="lblradio-block">';
$html .= '<input type="checkbox" name="field' . $field->id . '[]" value="' . $option . '"' . $selected . ' class="checkbox ' . $class . $style . ' />';
$html .= JText::_($option) . '</label>';
$elementCnt++;
}
}
$html .= '<span id="errfield' . $field->id . 'msg" style="display: none;"> </span>';
$html .= '</div>';
return $html;
}
示例3: getFieldHTML
public function getFieldHTML($field, $required)
{
$html = '';
$selectedElement = 0;
$elementSelected = 0;
$elementCnt = 0;
$params = new CParameter($field->params);
$readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' disabled="disabled"' : '';
for ($i = 0; $i < count($field->options); $i++) {
$option = $field->options[$i];
$selected = $option == $field->value ? ' checked="checked"' : '';
if (empty($selected)) {
$elementSelected++;
}
$elementCnt++;
}
$cnt = 0;
$html .= '<div style="display:inline-block" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
for ($i = 0; $i < count($field->options); $i++) {
$option = $field->options[$i];
$selected = html_entity_decode($option) == html_entity_decode($field->value) ? ' checked="checked"' : '';
$html .= '<label class="lblradio-block">';
$html .= '<input type="radio" name="field' . $field->id . '" value="' . $option . '"' . $selected . $readonly . ' style="margin: 2px 5px 0 0" />';
$html .= JText::_($option) . '</label>';
}
$html .= '</div>';
return $html;
}
示例4: getFieldHTML
public function getFieldHTML($field, $required)
{
$class = $field->required == 1 ? ' required' : '';
$class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
$lists = explode(',', $field->value);
CFactory::load('helpers', 'string');
$html = '<select id="field' . $field->id . '" name="field' . $field->id . '[]" type="select-multiple" multiple="multiple" class="jomNameTips tipRight select' . $class . '" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
$elementSelected = 0;
foreach ($field->options as $option) {
$selected = in_array($option, $lists) ? ' selected="selected"' : '';
if (empty($selected)) {
$elementSelected++;
}
$html .= '<option value="' . $option . '"' . $selected . '>' . JText::_($option) . '</option>';
}
if ($elementSelected == 0) {
//if nothing is selected, we default the 1st option to be selected.
$elementName = 'field' . $field->id;
$html .= <<<HTML
\t\t\t\t
\t\t\t\t <script type='text/javascript'>
\t\t\t\t\t var slt = document.getElementById('{$elementName}');
\t\t\t\t\t if(slt != null){
\t\t\t\t\t slt.options[0].selected = true;\t\t\t\t\t
\t\t\t\t\t }
\t\t\t\t </script>
HTML;
}
$html .= '</select>';
$html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>';
return $html;
}
示例5: getFieldHTML
function getFieldHTML($field, $required)
{
$html = '';
$selectedElement = 0;
$class = $field->required == 1 ? ' required validate-custom-radio' : '';
$elementSelected = 0;
$elementCnt = 0;
for ($i = 0; $i < count($field->options); $i++) {
$option = $field->options[$i];
$selected = $option == $field->value ? ' checked="checked"' : '';
if (empty($selected)) {
$elementSelected++;
}
$elementCnt++;
}
$cnt = 0;
CFactory::load('helpers', 'string');
$class = !empty($field->tips) ? 'jomTips tipRight' : '';
$html .= '<div class="' . $class . '" style="display: inline-block;" title="' . JText::_($field->name) . '::' . CStringHelper::escape(JText::_($field->tips)) . '">';
for ($i = 0; $i < count($field->options); $i++) {
$option = $field->options[$i];
$selected = $option == $field->value ? ' checked="checked"' : '';
$html .= '<label class="lblradio-block">';
$html .= '<input type="radio" name="field' . $field->id . '" value="' . $option . '"' . $selected . ' class="radio ' . $class . '" style="margin: 0 5px 0 0;" />';
$html .= JText::_($option) . '</label>';
}
$html .= '<span id="errfield' . $field->id . 'msg" style="display: none;"> </span>';
$html .= '</div>';
return $html;
}
示例6: display
/**
* The default method that will display the output of this view which is called by
* Joomla
*
* @param string template Template file name
**/
public function display($tpl = null)
{
$document = JFactory::getDocument();
$config =& CFactory::getConfig();
// Get required data's
$events = $this->get('Events');
$categories = $this->get('Categories');
$pagination = $this->get('Pagination');
$mainframe =& JFactory::getApplication();
$filter_order = $mainframe->getUserStateFromRequest("com_community.events.filter_order", 'filter_order', 'a.title', 'cmd');
$filter_order_Dir = $mainframe->getUserStateFromRequest("com_community.events.filter_order_Dir", 'filter_order_Dir', '', 'word');
$search = $mainframe->getUserStateFromRequest("com_community.events.search", 'search', '', 'string');
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
// We need to assign the users object to the groups listing to get the users name.
for ($i = 0; $i < count($events); $i++) {
$row =& $events[$i];
$row->user = JFactory::getUser($row->creator);
// Truncate the description
CFactory::load('helpers', 'string');
$row->description = CStringHelper::truncate($row->description, $config->get('tips_desc_length'));
}
$catHTML = $this->_getCategoriesHTML($categories);
$this->assignRef('events', $events);
$this->assignRef('categories', $catHTML);
$this->assignRef('search', $search);
$this->assignRef('lists', $lists);
$this->assignRef('pagination', $pagination);
parent::display($tpl);
}
示例7: send
/**
* Do a batch send
*/
function send($total = 100)
{
$mailqModel = CFactory::getModel('mailq');
$userModel = CFactory::getModel('user');
$mails = $mailqModel->get($total);
$jconfig = JFactory::getConfig();
$mailer = JFactory::getMailer();
$config = CFactory::getConfig();
$senderEmail = $jconfig->getValue('mailfrom');
$senderName = $jconfig->getValue('fromname');
if (empty($mails)) {
return;
}
CFactory::load('helpers', 'string');
foreach ($mails as $row) {
// @rule: only send emails that is valid.
// @rule: make sure recipient is not blocked!
$userid = $userModel->getUserFromEmail($row->recipient);
$user = CFactory::getUser($userid);
if (!$user->isBlocked() && !JString::stristr($row->recipient, 'foo.bar')) {
$mailer->setSender(array($senderEmail, $senderName));
$mailer->addRecipient($row->recipient);
$mailer->setSubject($row->subject);
$tmpl = new CTemplate();
$raw = isset($row->params) ? $row->params : '';
$params = new JParameter($row->params);
$base = $config->get('htmlemail') ? 'email.html' : 'email.text';
if ($config->get('htmlemail')) {
$row->body = JString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $row->body);
$mailer->IsHTML(true);
} else {
//@rule: Some content might contain 'html' tags. Strip them out since this mail should never contain html tags.
$row->body = CStringHelper::escape(strip_tags($row->body));
}
$tmpl->set('content', $row->body);
$tmpl->set('template', rtrim(JURI::root(), '/') . '/components/com_community/templates/' . $config->get('template'));
$tmpl->set('sitename', $config->get('sitename'));
$row->body = $tmpl->fetch($base);
// Replace any occurences of custom variables within the braces scoe { }
if (!empty($row->body)) {
preg_match_all("/{(.*?)}/", $row->body, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
$replaceWith = $params->get($val[1], null);
//if the replacement start with 'index.php', we can CRoute it
if (strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::getExternalURL($replaceWith);
}
if (!is_null($replaceWith)) {
$row->body = JString::str_ireplace($val[0], $replaceWith, $row->body);
}
}
}
unset($tmpl);
$mailer->setBody($row->body);
$mailer->send();
}
$mailqModel->markSent($row->id);
$mailer->ClearAllRecipients();
}
}
示例8: getFieldHTML
public function getFieldHTML($field, $required)
{
$required = $field->required == 1 ? ' data-required="true"' : '';
//a fix for wrong data
$field->value = JString::trim($field->value);
if (JString::strrpos($field->value, ',') == JString::strlen($field->value) - 1) {
$field->value = JString::substr($field->value, 0, -1);
}
$lists = explode(',', $field->value);
//CFactory::load( 'helpers' , 'string' );
$html = '<select id="field' . $field->id . '" name="field' . $field->id . '[]" type="select-multiple" multiple="multiple" class="joms-select joms-select--multiple" title="' . CStringHelper::escape(JText::_($field->tips)) . '" ' . $required . '>';
$elementSelected = 0;
foreach ($field->options as $option) {
$selected = in_array($option, $lists) ? ' selected="selected"' : '';
if (empty($selected)) {
$elementSelected++;
}
$html .= '<option value="' . $option . '"' . $selected . '>' . JText::_($option) . '</option>';
}
if ($elementSelected == 0) {
//if nothing is selected, we default the 1st option to be selected.
$elementName = 'field' . $field->id;
$html .= <<<HTML
<script type='text/javascript'>
var slt = document.getElementById('{$elementName}');
if(slt != null){
slt.options[0].selected = true;
}
</script>
HTML;
}
$html .= '</select>';
return $html;
}
示例9: onDiscussionDisplay
public function onDiscussionDisplay($row)
{
CError::assert($row->message, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
if (!CStringHelper::isHTML($row->message)) {
$row->message = CStringHelper::nl2br($row->message);
}
}
示例10: getFieldHTML
public function getFieldHTML($field, $required)
{
//CFactory::load( 'helpers' , 'string' );
$class = !empty($field->tips) ? ' jomNameTips tipRight' : '';
$html = '<textarea title="' . CStringHelper::escape(JText::_($field->tips)) . '" id="field' . $field->id . '" name="field' . $field->id . '" class="textarea' . $class . '" cols="20" rows="5" readonly="readonly">' . CStringHelper::escape($field->tips) . '</textarea>';
$html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>';
return $html;
}
示例11: check
public function check()
{
//CFactory::load( 'helpers', 'string');
// Santinise data
$safeHtmlFilter = CFactory::getInputFilter();
$this->caption = CStringHelper::nl2br($safeHtmlFilter->clean($this->caption));
return true;
}
示例12: onMessageDisplay
public function onMessageDisplay($row)
{
CFactory::load('helpers', 'string');
CError::assert($row->body, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
if (!CStringHelper::isHTML($row->body)) {
$row->body = CStringHelper::nl2br($row->body);
}
}
示例13: onWallDisplay
public function onWallDisplay($row)
{
//CFactory::load( 'helpers' , 'string' );
CError::assert($row->comment, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
if (!CStringHelper::isHTML($row->comment)) {
$row->comment = CStringHelper::nl2br($row->comment);
}
}
示例14: onWallDisplay
public function onWallDisplay($row)
{
//CFactory::load( 'helpers' , 'string' );
CError::assert($row->comment, '', '!empty', __FILE__, __LINE__);
// @rule: Only nl2br text that doesn't contain html tags
//@since 4.1 new rule added, to ignore newline replace
if (!CStringHelper::isHTML($row->comment) && !isset($row->newlineReplace)) {
$row->comment = CStringHelper::nl2br($row->comment);
}
}
示例15: getThumb
static function getThumb($userId, $imageClass = '', $anchorClass = '')
{
CFactory::load('helpers', 'string');
$user = CFactory::getUser($userId);
$imageClass = !empty($imageClass) ? ' class="' . $imageClass . '"' : '';
$anchorClass = !empty($anchorClass) ? ' class="' . $anchorClass . '"' : '';
$data = '<a href="' . CRoute::_('index.php?option=com_community&view=profile&userid=' . $user->id) . '"' . $anchorClass . '>';
$data .= '<img src="{user:thumbnail:' . $userId . '}" alt="' . CStringHelper::escape($user->getDisplayName()) . '"' . $imageClass . ' />';
$data .= '</a>';
return $data;
}