本文整理汇总了PHP中kartik\base\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:orlov-vo,项目名称:yii2-markdown,代码行数:43,代码来源:Markdown.php
示例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));
}
开发者ID:orlov-vo,项目名称:yii2-markdown,代码行数:14,代码来源:ParseController.php
示例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);
}
}
开发者ID:zhaoyan158567,项目名称:yii2-grid,代码行数:13,代码来源:EditableColumn.php
示例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}');");
}
}
开发者ID:luobenyu,项目名称:blog-1,代码行数:15,代码来源:EditableColumn.php
示例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();
}
开发者ID:rocketyang,项目名称:yii2-dynagrid,代码行数:17,代码来源:DynaGridStore.php
示例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);
}
}
开发者ID:eugene-kei,项目名称:yii2-micro-school-crm,代码行数:48,代码来源:DepDrop.php
示例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();
}
开发者ID:yudistirasukma32,项目名称:jobs_hunter,代码行数:24,代码来源:DepDrop.php
示例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;
}
开发者ID:jia253,项目名称:centosYii2,代码行数:33,代码来源:Markdown.php
示例9: fetchModule
/**
* Gets the module
*
* @param string $module the module name
*
* @return Module
*/
public static function fetchModule($module = self::MODULE)
{
return Config::getModule($module);
}
开发者ID:Romariosss,项目名称:yii2-dynagrid,代码行数:11,代码来源:Module.php
示例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.");
}
}
开发者ID:esoftkz,项目名称:yii2-field-range,代码行数:22,代码来源:FieldRange.php
示例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);
}
}
开发者ID:jplagahit,项目名称:brdsdev,代码行数:18,代码来源:DateControl.php
示例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));
}
开发者ID:hsleonis,项目名称:basetech,代码行数:10,代码来源:EditableColumn.php
示例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);
}
开发者ID:rumatakira,项目名称:yii2-detail-view,代码行数:63,代码来源:DetailView.php
示例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();
}
开发者ID:hscstudio,项目名称:psiaga,代码行数:22,代码来源:GridView.php
示例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]];
}
开发者ID:rocketyang,项目名称:yii2-dynagrid,代码行数:8,代码来源:DynaGridConfig.php
示例16: 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 '';
}
$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', '');
if ($inputWidth != '') {
$template = ArrayHelper::getValue($fieldConfig, 'template', "{input}\n{error}\n{hint}");
$fieldConfig['template'] = "<div style='width:{$inputWidth};'>{$template}</div>";
}
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($this->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($this->model, $attr, $fieldConfig)->widget($class, $widgetOptions);
}
if (in_array($input, self::$_dropDownInputs)) {
$items = ArrayHelper::getValue($config, 'items', []);
return $this->_form->field($this->model, $attr, $fieldConfig)->{$input}($items, $options);
}
if ($input == self::INPUT_HTML5_INPUT) {
$inputType = ArrayHelper::getValue($config, 'inputType', self::INPUT_TEXT);
return $this->_form->field($this->model, $attr, $fieldConfig)->{$input}($inputType, $options);
}
return $this->_form->field($this->model, $attr, $fieldConfig)->{$input}($options);
}
开发者ID:gpis88ce,项目名称:Gpis88ce,代码行数:52,代码来源:DetailView.php
示例17: registerAssetBundle
/**
* Registers the asset bundle and locale
*/
protected function registerAssetBundle() {
$view = $this->getView();
if (!empty($this->language) && substr($this->language, 0, 2) != 'en') {
$path = __DIR__ . '/lib';
$file = "select2_locale_{$this->language}.js";
if (!Config::fileExists("{$path}/{$file}")) {
$file = "select2_locale_{$this->_lang}.js";
}
if (Config::fileExists("{$path}/{$file}")) {
Select2Asset::register($view)->js[] = $file;
return;
}
}
Select2Asset::register($view);
}
开发者ID:jplagahit,项目名称:brdsdev,代码行数:18,代码来源:Select2.php
示例18: checkValidFilters
/**
* Checks if the filter input types are valid
*
* @return void
*/
protected function checkValidFilters()
{
if (isset($this->filterType)) {
\kartik\base\Config::validateInputWidget($this->filterType, 'for filtering the grid as per your setup');
}
}
开发者ID:hsleonis,项目名称:basetech,代码行数:11,代码来源:ColumnTrait.php
示例19: getLocaleFile
/**
* Fetches the locale settings file.
*
* @param string $lang the locale/language ISO code.
*
* @return string the locale file name.
*/
protected static function getLocaleFile($lang)
{
$s = DIRECTORY_SEPARATOR;
$file = __DIR__ . "{$s}locales{$s}{$lang}{$s}dateSettings.php";
if (!file_exists($file)) {
$langShort = Config::getLang($lang);
$file = __DIR__ . "{$s}locales{$s}{$langShort}{$s}dateSettings.php";
}
return $file;
}
开发者ID:kartik-v,项目名称:yii2-datecontrol,代码行数:17,代码来源:DateControl.php
示例20: renderInput
/**
* Renders all other HTML inputs (except HTML5)
*
* @return string
*/
protected function renderInput()
{
$list = Config::isDropdownInput($this->inputType);
$input = $this->inputType;
if ($this->hasModel()) {
if (isset($this->_form)) {
return $list ? $this->_form->field($this->model, $this->attribute, $this->inputFieldConfig)->{$input}($this->data, $this->_inputOptions)->label(false) : $this->_form->field($this->model, $this->attribute, $this->inputFieldConfig)->{$input}($this->_inputOptions)->label(false);
}
$input = 'active' . ucfirst($this->inputType);
}
$checked = false;
if ($input == 'radio' || $input == 'checkbox') {
$this->options['value'] = $this->value;
$checked = ArrayHelper::remove($this->_inputOptions, 'checked', false);
}
if ($list) {
$field = Html::$input($this->name, $this->value, $this->data, $this->_inputOptions);
} else {
$field = $input == 'checkbox' || $input == 'radio' ? Html::$input($this->name, $checked, $this->_inputOptions) : Html::$input($this->name, $this->value, $this->_inputOptions);
}
return Html::tag('div', $field, $this->inputContainerOptions);
}
开发者ID:cindyming,项目名称:yii-advance,代码行数:27,代码来源:Editable.php
注:本文中的kartik\base\Config类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论