本文整理汇总了PHP中CM_Util类的典型用法代码示例。如果您正苦于以下问题:PHP CM_Util类的具体用法?PHP CM_Util怎么用?PHP CM_Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CM_Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param CM_Frontend_Render $render
* @throws CM_Exception
*/
public function __construct(CM_Frontend_Render $render)
{
parent::__construct($render);
$this->addVariables();
$file = new CM_File(DIR_PUBLIC . 'static/css/library/icon.less');
if ($file->exists()) {
$this->add($file->read());
}
foreach (array_reverse($render->getSite()->getModules()) as $moduleName) {
foreach (array_reverse($render->getSite()->getThemes()) as $theme) {
foreach (CM_Util::rglob('*.less', $render->getThemeDir(true, $theme, $moduleName) . 'css/') as $path) {
$file = new CM_File($path);
$this->add($file->read());
}
}
}
$viewClasses = CM_View_Abstract::getClassChildren(true);
foreach ($viewClasses as $viewClassName) {
$validModule = in_array(CM_Util::getNamespace($viewClassName), $render->getSite()->getModules());
$validViewClass = $this->_isValidViewClass($viewClassName);
if ($validModule && $validViewClass) {
$asset = new CM_Asset_Css_View($this->_render, $viewClassName);
$this->add($asset->_getContent());
}
}
}
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:30,代码来源:Library.php
示例2: smarty_function_tag
function smarty_function_tag(array $params, Smarty_Internal_Template $template)
{
if (!isset($params['el'])) {
trigger_error('Param `el` missing.');
}
$name = $params['el'];
unset($params['el']);
$content = '';
if (isset($params['content'])) {
$content = (string) $params['content'];
unset($params['content']);
}
$attributes = $params;
// http://www.w3.org/TR/html-markup/syntax.html#void-element
$namesVoid = array('area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr');
$html = '<' . $name;
foreach ($attributes as $attributeName => $attributeValue) {
if (isset($attributeValue)) {
$html .= ' ' . $attributeName . '="' . CM_Util::htmlspecialchars($attributeValue) . '"';
}
}
if (in_array($name, $namesVoid)) {
$html .= '>';
} else {
$html .= '>' . $content . '</' . $name . '>';
}
return $html;
}
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:28,代码来源:function.tag.php
示例3: renderTag
/**
* @param string $elementName
* @param string|null $content
* @param array|null $attributes
* @param array|null $dataAttributes
* @return string
* @throws CM_Exception_Invalid
*/
public function renderTag($elementName, $content = null, array $attributes = null, array $dataAttributes = null)
{
$elementName = (string) $elementName;
if ('' === $elementName) {
throw new CM_Exception_Invalid('Empty element name');
}
$content = (string) $content;
if (null === $attributes) {
$attributes = [];
}
if (null === $dataAttributes) {
$dataAttributes = [];
}
// http://www.w3.org/TR/html-markup/syntax.html#void-element
$namesVoid = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
$html = '<' . $elementName;
foreach ($dataAttributes as $dataKey => $dataValue) {
$attributes['data-' . $dataKey] = $dataValue;
}
foreach ($attributes as $attributeName => $attributeValue) {
if (isset($attributeValue)) {
$html .= ' ' . CM_Util::htmlspecialchars($attributeName) . '="' . CM_Util::htmlspecialchars($attributeValue) . '"';
}
}
if (in_array($elementName, $namesVoid)) {
$html .= '>';
} else {
$html .= '>' . $content . '</' . $elementName . '>';
}
return $html;
}
开发者ID:cargomedia,项目名称:cm,代码行数:39,代码来源:HtmlTagRenderer.php
示例4: getTypes
/**
* @return CM_Elasticsearch_Type_Abstract[]
*/
public function getTypes()
{
$types = CM_Util::getClassChildren('CM_Elasticsearch_Type_Abstract');
return \Functional\map($types, function ($className) {
return new $className($this->getRandomClient());
});
}
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:10,代码来源:Cluster.php
示例5: autoloadCommands
public function autoloadCommands()
{
$classes = CM_Util::getClassChildren('CM_Cli_Runnable_Abstract', false);
foreach ($classes as $className) {
$this->addRunnable($className);
}
}
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:7,代码来源:CommandManager.php
示例6: __construct
/**
* @param CM_Frontend_Render $render
* @param string $className
* @throws CM_Exception
*/
public function __construct(CM_Frontend_Render $render, $className)
{
parent::__construct($render);
if (!preg_match('#^([^_]+)_([^_]+)_?(.*)$#', $className, $matches)) {
throw new CM_Exception('Cannot detect all className parts from view\'s className', null, ['className' => $className]);
}
list($className, $namespace, $viewType, $viewName) = $matches;
$viewPath = $viewType . '/';
if ($viewName) {
$viewPath .= $viewName . '/';
}
$relativePaths = array();
foreach ($render->getSite()->getThemes() as $theme) {
$basePath = $render->getThemeDir(true, $theme, $namespace) . $viewPath;
foreach (CM_Util::rglob('*.less', $basePath) as $path) {
$relativePaths[] = preg_replace('#^' . $basePath . '#', '', $path);
}
}
foreach (array_unique($relativePaths) as $path) {
$prefix = '.' . $className;
if ($path !== 'default.less' && strpos($path, '/') === false) {
$prefix .= '.' . preg_replace('#.less$#', '', $path);
}
$file = $render->getLayoutFile($viewPath . $path, $namespace);
$this->add($file->read(), $prefix);
}
}
开发者ID:cargomedia,项目名称:cm,代码行数:32,代码来源:View.php
示例7: _createLogger
/**
* @param CM_Log_Handler_HandlerInterface $handler
* @return CM_Log_Logger
*/
protected function _createLogger(CM_Log_Handler_HandlerInterface $handler)
{
$computerInfo = new CM_Log_Context_ComputerInfo(CM_Util::getFqdn(), phpversion());
$globalContext = new CM_Log_Context();
$globalContext->setComputerInfo($computerInfo);
return new CM_Log_Logger($globalContext, $handler);
}
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:Factory.php
示例8: iconRefresh
public function iconRefresh()
{
/** @var CM_File[] $svgFileList */
$svgFileList = array();
foreach (CM_Bootloader::getInstance()->getModules() as $moduleName) {
$iconPath = CM_Util::getModulePath($moduleName) . 'layout/default/resource/img/icon/';
foreach (glob($iconPath . '*.svg') as $svgPath) {
$svgFile = new CM_File($svgPath);
$svgFileList[strtolower($svgFile->getFileName())] = $svgFile;
}
}
if (0 === count($svgFileList)) {
throw new CM_Exception_Invalid('Cannot process `0` icons');
}
$this->_getStreamOutput()->writeln('Processing ' . count($svgFileList) . ' unique icons...');
$dirWork = CM_File::createTmpDir();
$dirBuild = $dirWork->joinPath('/build');
foreach ($svgFileList as $fontFile) {
$fontFile->copyToFile($dirWork->joinPath($fontFile->getFileName()));
}
CM_Util::exec('fontcustom', array('compile', $dirWork->getPathOnLocalFilesystem(), '--no-hash', '--autowidth', '--font-name=icon-webfont', '--output=' . $dirBuild->getPathOnLocalFilesystem()));
$cssFile = $dirBuild->joinPath('/icon-webfont.css');
$less = preg_replace('/url\\("(?:.*?\\/)(.+?)(\\??#.+?)?"\\)/', 'url(urlFont("\\1") + "\\2")', $cssFile->read());
CM_File::create(DIR_PUBLIC . 'static/css/library/icon.less', $less);
foreach (glob($dirBuild->joinPath('/icon-webfont.*')->getPathOnLocalFilesystem()) as $fontPath) {
$fontFile = new CM_File($fontPath);
$fontFile->rename(DIR_PUBLIC . 'static/font/' . $fontFile->getFileName());
}
$dirWork->delete(true);
$this->_getStreamOutput()->writeln('Created web-font and stylesheet.');
}
开发者ID:cargomedia,项目名称:cm,代码行数:31,代码来源:Cli.php
示例9: getUrl
/**
* @param string|null $email
* @param int|null $size
* @param string|null $default
* @return string
*/
public function getUrl($email, $size = null, $default = null)
{
if (null !== $email) {
$email = (string) $email;
}
if (null !== $size) {
$size = (int) $size;
}
if (null !== $default) {
$default = (string) $default;
}
if (null === $email && null !== $default) {
return $default;
}
$url = 'https://secure.gravatar.com/avatar';
if (null !== $email) {
$url .= '/' . md5(strtolower(trim($email)));
}
$params = array();
if (null !== $size) {
$params['s'] = $size;
}
if (null !== $default) {
$params['d'] = $default;
}
return CM_Util::link($url, $params);
}
开发者ID:cargomedia,项目名称:cm,代码行数:33,代码来源:Gravatar.php
示例10: getHtml
public function getHtml($zoneName, $zoneData, array $variables)
{
$zoneId = CM_Util::htmlspecialchars($zoneData['zoneId']);
$variables = $this->_variableKeysToUnderscore($variables);
$variables['key'] = $zoneData['accessKey'];
$html = '<div id="epom-' . $zoneId . '" class="epom-ad" data-zone-name="' . $zoneName . '" data-variables="' . CM_Util::htmlspecialchars(json_encode($variables, JSON_FORCE_OBJECT)) . '"></div>';
return $html;
}
开发者ID:cargomedia,项目名称:cm,代码行数:8,代码来源:Epom.php
示例11: _dbToFileSql
/**
* @param string $namespace
*/
private function _dbToFileSql($namespace)
{
$namespace = (string) $namespace;
$tables = CM_Db_Db::exec("SHOW TABLES LIKE ?", array(strtolower($namespace) . '_%'))->fetchAllColumn();
sort($tables);
$dump = CM_Db_Db::getDump($tables, true);
CM_File::create(CM_Util::getModulePath($namespace) . '/resources/db/structure.sql', $dump);
}
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:Cli.php
示例12: _processItem
protected function _processItem($itemRaw)
{
$index = serialize($itemRaw);
if (null === ($model = $this->_modelList[$index])) {
throw new CM_Exception_Nonexistent('Model itemRaw: `' . CM_Util::var_line($itemRaw) . '` has no data');
}
return $model;
}
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:8,代码来源:ModelAbstract.php
示例13: __construct
/**
* @param int $id
* @throws CM_Exception_Nonexistent
*/
public function __construct($id)
{
$this->_id = (int) $id;
$this->_text = CM_Db_Db::select('cm_captcha', 'number', array('captcha_id' => $this->getId()))->fetchColumn();
if (!$this->_text) {
throw new CM_Exception_Nonexistent('Invalid captcha id `' . $id . '`', CM_Exception::WARN);
}
$this->_fontPath = CM_Util::getModulePath('CM') . 'resources/font/comicsans.ttf';
}
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:13,代码来源:Captcha.php
示例14: _sanitizeRecord
/**
* @param array $formattedRecord
* @return array
*/
protected function _sanitizeRecord(array $formattedRecord)
{
array_walk_recursive($formattedRecord, function (&$value, $key) {
if (is_string($value) && !mb_check_encoding($value, 'UTF-8')) {
$value = CM_Util::sanitizeUtf($value);
}
});
return $formattedRecord;
}
开发者ID:cargomedia,项目名称:cm,代码行数:13,代码来源:Fluentd.php
示例15: __construct
public function __construct(CM_Site_Abstract $site)
{
$content = '';
foreach (array_reverse($site->getModules()) as $moduleName) {
$libraryPath = DIR_ROOT . CM_Bootloader::getInstance()->getModulePath($moduleName) . 'client-vendor/after-body/';
foreach (CM_Util::rglob('*.js', $libraryPath) as $path) {
$content .= (new CM_File($path))->read() . ';' . PHP_EOL;
}
}
$this->_content = $content;
}
开发者ID:NicolasSchmutz,项目名称:cm,代码行数:11,代码来源:VendorAfterBody.php
示例16: getHtml
public function getHtml($zoneName, $zoneData, array $variables)
{
$src = (string) $zoneData['src'];
$width = (string) $zoneData['width'];
$height = (string) $zoneData['height'];
$params = ['src' => $src, 'width' => $width, 'height' => $height, 'class' => 'advertisement-hasContent', 'data-variables' => json_encode($variables, JSON_FORCE_OBJECT), 'frameborder' => 0, 'scrolling' => 'no'];
$params = Functional\map($params, function ($value, $key) {
return $key . '="' . CM_Util::htmlspecialchars($value) . '"';
});
return '<iframe ' . join(' ', $params) . '></iframe>';
}
开发者ID:cargomedia,项目名称:cm,代码行数:11,代码来源:Iframe.php
示例17: _setInitialVersion
private function _setInitialVersion()
{
$app = CM_App::getInstance();
foreach (CM_App::getInstance()->getUpdateScriptPaths() as $namespace => $path) {
$updateFiles = CM_Util::rglob('*.php', $path);
$version = array_reduce($updateFiles, function ($initial, $path) {
$filename = basename($path);
return max($initial, (int) $filename);
}, 0);
$app->setVersion($version, $namespace);
}
}
开发者ID:cargomedia,项目名称:cm,代码行数:12,代码来源:SetupScript.php
示例18: __construct
/**
* @param int $level
* @param string $message
* @param CM_Log_Context $context
* @throws CM_Exception_Invalid
*/
public function __construct($level, $message, CM_Log_Context $context)
{
$level = (int) $level;
$message = (string) $message;
if (!CM_Log_Logger::hasLevel($level)) {
throw new CM_Exception_Invalid('Log level does not exist.', null, ['level' => $level]);
}
$this->_level = $level;
$this->_message = $message;
$this->_context = $context;
$this->_createdAt = CM_Util::createDateTimeWithMillis();
}
开发者ID:cargomedia,项目名称:cm,代码行数:18,代码来源:Record.php
示例19: __construct
/**
* @param string $verbName
* @param CM_Model_User|int $actor
* @param int $typeEmail
*/
public function __construct($verbName, $actor, $typeEmail)
{
parent::__construct($verbName, $actor);
$typeEmail = (int) $typeEmail;
try {
$className = CM_Mail_Mailable::_getClassName($typeEmail);
$this->_nameEmail = ucwords(CM_Util::uncamelize(str_replace('_', '', preg_replace('#\\A[^_]++_[^_]++_#', '', $className)), ' '));
} catch (CM_Class_Exception_TypeNotConfiguredException $exception) {
CM_Service_Manager::getInstance()->getLogger()->warning('Unrecognized mail type when creating mail action', (new CM_Log_Context())->setException($exception));
$this->_nameEmail = (string) $typeEmail;
}
}
开发者ID:cargomedia,项目名称:cm,代码行数:17,代码来源:Email.php
示例20: clear
public function clear()
{
$this->_getStreamOutput()->writeln('Clearing cache…');
$classes = CM_Util::getClassChildren('CM_Cache_Storage_Abstract', false);
foreach ($classes as $className) {
$this->_getStreamOutput()->writeln(' ' . $className);
/** @var CM_Cache_Storage_Abstract $cache */
$cache = new $className();
$cache->flush();
}
$this->_getStreamOutput()->writeln('Cache cleared.');
}
开发者ID:cargomedia,项目名称:cm,代码行数:12,代码来源:Cli.php
注:本文中的CM_Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论