本文整理汇总了PHP中CParameter类的典型用法代码示例。如果您正苦于以下问题:PHP CParameter类的具体用法?PHP CParameter怎么用?PHP CParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActivityContentHTML
static function getActivityContentHTML($act)
{
// Ok, the activity could be an upload OR a wall comment. In the future, the content should
// indicate which is which
$html = '';
$param = new CParameter($act->params);
$action = $param->get('action', false);
$count = $param->get('count', false);
$config = CFactory::getConfig();
switch ($action) {
case CAdminstreamsAction::TOP_USERS:
$model = CFactory::getModel('user');
$members = $model->getPopularMember($count);
$html = '';
//Get Template Page
$tmpl = new CTemplate();
$html = $tmpl->set('members', $members)->fetch('activity.members.popular');
return $html;
break;
case CAdminstreamsAction::TOP_PHOTOS:
$model = CFactory::getModel('photos');
$photos = $model->getPopularPhotos($count, 0);
$tmpl = new CTemplate();
$html = $tmpl->set('photos', $photos)->fetch('activity.photos.popular');
return $html;
break;
case CAdminstreamsAction::TOP_VIDEOS:
$model = CFactory::getModel('videos');
$videos = $model->getPopularVideos($count);
$tmpl = new CTemplate();
$html = $tmpl->set('videos', $videos)->fetch('activity.videos.popular');
return $html;
break;
}
}
示例2: 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;
}
示例3: getFieldHTML
public function getFieldHTML($field, $required)
{
$html = '';
$selectedElement = 0;
$required = $field->required == 1 ? ' data-required="true"' : '';
$style = ' style="margin: 0 5px 0 0;' . $this->getStyle() . '" ';
$params = new CParameter($field->params);
$disabled = '';
if ($params->get('readonly') == 1) {
$disabled = 'disabled="disabled"';
}
// Gender contain only male and female
$options = array("" => "COM_COMMUNITY_SELECT_GENDER", "COM_COMMUNITY_MALE" => "COM_COMMUNITY_MALE", "COM_COMMUNITY_FEMALE" => "COM_COMMUNITY_FEMALE");
$cnt = 0;
//CFactory::load( 'helpers' , 'string' );
// REMOVE 3.3
// $class = !empty($field->tips) ? 'jomNameTips tipRight' : '';
// REMOVE 3.3
// $html .= '<div class="' . $class . '" style="display: inline-block;" title="' . CStringHelper::escape(JText::_($field->tips)) . '">';
$html .= '<select class="joms-select" name="field' . $field->id . '" ' . $required . ' ' . $disabled . ' >';
foreach ($options as $key => $val) {
$selected = $key == $field->value ? ' selected="selected" ' : '';
$html .= '<option value="' . $key . '" ' . $selected . '>' . JText::_($val) . '</option>';
}
$html .= '</select>';
// REMOVE 3.3
// $html .= '<span id="errfield' . $field->id . 'msg" style="display: none;"> </span>';
// $html .= '</div>';
return $html;
}
示例4: ajaxTogglePublish
public function ajaxTogglePublish($id, $type, $eventName = false)
{
// Send email notification to owner when a group is published.
$config = CFactory::getConfig();
$event = JTable::getInstance('Event', 'CTable');
$event->load($id);
// Added published = 2 for new created event under moderation.
if ($type == 'published' && $event->published == 2) {
$lang = JFactory::getLanguage();
$lang->load('com_community', JPATH_ROOT);
$my = CFactory::getUser();
// Add notification
//CFactory::load('libraries', 'notification');
//CFactory::load('helpers', 'event');
if ($event->type == CEventHelper::GROUP_TYPE && $event->contentid != 0) {
$url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id . '&groupid=' . $event->contentid;
} else {
$url = 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id;
}
//Send notification email to owner
$params = new CParameter('');
$params->set('url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
$params->set('event', $event->title);
$params->set('event_url', 'index.php?option=com_community&view=events&task=viewevent&eventid=' . $event->id);
CNotificationLibrary::add('events_notify_creator', $my->id, $event->creator, JText::_('COM_COMMUNITY_EVENTS_PUBLISHED_MAIL_SUBJECT'), '', 'events.notifycreator', $params);
//CFactory::load('libraries', 'events');
// Add activity stream for new created event.
$event->published = 1;
// by pass published checking.
CEvents::addEventStream($event);
// send notification email to group's member for new created event.
CEvents::addGroupNotification($event);
}
return parent::ajaxTogglePublish($id, $type, 'events');
}
示例5: injectTags
/**
* Inject data from paramter to content tags ({}) .
*
* @param $content Original content with content tags.
* @param $params Text contain all values need to be replaced.
* @param $html Auto detect url tag and insert inline.
* @return $text The content after replacing.
**/
public static function injectTags($content, $paramsTxt, $html = false)
{
$params = new CParameter($paramsTxt);
preg_match_all("/{(.*?)}/", $content, $matches, PREG_SET_ORDER);
if (!empty($matches)) {
foreach ($matches as $val) {
$replaceWith = JString::trim($params->get($val[1], null));
if (!is_null($replaceWith)) {
//if the replacement start with 'index.php', we can CRoute it
if (JString::strpos($replaceWith, 'index.php') === 0) {
$replaceWith = CRoute::getExternalURL($replaceWith);
}
if ($html) {
$replaceUrl = $params->get($val[1] . '_url', null);
if (!is_null($replaceUrl)) {
if ($val[1] == 'stream') {
$replaceUrl .= '#activity-stream-container';
}
//if the replacement start with 'index.php', we can CRoute it
if (JString::strpos($replaceUrl, 'index.php') === 0) {
$replaceUrl = CRoute::getExternalURL($replaceUrl);
}
$replaceWith = '<a href="' . $replaceUrl . '">' . $replaceWith . '</a>';
}
}
$content = CString::str_ireplace($val[0], $replaceWith, $content);
}
}
}
return $content;
}
示例6: getMessage
public function getMessage($field)
{
$params = new CParameter($field['params']);
if ($params->get('min_char') && $params->get('max_char') && !$this->validLength($field['value'])) {
return JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_OUT_OF_RANGE', $field['name'], $params->get('max_char'), $params->get('min_char'));
}
return JText::sprintf('COM_COMMUNITY_FIELD_CONTAIN_IMPROPER_VALUES', JText::_($field['name']));
}
示例7: getFieldHTML
public function getFieldHTML($field, $required)
{
$params = new CParameter($field->params);
$readonly = $params->get('readonly') && !COwnerHelper::isCommunityAdmin() ? ' readonly=""' : '';
$style = $this->getStyle() ? ' style="' . $this->getStyle() . '"' : '';
$required = $field->required == 1 ? ' data-required="true"' : '';
// If maximum is not set, we define it to a default
$field->max = empty($field->max) ? 200 : $field->max;
$html = '<input type="text" value="' . $field->value . '" id="field' . $field->id . '" name="field' . $field->id . '" maxlength="' . $field->max . '" class="joms-input" ' . $readonly . $required . $style . ' />';
return $html;
}
示例8: getConfiguration
public static function getConfiguration()
{
static $configuration = null;
if (is_null($configuration)) {
$plugin = JPluginHelper::getPlugin('community', 'twitter');
$params = new CParameter($plugin->params);
$my = CFactory::getUser();
$oauth = JTable::getInstance('Oauth', 'CTable');
$loaded = $oauth->load($my->id, 'twitter');
$accesstoken = unserialize($oauth->accesstoken);
$configuration = array('consumer_key' => $params->get('consumerKey', '0rSLnHLm1cpX1sTsqkQaQ'), 'consumer_secret' => $params->get('consumerSecret', 'nsCObKFeJFP9YYGOZoHAHAWfvjZIZ4Hv7M8Y1w1flQ'), 'user_token' => $accesstoken['user_token'], 'user_secret' => $accesstoken['user_secret'], 'curl_ssl_verifypeer' => false);
}
return $configuration;
}
示例9: onGroupJoin
public function onGroupJoin($group, $userId)
{
//@rule: Clear existing invites fromt he invitation table once the user joined the group
$groupInvite = JTable::getInstance('GroupInvite', 'CTable');
$keys = array('groupid' => $group->id, 'userid' => $userId);
if ($groupInvite->load($keys)) {
$groupInvite->delete();
}
$member = JTable::getInstance('GroupMembers', 'CTable');
$keys = array('memberId' => $userId, 'groupId' => $group->id);
$member->load($keys);
$groupModel = CFactory::getModel('groups');
$admins = $groupModel->getAdmins($group->id, null);
$params = $group->getParams();
//@rule: Send notification when necessary
if ($params->get('joinrequestnotification') || $params->get('newmembernotification')) {
$user = CFactory::getUser($userId);
$subject = JText::sprintf('COM_COMMUNITY_GROUPS_EMAIL_NEW_MEMBER_JOINED_SUBJECT', '{user}', '{group}');
if (!$member->approved) {
$subject = JText::sprintf('COM_COMMUNITY_NEW_MEMBER_REQUESTED_TO_JOIN_GROUP_EMAIL_SUBJECT', '{user}', '{group}');
}
$params = new CParameter('');
$params->set('url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
$params->set('group', $group->name);
$params->set('group_url', 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id);
$params->set('user', $user->getDisplayName());
$params->set('user_url', 'index.php?option=com_community&view=profile&userid=' . $user->id);
$params->set('approved', $member->approved);
foreach ($admins as $admin) {
CNotificationLibrary::add('groups_member_join', $user->id, $admin->id, $subject, '', 'groups.memberjoin', $params);
}
}
}
示例10: ajaxEmailPage
public function ajaxEmailPage($uri, $emails, $message = '')
{
$filter = JFilterInput::getInstance();
$uri = $filter->clean($uri, 'string');
$emails = $filter->clean($emails, 'string');
$message = $filter->clean($message, 'string');
$message = stripslashes($message);
$mainframe =& JFactory::getApplication();
$bookmarks = CFactory::getBookmarks($uri);
$mailqModel = CFactory::getModel('mailq');
$config = CFactory::getConfig();
$response = new JAXResponse();
if (empty($emails)) {
$content = '<div>' . JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL') . '</div>';
$actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
} else {
$emails = explode(',', $emails);
$errors = array();
// Add notification
CFactory::load('libraries', 'notification');
foreach ($emails as $email) {
$email = JString::trim($email);
CFactory::load('helpers', 'validate');
if (!empty($email) && CValidateHelper::email($email)) {
$params = new CParameter('');
$params->set('uri', $uri);
$params->set('message', $message);
CNotificationLibrary::add('etype_system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
} else {
// If there is errors with email, inform the user.
$errors[] = $email;
}
}
if ($errors) {
$content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>';
foreach ($errors as $error) {
$content .= '<div style="font-weight:700;color: red;">' . $error . '</span>';
}
$actions = '<input type="button" class="button" onclick="joms.bookmarks.show(\'' . $uri . '\');" value="' . JText::_('COM_COMMUNITY_GO_BACK_BUTTON') . '"/>';
} else {
$content = '<div>' . JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS') . '</div>';
$actions = '<input type="button" class="button" onclick="cWindowHide();" value="' . JText::_('COM_COMMUNITY_DONE_BUTTON') . '"/>';
}
}
$response->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_SHARE_THIS'));
$response->addScriptCall('cWindowAddContent', $content, $actions);
return $response->sendResponse();
}
示例11: isValid
public function isValid($value, $required)
{
if ($required && empty($value) || !isset($this->fieldId)) {
return false;
}
$db =& JFactory::getDBO();
$query = 'SELECT * FROM ' . $db->nameQuote('#__community_fields') . ' WHERE ' . $db->nameQuote('id') . '=' . $db->quote($this->fieldId);
$db->setQuery($query);
$field = $db->loadAssoc();
$params = new CParameter($field['params']);
$max_range = $params->get('maxrange');
$min_range = $params->get('minrange');
$value = JFactory::getDate(strtotime($value))->toUnix();
$max_ok = true;
$min_ok = true;
//$ret = true;
if ($max_range) {
$max_range = JFactory::getDate(strtotime($max_range))->toUnix();
$max_ok = $value < $max_range;
}
if ($min_range) {
$min_range = JFactory::getDate(strtotime($min_range))->toUnix();
$min_ok = $value > $min_range;
}
return $max_ok && $min_ok ? true : false;
//return $ret;
}
示例12: sendCommentNotification
public static function sendCommentNotification(CTableWall $wall, $message)
{
CFactory::load('libraries', 'notification');
$my = CFactory::getUser();
$targetUser = CFactory::getUser($wall->post_by);
$url = 'index.php?option=com_community&view=profile&userid=' . $wall->contentid;
$userParams = $targetUser->getParams();
$params = new CParameter('');
$params->set('url', $url);
$params->set('message', $message);
if ($my->id != $targetUser->id && $userParams->get('notifyWallComment')) {
CNotificationLibrary::add('etype_profile_submit_wall_comment', $my->id, $targetUser->id, JText::sprintf('PLG_WALLS_WALL_COMMENT_EMAIL_SUBJECT', $my->getDisplayName()), '', 'profile.wallcomment', $params);
return true;
}
return false;
}
示例13: getFieldHTML
public function getFieldHTML($field, $required)
{
$lists = array();
//a fix for wrong data input
$field->value = JString::trim($field->value);
if (is_array($field->value)) {
$tmplist = $field->value;
} else {
if (JString::strrpos($field->value, ',') == JString::strlen($field->value) - 1) {
$field->value = JString::substr($field->value, 0, -1);
}
$tmplist = explode(',', $field->value);
}
if ($tmplist) {
foreach ($tmplist as $value) {
$lists[] = JString::trim($value);
}
}
$html = '';
$elementSelected = 0;
$elementCnt = 0;
$cnt = 0;
$params = new CParameter($field->params);
$readonly = '';
if ($params->get('readonly') == 1) {
$readonly = ' disabled="disabled"';
}
$html .= '<div style="display:inline-block">';
if (is_array($field->options)) {
foreach ($field->options as $option) {
if (JString::trim($option) == '') {
//do not display blank options
continue;
}
$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 . '" class="joms-checkbox" ' . $selected . $readonly . ' style="margin: 2px 5px 0 0" />';
$html .= JText::_($option) . '</label>';
$elementCnt++;
}
}
$html .= '</div>';
return $html;
}
示例14: ajaxEmailPage
public function ajaxEmailPage($uri, $emails, $message = '')
{
$filter = JFilterInput::getInstance();
$uri = $filter->clean($uri, 'string');
$emails = $filter->clean($emails, 'string');
$message = $filter->clean($message, 'string');
$message = stripslashes($message);
$mainframe = JFactory::getApplication();
$bookmarks = CFactory::getBookmarks($uri);
$mailqModel = CFactory::getModel('mailq');
$config = CFactory::getConfig();
$response = new JAXResponse();
$json = array();
if (empty($emails)) {
$json['error'] = JText::_('COM_COMMUNITY_SHARE_INVALID_EMAIL');
} else {
$emails = explode(',', $emails);
$errors = array();
// Add notification
//CFactory::load( 'libraries' , 'notification' );
foreach ($emails as $email) {
$email = JString::trim($email);
if (!empty($email) && CValidateHelper::email($email)) {
$params = new CParameter('');
$params->set('uri', $uri);
$params->set('message', $message);
CNotificationLibrary::add('system_bookmarks_email', '', $email, JText::sprintf('COM_COMMUNITY_SHARE_EMAIL_SUBJECT', $config->get('sitename')), '', 'bookmarks', $params);
} else {
// If there is errors with email, inform the user.
$errors[] = $email;
}
}
if ($errors) {
$content = '<div>' . JText::_('COM_COMMUNITY_EMAILS_ARE_INVALID') . '</div>';
foreach ($errors as $error) {
$content .= '<div style="font-weight:bold; color:red;">' . $error . '</div>';
}
$json['error'] = $content;
} else {
$content = JText::_('COM_COMMUNITY_EMAIL_SENT_TO_RECIPIENTS');
$json['message'] = $content;
}
}
die(json_encode($json));
}
示例15: getFieldHTML
public function getFieldHTML($field, $required)
{
$params = new CParameter($field->params);
$readonly = $params->get('readonly') ? ' readonly=""' : '';
$style = $this->getStyle() ? '' : ' style="' . $this->getStyle() . '" ';
// If maximum is not set, we define it to a default
$field->max = empty($field->max) ? 200 : $field->max;
CFactory::load('helpers', 'string');
$class = $field->required == 1 ? ' required' : '';
$class .= !empty($field->tips) ? ' jomNameTips tipRight' : '';
$tooltipcss = "";
if (!empty($field->tips)) {
$tooltipcss = "jomNameTips";
}
$html = '<input title="' . CStringHelper::escape(JText::_($field->tips)) . '" type="text" value="' . $field->value . '" id="field' . $field->id . '" name="field' . $field->id . '" maxlength="' . $field->max . '" size="40" class="' . $tooltipcss . ' tipRight inputbox' . $class . '" ' . $style . $readonly . ' />';
$html .= '<span id="errfield' . $field->id . 'msg" style="display:none;"> </span>';
return $html;
}