本文整理汇总了PHP中CM_Util::getModulePath方法的典型用法代码示例。如果您正苦于以下问题:PHP CM_Util::getModulePath方法的具体用法?PHP CM_Util::getModulePath怎么用?PHP CM_Util::getModulePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CM_Util
的用法示例。
在下文中一共展示了CM_Util::getModulePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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.');
}
示例2: _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);
}
示例3: testGetClasses
public function testGetClasses()
{
$classPaths = array('CM_Class_Abstract' => 'CM/Class/Abstract.php', 'CM_Paging_Abstract' => 'CM/Paging/Abstract.php', 'CM_Paging_Action_Abstract' => 'CM/Paging/Action/Abstract.php', 'CM_Paging_Action_User' => 'CM/Paging/Action/User.php');
foreach ($classPaths as $className => &$path) {
$path = CM_Util::getModulePath(CM_Util::getNamespace($className)) . 'library/' . $path;
}
$paths = array_reverse($classPaths);
$this->assertSame(array_flip($classPaths), CM_Util::getClasses($paths));
}
示例4: __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';
}
示例5: _getColorStyles
/**
* @return array
*/
private function _getColorStyles()
{
$site = $this->getParams()->getSite('site');
$style = '';
foreach (array_reverse($site->getModules()) as $moduleName) {
$file = new CM_File(CM_Util::getModulePath($moduleName) . 'layout/default/variables.less');
if ($file->exists()) {
$style .= $file->read() . PHP_EOL;
}
}
preg_match_all('#@(color\\w+)#', $style, $matches);
$colors = array_unique($matches[1]);
foreach ($colors as $variableName) {
$style .= '.' . $variableName . ' { background-color: @' . $variableName . '; }' . PHP_EOL;
}
$lessCompiler = new lessc();
$style = $lessCompiler->compile($style);
preg_match_all('#.(color\\w+)\\s+\\{([^}]+)\\}#', $style, $matches);
return array_combine($matches[1], $matches[2]);
}
示例6: setUp
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/function.checkbox.php';
class smarty_function_checkboxTest extends CMTest_TestCase
{
/** @var Smarty_Internal_Template */
private $_template;
public function setUp()
{
$smarty = new Smarty();
$render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $render);
}
public function testDefault()
{
$this->_assertSame('<input type="checkbox" id="foo"><label for="foo"><span class="label">Hello</span></label>', array('id' => 'foo', 'label' => 'Hello'));
}
/**
* @expectedException ErrorException
*/
public function testNoLabel()
{
smarty_function_checkbox(['id' => 'foo'], $this->_template);
}
public function testNoId()
{
$html = smarty_function_checkbox(['label' => 'Hello'], $this->_template);
$this->assertRegExp('#<input type="checkbox" id=".+">#', $html);
}
public function testChecked()
示例7: _getUpdateScriptPath
/**
* @param int $version
* @param string|null $moduleName
* @return string
* @throws CM_Exception_Invalid
*/
public function _getUpdateScriptPath($version, $moduleName = null)
{
$path = DIR_ROOT;
if ($moduleName) {
$path = CM_Util::getModulePath($moduleName);
}
$file = new CM_File($path . 'resources/db/update/' . $version . '.php');
if (!$file->exists()) {
throw new CM_Exception_Invalid('Update script `' . $version . '` does not exist for `' . $moduleName . '` namespace.');
}
return $file->getPath();
}
示例8: setUp
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/function.button_link.php';
class smarty_function_button_linkTest extends CMTest_TestCase
{
/** @var CM_Frontend_Render */
private $_render;
/** @var Smarty_Internal_Template */
private $_template;
public function setUp()
{
$smarty = new Smarty();
$this->_render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $this->_render);
}
public function testRender()
{
$params = array('action' => 'Create', 'label' => 'Some text <br /> with html tags', 'theme' => 'highlight', 'class' => 'button-large');
$this->_assertContains('<span class="label">Some text <br /> with html tags</span>', array_merge($params, array('isHtmlLabel' => true)));
$this->_assertContains('<span class="label">Some text <br /> with html tags</span>', array_merge($params, array('isHtmlLabel' => false)));
}
public function testRenderHref()
{
$this->assertRegExp('#<a.*href="http://example.com".*>.*Click me.*</a>#', smarty_function_button_link(['label' => 'Click me', 'href' => 'http://example.com'], $this->_template));
}
public function testRenderPage()
{
$urlPage = $this->_render->getUrlPage('CM_Page_Example', ['foo' => '12']);
$this->assertRegExp('#<a.*href="' . preg_quote($urlPage) . '".*>.*Click me.*</a>#', smarty_function_button_link(['label' => 'Click me', 'page' => 'CM_Page_Example', 'foo' => '12'], $this->_template));
}
示例9: setUp
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/function.lessVariable.php';
class smarty_function_lessVariableTest extends CMTest_TestCase
{
/** @var Smarty_Internal_Template */
private $_template;
public function setUp()
{
$smarty = new Smarty();
$render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $render);
}
public function testColor()
{
$this->assertSame('#2d78e2', smarty_function_lessVariable(['name' => 'colorBrand'], $this->_template));
}
public function testSize()
{
$this->assertSame('14px', smarty_function_lessVariable(['name' => 'fontSize'], $this->_template));
}
/**
* @expectedException Exception
* @expectedExceptionMessage is undefined
*/
public function testInvalidName()
{
smarty_function_lessVariable(['name' => 'helloworld'], $this->_template);
}
}
示例10: testTranslatePhrase
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/prefilter.translate.php';
class smarty_function_translateVariableTest extends CMTest_TestCase
{
public function testTranslatePhrase()
{
/** @var CM_Frontend_Render|\Mocka\AbstractClassTrait $render */
$render = $this->mockClass('CM_Frontend_Render')->newInstance();
$getTranslationMethod = $render->mockMethod('getTranslation')->set(function ($key, $params) {
$this->assertSame('Bar value is {$bar}', $key);
$this->assertSame(['bar' => 3], $params);
});
/** @var CM_Frontend_Render $render */
$object = new CM_I18n_Phrase('Bar value is {$bar}', ['bar' => 3]);
$render->parseTemplateContent('{translateVariable key=$foo}', ['foo' => $object]);
$this->assertSame(1, $getTranslationMethod->getCallCount());
$exception = $this->catchException(function () use($render, $object) {
$render->parseTemplateContent('{translateVariable key=$foo more=one}', ['foo' => $object]);
});
$this->assertInstanceOf('InvalidArgumentException', $exception);
$this->assertSame('Passed params will be ignored as you provided CM_I18n_Phrase object', $exception->getMessage());
}
}
示例11: smarty_function_numberDecimal
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/function.date_period.php';
function smarty_function_numberDecimal(array $params, Smarty_Internal_Template $template)
{
$value = $params['value'];
if (!is_numeric($value)) {
throw new CM_Exception_Invalid('Invalid non-numeric value');
}
/** @var CM_Frontend_Render $render */
$render = $template->getTemplateVars('render');
$formatter = new NumberFormatter($render->getLocale(), NumberFormatter::DECIMAL);
return $formatter->format($value);
}
示例12: setUp
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/function.usertext.php';
class smarty_function_usertextTest extends CMTest_TestCase
{
/** @var Smarty_Internal_Template */
private $_template;
public function setUp()
{
$smarty = new Smarty();
$render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $render);
}
public function tearDown()
{
CMTest_TH::clearEnv();
}
public function testModeEscape()
{
$this->_assertSame('foo<', array('text' => 'foo<', 'mode' => 'escape'));
}
public function testModeOneline()
{
$this->_assertSame('<span class="usertext oneline">foo</span>', array('text' => 'foo', 'mode' => 'oneline'));
}
public function testModeSimple()
{
$this->_assertSame("<span class=\"usertext simple\">foo<br />\nbar</span>", array('text' => "foo \nbar \n", 'mode' => 'simple'));
}
public function testModeMarkdown()
示例13: getClassChildren
/**
* @param string $className
* @param boolean|null $includeAbstracts
* @return string[]
*/
public static function getClassChildren($className, $includeAbstracts = null)
{
$key = CM_CacheConst::ClassChildren . '_className:' . $className . '_abstracts:' . (int) $includeAbstracts;
$cache = CM_Cache_Local::getInstance();
if (false === ($classNames = $cache->get($key))) {
$pathsFiltered = array();
$paths = array();
foreach (CM_Bootloader::getInstance()->getModules() as $modulePath) {
$namespacePaths = CM_Util::rglob('*.php', CM_Util::getModulePath($modulePath) . 'library/');
$paths = array_merge($paths, $namespacePaths);
}
$regexp = '#\\bclass\\s+(?<name>[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)\\s+#';
foreach ($paths as $path) {
$file = new CM_File($path);
$fileContents = $file->read();
if (preg_match($regexp, $fileContents, $matches)) {
if (class_exists($matches['name'], true)) {
$reflectionClass = new ReflectionClass($matches['name']);
if (($reflectionClass->isSubclassOf($className) || interface_exists($className) && $reflectionClass->implementsInterface($className)) && (!$reflectionClass->isAbstract() || $includeAbstracts)) {
$pathsFiltered[] = $path;
}
}
}
}
$classNames = self::getClasses($pathsFiltered);
$cache->set($key, $classNames);
}
return $classNames;
}
示例14: setUp
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/function.gravatar.php';
class smarty_function_gravatarTest extends CMTest_TestCase
{
/**
* @var Smarty_Internal_Template
*/
private $_template;
public function setUp()
{
$smarty = new Smarty();
$render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $render);
}
public function testRender()
{
$this->_assertSame('<img src="https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0" />', array('email' => 'test@example.com'));
$this->_assertSame('<img src="https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=140&d=http%3A%2F%2Fexample.com%2Fdefault.jpg" />', array('email' => 'test@example.com', 'size' => 140, 'default' => 'http://example.com/default.jpg'));
$this->_assertSame('<img src="https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=140&d=http%3A%2F%2Fexample.com%2Fdefault.jpg" class="TestClass" title="TestTitle" alt="TestTitle" width="20" height="20" />', array('email' => 'test@example.com', 'size' => 140, 'default' => 'http://example.com/default.jpg', 'class' => 'TestClass', 'title' => 'TestTitle', 'width' => 20, 'height' => 20));
}
/**
* @param string $expected
* @param array $params
*/
private function _assertSame($expected, array $params)
{
$this->assertSame($expected, smarty_function_gravatar($params, $this->_template));
}
}
示例15: setUp
<?php
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/block.contentPlaceholder.php';
class smarty_block_contentPlaceholderTest extends CMTest_TestCase
{
/**
* @var Smarty_Internal_Template
*/
private $_template;
public function setUp()
{
$smarty = new Smarty();
$render = new CM_Frontend_Render();
$this->_template = $smarty->createTemplate('string:');
$this->_template->assignGlobal('render', $render);
}
public function testRenderRatio()
{
$params = ['height' => 600, 'width' => 900];
$size = $this->_getImgSize($params);
$this->assertEquals(900, $size['width']);
$this->assertEquals(600, $size['height']);
}
/**
* @param array $params
* @return String
*/
private function _getImgSize(array $params)
{
$output = smarty_block_contentPlaceholder($params, '', $this->_template, false);
$matches = array();