protected function compile()
 {
     parent::compile();
     // ===================================
     // = Add for exporting configuration =
     // ===================================
     $this->configuration['credentials']['export'] = array();
     $this->configuration['export'] = array('fields' => array(), 'title' => $this->getExportTitle(), 'actions' => $this->getExportActions() ? $this->getExportActions() : array('_list' => array('action' => 'index', 'label' => 'Back')));
     $config = $this->getConfig();
     foreach (array_keys($config['default']) as $field) {
         $formConfig = array_merge($config['default'][$field], isset($config['form'][$field]) ? $config['form'][$field] : array());
         $this->configuration['export']['fields'][$field] = new sfModelGeneratorConfigurationField($field, array_merge(array('label' => sfInflector::humanize(sfInflector::underscore($field))), $config['default'][$field], isset($config['export'][$field]) ? $config['export'][$field] : array()));
     }
     foreach ($this->getExportDisplay() as $field) {
         list($field, $flag) = sfModelGeneratorConfigurationField::splitFieldWithFlag($field);
         $this->configuration['export']['fields'][$field] = new sfModelGeneratorConfigurationField($field, array_merge(array('type' => 'Text', 'label' => sfInflector::humanize(sfInflector::underscore($field))), isset($config['default'][$field]) ? $config['default'][$field] : array(), isset($config['export'][$field]) ? $config['export'][$field] : array(), array('flag' => $flag)));
     }
     // export actions
     foreach ($this->configuration['export']['actions'] as $action => $parameters) {
         $this->configuration['export']['actions'][$action] = $this->fixActionParameters($action, $parameters);
     }
     $this->configuration['export']['display'] = array();
     foreach ($this->getExportDisplay() as $name) {
         list($name, $flag) = sfModelGeneratorConfigurationField::splitFieldWithFlag($name);
         if (!isset($this->configuration['export']['fields'][$name])) {
             throw new InvalidArgumentException(sprintf('The field "%s" does not exist.', $name));
         }
         $field = $this->configuration['export']['fields'][$name];
         $field->setFlag($flag);
         $this->configuration['export']['display'][$name] = $field;
     }
 }
 public function addFields()
 {
     // Information object attribute (db column) to perform s/r on
     $map = new InformationObjectI18nTableMap();
     foreach ($map->getColumns() as $col) {
         if (!$col->isPrimaryKey() && !$col->isForeignKey()) {
             $col_name = $col->getPhpName();
             $choices[$col_name] = sfInflector::humanize(sfInflector::underscore($col_name));
         }
     }
     $this->form->setValidator('column', new sfValidatorString());
     $this->form->setWidget('column', new sfWidgetFormSelect(array('choices' => $choices), array('style' => 'width: auto')));
     // Search-replace values
     $this->form->setValidator('pattern', new sfValidatorString());
     $this->form->setWidget('pattern', new sfWidgetFormInput());
     $this->form->setValidator('replacement', new sfValidatorString());
     $this->form->setWidget('replacement', new sfWidgetFormInput());
     $this->form->setValidator('caseSensitive', new sfValidatorBoolean());
     $this->form->setWidget('caseSensitive', new sfWidgetFormInputCheckbox());
     $this->form->setValidator('allowRegex', new sfValidatorBoolean());
     $this->form->setWidget('allowRegex', new sfWidgetFormInputCheckbox());
     if ($this->request->isMethod('post') && !isset($this->request->confirm) && !empty($this->request->pattern) && !empty($this->request->replacement)) {
         $this->form->setValidator('confirm', new sfValidatorBoolean());
         $this->form->setWidget('confirm', new sfWidgetFormInputHidden(array(), array('value' => true)));
     }
 }
 /**
  * Saving changed page information
  *
  * @return afResponse
  * @author Sergey Startsev
  */
 protected function processSave()
 {
     // Getting needed parameters - page, application name, and sure definition
     $page_name = pathinfo($this->getParameter('page'), PATHINFO_FILENAME);
     $application = $this->getParameter('app');
     $definition = $this->getParameter('definition', array());
     $module = $this->getParameter('module', self::PAGES_MODULE);
     $permissions = new Permissions();
     $is_writable = $permissions->isWritable(sfConfig::get('sf_apps_dir') . '/' . $application . '/config/pages/');
     if ($is_writable !== true) {
         return $is_writable;
     }
     //idXml is stored inside the portal_state table from appFlowerPlugin
     $idXml = "pages/{$page_name}";
     $page = afsPageModelHelper::retrieve($page_name, $application);
     $is_new = $page->isNew();
     $page->setTitle(sfInflector::humanize(sfInflector::underscore($page_name)));
     $page->setDefinition($definition);
     $saveResponse = $page->save();
     $response = afResponseHelper::create();
     if ($saveResponse->getParameter(afResponseSuccessDecorator::IDENTIFICATOR)) {
         $console = afStudioConsole::getInstance()->execute(array("sf appflower:portal-state-cc {$idXml}", "sf appflower:validator-cache frontend cache yes", 'sf afs:fix-perms'));
         return $response->success(true)->content(!$is_new ? sprintf('Page <b>%s</b> has been saved', $page_name) : sprintf('Page <b>%s</b> has been created', $page_name))->console($console);
     }
     $response->success(false);
     if ($saveResponse->hasParameter(afResponseMessageDecorator::IDENTIFICATOR)) {
         $response->content($saveResponse->getParameter(afResponseMessageDecorator::IDENTIFICATOR));
     }
     return $response;
 }
  public function setup($options, $parameters = array())
  {
    $ret = parent::setup($options, $parameters);

    $this->humanizedModuleName = sfInflector::humanize($this->moduleName);

    return $ret;
  }
 public function getGenereatedLabel($name)
 {
     $label = $this->getLabel();
     if (null === $label) {
         $label = sfInflector::humanize($name);
     }
     return $label;
 }
 public function configure()
 {
     $target = $this->getOption('target');
     $options = array('file_src' => '', 'is_image' => true, 'with_delete' => false, 'label' => sfInflector::humanize($target));
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     $options['template'] = get_partial('opSkinClassicPlugin/formEditImage', array('target' => $target));
     $this->setWidget('image', new sfWidgetFormInputFileEditable($options, array('size' => 10)));
     $this->setValidator('image', new opValidatorImageFile(array('required' => true)));
     $this->widgetSchema->setNameFormat('image[' . $target . '][%s]');
 }
 public function configure()
 {
     foreach (opSkinClassicConfig::getAllowdColors() as $color) {
         $this->setWidget($color, new sfWidgetFormInputText());
         $this->widgetSchema->setLabel($color, sfInflector::humanize($color));
         $this->setValidator($color, new sfValidatorCallback(array('callback' => array('opSkinClassicColorForm', 'validateHex'))));
         $this->setDefault($color, opSkinClassicConfig::get($color));
     }
     $this->widgetSchema->setNameFormat('color[%s]');
 }
