当前位置: 首页>>代码示例>>PHP>>正文


PHP stringBeginsWith函数代码示例

本文整理汇总了PHP中stringBeginsWith函数的典型用法代码示例。如果您正苦于以下问题:PHP stringBeginsWith函数的具体用法?PHP stringBeginsWith怎么用?PHP stringBeginsWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了stringBeginsWith函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _checkTable

/**
 *
 *
 * @param $Data
 */
function _checkTable($Data)
{
    echo "<table class='Data' width='100%' style='table-layout: fixed;'>\n";
    echo "<thead><tr><td width='20%'>Field</td><td width='45%'>Current</td><td width='35%'>File</td></tr></thead>";
    $First = true;
    foreach ($Data as $Key => $Value) {
        if (stringBeginsWith($Key, 'File_') || is_array($Value) || $Key == 'Name') {
            continue;
        }
        $Value = Gdn_Format::html($Value);
        $FileValue = Gdn_Format::html(val('File_' . $Key, $Data));
        if ($Key == 'MD5') {
            $Value = substr($Value, 0, 10);
            $FileValue = substr($FileValue, 0, 10);
        }
        if ($Key == 'FileSize') {
            $Value = Gdn_Upload::FormatFileSize($Value);
        }
        echo "<tr><td>{$Key}</td><td>{$Value}</td>";
        if ($Error = val('File_Error', $Data)) {
            if ($First) {
                echo '<td rowspan="4">', htmlspecialchars($Error), '</td>';
            }
        } else {
            echo "<td>{$FileValue}</td></tr>";
        }
        echo "\n";
        $First = false;
    }
    echo '</table>';
}
开发者ID:vanilla,项目名称:community,代码行数:36,代码来源:check.php

示例2: 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;
 }
开发者ID:vanilla,项目名称:addons,代码行数:50,代码来源:class.jsconnect.plugin.php

