/** * Connector action */ public function actionConnector() { /** @var ElFinderComponent $elFinder */ $elFinder = Yii::$app->get('elFinder'); $roots = array_map(function ($root) { /** @var Root $root */ return $root->getOptions(); }, $elFinder->roots); /** @var FilesystemComponent $filesystem */ $filesystem = Yii::$app->get('filesystem'); foreach ($elFinder->filesystems as $key => $root) { if (is_string($root)) { $key = $root; $root = []; } $fs = $filesystem->get($key); if ($fs instanceof Filesystem) { $defaults = ['driver' => 'Flysystem', 'filesystem' => $fs, 'alias' => Inflector::titleize($key)]; $roots[] = array_merge($defaults, $root); } } $options = array('locale' => '', 'roots' => $roots); $connector = new \elFinderConnector(new \elFinder($options)); $connector->run(); }
public static function getChoices() { $types = \Yii::$app->get('typesRegister')->entityTypes; array_walk($types, function (&$value, $key) { $value = Inflector::titleize($key); }); return array_merge(array(self::STRING_TYPE => Module::t('attribute', 'Text')), $types); }
/** * Useful helper for migrations and other stuff * If description is null than it will be transformed like "editUserEmail" => "Edit user email" * * @param string $name * @param null|string $description * @param null|string $groupCode * @param null|string $ruleName * @param null|string $data * * @return static */ public static function create($name, $description = null, $groupCode = null, $ruleName = null, $data = null) { $item = new static(); $item->type = static::ITEM_TYPE; $item->name = $name; $item->description = ($description === null and static::ITEM_TYPE != static::TYPE_ROUTE) ? Inflector::titleize($name) : $description; $item->rule_name = $ruleName; $item->group_code = $groupCode; $item->data = $data; $item->save(); return $item; }
/** * Инициализация проекта. */ public function actionInit() { $rawProjectName = pathinfo(Yii::getAlias('@app'), PATHINFO_FILENAME); $rawProjectName = Inflector::camelize($rawProjectName); $projectId = Inflector::camel2id($rawProjectName); $projectId = Console::prompt('Project id', ['default' => $projectId]); $projectName = Inflector::titleize($projectId); $projectName = Console::prompt('Project name', ['default' => $projectName]); $vagrantIp = '192.168.33.' . rand(100, 254); $vagrantIp = Console::prompt('Vagrant IP', ['default' => $vagrantIp]); $values = ['PROJECT-ID' => $projectId, 'PROJECT-NAME' => $projectName, 'VAGRANT-IP' => $vagrantIp]; $files = ['@app/build.xml' => ['PROJECT-ID'], '@app/Vagrantfile' => ['VAGRANT-IP', 'PROJECT-ID'], '@app/config/web.php' => ['PROJECT-NAME'], '@app/config/console.php' => ['PROJECT-NAME'], '@app/config/env/vagrant.php' => ['VAGRANT-IP', 'PROJECT-ID']]; $this->replaceInFiles($files, $values); }
public static function defaultColumns() { return ['user_comment' => ['attribute' => 'user_comment', 'filterAttribute' => 'user_comment_like'], 'tech_comment' => ['attribute' => 'tech_comment'], 'payment_system' => ['header' => Yii::t('hipanel:finance', 'Payment system'), 'value' => function ($model) { return Inflector::titleize($model->params['system']); }], 'txn' => ['header' => Yii::t('hipanel:finance', 'TXN'), 'value' => function ($model) { return $model->params['txn']; }], 'label' => ['header' => Yii::t('hipanel', 'Description'), 'value' => function ($model) { return $model->params['label']; }], 'amount' => ['header' => Yii::t('hipanel:finance', 'Amount'), 'format' => 'html', 'value' => function ($model) { $html = Yii::t('hipanel:finance:change', 'Full:') . " " . Yii::$app->formatter->asCurrency($model->params['sum'], $model->params['purse_currency']) . "<br />"; $html .= Yii::t('hipanel:finance:change', 'Fee:') . " " . Yii::$app->formatter->asCurrency($model->params['fee'], $model->params['purse_currency']) . "<br />"; $html .= Yii::t('hipanel:finance:change', 'Sum:') . " " . Yii::$app->formatter->asCurrency($model->params['sum'] - $model->params['fee'], $model->params['purse_currency']); return $html; }], 'time' => ['value' => function ($model) { return Yii::$app->formatter->asDatetime($model->time); }], 'actions' => ['class' => ActionColumn::class, 'template' => '{view}', 'header' => Yii::t('hipanel', 'Actions')]]; }
public function init() { $possible = []; $field = $this->model->{$this->field}; foreach ($this->defaultValues as $key => $values) { $possible[$key] = ArrayHelper::merge($values, $this->values[$key] ?: []); } $this->values = ArrayHelper::merge($possible, $this->values); foreach ($this->values as $classes => $values) { if (in_array($field, $values, true)) { $class = $classes; break; } } $this->color = isset($class) ? $class : 'warning'; if ($this->model->hasAttribute("{$this->field}_label")) { $label = $this->model->getAttribute("{$this->field}_label"); } else { $label = Inflector::titleize($this->model->{$this->field}); } $this->label = Yii::t($this->i18nDictionary, $label); }
/** * @inheritdoc */ public function getLabel() { return $this->label ?: Inflector::titleize($this->name); }
<?php /** * Output TreeView widget * * @var $this yii\web\View */ use dmstr\modules\pages\models\Tree; use kartik\tree\TreeView; use yii\helpers\Inflector; $this->title = Inflector::titleize($this->context->module->id); /** * Wrapper templates */ $headerTemplate = <<<HTML <div class="row"> <div class="col-sm-6" id="pages-detail-heading"> {heading} </div> <div class="col-sm-6" id="pages-detail-search"> {search} </div> </div> HTML; $mainTemplate = <<<HTML <div class="row"> <div class="col-md-4" id="pages-detail-wrapper"> <div class="box boy-body"> {wrapper} </div> </div>
/** * Get descriptor. * * @return [[@doctodo return_type:getDescriptor]] [[@doctodo return_description:getDescriptor]] */ public function getDescriptor() { return Inflector::titleize($this->name, true); }
use yii\gii\plus\helpers\Helper; use yii\helpers\Inflector; /* @var $this yii\web\View */ /* @var $generator yii\gii\plus\generators\custom\model\Generator */ /* @var $ns string */ /* @var $modelName string */ /* @var $modelClass string|yii\boost\db\ActiveRecord */ /* @var $baseModelName string */ /* @var $baseModelClass string|yii\boost\db\ActiveRecord */ /* @var $queryNs string */ /* @var $queryName string */ /* @var $queryClass string|yii\boost\db\ActiveQuery */ /* @var $baseQueryName string */ /* @var $baseQueryClass string|yii\boost\db\ActiveQuery */ /* @var $tableSchema yii\gii\plus\db\TableSchema */ $uses = [$baseQueryClass]; Helper::sortUses($uses); echo '<?php namespace ', $queryNs, '; use ', implode(';' . "\n" . 'use ', $uses), '; /** * ', Inflector::titleize($queryName), ' * @see \\', $modelClass, ' */ class ', $queryName, ' extends ', $baseQueryName, ' { } ';
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) */ use hipanel\helpers\Url; use hipanel\widgets\Box; use hipanel\widgets\FileInput; use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\helpers\Inflector; use yii\widgets\ActiveForm; /** * @var \hipanel\modules\client\models\Contact $contact * @var \hipanel\modules\client\models\DocumentUploadForm $model */ $this->title = Yii::t('hipanel:client', 'Attached documents'); $this->params['breadcrumbs'][] = ['label' => Yii::t('hipanel:client', 'Contacts'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Inflector::titleize($contact->name, true), 'url' => ['view', 'id' => $contact->id]]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="col-md-6"> <?php $grouped = ArrayHelper::index($contact->documents, 'id', [function ($file) { return (new DateTime($file->create_time))->modify('today')->format('U'); }]); krsort($grouped, SORT_NUMERIC); ?> <?php foreach ($grouped as $date => $files) { ?> <div class="panel panel-default">
/* @var $fixtureName string */ /* @var $fixtureClass string|yii\boost\test\ActiveFixture */ /* @var $baseFixtureName string */ /* @var $baseFixtureClass string|yii\boost\test\ActiveFixture */ /* @var $dataFile string */ /* @var $tableSchema yii\gii\plus\db\TableSchema */ $uses = [$baseFixtureClass]; Helper::sortUses($uses); echo '<?php namespace ', $fixtureNs, '; use ', implode(';' . "\n" . 'use ', $uses), '; /** * ', Inflector::titleize($fixtureName), ' fixture * @see \\', $modelClass, ' */ class ', $fixtureName, ' extends ', $baseFixtureName, ' { public $modelClass = \'', $modelClass, '\'; '; /* @var $model yii\boost\db\ActiveRecord */ $model = new $modelClass(); // depends/backDepends $depends = []; $backDepends = []; foreach ($modelClass::allRelations() as $relationName => $relation) { if (!$relation['viaTable']) { /* @var $relationClass string|yii\boost\db\ActiveRecord */
/** * @return string */ public static function modelTitle() { return Inflector::titleize(static::classShortName()); }
/** * @param ActiveQuery $relation * @param string $name * @param string $label * @param bool $recursive * @return AttributeDescriptor[] */ protected function getRelationAttributes(ActiveQuery $relation, $name, $label = '', $recursive = true) { $searchableAttributes = []; $label = $label ?: $name; /** @var \im\search\components\SearchManager $searchManager */ $searchManager = Yii::$app->get('searchManager'); $modelClass = $relation->modelClass; $searchableType = $searchManager->getSearchableTypeByClass($modelClass); if (!$searchableType) { $reflector = new ReflectionClass($modelClass); /** @var SearchableInterface $searchableType */ $searchableType = Yii::createObject(['class' => 'im\\search\\components\\service\\db\\SearchableType', 'type' => Inflector::camel2id($reflector->getShortName(), '_'), 'modelClass' => $modelClass]); } $searchableAttributes[] = new AttributeDescriptor(['name' => Inflector::variablize($name), 'label' => Inflector::titleize($label), 'value' => function ($model) use($relation) { return $relation; }, 'type' => $searchableType->getType()]); if ($recursive) { foreach ($searchableType->getSearchableAttributes(false) as $attribute) { $attribute->label = Inflector::titleize($name) . ' >> ' . $attribute->label; $attribute->name = Inflector::variablize($label) . '.' . $attribute->name; $searchableAttributes[] = $attribute; } } return $searchableAttributes; }
public function name() { $reflector = new \ReflectionClass($this); return Inflector::titleize($reflector->getShortName()); }
/** * Parses the steps array into a "flat" array by resolving branches. * Branches are resolved according the settings * * @param array The steps array. * @return array Steps to take */ private function _parseSteps($steps) { $parsed = []; foreach ($steps as $label => $step) { $branch = ''; if (is_array($step)) { foreach (array_keys($step) as $branchName) { $branchDirective = isset($this->_session[$this->_branchKey][$branchName]) ? $this->_session[$this->_branchKey][$branchName] : self::BRANCH_DESELECT; if ($branchDirective === self::BRANCH_SELECT || empty($branch) && $this->defaultBranch && $branchDirective !== self::BRANCH_SKIP) { $branch = $branchName; } } if (!empty($branch)) { if (is_array($step[$branch])) { $parsed = array_merge($parsed, $this->_parseSteps($step[$branch])); } else { $parsed[$label] = $step[$branch]; } } } else { $parsed[$step] = is_string($label) ? $label : Inflector::titleize($step, true); } } return $parsed; }
/** * @param $name * @return AttributeInterface */ public static function getInstanceByName($name) { $instance = static::findOne(['name' => $name]); if ($instance === null) { /** @var AttributeInterface $instance */ $instance = new static(); $instance->setName($name); $instance->setPresentation(Inflector::titleize($name)); } return $instance; }
<?php } else { ?> <div class="row"> <div class="col-sm-6"> <?php echo Html::activeHiddenInput($node, $iconTypeAttribute); ?> <?php echo $form->field($node, $nameAttribute, ['addon' => ['prepend' => ['content' => Inflector::titleize($iconTypeAttribute)]]])->textArea(['rows' => 2] + $inputOpts)->label(false); ?> </div> <div class="col-sm-6"> <?php echo $form->field($node, $iconAttribute, ['addon' => ['prepend' => ['content' => Inflector::titleize($iconTypeAttribute)]]])->multiselect($iconsList, ['item' => function ($index, $label, $name, $checked, $value) use($inputOpts) { if ($index == 0 && $value == '') { $checked = true; $value = ''; } return '<div class="radio">' . Html::radio($name, $checked, ['value' => $value, 'label' => $label, 'disabled' => !empty($inputOpts['readonly']) || !empty($inputOpts['disabled'])]) . '</div>'; }, 'selector' => 'radio'])->label(false); ?> </div> </div> <?php } ?> <?php if (empty($inputOpts['disabled']) || $isAdmin && $showFormButtons) {
<?php /* * Client module for HiPanel * * @link https://github.com/hiqdev/hipanel-module-client * @package hipanel-module-client * @license BSD-3-Clause * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) */ use yii\helpers\Inflector; if (!$models) { $models[] = $model; } $this->title = Yii::t('hipanel', 'Update'); $this->params['breadcrumbs'][] = ['label' => Yii::t('hipanel:client', 'Contacts'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Inflector::titleize(reset($models)->getName(), true), 'url' => ['view', 'id' => reset($models)->id]]; $this->params['breadcrumbs'][] = $this->title; foreach ($models as $model) { $model->scenario = $scenario; echo $this->render('_form', ['model' => $model, 'countries' => $countries, 'askPincode' => $askPincode]); }
public static function titleize($str, $ucAll = true) { return Inflector::titleize(strtr($str, '-', ' '), $ucAll); }
/** * @inheritdoc */ public function getSearchableAttributes($recursive = true) { /** @var \im\base\types\EntityTypesRegister $typesRegister */ $typesRegister = Yii::$app->get('typesRegister'); /** @var \im\search\components\SearchManager $searchManager */ $searchManager = Yii::$app->get('searchManager'); $model = $this->getModel(); if ($model instanceof AttributeValue) { return []; } $entityType = $typesRegister->getEntityType($model); $attributes = $model->attributes(); $labels = $model->attributeLabels(); $searchableAttributes = []; $key = 0; // Attributes foreach ($attributes as $attribute) { $searchableAttributes[$key] = new AttributeDescriptor(['entity_type' => $entityType, 'name' => $attribute, 'label' => isset($labels[$attribute]) ? $labels[$attribute] : $model->generateAttributeLabel($attribute)]); $key++; } // EAV $eavAttributes = Attribute::findByEntityType($entityType); foreach ($eavAttributes as $attribute) { $searchableAttributes[$key] = new AttributeDescriptor(['entity_type' => $entityType, 'name' => $attribute->getName() . '_attr', 'label' => $attribute->getPresentation()]); $key++; } // Relations $class = new \ReflectionClass($model); foreach ($class->getMethods() as $method) { if ($method->isPublic()) { $methodName = $method->getName(); if (strpos($methodName, 'get') === 0) { $math = false; $name = substr($methodName, 3); if (substr($name, -8) === 'Relation') { $name = substr($name, 0, -8); $math = true; } elseif (preg_match('/@return.*ActiveQuery/i', $method->getDocComment())) { $math = true; } if ($math && $name) { /** @var ActiveQuery $relation */ $relation = $model->{$methodName}(); $modelClass = $relation->modelClass; $searchableType = $searchManager->getSearchableTypeByClass($modelClass); if (!$searchableType) { $reflector = new ReflectionClass($modelClass); /** @var SearchableInterface $searchableType */ $searchableType = Yii::createObject(['class' => 'im\\search\\components\\service\\db\\SearchableType', 'type' => Inflector::camel2id($reflector->getShortName(), '_'), 'modelClass' => $modelClass]); } $searchableAttributes[$key] = new AttributeDescriptor(['entity_type' => $entityType, 'name' => Inflector::variablize(substr($methodName, 3)), 'label' => Inflector::titleize($name), 'value' => function ($model) use($methodName) { return $model->{$methodName}(); }, 'type' => $searchableType->getType()]); $key++; if ($recursive) { foreach ($searchableType->getSearchableAttributes(false) as $attribute) { $attribute->label = Inflector::titleize($name) . ' >> ' . $attribute->label; $attribute->name = Inflector::variablize(substr($methodName, 3)) . '.' . $attribute->name; $searchableAttributes[$key] = $attribute; $key++; } } } } } } return $searchableAttributes; }
', ['create'], ['class' => 'btn btn-success']) ?> </p> <div class="pull-right"> <?php $items = []; $model = new $generator->modelClass(); foreach ($generator->getModelRelations($model) as $relation) { // relation dropdown links $iconType = $relation->multiple ? 'arrow-right' : 'arrow-left'; if ($generator->isPivotRelation($relation)) { $iconType = 'random'; } $controller = $generator->pathPrefix . Inflector::camel2id(StringHelper::basename($relation->modelClass), '-', true); $route = $generator->createRelationRoute($relation, 'index'); $label = Inflector::titleize(StringHelper::basename($relation->modelClass), '-', true); $items[] = ['label' => '<i class="glyphicon glyphicon-' . $iconType . '"> ' . $label . '</i>', 'url' => [$route]]; } ?> <?php echo "<?="; ?> \yii\bootstrap\ButtonDropdown::widget( [ 'id' => 'giiant-relations', 'encodeLabel' => false, 'label' => '<span class="glyphicon glyphicon-paperclip"></span> Relations', 'dropdown' => [ 'options' => [ 'class' => 'dropdown-menu-right'
/** * @return string */ public function getPluralName() { return $this->_pluralName ?: Inflector::titleize(Inflector::pluralize($this->_type)); }
/** * Creates taxonomy vocabulary by name * @param $name * @return TaxonomyVocabulary * @throws ErrorException */ public static function create($name) { $title = Inflector::titleize($name, true); $slug = Inflector::slug($name); $model = new self(['name' => $slug, 'title' => $title, 'status_id' => self::STATUS_ENABLED]); if ($model->save()) { return $model; } else { throw new ErrorException(implode(' ', $model->getFirstErrors())); } }
use yii\helpers\Inflector; /* @var $this yii\web\View */ /* @var $generator yii\gii\plus\generators\fixture\Generator */ /* @var $ns string */ /* @var $modelName string */ /* @var $modelClass string|yii\boost\db\ActiveRecord */ /* @var $fixtureNs string */ /* @var $fixtureName string */ /* @var $fixtureClass string|yii\boost\test\ActiveFixture */ /* @var $baseFixtureName string */ /* @var $baseFixtureClass string|yii\boost\test\ActiveFixture */ /* @var $dataFile string */ /* @var $tableSchema yii\gii\plus\db\TableSchema */ echo '<?php /* ', Inflector::titleize($fixtureName), ' data-file */ /* @see ', $fixtureClass, ' */ /* @see ', $modelClass, ' */ return [ /*[ '; /* @var $columns yii\gii\plus\db\ColumnSchema[] */ $columns = array_values($tableSchema->columns); foreach ($columns as $i => $column) { $comma = $i < count($columns) - 1 ? ',' : ''; echo ' \'', $column->name, '\' => \'\'', $comma, ' '; } echo ' ]*/ ];
use yii\gii\plus\helpers\Helper; use yii\helpers\Inflector; /* @var $this yii\web\View */ /* @var $generator yii\gii\plus\generators\custom\model\Generator */ /* @var $ns string */ /* @var $modelName string */ /* @var $modelClass string|yii\boost\db\ActiveRecord */ /* @var $baseModelName string */ /* @var $baseModelClass string|yii\boost\db\ActiveRecord */ /* @var $queryNs string */ /* @var $queryName string */ /* @var $queryClass string|yii\boost\db\ActiveQuery */ /* @var $baseQueryName string */ /* @var $baseQueryClass string|yii\boost\db\ActiveQuery */ /* @var $tableSchema yii\gii\plus\db\TableSchema */ $uses = [$baseModelClass]; Helper::sortUses($uses); echo '<?php namespace ', $ns, '; use ', implode(';' . "\n" . 'use ', $uses), '; /** * ', Inflector::titleize($modelName), ' * @see \\', $queryClass, ' */ class ', $modelName, ' extends ', $baseModelName, ' { } ';
<?php use hipanel\modules\client\grid\ContactGridView; use hipanel\modules\client\menus\ContactDetailMenu; use hipanel\modules\client\widgets\Verification; use hipanel\widgets\Box; use hipanel\widgets\ClientSellerLink; use hiqdev\assets\flagiconcss\FlagIconCssAsset; use hiqdev\menumanager\widgets\DetailMenu; use yii\helpers\Html; use yii\helpers\Inflector; /** * @var \hipanel\modules\client\models\Contact $model */ $this->title = Inflector::titleize($model->name, true); $this->params['subtitle'] = Yii::t('hipanel:client', 'Contact detailed information') . ' #' . $model->id; $this->params['breadcrumbs'][] = ['label' => Yii::t('hipanel:client', 'Contacts'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; FlagIconCssAsset::register($this); ?> <div class="row"> <div class="col-md-3"> <?php Box::begin(['options' => ['class' => 'box-solid'], 'bodyOptions' => ['class' => 'no-padding']]); ?> <div class="profile-user-img text-center"> <?php echo $this->render('//layouts/gravatar', ['email' => $model->email, 'size' => 120]); ?> </div>
public function testTitleize() { $this->assertEquals("Me my self and i", Inflector::titleize('MeMySelfAndI')); $this->assertEquals("Me My Self And I", Inflector::titleize('MeMySelfAndI', true)); }
} '; } if (count($datetimeAttributes)) { echo ' /** * @inheritdoc */ public static function datetimeAttributes() { return ', Helper::implode($datetimeAttributes, 2), '; } '; } // model title $modelTitle = Inflector::titleize($tableName); if ($generator->generateLabelsFromComments && $tableSchema->comment) { $modelTitle = $tableSchema->comment; } echo ' /** * @inheritdoc */ public static function modelTitle() { '; if ($generator->enableI18N) { echo ' return Yii::t(\'', $generator->messageCategory, '\', \'', $modelTitle, '\'); '; } else { echo ' return \'', $modelTitle, '\';
$this->params['searchQuery'] = $query; ?> <div class="package-details"> <h1> <?php echo Html::encode($package->getFullName()); ?> <small class="repository-link"> <?php echo Html::a(Yii::t('app', 'see on {registry}', ['registry' => Inflector::titleize($package->getType())]), $package->getRegistry()->buildPackageUrl($package->getName())); ?> </small> </h1> <?php echo Html::button(Yii::t('app', 'Fetch updates from {registry}', ['registry' => Inflector::titleize($package->getType())]), ['id' => 'fetch-btn', 'type' => 'button', 'class' => 'btn btn-success fetch-btn pull-right', 'data-loading-text' => Yii::t('app', 'Fetching for you...')]); ?> <?php echo $this->render('package-details', ['package' => $package]); ?> </div> <?php $options = Json::encode(['url' => Url::to('update'), 'type' => 'post', 'data' => ['query' => $package->getFullName()], 'success' => new \yii\web\JsExpression("function (html) {\n versions.removeClass('updating').html(html);\n btn.button('reset');\n }"), 'beforeSend' => new \yii\web\JsExpression("function (event) {\n versions.addClass('updating').html(\$('<i class=\"fa fa-cog fa-spin fa-3x fa-fw\"></i>'));\n btn.button('loading');\n }")]); $this->registerJs(<<<JS \$('#fetch-btn').on('click', function () { var versions = \$('.versions'), btn = \$('#fetch-btn'); \$.ajax({$options}); }) JS