本文整理汇总了PHP中stringEndsWith函数的典型用法代码示例。如果您正苦于以下问题:PHP stringEndsWith函数的具体用法?PHP stringEndsWith怎么用?PHP stringEndsWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stringEndsWith函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: subtractURLsEnd
function subtractURLsEnd($a, $b)
{
//Removes $b from the end of $a, if possible. Else errors.
if (stringEndsWith($a, $b)) {
return substr_b($a, 0, strlen($a) - strlen($b));
} else {
trigger_error("URL processing error: subtractURLsEnd('" . htmlentities($a) . "','" . htmlentities($b) . "')", E_USER_ERROR);
}
}
开发者ID:lhsmath,项目名称:lhsmath.org,代码行数:9,代码来源:functions.pathinfo.php
示例2: onMessage
public function onMessage($from, $channel, $msg)
{
if (stringEndsWith($msg, "{$this->config['trigger']}memory")) {
$usedMem = round(memory_get_usage() / 1024 / 1024, 2);
$freeMem = round($this->config['memoryLimit'] - $usedMem, 2);
sendMessage($this->socket, $channel, $from . ": Memory status: {$usedMem} MB used, {$freeMem} MB free.");
$usedMem = null;
$freeMem = null;
}
}
开发者ID:nask0,项目名称:VikingBot,代码行数:10,代码来源:memoryPlugin.php
示例3: requestDelosJSON
function requestDelosJSON() {
global $course_code;
$jsonObj = null;
if (isDelosEnabled()) {
$jsonbaseurl = getDelosURL();
$jsonbaseurl .= (stringEndsWith($jsonbaseurl, "/")) ? '' : '/';
$jsonurl = $jsonbaseurl . $course_code;
// request json from opendelos
$json = httpGetRequest($jsonurl);
$jsonObj = ($json) ? json_decode($json) : null;
}
return $jsonObj;
}
开发者ID:nikosv,项目名称:openeclass,代码行数:13,代码来源:delos_functions.php
示例4: loadPlugins
function loadPlugins()
{
$this->plugins = array();
$handle = opendir('plugins');
while (false !== ($file = readdir($handle))) {
if (stringEndsWith($file, '.php')) {
require 'plugins/' . $file;
$pName = str_replace('.php', '', $file);
$this->plugins[] = new $pName();
}
}
foreach ($this->plugins as $plugin) {
$plugin->init($this->config, $this->socket);
}
}
开发者ID:fathkay,项目名称:VikingBot,代码行数:15,代码来源:VikingBot.php
示例5: analytics
/**
*
*
* @param $Method
* @param $RequestParameters
* @param bool $Callback
* @param bool $ParseResponse
* @return array|bool|mixed|type
* @throws Exception
*/
public function analytics($Method, $RequestParameters, $Callback = false, $ParseResponse = true)
{
$FullMethod = explode('/', $Method);
if (sizeof($FullMethod) < 2) {
array_unshift($FullMethod, "analytics");
}
list($ApiController, $ApiMethod) = $FullMethod;
$ApiController = strtolower($ApiController);
$ApiMethod = stringEndsWith(strtolower($ApiMethod), '.json', true, true) . '.json';
$FinalURL = 'http://' . combinePaths(array($this->AnalyticsServer, $ApiController, $ApiMethod));
$RequestHeaders = array();
// Allow hooking of analytics events
$this->EventArguments['AnalyticsMethod'] =& $Method;
$this->EventArguments['AnalyticsArgs'] =& $RequestParameters;
$this->EventArguments['AnalyticsUrl'] =& $FinalURL;
$this->EventArguments['AnalyticsHeaders'] =& $RequestHeaders;
$this->fireEvent('SendAnalytics');
// Sign request
$this->sign($RequestParameters, true);
$RequestMethod = val('RequestMethod', $RequestParameters, 'GET');
unset($RequestParameters['RequestMethod']);
try {
$ProxyRequest = new ProxyRequest(false, array('Method' => $RequestMethod, 'Timeout' => 10, 'Cookies' => false));
$Response = $ProxyRequest->request(array('Url' => $FinalURL, 'Log' => false), $RequestParameters, null, $RequestHeaders);
} catch (Exception $e) {
$Response = false;
}
if ($Response !== false) {
$JsonResponse = json_decode($Response, true);
if ($JsonResponse !== false) {
if ($ParseResponse) {
$AnalyticsJsonResponse = (array) val('Analytics', $JsonResponse, false);
// If we received a reply, parse it
if ($AnalyticsJsonResponse !== false) {
$this->parseAnalyticsResponse($AnalyticsJsonResponse, $Response, $Callback);
return $AnalyticsJsonResponse;
}
} else {
return $JsonResponse;
}
}
return $Response;
}
return false;
}
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:55,代码来源:class.statistics.php
示例6: process
function process($currentXml)
{
//generate mimetype file
$mimeType = "application/vnd.oasis.opendocument.text";
$destinationPath = $this->contentDirectory . DIRECTORY_SEPARATOR . 'mimetype';
file_put_contents($destinationPath, $mimeType);
$filesDirectory = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR;
copy($filesDirectory . 'meta.xml', $this->contentDirectory . DIRECTORY_SEPARATOR . 'meta.xml');
copy($filesDirectory . 'settings.xml', $this->contentDirectory . DIRECTORY_SEPARATOR . 'settings.xml');
copy($filesDirectory . 'styles.xml', $this->contentDirectory . DIRECTORY_SEPARATOR . 'styles.xml');
//generate manifest
$manifestItemTemplate = "\n\t" . '<manifest:file-entry manifest:media-type="{{type}}" manifest:full-path="{{path}}"/>';
$manifest = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$manifest .= '<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">';
$manifest .= "\n\t" . '<manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.text" manifest:full-path="/"/>';
$files = glob($this->contentDirectory . DIRECTORY_SEPARATOR . '*');
$picturesDirectory = $this->contentDirectory . DIRECTORY_SEPARATOR . 'Pictures';
if (file_exists($picturesDirectory)) {
$files = array_merge($files, glob($picturesDirectory . DIRECTORY_SEPARATOR . '*'));
}
foreach ($files as $file) {
$fileType = '';
if (stringEndsWith($file, '.xml')) {
$fileType = 'text/xml';
} elseif (stringEndsWith($file, '.jpg') || stringEndsWith($file, '.jpeg') || stringEndsWith($file, '.gif') || stringEndsWith($file, '.png')) {
$fileType = 'image/jpeg';
}
$filePath = str_replace($this->contentDirectory . DIRECTORY_SEPARATOR, '', $file);
switch ($filePath) {
case 'mimetype':
break;
default:
$manifestItem = str_replace('{{type}}', $fileType, $manifestItemTemplate);
$manifestItem = str_replace('{{path}}', $filePath, $manifestItem);
$manifest .= $manifestItem;
}
}
$manifest .= "\n" . '</manifest:manifest>';
$manifestDirectory = $this->contentDirectory . DIRECTORY_SEPARATOR . 'META-INF';
mkdir($manifestDirectory);
$manifestPath = $manifestDirectory . DIRECTORY_SEPARATOR . 'manifest.xml';
file_put_contents($manifestPath, $manifest);
return $currentXml;
}
开发者ID:Nolfneo,项目名称:docvert,代码行数:44,代码来源:GenerateOtherNecessaryOpenDocumentFiles.php
示例7: onMessage
public function onMessage($from, $channel, $msg)
{
if (stringStartsWith($msg, "{$this->config['trigger']}upgrade")) {
$bits = explode(" ", $msg);
$pass = $bits[1];
if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) {
sendMessage($this->socket, $channel, "{$from}: Wrong password");
} else {
$restartRequired = false;
sendMessage($this->socket, $channel, "{$from}: Starting upgrade of bot and its plugins...");
$response = trim(shell_exec("git pull"));
if (empty($response)) {
sendMessage($this->socket, $channel, "{$from}: Error upgrading core. Check permissions!");
} elseif ($response != 'Already up-to-date.') {
$restartRequired = true;
sendMessage($this->socket, $channel, "{$from}: Upgrading core: {$response}");
}
$coreDir = getcwd();
$pluginsRecDirIterator = new RecursiveDirectoryIterator('./');
foreach (new RecursiveIteratorIterator($pluginsRecDirIterator) as $gitDir) {
if (stringEndsWith($gitDir, ".git/..")) {
chdir($gitDir);
$response = trim(shell_exec("git pull"));
if (empty($response)) {
sendMessage($this->socket, $channel, "{$from}: Error upgrading sub git. Check permissions!");
} elseif ($response != 'Already up-to-date.') {
$restartRequired = true;
sendMessage($this->socket, $channel, "{$from}: Upgrading sub git: {$response}");
}
chdir($coreDir);
}
}
if ($restartRequired) {
sendMessage($this->socket, $channel, "{$from}: Restarting...");
sendData($this->socket, 'QUIT :Restarting due to upgrade');
die(exec('sh start.sh > /dev/null &'));
} else {
sendMessage($this->socket, $channel, "{$from}: Everything up to date, not restarting.");
}
}
}
}
开发者ID:nask0,项目名称:VikingBot,代码行数:42,代码来源:upgradePlugin.php
示例8: loadPlugins
function loadPlugins()
{
$this->plugins = array();
$pluginsRecDirIterator = new RecursiveDirectoryIterator(dirname(__FILE__) . '/plugins');
foreach (new RecursiveIteratorIterator($pluginsRecDirIterator) as $filename) {
if (stringEndsWith($filename, '.php')) {
$content = file_get_contents($filename);
if (preg_match("/class (.+) extends basePlugin/", $content, $matches)) {
$pName = $matches[1];
if (!in_array($pName, $this->config['disabledPlugins'])) {
require_once $filename;
logMsg("Loading plugin " . $pName);
$this->plugins[] = new $pName($this->config, $this->socket);
}
}
}
}
foreach ($this->plugins as $plugin) {
$pluginHelpData = $plugin->help();
if (isset($pluginHelpData[0]['command'])) {
$this->helpData = array_merge($this->helpData, $pluginHelpData);
}
}
}
开发者ID:sergejey,项目名称:majordomo-app_ircbot,代码行数:24,代码来源:VikingBot.php
示例9: display_foto
/**
* Wiki Loves Jurytool
*
* @author Ruben Demus
* @copyright 2015 Ruben Demus
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
function display_foto($db, $sql, $programm, $starter)
{
global $config;
global $text;
$bg[0] = "style=\"background-color:#FAFAFA;\"";
$bg[1] = "style=\"background-color:#EEE;\"";
$bg[2] = "style=\"background-color:#DDD;\"";
$res = $db->query($sql);
$images = $res->num_rows;
$i = $ii = 0;
$uploader = "<table border=0 cellpadding=0px width=1000px style=\"text-align: left;border-spacing: 2px 15px;\">";
while ($row = $res->fetch_array(MYSQLI_ASSOC)) {
$i++;
// background color
if ($i % 2 == 1 && $images != 1) {
$ii++;
$uploader .= "<tr " . $bg[$ii % 2] . ">";
} else {
if (isset($_GET["b"])) {
$ii++;
$uploader .= "<tr " . $bg[$ii % 2] . ">";
} else {
$uploader .= "<td width=10px style=\"background-color:#fff;\"> </td>";
}
}
// small images list
if ($images != 1 && !isset($_GET["b"])) {
$uploader .= "<td style=\"text-align: center; background-image: url(../theme/img/cws.gif); background-repeat: no-repeat; background-position: center; height: 100px; width:100px;\">";
$uploader .= "<a href=\"" . $row['url'] . "\" target=\"_blank\"><img src=\"" . str_replace("/commons/", "/commons/thumb/", $row['url']) . "/";
if (stringEndsWith($row['name'], ".tif") || stringEndsWith($row['name'], ".tiff")) {
$uploader .= "lossy-page1-100px-" . urlencode(str_replace("File:", "", str_replace(' ', '_', $row['name']))) . ".jpg\"";
} else {
$uploader .= "100px-" . urlencode(str_replace("File:", "", str_replace(' ', '_', $row['name']))) . "\"";
}
if ($row['width'] > $row['height']) {
$uploader .= "width=\"100\"";
} else {
$uploader .= "height=\"100\"";
}
$uploader .= "></a></td><td>";
} else {
$uploader .= "<td width=" . $_SESSION['width'] . "px height=" . $_SESSION['width'] . "px style=\"text-align: center; background-image: url(../theme/img/cw.gif); background-repeat: no-repeat; background-position: center; \">";
$uploader .= "<a href=\"" . $row['url'] . "\" target=\"_blank\"><img src=\"";
if ($row['width'] <= $_SESSION['width']) {
$uploader .= $row['url'];
} else {
$uploader .= str_replace("/commons/", "/commons/thumb/", $row['url']) . "/";
if (stringEndsWith($row['name'], ".tif") || stringEndsWith($row['name'], ".tiff")) {
$uploader .= "lossy-page1-" . $_SESSION['width'] . "px-" . urlencode(str_replace("File:", "", str_replace(' ', '_', $row['name']))) . ".jpg";
} else {
$uploader .= $_SESSION['width'] . "px-" . urlencode(str_replace("File:", "", str_replace(' ', '_', $row['name'])));
}
if ($row['width'] > $row['height']) {
$uploader .= "\" width=\"" . $_SESSION['width'];
} else {
$uploader .= "\" height=\"" . $_SESSION['width'];
}
}
$uploader .= "\"></a></td>";
if (!isset($_GET["b"])) {
$uploader .= "<td width=30px style=\"background-color:#fff;\"> </td>";
}
$uploader .= "<td style=\"vertical-align: top;\">";
}
// info about image
$uploader1 = " " . sha1($row['user']) . " <br> " . $row['date'] . " " . $row['time'] . "<br> " . round($row['size'] / 1024 / 1024, 2) . " MB, " . $row['width'] . "x" . $row['height'] . " px<br> " . $row['license'] . "<br> <a href=\"" . $row['descriptionurl'] . "\" target=\"_blank\" class=\"co\">commons</a></td>";
// voting url
if ($programm != "") {
$action = "./index.php?p=" . $programm . "&f=" . urlencode($row['name']) . "&a=";
} else {
$action = "./index.php?f=" . urlencode($row['name']) . "&a=";
}
// voting url big images
if (isset($_GET["b"])) {
$action2 = "&b=1";
} else {
$action2 = "";
}
$uploader2 = " " . $text["vote"] . "<br><br> ";
if ($programm == "") {
//.........这里部分代码省略.........
开发者ID:glavkos,项目名称:Wiki-Loves-Jurytool,代码行数:101,代码来源:next_foto.php
示例10: _getStashSession
/**
* Used by $this->Stash() to create & manage sessions for users & guests.
*
* This is a stop-gap solution until full session management for users &
* guests can be imlemented.
*/
private function _getStashSession($ValueToStash)
{
$CookieName = c('Garden.Cookie.Name', 'Vanilla');
$Name = $CookieName . '-sid';
// Grab the entire session record
$SessionID = val($Name, $_COOKIE, '');
// If there is no session, and no value for saving, return;
if ($SessionID == '' && $ValueToStash == '') {
return false;
}
$Session = Gdn::SQL()->select()->from('Session')->where('SessionID', $SessionID)->get()->firstRow();
if (!$Session) {
$SessionID = betterRandomString(32);
$TransientKey = substr(md5(mt_rand()), 0, 11) . '!';
// Save the session information to the database.
Gdn::SQL()->insert('Session', array('SessionID' => $SessionID, 'UserID' => Gdn::session()->UserID, 'TransientKey' => $TransientKey, 'DateInserted' => Gdn_Format::toDateTime(), 'DateUpdated' => Gdn_Format::toDateTime()));
Trace("Inserting session stash {$SessionID}");
$Session = Gdn::SQL()->select()->from('Session')->where('SessionID', $SessionID)->get()->firstRow();
// Save a session cookie
$Path = c('Garden.Cookie.Path', '/');
$Domain = c('Garden.Cookie.Domain', '');
$Expire = 0;
// If the domain being set is completely incompatible with the current domain then make the domain work.
$CurrentHost = Gdn::request()->host();
if (!stringEndsWith($CurrentHost, trim($Domain, '.'))) {
$Domain = '';
}
safeCookie($Name, $SessionID, $Expire, $Path, $Domain);
$_COOKIE[$Name] = $SessionID;
}
$Session->Attributes = @unserialize($Session->Attributes);
if (!$Session->Attributes) {
$Session->Attributes = array();
}
return $Session;
}
开发者ID:sitexa,项目名称:vanilla,代码行数:42,代码来源:class.session.php
示例11: analyzeAddon
//.........这里部分代码省略.........
}
if (StringEndsWith($Name, '/definitions.php')) {
if (count(explode('/', $Folder)) > 3) {
// The file is too deep to be a plugin file.
continue;
}
// This could be a locale pack, but we have to examine its info array.
$Zip->extractTo($FolderPath, $Entry['name']);
$FilePath = CombinePaths(array($FolderPath, $Name));
$Info = self::parseInfoArray($FilePath, 'LocaleInfo');
Gdn_FileSystem::removeFolder(dirname($FilePath));
if (!is_array($Info) || !count($Info)) {
continue;
}
$Key = key($Info);
$Info = $Info[$Key];
$Valid = true;
$Root = trim(substr($Name, 0, -strlen('/definitions.php')), '/');
// Make sure the locale is at least one folder deep.
if ($Root != $Key) {
$Result[] = $Name . ': The locale pack\'s key must be the same as its folder name.';
$Valid = false;
}
if (!val('Locale', $Info)) {
$Result[] = $Name . ': ' . sprintf(t('ValidateRequired'), t('Locale'));
$Valud = false;
} elseif (strcasecmp($Info['Locale'], $Key) == 0) {
$Result[] = $Name . ': ' . t('The locale\'s key cannot be the same as the name of the locale.');
$Valid = false;
}
// Validate basic fields.
$checkResult = self::checkRequiredFields($Info);
if (count($checkResult)) {
$Result = array_merge($Result, $checkResult);
$Valid = false;
}
if ($Valid) {
// The locale pack was confirmed.
$Addon = array('AddonKey' => $Key, 'AddonTypeID' => ADDON_TYPE_LOCALE, 'Name' => val('Name', $Info) ? $Info['Name'] : $Key, 'Description' => $Info['Description'], 'Version' => $Info['Version'], 'License' => $Info['License'], 'Path' => $Path);
break;
}
}
// Check to see if the entry is a core file.
if (stringEndsWith($Name, '/index.php')) {
if (count(explode('/', $Folder)) != 3) {
// The file is too deep to be the core's index.php
continue;
}
// This could be a theme file, but we have to examine its info array.
$Zip->extractTo($FolderPath, $Entry['name']);
$FilePath = CombinePaths(array($FolderPath, $Name));
// Get the version number from the core.
$Version = self::parseCoreVersion($FilePath);
if (!$Version) {
continue;
}
// The application was confirmed.
$Addon = array('AddonKey' => 'vanilla', 'AddonTypeID' => ADDON_TYPE_CORE, 'Name' => 'Vanilla', 'Description' => 'Vanilla is an open-source, standards-compliant, multi-lingual, fully extensible discussion forum for the web. Anyone who has web-space that meets the requirements can download and use Vanilla for free!', 'Version' => $Version, 'Path' => $Path);
$Info = array();
break;
}
}
if ($Addon) {
// Add the requirements.
$Requirements = arrayTranslate($Info, array('RequiredApplications' => 'Applications', 'RequiredPlugins' => 'Plugins', 'RequiredThemes' => 'Themes'));
foreach ($Requirements as $Type => $Items) {
if (!is_array($Items)) {
unset($Requirements[$Type]);
}
}
$Addon['Requirements'] = serialize($Requirements);
$Addon['Checked'] = true;
$UploadsPath = PATH_ROOT . '/uploads/';
if (stringBeginsWith($Addon['Path'], $UploadsPath)) {
$Addon['File'] = substr($Addon['Path'], strlen($UploadsPath));
}
if ($Fix) {
// Delete extraneous files.
foreach ($Deletes as $Delete) {
$Zip->deleteName($Delete['name']);
}
}
}
$Zip->close();
if (file_exists($FolderPath)) {
Gdn_FileSystem::removeFolder($FolderPath);
}
if ($Addon) {
$Addon['MD5'] = md5_file($Path);
$Addon['FileSize'] = filesize($Path);
return $Addon;
} else {
if ($ThrowError) {
$Msg = implode("\n", $Result);
throw new Exception($Msg, 400);
} else {
return false;
}
}
}
开发者ID:sitexa,项目名称:vanilla,代码行数:101,代码来源:class.updatemodel.php
示例12: glob
$zipsInPreviewDirectory = glob($allDocumentsPreviewDirectory . '*.zip');
if (count($zipsInPreviewDirectory)) {
foreach ($zipsInPreviewDirectory as $zipInPreviewDirectory) {
silentlyUnlink($zipInPreviewDirectory);
if (file_exists($zipInPreviewDirectory)) {
webServiceError('Docvert internal error: unable to remove ZIP file at "' . $zipInPreviewDirectory . '"');
}
}
$zipFilePath = $zipsInPreviewDirectory[0];
} else {
$zipFileName = chooseNameOfZipFile($allDocumentsPreviewDirectory);
$zipFilePath = $allDocumentsPreviewDirectory . $zipFileName;
}
$filesInPreviewDirectory = glob($previewDirectory . '*');
foreach ($filesInPreviewDirectory as $fileInPreviewDirectory) {
if (!stringStartsWith(basename($fileInPreviewDirectory), "docvert") && !stringEndsWith(basename($fileInPreviewDirectory), "wmf") && !stringEndsWith(basename($fileInPreviewDirectory), "gif") && !stringEndsWith(basename($fileInPreviewDirectory), "png") && !stringEndsWith(basename($fileInPreviewDirectory), "jpeg") && !stringEndsWith(basename($fileInPreviewDirectory), "jpg") && !stringEndsWith(basename($fileInPreviewDirectory), "svg")) {
//print 'Delete: '.$fileInPreviewDirectory.'<br />';
silentlyUnlink($fileInPreviewDirectory);
} else {
//print 'Retain: '.$fileInPreviewDirectory.'<br />';
}
}
$docbookPath = $previewDirectory . 'docvert--all-docbook.xml';
$docbook = file_get_contents($docbookPath);
$docbook = str_replace('{{body}}', $docbookBody, $docbook);
$docbook = str_replace('{{title}}', $docbookTitle, $docbook);
$contentPath = $previewDirectory . 'content.xml';
file_put_contents($contentPath, $docbook);
$pipelineToUse = $pipeline;
$autoPipeline = $autopipeline;
$skipAheadToDocbook = true;
开发者ID:Nolfneo,项目名称:docvert,代码行数:31,代码来源:save-changes.php
示例13: discussionsController_afterDiscussionTabs_handler
/**
* Old Html method of adding to discussion filters.
*/
public function discussionsController_afterDiscussionTabs_handler()
{
if (stringEndsWith(Gdn::request()->path(), '/unanswered', true)) {
$CssClass = ' class="Active"';
} else {
$CssClass = '';
}
$Count = Gdn::cache()->get('QnA-UnansweredCount');
if ($Count === Gdn_Cache::CACHEOP_FAILURE) {
$Count = ' <span class="Popin Count" rel="/discussions/unansweredcount">';
} else {
$Count = ' <span class="Count">' . $Count . '</span>';
}
echo '<li' . $CssClass . '><a class="TabLink QnA-UnansweredQuestions" href="' . url('/discussions/unanswered') . '">' . t('Unanswered Questions', 'Unanswered') . $Count . '</span></a></li>';
}
开发者ID:vanilla,项目名称:addons,代码行数:18,代码来源:class.qna.plugin.php
示例14: addTemplateFile
/**
* Add a Mustache template to controller output
*
* @param string $template
* @param string $controllerName optional.
* @param string $applicationFolder optional.
* @return boolean
*/
public static function addTemplateFile($template = '', $controllerName = null, $applicationFolder = false)
{
if (is_null($controllerName)) {
$controllerName = stringEndsWith(Gdn::controller()->ControllerName, 'controller', true, true);
}
if ($controllerName) {
$template = "{$controllerName}/{$template}";
}
$template = stringEndsWith($template, '.mustache', true, true);
$fileName = "{$template}.mustache";
$templateInfo = array('FileName' => $fileName, 'AppFolder' => $applicationFolder, 'Options' => array('name' => $template));
// Handle plugin-sourced views
if (stringBeginsWith($applicationFolder, 'plugins/')) {
$name = stringBeginsWith($applicationFolder, 'plugins/', true, true);
$info = Gdn::pluginManager()->getPluginInfo($name, Gdn_PluginManager::ACCESS_PLUGINNAME);
if ($info) {
$templateInfo['Version'] = val('Version', $info);
}
} else {
$info = Gdn::applicationManager()->getApplicationInfo($applicationFolder);
if ($info) {
$templateInfo['Version'] = val('Version', $info);
} else {
$templateInfo['Version'] = APPLICATION_VERSION;
}
}
Gdn::factory('Mustache')->templates[] = $templateInfo;
}
开发者ID:SatiricMan,项目名称:addons,代码行数:36,代码来源:class.mustache.php
示例15: checkBox
/**
* Returns XHTML for a checkbox input element.
*
* Cannot consider all checkbox values to be boolean. (2009-04-02 mosullivan)
* Cannot assume checkboxes are stored in database as string 'TRUE'. (2010-07-28 loki_racer)
*
* @param string $FieldName Name of the field that is being displayed/posted with this input.
* It should related directly to a field name in $this->_DataArray.
* @param string $Label Label to place next to the checkbox.
* @param array $Attributes Associative array of attributes for the input. (e.g. onclick, class)\
* Setting 'InlineErrors' to FALSE prevents error message even if $this->InlineErrors is enabled.
* @return string
*/
public function checkBox($FieldName, $Label = '', $Attributes = false)
{
$Value = arrayValueI('value', $Attributes, true);
$Attributes['value'] = $Value;
$Display = val('display', $Attributes, 'wrap');
unset($Attributes['display']);
if (stringEndsWith($FieldName, '[]')) {
if (!isset($Attributes['checked'])) {
$GetValue = $this->getValue(substr($FieldName, 0, -2));
if (is_array($GetValue) && in_array($Value, $GetValue)) {
$Attributes['checked'] = 'checked';
} elseif ($GetValue == $Value) {
$Attributes['checked'] = 'checked';
}
}
} else {
if ($this->getValue($FieldName) == $Value) {
$Attributes['checked'] = 'checked';
}
}
// Show inline errors?
$ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
// Add error class to input element
if ($ShowErrors) {
$this->addErrorClass($Attributes);
}
$Input = $this->input($FieldName, 'checkbox', $Attributes);
if ($Label != '') {
$LabelElement = '<label for="' . arrayValueI('id', $Attributes, $this->escapeID($FieldName, false)) . '" class="' . val('class', $Attributes, 'CheckBoxLabel') . '"' . attribute('title', val('title', $Attributes)) . '>';
if ($Display === 'wrap') {
$Input = $LabelElement . $Input . ' ' . T($Label) . '</label>';
} elseif ($Display === 'before') {
$Input = $LabelElement . T($Label) . '</label> ' . $Input;
} else {
$Input = $Input . ' ' . $LabelElement . T($Label) . '</label>';
}
}
// Append validation error message
if ($ShowErrors && arrayValueI('InlineErrors', $Attributes, true)) {
$Return .= $this->inlineError($FieldName);
}
return $Input;
}
开发者ID:bryanjamesmiller,项目名称:vanilla,代码行数:56,代码来源:class.form.php
示例16: clearSectionNavigationPreference
/**
* Checks if a url is saved as a navigation preference and if so, deletes it.
* Also optionally resets the section dashboard landing page, which may be desirable if a user no longer has
* permission to access pages in that section.
*
* @param string $url The url to search the user navigation preferences for, defaults to the request
* @param string $userID The ID of the user to clear the preferences for, defaults to the sessioned user
* @param bool $resetSectionPreference Whether to reset the dashboard section landing page
*/
public function clearSectionNavigationPreference($url = '', $userID = '', $resetSectionPreference = true)
{
if (!$userID) {
$userID = Gdn::session()->UserID;
}
if ($url == '') {
$url = Gdn::request()->url();
}
$user = $this->getID($userID);
$preferences = val('Preferences', $user, []);
$landingPages = val('DashboardNav.SectionLandingPages', $preferences, []);
// Run through the user's saved landing page per section and if the url matches the passed url,
// remove that preference.
foreach ($landingPages as $section => $landingPage) {
$url = strtolower(trim($url, '/'));
$landingPage = strtolower(trim($landingPage, '/'));
if ($url == $landingPage || stringEndsWith($url, $landingPage)) {
unset($landingPages[$section]);
}
}
$this->savePreference($userID, 'DashboardNav.SectionLandingPages', $landingPages);
if ($resetSectionPreference) {
$this->savePreference($userID, 'DashboardNav.DashboardLandingPage', '');
}
}
开发者ID:vanilla,项目名称:vanilla,代码行数:34,代码来源:class.usermodel.php
示例17: checkBox
/**
* Returns XHTML for a checkbox input element.
*
* Cannot consider all checkbox values to be boolean. (2009-04-02 mosullivan)
* Cannot assume checkboxes are stored in database as string 'TRUE'. (2010-07-28 loki_racer)
*
* @param string $FieldName Name of the field that is being displayed/posted with this input.
* It should related directly to a field name in $this->_DataArray.
* @param string $Label Label to place next to the checkbox.
* @param array $Attributes Associative array of attributes for the input. (e.g. onclick, class)\
* Setting 'InlineErrors' to FALSE prevents error message even if $this->InlineErrors is enabled.
* @return string
*/
public function checkBox($FieldName, $Label = '', $Attributes = array())
{
$Value = arrayValueI('value', $Attributes, true);
$Attributes['value'] = $Value;
$Display = val('display', $Attributes, 'wrap');
unset($Attributes['display']);
if (stringEndsWith($FieldName, '[]')) {
if (!isset($Attributes['checked'])) {
$GetValue = $this->getValue(substr($FieldName, 0, -2));
if (is_array($GetValue) && in_array($Value, $GetValue)) {
$Attributes['checked'] = 'checked';
} elseif ($GetValue == $Value) {
$Attributes['checked'] = 'checked';
}
}
} else {
if ($this->getValue($FieldName) == $Value) {
$Attributes['checked'] = 'checked';
}
}
// Show inline errors?
$ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
// Add error class to input element.
if ($ShowErrors) {
$this->addErrorClass($Attributes);
}
if (isset($Attributes['class'])) {
$class = $this->translateClasses($Attributes['class']);
} else {
$class = $this->getStyle('checkbox', '');
}
$Input = $this->input($FieldName, 'checkbox', $Attributes);
if ($Label != '') {
$LabelElement = '<label for="' . arrayValueI('id', $Attributes, $this->escapeID($FieldName, false)) . '"' . attribute('class', $class) . attribute('title', val('title', $Attributes)) . '>';
if ($Display === 'wrap') {
$Input = $LabelElement . $Input . ' ' . T($Label) . '</label>';
} elseif ($Display === 'before') {
$Input = $LabelElement . T($Label) . '</label> ' . $Input;
} elseif ($Display === 'toggle') {
$Input = '<div class="label-wrap"><label>' . T($Label) . '</label></div><div class="toggle-box-wrapper"><div class="toggle-box">' . $Input . $LabelElement . '</label></div></div> ';
} else {
$Input = $Input . ' ' . $LabelElement . T($Label) . '</label>';
}
}
// Append validation error message
if ($ShowErrors && arrayValueI('InlineErrors', $Attributes, true)) {
$Input .= $this->inlineError($FieldName);
}
if ($this->getStyle('checkbox-container', '') && stripos($class, 'inline') == false) {
$container = $this->getStyle('checkbox-container');
$Input = "<div class=\"{$container}\">" . $Input . '</div>';
}
return $Input;
}
开发者ID:vanilla,项目名称:vanilla,代码行数:67,代码来源:class.form.php
示例18: defaultUpdate
public function defaultUpdate(Request $request, $item)
{
// Uppfæra öll "translatables"...
foreach (config('formable.locales') as $locale) {
foreach ($request->all() as $k => $v) {
if (stringEndsWith($k, '_' . $locale)) {
$keyName = substr($k, 0, -3);
// Uppfæra líka default attribute...
if ($locale === config('app.fallback_locale')) {
$item->{$keyName} = $v;
}
if (in_array($keyName, $item->translatable)) {
$item->translations($locale)->add($keyName, $v);
}
}
}
}
// Uppfæra öll "extras"...
foreach (config('formable.locales') as $locale) {
foreach ($request->all() as $k => $v) {
if (stringStartsWith($k, 'extra_' . $locale)) {
$keyName = substr($k, 9);
if (array_key_exists($keyName, $item->extras[$locale])) {
$item->extras($locale)->add($keyName, $v);
}
}
}
}
}
开发者ID:stjanilofts,项目名称:gicms,代码行数:29,代码来源:ItemableController.php
示例19: onMessage
function onMessage($from, $channel, $msg)
{
if (stringEndsWith($msg, "{$this->config['trigger']}ping")) {
sendMessage($this->socket, $channel, $from . ": Pong");
}
}
开发者ID:fathkay,项目名称:VikingBot,代码行数:6,代码来源:pingPlugin.php
|
请发表评论