本文整理匯總了PHP中dmString::underscore方法的典型用法代碼示例。如果您正苦於以下問題:PHP dmString::underscore方法的具體用法?PHP dmString::underscore怎麽用?PHP dmString::underscore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dmString
的用法示例。
在下文中一共展示了dmString::underscore方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filterSet
/**
* Implementation of filterSet() to call set on Translation relationship to allow
* access to I18n properties from the main object.
*
* @param Doctrine_Record $record
* @param string $name Name of the property
* @param string $value Value of the property
* @return void
*/
public function filterSet(Doctrine_Record $record, $fieldName, $value)
{
$translation = $record->get('Translation');
$culture = myDoctrineRecord::getDefaultCulture();
if ($translation->contains($culture)) {
$i18n = $record->get('Translation')->get($culture);
} else {
$i18n = $record->get('Translation')->get($culture);
/*
* If translation is new
* populate it with i18n fallback
*/
if ($i18n->state() == Doctrine_Record::STATE_TDIRTY) {
if ($fallback = $record->getI18nFallBack()) {
$fallBackData = $fallback->toArray();
unset($fallBackData['id'], $fallBackData['lang']);
$i18n->fromArray($fallBackData);
}
}
}
if (!ctype_lower($fieldName) && !$i18n->contains($fieldName)) {
$underscoredFieldName = dmString::underscore($fieldName);
if (strpos($underscoredFieldName, '_') !== false && $i18n->contains($underscoredFieldName)) {
$fieldName = $underscoredFieldName;
}
}
$i18n->set($fieldName, $value);
return $value;
}
示例2: setup
public function setup()
{
parent::setup();
$this->widgetSchema->setFormFormatterName('dmList');
$this->key = 'dm_form_' . self::$counter++;
$this->setName(dmString::underscore(get_class($this)));
}
示例3: addWidget
public function addWidget(DmZone $zone, $moduleAction)
{
list($module, $action) = explode('/', $moduleAction);
$this->info('Add a ' . $moduleAction . ' widget')->get(sprintf('/index.php/+/dmWidget/add?to_dm_zone=%d&mod=' . $module . '&act=' . $action . '&dm_cpi=%d', $zone->id, $this->getPage()->id))->checks(array('module_action' => 'dmWidget/add', 'method' => 'get'))->has('.dm_widget.' . str_replace('dm_widget_', '', dmString::underscore($module)) . '.' . dmString::underscore($action));
$zone->refreshRelated('Widgets');
return $this;
}
示例4: execute
public function execute(Doctrine_Connection $connection, $arguments = array(), $options = array())
{
$adapter = $this->getAdapter($connection);
$infos = $adapter->getInfos();
$infos['tag'] = dmString::underscore(dmOs::sanitizeFileName($options['tag']));
$file = $this->getFile($infos);
$this->log(sprintf('About to backup %s@%s to %s', $infos['name'], $infos['host'], $file));
$this->createDir();
$adapter->execute($file);
$this->log('Done.');
}
示例5: checkModuleAction
public function checkModuleAction($validator, $values)
{
if (!empty($values['module']) && !empty($values['action'])) {
foreach (array('module', 'action') as $key) {
$values[$key] = dmString::modulize(str_replace('-', '_', dmString::slugify(dmString::underscore($values[$key]))));
}
$existingPage = dmDb::query('DmPage p')->where('p.module = ? AND p.action = ? and p.record_id = ? AND p.id != ?', array($values['module'], $values['action'], $this->object->record_id, $this->object->id))->fetchRecord();
if ($existingPage) {
$error = new sfValidatorError($validator, $this->getI18n()->__('The page "%1%" uses this module.action', array('%1%' => $existingPage->name)));
// throw an error bound to the password field
throw new sfValidatorErrorSchema($validator, array('action' => $error));
}
}
return $values;
}
示例6: setupNestedSet
/**
* @return dmFormDoctrine
*/
protected function setupNestedSet()
{
if ($this->object instanceof sfDoctrineRecord && $this->object->getTable() instanceof myDoctrineTable) {
// unset NestedSet columns not needed as added in the getAutoFieldsToUnset() method
$this->updateNestedSetWidget($this->object->getTable(), 'nested_set_parent_id', 'Child of');
// check all relations for NestedSet
foreach ($this->object->getTable()->getRelationHolder()->getAll() as $relation) {
if ($relation->getTable() instanceof dmDoctrineTable && $relation->getTable()->isNestedSet()) {
// check for many to many
$fieldName = $relation->getType() ? dmString::underscore($relation->getAlias()) . '_list' : $relation->getLocalColumnName();
$this->updateNestedSetWidget($relation->getTable(), $fieldName);
}
}
}
return $this;
}
示例7: getDefaultFieldsConfiguration
/**
* Returns the default configuration for fields.
*
* @return array An array of default configuration for all fields
*/
public function getDefaultFieldsConfiguration()
{
$fields = array();
$names = array();
foreach ($this->getColumns() as $name => $column) {
$names[] = $name;
if ($localRelation = $this->table->getRelationHolder()->getLocalByColumnName($name)) {
$label = dmString::humanize($localRelation->getAlias());
} else {
$label = dmString::humanize($name);
}
$fields[$name] = array_merge(array('is_link' => (bool) $column->isPrimaryKey(), 'is_real' => true, 'is_partial' => false, 'is_component' => false, 'type' => $this->getType($column), 'markdown' => $this->module->getTable()->isMarkdownColumn($name), 'label' => $label), isset($this->config['fields'][$name]) ? $this->config['fields'][$name] : array());
}
foreach ($this->getManyToManyTables() as $relation) {
$name = dmString::underscore($relation->getAlias()) . '_list';
$names[] = $name;
$module = $this->moduleManager->getModuleByModel($relation->getClass());
$fields[$name] = array_merge(array('is_link' => false, 'is_real' => false, 'is_partial' => false, 'is_component' => false, 'type' => 'Text', 'label' => $module ? $module->getPlural() : dmString::humanize($relation->getAlias())), isset($this->config['fields'][$name]) ? $this->config['fields'][$name] : array());
}
foreach ($this->table->getRelationHolder()->getForeigns() as $alias => $relation) {
if ($this->moduleManager->getModuleByModel($relation->getClass())) {
$name = dmString::underscore($alias) . '_list';
$names[] = $name;
$fields[$name] = array_merge(array('is_link' => false, 'is_real' => false, 'is_partial' => false, 'is_component' => false, 'type' => 'Text', 'label' => $this->moduleManager->getModuleByModel($relation->getClass())->getPlural()), isset($this->config['fields'][$name]) ? $this->config['fields'][$name] : array());
}
}
foreach ($this->table->getRelationHolder()->getLocalMedias() as $alias => $relation) {
$name = $relation->getLocal() . '_form';
$names[] = $name;
$fields[$name] = array_merge(array('label' => $alias, 'is_real' => false, 'type' => 'Text'), isset($this->config['fields'][$name]) ? $this->config['fields'][$name] : array());
}
if (isset($this->config['fields'])) {
foreach ($this->config['fields'] as $name => $params) {
if (in_array($name, $names)) {
continue;
}
$fields[$name] = array_merge(array('is_link' => false, 'is_real' => false, 'is_partial' => false, 'is_component' => false, 'type' => 'Text'), is_array($params) ? $params : array());
}
}
unset($this->config['fields']);
return $fields;
}
示例8: fixModuleConfig
protected function fixModuleConfig($moduleKey, $moduleConfig, $isInContent)
{
/*
* Extract plural from name
* name | plural
*/
if (!empty($moduleConfig['name'])) {
if (strpos($moduleConfig['name'], '|')) {
list($moduleConfig['name'], $moduleConfig['plural']) = explode('|', $moduleConfig['name']);
}
} else {
$moduleConfig['name'] = dmString::humanize($moduleKey);
}
if (empty($moduleConfig['model'])) {
$candidateModel = dmString::camelize($moduleKey);
$model = class_exists('Base' . $candidateModel, true) ? Doctrine_Core::isValidModelClass($candidateModel) ? $candidateModel : false : false;
} else {
$model = $moduleConfig['model'];
}
// BC "actions" deprecated keyword becomes "components"
if (isset($moduleConfig['actions'])) {
$moduleConfig['components'] = $moduleConfig['actions'];
unset($moduleConfig['actions']);
}
//security features
$securityConfig = $this->fixSecurityConfig($moduleKey, $moduleConfig);
$moduleOptions = array('name' => (string) trim($moduleConfig['name']), 'plural' => (string) trim(empty($moduleConfig['plural']) ? $model ? dmString::pluralize($moduleConfig['name']) : $moduleConfig['name'] : $moduleConfig['plural']), 'model' => $model, 'credentials' => isset($moduleConfig['credentials']) ? is_string($moduleConfig['credentials']) ? trim($moduleConfig['credentials']) : (is_array($moduleConfig['credentials']) ? $moduleConfig['credentials'] : '') : ((bool) $isInContent ? 'content' : null), 'underscore' => (string) dmString::underscore($moduleKey), 'is_project' => (bool) $isInContent || dmArray::get($moduleConfig, 'page', false) || count(dmArray::get($moduleConfig, 'components', array())), 'plugin' => $moduleConfig['plugin'], 'overridden' => dmArray::get($moduleConfig, 'overridden', false), 'has_admin' => (bool) dmArray::get($moduleConfig, 'admin', $model || !$isInContent), 'has_front' => (bool) dmArray::get($moduleConfig, 'front', true), 'components' => dmArray::get($moduleConfig, 'components', array()), 'has_security' => is_array($securityConfig), 'security' => $securityConfig, 'i18n_catalogue' => isset($moduleConfig['i18n_catalogue']) ? $moduleConfig['i18n_catalogue'] : sfConfig::get('dm_i18n_catalogue'));
if ($moduleOptions['is_project']) {
$moduleOptions = array_merge($moduleOptions, array('parent_key' => dmArray::get($moduleConfig, 'parent') ? dmString::modulize(trim(dmArray::get($moduleConfig, 'parent'))) : null, 'has_page' => (bool) dmArray::get($moduleConfig, 'page', false)));
}
// fix non array action filters
foreach ($moduleOptions['components'] as $componentKey => $componentConfig) {
if (is_array($componentConfig) && array_key_exists('filters', $componentConfig) && !is_array($componentConfig['filters'])) {
$moduleOptions['components'][$componentKey]['filters'] = array($componentConfig['filters']);
}
}
return $moduleOptions;
}
示例9: renderEdit
/**
* Utility function
* Renders the form for the behavior edit
* @param dmBehaviorBaseForm $form
* @param dmBehaviorsManager $behaviorsManager
* @param boolean $withCopyActions
* @return rendered form
*/
protected function renderEdit(dmBehaviorBaseForm $form, $behaviorsManager, $withCopyActions = true)
{
$helper = $this->getHelper();
$copyActions = '';
if ($withCopyActions && $this->getUser()->can('behavior_add')) {
$copyActions .= $helper->tag('div.dm_cut_copy_actions.none', ($this->getUser()->can('behavior_delete') ? $helper->link('+/dmBehaviors/cut')->param('dm_behavior_id', $form->getDmBehavior()->get('id'))->text('')->title($this->getI18n()->__('Cut'))->set('.s16block.s16_cut.dm_behavior_cut') : '') . $helper->link('+/dmBehaviors/copy')->param('dm_behavior_id', $form->getDmBehavior()->get('id'))->text('')->title($this->getI18n()->__('Copy'))->set('.s16block.s16_copy.dm_behavior_copy'));
}
return $helper->tag('div.dm.dm_behavior_edit.dm_behavior_edit_form.' . dmString::underscore($form->getDmBehavior()->get('dm_behavior_key')) . '_form', array('json' => array('form_class' => $behaviorsManager->getBehaviorFormClass($form->getDmBehavior()->get('dm_behavior_key')), 'form_name' => $form->getName())), $form->render('.dm_form.list.little') . $copyActions);
}
示例10: renderEdit
protected function renderEdit(dmWidgetBaseForm $form, dmWidgetType $widgetType, $withCopyActions = true)
{
$helper = $this->getHelper();
$devActions = '';
if ($this->getUser()->can('code_editor') && $form instanceof dmWidgetProjectForm) {
$templateDir = dmOs::join(sfConfig::get('sf_app_module_dir'), $form->getDmModule()->getKey(), 'templates', '_' . $form->getDmComponent()->getKey() . '.php');
if (file_exists($templateDir)) {
$devActions .= '<a href="#' . dmProject::unRootify($templateDir) . '" class="code_editor s16 s16_code_editor block">' . $this->getI18n()->__('Edit template code') . '</a>';
}
$componentDir = dmOs::join(sfConfig::get('sf_app_module_dir'), $form->getDmModule()->getKey(), 'actions/components.class.php');
if (file_exists($componentDir)) {
$devActions .= '<a href="#' . dmProject::unRootify($componentDir) . '" class="code_editor s16 s16_code_editor block">' . $this->getI18n()->__('Edit component code') . '</a>';
}
}
if ($devActions) {
$devActions = '<div class="code_editor_links">' . $devActions . '</div>';
}
$copyActions = '';
if ($withCopyActions && $this->getUser()->can('widget_add')) {
$copyActions = $helper->tag('div.dm_cut_copy_actions.none', $helper->link('+/dmWidget/cut')->param('widget_id', $form->getDmWidget()->get('id'))->text('')->title($this->getI18n()->__('Cut'))->set('.s16block.s16_cut.dm_widget_cut') . $helper->link('+/dmWidget/copy')->param('widget_id', $form->getDmWidget()->get('id'))->text('')->title($this->getI18n()->__('Copy'))->set('.s16block.s16_copy.dm_widget_copy'));
}
return $helper->tag('div.dm.dm_widget_edit.' . dmString::underscore($widgetType->getFullKey()) . '_form', array('json' => array('form_class' => $widgetType->getFullKey() . 'Form', 'form_name' => $form->getName())), $form->render('.dm_form.list.little') . $devActions . $copyActions);
}
示例11: array
*/
$settings = array();
if ('Doctrine' != $this->options['orm']) {
throw new Exception('We are sorry, but Diem ' . DIEM_VERSION . ' supports only Doctrine for ORM.');
}
$projectKey = dmProject::getKey();
/*
* QUESTIONS
*/
$this->logSection($projectKey, 'Please answer a few questions to configure the ' . $projectKey . ' project' . "\n");
$culture = $this->askAndValidate(array('', 'Choose your site\'s main language ( default: en )', ''), new sfValidatorRegex(array('pattern' => '/^[\\w\\d-]+$/', 'max_length' => 2, 'min_length' => 2, 'required' => false), array('invalid' => 'Language must contain two alphanumeric characters')));
$settings['culture'] = empty($culture) ? 'en' : $culture;
$webDirName = $this->askAndValidate(array('', 'Choose a web directory name ( examples: web, html, public_html; default: web )', ''), new sfValidatorAnd(array(new sfValidatorRegex(array('pattern' => '/^[\\w\\d-]+$/', 'required' => false), array('invalid' => 'Web directory name must contain only alphanumeric characters')), new sfValidatorRegex(array('pattern' => '/^(apps|lib|config|data|cache|log|plugins|test)$/', 'must_match' => false, 'required' => false), array('invalid' => 'This directory name is already used by symfony'))), array('required' => false)), array('required' => false));
$settings['web_dir_name'] = empty($webDirName) ? 'web' : $webDirName;
do {
$defaultDbName = dmString::underscore(str_replace('-', '_', $projectKey));
$isDatabaseOk = false;
$dbm = $this->askAndValidate(array('', 'What kind of database will be used? ( mysql | pgsql | sqlite )', ''), new sfValidatorChoice(array('choices' => array('mysql', 'pgsql', 'sqlite'))));
if ('sqlite' !== $dbm) {
$settings['database'] = array('name' => $this->ask(array('', 'What is the database name? ( default: ' . $defaultDbName . ' )', ''), 'QUESTION', $defaultDbName), 'host' => $this->ask(array('', 'What is the database host? ( default: localhost )', ''), 'QUESTION', 'localhost', ''), 'user' => $this->ask(array('', 'What is the database user?', '')), 'password' => $this->ask(array('', 'What is the database password?', '')));
} else {
$settings['database'] = array('name' => $defaultDbName, 'user' => null, 'password' => null);
}
switch ($dbm) {
case "mysql":
$settings['database']['dsn'] = sprintf('mysql:host=%s;dbname=%s;', $settings['database']['host'], $settings['database']['name']);
break;
case "pgsql":
$settings['database']['dsn'] = sprintf('pgsql:host=%s;dbname=%s;', $settings['database']['host'], $settings['database']['name'], $settings['database']['user'], $settings['database']['password']);
break;
case "sqlite":
示例12: getFormFields
protected function getFormFields()
{
$fields = array();
/*
* Add is_link options
*/
foreach ($this->getStringFields() as $stringField) {
if ($this->table->isLinkColumn($stringField)) {
$fields[dmString::underscore($stringField)] = array('is_link' => true, 'help' => 'Drag & drop a page here from the PAGES panel, or write an url');
}
}
return $fields;
}
示例13: getUnderscore
public function getUnderscore()
{
return dmString::underscore($this->getKey());
}
示例14: getWidgetCssClassFromPattern
protected function getWidgetCssClassFromPattern(array $widget)
{
$pattern = $this->getOption('widget_css_class_pattern');
if (empty($pattern)) {
return '';
}
return strtr($pattern, array('%module%' => str_replace('dm_widget_', '', dmString::underscore($widget['module'])), '%action%' => dmString::underscore($widget['action'])));
}
示例15: _set
/**
* Allow to set values by modulized fieldName
* ex : _get('cssClass') returns _get('css_class')
*/
public function _set($fieldName, $value, $load = true)
{
if (!ctype_lower($fieldName) && !ctype_upper($fieldName[0]) && !$this->contains($fieldName)) {
$underscoredFieldName = dmString::underscore($fieldName);
if (strpos($underscoredFieldName, '_') !== false && $this->contains($underscoredFieldName)) {
return parent::_set($underscoredFieldName, $value, $load);
}
}
return parent::_set($fieldName, $value, $load);
}