Ejemplo n.º 8
0
 /**
  * Runs all test methods
  * 
  * @return null
  */
 public function run()
 {
     foreach ($this->getTestMethods() as $method) {
         $test = $method->getName();
         $this->info(sfInflector::humanize(sfInflector::underscore(substr($test, 4))));
         $this->setUp();
         $this->{$test}();
         $this->tearDown();
     }
 }
 /**
  * Builds and returns an array with the widget and validator to use with
  * any choice field for a theme
  *
  * @return array $widgetAndValidator
  */
 public function getThemeWidgetAndValidator()
 {
     $themes = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfThemePlugin')->getThemeManager()->getAvailableThemes();
     $options = array('' => '');
     foreach ($themes as $name => $theme) {
         $options[$name] = sfInflector::humanize($name);
     }
     $widget = new sfWidgetFormChoice(array('choices' => $options));
     $validator = new sfValidatorChoice(array('choices' => array_keys($options), 'required' => false));
     return array('widget' => $widget, 'validator' => $validator);
 }
 /**
  * Returns the configuration value for a given key.
  *
  * If the key is null, the method returns all the configuration array.
  *
  * @param  string  $key     A key string
  * @param  mixed   $default The default value if the key does not exist
  * @param  Boolean $escaped Whether to escape single quote (false by default)
  *
  * @return mixed   The configuration value associated with the key
  */
 public function getConfig($key = null, $default = null, $escaped = false)
 {
     if (is_null($key)) {
         return $this->config;
     }
     if ('label' == $key && !isset($this->config['label'])) {
         return sfInflector::humanize(sfInflector::underscore($this->name));
     }
     $value = sfModelGeneratorConfiguration::getFieldConfigValue($this->config, $key, $default);
     return $escaped ? str_replace("'", "\\'", $value) : $value;
 }
