本文整理汇总了PHP中formatString函数的典型用法代码示例。如果您正苦于以下问题:PHP formatString函数的具体用法?PHP formatString怎么用?PHP formatString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPlans
public function getPlans($where = '', $limit = ' LIMIT 3', $full_detail = true)
{
$plans = $this->db->query("SELECT\n \t\t\t\ta.id AS id,\n \t\t\t\ta.id_status AS id_status,\n \t\t\t\ta.name AS name,\n \t\t\t\ta.monthly AS month,\n a.quarterly AS quarter,\n a.semesterly AS semester,\n a.yearly AS year,\n a.content_id,\n (SELECT c.text_small FROM contents c WHERE c.id = a.content_id) AS text_small\n \t\t\tFROM {$this->table} a\n \t\t\t{$where}\n \t\t\tORDER BY id\n \t\t\t{$limit}\n \t\t");
$i = 0;
foreach ($plans->result_array() as $array) {
//plans
$i = $array['id'];
$result[$i]['id'] = $array['id'];
$result[$i]['name'] = formatString($array['name']);
$result[$i]['month'] = numberFormat($array['month'], 2);
$result[$i]['quarter'] = numberFormat($array['quarter'], 2);
$result[$i]['semester'] = numberFormat($array['semester'], 2);
$result[$i]['year'] = numberFormat($array['year'], 2);
$result[$i]['text_small'] = $array['text_small'];
$result[$i]['content_id'] = $array['content_id'];
$details = $this->db->query('SELECT description
FROM ' . $this->table . "_details\n \t\t\t\tWHERE id_plan = '" . $array['id'] . "'\n \t\t\t\tORDER BY id\n \t\t\t\t" . ($full_detail ? '' : ' LIMIT 3') . '
');
$j = 0;
foreach ($details->result_array() as $detail) {
//details
$result[$i]['details'][$j++] = formatString($detail['description']);
}
$i++;
}
return $result;
}
示例2: formatAddress
function formatAddress($row)
{
//pull together address details into one formatted string
//$words = preg_split('/[\s,]+/',$var);
//$num = count($words);
//for ($i = 0 ; $i < $num ; ++$i)
//{
//all alphabetic characters stored in uppercase
//$words[$i] = strtoupper($words[$i]);
//}
//$var = implode(" +",$words);
//$var = "+" . $var;
$addressString = '';
//SAON
$strTemp = $row[SAON];
$strTemp = $strTemp . trim();
if (!empty($strTemp)) {
$strTemp = formatString($strTemp);
$addressString = $addressString . $strTemp . ",";
}
//PAON
$strTemp = $row[PAON];
$strTemp = $strTemp . trim();
if (!empty($strTemp)) {
$strTemp = formatString($strTemp);
$addressString = $addressString . $strTemp . ",";
}
//Street
$strTemp = $row[Street];
$strTemp = $strTemp . trim();
if (!empty($strTemp)) {
$strTemp = formatString($strTemp);
$addressString = $addressString . $strTemp . ",";
}
//Locality
$strTemp = $row[Locality];
$strTemp = $strTemp . trim();
if (!empty($strTemp)) {
$strTemp = formatString($strTemp);
$addressString = $addressString . $strTemp . ",";
}
//District
$strTemp = $row[District];
$strTemp = $strTemp . trim();
if (!empty($strTemp)) {
$strTemp = formatString($strTemp);
$addressString = $addressString . $strTemp . ",";
}
//County
$strTemp = $row[County];
$strTemp = $strTemp . trim();
if (!empty($strTemp)) {
$strTemp = formatString($strTemp);
$addressString = $addressString . $strTemp . ",";
}
$addressString = $addressString . $row[Postcode1] . " " . $row[Postcode2];
return $addressString;
}
示例3: settingsController_render_before
/**
* Adds a "My Forums" menu option to the dashboard area.
*/
public function settingsController_render_before($Sender)
{
// Have they visited their dashboard?
if (strtolower($Sender->RequestMethod) != 'index') {
$this->saveStep('Plugins.GettingStarted.Dashboard');
}
// Save the action if editing registration settings
if (strcasecmp($Sender->RequestMethod, 'registration') == 0 && $Sender->Form->authenticatedPostBack() === true) {
$this->saveStep('Plugins.GettingStarted.Registration');
}
// Save the action if they reviewed plugins
if (strcasecmp($Sender->RequestMethod, 'plugins') == 0) {
$this->saveStep('Plugins.GettingStarted.Plugins');
}
// Save the action if they reviewed plugins
if (strcasecmp($Sender->RequestMethod, 'managecategories') == 0) {
$this->saveStep('Plugins.GettingStarted.Categories');
}
// Add messages & their css on dashboard
if (strcasecmp($Sender->RequestMethod, 'index') == 0) {
$Sender->addCssFile('getting-started.css', 'plugins/GettingStarted');
$Session = Gdn::session();
$WelcomeMessage = '<div class="GettingStarted">' . anchor('×', '/dashboard/plugin/dismissgettingstarted/' . $Session->transientKey(), 'Dismiss') . "<h1>" . t("Here's how to get started:") . "</h1>" . '<ul>
<li class="One' . (c('Plugins.GettingStarted.Dashboard', '0') == '1' ? ' Done' : '') . '">
<strong>' . anchor(t('Welcome to your Dashboard'), 'settings') . '</strong>
<p>' . t('This is the administrative dashboard for your new community.', 'This is the administrative dashboard for your new community. Check out the configuration options to the side. From there you can configure how your community works. <b>By default, only users in the "Administrator" role can see this part of your community.</b>') . '</p>
</li>
<li class="Two' . (c('Plugins.GettingStarted.Discussions', '0') == '1' ? ' Done' : '') . '">
<strong>' . anchor(t("Where is your Community Forum?"), '/') . '</strong>
<p>' . formatString(t('Access your community forum by clicking the "Visit Site" link.', 'Access your community forum by clicking the "Visit Site" link at the top of this page, or by <a href={/,url}>clicking here</a>. The community forum is what all of your users & customers will see when they visit <a href="{/,url,domain}">{/,url,domain}</a>.')) . '</p>
</li>
<li class="Three' . (c('Plugins.GettingStarted.Categories', '0') == '1' ? ' Done' : '') . '">
<strong>' . anchor(t('Organize your Categories'), 'vanilla/settings/managecategories') . '</strong>
<p>' . t('Categories are used to organize discussions.', 'Categories are used to help your users organize their discussions in a way that is meaningful for your community.') . '</p>
</li>
<li class="Four' . (c('Plugins.GettingStarted.Profile', '0') == '1' ? ' Done' : '') . '">
<strong>' . anchor(t('Customize your Public Profile'), 'profile') . '</strong>
<p>' . formatString(t('Everyone who signs up gets a profile page.', 'Everyone who signs up for your community gets a public profile page where they can upload a picture of themselves, manage their profile settings, and track cool things going on in the community. You should <a href="{/profile,url}">customize your profile now</a>.')) . '</p>
</li>
<li class="Five' . (c('Plugins.GettingStarted.Discussion', '0') == '1' ? ' Done' : '') . '">
<strong>' . anchor(t('Start your First Discussion'), 'post/discussion') . '</strong>
<p>' . formatString(t('Start the first discussion.', 'Get the ball rolling in your community by <a href="{/post/discussion,url}">starting the first discussion</a> now.')) . '</p>
</li>
<li class="Six' . (c('Plugins.GettingStarted.Plugins', '0') == '1' ? ' Done' : '') . '">
<strong>' . anchor(t('Manage Plugins'), 'settings/plugins') . '</strong>
<p>' . t('Change the way your community works with plugins.', 'Change the way your community works with plugins. We\'ve bundled popular plugins with the software, and there are more available online.') . '</p>
</li>
</ul>
</div>';
$Sender->addAsset('Messages', $WelcomeMessage, 'WelcomeMessage');
}
}
示例4: sent
public function sent()
{
$this->load->library('email');
$body = '
<table align="center" cellpadding="0" cellspacing="0" border="0" style="width: 600px; font-size: 12px; font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;font-weight: normal;border: 1px solid #2B7FE9; ">
<tr>
<td style="border: 1px solid #2B7FE9;border-bottom: none; background-color: #2B7FE9"><img src="' . base_url() . 'img/top_mail.png" alt=""></td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none; border-top: none;"><h4>Customer Info</h4></td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Name:</strong> ' . formatString($this->input->post('txtContactName')) . '</td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Email:</strong> ' . $this->input->post('txtContactEmail') . '</td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Phone Number:</strong> ' . formatString($this->input->post('txtContactTlf')) . '</td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><h4>Support Info</h4></td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Subject:</strong> ' . htmlentities(formatString($this->ModelContents->get_reason($this->input->post('cboContactReason'), 'name'), 2)) . '</td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;border-bottom: none;"><strong>Message</strong> </td>
</tr>
<tr>
<td style="padding:10px;border: 1px solid #2B7FE9;">' . formatString($this->input->post('txtContactMsg'), 2) . '</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
';
$ci = get_instance();
//_imprimir($ci->config->config['head']);
$this->email->initialize(emailSetting());
$this->email->from($ci->config->config['head']['no_reply'][1], $ci->config->config['head']['company']);
$this->email->to('info@websarrollo.com');
$this->email->subject(formatString($this->input->post('txtContactName')) . ' wants to cantact you!');
$this->email->message($body);
if (!$this->email->send()) {
$data = ['title' => 'Error', 'message' => 'there was an error when we tried to send the email, try again.', 'debugger' => ''];
} else {
$data = ['title' => 'Thanks for your request!', 'message' => 'We have received your message. You will receive a message from us in 24 hours.', 'out' => 'ok', 'url' => $ci->config->config['head']['domain'] . '/content/body/contact-us', 'debugger' => ''];
}
echo json_encode($data);
}
示例5: lookup
public function lookup($domain)
{
$domain = trim(formatString($domain, 3));
//remove space from start and end of domain
$aux = explode('.', $domain);
if (end($aux) == 've') {
$this->nic_ve($domain);
$this->tld_domain = $aux[count($aux) - 2] . '.' . array_pop($aux);
return;
}
$domain = empty($aux[1]) ? $domain . '.com' : $domain;
//if the domain does not have type we put it
if (substr(strtolower($domain), 0, 7) == 'http://') {
$domain = substr($domain, 7);
}
// remove http:// if included
if (substr(strtolower($domain), 0, 4) == 'www.') {
$domain = substr($domain, 4);
}
//remove www from domain
if (preg_match("/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\$/", $domain)) {
$this->out = $this->queryWhois('whois.lacnic.net', $domain);
} elseif (preg_match("/^([-a-z0-9]{2,100})\\.([a-z\\.]{2,8})\$/i", $domain)) {
$domain_parts = explode('.', $domain);
$this->tld_domain = $tld = strtolower(array_pop($domain_parts));
$server = $this->servers[$tld][0];
if (!$server) {
$this->error_number = 4;
//echo "Error: No appropriate Whois server found for $domain domain!";
}
$this->out = $this->queryWhois($server, $domain);
while (preg_match_all('/Whois Server: (.*)/', $this->out, $matches)) {
$server = array_pop($matches[1]);
$this->out = $this->queryWhois($server, $domain);
}
//return $res;
} else {
$this->error_number = 2;
//return "Invalid Input";
}
$this->domain = $domain;
$this->available = preg_match('/No match for/', $this->out, $info) ? 1 : 0;
}
示例6: connectButton
/**
*
*
* @param $Provider
* @param array $Options
* @return string
*/
public static function connectButton($Provider, $Options = [])
{
if (!is_array($Provider)) {
$Provider = self::getProvider($Provider);
}
$Url = htmlspecialchars(self::connectUrl($Provider));
$Data = $Provider;
$Target = Gdn::request()->get('Target');
if (!$Target) {
$Target = '/' . ltrim(Gdn::request()->path());
}
if (stringBeginsWith($Target, '/entry/signin')) {
$Target = '/';
}
$ConnectQuery = ['client_id' => $Provider['AuthenticationKey'], 'Target' => $Target];
$Data['Target'] = urlencode(url('entry/jsconnect', true) . '?' . http_build_query($ConnectQuery));
$Data['Redirect'] = $Data['target'] = $Data['redirect'] = $Data['Target'];
$SignInUrl = formatString(val('SignInUrl', $Provider, ''), $Data);
$RegisterUrl = formatString(val('RegisterUrl', $Provider, ''), $Data);
if ($RegisterUrl && !val('NoRegister', $Options)) {
$RegisterLink = ' ' . anchor(sprintf(t('Register with %s', 'Register'), $Provider['Name']), $RegisterUrl, 'Button RegisterLink');
} else {
$RegisterLink = '';
}
if (val('NoConnectLabel', $Options)) {
$ConnectLabel = '';
} else {
$ConnectLabel = '<span class="Username"></span><div class="ConnectLabel TextColor">' . sprintf(t('Sign In with %s'), $Provider['Name']) . '</div>';
}
if (!C('Plugins.JsConnect.NoGuestCheck')) {
$Result = '<div style="display: none" class="JsConnect-Container ConnectButton Small UserInfo" rel="' . $Url . '">';
if (!val('IsDefault', $Provider)) {
$Result .= '<div class="JsConnect-Guest">' . anchor(sprintf(t('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
}
$Result .= '<div class="JsConnect-Connect"><a class="ConnectLink">' . img('https://images.v-cdn.net/usericon_50.png', ['class' => 'ProfilePhotoSmall UserPhoto']) . $ConnectLabel . '</a></div>';
$Result .= '</div>';
} else {
if (!val('IsDefault', $Provider)) {
$Result = '<div class="JsConnect-Guest">' . anchor(sprintf(t('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button Primary SignInLink') . $RegisterLink . '</div>';
}
}
return $Result;
}
示例7: listPage
function listPage()
{
$postTile = "";
$postBlockName = "";
$sts = "1";
if (isset($_POST['title'])) {
$postTile = $_POST["title"];
}
if (isset($_POST['sts'])) {
$sts = $_POST["sts"];
}
if (isset($_POST['block_name'])) {
$postBlockName = $_POST["block_name"];
}
$table = "(select a.*,b.block_name,c.usr_nm from content a left join block b on a.block_id=b.block_id left join users c on a.usr_id=c.usr_id where a.sts in (" . formatString($sts) . ") and a.title like '%" . $postTile . "%' and b.block_name like '%" . $postBlockName . "%' order by edit_tm desc) mytable";
$this->logger = LogUtil::getLogger();
//$this->logger->info($table);
$pager = parent::getPager($table, $this->content->db);
$arrayList = $pager->getData();
$blockList = $this->block->getBlocks();
require 'view/admin/content_list.php';
}
示例8: comment
/**
* Create or update a comment.
*
* @since 2.0.0
* @access public
*
* @param int $DiscussionID Unique ID to add the comment to. If blank, this method will throw an error.
*/
public function comment($DiscussionID = '')
{
// Get $DiscussionID from RequestArgs if valid
if ($DiscussionID == '' && count($this->RequestArgs)) {
if (is_numeric($this->RequestArgs[0])) {
$DiscussionID = $this->RequestArgs[0];
}
}
// If invalid $DiscussionID, get from form.
$this->Form->setModel($this->CommentModel);
$DiscussionID = is_numeric($DiscussionID) ? $DiscussionID : $this->Form->getFormValue('DiscussionID', 0);
// Set discussion data
$this->DiscussionID = $DiscussionID;
$this->Discussion = $Discussion = $this->DiscussionModel->getID($DiscussionID);
// Is this an embedded comment being posted to a discussion that doesn't exist yet?
$vanilla_type = $this->Form->getFormValue('vanilla_type', '');
$vanilla_url = $this->Form->getFormValue('vanilla_url', '');
$vanilla_category_id = $this->Form->getFormValue('vanilla_category_id', '');
$Attributes = array('ForeignUrl' => $vanilla_url);
$vanilla_identifier = $this->Form->getFormValue('vanilla_identifier', '');
$isEmbeddedComments = $vanilla_url != '' && $vanilla_identifier != '';
// Only allow vanilla identifiers of 32 chars or less - md5 if larger
if (strlen($vanilla_identifier) > 32) {
$Attributes['vanilla_identifier'] = $vanilla_identifier;
$vanilla_identifier = md5($vanilla_identifier);
}
if (!$Discussion && $isEmbeddedComments) {
$Discussion = $Discussion = $this->DiscussionModel->getForeignID($vanilla_identifier, $vanilla_type);
if ($Discussion) {
$this->DiscussionID = $DiscussionID = $Discussion->DiscussionID;
$this->Form->setValue('DiscussionID', $DiscussionID);
}
}
// If so, create it!
if (!$Discussion && $isEmbeddedComments) {
// Add these values back to the form if they exist!
$this->Form->addHidden('vanilla_identifier', $vanilla_identifier);
$this->Form->addHidden('vanilla_type', $vanilla_type);
$this->Form->addHidden('vanilla_url', $vanilla_url);
$this->Form->addHidden('vanilla_category_id', $vanilla_category_id);
$PageInfo = fetchPageInfo($vanilla_url);
if (!($Title = $this->Form->getFormValue('Name'))) {
$Title = val('Title', $PageInfo, '');
if ($Title == '') {
$Title = t('Undefined discussion subject.');
if (!empty($PageInfo['Exception']) && $PageInfo['Exception'] === "Couldn't connect to host.") {
$Title .= ' ' . t('Page timed out.');
}
}
}
$Description = val('Description', $PageInfo, '');
$Images = val('Images', $PageInfo, array());
$LinkText = t('EmbededDiscussionLinkText', 'Read the full story here');
if (!$Description && count($Images) == 0) {
$Body = formatString('<p><a href="{Url}">{LinkText}</a></p>', array('Url' => $vanilla_url, 'LinkText' => $LinkText));
} else {
$Body = formatString('
<div class="EmbeddedContent">{Image}<strong>{Title}</strong>
<p>{Excerpt}</p>
<p><a href="{Url}">{LinkText}</a></p>
<div class="ClearFix"></div>
</div>', array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? img(val(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $vanilla_url, 'LinkText' => $LinkText));
}
if ($Body == '') {
$Body = $vanilla_url;
}
if ($Body == '') {
$Body = t('Undefined discussion body.');
}
// Validate the CategoryID for inserting.
$Category = CategoryModel::categories($vanilla_category_id);
if (!$Category) {
$vanilla_category_id = c('Vanilla.Embed.DefaultCategoryID', 0);
if ($vanilla_category_id <= 0) {
// No default category defined, so grab the first non-root category and use that.
$vanilla_category_id = $this->DiscussionModel->SQL->select('CategoryID')->from('Category')->where('CategoryID >', 0)->get()->firstRow()->CategoryID;
// No categories in the db? default to 0
if (!$vanilla_category_id) {
$vanilla_category_id = 0;
}
}
} else {
$vanilla_category_id = $Category['CategoryID'];
}
$EmbedUserID = c('Garden.Embed.UserID');
if ($EmbedUserID) {
$EmbedUser = Gdn::userModel()->getID($EmbedUserID);
}
if (!$EmbedUserID || !$EmbedUser) {
$EmbedUserID = Gdn::userModel()->getSystemUserID();
}
$EmbeddedDiscussionData = array('InsertUserID' => $EmbedUserID, 'DateInserted' => Gdn_Format::toDateTime(), 'DateUpdated' => Gdn_Format::toDateTime(), 'CategoryID' => $vanilla_category_id, 'ForeignID' => $vanilla_identifier, 'Type' => $vanilla_type, 'Name' => $Title, 'Body' => $Body, 'Format' => 'Html', 'Attributes' => dbencode($Attributes));
//.........这里部分代码省略.........
示例9: formatString
">
<?php
echo formatString($menu['title']);
?>
</a>
</li>
<?php
}
?>
<li>
<a href="<?php
echo base_url();
?>
content/body/contact-us">
<?php
echo formatString($language->line('header_support'));
?>
</a>
</li>
</ul>
</div>
</div>
</footer>
<script src="<?php
echo base_url();
?>
js/vendor/jquery.min.js"></script>
<script src="<?php
echo base_url();
?>
js/foundation.min.js"></script>
示例10: validateCaptcha
/**
* Validate a reCAPTCHA submission.
*
* @param string $captchaText
* @return boolean
* @throws Exception
*/
public function validateCaptcha($captchaText)
{
$api = new Garden\Http\HttpClient('https://www.google.com/recaptcha/api');
$data = array('secret' => $this->getPrivateKey(), 'response' => $captchaText);
$response = $api->get('/siteverify', $data);
if ($response->isSuccessful()) {
$result = $response->getBody();
$errorCodes = val('error_codes', $result);
if ($result && val('success', $result)) {
return true;
} else {
if (!empty($errorCodes) && $errorCodes != array('invalid-input-response')) {
throw new Exception(formatString(t('No response from reCAPTCHA.') . ' {ErrorCodes}', array('ErrorCodes' => join(', ', $errorCodes))));
}
}
} else {
throw new Exception(t('No response from reCAPTCHA.'));
}
return false;
}
示例11: base_render_before
/**
* Fire before every page render.
*
* @param Gdn_Controller $Sender
*/
public function base_render_before($Sender)
{
$Session = Gdn::session();
if ($Sender->MasterView == 'admin') {
if (val('Form', $Sender)) {
$Sender->Form->setStyles('bootstrap');
}
$Sender->CssClass = htmlspecialchars($Sender->CssClass);
$Sections = Gdn_Theme::section(null, 'get');
if (is_array($Sections)) {
foreach ($Sections as $Section) {
$Sender->CssClass .= ' Section-' . $Section;
}
}
// Get our plugin nav items.
$navAdapter = new NestedCollectionAdapter(DashboardNavModule::getDashboardNav());
$Sender->EventArguments['SideMenu'] = $navAdapter;
$Sender->fireEvent('GetAppSettingsMenuItems');
$Sender->removeJsFile('jquery.popup.js');
$Sender->addJsFile('vendors/jquery.checkall.min.js', 'dashboard');
$Sender->addJsFile('dashboard.js', 'dashboard');
$Sender->addJsFile('jquery.expander.js');
$Sender->addJsFile('settings.js', 'dashboard');
$Sender->addJsFile('vendors/tether.min.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/util.js', 'dashboard');
$Sender->addJsFile('vendors/drop.min.js', 'dashboard');
$Sender->addJsFile('vendors/moment.min.js', 'dashboard');
$Sender->addJsFile('vendors/daterangepicker.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/tooltip.js', 'dashboard');
$Sender->addJsFile('vendors/clipboard.min.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/dropdown.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/collapse.js', 'dashboard');
$Sender->addJsFile('vendors/bootstrap/modal.js', 'dashboard');
$Sender->addJsFile('vendors/icheck.min.js', 'dashboard');
$Sender->addJsFile('jquery.tablejenga.js', 'dashboard');
$Sender->addJsFile('jquery.fluidfixed.js', 'dashboard');
$Sender->addJsFile('vendors/prettify/prettify.js', 'dashboard');
$Sender->addJsFile('vendors/ace/ace.js', 'dashboard');
$Sender->addJsFile('vendors/ace/ext-searchbox.js', 'dashboard');
$Sender->addCssFile('vendors/tomorrow.css', 'dashboard');
}
// Check the statistics.
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
Gdn::statistics()->check();
}
// Inform user of theme previewing
if ($Session->isValid()) {
$PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', ''));
$PreviewMobileThemeFolder = htmlspecialchars($Session->getPreference('PreviewMobileThemeFolder', ''));
$PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', $PreviewThemeFolder));
$PreviewMobileThemeName = htmlspecialchars($Session->getPreference('PreviewMobileThemeName', $PreviewMobileThemeFolder));
if ($PreviewThemeFolder != '') {
$Sender->informMessage(sprintf(t('You are previewing the %s desktop theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
}
if ($PreviewMobileThemeFolder != '') {
$Sender->informMessage(sprintf(t('You are previewing the %s mobile theme.'), wrap($PreviewMobileThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/mobilethemes/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss');
}
}
if ($Session->isValid()) {
$Confirmed = val('Confirmed', Gdn::session()->User, true);
if (UserModel::requireConfirmEmail() && !$Confirmed) {
$Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.'));
$Sender->informMessage($Message, '');
}
}
// Add Message Modules (if necessary)
$MessageCache = Gdn::config('Garden.Messages.Cache', array());
$Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod;
$Exceptions = array('[Base]');
if (in_array($Sender->MasterView, array('', 'default'))) {
$Exceptions[] = '[NonAdmin]';
}
// SignIn popup is a special case
$SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin';
if ($SignInOnly) {
$Exceptions = array();
}
if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) {
$MessageModel = new MessageModel();
$MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID'));
foreach ($MessageData as $Message) {
$MessageModule = new MessageModule($Sender, $Message);
if ($SignInOnly) {
// Insert special messages even in SignIn popup
echo $MessageModule;
} elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
$Sender->addModule($MessageModule);
}
}
$Sender->MessagesLoaded = '1';
// Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly.
}
if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) {
$Gdn_Statistics = Gdn::factory('Statistics');
$Gdn_Statistics->check($Sender);
//.........这里部分代码省略.........
示例12: moderationController_mergeDiscussions_create
/**
* Add a method to the ModerationController to handle merging discussions.
*
* @param Gdn_Controller $Sender
*/
public function moderationController_mergeDiscussions_create($Sender)
{
$Session = Gdn::session();
$Sender->Form = new Gdn_Form();
$Sender->title(t('Merge Discussions'));
$DiscussionModel = new DiscussionModel();
$CheckedDiscussions = Gdn::userModel()->getAttribute($Session->User->UserID, 'CheckedDiscussions', array());
if (!is_array($CheckedDiscussions)) {
$CheckedDiscussions = array();
}
$DiscussionIDs = $CheckedDiscussions;
$Sender->setData('DiscussionIDs', $DiscussionIDs);
$CountCheckedDiscussions = count($DiscussionIDs);
$Sender->setData('CountCheckedDiscussions', $CountCheckedDiscussions);
$Discussions = $DiscussionModel->SQL->whereIn('DiscussionID', $DiscussionIDs)->get('Discussion')->resultArray();
$Sender->setData('Discussions', $Discussions);
// Make sure none of the selected discussions are ghost redirects.
$discussionTypes = array_column($Discussions, 'Type');
if (in_array('redirect', $discussionTypes)) {
throw Gdn_UserException('You cannot merge redirects.', 400);
}
// Perform the merge
if ($Sender->Form->authenticatedPostBack()) {
// Create a new discussion record
$MergeDiscussion = false;
$MergeDiscussionID = $Sender->Form->getFormValue('MergeDiscussionID');
foreach ($Discussions as $Discussion) {
if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
$MergeDiscussion = $Discussion;
break;
}
}
$RedirectLink = $Sender->Form->getFormValue('RedirectLink');
if ($MergeDiscussion) {
$ErrorCount = 0;
// Verify that the user has permission to perform the merge.
$Category = CategoryModel::categories($MergeDiscussion['CategoryID']);
if ($Category && !$Category['PermsDiscussionsEdit']) {
throw permissionException('Vanilla.Discussions.Edit');
}
$DiscussionModel->defineSchema();
$MaxNameLength = val('Length', $DiscussionModel->Schema->getField('Name'));
// Assign the comments to the new discussion record
$DiscussionModel->SQL->update('Comment')->set('DiscussionID', $MergeDiscussionID)->whereIn('DiscussionID', $DiscussionIDs)->put();
$CommentModel = new CommentModel();
foreach ($Discussions as $Discussion) {
if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
continue;
}
// Create a comment out of the discussion.
$Comment = arrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
$Comment['DiscussionID'] = $MergeDiscussionID;
$CommentModel->Validation->results(true);
$CommentID = $CommentModel->save($Comment);
if ($CommentID) {
// Move any attachments (FileUpload plugin awareness)
if (class_exists('MediaModel')) {
$MediaModel = new MediaModel();
$MediaModel->reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
}
if ($RedirectLink) {
// The discussion needs to be changed to a moved link.
$RedirectDiscussion = array('Name' => SliceString(sprintf(t('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => formatString(t('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
$DiscussionModel->setField($Discussion['DiscussionID'], $RedirectDiscussion);
$CommentModel->updateCommentCount($Discussion['DiscussionID']);
$CommentModel->removePageCache($Discussion['DiscussionID']);
} else {
// Delete discussion that was merged.
$DiscussionModel->delete($Discussion['DiscussionID']);
}
} else {
$Sender->informMessage($CommentModel->Validation->resultsText());
$ErrorCount++;
}
}
// Update counts on all affected discussions.
$CommentModel->updateCommentCount($MergeDiscussionID);
$CommentModel->removePageCache($MergeDiscussionID);
// Clear selections
Gdn::userModel()->saveAttribute($Session->UserID, 'CheckedDiscussions', false);
ModerationController::informCheckedDiscussions($Sender);
if ($ErrorCount == 0) {
$Sender->jsonTarget('', '', 'Refresh');
}
}
}
$Sender->render('MergeDiscussions', '', 'plugins/SplitMerge');
}
示例13: breadcrumbs
/**
*
*
* @param $Data
* @param bool $HomeLink
* @param array $Options
* @return string
*/
public static function breadcrumbs($Data, $HomeLink = true, $Options = array())
{
$Format = '<a href="{Url,html}" itemprop="url"><span itemprop="title">{Name,html}</span></a>';
$Result = '';
if (!is_array($Data)) {
$Data = array();
}
if ($HomeLink) {
$HomeUrl = val('HomeUrl', $Options);
if (!$HomeUrl) {
$HomeUrl = Url('/', true);
}
$Row = array('Name' => $HomeLink, 'Url' => $HomeUrl, 'CssClass' => 'CrumbLabel HomeCrumb');
if (!is_string($HomeLink)) {
$Row['Name'] = T('Home');
}
array_unshift($Data, $Row);
}
if (val('HideLast', $Options)) {
// Remove the last item off the list.
array_pop($Data);
}
$DefaultRoute = ltrim(val('Destination', Gdn::router()->getRoute('DefaultController'), ''), '/');
$Count = 0;
$DataCount = 0;
$HomeLinkFound = false;
foreach ($Data as $Row) {
$DataCount++;
if ($HomeLinkFound && Gdn::request()->urlCompare($Row['Url'], $DefaultRoute) === 0) {
continue;
// don't show default route twice.
} else {
$HomeLinkFound = true;
}
// Add the breadcrumb wrapper.
if ($Count > 0) {
$Result .= '<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">';
}
$Row['Url'] = $Row['Url'] ? Url($Row['Url']) : '#';
$CssClass = 'CrumbLabel ' . val('CssClass', $Row);
if ($DataCount == count($Data)) {
$CssClass .= ' Last';
}
$Label = '<span class="' . $CssClass . '">' . formatString($Format, $Row) . '</span> ';
$Result = concatSep('<span class="Crumb">' . T('Breadcrumbs Crumb', '›') . '</span> ', $Result, $Label);
$Count++;
}
// Close the stack.
for ($Count--; $Count > 0; $Count--) {
$Result .= '</span>';
}
$Result = '<span class="Breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">' . $Result . '</span>';
return $Result;
}
示例14: getPermissions
/**
* Get a user's permissions.
*
* @param int $userID Unique ID of the user.
* @return Vanilla\Permissions
*/
public function getPermissions($userID)
{
$permissions = new Vanilla\Permissions();
$permissionsKey = '';
if (Gdn::cache()->activeEnabled()) {
$permissionsIncrement = $this->getPermissionsIncrement();
$permissionsKey = formatString(self::USERPERMISSIONS_KEY, ['UserID' => $userID, 'PermissionsIncrement' => $permissionsIncrement]);
$cachedPermissions = Gdn::cache()->get($permissionsKey);
if ($cachedPermissions !== Gdn_Cache::CACHEOP_FAILURE) {
$permissions->setPermissions($cachedPermissions);
return $permissions;
}
}
$data = Gdn::permissionModel()->cachePermissions($userID);
$permissions->compileAndLoad($data);
$this->EventArguments['UserID'] = $userID;
$this->EventArguments['Permissions'] = $permissions;
$this->fireEvent('loadPermissions');
if (Gdn::cache()->activeEnabled()) {
Gdn::cache()->store($permissionsKey, $permissions->getPermissions());
} else {
// Save the permissions to the user table
if ($userID > 0) {
$this->SQL->put('User', ['Permissions' => dbencode($permissions->getPermissions())], ['UserID' => $userID]);
}
}
return $permissions;
}
示例15: log
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array())
{
trace(formatString($message, $context), 'FormattedMessage');
trace($context, 'context');
}