本文整理汇总了PHP中Craft::getPathOfAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP Craft::getPathOfAlias方法的具体用法?PHP Craft::getPathOfAlias怎么用?PHP Craft::getPathOfAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Craft
的用法示例。
在下文中一共展示了Craft::getPathOfAlias方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initializes the application component.
*
* @return null
*/
public function init()
{
parent::init();
// Import this here to ensure that libs like SimplePie are using our version of the class and not any server's
// random version.
require_once Craft::getPathOfAlias('app.vendor.simplepie.simplepie.idn.') . DIRECTORY_SEPARATOR . 'idna_convert.class.php';
}
示例2: findMissingTranslation
/**
* Looks for a missing translation string in Yii's core translations.
*
* @param \CMissingTranslationEvent $event
*
* @return null
*/
public static function findMissingTranslation(\CMissingTranslationEvent $event)
{
// Look for translation file from most to least specific. So nl_nl.php gets checked before nl.php, for example.
$translationFiles = array();
$parts = explode('_', $event->language);
$totalParts = count($parts);
for ($i = 1; $i <= $totalParts; $i++) {
$translationFiles[] = implode('_', array_slice($parts, 0, $i));
}
$translationFiles = array_reverse($translationFiles);
// First see if we have any cached info.
foreach ($translationFiles as $translationFile) {
// We've loaded the translation file already, just check for the translation.
if (isset(static::$_translations[$translationFile])) {
if (isset(static::$_translations[$translationFile][$event->message])) {
$event->message = static::$_translations[$translationFile][$event->message];
}
// No translation... just give up.
return;
}
}
// No luck in cache, check the file system.
$frameworkMessagePath = IOHelper::normalizePathSeparators(Craft::getPathOfAlias('app.framework.messages'));
foreach ($translationFiles as $translationFile) {
$path = $frameworkMessagePath . $translationFile . '/yii.php';
if (IOHelper::fileExists($path)) {
// Load it up.
static::$_translations[$translationFile] = (include $path);
if (isset(static::$_translations[$translationFile][$event->message])) {
$event->message = static::$_translations[$translationFile][$event->message];
return;
}
}
}
}
示例3: __construct
public function __construct()
{
require_once Craft::getPathOfAlias('system.vendors.htmlpurifier') . '/HTMLPurifier.standalone.php';
$whitelist = EmbeddedAssetsPlugin::getWhitelist();
foreach ($whitelist as $i => $url) {
$whitelist[$i] = preg_quote($url);
}
$regexp = '%^(https?:)?//([a-z0-9\\-]+\\.)?(' . implode('|', $whitelist) . ')([:/].*)?$%';
$config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.SafeIframe', true);
$config->set('URI.SafeIframeRegexp', $regexp);
$config->set('Cache.SerializerPath', \Yii::app()->getRuntimePath());
$this->_purifier = new \HTMLPurifier($config);
}
示例4: setContentTypeByExtension
/**
* Sets the Content-Type header based on a file extension.
*
* @param string $extension
*
* @return bool Whether setting the header was successful.
*/
public static function setContentTypeByExtension($extension)
{
$extension = strtolower($extension);
$mimeTypes = (require Craft::getPathOfAlias('app.framework.utils.mimeTypes') . '.php');
if (!isset($mimeTypes[$extension])) {
Craft::log('Tried to set the header mime type for the extension ' . $extension . ', but could not find in the mimeTypes list.', LogLevel::Warning);
return false;
}
$mimeType = $mimeTypes[$extension];
if (static::setHeader(array('Content-Type' => $mimeType . '; charset=utf-8'))) {
// Save the MIME type for getMimeType()
static::$_mimeType = $mimeType;
return true;
} else {
return false;
}
}
示例5: convertToUTF8
/**
* Attempts to convert a string to UTF-8 and clean any non-valid UTF-8 characters.
*
* @param $string
*
* @return bool|string
*/
public static function convertToUTF8($string)
{
// Don't wrap in a class_exists in case the server already has it's own version of HTMLPurifier and they have
// open_basedir restrictions
require_once Craft::getPathOfAlias('system.vendors.htmlpurifier') . '/HTMLPurifier.standalone.php';
// If it's already a UTF8 string, just clean and return it
if (static::isUTF8($string)) {
return \HTMLPurifier_Encoder::cleanUTF8($string);
}
// Otherwise set HTMLPurifier to the actual string encoding
$config = \HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', static::getEncoding($string));
// Clean it
$string = \HTMLPurifier_Encoder::cleanUTF8($string);
// Convert it to UTF8 if possible
if (static::checkForIconv()) {
$string = \HTMLPurifier_Encoder::convertToUTF8($string, $config, null);
} else {
$encoding = static::getEncoding($string);
$string = mb_convert_encoding($string, 'utf-8', $encoding);
}
return $string;
}
示例6: getTemplate
/**
* @return string
*/
public function getTemplate()
{
return file_get_contents(Craft::getPathOfAlias('app.etc.updates.migrationtemplate') . '.php');
}