Ejemplo n.º 11
0
 /**
  * Ensures that the site record has been created
  */
 protected function _getOrCreateSite($arguments, $options)
 {
     $site = Doctrine_Core::getTable('sfSympalSite')->createQuery('s')->where('s.slug = ?', $arguments['site'])->fetchOne();
     if (!$site) {
         $this->logSection('sympal', 'Creating new site record in database...');
         $site = new sfSympalSite();
         $site->title = sfInflector::humanize($arguments['site']);
         $site->slug = $arguments['site'];
     }
     $site->save();
     return $site;
 }
 /**
  * @see rtSiteForm
  */
 public function setup()
 {
     parent::setup();
     $social_media_locations = array('devour_url', 'facebook_url', 'flickr_url', 'google_plus_url', 'instagram_url', 'pinterest_url', 'tumblr_url', 'twitter_url', 'vimeo_url', 'youtube_url', 'linkedin_url');
     $this->useFields(array_merge($social_media_locations, array('title', 'sub_title', 'type', 'meta_title_suffix', 'meta_keyword_suffix', 'domain', 'reference_key', 'admin_email_address', 'content', 'published', 'html_snippet_suffix', 'email_signature', 'public_url', 'position', 'content_summery', 'email_contact_address', 'email_contact_response', 'email_booking_address', 'email_booking_response', 'redirects')));
     $this->widgetSchema->setLabel('meta_title_suffix', 'Meta Title Suffix');
     $this->widgetSchema->setHelp('meta_title_suffix', 'Will be glued as a suffix to the title meta tag content. Eg. "My Page Title | meta_title_suffix"');
     $this->widgetSchema['meta_title_suffix']->setAttribute('placeholder', 'Acme Consulting - Industry Leader for Consulting, Legal, Accounting');
     $this->widgetSchema->setLabel('meta_keyword_suffix', 'Meta Keyword Suffix');
     $this->widgetSchema->setHelp('meta_keyword_suffix', 'Will be glued as a suffix to the keywords meta tag content.');
     $this->widgetSchema['meta_keyword_suffix']->setAttribute('placeholder', 'consulting, legal, accounting');
     $categories = new rtSiteCategoriesToolkit();
     $this->setWidget('type', new sfWidgetFormChoice(array('choices' => $categories->getCategories())));
     $this->setWidget('content', $this->getWidgetFormTextarea());
     $this->widgetSchema->setLabel('content', 'Description');
     $this->setWidget('content_summery', new sfWidgetFormTextarea());
     $this->widgetSchema->setLabel('content_summery', 'Brief Description');
     $this->widgetSchema->setLabel('public_url', 'Public URL');
     $this->setWidget('email_contact_response', new sfWidgetFormTextarea());
     $this->widgetSchema->setLabel('email_contact_address', 'Email Address');
     $this->widgetSchema->setLabel('email_contact_response', 'Response');
     $this->setWidget('email_booking_response', new sfWidgetFormTextarea());
     $this->widgetSchema->setLabel('email_booking_address', 'Email Address');
     $this->widgetSchema->setLabel('email_booking_response', 'Response');
     // Social Media
     foreach ($social_media_locations as $k => $v) {
         $this->widgetSchema->setLabel($v, str_replace('url', 'URL', sfInflector::humanize($v)));
         $this->setValidator($v, new sfValidatorUrl(array('required' => false), array('invalid' => 'Must be a valid URL, eg. https://www.acme.com/...')));
     }
     $this->setWidget('html_snippet_suffix', new sfWidgetFormTextarea());
     $this->widgetSchema->setLabel('html_snippet_suffix', 'Included HTML');
     $this->setWidget('redirects', new sfWidgetFormTextarea());
     $this->widgetSchema->setLabel('redirects', 'HTTP Redirects (YAML)');
     $this->widgetSchema->setHelp('redirects', 'Set of YAML formatted arrays Eg. "- /old-page.html, /new-page, 301"');
     // Populate position dropdown
     $query = Doctrine::getTable('rtSite')->getQuery()->andWhere('site.position is not null');
     if (!$this->isNew()) {
         $query->andWhere('site.id != ?', $this->getObject()->getId());
     }
     $query->orderBy('site.position ASC');
     $site_positions = array();
     $site_positions[1] = 'First';
     $i = 2;
     foreach ($query->execute() as $tw_job) {
         $site_positions[$i] = 'Below ' . $tw_job->getTitle();
         $i++;
     }
     $this->setValidator('admin_email_address', new sfValidatorEmail(array('required' => true), array('invalid' => 'Must be a valid email address')));
     $this->widgetSchema['position'] = new sfWidgetFormSelect(array('choices' => $site_positions));
     $this->setValidator('public_url', new sfValidatorUrl(array('required' => false), array('invalid' => 'Must be a valid URL, eg. http://example.com')));
     $this->setEmbeddedForms();
 }
 /**
  * Returns HTML code for slot action.
  *
  * @param string  $actionName   The action name
  * @param array   $params       The parameters
  * @param boolean $pk_link      Whether to add a primary key link or not
  *
  * @return string HTML code
  */
 public function getSlotAction($actionName, $params, $pk_link = false)
 {
     $action = isset($params['action']) ? $params['action'] : 'List' . sfInflector::camelize($actionName);
     //Default parameters definition
     $params['params'] = isset($params['params']) ? $params['params'] : array();
     $params['label'] = isset($params['label']) ? $params['label'] : sfInflector::humanize($params['action']);
     $params['icon'] = isset($params['icon']) ? $params['icon'] : $this->getDefaultValue('slot.icon');
     $params['params']['class'] = isset($params['params']['class']) ? $params['params']['class'] : $this->getDefaultValue('slot.class');
     $params['params']['image_class'] = isset($params['params']['image_class']) ? $params['params']['image_class'] : $this->getDefaultValue('slot.image_class');
     $params['params']['text_class'] = isset($params['params']['text_class']) ? $params['params']['text_class'] : $this->getDefaultValue('slot.text_class');
     $url_params = $pk_link ? '?' . $this->getPrimaryKeyUrlParams() : '\'';
     $content = '$helper->getSlotActionImage(' . $this->asPhp($params) . ') . $helper->getSlotActionText(' . $this->asPhp($params) . ')';
     return '[?php echo link_to(' . $content . ', \'' . $this->getModuleName() . '/' . $action . $url_params . ', ' . $this->asPhp($params['params']) . ', \'' . $this->getI18nCatalogue() . '\') ?]';
 }
 /**
  * Render a value of a single server check unit
  *
  * @param string $value
  * @param sfSympalServerCheckUnit $unit 
  * @return string $renderedValue
  */
 protected function _renderValue($value, sfSympalServerCheckUnit $unit)
 {
     switch ($unit->getType()) {
         case sfSympalServerCheckUnit::TYPE_BOOL:
             $response = $value ? 'ON' : 'OFF';
             break;
         case sfSympalServerCheckUnit::TYPE_BYTE:
             $response = sfInflector::humanize($value);
             break;
         default:
             $response = $value ? $value : '-';
     }
     return $response;
 }
 public function addField($space, $name, $options = array())
 {
     $type = isset($options['type']) ? strtolower($options['type']) : 'text';
     $class = sfInflector::classify($type) . 'ConfigField';
     if (class_exists($class)) {
         if (!isset($options['options']['label'])) {
             $options['options']['label'] = sfInflector::humanize($name);
         }
         $this->_fields[$space][$name] = new $class($options['options']);
         $this->widgetSchema[$space][$name] = $this->_fields[$space][$name]->getWidget();
         $this->validatorSchema[$space][$name] = $this->_fields[$space][$name]->getValidator();
     } else {
         throw new InvalidArgumentException('This field type doesn\'t, you need to create a classe named ' . $class);
     }
 }
