Changeset 75 for trunk

Show
Ignore:
Timestamp:
08/22/08 14:03:33 (2 years ago)
Author:
nperriault
Message:

[1.1]:

  • Companies and people modules migrated, with according form classes and templates, and functional test suite
  • Enhanced SymfoniansTestBrowser?
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/main/config/routing.yml

    r71 r75  
    111111 
    112112# Applications 
    113 applications_test: 
    114   url: /applications/test 
    115   param: { module: applications, action: test } 
    116113applications_countries: 
    117114  url:   /applications/countries 
     
    169166company_add: 
    170167  url:   /company/add 
    171   param: { module: companies, action: add
     168  param: { module: companies, action: edit
    172169 
    173170company_edit: 
     
    185182company_edit_connection: 
    186183  url:   /company/:slug/connection/:id/edit 
    187   param: { module: companies, action: editConnection
     184  param: { module: companies, action: connect
    188185 
    189186company_contact: 
  • trunk/apps/main/i18n/fr/messages.xml

    r38 r75  
    315315<trans-unit id="69"> 
    316316<source>Fields marked with a &lt;span class="left-star"&gt;star&lt;/span&gt; are mandatory.</source> 
    317 <target>Les champs marqués d'une &lt;span class="left-star"&gt;star&lt;/span&gt; sont obligatoires</target> 
     317<target>Les champs marqués d'une &lt;span class="left-star"&gt;étoile&lt;/span&gt; sont obligatoires</target> 
    318318</trans-unit> 
    319319 
     
    615615<trans-unit id="129"> 
    616616<source>Update %name% application informations</source> 
    617 <target>Mettre à jour les informations concernant l'application %application%</target> 
     617<target>Mettre à jour les informations concernant l'application %name%</target> 
    618618</trans-unit> 
    619619 
  • trunk/apps/main/lib/myActions.class.php

    r62 r75  
    11<?php 
    22/** 
    3  * Shared actions stub 
     3 * Shared actions stub for all actions 
    44 * 
    55 */ 
     
    2929  protected function buildPagerRoute($route_name, $params = array()) 
    3030  { 
    31     $query_string = http_build_query($params, '', '&'); 
    32     if ($query_string) 
     31    if ($query_string = http_build_query($params, '', '&')) 
    3332    { 
    3433      $route = sprintf('%s?%s&page=', $route_name, $query_string); 
     
    3837      $route = sprintf('%s?page=', $route_name); 
    3938    } 
     39 
    4040    return $route; 
    4141  } 
     
    6464   * Returns the rendered value of a partial 
    6565   * 
    66    * @param  string $module   Module name 
    67    * @param  string $partial  Partial name (including the underscore prefix) 
    68    * @param  array  $vars     Var to pass to the partial (optional) 
     66   * @param  string $module   Module name 
     67   * @param  string $partial  Partial name (including the underscore prefix) 
     68   * @param  array  $vars     Var to pass to the partial (optional) 
    6969   * @return string 
    7070   */ 
    7171  protected function getRenderedPartial($module, $partial, $vars = array()) 
    7272  { 
    73     $view = new sfPartialView(); 
    74     $view->initialize(sfContext::getInstance(), $module, $partial, null); 
    75     return $view->render($vars); 
    76   } 
    77  
     73    $view = new sfPartialView(sfContext::getInstance(), $module, $partial, null); 
     74    $view->setPartialVars($vars); 
     75    return $view->render(); 
     76  } 
     77 
     78  /** 
     79   * Get the current view cache manager, if any (it does not exist in dev env) 
     80   * 
     81   * @return sfViewCacheManager|null 
     82   */ 
    7883  protected function getViewCacheManager() 
    7984  { 
     
    8186  } 
    8287 
     88  /** 
     89   * Purges the cache related to a given object 
     90   * 
     91   * @param  object  $object 
     92   * @return mixed 
     93   */ 
    8394  protected function purgeObjectRelatedCache($object) 
    8495  { 
    8596    $purge_method = sprintf('purge%sRelatedCache', ucfirst(get_class($object))); 
     97 
    8698    if (method_exists($this, $purge_method)) 
    8799    { 
     
    90102  } 
    91103 
     104  /** 
     105   * Purges the homepage cache related assets 
     106   * 
     107   */ 
    92108  protected function purgeHomepage() 
    93109  { 
     
    98114  } 
    99115 
     116  /** 
     117   * Purges the sections homepages cache related assets 
     118   * 
     119   */ 
    100120  protected function purgeHomepages() 
    101121  { 
     
    112132  } 
    113133 
     134  /** 
     135   * Purges an application cache related assets 
     136   * 
     137   * @param Application $application 
     138   */ 
    114139  protected function purgeApplicationRelatedCache(Application $application) 
    115140  { 
     
    127152  } 
    128153 
     154  /** 
     155   * Purges a company cache related assets 
     156   * 
     157   * @param Company $company 
     158   */ 
    129159  protected function purgeCompanyRelatedCache(Company $company) 
    130160  { 
     
    142172  } 
    143173 
     174  /** 
     175   * Purges a job cache related assets 
     176   * 
     177   * @param Job $job 
     178   */ 
    144179  protected function purgeJobRelatedCache(Job $job) 
    145180  { 
     
    157192  } 
    158193 
     194  /** 
     195   * Purges a user cache related assets 
     196   * 
     197   * @param sfGuardUser $person 
     198   */ 
    159199  protected function purgePersonRelatedCache(sfGuardUser $person) 
    160200  { 
     
    168208  } 
    169209 
     210  /** 
     211   * Purges a recommendation cache related assets 
     212   * 
     213   * @param Recommendation $recommendation 
     214   */ 
    170215  protected function purgeRecommendationRelatedCache(Recommendation $recommendation) 
    171216  { 
     
    179224  } 
    180225 
     226  /** 
     227   * Purges an application company relation cache 
     228   * 
     229   * @param ApplicationCompany $app_company 
     230   */ 
    181231  protected function purgeApplicationCompanyRelatedCache(ApplicationCompany $app_company) 
    182232  { 
     
    190240  } 
    191241 
     242  /** 
     243   * Purges an application developer related cache 
     244   * 
     245   * @param ApplicationDeveloper $app_person 
     246   */ 
    192247  protected function purgeApplicationDeveloperRelatedCache(ApplicationDeveloper $app_person) 
    193248  { 
     
    201256  } 
    202257 
     258  /** 
     259   * Purges a company person related cache 
     260   * 
     261   * @param CompanyPerson $company_person 
     262   */ 
    203263  protected function purgeCompanyPersonRelatedCache(CompanyPerson $company_person) 
    204264  { 
     
    298358    } 
    299359    $mailer->disconnect(); 
    300      
     360 
    301361    // Add mailSent timestamp 
    302362    $this->getUser()->setAttribute('lastMailAt', time()); 
    303      
     363 
    304364    return ($sent > 0); 
    305365  } 
     
    342402    return $address; 
    343403  } 
    344    
     404 
    345405  /** 
    346406   * Checks for mail flooding (die, dirty spammers) 
     
    352412  { 
    353413    $user = $this->getUser(); 
    354      
     414 
    355415    if (!$user) 
    356416    { 
    357417      throw new sfException($this->__('Mail sending use the session, please allow cookies')); 
    358418    } 
    359      
     419 
    360420    $lastMailAt = $user->getAttribute('lastMailAt', null); 
    361      
     421 
    362422    if (is_null($lastMailAt)) 
    363423    { 
    364424      return; 
    365425    } 
    366      
     426 
    367427    $ttl = sfConfig::get('app_mail_mail_flood_time', 300); 
    368      
    369     if (time() - $lastMailAt < $ttl)  
     428 
     429    if (time() - $lastMailAt < $ttl) 
    370430    { 
    371431      throw new sfException(sprintf($this->__('You must wait at least %d seconds between two mail send, please try again later'), $ttl)); 
    372432    } 
    373433  } 
    374    
    375   /** 
    376    * Post execution: if a form has been set, we put it in sfContext to be able  
     434 
     435  /** 
     436   * Post execution: if a form has been set, we put it in sfContext to be able 
    377437   * to reference it in the layout or partials 
    378438   * 
  • trunk/apps/main/modules/applications/actions/actions.class.php

    r71 r75  
    3838 
    3939      $this->form = new ApplicationForm($application); 
     40      $this->form->setDefault('tags', $application->getTagsString()); 
    4041      $this->setTemplate('edit'); 
    4142      $message = $this->__('Application updated'); 
     
    5354    } 
    5455 
    55     $this->form->setDefault('tags', $application->getTagsString()); 
    56     $this->application = $application; 
    57  
    5856    if ($request->isMethod('post')) 
    5957    { 
     
    7977 
    8078      $this->getUser()->setFlash('notice', $message); 
    81       $this->getUser()->setAttribute('from_app_creation', is_null($request->getParameter('slug')), 'symfonians'); 
    8279      $this->redirect(sprintf($redirect, $application->getSlug())); 
    8380    } 
     
    161158    { 
    162159      $connection = ApplicationDeveloperPeer::retrieveByPK($request->getParameter('id')); 
     160 
    163161      $this->forward404If(is_null($connection)); 
    164162 
     
    200198                                  'developer_id'   => $this->getUser()->getId())); 
    201199      $this->form->bind($params); 
     200 
    202201      if ($this->form->isValid()) 
    203202      { 
  • trunk/apps/main/modules/applications/actions/components.class.php

    r2 r75  
    77{ 
    88 
     9  /** 
     10   * Filter form component 
     11   * 
     12   */ 
    913  public function executeFilterForm() 
    1014  { 
    11     $this->countries = ApplicationPeer::retrieveCountries(); 
     15    $this->form = new CountrySelectorForm(ApplicationPeer::retrieveCountries()); 
     16    $this->form->setDefault('country', $this->getRequestParameter('country')); 
    1217  } 
    1318 
     19  /** 
     20   * Popular tags component 
     21   * 
     22   */ 
    1423  public function executePopularTags() 
    1524  { 
     
    2029  } 
    2130 
     31  /** 
     32   * Recently added apps component 
     33   * 
     34   */ 
    2235  public function executeRecentlyAdded() 
    2336  { 
     
    2841  } 
    2942 
     43  /** 
     44   * Recently updated apps component 
     45   * 
     46   */ 
    3047  public function executeRecentlyUpdated() 
    3148  { 
     
    3653  } 
    3754 
     55  /** 
     56   * Related tags component 
     57   * 
     58   */ 
    3859  public function executeRelatedTags() 
    3960  { 
    40     $this->related_tags = TagPeer::getRelatedTags($this->tag, 
    41                               array('model' => 'Application')); 
     61    $this->related_tags = TagPeer::getRelatedTags($this->tag, array('model' => 'Application')); 
    4262  } 
    4363 
     64  /** 
     65   * User applications 
     66   * 
     67   */ 
    4468  public function executeUserApplications() 
    4569  { 
  • trunk/apps/main/modules/applications/templates/_filterForm.php

    r56 r75  
    11<form action="<?php echo url_for('@application_home') ?>" method="get" id="country_form"> 
    2   <?php /* 
     2  <?php echo $form['country']->renderLabel() ?> 
     3  <?php echo $form['country']->render() ?> 
    34  <p> 
    4     <label for="country"><?php echo __('Filter by country') ?></label> 
    5     <?php echo select_tag('country', 
    6                           options_for_select($countries, 
    7                                              $sf_request->getParameter('country'), 
    8                                              array('include_custom' => __('All countries')))) ?> 
     5    <input type="checkbox" value="1" <?php echo $sf_request->hasParameter('opensource') ? 'checked="checked"' : '' ?> name="opensource" id="opensource"> 
     6    <label for="opensource" class="left"><?php echo __('Only open source applications') ?></label> 
    97  </p> 
    108  <p> 
    11     <?php echo checkbox_tag('opensource', 1, $sf_request->hasParameter('opensource'), 'id=opensource') ?> 
    12     <?php echo label_for('opensource', __('Only open source applications'), 'class=left') ?> 
     9    <input type="submit" value="<?php echo __('Filter') ?>" name="commit"/> 
    1310  </p> 
    14   <p> 
    15     <?php echo submit_tag(__('Filter')) ?> 
    16   </p> 
    17   */ ?> 
    1811</form> 
  • trunk/apps/main/modules/applications/templates/_form.php

    r70 r75  
    1515      <legend><?php echo __('Application informations') ?></legend> 
    1616      <div class="form-row required <?php echo $form['name']->hasError() ? 'field_error' : '' ?>"> 
    17         <?php echo $form['name']->renderLabel() ?> 
     17        <?php echo $form['name']->renderLabel(__('Application name')) ?> 
    1818        <?php echo $form['name']->render() ?> 
    1919        <?php echo $form['name']->renderError() ?> 
     
    2828      <legend><?php echo __('Other informations') ?></legend> 
    2929      <?php echo $form['country']->renderRow() ?> 
    30       <?php echo $form['screenshot_file']->renderRow() ?> 
     30      <?php echo $form['screenshot_file']->renderRow(array(), __('Screenshot')) ?> 
    3131      <div class="form-row"> 
    3232        <?php echo $form['is_opensource'] ?> 
    33         <?php echo $form['is_opensource']->renderLabel(__('Is this application open source?'), array('class' => 'inline')) ?> 
     33        <?php echo $form['is_opensource']->renderLabel(__('This application is open source'), array('class' => 'inline')) ?> 
    3434      </div> 
    35       <?php echo $form['licence']->renderRow(array(), __('If application is open source, how is it licensed?')) ?> 
     35      <?php echo $form['licence']->renderRow(array(), __('Licence informations')) ?> 
    3636      <?php echo $form['feed_url']->renderRow() ?> 
    3737      <div class="date_select"> 
     
    4343  <div class="form-row" style="text-align:center;clear:left;"> 
    4444    <p> 
     45      <?php echo $form['id'] ?> 
    4546      <?php echo $form['_csrf_token'] ?> 
    4647      <input type="submit" value="<?php echo $submit_label ?>" /> 
  • trunk/apps/main/modules/applications/templates/_popularTags.php

    r2 r75  
    22<h3><?php echo __('Tags') ?></h3> 
    33<div class="tags_cloud"> 
    4   <?php echo tag_cloud($tags, '@application_tag?tag=') ?> 
     4  <?php echo tag_cloud($tags->getRawValue(), '@application_tag?tag=%s') ?> 
    55</div> 
    66<p class="more"> 
  • trunk/apps/main/modules/applications/templates/_relatedTags.php

    r2 r75  
    33                  array('%tag%' => tags_string($tag))) ?></h3> 
    44<div class="tags_cloud"> 
    5   <?php echo more_related_tag_cloud($related_tags, '@application_home?tag=', $tag)?> 
     5  <?php echo more_related_tag_cloud($related_tags, '@application_home?tag=%s', $tag)?> 
    66</div> 
    77<p class="more"> 
  • trunk/apps/main/modules/applications/templates/addSuccess.php

    r56 r75  
    55 
    66<?php include_partial('applications/form', 
    7                       array('application'  => $application
     7                      array('application'  => $form->getObject()
    88                            'form'         => $form, 
    99                            'title'        => $page_title, 
  • trunk/apps/main/modules/applications/templates/connectAsCompanySuccess.php

    r71 r75  
    99<?php slot('sidebar') ?> 
    1010  <?php if ($application->getScreenshotPath()): ?> 
    11     <?php $image = image_tag($application->getFullScreenshotPath(), 
    12                              'class=app_screenshot alt='.$application->getName().' preview') ?> 
     11    <?php $image = application_image_tag($application, 'class=app_screenshot alt='.$application->getName().' preview') ?> 
    1312    <?php if ($application->getHomepage()): ?> 
    1413      <?php echo link_to($image, $application->getHomepage()) ?> 
  • trunk/apps/main/modules/applications/templates/connectAsDeveloperSuccess.php

    r68 r75  
    22 
    33<?php slot('page_title') ?> 
    4   <?php $page_title = __('Connect yourself to the %application% application',  
     4  <?php $page_title = __('Connect yourself to the %application% application', 
    55                         array('%application%' => $application->getName())) ?> 
    66  <?php echo $page_title ?> 
     
    99<?php slot('sidebar') ?> 
    1010  <?php if ($application->getScreenshotPath()): ?> 
    11     <?php $image = image_tag($application->getFullScreenshotPath(),  
    12                              'class=app_screenshot alt='.$application->getName().' preview') ?> 
     11    <?php $image = image_tag($application, 'class=app_screenshot alt='.$application->getName().' preview') ?> 
    1312    <?php if ($application->getHomepage()): ?> 
    1413      <?php echo link_to($image, $application->getHomepage()) ?> 
     
    1918<?php end_slot() ?> 
    2019 
    21 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'),  
     20<?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 
    2221                            array($application->getName(), '@application_page?slug='.$application->getSlug()), 
    2322                            $page_title)) ?> 
     
    2524<h2><?php echo $page_title ?><span class="gradient">&nbsp;</span></h2> 
    2625 
    27 <?php if (isset($from_app_creation) && $from_app_creation): ?> 
    28   <p><?php echo __('Now that your app has been added, please provide some informations on how you\'ve been implied with it :-)') ?></p> 
    29 <?php else: ?> 
    30   <p><?php echo __('If you have worked on the %application% application, please fill and submit the form below.', 
    31                    array('%application%' => $application->getName())) ?></p> 
    32 <?php endif; ?> 
     26<p><?php echo __('If you have worked on the %application% application, please fill and submit the form below.', 
     27                 array('%application%' => $application->getName())) ?></p> 
    3328 
    3429<p class="form-info"> 
     
    4035    <fieldset> 
    4136      <legend><?php echo __('Connection informations') ?></legend> 
    42       <div class="form-row required"> 
     37      <div class="form-row required <?php echo $form['role']->hasError() ? 'field_error' : '' ?>"> 
    4338        <?php echo $form['role']->renderLabel(__('Your role in this project')) ?> 
    4439        <?php echo $form['role']->render() ?> 
  • trunk/apps/main/modules/applications/templates/detailsSuccess.php

    r2 r75  
    88<?php slot('sidebar') ?> 
    99  <?php if ($application->getScreenshotPath()): ?> 
    10     <?php $image = image_tag($application->getFullScreenshotPath(),  
    11                              'class=app_screenshot alt='.$application->getName().' preview') ?> 
     10    <?php $image = application_image_tag($application, 'class=app_screenshot alt='.$application->getName().' preview') ?> 
    1211    <?php if ($application->getHomepage()): ?> 
    1312      <?php echo link_to($image, $application->getHomepage()) ?> 
     
    2625    <ul class="admin_actions"> 
    2726      <li> 
    28         <?php echo link_to(__('Edit this application informations'),  
     27        <?php echo link_to(__('Edit this application informations'), 
    2928                         '@application_edit?slug='.$application->getSlug(), 
    3029                         'class=bigedit') ?></li> 
    3130      <li> 
    32         <?php echo link_to(__('Delete this application'),  
     31        <?php echo link_to(__('Delete this application'), 
    3332                         '@application_delete?slug='.$application->getSlug(), 
    3433                         'class=bigdelete confirm='.__('Are you sure?')) ?></li> 
    3534      <?php if ($sf_user->isAdmin()): ?> 
    3635      <li> 
    37         <?php echo link_to(__('Promote as featured on homepage'),  
     36        <?php echo link_to(__('Promote as featured on homepage'), 
    3837                         '@application_promote?slug='.$application->getSlug(), 
    3938                         'class=promote confirm='.__('Are you sure?')) ?></li> 
     
    4241  <?php endif; ?> 
    4342  <h3><?php echo __('Have a nice symfony app?') ?></h3> 
    44   <?php echo big_button_to(__('Add an application'),  
     43  <?php echo big_button_to(__('Add an application'), 
    4544                           '@application_add', 'id=bt_addapp') ?> 
    4645<?php end_slot() ?> 
    4746 
    4847<div class="fiftypercent"> 
    49    
    50   <?php echo breadcrumb(array(array(__('Applications'), '@application_home'),  
     48 
     49  <?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 
    5150                              $page_title)) ?> 
    52    
     51 
    5352  <h2> 
    5453    <?php echo $page_title ?> 
     
    6160    <span class="gradient">&nbsp;</span> 
    6261  </h2> 
    63    
     62 
    6463  <?php include_partial('applications/entry', 
    6564                        array('application' => $application)) ?> 
    66    
     65 
    6766</div> 
    6867 
     
    8685          <?php endif; ?> 
    8786          <?php if ($sf_user->getId() == $app_person->getDeveloperId()): ?> 
    88             <?php echo link_to(image_tag('page_edit.png', 'alt=Edit'), 
     87            <?php echo link_to(image_tag('page_edit.png', 'alt=Edit person connection'), 
    8988                               '@application_edit_developer_connection?slug='.$application->getSlug().'&id='.$app_person->getId(), 
    9089                               'title='.__('Edit your connection with ').$app_person->getApplication()->getName().' rel=nofollow class=edit') ?> 
     
    116115    <?php endif; ?> 
    117116  </div> 
    118    
     117 
    119118  <div class="related_companies"> 
    120119    <h3><?php echo __('Companies related to this application') ?></h3> 
     
    125124        <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 
    126125          <td class="mini_thumb_cell"> 
    127             <?php echo link_to(image_tag($company_application->getCompany()->getFullLogoPath(), 
     126            <?php echo link_to(company_image_tag($company_application->getCompany(), 
    128127                                         'class=mini_thumb'), 
    129128                               '@company_page?slug='.$company_application->getCompany()->getSlug(), 
     
    137136            <?php endif; ?> 
    138137            <?php if ($sf_user->getId() == $company_application->getSubmitterId()): ?> 
    139               <?php echo link_to(image_tag('page_edit.png', 'alt=Edit'), 
     138              <?php echo link_to(image_tag('page_edit.png', 'alt=Edit company connection'), 
    140139                                 '@application_edit_company_connection?slug='.$application->getSlug().'&id='.$company_application->getId(), 
    141140                                 'title='.__('Edit this connection to ').$company_application->getCompany()->getName().' rel=nofollow class=edit') ?> 
     
    161160    <?php endif; ?> 
    162161    <p class="more"> 
    163       <?php echo link_to(__('Connect a company!'),  
     162      <?php echo link_to(__('Connect a company!'), 
    164163                         '@application_connect_as_company?slug='.$application->getSlug()) ?> 
    165164    </p> 
    166165  </div> 
    167    
     166 
    168167</div> 
  • trunk/apps/main/modules/applications/templates/homeSuccess.php

    r11 r75  
    6262      <?php endif; ?> 
    6363      <?php echo link_to($application->getName(), 
    64                            '@application_page?slug='.$application->getSlug()) ?> 
     64                         '@application_page?slug='.$application->getSlug()) ?> 
    6565      <?php if ($application->getCountry()): ?> 
    6666        <?php echo flag_image_tag($application->getCountry()) ?> 
     
    6969    <div class="thumb_area"> 
    7070      <p><?php if ($application->getScreenshotPath()): ?> 
    71       <?php echo link_to(image_tag($application->getFullScreenshotPath(), 
    72                                    'alt=screenshot'), 
     71      <?php echo link_to(application_image_tag($application, 'alt=screenshot'), 
    7372                         '@application_page?slug='.$application->getSlug(), 
    7473                         'class=thumb_link') ?> 
  • trunk/apps/main/modules/applications/templates/tagsSuccess.php

    r2 r75  
    1010<?php end_slot() ?> 
    1111 
    12 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'),  
     12<?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 
    1313                            $page_title)) ?> 
    1414 
     
    1919 
    2020<div class="tags_cloud big_cloud"> 
    21   <?php echo tag_cloud($tags, '@application_home?tag=') ?> 
     21  <?php echo tag_cloud($tags, '@application_home?tag=%s') ?> 
    2222</div> 
  • trunk/apps/main/modules/companies/actions/actions.class.php

    r48 r75  
    99{ 
    1010 
    11   public function executeAdd() 
    12   { 
    13     $this->company = new Company(); 
    14     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    15     { 
    16       $this->updateFromRequest(); 
    17       parent::purgeObjectRelatedCache($this->company); 
    18       $this->getUser()->setFlash('notice', $this->__('Company added')); 
    19       $this->getUser()->setAttribute('from_company_creation', true, 'symfonians'); 
    20       $this->redirect('@company_connect_as_member?slug='.$this->company->getSlug()); 
    21     } 
    22   } 
    23  
    24   public function executeEdit() 
     11  /** 
     12   * Adds or edit a Company 
     13   * 
     14   * @param sfWebRequest $request 
     15   */ 
     16  public function executeEdit(sfWebRequest $request) 
     17  { 
     18    if (!is_null($request->getParameter('slug'))) 
     19    { 
     20      $company = $this->getFromSlug(); 
     21 
     22      $this->forward404If(is_null($company), sprintf('Company with slug "%s" not found', $request->getParameter('slug'))); 
     23 
     24      if (!$this->getUser()->isAdmin() && $company->getSubmitterId() != $this->getUser()->getId()) 
     25      { 
     26        $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record')); 
     27        $this->redirect('@company_page?slug='.$company->getSlug()); 
     28      } 
     29 
     30      $this->form = new CompanyForm($company); 
     31      $this->setTemplate('edit'); 
     32      $message = $this->__('Company updated'); 
     33      $redirect = '@company_page?slug=%s'; 
     34      $creation = false; 
     35    } 
     36    else 
     37    { 
     38      $company = new Company(); 
     39      $this->form = new CompanyForm(); 
     40      $this->setTemplate('add'); 
     41      $message = $this->__('Company added'); 
     42      $redirect = '@company_connect_as_member?slug=%s'; 
     43      $creation = true; 
     44    } 
     45 
     46    if ($request->isMethod('post')) 
     47    { 
     48      $submitter_id = $this->getUser()->isAdmin() && $company->getSubmitterId() ? $company->getSubmitterId() : $this->getUser()->getId(); 
     49      $params = array_merge($request->getParameter('company'), 
     50                            array('submitter_id' => $submitter_id)); 
     51      $this->form->bind($params, $request->getFiles('company')); 
     52 
     53      if (!$this->form->isValid() or is_null($company = $this->form->save())) 
     54      { 
     55        return sfView::SUCCESS; 
     56      } 
     57 
     58      /* @var $thumb sfValidatedThumb */ 
     59      if (!is_null($thumb = $this->form->getValue('logo_file'))) 
     60      { 
     61        $thumb->saveThumb('companies', $company, 'setLogoPath'); 
     62      } 
     63 
     64      parent::purgeObjectRelatedCache($company); 
     65 
     66      $this->getUser()->setFlash('notice', $this->__('Company updated')); 
     67      $this->redirect(sprintf($redirect, $company->getSlug())); 
     68    } 
     69  } 
     70 
     71  /** 
     72   * Connect to a company 
     73   * 
     74   * @param sfWebRequest $request 
     75   */ 
     76  public function executeConnect(sfWebRequest $request) 
    2577  { 
    2678    $this->company = $this->getFromSlug(); 
    2779 
    28     if (!$this->getUser()->isAdmin() && $this->company->getSubmitterId() != $this->getUser()->getId()) 
    29     { 
    30       $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record')); 
    31       $this->redirect('@company_page?slug='.$this->company->getSlug()); 
    32     } 
    33  
    34     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    35     { 
    36       $this->updateFromRequest(); 
    37       parent::purgeObjectRelatedCache($this->company); 
    38       $this->getUser()->setFlash('notice', $this->__('Company updated')); 
    39       $this->redirect('@company_page?slug='.$this->company->getSlug()); 
    40     } 
    41   } 
    42  
    43   public function executeEditConnection() 
    44   { 
    45     $this->company = $this->getFromSlug(); 
    46     $this->connection = CompanyPersonPeer::retrieveByPK($this->getRequestParameter('id')); 
    47     $this->forward404Unless($this->connection); 
    48  
    49     if ($this->getUser()->getId() != $this->connection->getUserId()) 
    50     { 
    51       $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record')); 
    52       $this->redirect('@company_page?slug='.$this->company->getSlug()); 
    53     } 
    54  
    55     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    56     { 
    57       $this->updateConnectionFromRequest(); 
    58       parent::purgeObjectRelatedCache($this->company); 
    59       $this->getUser()->setFlash('notice', $this->__('Your connection informations has been updated')); 
    60       $this->redirect('@company_page?slug='.$this->company->getSlug()); 
    61     } 
    62  
    63     $this->from_company_creation = false; 
    64     $this->form_action = '@company_edit_connection?slug='.$this->company->getSlug().'&id='.$this->connection->getId(); 
    65     $this->setTemplate('connect'); 
    66   } 
    67  
    68   public function executeConnect() 
    69   { 
    70     $this->company = $this->getFromSlug(); 
    71     $existing_connection = CompanyPersonPeer::retrieveByCompanyIdAndUserId($this->company->getId(), $this->getUser()->getId()); 
    72     if ($existing_connection) 
    73     { 
    74       $this->redirect('@company_edit_connection?slug='.$this->company->getSlug().'&id='.$existing_connection->getId()); 
    75     } 
    76     $this->connection = new CompanyPerson(); 
    77  
    78     // Where do we come from ? 
    79     $this->from_company_creation = $this->getUser()->getAttribute('from_company_creation', false, 'symfonians'); 
    80     $this->getUser()->getAttributeHolder()->remove('from_company_creation', 'symfonians'); 
    81  
    82     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    83     { 
    84       $this->updateConnectionFromRequest(); 
    85       parent::purgeObjectRelatedCache($this->connection); 
    86       $this->getUser()->setFlash('notice', $this->__('Your connection informations has been added')); 
    87       $this->redirect('@company_page?slug='.$this->company->getSlug()); 
    88     } 
    89  
    90     $this->form_action = '@company_connect_as_member?slug='.$this->company->getSlug(); 
    91   } 
    92  
    93   public function executeContact() 
     80    $this->forward404If(is_null($this->company), sprintf('Company with slug "%s" not found', $request->getParameter('slug'))); 
     81 
     82    if ($request->hasParameter('id')) 
     83    { 
     84      $connection = CompanyPersonPeer::retrieveByPK($request->getParameter('id')); 
     85 
     86      $this->forward404If(is_null($connection), 'Connection not found'); 
     87 
     88      if ($this->getUser()->getId() != $connection->getUserId()) 
     89      { 
     90        $this->getUser()->setFlash('warning', $this->__('You are not allowed to edit this record')); 
     91        $this->redirect('@company_page?slug='.$this->company->getSlug()); 
     92      } 
     93 
     94      $this->form = new CompanyPersonForm($connection); 
     95 
     96      $this->form_action = '@company_edit_connection?slug='.$this->company->getSlug().'&id='.$connection->getId(); 
     97    } 
     98    else 
     99    { 
     100      // Check for an existing connection if connected user 
     101      if (!is_null($this->getUser()->getId()) && $existingConnection = CompanyPersonPeer::retrieveByCompanyIdAndUserId($this->company->getId(), $this->getUser()->getId())) 
     102      { 
     103        $this->redirect('@company_edit_connection?slug='.$this->company->getSlug().'&id='.$existingConnection->getId()); 
     104      } 
     105 
     106      $connection = new CompanyPerson(); 
     107      $this->form = new CompanyPersonForm($connection); 
     108 
     109      $this->form_action = '@company_connect_as_member?slug='.$this->company->getSlug(); 
     110    } 
     111 
     112    if ($request->isMethod('post')) 
     113    { 
     114      $params = array_merge($request->getParameter('connection', array()), 
     115                            array('company_id' => $this->company->getId(), 
     116                                  'user_id'    => $this->getUser()->getId())); 
     117      $this->form->bind($params); 
     118 
     119      if ($this->form->isValid()) 
     120      { 
     121        $this->form->save(); 
     122        parent::purgeObjectRelatedCache($connection); 
     123 
     124        $this->getUser()->setFlash('notice', $this->__('Your connection informations has been added')); 
     125        $this->redirect('@company_page?slug='.$this->company->getSlug()); 
     126      } 
     127    } 
     128  } 
     129 
     130  /** 
     131   * Contact a company 
     132   * 
     133   * @param sfWebRequest $request 
     134   */ 
     135  public function executeContact(sfWebRequest $request) 
    94136  { 
    95137    $this->company = $this->getFromSlug(); 
    96138    $this->user = $this->getUser()->getGuardUser(); 
     139    $this->form = new CompanyContactForm(); 
    97140 
    98141    if (!$this->company->getAllowContact()) 
     
    102145    } 
    103146 
    104     if ($this->getRequest()->getMethod() == sfRequest::POST) 
    105     { 
    106       $this->getRequest()->setAttribute('company', $this->company); 
    107       $this->getRequest()->setAttribute('message', $this->getRequestParameter('body')); 
    108       $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'companyContact', 
    109                            $this->company->getEmail(), 
    110                            $this->getRequestParameter('subject'), 
    111                            array('from-name' => $this->user->getDisplayName(), 
    112                                  'reply-to'  => array('address' => $this->user->getEmail(), 
    113                                                       'name'    => $this->user->getDisplayName()))); 
    114       if (!$mailSent) 
    115       { 
    116         $this->getRequest()->setError('errors', $this->__('A server problem occured while attempting to send your message. Please try again later.')); 
    117         return sfView::SUCCESS; 
    118       } 
    119       $this->getUser()->setFlash('notice', $this->__('Your message has been sent to %company%', 
    120                                           array('%company%' => $this->company->getName()))); 
    121       $this->redirect('@company_page?slug='.$this->company->getSlug()); 
    122     } 
    123   } 
    124  
    125   public function executeDelete() 
     147    if ($request->isMethod('post')) 
     148    { 
     149      $this->form->bind($request->getParameter('contact')); 
     150 
     151      if ($this->form->isValid()) 
     152      { 
     153        $this->getRequest()->setAttribute('company', $this->company); 
     154        $this->getRequest()->setAttribute('message', $this->getRequestParameter('body')); 
     155        $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'companyContact', 
     156                             $this->company->getEmail(), 
     157                             $this->getRequestParameter('subject'), 
     158                             array('from-name' => $this->user->getDisplayName(), 
     159                                   'reply-to'  => array('address' => $this->user->getEmail(), 
     160                                                        'name'    => $this->user->getDisplayName()))); 
     161        if (!$mailSent) 
     162        { 
     163          $this->getRequest()->setError('errors', $this->__('A server problem occured while attempting to send your message. Please try again later.')); 
     164          return sfView::SUCCESS; 
     165        } 
     166 
     167        $this->getUser()->setFlash('notice', $this->__('Your message has been sent to %company%', 
     168                                            array('%company%' => $this->company->getName()))); 
     169        $this->redirect('@company_page?slug='.$this->company->getSlug()); 
     170      } 
     171    } 
     172  } 
     173 
     174  public function executeDelete(sfWebRequest $request) 
    126175  { 
    127176    $this->company = $this->getFromSlug(); 
     
    139188  } 
    140189 
    141   public function executeDetails(
     190  public function executeDetails(sfWebRequest $request
    142191  { 
    143192    $this->company = $this->getFromSlug(); 
     
    180229  } 
    181230 
    182   public function executeHome(
     231  public function executeHome(sfWebRequest $request
    183232  { 
    184233    if ($this->getRequest()->hasParameter('commit') && $this->getRequestParameter('country')) 
     
    209258  } 
    210259 
    211   public function executeIndex(
     260  public function executeIndex(sfWebRequest $request
    212261  { 
    213262    $this->forward('companies', 'home'); 
    214263  } 
    215264 
    216   protected function getFromSlug($peer_method = null) 
    217   { 
    218     $slug = $this->getRequestParameter('slug'); 
    219     $c = new Criteria; 
     265  /** 
     266   * Retrieves Company object from slug, if any 
     267   * 
     268   * @return Company|null 
     269   */ 
     270  protected function getFromSlug() 
     271  { 
     272    if (is_null($slug = $this->getRequestParameter('slug'))) 
     273    { 
     274      return null; 
     275    } 
     276 
     277    $c = new Criteria(); 
     278 
    220279    $c->addJoin(CompanyPeer::SUBMITTER_ID, sfGuardUserPeer::ID, Criteria::LEFT_JOIN); 
    221280    $c->add(CompanyPeer::SLUG, $slug); 
    222     $company = CompanyPeer::doSelectOne($c); 
    223     $this->forward404Unless($company, sprintf('Unable to retrieve company "%s"',$slug)); 
    224     return $company; 
    225   } 
    226  
    227   public function handleErrorAdd() 
    228   { 
    229     $this->company = new Company(); 
    230     return sfView::SUCCESS; 
    231   } 
    232  
    233   public function handleErrorEdit() 
    234   { 
    235     $this->company = $this->getFromSlug(); 
    236     return sfView::SUCCESS; 
    237   } 
    238  
    239   public function handleErrorConnect() 
    240   { 
    241     $this->connection = new CompanyPerson(); 
    242     $this->company = $this->getFromSlug(); 
    243     $this->from_company_creation = $this->getRequestParameter('from_company_creation'); 
    244     $this->form_action = '@company_connect_as_member?slug='.$this->company->getSlug(); 
    245     return sfView::SUCCESS; 
    246   } 
    247  
    248   public function handleErrorEditConnection() 
    249   { 
    250     $this->company = $this->getFromSlug(); 
    251     $this->connection = CompanyPersonPeer::retrieveByPK($this->getRequestParameter('id')); 
    252     $this->forward404Unless($this->connection); 
    253     $this->from_company_creation = false; 
    254     $this->form_action = '@company_edit_connection?slug='.$this->company->getSlug().'&id='.$this->connection->getId(); 
    255     $this->setTemplate('connect'); 
    256     return sfView::SUCCESS; 
    257   } 
    258  
    259   public function handleErrorContact() 
    260   { 
    261     $this->company = $this->getFromSlug(); 
    262     return sfView::SUCCESS; 
     281 
     282    return CompanyPeer::doSelectOne($c); 
    263283  } 
    264284 
  • trunk/apps/main/modules/companies/actions/components.class.php

    r66 r75  
    99  public function executeFilterForm() 
    1010  { 
    11     $this->form = new CountrySelectorForm(); 
     11    $this->form = new CountrySelectorForm(CompanyPeer::retrieveCountries()); 
    1212    $this->form->setDefault('country', $this->getRequestParameter('country')); 
    1313  } 
  • trunk/apps/main/modules/companies/templates/_form.php

    r64 r75  
    11<?php use_helper('Object', 'Validation') ?> 
    22 
    3 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'),  
     3<?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 
    44                            $title)) ?> 
    55 
     
    1414    <fieldset> 
    1515      <legend><?php echo __('Company informations') ?></legend> 
    16       <div class="form-row required"> 
    17         <label for="name"><?php echo __('Company name') ?></label
    18         <?php echo object_input_tag($company, 'getName', 'name=company[name]', $sf_params->get('company[name]')) ?> 
    19         <?php echo form_error('company[name]') ?> 
     16      <div class="form-row required <?php echo $form['name']->hasError() ? 'field_error' : '' ?>"> 
     17        <?php echo $form['name']->renderLabel(__('Company name')) ?
     18        <?php echo $form['name']->render() ?> 
     19        <?php echo $form['name']->renderError() ?> 
    2020      </div> 
    21       <div class="form-row required"> 
    22         <label for="email"><?php echo __('Email') ?></label
    23         <?php echo object_input_tag($company, 'getEmail', 'name=company[email]', $sf_params->get('company[email]')) ?> 
    24         <?php echo form_error('company[email]') ?> 
     21      <div class="form-row required <?php echo $form['email']->hasError() ? 'field_error' : '' ?>"> 
     22        <?php echo $form['email']->renderLabel() ?
     23        <?php echo $form['email']->render() ?> 
     24        <?php echo $form['email']->renderError() ?> 
    2525      </div> 
    2626      <div class="form-row"> 
    27         <?php echo object_checkbox_tag($company, 'getAllowContact', 'name=company[allow_contact]', $sf_params->get('company[allow_contact]')) ?> 
    28         <?php echo label_for('allow_contact', __('Allow contact by email'), 'class=left') ?> 
    29         <?php echo form_error('company[allow_contact]') ?> 
     27        <?php echo $form['allow_contact']->render() ?> 
     28        <?php echo $form['allow_contact']->renderLabel(__('Allow contact by email'), array('class' => 'left')) ?> 
    3029      </div> 
    31       <div class="form-row"> 
    32         <label for="logo_path"><?php echo __('Logo') ?></label> 
    33         <?php echo input_file_tag('company[logo_path]') ?> 
    34         <?php echo form_error('company[logo_path]') ?> 
    35       </div> 
    36       <div class="form-row"> 
    37         <label for="summary"><?php echo __('Summary') ?></label> 
    38         <?php echo object_textarea_tag($company, 'getSummary', 'name=company[summary]', $sf_params->get('company[summary]')) ?> 
    39         <?php echo form_error('company[summary]') ?> 
    40       </div> 
    41       <div class="form-row"> 
    42         <label for="homepage"><?php echo __('Company homepage') ?></label> 
    43         <?php echo object_input_tag($company, 'getHomepage', 'name=company[homepage]', $sf_params->get('company[homepage]')) ?> 
    44         <?php echo form_error('company[homepage]') ?> 
    45       </div> 
    46       <div class="form-row"> 
    47         <label for="phone"><?php echo __('Phone') ?></label> 
    48         <?php echo object_input_tag($company, 'getPhone', 'name=company[phone]', $sf_params->get('company[phone]')) ?> 
    49         <?php echo form_error('company[phone]') ?> 
    50       </div> 
     30      <?php echo $form['logo_file']->renderRow(array(), __('Logo')) ?> 
     31      <?php echo $form['summary']->renderRow() ?> 
     32      <?php echo $form['homepage']->renderRow(array(), __('Company homepage')) ?> 
     33      <?php echo $form['phone']->renderRow() ?> 
    5134    </fieldset> 
    5235  </div> 
     
    5740        <?php echo __('By providing your localization, people will be able to find you in their area.') ?> 
    5841      </p> 
    59       <div class="form-row required"> 
    60         <label for="country"><?php echo __('Country') ?></label
    61         <?php echo object_select_country_tag($company, 'getCountry', 'name=company[country] include_custom='.__('Select a country'), $sf_params->getRawValue()->get('company[country]')) ?> 
    62         <?php echo form_error('company[country]') ?> 
     42      <div class="form-row required <?php echo $form['country']->hasError() ? 'field_error' : '' ?>"> 
     43        <?php echo $form['country']->renderLabel() ?
     44        <?php echo $form['country']->render() ?> 
     45        <?php echo $form['country']->renderError() ?> 
    6346      </div> 
    64       <div class="form-row"> 
    65         <label for="address"><?php echo __('Street address') ?></label> 
    66         <?php echo object_textarea_tag($company, 'getAddress', 'name=company[address] style=height:60px', $sf_params->get('company[address]')) ?> 
    67         <?php echo form_error('company[address]') ?> 
    68       </div> 
    69       <div class="form-row"> 
    70         <label for="zip"><?php echo __('Zip') ?></label> 
    71         <?php echo object_input_tag($company, 'getZip', 'name=company[zip]', $sf_params->get('company[zip]')) ?> 
    72         <?php echo form_error('company[zip]') ?> 
    73       </div> 
    74       <div class="form-row"> 
    75         <label for="city"><?php echo __('City') ?></label> 
    76         <?php echo object_input_tag($company, 'getCity', 'name=company[city]', $sf_params->get('company[city]')) ?> 
     47      <?php echo $form['address']->renderRow(array(), __('Street address')) ?> 
     48      <?php echo $form['zip']->renderRow() ?> 
     49      <div class="form-row required <?php echo $form['city']->hasError() ? 'field_error' : '' ?>"> 
     50        <?php echo $form['city']->renderLabel() ?> 
     51        <?php echo $form['city']->render() ?> 
     52        <?php echo $form['city']->renderError() ?> 
    7753        <div class="form_help"> 
    7854          <?php echo __('Please enter only one city name. If the company have distinct implementations, please create one company sheet per location.') ?> 
    7955        </div> 
    80         <?php echo form_error('company[city]') ?> 
    8156      </div> 
    82       <div class="form-row"> 
    83         <label for="state"><?php echo __('State (if applicable)') ?></label> 
    84         <?php echo object_input_tag($company, 'getState', 'name=company[state]', $sf_params->get('company[state]')) ?> 
    85         <?php echo form_error('company[state]') ?> 
    86       </div> 
     57      <?php echo $form['state']->renderRow(array(), __('State (if applicable)')) ?> 
    8758    </fieldset> 
    8859  </div> 
    8960  <div class="form-row" style="text-align:center;clear:left;"> 
    9061    <p> 
    91       <?php echo submit_tag($submit_label) ?> 
     62      <?php echo $form['id'] ?> 
     63      <?php echo $form['_csrf_token'] ?> 
     64      <input type="submit" value="<?php echo $submit_label ?>"/> 
    9265    </p> 
    9366  </div> 
  • trunk/apps/main/modules/companies/templates/addSuccess.php

    r2 r75  
    55 
    66<?php include_partial('companies/form', 
    7                       array('company'      => $company, 
     7                      array('company'      => $form->getObject(), 
     8                            'form'         => $form, 
    89                            'title'        => __('Add a company'), 
    910                            'form_route'   => '@company_add', 
  • trunk/apps/main/modules/companies/templates/connectSuccess.php

    r64 r75  
    22 
    33<?php slot('page_title') ?> 
    4   <?php $page_title = __('Connect to %company%',  
     4  <?php $page_title = __('Connect to %company%', 
    55                         array('%company%' => $company->getName())) ?> 
    66  <?php echo $page_title ?> 
     
    99<?php slot('sidebar') ?> 
    1010  <?php if ($company->getLogoPath()): ?> 
    11     <?php $image = image_tag($company->getFullLogoPath(),  
     11    <?php $image = company_image_tag($company, 
    1212                             'class=company_logo alt='.$company->getName().' logo') ?> 
    1313    <?php if ($company->getHomepage()): ?> 
     
    1919<?php end_slot() ?> 
    2020 
    21 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'),  
     21<?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 
    2222                            array($company->getName(), '@company_page?slug='.$company->getSlug()), 
    2323                            $page_title)) ?> 
     
    2525<h2><?php echo $page_title ?><span class="gradient">&nbsp;</span></h2> 
    2626 
    27 <?php if ($from_company_creation): ?> 
    28   <p><?php echo __('Now that the company has been added, please provide some informations on how you are related to it') ?></p> 
    29 <?php else: ?> 
    30   <p><?php echo __('If you are related to the %company% company, please fill and submit the form below.', 
    31                    array('%company%' => $company->getName())) ?></p> 
    32 <?php endif; ?> 
     27<p><?php echo __('If you are related to the %company% company, please fill and submit the form below.', 
     28                 array('%company%' => sprintf('<em>%s</em>', $company->getName()))) ?></p> 
    3329 
    3430<p class="form-info"> 
     
    4036    <fieldset> 
    4137      <legend><?php echo __('Connection informations') ?></legend> 
    42       <div class="form-row required"> 
    43         <label for="role"><?php echo __('Your role') ?></label
    44         <?php echo object_input_tag($connection, 'getRole', 'name=connection[role]', $sf_params->get('connection[role]')) ?> 
    45         <?php echo form_error('connection[role]') ?> 
     38      <div class="form-row required <?php echo $form['role']->hasError() ? 'field_error' : '' ?>"> 
     39        <?php echo $form['role']->renderLabel(__('Your role')) ?
     40        <?php echo $form['role']->render() ?> 
     41        <?php echo $form['role']->renderError() ?> 
    4642      </div> 
    4743      <div class="form-row"> 
    48         <label for="description"><?php echo __('Description of your relation') ?></label
    49         <?php echo object_textarea_tag($connection, 'getDescription', 'name=connection[description]', $sf_params->get('connection[description]')) ?> 
    50         <?php echo form_error('connection[description]') ?> 
     44        <?php echo $form['description']->renderLabel(__('Description of your relation')) ?
     45        <?php echo $form['description']->render() ?> 
     46        <?php echo $form['description']->renderError() ?> 
    5147      </div> 
    5248    </fieldset> 
     
    5551    <fieldset> 
    5652      <legend><?php echo __('Timeline') ?></legend> 
    57       <div class="form-row"> 
    58         <label for="started_at"><?php echo __('Start date of activity (yyyy-mm-dd)') ?></label> 
    59         <?php echo object_input_date_tag($connection, 'getStartedAt', 'name=connection[started_at] format=Y-MM-dd rich=true class=date_select', $sf_params->get('connection[started_at]')) ?> 
    60         <?php echo form_error('connection[started_at]') ?> 
    61       </div> 
    62       <div class="form-row"> 
    63         <label for="ended_at"><?php echo __('End date of activity (yyyy-mm-dd)') ?></label> 
    64         <?php echo object_input_date_tag($connection, 'getEndedAt', 'name=connection[ended_at] format=Y-MM-dd rich=true class=date_select', $sf_params->get('connection[ended_at]')) ?> 
    65         <?php echo form_error('connection[ended_at]') ?> 
     53      <div class="date_select"> 
     54        <div class="form-row"> 
     55          <?php echo $form['started_at']->renderLabel(__('Start date of activity')) ?> 
     56          <?php echo $form['started_at']->render() ?> 
     57          <?php echo $form['started_at']->renderError() ?> 
     58        </div> 
     59        <div class="form-row"> 
     60          <?php echo $form['ended_at']->renderLabel(__('End date of activity')) ?> 
     61          <?php echo $form['ended_at']->render() ?> 
     62          <?php echo $form['ended_at']->renderError() ?> 
     63        </div> 
    6664      </div> 
    6765    </fieldset> 
     
    6967  <div class="form-row" style="text-align:center;clear:left;"> 
    7068    <p> 
    71       <?php if ($from_company_creation): ?> 
    72         <?php $label = __('Skip this step') ?> 
    73       <?php else: ?> 
    74         <?php $label = __('Cancel') ?> 
    75       <?php endif; ?> 
    76       <?php echo input_hidden_tag('from_company_creation', $from_company_creation) ?> 
    77       <?php echo button_to($label, '@company_page?slug='.$company->getSlug()) ?> 
    78       <?php echo submit_tag(__('Connect your profile to this company')) ?> 
     69      <?php echo $form['_csrf_token'] ?> 
     70      <?php echo $form['id'] ?> 
     71      <input type="button" value="<?php echo __('Cancel') ?>" onclick="document.location='<?php echo url_for('@company_page?slug='.$company->getSlug()) ?>';return false"/> 
     72      <input type="submit" name="commit" value="<?php echo __('Connect your profile to this company') ?>"/> 
    7973    </p> 
    8074  </div> 
  • trunk/apps/main/modules/companies/templates/contactSuccess.php

    r64 r75  
    77<?php end_slot() ?> 
    88 
    9 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'),  
     9<?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 
    1010                            array($company->getName(), '@company_page?slug='.$company->getSlug()), 
    1111                            $page_title)) ?> 
     
    2121    <legend><?php echo __('Fill the form then send your message') ?></legend> 
    2222    <div class="form-row"> 
    23       <?php echo __('From: %sender%',  
     23      <?php echo __('From: %sender%', 
    2424                    array('%sender%' => $sf_user->getGuardUser()->getEmailSender())) ?> 
    2525    </div> 
    26     <div class="form-row required"> 
    27       <?php echo label_for('subject', __('Subject')) ?> 
    28       <?php echo input_tag('subject', $sf_params->get('subject'), 'id=subject size=40') ?> 
    29       <?php echo form_error('subject') ?> 
     26    <div class="form-row required <?php echo $form['subject']->hasError() ? 'field_error' : '' ?>"> 
     27      <?php echo $form['subject']->renderLabel() ?> 
     28      <?php echo $form['subject']->render() ?> 
     29      <?php echo $form['subject']->renderError() ?> 
    3030    </div> 
    31     <div class="form-row required"> 
    32       <?php echo label_for('body', __('Message')) ?> 
    33       <?php echo textarea_tag('body', $sf_params->get('body'), 'id=body cols=40 rows=10') ?> 
    34       <?php echo form_error('body') ?> 
     31    <div class="form-row required <?php echo $form['body']->hasError() ? 'field_error' : '' ?>"> 
     32      <?php echo $form['body']->renderLabel() ?> 
     33      <?php echo $form['body']->render() ?> 
     34      <?php echo $form['body']->renderError() ?> 
    3535    </div> 
    36     <div class="form-row required"> 
    37       <?php echo label_for('captcha', __('Security code')) ?> 
    38       <?php echo input_tag('captcha', null, 'id=captcha style=width:150px'); ?> 
    39       <?php echo cryptographp_picture() ?> 
    40       <?php echo cryptographp_reload() ?> 
    41       <?php echo form_error('captcha') ?> 
     36    <div class="form-row required <?php echo $form['captcha']->hasError() ? 'field_error' : '' ?>"> 
     37      <?php echo $form['captcha']->renderLabel(__('Security code')) ?> 
     38      <?php echo $form['captcha']->render() ?> 
     39      <?php echo $form['captcha']->renderError() ?> 
    4240    </div> 
    4341    <div class="form-row"> 
    44     <?php echo submit_tag(__('Send your message to %company%',  
    45                                array('%company%' => $company->getName()))) ?> 
     42      <input type="submit" value="<?php echo __('Send your message to %company%', array('%company%' => $company->getName())) ?>" /> 
    4643    </div> 
    4744  </fieldset> 
  • trunk/apps/main/modules/companies/templates/detailsSuccess.php

    r2 r75  
    88<?php slot('sidebar') ?> 
    99  <?php if ($company->getLogoPath()): ?> 
    10     <?php $image = image_tag($company->getFullLogoPath(),  
    11                              'class=company_logo alt='.$company->getName().' logo') ?> 
     10    <?php $image = company_image_tag($company, 'class=company_logo alt='.$company->getName().' logo') ?> 
    1211    <?php if ($company->getHomepage()): ?> 
    1312      <?php echo link_to($image, $company->getHomepage()) ?> 
     
    2322                                               $company->getsfGuardUser()->getUsername(), 
    2423                                               $company->getSlug())) ?>) 
    25     <?php endif; ?>  
     24    <?php endif; ?> 
    2625  </small></p> 
    2726  <?php if ($user_is_submitter or $sf_user->isAdmin()): ?> 
     
    2928    <ul class="admin_actions"> 
    3029      <li> 
    31         <?php echo link_to(__('Edit this company informations'),  
     30        <?php echo link_to(__('Edit this company informations'), 
    3231                         '@company_edit?slug='.$company->getSlug(), 
    3332                         'class=bigedit') ?></li> 
    3433      <li> 
    35         <?php echo link_to(__('Delete this company'),  
     34        <?php echo link_to(__('Delete this company'), 
    3635                         '@company_delete?slug='.$company->getSlug(), 
    3736                         'class=bigdelete confirm='.__('Are you sure?')) ?></li> 
     
    4039  <?php if ($company->getAllowContact()): ?> 
    4140    <h3><?php echo __('Want to get in touch?') ?></h3> 
    42     <?php echo big_button_to(__('Contact this company'),  
    43                              '@company_contact?slug='.$company->getSlug(),  
     41    <?php echo big_button_to(__('Contact this company'), 
     42                             '@company_contact?slug='.$company->getSlug(), 
    4443                             'id=bt_companycontact') ?> 
    4544  <?php endif; ?> 
     
    5453<div class="fiftypercent vcard"> 
    5554 
    56   <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'),  
     55  <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 
    5756                              $page_title)) ?> 
    58    
    5957  <h2> 
    6058    <span class="fn org"><?php echo $page_title ?></span> 
     
    6260    <span class="gradient">&nbsp;</span> 
    6361  </h2> 
    64    
     62 
    6563  <?php include_partial('companies/entry', 
    6664                        array('company'      => $company, 
    6765                              'sf_cache_key' => $company->getSlug())) ?> 
    68    
    6966</div> 
    7067 
    7168<div class="fiftypercent"> 
    72    
     69 
    7370  <div class="related_people"> 
    7471    <h3 class="col2"><?php echo __('Active people related with this company') ?></h3> 
     
    116113    </p> 
    117114  </div> 
    118    
     115 
    119116  <div class="related_applications"> 
    120117    <h3><?php echo __('Applications related to this company') ?></h3> 
     
    125122        <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 
    126123          <td class="mini_thumb_cell"> 
    127             <?php echo link_to(image_tag($company_application->getApplication()->getFullScreenshotPath(), 
     124            <?php echo link_to(application_image_tag($company_application->getApplication(), 
    128125                                         'class=mini_thumb'), 
    129126                               '@application_page?slug='.$company_application->getApplication()->getSlug(), 
     
    153150    <?php endif; ?> 
    154151  </div> 
    155    
     152 
    156153  <div class="related_jobs"> 
    157154    <h3><?php echo __('Jobs proposed by this company') ?></h3> 
     
    177174    <?php endif; ?> 
    178175  </div> 
    179    
     176 
    180177</div> 
  • trunk/apps/main/modules/companies/templates/editSuccess.php

    r2 r75  
    11<?php slot('page_title') ?> 
    2   <?php $page_title = __('Edit %name%',  
    3                          array('%name%' => $company->getRawValue()->getName())) ?> 
     2  <?php $page_title = __('Edit %name%', 
     3                         array('%name%' => $form->getObject()->getName())) ?> 
    44  <?php echo $page_title ?> 
    55<?php end_slot() ?> 
    66 
    77<?php include_partial('companies/form', 
    8                       array('company'      => $company, 
     8                      array('company'      => $form->getObject(), 
     9                            'form'         => $form, 
    910                            'title'        => $page_title, 
    10                             'form_route'   => '@company_edit?slug='.$company->getSlug(), 
     11                            'form_route'   => '@company_edit?slug='.$form->getObject()->getSlug(), 
    1112                            'submit_label' => __('Update company informations'))) ?> 
  • trunk/apps/main/modules/companies/templates/homeSuccess.php

    r2 r75  
    4141        <td style="width:10%;text-align:right"> 
    4242          <?php if ($company->getLogoPath()): ?> 
    43           <?php echo link_to(image_tag($company->getFullLogoPath(), 
    44                                        'alt=logo style=max-height:40px;max-width:200px'), 
     43          <?php echo link_to(company_image_tag($company, 'alt=logo style=max-height:40px;max-width:200px'), 
    4544                             '@company_page?slug='.$company->getSlug(), 
    4645                             'class=thumb_link') ?> 
  • trunk/apps/main/modules/feeds/actions/actions.class.php

    r2 r75  
    2929   * @param  BaseObject  $object 
    3030   * @return sfFeedItem 
     31   * @throws sfActionException if no parameters getter is not found for $object 
    3132   */ 
    3233  protected function generateFeedItemFromObject(BaseObject $object) 
     
    3435    $item = new sfFeedItem(); 
    3536    $params_getter = sprintf('get%sItemParameters', get_class($object)); 
     37 
    3638    if (!method_exists($this, $params_getter)) 
    3739    { 
     
    3941                                          $params_getter)); 
    4042    } 
     43 
    4144    $params = $this->$params_getter($object); 
    4245    $params = array_merge($params, 
    4346                          array('pubDate'  => $object->getCreatedAt(null), 
    4447                                'uniqueId' => md5(get_class($object).$object->getId()))); 
     48 
    4549    $item->initialize($params); 
     50 
    4651    return $item; 
    4752  } 
  • trunk/apps/main/modules/home/templates/indexSuccess.php

    r2 r75  
    1515    </h3> 
    1616    <?php if ($featured_application->getScreenshotPath()): ?> 
    17       <?php $image = image_tag($featured_application->getFullScreenshotPath()
    18                                'class=featured_app_screenshot alt='.$featured_application->getName().' preview') ?> 
     17      <?php $image = application_image_tag($featured_application
     18                                           'class=featured_app_screenshot alt='.$featured_application->getName().' preview') ?> 
    1919      <?php echo link_to_application($featured_application, 
    2020                                     array('label' => $image ? $image : $featured_application->getName())) ?> 
  • trunk/apps/main/modules/jobs/actions/actions.class.php

    r48 r75  
    6868  } 
    6969 
    70   public function executeHome(
     70  public function executeHome(sfWebRequest $request
    7171  { 
    7272    $pager_route_params = array(); 
    73      
    74     $country = $this->getRequestParameter('country'); 
    75     $city    = urldecode($this->getRequestParameter('city')); 
    76     $company = urldecode($this->getRequestParameter('company')); 
    77      
     73 
     74    $country = $request->getParameter('country'); 
     75    $city    = urldecode($request->getParameter('city')); 
     76    $company = urldecode($request->getParameter('company')); 
     77 
    7878    $c = new Criteria(); 
    79      
     79 
    8080    if ($country) 
    8181    { 
     
    9595      $this->company_name = $company->getName(); 
    9696      $c->add(JobPeer::COMPANY_ID, $company->getId()); 
    97       $pager_route_params['company'] = $company
    98     } 
    99  
    100     if ($this->getRequestParameter('teleworking') == 1) 
     97      $pager_route_params['company'] = $company->getSlug()
     98    } 
     99 
     100    if ($request->getParameter('teleworking') == 1) 
    101101    { 
    102102      $c->add(JobPeer::TELEWORKING, true); 
     
    107107 
    108108    // Redirect with a nicer url 
    109     if ($this->getRequest()->hasParameter('commit')) 
     109    if ($request->getParameter('commit')) 
    110110    { 
    111111      $this->redirect($this->pager_route); 
     
    124124 
    125125    // Feed mode handling 
    126     if ($this->hasRequestParameter('feed')) 
     126    if ($request->getParameter('feed')) 
    127127    { 
    128128      $this->renderHomeAsFeed($c); 
     
    137137                                       // meanwhile, cache is your friend :-/ 
    138138    $pager->setCriteria($c); 
    139     $pager->setPage($this->getRequestParameter('page', 1)); 
     139    $pager->setPage($request->getParameter('page', 1)); 
    140140    $pager->init(); 
    141141    $this->pager = $pager; 
  • trunk/apps/main/modules/jobs/actions/components.class.php

    r2 r75  
    22/** 
    33 * Jobs components 
    4  *  
     4 * 
    55 */ 
    66class jobsComponents extends sfComponents 
    77{ 
    88 
     9  /** 
     10   * Retrieves and displays cities in a given country 
     11   * 
     12   */ 
    913  public function executeCountryCities() 
    1014  { 
     
    1620    $c->addGroupByColumn(JobPeer::CITY); 
    1721    $c->addAscendingOrderByColumn(JobPeer::CITY); 
     22 
    1823    $rs = JobPeer::doSelectRS($c); 
     24 
    1925    $cities = array(); 
     26 
    2027    while ($rs->next()) 
    2128    { 
     
    2734      } 
    2835    } 
     36 
    2937    $this->cities = $cities; 
    3038  } 
    31    
     39 
     40  /** 
     41   * Filter form 
     42   * 
     43   */ 
    3244  public function executeFilterForm() 
    3345  { 
    34     $this->countries = JobPeer::retrieveCountries(); 
    35     $this->companies = JobPeer::retrieveCompanies($this->getRequestParameter('country')); 
     46    $this->form = new JobFilterForm(JobPeer::retrieveCountries(), JobPeer::retrieveCompanies($this->getRequestParameter('country'))); 
     47    $this->form->setDefault('country', $this->getRequestParameter('country')); 
     48    $this->form->setDefault('company', $this->getRequestParameter('company')); 
    3649  } 
    37    
     50 
     51  /** 
     52   * Displays recent job offers 
     53   * 
     54   */ 
    3855  public function executeRecent() 
    3956  { 
  • trunk/apps/main/modules/jobs/templates/_entry.php

    r2 r75  
    33<p><strong> 
    44  <?php if ($job->getCompanyId()): ?> 
    5     <?php echo __('Proposed by the %company% company %time% ago.',  
     5    <?php echo __('Proposed by the %company% company %time% ago.', 
    66                  array('%company%' => link_to($job->getCompany(), 
    77                                               '@company_page?slug='.$job->getCompany()->getSlug()), 
    88                        '%time%'    => my_distance_of_time_in_words($job->getCreatedAt(null), time()))) ?> 
    99  <?php elseif ($job->getContactId()): ?> 
    10     <?php echo __('Proposed by %name% on %date%.',  
     10    <?php echo __('Proposed by %name% on %date%.', 
    1111                  array('%name%' => link_to_person($job->getsfGuardUser()), 
    1212                        '%date%' => format_date($job->getCreatedAt()))) ?> 
    1313  <?php endif; ?> 
    1414  <?php if ($job->getExpiresAt()): ?> 
    15     <?php echo __('Offer will expire on %date%.',  
     15    <?php echo __('Offer will expire on %date%.', 
    1616                  array('%date%' => format_date($job->getExpiresAt(), 'MMMM, d yyyy'))) ?> 
    1717  <?php endif; ?> 
     
    4141  <h3> 
    4242    <?php if ($job->getCompany()->getLogoPath()): ?> 
    43       <?php echo image_tag($job->getCompany()->getFullLogoPath(),  
    44                            'style=height:16px;vertical-align:baseline') ?> 
     43      <?php echo company_image_tag($job->getCompany(), 
     44                                   'style=height:16px;vertical-align:baseline') ?> 
    4545    <?php endif; ?> 
    4646    <?php echo $job->getCompany()->getName() ?> 
     
    5151  <h3> 
    5252    <?php if ($job->getsfGuardUser()->getAvatarPath()): ?> 
    53       <?php echo image_tag($job->getsfGuardUser()->getFullAvatarPath('small16')) ?> 
     53      <?php echo person_image_tag($job->getsfGuardUser(), 'small16') ?> 
    5454    <?php endif; ?> 
    5555    <?php echo $job->getsfGuardUser()->getDisplayName() ?> 
  • trunk/apps/main/modules/jobs/templates/_filterForm.php

    r64 r75  
    11<form action="<?php echo url_for('@jobs_home') ?>" method="get" id="country_form"> 
    22  <p> 
    3     <?php echo label_for('country', __('Filter by country')) ?> 
    4     <?php echo select_tag('country', 
    5                           options_for_select($countries, 
    6                                              $sf_request->getParameter('country'), 
    7                                              array('include_custom' => __('All countries')))) ?> 
     3    <?php echo $form['country']->renderLabel(__('Filter by country')) ?> 
     4    <?php echo $form['country']->render() ?> 
    85  </p> 
    96  <p> 
    10     <?php echo label_for('company', __('Filter by company')) ?> 
    11     <?php echo select_tag('company', 
    12                           options_for_select($companies, 
    13                                              $sf_request->getParameter('company'), 
    14                                              array('include_custom' => __('All companies')))) ?> 
     7    <?php echo $form['company']->renderLabel(__('Filter by company')) ?> 
     8    <?php echo $form['company']->render() ?> 
    159  </p> 
    1610  <p> 
    17     <?php echo checkbox_tag('teleworking', 1, $sf_request->hasParameter('teleworking'), 'id=teleworking') ?
    18     <?php echo label_for('teleworking', __('Possible teleworking'), 'class=left') ?
     11    <input type="checkbox" value="1" <?php echo $sf_request->hasParameter('teleworking') ? 'checked="checked"' : '' ?> name="teleworking" id="teleworking"
     12    <label for="teleworking" class="left"><?php echo __('Possible teleworking') ?></label
    1913  </p> 
    2014  <p> 
    21     <?php echo submit_tag(__('Filter')) ?
     15    <input type="submit" value="<?php echo __('Filter') ?>" name="commit"/
    2216  </p> 
    2317</form> 
  • trunk/apps/main/modules/maps/templates/CompanySuccess.php

    r2 r75  
    33<?php $company = $object; unset($object) ?> 
    44<?php if ($company->getLogoPath()): ?> 
    5   <?php echo image_tag($company->getFullLogoPath('small48'), 'style=max-width:100px;max-height:60px;padding-bottom:5px') ?> 
     5  <?php echo company_image_tag($company, 'style=max-width:100px;max-height:60px;padding-bottom:5px') ?> 
    66<?php endif; ?> 
    77<h3 style="padding:0;margin:0"> 
  • trunk/apps/main/modules/maps/templates/sfGuardUserSuccess.php

    r2 r75  
    33<?php $person = $object; unset($object) ?> 
    44<?php if ($person->getAvatarPath()): ?> 
    5   <?php echo image_tag($person->getFullAvatarPath('small48'), 'style=float:left;margin:0 5px 2px 0') ?> 
     5  <?php echo person_image_tag($person, 'small48', 'style=float:left;margin:0 5px 2px 0') ?> 
    66<?php endif; ?> 
    77<h3 style="padding:0;margin:0"> 
  • trunk/apps/main/modules/people/actions/actions.class.php

    r48 r75  
    88class peopleActions extends myActions 
    99{ 
    10  
    11   public function executeContact() 
     10  /** 
     11   * Contact action 
     12   * 
     13   */ 
     14  public function executeContact(sfWebRequest $request) 
    1215  { 
    1316    $this->recipient = $this->getFromSlug('to_username'); 
     17    $this->form = new PersonContactForm(); 
    1418 
    1519    if (!$this->recipient->getAllowContact(true)) 
     
    3842  } 
    3943 
    40   public function executeDashboard() 
     44  /** 
     45   * Dashboard action 
     46   * 
     47   */ 
     48  public function executeDashboard(sfWebRequest $request) 
    4149  { 
    4250    $user = $this->getUser()->getGuardUser() 
     
    6371  } 
    6472 
    65   public function executeDelete() 
     73  /** 
     74   * Deletion action 
     75   * 
     76   */ 
     77  public function executeDelete(sfWebRequest $request) 
    6678  { 
    6779    $this->user = $this->getFromSlug(); 
     
    8092  } 
    8193 
    82   public function executeDetails() 
     94  /** 
     95   * Profile details action 
     96   * 
     97   */ 
     98  public function executeDetails(sfWebRequest $request) 
    8399  { 
    84100    $this->user = $this->getFromSlug('username'); 
     
    93109  } 
    94110 
    95   public function executeHome() 
     111  /** 
     112   * People homepage action 
     113   * 
     114   */ 
     115  public function executeHome(sfWebRequest $request) 
    96116  { 
    97117    $pager_route_params = array(); 
     
    142162  } 
    143163 
    144   public function executeDeleteRecommendation() 
     164  /** 
     165   * Recommendation deletion action 
     166   * 
     167   */ 
     168  public function executeDeleteRecommendation(sfWebRequest $request) 
    145169  { 
    146170    $recommendation = RecommendationPeer::retrieveByPK($this->getRequestParameter('id')); 
     
    160184  } 
    161185 
    162   public function executeRecommend() 
     186  /** 
     187   * Recommend action 
     188   * 
     189   */ 
     190  public function executeRecommend(sfWebRequest $request) 
    163191  { 
    164192    $this->user = $this->getFromSlug('to_username'); 
     
    223251  } 
    224252 
    225   public function executeRecommendations() 
     253  /** 
     254   * Recommendatyions list actions 
     255   * 
     256   */ 
     257  public function executeRecommendations(sfWebRequest $request) 
    226258  { 
    227259    $c = new Criteria; 
     
    238270  } 
    239271 
    240   public function executeSkills() 
     272  /** 
     273   * Skill tags action 
     274   * 
     275   */ 
     276  public function executeSkills(sfWebRequest $request) 
    241277  { 
    242278    $c = new Criteria; 
     
    248284  public function handleErrorContact() 
    249285  { 
    250  
    251286    $this->recipient = $this->getFromSlug('to_username'); 
    252287    return sfView::SUCCESS; 
     
    260295  } 
    261296 
     297  /** 
     298   * Retrieves user from slug in request parameter 
     299   * 
     300   * @param  string  $slug_param 
     301   * @param  string  $peer_method 
     302   * @return sfGuardUser|null 
     303   */ 
    262304  protected function getFromSlug($slug_param = 'username', $peer_method = null) 
    263305  { 
     
    265307    $user = sfGuardUserPeer::retrieveByUsername($username, true, $peer_method); 
    266308    $this->forward404Unless($user, sprintf('Unable to retrieve user "%s" (maybe user is not an active one)', $username)); 
     309 
    267310    return $user; 
    268311  } 
    269  
    270312} 
  • trunk/apps/main/modules/people/actions/components.class.php

    r2 r75  
    99  public function executeFilterForm() 
    1010  { 
    11     $this->countries = sfGuardUserPeer::retrieveCountries(); 
    12     if ($this->getRequestParameter('country')) 
     11    $this->form = new CountrySelectorForm(sfGuardUserPeer::retrieveCountries()); 
     12    $this->form->setDefault('country', $this->getRequestParameter('country')); 
     13 
     14    if ($this->hasRequestParameter('country')) 
    1315    { 
    1416      $this->cities = sfGuardUserPeer::retrieveCountryCities($this->getRequestParameter('country')); 
  • trunk/apps/main/modules/people/templates/_filterForm.php

    r64 r75  
    11<form action="<?php echo url_for('@people_home') ?>" method="get" id="country_form"> 
    2   <p> 
    3     <?php echo label_for('country', __('Filter by country')) ?> 
    4     <?php echo select_tag('country', 
    5                           options_for_select($countries, 
    6                                              $sf_request->getParameter('country'), 
    7                                              array('include_custom' => __('All countries'))), 
    8                           array("onchange" => "document.getElementById('city').selectedIndex=0;". 
    9                                               "document.getElementById('city_selector').style.display='none';". 
    10                                               "return false")) ?> 
    11   </p> 
    12   <?php if ($sf_request->hasParameter('country') && isset($cities)): ?> 
     2  <?php echo $form['country']->renderLabel() ?> 
     3  <?php echo $form['country']->render(array("onchange" => "if(!document.getElementById('city'))return false;". 
     4                                                          "document.getElementById('city').selectedIndex=0;". 
     5                                                          "document.getElementById('city_selector').style.display='none';". 
     6                                                          "return false")) ?> 
     7  <?php if ($sf_request->hasParameter('country') && isset($cities) && count($cities)): ?> 
    138  <p id="city_selector"> 
    14     <?php echo label_for('country', __('Filter by city in %country%', 
    15                                        array('%country%' => format_country($sf_request->getParameter('country'))))) ?> 
    16     <?php echo select_tag('city', 
    17                           options_for_select($cities, 
    18                                              $sf_params->getRaw('selected_city'), 
    19                                              array('include_custom' => __('All cities')))) ?> 
     9    <label for="city"><?php echo __('Filter by city in %country%', 
     10                                    array('%country%' => format_country($sf_request->getParameter('country')))) ?></label> 
     11    <select name="city" id="city"> 
     12      <option value=""><?php echo __('All cities') ?></option> 
     13      <?php foreach ($cities as $city): ?> 
     14      <option value="<?php echo $city ?>"<?php echo $sf_params->getRaw('selected_city') == $city ? ' selected="selected"' : '' ?>><?php echo $city ?></option> 
     15      <?php endforeach; ?> 
     16    </select> 
    2017  </p> 
    2118  <?php endif; ?> 
    2219  <p> 
    23     <?php echo checkbox_tag('available', 1, $sf_request->hasParameter('available'), 'id=available') ?
    24     <?php echo label_for('available', __('Only people available for hire'), 'class=left') ?
     20    <input type="checkbox" value="1" <?php echo $sf_request->hasParameter('available') ? 'checked="checked"' : '' ?> name="available" id="available"
     21    <label for="available" class="left"><?php echo __('Only people available for hire') ?></label
    2522  </p> 
    2623  <p> 
    27     <?php echo submit_tag(__('Filter')) ?
     24    <input type="submit" value="<?php echo __('Filter') ?>" name="commit"/
    2825  </p> 
    2926</form> 
  • trunk/apps/main/modules/people/templates/contactSuccess.php

    r64 r75  
    77<?php end_slot() ?> 
    88 
    9 <?php echo breadcrumb(array(array(__('People'), '@people_home'),  
     9<?php echo breadcrumb(array(array(__('People'), '@people_home'), 
    1010                            array($recipient->getDisplayName(), '@person_page?username='.$recipient->getUsername()), 
    1111                            $page_title)) ?> 
     
    1717    <legend><?php echo __('Fill the form then send your message') ?></legend> 
    1818    <div class="form-row"> 
    19       <?php echo __('From: %sender%',  
     19      <?php echo __('From: %sender%', 
    2020                    array('%sender%' => $sf_user->getGuardUser()->getEmailSender())) ?> 
    2121    </div> 
    22     <div class="form-row required"> 
    23       <?php echo label_for('subject', __('Subject')) ?> 
    24       <?php echo input_tag('subject', $sf_params->get('subject'), 'id=subject size=40') ?> 
    25       <?php echo form_error('subject') ?> 
     22    <div class="form-row required <?php echo $form['subject']->hasError() ? 'field_error' : '' ?>"> 
     23      <?php echo $form['subject']->renderLabel() ?> 
     24      <?php echo $form['subject']->render() ?> 
     25      <?php echo $form['subject']->renderError() ?> 
    2626    </div> 
    27     <div class="form-row required"> 
    28       <?php echo label_for('body', __('Message')) ?> 
    29       <?php echo textarea_tag('body', $sf_params->get('body'), 'id=body cols=40 rows=10') ?> 
    30       <?php echo form_error('body') ?> 
     27    <div class="form-row required <?php echo $form['body']->hasError() ? 'field_error' : '' ?>"> 
     28      <?php echo $form['body']->renderLabel() ?> 
     29      <?php echo $form['body']->render() ?> 
     30      <?php echo $form['body']->renderError() ?> 
    3131    </div> 
    32     <div class="form-row required"> 
    33       <?php use_helper('Cryptographp') ?> 
    34       <?php echo label_for('captcha', __('Security code')) ?> 
    35       <?php echo input_tag('captcha', null, 'id=captcha style=width:150px'); ?> 
    36       <?php echo cryptographp_picture() ?> 
    37       <?php echo cryptographp_reload() ?> 
    38       <?php echo form_error('captcha') ?> 
     32    <div class="form-row required <?php echo $form['captcha']->hasError() ? 'field_error' : '' ?>"> 
     33      <?php echo $form['captcha']->renderLabel(__('Security code')) ?> 
     34      <?php echo $form['captcha']->render() ?> 
     35      <?php echo $form['captcha']->renderError() ?> 
    3936    </div> 
    40     <p> 
    41       <?php echo submit_tag(__('Send your message to %user%',  
    42                                array('%user%' => $recipient->getDisplayName()))) ?> 
    43     </p> 
     37    <div class="form-row"> 
     38      <input type="submit" value="<?php echo __('Send your message to %user%', array('%user%' => $recipient->getDisplayName())) ?>" /> 
     39    </div> 
    4440  </fieldset> 
    4541</form> 
  • trunk/apps/main/modules/people/templates/detailsSuccess.php

    r2 r75  
    88 
    99<?php slot('sidebar') ?> 
    10   <?php echo link_thumb_to_person('standard', $user, 'imgclass=person_avatar') ?>   
     10  <?php echo link_thumb_to_person('standard', $user, 'imgclass=person_avatar') ?> 
    1111  <?php if ($user->getIsForHire()): ?> 
    1212    <p class="for_hire"><?php echo __('Available for hire') ?></p> 
     
    1919      <?php if ($is_current_user): ?> 
    2020        <li> 
    21           <?php echo link_to(__('Edit your profile'),  
    22                            '@user_profile?username='.$user->getUsername(), 
    23                            'class=bigedit') ?></li> 
     21          <?php echo link_to(__('Edit your profile'), 
     22                             '@user_profile?username='.$user->getUsername(), 
     23                             'class=bigedit') ?></li> 
    2424      <?php endif; ?> 
    2525      <?php if ($sf_user->isAdmin()): ?> 
    2626        <li> 
    27           <?php echo link_to(__('Delete this account'),  
    28                            '@person_delete?username='.$user->getUsername(), 
    29                            'class=bigdelete confirm='.__('Are you sure?')) ?></li> 
     27          <?php echo link_to(__('Delete this account'), 
     28                             '@person_delete?username='.$user->getUsername(), 
     29                             'class=bigdelete confirm='.__('Are you sure?')) ?></li> 
    3030      <?php endif; ?> 
    3131    </ul> 
     
    3434    <h3><?php echo __('Wanna get in touch?') ?></h3> 
    3535    <p class="mail_contact"> 
    36       <?php echo big_button_to(__('Contact by email'),  
     36      <?php echo big_button_to(__('Contact by email'), 
    3737                               '@person_contact?to_username='.$user->getUsername()) ?> 
    3838    </p> 
    3939  <?php endif; ?> 
    4040  <?php if (!$is_current_user && !$has_recommended): ?> 
    41     <h3><?php echo __('You appreciate this person?') ?></h3>  
     41    <h3><?php echo __('You appreciate this person?') ?></h3> 
    4242    <p><?php echo big_button_to(__('Recommend this person'), 
    4343                                  '@person_recommend?to_username='.$user->getUsername()) ?></p> 
     
    4747<div class="fiftypercent vcard"> 
    4848 
    49   <?php echo breadcrumb(array(array(__('People'), '@people_home'),  
     49  <?php echo breadcrumb(array(array(__('People'), '@people_home'), 
    5050                              $page_title)) ?> 
    5151  <h2> 
     
    5454    <span class="gradient">&nbsp;</span> 
    5555  </h2> 
    56    
     56 
    5757  <?php include_partial('people/entry', 
    5858                        array('person'       => $user, 
    5959                              'sf_cache_key' => $user->getUsername())) ?> 
    60    
     60 
    6161  <div class="recommendations_received"> 
    6262    <h3 class="recommended_title"><?php echo __('Recommendations received') ?></h3> 
     
    6666        <?php echo __('%name% has been recommended by %nb_people%.', 
    6767                       array('%name%'      => $user->getDisplayName(), 
    68                              '%nb_people%' => format_number_choice('[0]nobody|[1]one person|(1,+Inf]%1% people',  
     68                             '%nb_people%' => format_number_choice('[0]nobody|[1]one person|(1,+Inf]%1% people', 
    6969                                                                 array('%1%' => $nb_rec_received), $nb_rec_received))) ?> 
    7070      </strong> 
     
    7979        </p> 
    8080        <blockquote> 
    81           <?php if ($sf_user->isAdmin()  
     81          <?php if ($sf_user->isAdmin() 
    8282                    or $recommendation->getRecommendedId() == $sf_user->getId() 
    8383                    or $recommendation->getRecommenderId() == $sf_user->getId()): ?> 
     
    9898    <?php else: ?> 
    9999    <p> 
    100       <?php echo __('%name% has not been recommended yet.',  
     100      <?php echo __('%name% has not been recommended yet.', 
    101101                    array('%name%' => $user->getDisplayName())) ?> 
    102102    </p> 
    103103    <?php endif; ?> 
    104104    <p class="more"> 
    105       <?php echo link_to(__('Recommend '.$user->getDisplayName()),  
     105      <?php echo link_to(__('Recommend '.$user->getDisplayName()), 
    106106                        '@person_recommend?to_username='.$user->getUsername()) ?> 
    107107    </p> 
    108108  </div> 
    109    
     109 
    110110  <div class="recommendations_sent"> 
    111111    <h3 class="recommender_title"><?php echo __('Recommendations sent to others') ?></h3> 
     
    115115        <?php echo __('%name% has recommended %nb_people%.', 
    116116                       array('%name%'      => $user->getDisplayName(), 
    117                              '%nb_people%' => format_number_choice('[0]nobody|[1]one person|(1,+Inf]%1% people',  
     117                             '%nb_people%' => format_number_choice('[0]nobody|[1]one person|(1,+Inf]%1% people', 
    118118                                                                   array('%1%' => $nb_rec_made), $nb_rec_made))) ?> 
    119119      </strong> 
     
    127127                               '%date%'        => $recommendation->getCreatedAt('m/d/Y'))) ?> 
    128128        <blockquote> 
    129           <?php if ($sf_user->isAdmin()  
     129          <?php if ($sf_user->isAdmin() 
    130130                    or $recommendation->getRecommendedId() == $sf_user->getId() 
    131131                    or $recommendation->getRecommenderId() == $sf_user->getId()): ?> 
     
    149149    <?php endif; ?> 
    150150  </div> 
    151    
     151 
    152152</div> 
    153153 
     
    160160      <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 
    161161        <td class="mini_thumb_cell"> 
    162           <?php echo link_to(image_tag($app_person->getApplication()->getFullScreenshotPath(), 
    163                                        'class=mini_thumb'), 
     162          <?php echo link_to(application_image_tag($app_person->getApplication(), 
     163                                                   'class=mini_thumb'), 
    164164                             '@application_page?slug='.$app_person->getApplication()->getSlug(), 
    165165                             'class=thumb_link') ?> 
     
    186186  <p><?php echo __('No application related to this person (yet).') ?></p> 
    187187  <?php endif; ?> 
    188    
     188 
    189189  <h3><?php echo __('Related companies') ?></h3> 
    190190  <?php if (count($person_companies->getRawValue()) > 0): ?> 
     
    194194      <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 
    195195        <td class="mini_thumb_cell"> 
    196           <?php echo link_to(image_tag($company_person->getCompany()->getFullLogoPath(), 
    197                                        'class=mini_thumb'), 
     196          <?php echo link_to(company_image_tag($company_person->getCompany(), 
     197                                               'class=mini_thumb'), 
    198198                             '@company_page?slug='.$company_person->getCompany()->getSlug(), 
    199199                             'class=thumb_link') ?> 
  • trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php

    r56 r75  
    4141    } 
    4242  } 
    43    
     43 
    4444  public function executeChangePassword(sfWebRequest $request) 
    4545  { 
     
    5454    } 
    5555  } 
    56    
     56 
    5757  public function executeDeleteAvatar(sfWebRequest $request) 
    5858  { 
     
    7676    } 
    7777  } 
    78    
     78 
    7979  public function executeForgotPassword(sfWebRequest $request) 
    8080  { 
     
    8787      $user->setPassword($password); 
    8888      $user->save(); 
    89        
     89 
    9090      $request->setAttribute('user', $user); 
    9191      $request->setAttribute('password', $password); 
     
    107107  { 
    108108    $this->embedGoogleJavascriptApi(); 
    109      
     109 
    110110    $this->user = $this->getUser()->getGuardUser(); 
    111111 
     
    114114      return sfView::SUCCESS; 
    115115    } 
    116      
     116 
    117117    $profile = $request->getParameter('profile', array()); 
    118      
     118 
    119119    # 1. Boolean values 
    120120    if (!isset($profile['allow_contact'])) 
     
    130130      $profile['is_for_hire'] = false; 
    131131    } 
    132      
     132 
    133133    # 2. Dates 
    134134    if (!$profile['birthdate']) 
     
    144144      unset($profile['symfony_at']); 
    145145    } 
    146      
     146 
    147147    try 
    148148    { 
    149149      $thumb = ImagesTools::createThumbs ( 
    150         'profile[avatar_path]',  
     150        'profile[avatar_path]', 
    151151        sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.sfConfig::get('app_people_upload_dir', 'people'), 
    152152        md5($this->user->getUsername()).'.jpg', 
     
    214214    } 
    215215  } 
    216    
     216 
    217217  public function handleErrorProfile() 
    218218  { 
     
    221221    return sfView::SUCCESS; 
    222222  } 
    223    
     223 
    224224  public function handleErrorForgotPassword() 
    225225  { 
    226226    return sfView::SUCCESS; 
    227227  } 
    228    
     228 
    229229  /** 
    230230   * Registers a new member 
     
    239239      $this->redirect('@homepage'); 
    240240    } 
    241      
     241 
    242242    $this->form = new RegisterForm(); 
    243      
    244     // Recaptcha parameters 
    245     $captcha = array( 
    246       'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 
    247       'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'), 
    248     ); 
    249     $params = array_merge($request->getParameter('user', array()), array('captcha' => $captcha)); 
    250      
     243 
     244    $params = $request->getParameter('user', array()); 
     245 
     246    if (true === sfConfig::get('app_recaptcha_enabled', true)) 
     247    { 
     248      $captcha = array ( 
     249        'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 
     250        'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'), 
     251      ); 
     252 
     253      $params = array_merge($params, array('captcha' => $captcha)); 
     254    } 
     255 
    251256    if (!$request->isMethod('post') or !$this->form->bindAndSave($params)) 
    252257    { 
    253258      return sfView::SUCCESS; // redisplay form with errors 
    254259    } 
    255      
     260 
    256261    // At this point we got a valid form and a created sfGuardUser object 
    257262    $user = $this->form->getObject(); 
    258      
     263 
    259264    // Create activation entry 
    260265    $activation = new Activation(); 
     
    262267    $activation->setHash(md5(rand(100000, 999999))); 
    263268    $activation->save(); 
    264      
     269 
    265270    // Send user an activation email 
    266271    $request->setAttribute('user', $user); 
     
    269274                                              $user->getEmail(), 
    270275                                              $this->__('Please confirm your Symfonians account creation request')); 
    271      
    272     // If mail sending failed,  
     276 
     277    // If mail sending failed, 
    273278    if (!$mailSent) 
    274279    { 
     
    282287    $this->redirect('@user_register_done'); 
    283288  } 
    284    
     289 
    285290  public function executeRegisterDone(sfWebRequest $request) 
    286291  { 
     
    288293    return sfView::SUCCESS; 
    289294  } 
    290    
     295 
    291296  /** 
    292297   * Resend activation mail 
     
    301306  { 
    302307    $this->form = new ResendActivationForm(); 
    303      
     308 
    304309    if ($request->isMethod('post')) 
    305310    { 
    306311      $this->form->bindFromRequest($request); 
    307        
     312 
    308313      if ($this->form->isValid()) 
    309314      { 
    310315        $user = sfGuardUserPeer::retrieveByEmail($this->form->getValue('email')); 
    311316        $this->forward404Unless($user); // theoricaly, can't happen 
    312          
     317 
    313318        $c = new Criteria(); 
    314319        $c->add(ActivationPeer::USER_ID, $user->getId()); 
    315320        $activation = ActivationPeer::doSelectOne($c); 
    316321        $request->setAttribute('activation', $activation); 
    317          
     322 
    318323        $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'resendActivation', 
    319324                                                  $user->getEmail(), 
     
    324329          return sfView::SUCCESS; 
    325330        } 
    326          
     331 
    327332        $this->getUser()->setFlash('notice', $this->__('Your activation mail has been sent to '.$user->getEmail())); 
    328333        $this->redirect('@homepage'); 
     
    330335    } 
    331336  } 
    332    
     337 
    333338  public function handleErrorChangePassword() 
    334339  { 
    335340    return sfView::SUCCESS; 
    336341  } 
    337    
     342 
    338343  public function validateActivate() 
    339344  { 
     
    342347    $c->add(ActivationPeer::HASH, $key); 
    343348    $c->addJoin(ActivationPeer::USER_ID, sfGuardUserPeer::ID); 
    344      
     349 
    345350    $this->activation = ActivationPeer::doSelectOne($c); 
    346351    if (!$this->activation) 
     
    349354      return false; 
    350355    } 
    351      
     356 
    352357    $this->user = $this->activation->getsfGuardUser(); 
    353358    if (!$this->user) 
    354359    { 
    355360      $this->getRequest()->setError('errors', $this->__('Unable to find user to activate')); 
    356       return false;  
    357     } 
    358      
     361      return false; 
     362    } 
     363 
    359364    if ($this->user->getIsActive()) 
    360365    { 
     
    362367      return false; 
    363368    } 
    364      
     369 
    365370    return true; 
    366371  } 
    367    
     372 
    368373  public function validateChangePassword() 
    369374  { 
     
    379384    } 
    380385  } 
    381    
     386 
    382387  public function validateForgotPassword() 
    383388  { 
     
    398403    return true; 
    399404  } 
    400    
     405 
    401406} 
  • trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php

    r64 r75  
    1414  <?php echo big_button_to(__('Sign in!'), '@sf_guard_signin') ?> 
    1515  <p style="text-align:center"> 
    16     (<?php echo link_to(__('Forgot your password?'),  
     16    (<?php echo link_to(__('Forgot your password?'), 
    1717                        '@user_forgot_password') ?>) 
    1818  </p> 
     
    4141    <fieldset> 
    4242      <legend><?php echo __('Security') ?></legend> 
     43      <?php if (true === sfConfig::get('app_recaptcha_enabled')): ?> 
    4344      <?php echo $form['captcha']->renderRow() ?> 
     45      <?php else: ?> 
     46      <p>Disabled in dev mode</p> 
     47      <?php endif; ?> 
    4448    </fieldset> 
    4549    <p class="tip"> 
  • trunk/apps/main/templates/_messages.php

    r56 r75  
    1 <?php if (!is_null($activeForm) && $activeForm->hasGlobalErrors()): ?> 
    2 <div class="form-errors"> 
    3   <h4><?php echo __('Errors have been encountered') ?></h4> 
    4   <?php echo $activeForm->renderGlobalErrors() ?> 
    5 </div> 
     1<?php /* @var $activeForm sfForm */ ?> 
     2<?php if (!is_null($activeForm)): ?> 
     3  <?php if ($activeForm->hasGlobalErrors()): ?> 
     4  <div class="global-form-errors"> 
     5    <h4><?php echo __('Errors have been encountered') ?></h4> 
     6    <?php echo $activeForm->renderGlobalErrors() ?> 
     7  </div> 
     8  <?php elseif (count($activeForm->getErrorSchema())): ?> 
     9  <div class="global-form-errors"> 
     10    <h4><?php echo __('Errors have been encountered') ?></h4> 
     11    <p><?php echo __('Please check the fields of the form below') ?></p> 
     12  </div> 
     13  <?php endif; ?> 
    614<?php endif; ?> 
    715 
  • trunk/config/ProjectConfiguration.class.php

    r66 r75  
    77  public function setup() 
    88  { 
     9    // Base forms configuration 
    910    sfWidgetFormSchema::setDefaultFormFormatterName('div'); 
    10      
     11    sfValidatorBase::setRequiredMessage('This field is required.'); 
     12    sfValidatorBase::setInvalidMessage('The value provided is invalid.'); 
     13 
    1114    // symfonians constants definition 
    1215    if (!defined('SYMFONIANS_MAIN_DOMAIN')) 
     
    2225    } 
    2326  } 
    24    
     27 
    2528  public function getWebDir() 
    2629  { 
    2730    return sfConfig::get('sf_web_dir'); 
    2831  } 
    29    
     32 
    3033  public function getUploadDir() 
    3134  { 
    3235    return sfConfig::get('sf_upload_dir'); 
    3336  } 
    34    
     37 
    3538  public function getUploadDirName() 
    3639  { 
  • trunk/config/app.yml-dist

    r62 r75  
    77    max_sidebar_tags:    50 
    88    upload_dir:          applications 
    9     screenshot_width:    200 
    10     screenshot_height:   140 
    11     screenshot_mime:     image/jpeg 
    12     screenshot_quality:  90 
     9    thumb.width:         200 
     10    thumb.height:        140 
     11    thumb.quality:       90 
    1312    default_screenshot:  default_screenshot.png 
    1413 
     
    2423    box_max_items:       5 
    2524    upload_dir:          companies 
    26     logo_width:          200 
    27     logo_height:         140 
    28     logo_mime:           image/jpeg 
    29     logo_quality:        90 
     25    thumb.width:         200 
     26    thumb.height:        140 
     27    thumb.quality:       90 
    3028    default_logo:        default_logo.png 
    3129 
     
    8987 
    9088  people: 
     89    forbidden_names:     [admin, contact, info, infos, commercial, tech, support, sales, partnership, webmaster, business, owner] 
    9190    max_items:           6 
    9291    box_max_items:       5 
  • trunk/data/fixtures/data.yml

    r66 r75  
     1Event: 
     2 
    13sfGuardUser: 
    24  fabpot: 
  • trunk/lib/form/ActivationForm.class.php

    r71 r75  
    11<?php 
    2  
    32/** 
    43 * Activation form. 
     
    98class ActivationForm extends BaseActivationForm 
    109{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1114  public function configure() 
    1215  { 
  • trunk/lib/form/ApplicationCompanyForm.class.php

    r71 r75  
    88class ApplicationCompanyForm extends BaseApplicationCompanyForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
  • trunk/lib/form/ApplicationDeveloperForm.class.php

    r71 r75  
    88class ApplicationDeveloperForm extends BaseApplicationDeveloperForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
  • trunk/lib/form/ApplicationForm.class.php

    r71 r75  
    88class ApplicationForm extends BaseApplicationForm 
    99{ 
    10   protected $culture = null; 
    11  
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1214  public function configure() 
    1315  { 
    14     sfLoader::loadHelpers('I18n'); 
    15     $context = sfContext::getInstance(); 
    16     $this->culture = $context->getUser()->getCulture(); 
    17  
    1816    // Unset unused widgets 
    19     unset($this['id'], 
    20           $this['created_at'], 
     17    unset($this['created_at'], 
    2118          $this['updated_at'], 
    2219          $this['slug'], 
     
    2825 
    2926    // Defaults 
    30     $this->setDefaults(array('homepage'      => 'http://', 
    31                              'feed_url'      => 'http://', 
    32                              'released_at'   => 'today',   // thanks strtotime() 
    33                              'is_featured'   => null, 
    34                              'is_opensource' => null)); 
     27    parent::setDefaults(array('homepage'      => 'http://', 
     28                              'feed_url'      => 'http://', 
     29                              'released_at'   => 'today',   // thanks strtotime() 
     30                              'is_featured'   => null, 
     31                              'is_opensource' => null)); 
     32  } 
     33 
     34  /** 
     35   * Overrides parent doSave method to save tags for current Application object 
     36   * 
     37   * @param Connection $con An optional Connection object 
     38   * @see   doSave 
     39   */ 
     40  protected function doSave($con = null) 
     41  { 
     42    parent::doSave($con); 
     43 
     44    $values = $this->getValues(); 
     45 
     46    if (isset($values['tags'])) 
     47    { 
     48      $this->getObject()->setTags($values['tags']); 
     49      $this->getObject()->save($con); 
     50    } 
    3551  } 
    3652 
     
    6581      new sfValidatorUrl(), 
    6682      new sfValidatorChoice(array('choices' => array('http://', ''))), 
    67     )); 
     83    ), array(), array('invalid' => 'This url seems to be invalid')); 
    6884 
    6985    $this->validatorSchema['feed_url'] = new sfValidatorOr(array( 
    7086      new sfValidatorUrl(), 
    7187      new sfValidatorChoice(array('choices' => array('http://', ''))), 
    72     )); 
     88    ), array(), array('invalid' => 'This feed url seems to be invalid')); 
    7389 
    7490    // Post validators 
    75     /*$this->validatorSchema->setPostValidator(new sfValidatorAnd(array( 
     91    $this->validatorSchema->setPostValidator(new sfValidatorAnd(array( 
     92      new sfValidatorOr(array( 
     93        new sfValidatorSchemaFilter('homepage', new sfValidatorChoice(array('choices' => array('http://', ''), 'required' => false))), 
    7694        new sfValidatorPropelUnique(array('model' => 'Application', 'column' => array('homepage'))), 
    77         new sfValidatorSchemaLicence(), 
    78     )));*/ 
     95      )), 
     96      new sfValidatorSchemaTimeInterval('started_at', 'released_at', array('disallow_future_dates' => true, 'throw_global_error' => false)), 
     97      new sfValidatorSchemaLicence(), 
     98    ))); 
    7999  } 
    80100} 
  • trunk/lib/form/BaseFormPropel.class.php

    r71 r75  
    11<?php 
    22/** 
    3  * Project form base class. 
     3 * Project base Propel form class. 
    44 * 
    55 * @package    form 
     
    77abstract class BaseFormPropel extends sfFormPropel 
    88{ 
     9  /** 
     10   * Current culture 
     11   * @var string 
     12   */ 
     13  protected $culture = null; 
     14 
     15  /** 
     16   * Form setup: 
     17   * 
     18   *  - automatically loads the culture from user session 
     19   *  - defines default form schema formatter 
     20   */ 
    921  public function setup() 
    1022  { 
     23    // Culture setup 
     24    sfLoader::loadHelpers('I18n'); 
     25    $context = sfContext::getInstance(); 
     26    $this->culture = $context->getUser()->getCulture(); 
     27 
     28    // Default formatter 
    1129    sfWidgetFormSchema::setDefaultFormFormatterName('div'); 
    1230  } 
  • trunk/lib/form/BlogPostForm.class.php

    r71 r75  
    88class BlogPostForm extends BaseBlogPostForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
  • trunk/lib/form/CompanyForm.class.php

    r71 r75  
    88class CompanyForm extends BaseCompanyForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
     16    unset($this['created_at'], 
     17          $this['updated_at'], 
     18          $this['slug'], 
     19          $this['logo_path']); 
     20 
     21    $this->initWidgets(); 
     22    $this->initValidators(); 
     23 
     24    // Defaults 
     25    parent::setDefaults(array('homepage' => 'http://')); 
     26  } 
     27 
     28  /** 
     29   * Intitialize widgets 
     30   * 
     31   */ 
     32  public function initWidgets() 
     33  { 
     34    $this->widgetSchema['country']   = new ExtendedWidgetFormI18nSelectCountry(array('culture' => $this->culture, 'add_label_option' => __('Select a country'))); 
     35    $this->widgetSchema['logo_file'] = new sfWidgetFormInputFile(); 
     36  } 
     37 
     38  /** 
     39   * Initialize validators 
     40   * 
     41   */ 
     42  public function initValidators() 
     43  { 
     44    $this->validatorSchema['email']     = new sfValidatorAnd(array( 
     45      new sfValidatorString(array('max_length' => 100, 'required' => true)), 
     46      new sfValidatorEmail(array(), array('invalid' => __('This email address is invalid'))), 
     47    )); 
     48    $this->validatorSchema['city']      = new sfValidatorString(array('max_length' => 50, 'required' => true)); 
     49    $this->validatorSchema['country']   = new sfValidatorI18nChoiceCountry(array('culture' => $this->culture, 'required' => true)); 
     50    $this->validatorSchema['logo_file'] = new sfValidatorFile(array('max_size' => 512000, 
     51                                                                    'mime_types' => 'web_images', 
     52                                                                    'validated_file_class' => 'sfValidatedThumb', 
     53                                                                    'required' => false)); 
     54    $this->validatorSchema['homepage'] = new sfValidatorOr(array( 
     55      new sfValidatorUrl(), 
     56      new sfValidatorChoice(array('choices' => array('http://', ''))), 
     57    ), array(), array('invalid' => 'This url seems to be invalid')); 
     58 
     59    // Post validators 
     60    $this->validatorSchema->setPostValidator(new sfValidatorAnd(array( 
     61      new sfValidatorPropelUnique(array('model' => 'Company', 'column' => array('name'))), 
     62      new sfValidatorOr(array( 
     63        new sfValidatorSchemaFilter('homepage', new sfValidatorChoice(array('choices' => array('http://', ''), 'required' => false))), 
     64        new sfValidatorPropelUnique(array('model' => 'Company', 'column' => array('homepage'))), 
     65      )), 
     66    ))); 
    1267  } 
    1368} 
  • trunk/lib/form/CompanyPersonForm.class.php

    r71 r75  
    88class CompanyPersonForm extends BaseCompanyPersonForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
     16    unset($this['started_at'], 
     17          $this['ended_at'], 
     18          $this['created_at'], 
     19          $this['updated_at']); 
     20 
     21    $this->mergeForm(new BaseConnectionForm()); 
     22 
     23    $this->widgetSchema->setNameFormat('connection[%s]'); 
    1224  } 
    1325} 
  • trunk/lib/form/CountrySelectorForm.class.php

    r68 r75  
    88class CountrySelectorForm extends sfForm 
    99{ 
    10   protected  
     10  protected 
    1111    $countries = array(), 
    1212    $culture   = 'en'; 
    13    
     13 
    1414  /** 
    1515   * Public constructor 
     
    2222    $this->countries = array_keys($countries); 
    2323    $this->culture = sfContext::getInstance()->getUser()->getCulture(); 
     24 
    2425    parent::__construct($defaults, $options, $CSRFSecret); 
    2526  } 
    26    
     27 
    2728  /** 
    2829   * Form configuration 
    2930   * 
    3031   */ 
    31   public function configure() 
     32  public function setup() 
    3233  { 
    3334    $this->setWidgets(array( 
    34       'country' => new sfWidgetFormI18nSelectCountry(array('culture' => $this->culture, 
    35                                                            'countries' => $this->countries,  
    36                                                            'include_custom' => array('' => __('Any country')))), 
     35      'country' => new ExtendedWidgetFormI18nSelectCountry(array('culture' => $this->culture, 
     36                                                                 'countries' => $this->countries, 
     37                                                                 'add_label_option' => __('Any country'))), 
    3738    )); 
    38      
     39 
    3940    $this->setValidators(array( 
    4041      'country' => new sfValidatorI18nChoiceCountry(array('culture' => $this->culture, 
  • trunk/lib/form/EventForm.class.php

    r71 r75  
    88class EventForm extends BaseEventForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
  • trunk/lib/form/JobForm.class.php

    r71 r75  
    88class JobForm extends BaseJobForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
  • trunk/lib/form/LocalEventForm.class.php

    r71 r75  
    88class LocalEventForm extends BaseLocalEventForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
  • trunk/lib/form/RecommendationForm.class.php

    r71 r75  
    88class RecommendationForm extends BaseRecommendationForm 
    99{ 
     10  /** 
     11   * Form configuration 
     12   * 
     13   */ 
    1014  public function configure() 
    1115  { 
  • trunk/lib/form/RegisterForm.class.php

    r68 r75  
    55 * @see sfGuardUserForm 
    66 */ 
    7 class RegisterForm extends BasesfGuardUserForm  
     7class RegisterForm extends BasesfGuardUserForm 
    88{ 
    9  
    10   static protected  
    11     $forbidden_names = array('admin', 'niko', 'contact', 'info', 'infos', 'commercial', 'tech', 'support', 'sales', 'partnership', 'webmaster', 'business', 'owner'); 
    12    
     9  /** 
     10  * Form configuration 
     11   * 
     12  */ 
    1313  public function configure() 
    1414  { 
     
    1919      'password'  => new sfWidgetFormInputPassword(), 
    2020      'password2' => new sfWidgetFormInputPassword(), 
    21       'captcha'   => new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))), 
    2221    )); 
    23      
     22 
    2423    // helps 
    2524    $this->widgetSchema->setHelps(array( 
     
    2827      'password'  => 'Your password must be 6 characters length minimum.', 
    2928      'password2' => 'Please confirm your password for avoiding typos.', 
    30       'captcha'   => 'This codes aims at detecting if you are a bot or a human person.', 
    3129    )); 
    32      
     30 
    3331    // validators 
    3432    $this->setValidators(array( 
     
    3634        new sfValidatorString(array('min_length' => 3, 'max_length' => 20)), 
    3735        new sfValidatorRegex(array('pattern' => '/^[a-zA-Z]([a-zA-Z0-9._-]+)$/'), array('invalid' => 'Name "%value%" contains forbidden characters')), 
    38         new sfValidatorBlacklist(array('forbidden_values' => self::$forbidden_names), array('invalid' => 'Name "%value%" is blacklisted')), 
     36        new sfValidatorBlacklist(array('forbidden_values' => sfConfig::get('app_people_forbidden_names', array())), array('invalid' => 'Name "%value%" is blacklisted')), 
    3937      )), 
    4038      'email'     => new sfValidatorAnd(array( 
     
    4442      'password'  => new sfValidatorString(array('min_length' => 6, 'max_length' => 128)), 
    4543      'password2' => new sfValidatorString(array('min_length' => 6, 'max_length' => 128)), 
    46       'captcha'   => new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))), 
    4744    )); 
    48      
     45 
     46    $this->addCaptcha(); 
     47 
    4948    // post validator 
    5049    $this->validatorSchema->setPostValidator(new sfValidatorAnd(array( 
    51       new sfValidatorSchemaCompare('password', 'equal', 'password2', array('throw_global_error' => true)), 
     50      new sfValidatorSchemaCompare('password', 'equal', 'password2'), 
    5251      new sfValidatorPropelUnique(array('model'  => 'sfGuardUser', 'column' => 'username')), 
    5352      new sfValidatorPropelUnique(array('model'  => 'sfGuardUser', 'column' => 'email')) 
    5453    ))); 
    55      
     54 
    5655    $this->widgetSchema->setNameFormat('user[%s]'); 
    5756  } 
    58    
     57 
     58  /** 
     59   * Adds a captcha to current form, if enabled by configuration 
     60   * 
     61   */ 
     62  public function addCaptcha() 
     63  { 
     64    if (true === sfConfig::get('app_recaptcha_enabled')) 
     65    { 
     66      $this->widgetSchema['captcha']    = new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))); 
     67      $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))); 
     68      $this->widgetSchema->setHelp('captcha', 'This codes aims at detecting if you are a bot or a human person.'); 
     69    } 
     70  } 
    5971} 
  • trunk/lib/form/ResendActivationForm.class.php

    r68 r75  
    44 * 
    55 */ 
    6 class ResendActivationForm extends sfFormReCaptcha   
     6class ResendActivationForm extends sfFormReCaptcha 
    77{ 
     8  /** 
     9   * Form configuration 
     10   * 
     11   */ 
    812  public function configure() 
    913  { 
     
    1418      $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))); 
    1519    } 
    16      
     20 
    1721    // Validators 
    18     $this->validatorSchema['email'] = new sfValidatorAnd(array(  
     22    $this->validatorSchema['email'] = new sfValidatorAnd(array( 
    1923      new sfValidatorEmail(), 
    20       new sfValidatorPropelChoice(array('model' => 'sfGuardUser', 'column' => 'email', 'criteria' => self::getActiveCriteria()),  
     24      new sfValidatorPropelChoice(array('model' => 'sfGuardUser', 'column' => 'email', 'criteria' => self::getActiveCriteria()), 
    2125                                  array('invalid' => 'This email has never been registered here, or is already activated.')), 
    2226    )); 
    23      
     27 
    2428    if (true === sfConfig::get('app_recaptcha_enabled')) 
    2529    { 
    2630      $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))); 
    2731    } 
    28      
     32 
    2933    $this->widgetSchema->setNameFormat('user[%s]'); 
    3034  } 
    31    
     35 
    3236  /** 
    3337   * Generates a Criteria filtering active users only 
  • trunk/lib/form/SigninForm.class.php

    r68 r75  
    44 * 
    55 */ 
    6 class SigninForm extends sfGuardFormSignin  
     6class SigninForm extends sfGuardFormSignin 
    77{ 
     8  /** 
     9   * Form configuration 
     10   * 
     11   */ 
    812  public function configure() 
    913  { 
    1014    parent::configure(); 
    11      
     15 
    1216    $this->widgetSchema['remember'] = new sfWidgetFormInputCheckbox(); 
    1317    $this->validatorSchema['remember'] = new sfValidatorPass(); 
  • trunk/lib/form/shared/BaseConnectionForm.class.php

    r72 r75  
    11<?php 
    22/** 
    3  * Base form class to represent a connection between two resources: 
     3 * Base form class to represent a connection between two resources. In the 
     4 * Symfonians app, these resources connection can be between: 
    45 * 
    56 *  - an Application and a Company 
     
    1314 *  - ended_at:   the date the connection stopped 
    1415 * 
     16 * Typical use is to merge a new instance of this form object with one of your 
     17 * form, not by extending it. This way you'll have the provided widgets and 
     18 * validators available in your own form. By example: 
     19 * 
     20 *     class myForm extends sfForm 
     21 *     { 
     22 *       public function configure() 
     23 *       { 
     24 *         $this->mergeForm(new BaseConnectionForm()); 
     25 *       } 
     26 *     } 
     27 * 
     28 * @package form 
    1529 */ 
    1630class BaseConnectionForm extends sfForm 
     
    2034   * 
    2135   */ 
    22   public function configure() 
     36  public function setup() 
    2337  { 
    24     $context = sfContext::getInstance(); 
    25     $culture = $context->getUser()->getCulture(); 
     38    $years = range(date('Y') - 5, date('Y')); 
     39    $years = array_combine($years, $years); 
     40    $dateConfig = array('culture' => sfContext::getInstance()->getUser()->getCulture(), 
     41                        'years'   => $years); 
    2642 
    2743    // Widgets 
     
    2945      'role'        => new sfWidgetFormInput(), 
    3046      'description' => new sfWidgetFormTextarea(), 
    31       'started_at'  => new sfWidgetFormI18nDate(array('culture' => $culture)), 
    32       'ended_at'    => new sfWidgetFormI18nDate(array('culture' => $culture)), 
     47      'started_at'  => new sfWidgetFormI18nDate($dateConfig), 
     48      'ended_at'    => new sfWidgetFormI18nDate($dateConfig), 
    3349    )); 
    3450 
     
    4056      'ended_at'    => new sfValidatorDate(array('required' => false)), 
    4157    )); 
     58 
     59    $this->validatorSchema->setPostValidator(new sfValidatorSchemaTimeInterval('started_at', 'ended_at')); 
     60 
     61    $this->widgetSchema->setNameFormat('connection[%s]'); 
    4262  } 
    4363} 
  • trunk/lib/helper/ImageHelper.php

    r2 r75  
    33 
    44/** 
    5  * Return an img tag to the flag image of a given coutnry  
     5 * Return an img tag to the flag image of a given coutnry 
    66 * 
    77 * @param  string  $country_code ISO country code 
     
    1515    return ''; 
    1616  } 
    17    
     17 
    1818  $options = _parse_attributes($options); 
    19    
     19 
    2020  if (isset($options['class'])) 
    2121  { 
     
    2626    $options['class'] = 'flag'; 
    2727  } 
    28    
     28 
    2929  $options['alt'] = format_country($country_code); 
    3030  $flag_image = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'flags'.DIRECTORY_SEPARATOR.strtolower($country_code).'.png'; 
     
    3333    return ''; 
    3434  } 
    35    
     35 
    3636  return image_tag('flags/'.strtolower($country_code).'.png', $options); 
    3737} 
     38 
     39/** 
     40 * Returns the application thumb web path 
     41 * 
     42 * @param  Application $application 
     43 * @param  mixed       $options 
     44 * @return string|null 
     45 */ 
     46function application_image_tag($application, $options = null) 
     47{ 
     48  return image_tag(sprintf('/%s/applications/%s', 
     49                           sfContext::getInstance()->getConfiguration()->getUploadDirName(), 
     50                           $application->getScreenshotPath()), $options); 
     51} 
     52 
     53/** 
     54 * Returns the company logo web path 
     55 * 
     56 * @param  Company  $company 
     57 * @param  mixed    $options 
     58 * @return string|null 
     59 */ 
     60function company_image_tag($company, $options = null) 
     61{ 
     62  return image_tag(sprintf('/%s/companies/%s', 
     63                           sfContext::getInstance()->getConfiguration()->getUploadDirName(), 
     64                           $company->getLogoPath()), $options); 
     65} 
     66 
     67/** 
     68 * Returns the person avatar web path. Due to image formats handling, the 
     69 * signature is a bit different regarding the previous *_image_tag functions. 
     70 * 
     71 * @param  sfGuardUser  $person 
     72 * @param  mixed        $options 
     73 * @return string|null 
     74 */ 
     75function person_image_tag($person, $format = 'standard', $options = null) 
     76{ 
     77  if (!$person->getAvatarPath()) 
     78  { 
     79    $config = sfConfig::get('app_people_formats', array()); 
     80 
     81    if (isset($config[$format]['default'])) 
     82    { 
     83      return image_tag(sprintf('/images/%s', $config[$format]['default']), $options); 
     84    } 
     85  } 
     86 
     87  return image_tag(sprintf('/%s/people/%s', 
     88                           sfContext::getInstance()->getConfiguration()->getUploadDirName(), 
     89                           $person->getAvatarPath()), $options); 
     90} 
  • trunk/lib/helper/ObjectUrlHelper.php

    r46 r75  
    33 
    44/** 
    5  * Link to a user profile  
     5 * Link to a user profile 
    66 * 
    77 * @param  sfGuardUser $person 
     
    1515    return __('&lt;Removed profile&gt;'); 
    1616  } 
    17    
    18   $options = _parse_attributes($options); 
    19    
     17 
     18  $options = _parse_attributes($options); 
     19 
    2020  if (isset($options['label'])) 
    2121  { 
     
    2727    $label = $person->getDisplayName(); 
    2828  } 
    29    
     29 
    3030  $append = ''; 
    3131  if (isset($options['include_flag'])) 
     
    3737    unset($options['include_flag']); 
    3838  } 
    39    
     39 
    4040  if (!isset($options['title'])) 
    4141  { 
     
    4343                           array('%person%' => $person->getDisplayName())); 
    4444  } 
    45    
    46   return link_to($label,  
     45 
     46  return link_to($label, 
    4747                 '@person_page?username='.$person->getUsername(), 
    4848                 $options).$append; 
     
    5050 
    5151/** 
    52  * Link to a company profile  
     52 * Link to a company profile 
    5353 * 
    5454 * @param  Company  $company 
     
    6262    return __('&lt;Removed company&gt;'); 
    6363  } 
    64    
    65   $options = _parse_attributes($options); 
    66    
     64 
     65  $options = _parse_attributes($options); 
     66 
    6767  if (isset($options['label'])) 
    6868  { 
     
    7474    $label = $company->getName(); 
    7575  } 
    76    
     76 
    7777  $append = ''; 
    7878  if (isset($options['include_flag'])) 
     
    8484    unset($options['include_flag']); 
    8585  } 
    86    
     86 
    8787  if (!isset($options['title'])) 
    8888  { 
     
    9090                           array('%company%' => $company->getName())); 
    9191  } 
    92    
    93   return link_to($label,  
     92 
     93  return link_to($label, 
    9494                 '@company_page?slug='.$company->getSlug(), 
    9595                 $options).$append; 
     
    9797 
    9898/** 
    99  * Link to a application profile  
     99 * Link to a application profile 
    100100 * 
    101101 * @param  Application  $application 
     
    109109    return __('&lt;Removed application&gt;'); 
    110110  } 
    111    
    112   $options = _parse_attributes($options); 
    113    
     111 
     112  $options = _parse_attributes($options); 
     113 
    114114  if (isset($options['label'])) 
    115115  { 
     
    121121    $label = $application->getName(); 
    122122  } 
    123    
     123 
    124124  $append = ''; 
    125125  if (isset($options['include_flag'])) 
     
    131131    unset($options['include_flag']); 
    132132  } 
    133    
     133 
    134134  if (!isset($options['title'])) 
    135135  { 
     
    137137                           array('%app%' => $application->getName())); 
    138138  } 
    139    
    140   return link_to($label,  
     139 
     140  return link_to($label, 
    141141                 '@application_page?slug='.$application->getSlug(), 
    142142                 $options).$append; 
     
    144144 
    145145/** 
    146  * Link to a job profile  
     146 * Link to a job profile 
    147147 * 
    148148 * @param  Job  $job 
     
    156156    return __('&lt;Removed job offer&gt;'); 
    157157  } 
    158    
    159   $options = _parse_attributes($options); 
    160    
     158 
     159  $options = _parse_attributes($options); 
     160 
    161161  if (isset($options['label'])) 
    162162  { 
     
    168168    $label = $job->getTitle(); 
    169169  } 
    170    
     170 
    171171  $append = ''; 
    172172  if (isset($options['include_flag'])) 
     
    178178    unset($options['include_flag']); 
    179179  } 
    180    
     180 
    181181  if (!isset($options['title'])) 
    182182  { 
     
    184184                           array('%jobtitle%' => $job->getTitle())); 
    185185  } 
    186    
    187   return link_to($label,  
     186 
     187  return link_to($label, 
    188188                 '@job_page?slug='.$job->getSlug(), 
    189189                 $options).$append; 
     
    204204  $options = _parse_attributes($options); 
    205205  $image_src = null; 
     206 
    206207  if (isset($options['imgclass'])) 
    207208  { 
     
    213214    $imgclass = 'avatar'; 
    214215  } 
     216 
    215217  $force_reload = false; 
    216218  if (isset($options['force_reload'])) 
     
    219221    unset($options['force_reload']); 
    220222  } 
    221   if ($person->getAvatarPath()) 
    222   { 
    223     if ($force_reload) 
    224     { 
    225       $image_src = sprintf('%s?%s', 
    226                            $person->getFullAvatarPath($format), 
    227                            time()); 
    228     } 
    229     else 
    230     { 
    231       $image_src = $person->getFullAvatarPath($format); 
    232     } 
    233   } 
    234   if (is_null($image_src) && !file_exists(sfConfig::get('sf_upload_dirname').$image_src)) 
    235   { 
    236     $formats = sfConfig::get('app_people_formats', array()); 
    237     $image_src = $formats[$format]['default']; 
    238   } 
     223 
    239224  if (isset($options['route'])) 
    240225  { 
     
    246231    $route = '@person_page?username='.$person->getUsername(); 
    247232  } 
    248   $image = image_tag($image_src, 'alt='.$person->getDisplayName().' class='.$imgclass); 
    249   return link_to($image, $route, $options); 
     233 
     234  if (!$content = person_image_tag($person, $format, 'alt='.$person->getDisplayName().' class='.$imgclass)) 
     235  { 
     236    $content = $person->getDisplayName(); 
     237  } 
     238 
     239  return link_to($content, $route, $options); 
    250240} 
    251241 
  • trunk/lib/model/Application.php

    r71 r75  
    150150    } 
    151151    return implode($separator, $devs); 
    152   } 
    153  
    154   /** 
    155    * Returns full screenshot path for current app 
    156    * 
    157    * @return string 
    158    */ 
    159   public function getFullScreenshotPath() 
    160   { 
    161     if (!$this->getScreenshotPath()) 
    162     { 
    163       return sfConfig::get('app_applications_default_screenshot'); 
    164     } 
    165     $t = explode('/', sfConfig::get('sf_upload_dir'));// FIXME: move this somewhere else 
    166     $base_dir = array_pop($t); 
    167     return sprintf('/%s/%s/%s', 
    168                    $base_dir, 
    169                    sfConfig::get('app_applications_upload_dir', 'applications'), 
    170                    $this->getScreenshotPath()); 
    171152  } 
    172153 
  • trunk/lib/model/Company.php

    r49 r75  
    108108    } 
    109109    return implode($separator, $people); 
    110   } 
    111  
    112   /** 
    113    * Returns logo image full path 
    114    * 
    115    * @return string 
    116    */ 
    117   public function getFullLogoPath() 
    118   { 
    119     if (!$this->getLogoPath()) 
    120     { 
    121       return sfConfig::get('app_companies_default_logo'); 
    122     } 
    123     return sprintf('/%s/%s/%s', 
    124                    sfConfig::get('sf_upload_dir_name'), 
    125                    sfConfig::get('app_companies_upload_dir', 'companies'), 
    126                    $this->getLogoPath()); 
    127110  } 
    128111 
  • trunk/lib/utils/SymfoniansTestBrowser.class.php

    r71 r75  
    5252   * Simulates a click on a link or button. 
    5353   * 
    54    * @param string $name       The link or button text 
    55    * @param array  $arguments 
    56    * 
    57    * @return sfBrowser 
     54   * @param string $name       The link or button text 
     55   * @param array   $arguments 
     56   * 
     57   * @return SymfoniansTestBrowser 
    5858   */ 
    5959  public function click($name, $arguments = array()) 
     
    6868    catch (sfException $e) 
    6969    { 
    70       self::$test->fail(sprintf('%s in "%s"', $e->getMessage(), $this->getResponse()->getContent())); 
     70      self::$test->fail(sprintf('"%s" in "%s"', $e->getMessage(), $this->getResponse()->getContent())); 
    7171      return $this; 
    7272    } 
     73  } 
     74 
     75  public function followRedirect() 
     76  { 
     77    try 
     78    { 
     79      $r = parent::followRedirect(); 
     80    } 
     81    catch (Exception $e) 
     82    { 
     83      self::$test->fail(sprintf('%s: %s', $e->getMessage(), html_entity_decode($this->getContext()->getResponse()->getContent())), ENT_QUOTES, 'UTF-8'); 
     84 
     85      $r = $this; 
     86    } 
     87 
     88    return $r; 
     89  } 
     90 
     91  /** 
     92   * Generates and returns a test admin user 
     93   * 
     94   * @return sfGuardUser 
     95   */ 
     96  public static function getAdminTestUser() 
     97  { 
     98    if (is_null(self::$adminUser)) 
     99    { 
     100      self::$adminUser = usersFactory::createTestUser('testadmin', 'testpass2', 'testadmin@gmail.com', true); 
     101    } 
     102 
     103    return self::$adminUser; 
     104  } 
     105 
     106  /** 
     107   * Generates and returns a test user 
     108   * 
     109   * @return sfGuardUser 
     110   */ 
     111  public static function getStandardTestUser() 
     112  { 
     113    if (is_null(self::$standardUser)) 
     114    { 
     115      self::$standardUser = usersFactory::createTestUser('testuser', 'testpass1', 'testuser@gmail.com'); 
     116    } 
     117 
     118    return self::$standardUser; 
     119  } 
     120 
     121  /** 
     122   * Checks if crrent request has a given parameter 
     123   * 
     124   * @param  string  $name 
     125   * @return SymfoniansTestBrowser 
     126   */ 
     127  public function hasRequestParameter($name) 
     128  { 
     129    $request = $this->getRequest(); 
     130 
     131    self::$test->ok($request->hasParameter($name), 
     132                    sprintf('request has parameter "%s"', $name) . 
     133                    ($request->hasParameter($name) ? 
     134                       sprintf(': "%s"', $request->getParameter($name)) : '')); 
     135 
     136    return $this; 
     137  } 
     138 
     139  /** 
     140   * Checks the HTTP request method 
     141   * 
     142   * @param  string  $method 
     143   * @return SymfoniansTestBrowser 
     144   */ 
     145  public function isRequestMethod($method) 
     146  { 
     147    self::$test->ok($this->getContext()->getRequest()->isMethod($method), sprintf('request method is "%s"', $method)); 
     148 
     149    return $this; 
     150  } 
     151 
     152  /** 
     153   * Loads project default fixtures 
     154   * 
     155   */ 
     156  public static function loadFixtures() 
     157  { 
     158    self::$test->comment('Loading fixtures...'); 
     159 
     160    $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 
     161    $t->run(array('application' => self::$configuration->getApplication())); 
     162 
     163    self::$test->comment('Fixtures loaded.'); 
     164  } 
     165 
     166  /** 
     167   * Sets a form field in the browser. 
     168   * 
     169   * @param string $name   The field name 
     170   * @param string $value  The field value 
     171   * 
     172   * @return SymfoniansTestBrowser 
     173   */ 
     174  public function setField($name, $value) 
     175  { 
     176    self::$test->diag(sprintf('setting field "%s" value to "%s"', $name, $value)); 
     177 
     178    return parent::setField($name, $value); 
     179  } 
     180 
     181  /** 
     182   * Retrieve the current user session 
     183   * 
     184   * @return myUser 
     185   */ 
     186  protected function getSession() 
     187  { 
     188    return $this->getContext()->getUser(); 
     189  } 
     190 
     191  /** 
     192   * Sets the value of a session attribute 
     193   * 
     194   * @param  string       $name 
     195   * @param  mixed        $value 
     196   * @param  string|null  $ns 
     197   * @return SymfoniansTestBrowser 
     198   */ 
     199  public function sessionSetAttribute($name, $value, $ns = null) 
     200  { 
     201    $this->getSession()->setAttribute($name, $value, $ns); 
     202    self::$test->comment(sprintf('Setting "%s" session attribute', $name)); 
     203    return $this; 
     204  } 
     205 
     206  /** 
     207   * Checks if a session attribute matches a value 
     208   * 
     209   * @param  string       $name 
     210   * @param  mixed        $value 
     211   * @param  string|null  $ns 
     212   * @return SymfoniansTestBrowser 
     213   */ 
     214  public function sessionAttributeEquals($name, $value, $ns = null) 
     215  { 
     216    self::$test->is($this->getSession()->getAttribute($name, null, $ns), $value, sprintf('Session attribute "%s" equals expected value', $name)); 
     217    return $this; 
     218  } 
     219 
     220  /** 
     221   * Forces current user to be authenticated 
     222   * 
     223   * @param  boolean  $v 
     224   * @return SymfoniansTestBrowser 
     225   */ 
     226  public function sessionSetAuthenticated($v = true) 
     227  { 
     228    $this->getSession()->setAuthenticated($v); 
     229    return $this; 
    73230  } 
    74231 
     
    80237   * @return SymfoniansTestBrowser 
    81238   */ 
    82   public function signInUser($goto = '/', $admin = false) 
     239  public function signInTestUser($goto = '/', $admin = false) 
    83240  { 
    84241    if ($admin) 
     
    86243      $user = $this->getAdminTestUser(); 
    87244      $pass = 'testpass2'; 
     245      self::$test->comment('Login admin test user'); 
    88246    } 
    89247    else 
     
    91249      $user = $this->getStandardTestUser(); 
    92250      $pass = 'testpass1'; 
     251      self::$test->comment('Login standard test user'); 
    93252    } 
    94253 
    95254    self::$test->comment('Login user'); 
    96255 
     256    return $this->signInUser($user->getUsername(), $pass, $goto); 
     257  } 
     258 
     259  /** 
     260   * Sign in a user from the fixtures 
     261   * 
     262   * @param  string   $username  Username 
     263   * @param  string   $password  Password 
     264   * @param  string   $goto      The url to go to after been authenticated 
     265   * @return SymfoniansTestBrowser 
     266   */ 
     267  public function signInUser($username, $password, $goto = '/') 
     268  { 
     269    self::$test->comment(sprintf('User "%s" signs in', $username)); 
    97270    return $this-> 
    98       click('Sign in')-> 
    99       setField('signin[username]', $user->getUsername())-> 
    100       setField('signin[password]', $pass)-> 
     271      get('/login')-> 
     272      setField('signin[username]', $username)-> 
     273      setField('signin[password]', $password)-> 
    101274      click('sign in')-> 
    102275      followRedirect()-> 
     
    105278 
    106279  /** 
    107    * Generates and returns a test user 
    108    * 
    109    * @return sfGuardUser 
    110    */ 
    111   public static function getStandardTestUser() 
    112   { 
    113     if (is_null(self::$standardUser)) 
    114     { 
    115       self::$standardUser = usersFactory::createTestUser('testuser', 'testpass1', 'testuser@gmail.com'); 
    116     } 
    117  
    118     return self::$standardUser; 
    119   } 
    120  
    121   /** 
    122    * Generates and returns a test admin user 
    123    * 
    124    * @return sfGuardUser 
    125    */ 
    126   public static function getAdminTestUser() 
    127   { 
    128     if (is_null(self::$adminUser)) 
    129     { 
    130       self::$adminUser = usersFactory::createTestUser('testadmin', 'testpass2', 'testadmin@gmail.com', true); 
    131     } 
    132  
    133     return self::$adminUser; 
    134   } 
    135  
    136   /** 
    137    * Loads project default fixtures 
    138    * 
    139    */ 
    140   public static function loadFixtures() 
    141   { 
    142     self::$test->comment('Loading fixtures...'); 
    143  
    144     $t = new sfPropelLoadDataTask(self::$configuration->getEventDispatcher(), new sfAnsiColorFormatter()); 
    145     $t->run(array('application' => self::$configuration->getApplication())); 
    146  
    147     self::$test->comment('Fixtures loaded.'); 
    148   } 
    149  
    150   /** 
    151    * Sets a form field in the browser. 
    152    * 
    153    * @param string $name   The field name 
    154    * @param string $value  The field value 
    155    * 
    156    * @return sfBrowser 
    157    */ 
    158   public function setField($name, $value) 
    159   { 
    160     self::$test->diag(sprintf('setting field "%s" value to "%s"', $name, $value)); 
    161  
    162     return parent::setField($name, $value); 
    163   } 
    164  
    165   /** 
    166    * Retrieve the current user session 
    167    * 
    168    * @return myUser 
    169    */ 
    170   protected function getSession() 
    171   { 
    172     return $this->getContext()->getUser(); 
    173   } 
    174  
    175   /** 
    176    * Sets the value of a session attribute 
    177    * 
    178    * @param  string       $name 
    179    * @param  mixed        $value 
    180    * @param  string|null  $ns 
    181    * @return SymfoniansTestBrowser 
    182    */ 
    183   public function sessionSetAttribute($name, $value, $ns = null) 
    184   { 
    185     $this->getSession()->setAttribute($name, $value, $ns); 
    186     self::$test->comment(sprintf('Setting "%s" session attribute', $name)); 
    187     return $this; 
    188   } 
    189  
    190   /** 
    191    * Checks if a session attribute matches a value 
    192    * 
    193    * @param  string       $name 
    194    * @param  mixed        $value 
    195    * @param  string|null  $ns 
    196    * @return SymfoniansTestBrowser 
    197    */ 
    198   public function sessionAttributeEquals($name, $value, $ns = null) 
    199   { 
    200     self::$test->is($this->getSession()->getAttribute($name, null, $ns), $value, sprintf('Session attribute "%s" equals expected value', $name)); 
    201     return $this; 
    202   } 
    203  
    204   /** 
    205    * Forces current user to be authenticated 
    206    * 
    207    * @param  boolean  $v 
    208    * @return SymfoniansTestBrowser 
    209    */ 
    210   public function sessionSetAuthenticated($v = true) 
    211   { 
    212     $this->getSession()->setAuthenticated($v); 
    213     return $this; 
     280   * Signs out current user 
     281   * 
     282   * @return SymfoniansTestBrowser 
     283   */ 
     284  public function signOutUser() 
     285  { 
     286    self::$test->comment('User signed out'); 
     287    return $this->get('/logout')->followRedirect(); 
    214288  } 
    215289 
  • trunk/lib/utils/sfValidatedThumb.class.php

    r70 r75  
    11<?php 
    22/** 
    3  * Saves an uploaded image file as a web thumb and updates a Propel object  
     3 * Saves an uploaded image file as a web thumb and updates a Propel object 
    44 * accordingly. The thumbnail generation depends on the sfThumbnail plugin. 
    5  *   
    6  * This class aims to be used as the one to use with the sfValidatorFile  
     5 * 
     6 * This class aims to be used as the one to use with the sfValidatorFile 
    77 * validator: 
    8  *  
     8 * 
    99 *     new sfValidatorFile(array('validated_file_class' => 'sfValidatedThumb')); 
    1010 * 
    1111 * You must use the saveThumb() method to save the thumb on your filesystem: 
    12  *  
    13  *     $thumb->saveThumb('applications', $application, 'setThumbnail') 
    14  *  
     12 * 
     13 *     $thumb->saveThumb('config_section', $propelObject, 'setThumbnail') 
     14 * 
     15 * The "config_section" must be a configuration entry in your app.yml file, and 
     16 * exists in the $allowedType property of the current class. 
     17 * 
     18 * Here's an example of configuration entry in app.yml: 
     19 * 
     20 *     all: 
     21 *       applications: 
     22 *         upload_dir:          applications 
     23 *         thumb.width:         200 
     24 *         thumb.height:        140 
     25 *         thumb.quality:       90 
     26 *         default_screenshot:  default_screenshot.png 
     27 * 
    1528 * @package    symfonians 
    1629 * @subpackage validator 
     
    1831class sfValidatedThumb extends sfValidatedFile 
    1932{ 
    20    
     33  const 
     34    DEFAULT_THUMB_WIDTH   = 200, 
     35    DEFAULT_THUMB_HEIGHT  = 140, 
     36    DEFAULT_THUMB_QUALITY = 90; 
     37 
    2138  /** 
    2239   * Allowed types 
     
    2441   */ 
    2542  protected static $allowedTypes = array('applications', 'people', 'companies'); 
    26    
     43 
    2744  /** 
    2845   * Makes thumb from app.yml configuration and updates Propel related object on 
     
    4057      throw new sfConfigurationException('The sfThumbnailPlugin must be installed'); 
    4158    } 
    42      
     59 
    4360    if (!in_array($type, self::$allowedTypes)) 
    4461    { 
    4562      throw new InvalidArgumentException(sprintf('Type "%s" is invalid', $type)); 
    4663    } 
    47      
     64 
    4865    if (!method_exists($object, $thumbSetter)) 
    4966    { 
    50       throw new InvalidArgumentException(sprintf('Method "%s" does not exist for "%s" object',  
     67      throw new InvalidArgumentException(sprintf('Method "%s" does not exist for "%s" object', 
    5168                                                 $thumbSetter, get_class($object))); 
    5269    } 
    53      
    54     $width    = sfConfig::get(sprintf('app_%s_thumb.width', $type), 200); 
    55     $height   = sfConfig::get(sprintf('app_%s_thumb.height', $type), 140); 
    56     $quality  = sfConfig::get(sprintf('app_%s_thumb.quality', $type), 90); 
    57      
     70 
     71    $width    = sfConfig::get(sprintf('app_%s_thumb.width', $type), self::DEFAULT_THUMB_WIDTH); 
     72    $height   = sfConfig::get(sprintf('app_%s_thumb.height', $type), self::DEFAULT_THUMB_HEIGHT); 
     73    $quality  = sfConfig::get(sprintf('app_%s_thumb.quality', $type), self::DEFAULT_THUMB_QUALITY); 
     74 
    5875    $fileName = md5($object->__toString()).'.jpg'; 
    59      
     76 
    6077    $file = sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR. 
    6178            sfConfig::get(sprintf('app_%s_upload_dir', $type)).DIRECTORY_SEPARATOR. 
    6279            $fileName; 
    63      
    64     $thumbnail = new sfThumbnail($width, $height, true, true, $quality, null); 
     80 
     81    $thumbnail = new sfThumbnail($width, $height, true, true, $quality, 'sfGDAdapter'); 
    6582    $thumbnail->loadFile($this->getTempName()); 
    6683    $thumbnail->save($file, 'image/jpeg'); 
    6784    $this->savedName = $file; 
    68      
     85 
    6986    $object->$thumbSetter($fileName); 
    70      
     87 
    7188    return ($object->save() > 0); 
    7289  } 
    73    
     90 
     91  /** 
     92   * Override save() method to throw an InvalidException when used in this 
     93   * context (the saveThumb() method must be used) 
     94   * 
     95   * @see    sfValidatedFile 
     96   * @throws LogicException in every case 
     97   */ 
    7498  public function save($file, $fileMode = 0666, $create = true, $dirMode = 0777) 
    7599  { 
    76100    throw new LogicException('You must use the saveThumb() method'); 
    77101  } 
    78    
    79102} 
  • trunk/lib/validator/sfValidatorSchemaLicence.class.php

    r70 r75  
    11<?php 
     2/** 
     3 * This validators validates the license and is_opensource fields 
     4 * 
     5 */ 
    26class sfValidatorSchemaLicence extends sfValidatorSchema 
    37{ 
     8  /** 
     9   * Apply validation 
     10   * 
     11   * @param mixed $values 
     12   */ 
    413  protected function doClean($values) 
    514  { 
    615    //parent::doClean($values); 
    7      
     16 
    817    $errorSchema = new sfValidatorErrorSchema($this); 
    9      
     18 
    1019    if ($values['is_opensource'] && 0 === strlen(trim($values['licence']))) 
    1120    { 
     
    1322      throw new sfValidatorErrorSchema($this, array('licence' => $error)); 
    1423    } 
     24 
     25    return $values; 
    1526  } 
    1627} 
  • trunk/lib/validator/sfValidatorTags.class.php

    r70 r75  
    11<?php 
    2 class sfValidatorTags extends sfValidatorBase  
     2/** 
     3 * This validators validates tags string 
     4 * 
     5 */ 
     6class sfValidatorTags extends sfValidatorBase 
    37{ 
    4    
     8 
     9  /** 
     10   * Configures the validator 
     11   * 
     12   * @param unknown_type $options 
     13   * @param unknown_type $messages 
     14   */ 
    515  public function configure($options = array(), $messages = array()) 
    616  { 
     
    818    $this->setMessage('invalid', 'Looks like your tags should be separated by the "%separator%" char'); 
    919  } 
    10    
     20 
     21  /** 
     22   * Apply validator 
     23   * 
     24   * @param  mixed $value 
     25   * @return mixed 
     26   */ 
    1127  public function doClean($value) 
    1228  { 
     
    1531      return $value; 
    1632    } 
    17      
     33 
    1834    $words = str_word_count($value); 
    1935    $seps = substr_count($value, $this->getOption('separator')); 
    20      
     36 
    2137    if ($seps < $words / 2) 
    2238    { 
    2339      throw new sfValidatorError($this, 'invalid', array('separator' => $this->getOption('separator'))); 
    2440    } 
    25      
     41 
    2642    return $value; 
    2743  } 
    28    
     44 
    2945} 
  • trunk/lib/widget/sfWidgetFormSchemaFormatterDiv.class.php

    r53 r75  
    77{ 
    88  protected 
    9     $rowFormat       = "<div class=\"form-row%is_error%\">\n  %label%\n  %error%\n  %field%\n  %help%\n%hidden_fields%</div>\n", 
     9    $rowFormat       = "<div class=\"form-row%is_error%%is_required%\">\n  %label%\n  %error%\n  %field%\n  %help%\n%hidden_fields%</div>\n", 
    1010    $errorRowFormat  = "%errors%\n", 
    1111    $helpFormat      = '<div class="form-help">%help%</div>', 
    1212    $decoratorFormat = "\n  %content%"; 
    13    
     13 
    1414  public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) 
    1515  { 
    1616    return strtr(parent::formatRow($label, $field, $errors, $help, $hiddenFields), array( 
    17       '%is_error%' => (count($errors) > 0) ? ' field_error' : '', 
     17      '%is_error%'    => (count($errors) > 0) ? ' field_error' : '', 
     18      //'%is_required%' => $field, 
    1819    )); 
    1920  } 
  • trunk/test/functional/main/applicationsActionsTest.php

    r71 r75  
    1616  isRequestParameter('action', 'home')-> 
    1717  isCached(true)-> 
    18   checkResponseElement('body', '!/This is a temporary page/')-> 
    1918  checkResponseElement('h2', '/Symfony applications/')-> 
    2019  checkResponseElement('.thumbs_list h4', '/Yahoo Bookmarks/', array('position' => 0))-> 
     
    3433  checkResponseElement('div.summary', '/SplitGames est la première communauté européenne/')-> 
    3534 
     35  // No admin links 
     36  checkResponseElement('ul.admin_actions', '!/Edit/')-> 
     37  checkResponseElement('ul.admin_actions', '!/Delete/')-> 
     38 
    3639  // Checking application form in authenticated mode 
    3740  click('Add an application')-> 
    3841  isStatusCode(401)-> 
    39   signInUser('/application/add')-> 
     42  signInUser('niko', 'password', '/application/add')-> 
    4043  isStatusCode(200)-> 
    4144 
     
    4346  responseContains('<input type="checkbox" name="application[is_opensource]" id="application_is_opensource" />')-> 
    4447 
     48  // Test application form error handling 
     49  click('Add this application')-> 
     50  isStatusCode(200)-> 
     51  isRequestParameter('module', 'applications')-> 
     52  isRequestParameter('action', 'edit')-> 
     53  checkResponseElement('ul.error_list', '/This field is required/', array('position' => 0))-> 
     54 
    4555  // Create a new application 
    4656  setField('application[name]', 'My test app')-> 
     57  setField('application[homepage]', 'http://mytestapp.com/')-> 
     58  setField('application[screenshot_file]', dirname(__FILE__).'/assets/sample_image.png')-> 
     59  setField('application[description]', 'The coolest app of the net.')-> 
     60  setField('application[tags]', 'coolapp, appcool')-> 
     61  setField('application[country]', 'FR')-> 
     62  setField('application[started_at][year]', '2004')-> 
     63  setField('application[started_at][month]', '1')-> 
     64  setField('application[started_at][day]', '1')-> 
    4765  click('Add this application')-> 
    4866  isStatusCode(302)-> 
     
    5169  followRedirect()-> 
    5270 
    53   // Connect as developer 
     71  // Connect a developer 
    5472  isRequestParameter('module', 'applications')-> 
    5573  isRequestParameter('action', 'connectAsDeveloper')-> 
     
    5876  setField('connection[role]', 'My role')-> 
    5977  setField('connection[description]', 'Mostly sleeping')-> 
     78  setField('connection[started_at][year]', '2004')-> 
     79  setField('connection[started_at][month]', '1')-> 
     80  setField('connection[started_at][day]', '1')-> 
     81  setField('connection[ended_at][year]', '2008')-> 
     82  setField('connection[ended_at][month]', '1')-> 
     83  setField('connection[ended_at][day]', '1')-> 
    6084  click('Connect your profile to this application')-> 
    6185  isRequestParameter('module', 'applications')-> 
     
    6488  followRedirect()-> 
    6589 
    66   // Check application details page 
    67   isRequestParameter('module', 'applications')-> 
    68   isRequestParameter('action', 'details')-> 
    69   isRequestParameter('slug', 'my-test-app')-> 
     90  // Check application details page (we're logged as creator) 
     91  isRequestParameter('module', 'applications')-> 
     92  isRequestParameter('action', 'details')-> 
     93  isRequestParameter('slug', 'my-test-app')-> 
     94  checkResponseElement('h2', '/My test app/')-> 
     95  checkResponseElement('div.summary', '/The coolest app of the net/')-> 
     96  checkResponseElement('ul.tags', '/appcool/', array('position' => 0))-> 
     97  checkResponseElement('ul.tags', '/coolapp/', array('position' => 0))-> 
     98  checkResponseElement('li.clock_play', '/Development started on January 2004/', array('position' => 0))-> 
    7099  checkResponseElement('p.notice', '/You have been marked as implied with this application/', array('position' => 0))-> 
     100  checkResponseElement('table.related_people_list tr', '/Nicolas Perriault/', array('position' => 0))-> 
     101  checkResponseElement('table.related_people_list tr', '/My role/', array('position' => 0))-> 
     102  checkResponseElement('table.related_people_list tr', '/Mostly sleeping/', array('position' => 0))-> 
     103  checkResponseElement('img.app_screenshot', true)-> 
     104 
     105  // Check admin links 
     106  checkResponseElement('ul.admin_actions', '/Edit/')-> 
     107  checkResponseElement('ul.admin_actions', '/Delete/')-> 
    71108 
    72109  // Connect a company 
     
    75112  isRequestParameter('action', 'connectAsCompany')-> 
    76113  isStatusCode(200)-> 
     114  setField('connection[company_id]', CompanyPeer::retrieveBySlug('clever-age')->getId())-> 
    77115  setField('connection[role]', 'My company role')-> 
     116  setField('connection[description]', 'Mostly haking')-> 
    78117  click('Connect the company to this application')-> 
    79118  isRequestParameter('module', 'applications')-> 
    80119  isRequestParameter('action', 'connectAsCompany')-> 
    81   // FIXME: current testuser doesn't have any companies! 
    82120  isStatusCode(302)-> 
    83121  followRedirect()-> 
     
    86124  isRequestParameter('slug', 'my-test-app')-> 
    87125  checkResponseElement('p.notice', '/The company has been marked as connected to this application/', array('position' => 0))-> 
     126  checkResponseElement('table.company_applications_list tr', '/Clever Age/', array('position' => 0))-> 
     127  checkResponseElement('table.company_applications_list tr', '/My company role/', array('position' => 0))-> 
     128  checkResponseElement('table.company_applications_list tr', '/Mostly haking/', array('position' => 0))-> 
     129 
     130  // Edit company connection 
     131  click('Edit company connection')-> 
     132  isRequestParameter('module', 'applications')-> 
     133  isRequestParameter('action', 'connectAsCompany')-> 
     134  isStatusCode(200)-> 
     135  setField('connection[role]', 'My company role was big')-> 
     136  click('Connect the company to this application')-> 
     137  isRequestParameter('module', 'applications')-> 
     138  isRequestParameter('action', 'connectAsCompany')-> 
     139  isStatusCode(302)-> 
     140  followRedirect()-> 
     141  isRequestParameter('module', 'applications')-> 
     142  isRequestParameter('action', 'details')-> 
     143  checkResponseElement('table.company_applications_list tr', '/My company role was big/', array('position' => 0))-> 
    88144 
    89145  // Edit application 
     
    103159  checkResponseElement('p.notice', '/Application updated/', array('position' => 0))-> 
    104160  checkResponseElement('h2', '/My edited test app/', array('position' => 0))-> 
    105   checkResponseElement('table.related_people_list tr', '/testuser/', array('position' => 0))-> 
    106   checkResponseElement('table.related_people_list tr', '/My role/', array('position' => 0))-> 
    107   checkResponseElement('table.related_people_list tr', '/Mostly sleeping/', array('position' => 0))-> 
    108  
     161 
     162  // Check homepage 
     163  get('/applications')-> 
     164  isRequestParameter('module', 'applications')-> 
     165  isRequestParameter('action', 'home')-> 
     166  checkResponseElement('.thumbs_list h4', '/My edited test app/')-> 
     167 
     168  // Check pagination 
     169  checkResponseElement('p.navigation a', '/2/')-> 
     170  click('2')-> 
     171  isStatusCode(200)-> 
     172  isRequestParameter('module', 'applications')-> 
     173  isRequestParameter('action', 'home')-> 
     174  isRequestParameter('page', 2)-> 
     175  checkResponseElement('p.navigation a', '/1/')-> 
     176  click('1')-> 
     177  isStatusCode(200)-> 
     178  isRequestParameter('module', 'applications')-> 
     179  isRequestParameter('action', 'home')-> 
     180  isRequestParameter('page', 1)-> 
     181 
     182  // Check tag cloud 
     183  checkResponseElement('.tags_cloud', '/coolapp/')-> 
     184  checkResponseElement('.tags_cloud', '/appcool/')-> 
     185 
     186  // Check tagged apps list 
     187  click('coolapp')-> 
     188  isStatusCode(200)-> 
     189  isRequestParameter('module', 'applications')-> 
     190  isRequestParameter('action', 'home')-> 
     191  isRequestParameter('tag', 'coolapp')-> 
     192 
     193  // Check tags list page 
     194  click('All tags')-> 
     195  isStatusCode(200)-> 
     196  isRequestParameter('module', 'applications')-> 
     197  isRequestParameter('action', 'tags')-> 
     198  checkResponseElement('.big_cloud', '/coolapp/')-> 
     199  checkResponseElement('.big_cloud', '/appcool/')-> 
     200 
     201  // Shutdown 
     202  signOutUser()-> 
    109203  shutdown() 
    110204; 
  • trunk/test/functional/main/companiesActionsTest.php

    r66 r75  
    55$browser = new SymfoniansTestBrowser($configuration); 
    66$browser->initialize(); 
     7$browser->loadFixtures(); 
    78 
    89$browser-> 
     10  get('/logout')-> // Forces the purge of the session 
    911  get('/companies')-> 
    1012  isStatusCode(200)-> 
     
    1214  isRequestParameter('action', 'home')-> 
    1315  isCached(true)-> 
    14   checkResponseElement('body', '!/This is a temporary page/')-> 
     16  checkResponseElement('table.common h4', '/Mageneration/', array('position' => 0))-> 
     17  checkResponseElement('table.common h4', '/Sensio/', array('position' => 1))-> 
     18  checkResponseElement('table.common h4', '/Clever Age Poland/', array('position' => 2))-> 
    1519  checkResponseElement('table.common h4', '/Clever Age/', array('position' => 3))-> 
    1620 
    1721  click('Clever Age')-> 
    1822  isStatusCode(200)-> 
     23  isRequestMethod('get')-> 
    1924  isRequestParameter('module', 'companies')-> 
    2025  isRequestParameter('action', 'details')-> 
     26  isRequestParameter('slug', 'clever-age')-> 
    2127  isCached(true)-> 
    2228  checkResponseElement('h2', '/Clever Age/')-> 
     
    4753  checkResponseElement('table.company_applications_list', '/Mageneration.com/')-> 
    4854 
    49   // Contact button (check auth) 
     55  // Check security 
    5056  click('Contact this company')-> 
    5157  isStatusCode(401)-> 
    5258  back()-> 
    53  
    54   // Add button (check auth) 
    5559  click('Add your company!')-> 
    5660  isStatusCode(401)-> 
     61  back()-> 
     62  signInUser('niko', 'password', '/companies')-> 
     63  click('Clever Age')-> 
     64  click('Contact this company')-> 
     65  isStatusCode(200)-> 
     66  back()-> 
     67  click('Add your company!')-> 
     68  isRequestParameter('module', 'companies')-> 
     69  isRequestParameter('action', 'edit')-> 
     70  isStatusCode(200)-> 
     71  click('Add this company to the directory')-> 
     72  isRequestMethod('post')-> 
     73  isStatusCode(200)-> 
     74  setField('company[name]', 'My Company')-> 
     75  setField('company[summary]', 'This is my company')-> 
     76  setField('company[email]', 'niko@niko.net')-> 
     77  setField('company[country]', 'FR')-> 
     78  setField('company[address]', '12, rue des boites')-> 
     79  setField('company[zip]', '69001')-> 
     80  setField('company[city]', 'Lyon')-> 
     81  setField('company[phone]', '0102030405')-> 
     82  setField('company[logo_file]', dirname(__FILE__).'/assets/sample_image.png')-> 
     83  click('Add this company to the directory')-> 
     84  isRequestParameter('module', 'companies')-> 
     85  isRequestParameter('action', 'edit')-> 
     86  isRequestMethod('post')-> 
     87  isStatusCode(302)-> 
     88  followRedirect()-> 
    5789 
     90  // Connect a member 
     91  isRequestParameter('module', 'companies')-> 
     92  isRequestParameter('action', 'connect')-> 
     93  isRequestParameter('slug', 'my-company')-> 
     94  isStatusCode(200)-> 
     95  setField('connection[role]', 'Boss')-> 
     96  setField('connection[description]', 'Lazy guy I was')-> 
     97  setField('connection[started_at][year]', '2008')-> 
     98  setField('connection[started_at][month]', '01')-> 
     99  setField('connection[started_at][day]', '01')-> 
     100  setField('connection[ended_at][year]', '2008')-> 
     101  setField('connection[ended_at][month]', '05')-> 
     102  setField('connection[ended_at][day]', '01')-> 
     103  click('Connect your profile to this company')-> 
     104  isRequestParameter('module', 'companies')-> 
     105  isRequestParameter('action', 'connect')-> 
     106  isRequestParameter('slug', 'my-company')-> 
     107  isRequestMethod('post')-> 
     108  isStatusCode(302)-> 
     109  followRedirect()-> 
     110  checkResponseElement('p.notice', '/Your connection informations has been added/', array('position' => 0))-> 
     111  checkResponseElement('table.company_people_list', '/Nicolas Perriault(.*)has been(.*)Boss(.*)for 4 months until may 2008/')-> 
     112 
     113  // Check companies homepage 
     114  get('/companies')-> 
     115  isStatusCode(200)-> 
     116  isRequestParameter('module', 'companies')-> 
     117  isRequestParameter('action', 'home')-> 
     118  checkResponseElement('table.common h4', '/My Company/', array('position' => 0))-> 
     119 
     120  // Check details page 
     121  click('My Company')-> 
     122  isRequestParameter('module', 'companies')-> 
     123  isRequestParameter('action', 'details')-> 
     124  isRequestParameter('slug', 'my-company')-> 
     125  isStatusCode(200)-> 
     126  checkResponseElement('h2', '/My Company/')-> 
     127  checkResponseElement('div.summary', '/This is my company/')-> 
     128  checkResponseElement('div.street-address', '/12, rue des boites/')-> 
     129  checkResponseElement('span.zip', '/69001/')-> 
     130  checkResponseElement('span.locality', '/Lyon/')-> 
     131  checkResponseElement('div.country', '/France/')-> 
     132  checkResponseElement('div.phone', '/0102030405/')-> 
     133 
     134  // Edit company 
     135  click('Edit this company informations')-> 
     136  isRequestParameter('module', 'companies')-> 
     137  isRequestParameter('action', 'edit')-> 
     138  isRequestParameter('slug', 'my-company')-> 
     139  isStatusCode(200)-> 
     140  setField('company[name]', 'My Beautiful Company')-> 
     141  setField('company[summary]', 'This is my wonderful company')-> 
     142  click('Update company informations')-> 
     143  isRequestParameter('module', 'companies')-> 
     144  isRequestParameter('action', 'edit')-> 
     145  isRequestParameter('slug', 'my-company')-> 
     146  isRequestMethod('post')-> 
     147  isStatusCode(302)-> 
     148  followRedirect()-> 
     149  isRequestParameter('module', 'companies')-> 
     150  isRequestParameter('action', 'details')-> 
     151  isRequestParameter('slug', 'my-company')-> 
     152  isStatusCode(200)-> 
     153  checkResponseElement('h2', '/My Beautiful Company/')-> 
     154  checkResponseElement('p.notice', '/Company updated/', array('position' => 0))-> 
     155 
     156  // Edit connection 
     157  click('Connect to this company')-> 
     158  isRequestParameter('module', 'companies')-> 
     159  isRequestParameter('action', 'connect')-> 
     160  isRequestParameter('slug', 'my-company')-> 
     161  isStatusCode(302)-> 
     162  followRedirect()-> 
     163  isRequestParameter('module', 'companies')-> 
     164  isRequestParameter('action', 'connect')-> 
     165  isRequestParameter('slug', 'my-company')-> 
     166  hasRequestParameter('id')-> 
     167  isStatusCode(200)-> 
     168  setField('connection[role]', 'Big Boss')-> 
     169  setField('connection[description]', 'Very Very Lazy')-> 
     170  click('Connect your profile to this company')-> 
     171  isRequestParameter('module', 'companies')-> 
     172  isRequestParameter('action', 'connect')-> 
     173  isRequestParameter('slug', 'my-company')-> 
     174  isRequestMethod('post')-> 
     175  isStatusCode(302)-> 
     176  followRedirect()-> 
     177 
     178  // Check details page again 
     179  isRequestParameter('module', 'companies')-> 
     180  isRequestParameter('action', 'details')-> 
     181  isRequestParameter('slug', 'my-company')-> 
     182  isStatusCode(200)-> 
     183  checkResponseElement('p.notice', '/Your connection informations has been added/', array('position' => 0))-> 
     184  checkResponseElement('h2', '/My Beautiful Company/')-> 
     185  checkResponseElement('div.summary', '/This is my wonderful company/')-> 
     186  checkResponseElement('div.street-address', '/12, rue des boites/')-> 
     187  checkResponseElement('span.zip', '/69001/')-> 
     188  checkResponseElement('span.locality', '/Lyon/')-> 
     189  checkResponseElement('div.country', '/France/')-> 
     190  checkResponseElement('div.phone', '/0102030405/')-> 
     191  checkResponseElement('table.company_people_list', '/Nicolas Perriault(.*)has been(.*)Big Boss(.*)for 4 months until may 2008/')-> 
     192 
     193  // Go sleep 
     194  signOutUser('/')-> 
    58195  shutdown() 
    59196; 
  • trunk/test/functional/main/conditionalCacheTest.php

    r66 r75  
    55$browser = new SymfoniansTestBrowser($configuration); 
    66$browser->initialize(); 
    7  
    8 // initialize database manager 
    9 $databaseManager = new sfDatabaseManager(); 
    10 $databaseManager->initialize(); 
    11  
    12 $user = usersFactory::createTestUser('testuser', 'testpass1', 'testuser@gmail.com'); 
     7$browser->loadFixtures(); 
    138 
    149$browser-> 
     10  get('/')-> // first load to put content in cache 
    1511  get('/')->isCached(true)-> 
    1612  get('/applications')->isCached(true)-> 
     
    2218  click('Sign in')-> 
    2319  isStatusCode(401)-> 
    24   setField('username', $user->getUsername())-> 
    25   setField('password', 'testpass1')-> 
    26   click('sign in')-> 
    27   isStatusCode(302)->followRedirect()-> 
    28   isStatusCode(302)->followRedirect()-> 
     20  signInUser('niko', 'password')-> 
    2921 
    3022  get('/')->isCached(false)-> 
     
    3830  shutdown() 
    3931; 
    40  
    41 $user->delete(); 
  • trunk/test/functional/main/feedsActionsTest.php

    r2 r75  
    33 
    44// create a new test browser 
    5 $browser = new sfTestBrowser(); 
     5$browser = new SymfoniansTestBrowser($configuration); 
    66$browser->initialize(); 
     7$browser->loadFixtures(); 
    78 
    89$browser-> 
     10  get('/feed/applications/fresh')-> 
    911  get('/feed/applications/fresh')-> 
    1012  isStatusCode(200)-> 
  • trunk/test/functional/main/homeActionsTest.php

    r2 r75  
    33 
    44// create a new test browser 
    5 $browser = new sfTestBrowser(); 
     5$browser = new SymfoniansTestBrowser($configuration); 
    66$browser->initialize(); 
    7  
    8 // initialize database manager 
    9 $databaseManager = new sfDatabaseManager(); 
    10 $databaseManager->initialize(); 
    11 $con = Propel::getConnection(); 
     7$browser->loadFixtures(); 
    128 
    139$c = new Criteria; 
     
    1814 
    1915$browser-> 
     16 
    2017  get('/')-> 
    2118  isStatusCode(200)-> 
    2219  isRequestParameter('module', 'home')-> 
    2320  isRequestParameter('action', 'index')-> 
    24   checkResponseElement('body', '!/This is a temporary page/')-> 
     21  isCached(true)-> 
    2522  checkResponseElement('body', '/This website aims to connect coders/')-> 
    2623  checkResponseElement('#main h3', 4)-> 
     
    3330  checkResponseElement('#main h3', '/Fresh job offers/',     array('position' => 3))-> 
    3431  checkResponseElement('#main .home_recent_jobs li',         sfConfig::get('app_homepage_max_jobs', 5))-> 
     32 
    3533  shutdown() 
    3634; 
  • trunk/test/functional/main/localEventsActionsTest.php

    r46 r75  
    88 
    99$browser-> 
    10   get('/localEvents/index')-> 
     10  get('/localEvents')-> 
    1111  isStatusCode(200)-> 
    1212  isRequestParameter('module', 'localEvents')-> 
  • trunk/test/functional/main/peopleActionsTest.php

    r2 r75  
    33 
    44// create a new test browser 
    5 $browser = new sfTestBrowser(); 
     5$browser = new SymfoniansTestBrowser($configuration); 
    66$browser->initialize(); 
    7  
    8 // initialize database manager 
    9 $databaseManager = new sfDatabaseManager(); 
    10 $databaseManager->initialize(); 
    11  
    12 // Remove test user, if exists 
    13 $c = new Criteria; 
    14 $c->add(sfGuardUserPeer::USERNAME, 'testuser'); 
    15 sfGuardUserPeer::doDelete($c); 
     7$browser->loadFixtures(); 
    168 
    179$browser-> 
  • trunk/web/css/style.css

    r57 r75  
    730730  } 
    731731 
    732 .form-row.field_error input, 
     732.form-row.field_error input[type=text], 
     733.form-row.field_error input[type=password], 
     734.form-row.field_error input[type=file], 
    733735.form-row.field_error select, 
    734736.form-row.field_error textarea { 
    735   color: red;   
     737  color: darkred; 
     738  border: 1px solid red; 
     739  background: #fff2f2 url(../images/exclamation.png) no-repeat 99% 7px; 
    736740} 
    737741 
     
    747751    font-size: .8em; 
    748752  } 
     753   
     754  .global-form-errors ul.error_list li, 
     755  .global-form-errors p { 
     756    color: #fff; 
     757    font-size: .9em; 
     758  } 
     759   
     760  .global-form-errors p { 
     761    margin: 0; 
     762    padding: 0; 
     763    line-height: 1.7em; 
     764  }  
    749765 
    750766.form_help { 
     
    753769} 
    754770 
    755 .form-errors { 
     771.global-form-errors { 
    756772  background: #d00 url(/sf/sf_default/images/icons/cancel48.png) no-repeat 2px 4px; 
    757773  color: #fff; 
     
    759775} 
    760776 
    761 .form-errors h4 { 
     777.global-form-errors h4 { 
    762778  margin: 0; 
    763779  padding: 0; 
     
    765781} 
    766782 
     783.global-form-errors ul, 
    767784.form-errors ul { 
    768785  list-style-type: none;