示例3: logo

 /**
  * Renders the banner logo, or just the banner title if the logo is not defined.
  *
  * @param array $Properties
  */
 public static function logo($Properties = array())
 {
     $Logo = C('Garden.Logo');
     if ($Logo) {
         $Logo = ltrim($Logo, '/');
         // Fix the logo path.
         if (stringBeginsWith($Logo, 'uploads/')) {
             $Logo = substr($Logo, strlen('uploads/'));
         }
         // Set optional title text.
         if (empty($Properties['title']) && C('Garden.LogoTitle')) {
             $Properties['title'] = C('Garden.LogoTitle');
         }
     }
     // Use the site title as alt if none was given.
     $Title = C('Garden.Title', 'Title');
     if (empty($Properties['alt'])) {
         $Properties['alt'] = $Title;
     }
     echo $Logo ? Img(Gdn_Upload::url($Logo), $Properties) : $Title;
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:26,代码来源:class.theme.php

示例4: fetchPageInfo

 public function fetchPageInfo($Url, $ThrowError = false)
 {
     $PageInfo = FetchPageInfo($Url, 3, $ThrowError);
     $Title = val('Title', $PageInfo, '');
     if ($Title == '') {
         if ($ThrowError) {
             throw new Gdn_UserException(t("The page didn't contain any information."));
         }
         $Title = formatString(t('Undefined discussion subject.'), array('Url' => $Url));
     } else {
         if ($Strip = c('Vanilla.Embed.StripPrefix')) {
             $Title = stringBeginsWith($Title, $Strip, true, true);
         }
         if ($Strip = c('Vanilla.Embed.StripSuffix')) {
             $Title = StringEndsWith($Title, $Strip, true, true);
         }
     }
     $Title = trim($Title);
     $Description = val('Description', $PageInfo, '');
     $Images = val('Images', $PageInfo, array());
     $Body = formatString(t('EmbeddedDiscussionFormat'), array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? img(val(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $Url));
     if ($Body == '') {
         $Body = $Url;
     }
     if ($Body == '') {
         $Body = formatString(t('EmbeddedNoBodyFormat.'), array('Url' => $Url));
     }
     $Result = array('Name' => $Title, 'Body' => $Body, 'Format' => 'Html');
     return $Result;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:30,代码来源:class.discussionmodel.php

示例5: reverseRoute

 /**
  *
  *
  * @param $Url
  * @return bool|int|string
  */
 public function reverseRoute($Url)
 {
     $Root = rtrim(Gdn::request()->domain() . '/' . Gdn::request()->webRoot(), '/');
     if (stringBeginsWith($Url, $Root)) {
         $Url = stringBeginsWith($Url, $Root, true, true);
         $WithDomain = true;
     } else {
         $WithDomain = false;
     }
     $Url = '/' . ltrim($Url, '/');
     foreach ($this->Routes as $Route => $RouteData) {
         if ($RouteData['Type'] != 'Internal' || $RouteData['Reserved'] && $RouteData['Route'] != 'DefaultController') {
             continue;
         }
         $Destination = '/' . ltrim($RouteData['Destination'], '/');
         if ($Destination == $Url) {
             $Route = '/' . ltrim($RouteData['Route'], '/');
             if ($Route == '/DefaultController') {
                 $Route = '/';
             }
             if ($WithDomain) {
                 return $Root . $Route;
             } else {
                 return $Route;
             }
         }
     }
     if ($WithDomain) {
         return $Root . $Url;
     } else {
         return $Url;
     }
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:39,代码来源:class.router.php

示例6: externalUrl

 /**
  * Build a URL to an external site linked to this one.
  *
  * This function is used when an external site is configured with Vanilla in an embedding scenario.
  *
  * @param string $path The path within Vanilla.
  * @return string Returns the external URL.
  */
 function externalUrl($path)
 {
     $urlFormat = c('Garden.ExternalUrlFormat');
     if ($urlFormat && !isUrl($path)) {
         $result = sprintf($urlFormat, ltrim($path, '/'));
     } elseif (stringBeginsWith($path, '//')) {
         $result = Gdn::request()->scheme() . ':' . $path;
     } else {
         $result = Url($path, true);
     }
     return $result;
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:20,代码来源:functions.general.php

示例7: crawlAddonLocaleSources

 /**
  * Crawl applications or plugins for its locale files.
  *
  * @param string $basePath The base path. Either the plugins or applications path.
  * @param string[] $folders The folders to crawl within the base path.
  * @param array $result The result array to put all the translation paths.
  */
 protected function crawlAddonLocaleSources($basePath, $folders, &$result)
 {
     if (!is_array($folders)) {
         return;
     }
     $paths = array();
     foreach ($folders as $folder) {
         $paths[] = $basePath . "/{$folder}/locale";
     }
     // Get all of the locale files for the addons.
     foreach ($paths as $path) {
         // Look for individual locale files.
         $localePaths = safeGlob($path . '/*.php');
         foreach ($localePaths as $localePath) {
             $locale = self::canonicalize(basename($localePath, '.php'));
             $result[$locale][] = $localePath;
         }
         // Look for locale files in a directory.
         // This should be deprecated very soon.
         $localePaths = safeGlob($path . '/*/definitions.php');
         foreach ($localePaths as $localePath) {
             $locale = self::canonicalize(basename(dirname($localePath)));
             $result[$locale][] = $localePath;
             $subPath = stringBeginsWith($localePath, PATH_ROOT, true, true);
             $properPath = dirname($subPath) . '.php';
             trigger_error("Locales in {$subPath} is deprecated. Use {$properPath} instead.", E_USER_DEPRECATED);
         }
     }
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:36,代码来源:class.locale.php

示例8: banner

 /**
  * Banner management screen.
  *
  * @since 2.0.0
  * @access public
  */
 public function banner()
 {
     $this->permission('Garden.Community.Manage');
     $this->addSideMenu('dashboard/settings/banner');
     $this->title(t('Banner'));
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->setField(array('Garden.HomepageTitle' => c('Garden.Title'), 'Garden.Title', 'Garden.Description'));
     // Set the model on the form.
     $this->Form->setModel($ConfigurationModel);
     // Get the current logo.
     $Logo = c('Garden.Logo');
     if ($Logo) {
         $Logo = ltrim($Logo, '/');
         // Fix the logo path.
         if (stringBeginsWith($Logo, 'uploads/')) {
             $Logo = substr($Logo, strlen('uploads/'));
         }
         $this->setData('Logo', $Logo);
     }
     // Get the current mobile logo.
     $MobileLogo = c('Garden.MobileLogo');
     if ($MobileLogo) {
         $MobileLogo = ltrim($MobileLogo, '/');
         // Fix the logo path.
         if (stringBeginsWith($MobileLogo, 'uploads/')) {
             $MobileLogo = substr($MobileLogo, strlen('uploads/'));
         }
         $this->setData('MobileLogo', $MobileLogo);
     }
     // Get the current favicon.
     $Favicon = c('Garden.FavIcon');
     $this->setData('Favicon', $Favicon);
     $ShareImage = c('Garden.ShareImage');
     $this->setData('ShareImage', $ShareImage);
     // If seeing the form for the first time...
     if (!$this->Form->authenticatedPostBack()) {
         // Apply the config settings to the form.
         $this->Form->setData($ConfigurationModel->Data);
     } else {
         $SaveData = array();
         if ($this->Form->save() !== false) {
             $Upload = new Gdn_Upload();
             try {
                 // Validate the upload
                 $TmpImage = $Upload->validateUpload('Logo', false);
                 if ($TmpImage) {
                     // Generate the target image name
                     $TargetImage = $Upload->generateTargetName(PATH_UPLOADS);
                     $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
                     // Delete any previously uploaded images.
                     if ($Logo) {
                         $Upload->delete($Logo);
                     }
                     // Save the uploaded image
                     $Parts = $Upload->SaveAs($TmpImage, $ImageBaseName);
                     $ImageBaseName = $Parts['SaveName'];
                     $SaveData['Garden.Logo'] = $ImageBaseName;
                     $this->setData('Logo', $ImageBaseName);
                 }
                 $TmpMobileImage = $Upload->validateUpload('MobileLogo', false);
                 if ($TmpMobileImage) {
                     // Generate the target image name
                     $TargetImage = $Upload->generateTargetName(PATH_UPLOADS);
                     $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
                     // Delete any previously uploaded images.
                     if ($MobileLogo) {
                         $Upload->delete($MobileLogo);
                     }
                     // Save the uploaded image
                     $Parts = $Upload->saveAs($TmpMobileImage, $ImageBaseName);
                     $ImageBaseName = $Parts['SaveName'];
                     $SaveData['Garden.MobileLogo'] = $ImageBaseName;
                     $this->setData('MobileLogo', $ImageBaseName);
                 }
                 $ImgUpload = new Gdn_UploadImage();
                 $TmpFavicon = $ImgUpload->validateUpload('Favicon', false);
                 if ($TmpFavicon) {
                     $ICOName = 'favicon_' . substr(md5(microtime()), 16) . '.ico';
                     if ($Favicon) {
                         $Upload->delete($Favicon);
                     }
                     // Resize the to a png.
                     $Parts = $ImgUpload->SaveImageAs($TmpFavicon, $ICOName, 16, 16, array('OutputType' => 'ico', 'Crop' => true));
                     $SaveData['Garden.FavIcon'] = $Parts['SaveName'];
                     $this->setData('Favicon', $Parts['SaveName']);
                 }
                 $TmpShareImage = $Upload->ValidateUpload('ShareImage', false);
                 if ($TmpShareImage) {
                     $TargetImage = $Upload->GenerateTargetName(PATH_UPLOADS, false);
                     $ImageBaseName = pathinfo($TargetImage, PATHINFO_BASENAME);
                     if ($ShareImage) {
                         $Upload->delete($ShareImage);
                     }
//.........这里部分代码省略.........
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:101,代码来源:class.settingscontroller.php

示例9: scanThemeFile

 /**
  *
  *
  * @param $ThemeFile
  * @param null $VariableName
  * @return null|void
  */
 public function scanThemeFile($ThemeFile, $VariableName = null)
 {
     // Find the $PluginInfo array
     if (!file_exists($ThemeFile)) {
         return;
     }
     $Lines = file($ThemeFile);
     $InfoBuffer = false;
     $ClassBuffer = false;
     $ClassName = '';
     $ThemeInfoString = '';
     if (!$VariableName) {
         $VariableName = 'ThemeInfo';
     }
     $ParseVariableName = '$' . $VariableName;
     ${$VariableName} = array();
     foreach ($Lines as $Line) {
         if ($InfoBuffer && substr(trim($Line), -2) == ');') {
             $ThemeInfoString .= $Line;
             $ClassBuffer = true;
             $InfoBuffer = false;
         }
         if (stringBeginsWith(trim($Line), $ParseVariableName)) {
             $InfoBuffer = true;
         }
         if ($InfoBuffer) {
             $ThemeInfoString .= $Line;
         }
         if ($ClassBuffer && strtolower(substr(trim($Line), 0, 6)) == 'class ') {
             $Parts = explode(' ', $Line);
             if (count($Parts) > 2) {
                 $ClassName = $Parts[1];
             }
             break;
         }
     }
     unset($Lines);
     if ($ThemeInfoString != '') {
         @eval($ThemeInfoString);
     }
     // Define the folder name and assign the class name for the newly added item
     if (isset(${$VariableName}) && is_array(${$VariableName})) {
         $Item = array_pop($Trash = array_keys(${$VariableName}));
         ${$VariableName}[$Item]['Index'] = $Item;
         ${$VariableName}[$Item]['AboutFile'] = $ThemeFile;
         ${$VariableName}[$Item]['RealAboutFile'] = realpath($ThemeFile);
         ${$VariableName}[$Item]['ThemeRoot'] = dirname($ThemeFile);
         if (!array_key_exists('Name', ${$VariableName}[$Item])) {
             ${$VariableName}[$Item]['Name'] = $Item;
         }
         if (!array_key_exists('Folder', ${$VariableName}[$Item])) {
             ${$VariableName}[$Item]['Folder'] = basename(dirname($ThemeFile));
         }
         return ${$VariableName}[$Item];
     } elseif ($VariableName !== null) {
         if (isset(${$VariableName})) {
             return ${$VariableName};
         }
     }
     return null;
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:68,代码来源:class.thememanager.php

示例10: resolveStaticResources


//.........这里部分代码省略.........
         } elseif (strpos($resourceFile, '/') === 0) {
             // A direct path to the file was given.
             $testPaths = array(paths(PATH_ROOT, $resourceFile));
         } elseif (strpos($resourceFile, '~') === 0) {
             $skipFileCheck = true;
             $resourceFile = substr($resourceFile, 1);
             $testPaths = array(paths(PATH_ROOT, $resourceFile));
         } else {
             // Relative path
             $appFolder = val('AppFolder', $resourceInfo, false);
             if ($appFolder == '') {
                 $appFolder = $controllerAppFolder;
             }
             if ($appFolder == 'false') {
                 $appFolder = false;
             }
             // Resources can come from:
             //   - a theme
             //   - an application
             //   - a plugin
             //   - global garden resource-specific folder
             //   - global garden resource-specific library folder
             $testPaths = array();
             // Theme
             if (in_array('themes', $checkLocations) && $controllerTheme) {
                 // Application-specific theme override
                 if ($appFolder) {
                     $testPaths[] = paths(PATH_THEMES, $controllerTheme, $appFolder, $stub, $resourceFile);
                 }
                 // Garden-wide theme override
                 $testPaths[] = paths(PATH_THEMES, $controllerTheme, $stub, $resourceFile);
             }
             // Application or plugin
             $isPluginFolder = stringBeginsWith(trim($appFolder, '/'), 'plugins/', true, false);
             if ($isPluginFolder) {
                 $pluginFolder = stringBeginsWith(trim($appFolder, '/'), 'plugins/', true, true);
             }
             if (in_array('plugins', $checkLocations) && $isPluginFolder) {
                 // Plugin
                 $testPaths[] = paths(PATH_PLUGINS, $pluginFolder, $stub, $resourceFile);
                 $testPaths[] = paths(PATH_PLUGINS, $pluginFolder, $resourceFile);
             }
             if (in_array('applications', $checkLocations) && !$isPluginFolder) {
                 // Application
                 if ($appFolder) {
                     $testPaths[] = paths(PATH_APPLICATIONS, $appFolder, $stub, $resourceFile);
                 }
                 // Dashboard app is added by default
                 if ($appFolder != 'dashboard') {
                     $testPaths[] = paths(PATH_APPLICATIONS, 'dashboard', $stub, $resourceFile);
                 }
             }
             if (in_array('global', $checkLocations)) {
                 // Global folder. eg. root/js/
                 $testPaths[] = paths(PATH_ROOT, $stub, $resourceFile);
                 if ($checkGlobalLibrary) {
                     // Global library folder. eg. root/js/library/
                     $testPaths[] = paths(PATH_ROOT, $stub, 'library', $resourceFile);
                 }
             }
         }
         // Find the first file that matches the path.
         $resourcePath = false;
         if (!$skipFileCheck) {
             foreach ($testPaths as $glob) {
                 $paths = safeGlob($glob);
开发者ID:SatiricMan,项目名称:addons,代码行数:67,代码来源:class.mustache.php

示例11: jsPath

 /**
  * Lookup the path to a JS file and return its info array
  *
  * @param string $filename name/relative path to js file
  * @param string $folder optional. app or plugin folder to search
  * @param string $themeType mobile or desktop
  * @return array|bool
  */
 public static function jsPath($filename, $folder = '', $themeType = '')
 {
     if (!$themeType) {
         $themeType = isMobile() ? 'mobile' : 'desktop';
     }
     // 1. Check for a url.
     if (isUrl($filename)) {
         return array($filename, $filename);
     }
     $paths = array();
     // 2. Check for a full path.
     if (strpos($filename, '/') === 0) {
         $filename = ltrim($filename, '/');
         // Direct path was given
         $filename = "/{$filename}";
         $path = PATH_ROOT . $filename;
         if (file_exists($path)) {
             deprecated("AssetModel::JsPath() with direct paths");
             return array($path, $filename);
         }
         return false;
     }
     // 3. Check the theme.
     $theme = Gdn::themeManager()->themeFromType($themeType);
     if ($theme) {
         $path = "/{$theme}/js/{$filename}";
         $paths[] = array(PATH_THEMES . $path, "/themes{$path}");
     }
     // 4. Static, Plugin, or App relative file
     if ($folder) {
         if (in_array($folder, array('resources', 'static'))) {
             $path = "/resources/js/{$filename}";
             $paths[] = array(PATH_ROOT . $path, $path);
             // A plugin-relative path was given
         } elseif (stringBeginsWith($folder, 'plugins/')) {
             $folder = substr($folder, strlen('plugins/'));
             $path = "/{$folder}/js/{$filename}";
             $paths[] = array(PATH_PLUGINS . $path, "/plugins{$path}");
             // Allow direct-to-file links for plugins
             $paths[] = array(PATH_PLUGINS . "/{$folder}/{$filename}", "/plugins/{$folder}/{$filename}", true);
             // deprecated
             // An app-relative path was given
         } else {
             // App-relative path under the theme
             if ($theme) {
                 $path = "/{$theme}/{$folder}/js/{$filename}";
                 $paths[] = array(PATH_THEMES . $path, "/themes{$path}");
             }
             $path = "/{$folder}/js/{$filename}";
             $paths[] = array(PATH_APPLICATIONS . $path, "/applications{$path}");
         }
     }
     // 5. Check the global js folder.
     $paths[] = array(PATH_ROOT . "/js/{$filename}", "/js/{$filename}");
     $paths[] = array(PATH_ROOT . "/js/library/{$filename}", "/js/library/{$filename}");
     foreach ($paths as $info) {
         if (file_exists($info[0])) {
             if (!empty($info[2])) {
                 // This path is deprecated.
                 unset($info[2]);
                 deprecated("The js file '{$filename}' in folder '{$folder}'");
             }
             return $info;
         }
     }
     if (!stringEndsWith($filename, 'custom.js')) {
         trace("Could not find file '{$filename}' in folder '{$folder}'.");
     }
     return false;
 }
开发者ID:rensi4rn,项目名称:vanilla,代码行数:78,代码来源:class.assetmodel.php

示例12: createController

 /**
  * Create a controller and initialize it with data from the dispatcher.
  *
  * @param string $controllerName The name of the controller to create.
  * @param Gdn_Request $request The current request.
  * @param array &$routeArgs Arguments from a call to {@link Gdn_Dispatcher::analyzeRequest}.
  * @return Gdn_Controller Returns a new {@link Gdn_Controller} object.
  */
 private function createController($controllerName, $request, &$routeArgs)
 {
     /* @var Gdn_Controller $controller */
     $controller = new $controllerName();
     Gdn::controller($controller);
     $this->EventArguments['Controller'] =& $controller;
     $this->fireEvent('AfterControllerCreate');
     // Pass along any assets
     if (is_array($this->controllerAssets)) {
         foreach ($this->controllerAssets as $AssetName => $Assets) {
             foreach ($Assets as $Asset) {
                 $controller->addAsset($AssetName, $Asset);
             }
         }
     }
     // Instantiate Imported & Uses classes
     $controller->getImports();
     // Pass along any objects
     foreach ($this->controllerProperties as $Name => $Mixed) {
         $controller->{$Name} = $Mixed;
     }
     // Pass along any data.
     if (!empty($this->controllerData)) {
         $controller->Data = $this->controllerData;
     }
     $controller->Request = $request;
     $controller->SelfUrl = $routeArgs['path'];
     /* @var Addon $addon */
     $addon = $routeArgs['addon'];
     if ($addon) {
         $controller->Application = $addon->getKey();
         $controller->ApplicationFolder = stringBeginsWith(ltrim($addon->getSubdir(), '/'), 'applications/', true, true);
     }
     $controller->Request = $request;
     $controller->deliveryType($routeArgs['deliveryType']);
     $controller->deliveryMethod($routeArgs['deliveryMethod']);
     $controller->SyndicationMethod = val('syndicationMethod', $routeArgs, SYNDICATION_NONE);
     $this->deliveryType = $routeArgs['deliveryType'];
     $this->deliveryMethod = $routeArgs['deliveryMethod'];
     // Kludge: We currently have a couple of plugins that modify the path arguments on initialize.
     $this->controllerArguments($routeArgs['pathArgs']);
     // End kludge.
     $controller->initialize();
     // Kludge for controllers that modify the dispatcher.
     $pathArgs = $this->controllerArguments();
     if (!empty($this->ControllerMethod)) {
         array_unshift($pathArgs, Gdn::Dispatcher()->ControllerMethod);
     }
     $routeArgs['pathArgs'] = $pathArgs;
     // End kluge.
     $this->EventArguments['Controller'] = $controller;
     $this->fireEvent('AfterControllerInit');
     return $controller;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:62,代码来源:class.dispatcher.php

示例13: _setBreadcrumbs

 public function _setBreadcrumbs($Name = null, $Url = null)
 {
     // Add the root link.
     if (val('UserID', $this->User) == Gdn::session()->UserID) {
         $Root = array('Name' => t('Profile'), 'Url' => '/profile');
         $Breadcrumb = array('Name' => $Name, 'Url' => $Url);
     } else {
         $NameUnique = c('Garden.Registration.NameUnique');
         $Root = array('Name' => val('Name', $this->User), 'Url' => userUrl($this->User));
         $Breadcrumb = array('Name' => $Name, 'Url' => $Url . '/' . ($NameUnique ? '' : val('UserID', $this->User) . '/') . rawurlencode(val('Name', $this->User)));
     }
     $this->Data['Breadcrumbs'][] = $Root;
     if ($Name && !stringBeginsWith($Root['Url'], $Url)) {
         $this->Data['Breadcrumbs'][] = array('Name' => $Name, 'Url' => $Url);
     }
 }
开发者ID:korelstar,项目名称:vanilla,代码行数:16,代码来源:class.profilecontroller.php

示例14: validateRule

 /**
  * Execute a single validation rule and return its result.
  *
  * @param mixed $Value The value to validate.
  * @param string $FieldName The name of the field to put into the error result.
  * @param string|array $Rule The rule to validate which can be one of the following.
  *  - string: The name of a function used to validate the value.
  *  - 'regex:<regex>': The regular expression used to validate the value.
  *  - array: An array with the following keys:
  *    - Name: The name of the function used to validate.
  *    - Args: An argument to pass to the function after the value.
  * @param string $CustomError A custom error message.
  * @return bool|string One of the following
  *  - TRUE: The value passed validation.
  *  - string: The error message associated with the error.
  */
 public static function validateRule($Value, $FieldName, $Rule, $CustomError = false)
 {
     // Figure out the type of rule.
     if (is_string($Rule)) {
         if (stringBeginsWith($Rule, 'regex:', true)) {
             $RuleName = 'validateregex';
             $Args = substr($Rule, 6);
         } elseif (stringBeginsWith($Rule, 'function:', true)) {
             $RuleName = substr($Rule, 9);
         } else {
             $RuleName = $Rule;
         }
     } elseif (is_array($Rule)) {
         $RuleName = val('Name', $Rule);
         $Args = val('Args', $Rule);
     }
     if (!isset($Args)) {
         $Args = null;
     }
     if (function_exists($RuleName)) {
         $Result = $RuleName($Value, $Args);
         if ($Result === true) {
             return true;
         } elseif ($CustomError) {
             return $CustomError;
         } elseif (is_string($Result)) {
             return $Result;
         } else {
             return sprintf(T($RuleName), T($FieldName));
         }
     } else {
         return sprintf('Validation does not exist: %s.', $RuleName);
     }
 }
开发者ID:battaglia01,项目名称:vanilla,代码行数:50,代码来源:class.validation.php

示例15: cssPath

 /**
  * Lookup the path to a CSS file and return its info array
  *
  * @param string $Filename name/relative path to css file
  * @param string $Folder optional. app or plugin folder to search
  * @param string $ThemeType mobile or desktop
  * @return array|bool
  */
 public static function cssPath($Filename, $Folder = '', $ThemeType = '')
 {
     if (!$ThemeType) {
         $ThemeType = IsMobile() ? 'mobile' : 'desktop';
     }
     // 1. Check for a url.
     if (IsUrl($Filename)) {
         return array($Filename, $Filename);
     }
     $Paths = array();
     // 2. Check for a full path.
     if (strpos($Filename, '/') !== false) {
         $Filename = ltrim($Filename, '/');
         // Direct path was given
         $Filename = "/{$Filename}";
         $Path = PATH_ROOT . $Filename;
         if (file_exists($Path)) {
             Deprecated("AssetModel::CssPath() with direct paths");
             return array($Path, $Filename);
         }
         return false;
     }
     // 3. Check the theme.
     $Theme = Gdn::ThemeManager()->ThemeFromType($ThemeType);
     if ($Theme) {
         $Path = "/{$Theme}/design/{$Filename}";
         $Paths[] = array(PATH_THEMES . $Path, "/themes{$Path}");
     }
     // 4. Static, Plugin, or App relative file
     if ($Folder) {
         if (in_array($Folder, array('resources', 'static'))) {
             $Path = "/resources/design/{$Filename}";
             $Paths[] = array(PATH_ROOT . $Path, $Path);
             // A plugin-relative path was given
         } elseif (stringBeginsWith($Folder, 'plugins/')) {
             $Folder = substr($Folder, strlen('plugins/'));
             $Path = "/{$Folder}/design/{$Filename}";
             $Paths[] = array(PATH_PLUGINS . $Path, "/plugins{$Path}");
             // Allow direct-to-file links for plugins
             $Paths[] = array(PATH_PLUGINS . "/{$Folder}/{$Filename}", "/plugins/{$Folder}/{$Filename}", true);
             // deprecated
             // An app-relative path was given
         } else {
             $Path = "/{$Folder}/design/{$Filename}";
             $Paths[] = array(PATH_APPLICATIONS . $Path, "/applications{$Path}");
         }
     }
     // 5. Check the default application.
     if ($Folder != 'dashboard') {
         $Paths[] = array(PATH_APPLICATIONS . "/dashboard/design/{$Filename}", "/applications/dashboard/design/{$Filename}", true);
         // deprecated
     }
     foreach ($Paths as $Info) {
         if (file_exists($Info[0])) {
             if (!empty($Info[2])) {
                 // This path is deprecated.
                 unset($Info[2]);
                 Deprecated("The css file '{$Filename}' in folder '{$Folder}'");
             }
             return $Info;
         }
     }
     if (!(StringEndsWith($Filename, 'custom.css') || StringEndsWith($Filename, 'customadmin.css'))) {
         trace("Could not find file '{$Filename}' in folder '{$Folder}'.");
     }
     return false;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:75,代码来源:class.assetmodel.php


注:本文中的stringBeginsWith函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。