Ejemplo n.º 16
0
function installPlugin($name, $t)
{
    // Install the plugin
    $manager = sfSympalPluginManager::getActionInstance($name, 'install');
    $manager->install();
    // Check that content type was created
    $contentTypeName = $manager->getContentTypeForPlugin($name);
    $contentType = Doctrine_Core::getTable('sfSympalContentType')->findOneByName($contentTypeName);
    $t->is($contentType['name'], $contentTypeName, 'Test content type name set');
    $t->is($contentType['label'], sfInflector::humanize(sfInflector::tableize(str_replace('sfSympal', null, $contentTypeName))), 'Test content type label set');
    $t->is($contentType['plugin_name'], $name, 'Test content type plugin name set');
    $contentList = Doctrine_Core::getTable('sfSympalContentList')->findOneByContentTypeId($contentType['id']);
    $t->is($contentList instanceof sfSympalContentList, true, 'Test sample content list was created.');
    $menuItem = Doctrine_Core::getTable('sfSympalMenuItem')->findOneByContentId($contentList['content_id']);
    $t->is($menuItem instanceof sfSympalMenuItem, true, 'Test menu item to sample content list was created.');
}
 /**
  * Renders the widget.
  *
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     if (0 == count($this->getOption('config'))) {
         return '';
     }
     if (is_null($value)) {
         $value = array();
     }
     $output = array();
     foreach ($this->getOption('config') as $field => $config) {
         if (in_array($config['type'], array('checkbox', 'radio'))) {
             $attributes['checked'] = 'checked';
         }
         $output[] = $this->renderContentTag('label', sfInflector::humanize($field)) . PHP_EOL . $this->renderTag('input', array_merge(array('type' => $config['type'], 'name' => $name . '[' . $field . ']', 'value' => array_key_exists($field, $value) ? $value[$field] : $config['default']), $attributes));
     }
     return '<fieldset>' . implode("<br />\n", $output) . '</fieldset>';
 }
 protected function generateRoutes()
 {
     $options = $this->getOptions();
     $apis = array('retrieve_feed', 'retrieve_resource', 'insert_resource', 'update_resource', 'delete_resource');
     if (!empty($options['apis'])) {
         $apis = (array) $options['apis'];
     }
     $model = $options['model'];
     if (!class_exists(ucfirst($model))) {
         return false;
     }
     $parentModel = '';
     $prefix = 'feeds_' . sfInflector::underscore($model) . '_';
     if (!empty($options['parent_model'])) {
         $parentModel = $options['parent_model'];
         if (!class_exists(ucfirst($parentModel))) {
             return false;
         }
     }
     foreach ($this->templates as $name => $template) {
         if (!in_array($name, $apis)) {
             continue;
         }
         $uris = array();
         $action = array('module' => 'feeds', 'action' => $template['action']);
         $requirements = array('model' => $model, 'sf_method' => $template['method']);
         $routeOption = array('model' => ucfirst($model), 'type' => 'object', 'uriType' => $template['uriType']);
         $routeOption['api_name'] = 'webapi_' . sfInflector::underscore($model) . '_' . $template['method'];
         $routeOption['api_caption'] = ucfirst($template['method']) . ' ' . sfInflector::humanize($model) . ' item(s)';
         if ($template['uriType'] === opWebAPIRoute::URI_TYPE_COLLECTION) {
             $uri = $this->collectionUriRule;
             if ($parentModel) {
                 $uri .= '/:parent_model/:parent_id';
                 $requirements['parent_model'] = $parentModel;
             }
             $uris['normal'] = $uri;
             $uris['category'] = $uri . '/-/*';
         } else {
             $uris['normal'] = $this->memberUriRule;
         }
         foreach ($uris as $key => $value) {
             $this->routes[$prefix . $name . '_' . $key] = new opWebAPIRoute($value, array_merge($action, array('sf_format' => 'atom')), $requirements, $routeOption);
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * Adds a setting to the form. This is the main interface for adding
  * to the config form
  * 
  * @param string $group  The config group (can be null of at root of sympal_config)
  * @param string $name   The name of the config
  * @param string $label  The label to use in the form
  * @param string $widget The sfWidgetForm%%% class to use for the widget
  * @param string $validator The sfValidator%%% class to use as the validator
  */
 public function addSetting($group, $name, $label = null, $widget = 'Input', $validator = 'String')
 {
     if ($label === null) {
         $label = sfInflector::humanize($name);
     }
     if (!is_object($widget)) {
         $widgetClass = 'sfWidgetForm' . $widget;
         $widget = new $widgetClass();
     }
     if (!is_object($validator)) {
         $validatorClass = 'sfValidator' . $validator;
         $validator = new $validatorClass();
     }
     $validator->setOption('required', false);
     $node = array('name' => $name, 'label' => $label, 'widget' => $widget, 'validator' => $validator);
     if (!$group) {
         $this->_settings[] = $node;
     } else {
         $this->_settings[$group][] = $node;
     }
 }
