本文整理汇总了PHP中kartik\base\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
/**
* Converts markdown into HTML
*
* @param string $content
* @param array $config . Options to configure MarkdownExtra and smarty
* - markdown: array for MarkdownExtra configuration parameters
* - smarty: array for SmartyPantsTypographer configuration parameters
* - custom: array for Custom configuration parameters
* @param int $smartyMode the SmartyPantsTypographer processing mode
*
* @return string
* @throws InvalidConfigException if module not set
*/
public static function convert($content, $config = [], $smartyMode = self::SMARTYPANTS_ATTR_LONG_EM_DASH_SHORT_EN)
{
$module = Config::initModule(Module::classname());
$output = $content;
if (strlen($output) > 0) {
$mdConfig = empty($config['markdown']) ? [] : $config['markdown'];
$output = static::process($content, $mdConfig);
if ($module->smartyPants) {
$smConfig = empty($config['smarty']) ? [] : $config['smarty'];
$smarty = new SmartyPants($smartyMode);
foreach ($smConfig as $name => $value) {
$smarty->{$name} = $value;
}
$output = $smarty->transform($output);
$cuConfig = empty($config['custom']) ? $module->customConversion : $config['custom'];
$output = static::customProcess($output, $cuConfig);
}
if (is_bool($module->smarty) && $module->smarty || (is_string($module->smarty) || is_callable($module->smarty)) && call_user_func($module->smarty, $module)) {
$smarty = new \Smarty();
if ($module->smartyYiiApp) {
$smarty->assign('app', Yii::$app);
}
if ($module->smartyYiiParams) {
$smarty->config_vars = Yii::$app->params;
}
$output = $smarty->fetch('string:' . $output, null, null, $module->smartyParams);
}
}
return $output;
}
示例2: actionPreview
/**
* Convert markdown text to HTML for preview
*
* @returns JSON encoded HTML output
*/
public function actionPreview()
{
$output = '';
$module = Config::getModule(Module::MODULE);
if (isset($_POST['source'])) {
$output = strlen($_POST['source']) > 0 ? Markdown::convert($_POST['source'], ['custom' => $module->customConversion]) : $_POST['nullMsg'];
}
echo Json::encode(HtmlPurifier::process($output));
}
示例3: init
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
parent::init();
Config::checkDependency('editable\\Editable', 'yii2-editable', 'for GridView EditableColumn');
$this->_css = 'kv-edcol-' . hash('crc32', uniqid(rand(1, 100), true));
if ($this->refreshGrid) {
EditableColumnAsset::register($this->_view);
}
}
示例4: init
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
parent::init();
\kartik\base\Config::checkDependency('editable\\Editable', 'yii2-editable', 'for GridView EditableColumn');
$this->_css = 'kv-edcol-' . hash('crc32', uniqid(rand(1, 100), true));
if ($this->refreshGrid) {
EditableColumnAsset::register($this->_view);
$id = $this->grid->options['id'];
$this->_view->registerJs("kvRefreshEC('{$id}','{$this->_css}');");
}
}
示例5: init
/**
* Initializes the object
*
* @throws InvalidConfigException
*/
public function init()
{
$this->_module = Config::initModule(Module::classname());
$this->_isMaster = $this->category == self::STORE_GRID ? true : false;
if ($this->_module == null || !$this->_module instanceof Module) {
throw new InvalidConfigException('The "dynagrid" module MUST be setup in your Yii configuration file and assigned to "\\kartik\\dynagrid\\Module" class.');
}
if (!isset($this->id)) {
throw new InvalidConfigException('The dynagrid "id" property must be entered.');
}
$this->setKey();
}
示例6: init
/**
* @inherit doc
* @throw InvalidConfigException
*/
public function init()
{
if (empty($this->pluginOptions['url'])) {
throw new InvalidConfigException("The 'pluginOptions[\"url\"]' property has not been set.");
}
if (empty($this->pluginOptions['depends']) || !is_array($this->pluginOptions['depends'])) {
throw new InvalidConfigException("The 'pluginOptions[\"depends\"]' property must be set and must be an array of dependent dropdown element ID.");
}
if (empty($this->options['class'])) {
$this->options['class'] = 'form-control';
}
if ($this->type === self::TYPE_SELECT2) {
Config::checkDependency('select2\\Select2', 'yii2-widget-select2', 'for dependent dropdown for TYPE_SELECT2');
}
parent::init();
if ($this->type !== self::TYPE_SELECT2 && !empty($this->options['placeholder'])) {
$this->data = ['' => $this->options['placeholder']] + $this->data;
}
if ($this->type === self::TYPE_SELECT2 && (!empty($this->options['placeholder']) || !empty($this->select2Options['options']['placeholder']))) {
$this->pluginOptions['placeholder'] = '';
} elseif ($this->type === self::TYPE_SELECT2 && !empty($this->pluginOptions['placeholder']) && $this->pluginOptions['placeholder'] !== false) {
$this->options['placeholder'] = $this->pluginOptions['placeholder'];
$this->pluginOptions['placeholder'] = '';
}
$this->_view = $this->getView();
$this->registerAssets();
if ($this->type === self::TYPE_SELECT2) {
if (empty($this->data)) {
$this->data = ['' => ''];
}
if ($this->hasModel()) {
$settings = ArrayHelper::merge($this->select2Options, ['model' => $this->model, 'attribute' => $this->attribute, 'data' => $this->data, 'options' => $this->options]);
} else {
$settings = ArrayHelper::merge($this->select2Options, ['name' => $this->name, 'value' => $this->value, 'data' => $this->data, 'options' => $this->options]);
}
echo Select2::widget($settings);
$id = 'jQuery("#' . $this->options['id'] . '")';
$text = ArrayHelper::getValue($this->pluginOptions, 'loadingText', 'Loading ...');
$this->_view->registerJs("{$id}.on('depdrop.beforeChange',function(e,i,v){{$id}.select2('data',{text: '{$text}'});});");
$this->_view->registerJs("{$id}.on('depdrop.change',function(e,i,v,c){{$id}.select2('val',{$id}.val());});");
} else {
echo $this->getInput(!empty($this->typename) ? $this->typename : 'dropdownList', true);
}
}
示例7: run
/**
* Runs the widget
*
* @throws InvalidConfigException
*/
public function run()
{
if (empty($this->pluginOptions['url'])) {
throw new InvalidConfigException("The 'pluginOptions[\"url\"]' property has not been set.");
}
if (empty($this->pluginOptions['depends']) || !is_array($this->pluginOptions['depends'])) {
throw new InvalidConfigException("The 'pluginOptions[\"depends\"]' property must be set and must be an array of dependent dropdown element identifiers.");
}
if (empty($this->options['class'])) {
$this->options['class'] = 'form-control';
}
if ($this->type === self::TYPE_SELECT2) {
Config::checkDependency('select2\\Select2', 'yii2-widget-select2', 'for dependent dropdown for Select2');
}
if ($this->type !== self::TYPE_SELECT2 && !empty($this->options['placeholder'])) {
$this->data = ['' => $this->options['placeholder']] + $this->data;
}
$this->registerAssets();
}
示例8: convert
/**
* Converts markdown into HTML
*
* @param string $content
* @param array $config . Options to configure MarkdownExtra and smarty
* - markdown: array for MarkdownExtra configuration parameters
* - smarty: array for SmartyPantsTypographer configuration parameters
* - custom: array for Custom configuration parameters
* @param int $smartyMode the SmartyPantsTypographer processing mode
*
* @return string
* @throws InvalidConfigException if module not set
*/
public static function convert($content, $config = [], $smartyMode = self::SMARTYPANTS_ATTR_LONG_EM_DASH_SHORT_EN)
{
$module = Config::initModule(Module::classname());
$output = $content;
if (strlen($output) > 0) {
$mdConfig = empty($config['markdown']) ? [] : $config['markdown'];
$output = static::process($content, $mdConfig);
if ($module->smartyPants) {
$smConfig = empty($config['smarty']) ? [] : $config['smarty'];
$smarty = new SmartyPantsTypographer($smartyMode);
foreach ($smConfig as $name => $value) {
$smarty->{$name} = $value;
}
$output = $smarty->transform($output);
$cuConfig = empty($config['custom']) ? $module->customConversion : $config['custom'];
$output = static::customProcess($output, $cuConfig);
}
}
return $output;
}
示例9: fetchModule
/**
* Gets the module
*
* @param string $module the module name
*
* @return Module
*/
public static function fetchModule($module = self::MODULE)
{
return Config::getModule($module);
}
示例10: validateSettings
public function validateSettings()
{
if (!$this->hasModel() && ($this->name1 === null || $this->name2 === null)) {
throw new InvalidConfigException("Either 'name1','name2' or 'attribute1', 'attribute2' with 'model' properties must be specified.");
}
if (!$this->_isInput && $this->type !== self::INPUT_WIDGET && !in_array($this->type, self::$_inputWidgets)) {
throw new InvalidConfigException("Invalid value for 'type'. Must be one of the FieldRange::INPUT constants.");
}
if (isset($this->form) && $this->useAddons && !$this->form instanceof ActiveForm) {
Config::checkDependency('form\\ActiveForm', ['yii2-widget-activeform', 'yii2-widgets'], "when 'useAddons' is set to true.");
throw new InvalidConfigException("The 'form' property must be an instance of '\\kartik\\form\\ActiveForm' or '\\kartik\\widgets\\ActiveForm' when 'useAddons' is set to true.");
}
if (isset($this->form) && !$this->useAddons && !$this->form instanceof \yii\widgets\ActiveForm) {
throw new InvalidConfigException("The 'form' property must be an instance of '\\yii\\widgets\\ActiveForm'.");
}
if (isset($this->form) && !$this->hasModel()) {
throw new InvalidConfigException("The 'model' and 'attribute1', 'attribute2' property must be set when 'form' is set.");
}
if ($this->type === self::INPUT_WIDGET && empty($this->widgetClass)) {
throw new InvalidConfigException("The 'widgetClass' property must be set for widget input type.");
}
}
示例11: setLocale
/**
* Sets the locale using the locales configuration settings
*/
protected function setLocale()
{
if (!$this->_doTranslate || !empty($this->pluginOptions['dateSettings'])) {
return;
}
$s = DIRECTORY_SEPARATOR;
$file = __DIR__ . "{$s}locales{$s}{$this->language}{$s}dateSettings.php";
if (!file_exists($file)) {
$langShort = Config::getLang($this->language);
$file = __DIR__ . "{$s}locales{$s}$langShort{$s}dateSettings.php";
}
if (file_exists($file)) {
$this->pluginOptions['dateSettings'] = require_once($file);
}
}
示例12: init
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
parent::init();
\kartik\base\Config::checkDependency('editable\\Editable', 'yii2-editable', 'for GridView EditableColumn');
$this->_css = 'kv-edcol-' . hash('crc32', uniqid(rand(1, 100), true));
}
示例13: renderFormAttribute
/**
* Renders each form attribute
*
* @param array $config the attribute config
*
* @return mixed
* @throws \yii\base\InvalidConfigException
*/
protected function renderFormAttribute($config)
{
if (empty($config['attribute'])) {
return '';
}
$model = ArrayHelper::getValue($config, 'editModel', $this->model);
if (!$model instanceof Model) {
$model = $this->model;
}
$attr = ArrayHelper::getValue($config, 'updateAttr', $config['attribute']);
$input = ArrayHelper::getValue($config, 'type', self::INPUT_TEXT);
$fieldConfig = ArrayHelper::getValue($config, 'fieldConfig', []);
$inputWidth = ArrayHelper::getValue($config, 'inputWidth', '');
$container = ArrayHelper::getValue($config, 'inputContainer', []);
if ($inputWidth != '') {
Html::addCssStyle($container, "width: {$inputWidth}");
// deprecated since v1.7.4
}
$template = ArrayHelper::getValue($fieldConfig, 'template', "{input}\n{error}\n{hint}");
$row = Html::tag('div', $template, $container);
if (static::hasGridCol($container)) {
$row = '<div class="row">' . $row . '</div>';
}
$fieldConfig['template'] = $row;
if (substr($input, 0, 8) == "\\kartik\\") {
Config::validateInputWidget($input, 'as an input widget for DetailView edit mode');
} elseif ($input !== self::INPUT_WIDGET && !in_array($input, self::$_inputsList)) {
throw new InvalidConfigException("Invalid input type '{$input}' defined for the attribute '" . $config['attribute'] . "'.");
}
$options = ArrayHelper::getValue($config, 'options', []);
$widgetOptions = ArrayHelper::getValue($config, 'widgetOptions', []);
$class = ArrayHelper::remove($widgetOptions, 'class', '');
if (!empty($config['options'])) {
$widgetOptions['options'] = $config['options'];
}
if (Config::isInputWidget($input)) {
$class = $input;
return $this->_form->field($model, $attr, $fieldConfig)->widget($class, $widgetOptions);
}
if ($input === self::INPUT_WIDGET) {
if ($class == '') {
throw new InvalidConfigException("Widget class not defined in 'widgetOptions' for {$input}'.");
}
return $this->_form->field($model, $attr, $fieldConfig)->widget($class, $widgetOptions);
}
if (in_array($input, self::$_dropDownInputs)) {
$items = ArrayHelper::getValue($config, 'items', []);
return $this->_form->field($model, $attr, $fieldConfig)->{$input}($items, $options);
}
if ($input == self::INPUT_HTML5_INPUT) {
$inputType = ArrayHelper::getValue($config, 'inputType', self::INPUT_TEXT);
return $this->_form->field($model, $attr, $fieldConfig)->{$input}($inputType, $options);
}
return $this->_form->field($model, $attr, $fieldConfig)->{$input}($options);
}
示例14: run
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function run()
{
$this->initToggleData();
$this->initExport();
if ($this->export !== false && isset($this->exportConfig[self::PDF])) {
\kartik\base\Config::checkDependency('mpdf\\Pdf', 'yii2-mpdf', "for PDF export functionality. To include PDF export, follow the install steps below. If you do not " . "need PDF export functionality, do not include 'PDF' as a format in the 'export' property. You can " . "otherwise set 'export' to 'false' to disable all export functionality");
}
$this->initHeader();
$this->initBootstrapStyle();
$this->containerOptions['id'] = $this->options['id'] . '-container';
Html::addCssClass($this->containerOptions, 'kv-grid-container');
$this->registerAssets();
$this->renderPanel();
$this->initLayout();
$this->beginPjax();
parent::run();
$this->endPjax();
}
示例15: rules
/**
* @inheritdoc
*/
public function rules()
{
$this->_module = Config::initModule(Module::classname());
return [[['id', 'hiddenColumns', 'visibleColumns', 'pageSize', 'filterId', 'sortId', 'theme', 'hiddenKeys', 'visibleKeys'], 'safe'], [['pageSize', 'theme'], 'required'], ['pageSize', 'integer', 'min' => $this->_module->minPageSize, 'max' => $this->_module->maxPageSize], ['pageSize', 'default', 'value' => $this->_module->defaultPageSize], ['theme', 'default', 'value' => $this->_module->defaultTheme]];
}