Ejemplo n.º 20
0
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $properties = parse_ini_file(sfConfig::get('sf_config_dir') . '/properties.ini', true);
     $constants = array('PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', 'APP_NAME' => $arguments['application'], 'MODULE_NAME' => $arguments['module'], 'MODEL_CLASS' => $arguments['model'], 'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here', 'THEME' => $options['theme'], 'OBJECT_NAME' => sfInflector::humanize(sfInflector::underscore($arguments['model'])));
     $moduleDir = sfConfig::get('sf_app_module_dir') . '/' . $arguments['module'];
     // create module structure
     $finder = sfFinder::type('any')->discard('.sf');
     $dirs = $this->configuration->getGeneratorSkeletonDirs('DbFinderAdmin', $options['theme']);
     foreach ($dirs as $dir) {
         if (is_dir($dir)) {
             $this->getFilesystem()->mirror($dir, $moduleDir, $finder);
             break;
         }
     }
     // customize php and yml files
     $finder = sfFinder::type('file')->name('*.php', '*.yml');
     $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $constants);
     //set our generated directories writable so we can put generated files in them
     //$finder = sfFinder::type('directory')->ignore_version_control()->discard('.sf');
     //$this->getFilesystem()->chmod($finder,$moduleDir,0777);
 }
Ejemplo n.º 21
0
 public function executeExport($request)
 {
     if ($request->isMethod('POST')) {
         $exportManager = sfExportManager::create('Resource');
         $sheets = array('stuff' => array('have', 'need'), 'info' => array('have', 'need'), 'time' => array('need'));
         foreach ($sheets as $prefix => $types) {
             $class = sfInflector::camelize($prefix . 'Resource');
             $fields = Doctrine::getTable($class)->getColumnNames();
             $fields = array_combine($fields, $fields);
             foreach ($fields as $key => $value) {
                 $fields[$key] = sfInflector::humanize($value);
             }
             foreach ($types as $type) {
                 $results = Doctrine::getTable($class)->createQuery()->where('transaction_type = ?', $type)->execute();
                 $exportManager->exportCollectionSheet($results, $fields, sprintf('%s %s', $type, $prefix));
             }
         }
         $title = $request->getParameter('title', 'Donate_Nashville_Export');
         $title = $request->getParameter('include_timestamp') ? $title . '-' . date('Y-m-d H:i') : $title;
         $exportManager->output($title);
         return sfView::NONE;
     }
 }
Ejemplo n.º 22
0
$form = $this->getFormObject();
?>
<h1><?php 
echo sfInflector::humanize($this->getModuleName());
?>
 List</h1>

<table>
  <thead>
    <tr>
<?php 
foreach ($this->getColumns() as $column) {
    ?>
      <th><?php 
    echo sfInflector::humanize(sfInflector::underscore($column->getPhpName()));
    ?>
</th>
<?php 
}
?>
    </tr>
  </thead>
  <tbody>
    [?php foreach ($<?php 
echo $this->getPluralName();
?>
 as $<?php 
echo $this->getSingularName();
?>
): ?]
 protected function fixActionParameters($action, $parameters)
 {
     if (null === $parameters) {
         $parameters = array();
     }
     if (!isset($parameters['params'])) {
         $parameters['params'] = array();
     }
     if ('_delete' == $action && !isset($parameters['confirm'])) {
         $parameters['confirm'] = 'Are you sure?';
     }
     $parameters['class_suffix'] = strtolower('_' == $action[0] ? substr($action, 1) : $action);
     // merge with defaults
     $defaults = $this->getActionsDefault();
     if (isset($defaults[$action])) {
         $parameters = array_merge($defaults[$action], $parameters);
     }
     if (isset($parameters['label'])) {
         $label = $parameters['label'];
     } else {
         if ('_' != $action[0]) {
             $label = $action;
         } else {
             $label = '_list' == $action ? 'Back to list' : substr($action, 1);
         }
     }
     $parameters['label'] = sfInflector::humanize($label);
     return $parameters;
 }
';
<?php 
unset($this->config['edit']['title']);
?>

    } // Base<?php 
echo ucfirst($this->getModuleName());
?>
GeneratorConfiguration::getEditTitle()


    public function getNewTitle()
    {

        return '<?php 
echo $this->escapeString(isset($this->config['new']['title']) ? $this->config['new']['title'] : 'New ' . sfInflector::humanize($this->getModuleName()));
?>
';
<?php 
unset($this->config['new']['title']);
?>

    } // Base<?php 
echo ucfirst($this->getModuleName());
?>
GeneratorConfiguration::getNewTitle()


    public function getFilterDisplay()
    {
Ejemplo n.º 25
0
      <form enctype="multipart/form-data" action="" method="post">
        <?php 
echo $form->renderHiddenFields();
?>
        <?php 
echo $form->renderGlobalErrors();
?>
        <?php 
foreach ($fields as $space => $fs) {
    ?>
          <fieldset id="sf_fieldset_<?php 
    echo $space;
    ?>
">
            <h2><?php 
    echo sfInflector::humanize($space);
    ?>
</h2>
            <?php 
    foreach ($fs as $field => $options) {
        ?>
              <div class="sf_admin_form_row sf_admin_text sf_admin_form_field_author">
                <?php 
        echo $form[$space][$field]->renderError();
        ?>
                <div>
                  <?php 
        echo $form[$space][$field]->renderLabel();
        ?>
                  <div class="content">
                    <?php 
Ejemplo n.º 26
0
 protected function _populateDefaultColumns()
 {
     $rootAlias = $this->_query->getRootAlias();
     $this->_columns = array();
     foreach ($this->_table->getColumns() as $name => $column) {
         $column['fieldName'] = $this->_table->getFieldName($name);
         $column['name'] = $rootAlias . '.' . $column['fieldName'];
         $column['label'] = sfInflector::humanize($column['fieldName']);
         $column['is_sortable'] = true;
         $this->_columns[$column['name']] = $column;
     }
 }
Ejemplo n.º 27
0
    try
    {
      $this-><?php 
echo $this->getSingularName();
?>
->delete();
      $this->redirect('<?php 
echo $this->getModuleName();
?>
/list');
    }
    catch (Doctrine_Exception $e)
    {
      $this->getRequest()->setError('delete', 'Could not delete the selected <?php 
echo sfInflector::humanize($this->getSingularName());
?>
. Make sure it does not have any associated items.');
      return $this->forward('<?php 
echo $this->getModuleName();
?>
', 'list');
    }
  }

  public function executeUpdate ()
  {
    if (<?php 
echo $this->getTestPksForGetOrCreate(false);
?>
)
Ejemplo n.º 28
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
require_once $_test_dir . '/../lib/util/sfToolkit.class.php';
require_once $_test_dir . '/../lib/util/sfInflector.class.php';
$t = new lime_test(7);
// ::camelize()
$t->diag('::camelize()');
$t->is(sfInflector::camelize('symfony'), 'Symfony', '::camelize() upper-case the first letter');
$t->is(sfInflector::camelize('symfony_is_great'), 'SymfonyIsGreat', '::camelize() upper-case each letter after a _ and remove _');
// ::underscore()
$t->diag('::underscore()');
$t->is(sfInflector::underscore('Symfony'), 'symfony', '::underscore() lower-case the first letter');
$t->is(sfInflector::underscore('SymfonyIsGreat'), 'symfony_is_great', '::underscore() lower-case each upper-case letter and add a _ before');
$t->is(sfInflector::underscore('HTMLTest'), 'html_test', '::underscore() lower-case all other letters');
// ::humanize()
$t->diag('::humanize()');
$t->is(sfInflector::humanize('symfony'), 'Symfony', '::humanize() upper-case the first letter');
$t->is(sfInflector::humanize('symfony_is_great'), 'Symfony is great', '::humanize() replaces _ by a space');
Ejemplo n.º 29
0
', '<?php 
            echo $name;
            ?>
', array('<?php 
            echo $this->getSingularName();
            ?>
' => $<?php 
            echo $this->getSingularName();
            ?>
)) ?]
      <?php 
        } else {
            ?>
      <tr>
         <th>[?php echo __('<?php 
            echo $field->getConfig('name', sfInflector::humanize(sfInflector::underscore($name)));
            ?>
', array(), '<?php 
            echo $this->getI18nCatalogue();
            ?>
') ?]</th>
         <?php 
            echo $this->addCredentialCondition(sprintf(<<<EOF
<td class="sf_admin_%s sf_admin_list_th_%s">
   [?php echo %s ?]
</td>
EOF
, strtolower($field->getType()), $name, $this->renderField($field)), $field->getConfig());
            ?>
         </tr>
         <?php 
Ejemplo n.º 30
0
 /**
  * Gets a field parameter value.
  *
  * @param string The key name
  * @param string The type (list, edit)
  * @param mixed  The default value
  *
  * @return mixed The parameter value
  */
 protected function getFieldParameterValue($key, $type = '', $default = null)
 {
     $retval = $this->getValueFromKey($type . '.fields.' . $key, $default);
     if ($retval !== null) {
         return $retval;
     }
     $retval = $this->getValueFromKey('fields.' . $key, $default);
     if ($retval !== null) {
         return $retval;
     }
     if (preg_match('/\\.name$/', $key)) {
         // default field.name
         return sfInflector::humanize(($pos = strpos($key, '.')) ? substr($key, 0, $pos) : $key);
     } else {
         return null;
     }
 }