- Timestamp:
- 08/22/08 14:03:33 (2 years ago)
- Files:
-
- trunk/apps/main/config/routing.yml (modified) (3 diffs)
- trunk/apps/main/i18n/fr/messages.xml (modified) (2 diffs)
- trunk/apps/main/lib/myActions.class.php (modified) (18 diffs)
- trunk/apps/main/modules/applications/actions/actions.class.php (modified) (5 diffs)
- trunk/apps/main/modules/applications/actions/components.class.php (modified) (4 diffs)
- trunk/apps/main/modules/applications/templates/_filterForm.php (modified) (1 diff)
- trunk/apps/main/modules/applications/templates/_form.php (modified) (3 diffs)
- trunk/apps/main/modules/applications/templates/_popularTags.php (modified) (1 diff)
- trunk/apps/main/modules/applications/templates/_relatedTags.php (modified) (1 diff)
- trunk/apps/main/modules/applications/templates/addSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/applications/templates/connectAsCompanySuccess.php (modified) (1 diff)
- trunk/apps/main/modules/applications/templates/connectAsDeveloperSuccess.php (modified) (5 diffs)
- trunk/apps/main/modules/applications/templates/detailsSuccess.php (modified) (9 diffs)
- trunk/apps/main/modules/applications/templates/homeSuccess.php (modified) (2 diffs)
- trunk/apps/main/modules/applications/templates/tagsSuccess.php (modified) (2 diffs)
- trunk/apps/main/modules/companies/actions/actions.class.php (modified) (5 diffs)
- trunk/apps/main/modules/companies/actions/components.class.php (modified) (1 diff)
- trunk/apps/main/modules/companies/templates/_form.php (modified) (3 diffs)
- trunk/apps/main/modules/companies/templates/addSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/companies/templates/connectSuccess.php (modified) (7 diffs)
- trunk/apps/main/modules/companies/templates/contactSuccess.php (modified) (2 diffs)
- trunk/apps/main/modules/companies/templates/detailsSuccess.php (modified) (10 diffs)
- trunk/apps/main/modules/companies/templates/editSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/companies/templates/homeSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/companies/validate (deleted)
- trunk/apps/main/modules/feeds/actions/actions.class.php (modified) (3 diffs)
- trunk/apps/main/modules/home/templates/indexSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/jobs/actions/actions.class.php (modified) (5 diffs)
- trunk/apps/main/modules/jobs/actions/components.class.php (modified) (3 diffs)
- trunk/apps/main/modules/jobs/templates/_entry.php (modified) (3 diffs)
- trunk/apps/main/modules/jobs/templates/_filterForm.php (modified) (1 diff)
- trunk/apps/main/modules/maps/templates/CompanySuccess.php (modified) (1 diff)
- trunk/apps/main/modules/maps/templates/sfGuardUserSuccess.php (modified) (1 diff)
- trunk/apps/main/modules/people/actions/actions.class.php (modified) (12 diffs)
- trunk/apps/main/modules/people/actions/components.class.php (modified) (1 diff)
- trunk/apps/main/modules/people/templates/_filterForm.php (modified) (1 diff)
- trunk/apps/main/modules/people/templates/contactSuccess.php (modified) (2 diffs)
- trunk/apps/main/modules/people/templates/detailsSuccess.php (modified) (14 diffs)
- trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php (modified) (23 diffs)
- trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php (modified) (2 diffs)
- trunk/apps/main/templates/_messages.php (modified) (1 diff)
- trunk/config/ProjectConfiguration.class.php (modified) (2 diffs)
- trunk/config/app.yml-dist (modified) (3 diffs)
- trunk/data/fixtures/data.yml (modified) (1 diff)
- trunk/lib/form/ActivationForm.class.php (modified) (2 diffs)
- trunk/lib/form/ApplicationCompanyForm.class.php (modified) (1 diff)
- trunk/lib/form/ApplicationDeveloperForm.class.php (modified) (1 diff)
- trunk/lib/form/ApplicationForm.class.php (modified) (3 diffs)
- trunk/lib/form/BaseFormPropel.class.php (modified) (2 diffs)
- trunk/lib/form/BlogPostForm.class.php (modified) (1 diff)
- trunk/lib/form/CompanyContactForm.class.php (added)
- trunk/lib/form/CompanyForm.class.php (modified) (1 diff)
- trunk/lib/form/CompanyPersonForm.class.php (modified) (1 diff)
- trunk/lib/form/CountrySelectorForm.class.php (modified) (2 diffs)
- trunk/lib/form/EventForm.class.php (modified) (1 diff)
- trunk/lib/form/JobFilterForm.class.php (added)
- trunk/lib/form/JobForm.class.php (modified) (1 diff)
- trunk/lib/form/LocalEventForm.class.php (modified) (1 diff)
- trunk/lib/form/PersonContactForm.class.php (added)
- trunk/lib/form/RecommendationForm.class.php (modified) (1 diff)
- trunk/lib/form/RegisterForm.class.php (modified) (5 diffs)
- trunk/lib/form/ResendActivationForm.class.php (modified) (2 diffs)
- trunk/lib/form/SigninForm.class.php (modified) (1 diff)
- trunk/lib/form/shared/BaseConnectionForm.class.php (modified) (5 diffs)
- trunk/lib/form/shared/BaseContactForm.class.php (added)
- trunk/lib/form/shared/BaseForm.class.php (added)
- trunk/lib/helper/ImageHelper.php (modified) (4 diffs)
- trunk/lib/helper/ObjectUrlHelper.php (modified) (24 diffs)
- trunk/lib/model/Application.php (modified) (1 diff)
- trunk/lib/model/Company.php (modified) (1 diff)
- trunk/lib/utils/SymfoniansTestBrowser.class.php (modified) (6 diffs)
- trunk/lib/utils/sfValidatedThumb.class.php (modified) (4 diffs)
- trunk/lib/validator/sfValidatorSchemaLicence.class.php (modified) (2 diffs)
- trunk/lib/validator/sfValidatorTags.class.php (modified) (3 diffs)
- trunk/lib/widget/sfWidgetFormSchemaFormatterDiv.class.php (modified) (1 diff)
- trunk/test/functional/main/applicationsActionsTest.php (modified) (9 diffs)
- trunk/test/functional/main/assets (added)
- trunk/test/functional/main/assets/sample_image.png (added)
- trunk/test/functional/main/companiesActionsTest.php (modified) (3 diffs)
- trunk/test/functional/main/conditionalCacheTest.php (modified) (3 diffs)
- trunk/test/functional/main/feedsActionsTest.php (modified) (1 diff)
- trunk/test/functional/main/homeActionsTest.php (modified) (3 diffs)
- trunk/test/functional/main/localEventsActionsTest.php (modified) (1 diff)
- trunk/test/functional/main/peopleActionsTest.php (modified) (1 diff)
- trunk/test/unit/BaseFormTest.php (added)
- trunk/web/css/style.css (modified) (5 diffs)
- trunk/web/uploads/people/standard (added)
- trunk/web/uploads/people/standard/samples (moved) (moved from trunk/web/uploads/people/samples)
- trunk/web/uploads/people/standard/samples/fabpot.png (copied) (copied from trunk/web/uploads/people/samples/fabpot.png)
- trunk/web/uploads/people/standard/samples/mbertier.png (copied) (copied from trunk/web/uploads/people/samples/mbertier.png)
- trunk/web/uploads/people/standard/samples/niko.jpg (copied) (copied from trunk/web/uploads/people/samples/niko.jpg)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/main/config/routing.yml
r71 r75 111 111 112 112 # Applications 113 applications_test:114 url: /applications/test115 param: { module: applications, action: test }116 113 applications_countries: 117 114 url: /applications/countries … … 169 166 company_add: 170 167 url: /company/add 171 param: { module: companies, action: add}168 param: { module: companies, action: edit } 172 169 173 170 company_edit: … … 185 182 company_edit_connection: 186 183 url: /company/:slug/connection/:id/edit 187 param: { module: companies, action: editConnection}184 param: { module: companies, action: connect } 188 185 189 186 company_contact: trunk/apps/main/i18n/fr/messages.xml
r38 r75 315 315 <trans-unit id="69"> 316 316 <source>Fields marked with a <span class="left-star">star</span> are mandatory.</source> 317 <target>Les champs marqués d'une <span class="left-star"> star</span> sont obligatoires</target>317 <target>Les champs marqués d'une <span class="left-star">étoile</span> sont obligatoires</target> 318 318 </trans-unit> 319 319 … … 615 615 <trans-unit id="129"> 616 616 <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> 618 618 </trans-unit> 619 619 trunk/apps/main/lib/myActions.class.php
r62 r75 1 1 <?php 2 2 /** 3 * Shared actions stub 3 * Shared actions stub for all actions 4 4 * 5 5 */ … … 29 29 protected function buildPagerRoute($route_name, $params = array()) 30 30 { 31 $query_string = http_build_query($params, '', '&'); 32 if ($query_string) 31 if ($query_string = http_build_query($params, '', '&')) 33 32 { 34 33 $route = sprintf('%s?%s&page=', $route_name, $query_string); … … 38 37 $route = sprintf('%s?page=', $route_name); 39 38 } 39 40 40 return $route; 41 41 } … … 64 64 * Returns the rendered value of a partial 65 65 * 66 * @param string $module Module name67 * @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) 69 69 * @return string 70 70 */ 71 71 protected function getRenderedPartial($module, $partial, $vars = array()) 72 72 { 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 */ 78 83 protected function getViewCacheManager() 79 84 { … … 81 86 } 82 87 88 /** 89 * Purges the cache related to a given object 90 * 91 * @param object $object 92 * @return mixed 93 */ 83 94 protected function purgeObjectRelatedCache($object) 84 95 { 85 96 $purge_method = sprintf('purge%sRelatedCache', ucfirst(get_class($object))); 97 86 98 if (method_exists($this, $purge_method)) 87 99 { … … 90 102 } 91 103 104 /** 105 * Purges the homepage cache related assets 106 * 107 */ 92 108 protected function purgeHomepage() 93 109 { … … 98 114 } 99 115 116 /** 117 * Purges the sections homepages cache related assets 118 * 119 */ 100 120 protected function purgeHomepages() 101 121 { … … 112 132 } 113 133 134 /** 135 * Purges an application cache related assets 136 * 137 * @param Application $application 138 */ 114 139 protected function purgeApplicationRelatedCache(Application $application) 115 140 { … … 127 152 } 128 153 154 /** 155 * Purges a company cache related assets 156 * 157 * @param Company $company 158 */ 129 159 protected function purgeCompanyRelatedCache(Company $company) 130 160 { … … 142 172 } 143 173 174 /** 175 * Purges a job cache related assets 176 * 177 * @param Job $job 178 */ 144 179 protected function purgeJobRelatedCache(Job $job) 145 180 { … … 157 192 } 158 193 194 /** 195 * Purges a user cache related assets 196 * 197 * @param sfGuardUser $person 198 */ 159 199 protected function purgePersonRelatedCache(sfGuardUser $person) 160 200 { … … 168 208 } 169 209 210 /** 211 * Purges a recommendation cache related assets 212 * 213 * @param Recommendation $recommendation 214 */ 170 215 protected function purgeRecommendationRelatedCache(Recommendation $recommendation) 171 216 { … … 179 224 } 180 225 226 /** 227 * Purges an application company relation cache 228 * 229 * @param ApplicationCompany $app_company 230 */ 181 231 protected function purgeApplicationCompanyRelatedCache(ApplicationCompany $app_company) 182 232 { … … 190 240 } 191 241 242 /** 243 * Purges an application developer related cache 244 * 245 * @param ApplicationDeveloper $app_person 246 */ 192 247 protected function purgeApplicationDeveloperRelatedCache(ApplicationDeveloper $app_person) 193 248 { … … 201 256 } 202 257 258 /** 259 * Purges a company person related cache 260 * 261 * @param CompanyPerson $company_person 262 */ 203 263 protected function purgeCompanyPersonRelatedCache(CompanyPerson $company_person) 204 264 { … … 298 358 } 299 359 $mailer->disconnect(); 300 360 301 361 // Add mailSent timestamp 302 362 $this->getUser()->setAttribute('lastMailAt', time()); 303 363 304 364 return ($sent > 0); 305 365 } … … 342 402 return $address; 343 403 } 344 404 345 405 /** 346 406 * Checks for mail flooding (die, dirty spammers) … … 352 412 { 353 413 $user = $this->getUser(); 354 414 355 415 if (!$user) 356 416 { 357 417 throw new sfException($this->__('Mail sending use the session, please allow cookies')); 358 418 } 359 419 360 420 $lastMailAt = $user->getAttribute('lastMailAt', null); 361 421 362 422 if (is_null($lastMailAt)) 363 423 { 364 424 return; 365 425 } 366 426 367 427 $ttl = sfConfig::get('app_mail_mail_flood_time', 300); 368 369 if (time() - $lastMailAt < $ttl) 428 429 if (time() - $lastMailAt < $ttl) 370 430 { 371 431 throw new sfException(sprintf($this->__('You must wait at least %d seconds between two mail send, please try again later'), $ttl)); 372 432 } 373 433 } 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 377 437 * to reference it in the layout or partials 378 438 * trunk/apps/main/modules/applications/actions/actions.class.php
r71 r75 38 38 39 39 $this->form = new ApplicationForm($application); 40 $this->form->setDefault('tags', $application->getTagsString()); 40 41 $this->setTemplate('edit'); 41 42 $message = $this->__('Application updated'); … … 53 54 } 54 55 55 $this->form->setDefault('tags', $application->getTagsString());56 $this->application = $application;57 58 56 if ($request->isMethod('post')) 59 57 { … … 79 77 80 78 $this->getUser()->setFlash('notice', $message); 81 $this->getUser()->setAttribute('from_app_creation', is_null($request->getParameter('slug')), 'symfonians');82 79 $this->redirect(sprintf($redirect, $application->getSlug())); 83 80 } … … 161 158 { 162 159 $connection = ApplicationDeveloperPeer::retrieveByPK($request->getParameter('id')); 160 163 161 $this->forward404If(is_null($connection)); 164 162 … … 200 198 'developer_id' => $this->getUser()->getId())); 201 199 $this->form->bind($params); 200 202 201 if ($this->form->isValid()) 203 202 { trunk/apps/main/modules/applications/actions/components.class.php
r2 r75 7 7 { 8 8 9 /** 10 * Filter form component 11 * 12 */ 9 13 public function executeFilterForm() 10 14 { 11 $this->countries = ApplicationPeer::retrieveCountries(); 15 $this->form = new CountrySelectorForm(ApplicationPeer::retrieveCountries()); 16 $this->form->setDefault('country', $this->getRequestParameter('country')); 12 17 } 13 18 19 /** 20 * Popular tags component 21 * 22 */ 14 23 public function executePopularTags() 15 24 { … … 20 29 } 21 30 31 /** 32 * Recently added apps component 33 * 34 */ 22 35 public function executeRecentlyAdded() 23 36 { … … 28 41 } 29 42 43 /** 44 * Recently updated apps component 45 * 46 */ 30 47 public function executeRecentlyUpdated() 31 48 { … … 36 53 } 37 54 55 /** 56 * Related tags component 57 * 58 */ 38 59 public function executeRelatedTags() 39 60 { 40 $this->related_tags = TagPeer::getRelatedTags($this->tag, 41 array('model' => 'Application')); 61 $this->related_tags = TagPeer::getRelatedTags($this->tag, array('model' => 'Application')); 42 62 } 43 63 64 /** 65 * User applications 66 * 67 */ 44 68 public function executeUserApplications() 45 69 { trunk/apps/main/modules/applications/templates/_filterForm.php
r56 r75 1 1 <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() ?> 3 4 <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> 9 7 </p> 10 8 <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"/> 13 10 </p> 14 <p>15 <?php echo submit_tag(__('Filter')) ?>16 </p>17 */ ?>18 11 </form> trunk/apps/main/modules/applications/templates/_form.php
r70 r75 15 15 <legend><?php echo __('Application informations') ?></legend> 16 16 <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')) ?> 18 18 <?php echo $form['name']->render() ?> 19 19 <?php echo $form['name']->renderError() ?> … … 28 28 <legend><?php echo __('Other informations') ?></legend> 29 29 <?php echo $form['country']->renderRow() ?> 30 <?php echo $form['screenshot_file']->renderRow( ) ?>30 <?php echo $form['screenshot_file']->renderRow(array(), __('Screenshot')) ?> 31 31 <div class="form-row"> 32 32 <?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')) ?> 34 34 </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')) ?> 36 36 <?php echo $form['feed_url']->renderRow() ?> 37 37 <div class="date_select"> … … 43 43 <div class="form-row" style="text-align:center;clear:left;"> 44 44 <p> 45 <?php echo $form['id'] ?> 45 46 <?php echo $form['_csrf_token'] ?> 46 47 <input type="submit" value="<?php echo $submit_label ?>" /> trunk/apps/main/modules/applications/templates/_popularTags.php
r2 r75 2 2 <h3><?php echo __('Tags') ?></h3> 3 3 <div class="tags_cloud"> 4 <?php echo tag_cloud($tags , '@application_tag?tag=') ?>4 <?php echo tag_cloud($tags->getRawValue(), '@application_tag?tag=%s') ?> 5 5 </div> 6 6 <p class="more"> trunk/apps/main/modules/applications/templates/_relatedTags.php
r2 r75 3 3 array('%tag%' => tags_string($tag))) ?></h3> 4 4 <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)?> 6 6 </div> 7 7 <p class="more"> trunk/apps/main/modules/applications/templates/addSuccess.php
r56 r75 5 5 6 6 <?php include_partial('applications/form', 7 array('application' => $ application,7 array('application' => $form->getObject(), 8 8 'form' => $form, 9 9 'title' => $page_title, trunk/apps/main/modules/applications/templates/connectAsCompanySuccess.php
r71 r75 9 9 <?php slot('sidebar') ?> 10 10 <?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') ?> 13 12 <?php if ($application->getHomepage()): ?> 14 13 <?php echo link_to($image, $application->getHomepage()) ?> trunk/apps/main/modules/applications/templates/connectAsDeveloperSuccess.php
r68 r75 2 2 3 3 <?php slot('page_title') ?> 4 <?php $page_title = __('Connect yourself to the %application% application', 4 <?php $page_title = __('Connect yourself to the %application% application', 5 5 array('%application%' => $application->getName())) ?> 6 6 <?php echo $page_title ?> … … 9 9 <?php slot('sidebar') ?> 10 10 <?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') ?> 13 12 <?php if ($application->getHomepage()): ?> 14 13 <?php echo link_to($image, $application->getHomepage()) ?> … … 19 18 <?php end_slot() ?> 20 19 21 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 20 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 22 21 array($application->getName(), '@application_page?slug='.$application->getSlug()), 23 22 $page_title)) ?> … … 25 24 <h2><?php echo $page_title ?><span class="gradient"> </span></h2> 26 25 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> 33 28 34 29 <p class="form-info"> … … 40 35 <fieldset> 41 36 <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' : '' ?>"> 43 38 <?php echo $form['role']->renderLabel(__('Your role in this project')) ?> 44 39 <?php echo $form['role']->render() ?> trunk/apps/main/modules/applications/templates/detailsSuccess.php
r2 r75 8 8 <?php slot('sidebar') ?> 9 9 <?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') ?> 12 11 <?php if ($application->getHomepage()): ?> 13 12 <?php echo link_to($image, $application->getHomepage()) ?> … … 26 25 <ul class="admin_actions"> 27 26 <li> 28 <?php echo link_to(__('Edit this application informations'), 27 <?php echo link_to(__('Edit this application informations'), 29 28 '@application_edit?slug='.$application->getSlug(), 30 29 'class=bigedit') ?></li> 31 30 <li> 32 <?php echo link_to(__('Delete this application'), 31 <?php echo link_to(__('Delete this application'), 33 32 '@application_delete?slug='.$application->getSlug(), 34 33 'class=bigdelete confirm='.__('Are you sure?')) ?></li> 35 34 <?php if ($sf_user->isAdmin()): ?> 36 35 <li> 37 <?php echo link_to(__('Promote as featured on homepage'), 36 <?php echo link_to(__('Promote as featured on homepage'), 38 37 '@application_promote?slug='.$application->getSlug(), 39 38 'class=promote confirm='.__('Are you sure?')) ?></li> … … 42 41 <?php endif; ?> 43 42 <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'), 45 44 '@application_add', 'id=bt_addapp') ?> 46 45 <?php end_slot() ?> 47 46 48 47 <div class="fiftypercent"> 49 50 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 48 49 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 51 50 $page_title)) ?> 52 51 53 52 <h2> 54 53 <?php echo $page_title ?> … … 61 60 <span class="gradient"> </span> 62 61 </h2> 63 62 64 63 <?php include_partial('applications/entry', 65 64 array('application' => $application)) ?> 66 65 67 66 </div> 68 67 … … 86 85 <?php endif; ?> 87 86 <?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'), 89 88 '@application_edit_developer_connection?slug='.$application->getSlug().'&id='.$app_person->getId(), 90 89 'title='.__('Edit your connection with ').$app_person->getApplication()->getName().' rel=nofollow class=edit') ?> … … 116 115 <?php endif; ?> 117 116 </div> 118 117 119 118 <div class="related_companies"> 120 119 <h3><?php echo __('Companies related to this application') ?></h3> … … 125 124 <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 126 125 <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(), 128 127 'class=mini_thumb'), 129 128 '@company_page?slug='.$company_application->getCompany()->getSlug(), … … 137 136 <?php endif; ?> 138 137 <?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'), 140 139 '@application_edit_company_connection?slug='.$application->getSlug().'&id='.$company_application->getId(), 141 140 'title='.__('Edit this connection to ').$company_application->getCompany()->getName().' rel=nofollow class=edit') ?> … … 161 160 <?php endif; ?> 162 161 <p class="more"> 163 <?php echo link_to(__('Connect a company!'), 162 <?php echo link_to(__('Connect a company!'), 164 163 '@application_connect_as_company?slug='.$application->getSlug()) ?> 165 164 </p> 166 165 </div> 167 166 168 167 </div> trunk/apps/main/modules/applications/templates/homeSuccess.php
r11 r75 62 62 <?php endif; ?> 63 63 <?php echo link_to($application->getName(), 64 '@application_page?slug='.$application->getSlug()) ?>64 '@application_page?slug='.$application->getSlug()) ?> 65 65 <?php if ($application->getCountry()): ?> 66 66 <?php echo flag_image_tag($application->getCountry()) ?> … … 69 69 <div class="thumb_area"> 70 70 <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'), 73 72 '@application_page?slug='.$application->getSlug(), 74 73 'class=thumb_link') ?> trunk/apps/main/modules/applications/templates/tagsSuccess.php
r2 r75 10 10 <?php end_slot() ?> 11 11 12 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 12 <?php echo breadcrumb(array(array(__('Applications'), '@application_home'), 13 13 $page_title)) ?> 14 14 … … 19 19 20 20 <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') ?> 22 22 </div> trunk/apps/main/modules/companies/actions/actions.class.php
r48 r75 9 9 { 10 10 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) 25 77 { 26 78 $this->company = $this->getFromSlug(); 27 79 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) 94 136 { 95 137 $this->company = $this->getFromSlug(); 96 138 $this->user = $this->getUser()->getGuardUser(); 139 $this->form = new CompanyContactForm(); 97 140 98 141 if (!$this->company->getAllowContact()) … … 102 145 } 103 146 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) 126 175 { 127 176 $this->company = $this->getFromSlug(); … … 139 188 } 140 189 141 public function executeDetails( )190 public function executeDetails(sfWebRequest $request) 142 191 { 143 192 $this->company = $this->getFromSlug(); … … 180 229 } 181 230 182 public function executeHome( )231 public function executeHome(sfWebRequest $request) 183 232 { 184 233 if ($this->getRequest()->hasParameter('commit') && $this->getRequestParameter('country')) … … 209 258 } 210 259 211 public function executeIndex( )260 public function executeIndex(sfWebRequest $request) 212 261 { 213 262 $this->forward('companies', 'home'); 214 263 } 215 264 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 220 279 $c->addJoin(CompanyPeer::SUBMITTER_ID, sfGuardUserPeer::ID, Criteria::LEFT_JOIN); 221 280 $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); 263 283 } 264 284 trunk/apps/main/modules/companies/actions/components.class.php
r66 r75 9 9 public function executeFilterForm() 10 10 { 11 $this->form = new CountrySelectorForm( );11 $this->form = new CountrySelectorForm(CompanyPeer::retrieveCountries()); 12 12 $this->form->setDefault('country', $this->getRequestParameter('country')); 13 13 } trunk/apps/main/modules/companies/templates/_form.php
r64 r75 1 1 <?php use_helper('Object', 'Validation') ?> 2 2 3 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 3 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 4 4 $title)) ?> 5 5 … … 14 14 <fieldset> 15 15 <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() ?> 20 20 </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() ?> 25 25 </div> 26 26 <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')) ?> 30 29 </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() ?> 51 34 </fieldset> 52 35 </div> … … 57 40 <?php echo __('By providing your localization, people will be able to find you in their area.') ?> 58 41 </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() ?> 63 46 </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() ?> 77 53 <div class="form_help"> 78 54 <?php echo __('Please enter only one city name. If the company have distinct implementations, please create one company sheet per location.') ?> 79 55 </div> 80 <?php echo form_error('company[city]') ?>81 56 </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)')) ?> 87 58 </fieldset> 88 59 </div> 89 60 <div class="form-row" style="text-align:center;clear:left;"> 90 61 <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 ?>"/> 92 65 </p> 93 66 </div> trunk/apps/main/modules/companies/templates/addSuccess.php
r2 r75 5 5 6 6 <?php include_partial('companies/form', 7 array('company' => $company, 7 array('company' => $form->getObject(), 8 'form' => $form, 8 9 'title' => __('Add a company'), 9 10 'form_route' => '@company_add', trunk/apps/main/modules/companies/templates/connectSuccess.php
r64 r75 2 2 3 3 <?php slot('page_title') ?> 4 <?php $page_title = __('Connect to %company%', 4 <?php $page_title = __('Connect to %company%', 5 5 array('%company%' => $company->getName())) ?> 6 6 <?php echo $page_title ?> … … 9 9 <?php slot('sidebar') ?> 10 10 <?php if ($company->getLogoPath()): ?> 11 <?php $image = image_tag($company->getFullLogoPath(),11 <?php $image = company_image_tag($company, 12 12 'class=company_logo alt='.$company->getName().' logo') ?> 13 13 <?php if ($company->getHomepage()): ?> … … 19 19 <?php end_slot() ?> 20 20 21 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 21 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 22 22 array($company->getName(), '@company_page?slug='.$company->getSlug()), 23 23 $page_title)) ?> … … 25 25 <h2><?php echo $page_title ?><span class="gradient"> </span></h2> 26 26 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> 33 29 34 30 <p class="form-info"> … … 40 36 <fieldset> 41 37 <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() ?> 46 42 </div> 47 43 <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() ?> 51 47 </div> 52 48 </fieldset> … … 55 51 <fieldset> 56 52 <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> 66 64 </div> 67 65 </fieldset> … … 69 67 <div class="form-row" style="text-align:center;clear:left;"> 70 68 <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') ?>"/> 79 73 </p> 80 74 </div> trunk/apps/main/modules/companies/templates/contactSuccess.php
r64 r75 7 7 <?php end_slot() ?> 8 8 9 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 9 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 10 10 array($company->getName(), '@company_page?slug='.$company->getSlug()), 11 11 $page_title)) ?> … … 21 21 <legend><?php echo __('Fill the form then send your message') ?></legend> 22 22 <div class="form-row"> 23 <?php echo __('From: %sender%', 23 <?php echo __('From: %sender%', 24 24 array('%sender%' => $sf_user->getGuardUser()->getEmailSender())) ?> 25 25 </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() ?> 30 30 </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() ?> 35 35 </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() ?> 42 40 </div> 43 41 <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())) ?>" /> 46 43 </div> 47 44 </fieldset> trunk/apps/main/modules/companies/templates/detailsSuccess.php
r2 r75 8 8 <?php slot('sidebar') ?> 9 9 <?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') ?> 12 11 <?php if ($company->getHomepage()): ?> 13 12 <?php echo link_to($image, $company->getHomepage()) ?> … … 23 22 $company->getsfGuardUser()->getUsername(), 24 23 $company->getSlug())) ?>) 25 <?php endif; ?> 24 <?php endif; ?> 26 25 </small></p> 27 26 <?php if ($user_is_submitter or $sf_user->isAdmin()): ?> … … 29 28 <ul class="admin_actions"> 30 29 <li> 31 <?php echo link_to(__('Edit this company informations'), 30 <?php echo link_to(__('Edit this company informations'), 32 31 '@company_edit?slug='.$company->getSlug(), 33 32 'class=bigedit') ?></li> 34 33 <li> 35 <?php echo link_to(__('Delete this company'), 34 <?php echo link_to(__('Delete this company'), 36 35 '@company_delete?slug='.$company->getSlug(), 37 36 'class=bigdelete confirm='.__('Are you sure?')) ?></li> … … 40 39 <?php if ($company->getAllowContact()): ?> 41 40 <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(), 44 43 'id=bt_companycontact') ?> 45 44 <?php endif; ?> … … 54 53 <div class="fiftypercent vcard"> 55 54 56 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 55 <?php echo breadcrumb(array(array(__('Companies'), '@companies_home'), 57 56 $page_title)) ?> 58 59 57 <h2> 60 58 <span class="fn org"><?php echo $page_title ?></span> … … 62 60 <span class="gradient"> </span> 63 61 </h2> 64 62 65 63 <?php include_partial('companies/entry', 66 64 array('company' => $company, 67 65 'sf_cache_key' => $company->getSlug())) ?> 68 69 66 </div> 70 67 71 68 <div class="fiftypercent"> 72 69 73 70 <div class="related_people"> 74 71 <h3 class="col2"><?php echo __('Active people related with this company') ?></h3> … … 116 113 </p> 117 114 </div> 118 115 119 116 <div class="related_applications"> 120 117 <h3><?php echo __('Applications related to this company') ?></h3> … … 125 122 <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 126 123 <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(), 128 125 'class=mini_thumb'), 129 126 '@application_page?slug='.$company_application->getApplication()->getSlug(), … … 153 150 <?php endif; ?> 154 151 </div> 155 152 156 153 <div class="related_jobs"> 157 154 <h3><?php echo __('Jobs proposed by this company') ?></h3> … … 177 174 <?php endif; ?> 178 175 </div> 179 176 180 177 </div> trunk/apps/main/modules/companies/templates/editSuccess.php
r2 r75 1 1 <?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())) ?> 4 4 <?php echo $page_title ?> 5 5 <?php end_slot() ?> 6 6 7 7 <?php include_partial('companies/form', 8 array('company' => $company, 8 array('company' => $form->getObject(), 9 'form' => $form, 9 10 'title' => $page_title, 10 'form_route' => '@company_edit?slug='.$ company->getSlug(),11 'form_route' => '@company_edit?slug='.$form->getObject()->getSlug(), 11 12 'submit_label' => __('Update company informations'))) ?> trunk/apps/main/modules/companies/templates/homeSuccess.php
r2 r75 41 41 <td style="width:10%;text-align:right"> 42 42 <?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'), 45 44 '@company_page?slug='.$company->getSlug(), 46 45 'class=thumb_link') ?> trunk/apps/main/modules/feeds/actions/actions.class.php
r2 r75 29 29 * @param BaseObject $object 30 30 * @return sfFeedItem 31 * @throws sfActionException if no parameters getter is not found for $object 31 32 */ 32 33 protected function generateFeedItemFromObject(BaseObject $object) … … 34 35 $item = new sfFeedItem(); 35 36 $params_getter = sprintf('get%sItemParameters', get_class($object)); 37 36 38 if (!method_exists($this, $params_getter)) 37 39 { … … 39 41 $params_getter)); 40 42 } 43 41 44 $params = $this->$params_getter($object); 42 45 $params = array_merge($params, 43 46 array('pubDate' => $object->getCreatedAt(null), 44 47 'uniqueId' => md5(get_class($object).$object->getId()))); 48 45 49 $item->initialize($params); 50 46 51 return $item; 47 52 } trunk/apps/main/modules/home/templates/indexSuccess.php
r2 r75 15 15 </h3> 16 16 <?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') ?> 19 19 <?php echo link_to_application($featured_application, 20 20 array('label' => $image ? $image : $featured_application->getName())) ?> trunk/apps/main/modules/jobs/actions/actions.class.php
r48 r75 68 68 } 69 69 70 public function executeHome( )70 public function executeHome(sfWebRequest $request) 71 71 { 72 72 $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 78 78 $c = new Criteria(); 79 79 80 80 if ($country) 81 81 { … … 95 95 $this->company_name = $company->getName(); 96 96 $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) 101 101 { 102 102 $c->add(JobPeer::TELEWORKING, true); … … 107 107 108 108 // Redirect with a nicer url 109 if ($ this->getRequest()->hasParameter('commit'))109 if ($request->getParameter('commit')) 110 110 { 111 111 $this->redirect($this->pager_route); … … 124 124 125 125 // Feed mode handling 126 if ($ this->hasRequestParameter('feed'))126 if ($request->getParameter('feed')) 127 127 { 128 128 $this->renderHomeAsFeed($c); … … 137 137 // meanwhile, cache is your friend :-/ 138 138 $pager->setCriteria($c); 139 $pager->setPage($ this->getRequestParameter('page', 1));139 $pager->setPage($request->getParameter('page', 1)); 140 140 $pager->init(); 141 141 $this->pager = $pager; trunk/apps/main/modules/jobs/actions/components.class.php
r2 r75 2 2 /** 3 3 * Jobs components 4 * 4 * 5 5 */ 6 6 class jobsComponents extends sfComponents 7 7 { 8 8 9 /** 10 * Retrieves and displays cities in a given country 11 * 12 */ 9 13 public function executeCountryCities() 10 14 { … … 16 20 $c->addGroupByColumn(JobPeer::CITY); 17 21 $c->addAscendingOrderByColumn(JobPeer::CITY); 22 18 23 $rs = JobPeer::doSelectRS($c); 24 19 25 $cities = array(); 26 20 27 while ($rs->next()) 21 28 { … … 27 34 } 28 35 } 36 29 37 $this->cities = $cities; 30 38 } 31 39 40 /** 41 * Filter form 42 * 43 */ 32 44 public function executeFilterForm() 33 45 { 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')); 36 49 } 37 50 51 /** 52 * Displays recent job offers 53 * 54 */ 38 55 public function executeRecent() 39 56 { trunk/apps/main/modules/jobs/templates/_entry.php
r2 r75 3 3 <p><strong> 4 4 <?php if ($job->getCompanyId()): ?> 5 <?php echo __('Proposed by the %company% company %time% ago.', 5 <?php echo __('Proposed by the %company% company %time% ago.', 6 6 array('%company%' => link_to($job->getCompany(), 7 7 '@company_page?slug='.$job->getCompany()->getSlug()), 8 8 '%time%' => my_distance_of_time_in_words($job->getCreatedAt(null), time()))) ?> 9 9 <?php elseif ($job->getContactId()): ?> 10 <?php echo __('Proposed by %name% on %date%.', 10 <?php echo __('Proposed by %name% on %date%.', 11 11 array('%name%' => link_to_person($job->getsfGuardUser()), 12 12 '%date%' => format_date($job->getCreatedAt()))) ?> 13 13 <?php endif; ?> 14 14 <?php if ($job->getExpiresAt()): ?> 15 <?php echo __('Offer will expire on %date%.', 15 <?php echo __('Offer will expire on %date%.', 16 16 array('%date%' => format_date($job->getExpiresAt(), 'MMMM, d yyyy'))) ?> 17 17 <?php endif; ?> … … 41 41 <h3> 42 42 <?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') ?> 45 45 <?php endif; ?> 46 46 <?php echo $job->getCompany()->getName() ?> … … 51 51 <h3> 52 52 <?php if ($job->getsfGuardUser()->getAvatarPath()): ?> 53 <?php echo image_tag($job->getsfGuardUser()->getFullAvatarPath('small16')) ?>53 <?php echo person_image_tag($job->getsfGuardUser(), 'small16') ?> 54 54 <?php endif; ?> 55 55 <?php echo $job->getsfGuardUser()->getDisplayName() ?> trunk/apps/main/modules/jobs/templates/_filterForm.php
r64 r75 1 1 <form action="<?php echo url_for('@jobs_home') ?>" method="get" id="country_form"> 2 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')))) ?> 3 <?php echo $form['country']->renderLabel(__('Filter by country')) ?> 4 <?php echo $form['country']->render() ?> 8 5 </p> 9 6 <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() ?> 15 9 </p> 16 10 <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> 19 13 </p> 20 14 <p> 21 < ?php echo submit_tag(__('Filter')) ?>15 <input type="submit" value="<?php echo __('Filter') ?>" name="commit"/> 22 16 </p> 23 17 </form> trunk/apps/main/modules/maps/templates/CompanySuccess.php
r2 r75 3 3 <?php $company = $object; unset($object) ?> 4 4 <?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') ?> 6 6 <?php endif; ?> 7 7 <h3 style="padding:0;margin:0"> trunk/apps/main/modules/maps/templates/sfGuardUserSuccess.php
r2 r75 3 3 <?php $person = $object; unset($object) ?> 4 4 <?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') ?> 6 6 <?php endif; ?> 7 7 <h3 style="padding:0;margin:0"> trunk/apps/main/modules/people/actions/actions.class.php
r48 r75 8 8 class peopleActions extends myActions 9 9 { 10 11 public function executeContact() 10 /** 11 * Contact action 12 * 13 */ 14 public function executeContact(sfWebRequest $request) 12 15 { 13 16 $this->recipient = $this->getFromSlug('to_username'); 17 $this->form = new PersonContactForm(); 14 18 15 19 if (!$this->recipient->getAllowContact(true)) … … 38 42 } 39 43 40 public function executeDashboard() 44 /** 45 * Dashboard action 46 * 47 */ 48 public function executeDashboard(sfWebRequest $request) 41 49 { 42 50 $user = $this->getUser()->getGuardUser() … … 63 71 } 64 72 65 public function executeDelete() 73 /** 74 * Deletion action 75 * 76 */ 77 public function executeDelete(sfWebRequest $request) 66 78 { 67 79 $this->user = $this->getFromSlug(); … … 80 92 } 81 93 82 public function executeDetails() 94 /** 95 * Profile details action 96 * 97 */ 98 public function executeDetails(sfWebRequest $request) 83 99 { 84 100 $this->user = $this->getFromSlug('username'); … … 93 109 } 94 110 95 public function executeHome() 111 /** 112 * People homepage action 113 * 114 */ 115 public function executeHome(sfWebRequest $request) 96 116 { 97 117 $pager_route_params = array(); … … 142 162 } 143 163 144 public function executeDeleteRecommendation() 164 /** 165 * Recommendation deletion action 166 * 167 */ 168 public function executeDeleteRecommendation(sfWebRequest $request) 145 169 { 146 170 $recommendation = RecommendationPeer::retrieveByPK($this->getRequestParameter('id')); … … 160 184 } 161 185 162 public function executeRecommend() 186 /** 187 * Recommend action 188 * 189 */ 190 public function executeRecommend(sfWebRequest $request) 163 191 { 164 192 $this->user = $this->getFromSlug('to_username'); … … 223 251 } 224 252 225 public function executeRecommendations() 253 /** 254 * Recommendatyions list actions 255 * 256 */ 257 public function executeRecommendations(sfWebRequest $request) 226 258 { 227 259 $c = new Criteria; … … 238 270 } 239 271 240 public function executeSkills() 272 /** 273 * Skill tags action 274 * 275 */ 276 public function executeSkills(sfWebRequest $request) 241 277 { 242 278 $c = new Criteria; … … 248 284 public function handleErrorContact() 249 285 { 250 251 286 $this->recipient = $this->getFromSlug('to_username'); 252 287 return sfView::SUCCESS; … … 260 295 } 261 296 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 */ 262 304 protected function getFromSlug($slug_param = 'username', $peer_method = null) 263 305 { … … 265 307 $user = sfGuardUserPeer::retrieveByUsername($username, true, $peer_method); 266 308 $this->forward404Unless($user, sprintf('Unable to retrieve user "%s" (maybe user is not an active one)', $username)); 309 267 310 return $user; 268 311 } 269 270 312 } trunk/apps/main/modules/people/actions/components.class.php
r2 r75 9 9 public function executeFilterForm() 10 10 { 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')) 13 15 { 14 16 $this->cities = sfGuardUserPeer::retrieveCountryCities($this->getRequestParameter('country')); trunk/apps/main/modules/people/templates/_filterForm.php
r64 r75 1 1 <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)): ?> 13 8 <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> 20 17 </p> 21 18 <?php endif; ?> 22 19 <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> 25 22 </p> 26 23 <p> 27 < ?php echo submit_tag(__('Filter')) ?>24 <input type="submit" value="<?php echo __('Filter') ?>" name="commit"/> 28 25 </p> 29 26 </form> trunk/apps/main/modules/people/templates/contactSuccess.php
r64 r75 7 7 <?php end_slot() ?> 8 8 9 <?php echo breadcrumb(array(array(__('People'), '@people_home'), 9 <?php echo breadcrumb(array(array(__('People'), '@people_home'), 10 10 array($recipient->getDisplayName(), '@person_page?username='.$recipient->getUsername()), 11 11 $page_title)) ?> … … 17 17 <legend><?php echo __('Fill the form then send your message') ?></legend> 18 18 <div class="form-row"> 19 <?php echo __('From: %sender%', 19 <?php echo __('From: %sender%', 20 20 array('%sender%' => $sf_user->getGuardUser()->getEmailSender())) ?> 21 21 </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() ?> 26 26 </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() ?> 31 31 </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() ?> 39 36 </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> 44 40 </fieldset> 45 41 </form> trunk/apps/main/modules/people/templates/detailsSuccess.php
r2 r75 8 8 9 9 <?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') ?> 11 11 <?php if ($user->getIsForHire()): ?> 12 12 <p class="for_hire"><?php echo __('Available for hire') ?></p> … … 19 19 <?php if ($is_current_user): ?> 20 20 <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> 24 24 <?php endif; ?> 25 25 <?php if ($sf_user->isAdmin()): ?> 26 26 <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> 30 30 <?php endif; ?> 31 31 </ul> … … 34 34 <h3><?php echo __('Wanna get in touch?') ?></h3> 35 35 <p class="mail_contact"> 36 <?php echo big_button_to(__('Contact by email'), 36 <?php echo big_button_to(__('Contact by email'), 37 37 '@person_contact?to_username='.$user->getUsername()) ?> 38 38 </p> 39 39 <?php endif; ?> 40 40 <?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> 42 42 <p><?php echo big_button_to(__('Recommend this person'), 43 43 '@person_recommend?to_username='.$user->getUsername()) ?></p> … … 47 47 <div class="fiftypercent vcard"> 48 48 49 <?php echo breadcrumb(array(array(__('People'), '@people_home'), 49 <?php echo breadcrumb(array(array(__('People'), '@people_home'), 50 50 $page_title)) ?> 51 51 <h2> … … 54 54 <span class="gradient"> </span> 55 55 </h2> 56 56 57 57 <?php include_partial('people/entry', 58 58 array('person' => $user, 59 59 'sf_cache_key' => $user->getUsername())) ?> 60 60 61 61 <div class="recommendations_received"> 62 62 <h3 class="recommended_title"><?php echo __('Recommendations received') ?></h3> … … 66 66 <?php echo __('%name% has been recommended by %nb_people%.', 67 67 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', 69 69 array('%1%' => $nb_rec_received), $nb_rec_received))) ?> 70 70 </strong> … … 79 79 </p> 80 80 <blockquote> 81 <?php if ($sf_user->isAdmin() 81 <?php if ($sf_user->isAdmin() 82 82 or $recommendation->getRecommendedId() == $sf_user->getId() 83 83 or $recommendation->getRecommenderId() == $sf_user->getId()): ?> … … 98 98 <?php else: ?> 99 99 <p> 100 <?php echo __('%name% has not been recommended yet.', 100 <?php echo __('%name% has not been recommended yet.', 101 101 array('%name%' => $user->getDisplayName())) ?> 102 102 </p> 103 103 <?php endif; ?> 104 104 <p class="more"> 105 <?php echo link_to(__('Recommend '.$user->getDisplayName()), 105 <?php echo link_to(__('Recommend '.$user->getDisplayName()), 106 106 '@person_recommend?to_username='.$user->getUsername()) ?> 107 107 </p> 108 108 </div> 109 109 110 110 <div class="recommendations_sent"> 111 111 <h3 class="recommender_title"><?php echo __('Recommendations sent to others') ?></h3> … … 115 115 <?php echo __('%name% has recommended %nb_people%.', 116 116 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', 118 118 array('%1%' => $nb_rec_made), $nb_rec_made))) ?> 119 119 </strong> … … 127 127 '%date%' => $recommendation->getCreatedAt('m/d/Y'))) ?> 128 128 <blockquote> 129 <?php if ($sf_user->isAdmin() 129 <?php if ($sf_user->isAdmin() 130 130 or $recommendation->getRecommendedId() == $sf_user->getId() 131 131 or $recommendation->getRecommenderId() == $sf_user->getId()): ?> … … 149 149 <?php endif; ?> 150 150 </div> 151 151 152 152 </div> 153 153 … … 160 160 <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 161 161 <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'), 164 164 '@application_page?slug='.$app_person->getApplication()->getSlug(), 165 165 'class=thumb_link') ?> … … 186 186 <p><?php echo __('No application related to this person (yet).') ?></p> 187 187 <?php endif; ?> 188 188 189 189 <h3><?php echo __('Related companies') ?></h3> 190 190 <?php if (count($person_companies->getRawValue()) > 0): ?> … … 194 194 <tr class="<?php echo $i % 2 == 0 ? 'row' : 'row odd' ?>"> 195 195 <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'), 198 198 '@company_page?slug='.$company_person->getCompany()->getSlug(), 199 199 'class=thumb_link') ?> trunk/apps/main/modules/sfGuardAuth/actions/actions.class.php
r56 r75 41 41 } 42 42 } 43 43 44 44 public function executeChangePassword(sfWebRequest $request) 45 45 { … … 54 54 } 55 55 } 56 56 57 57 public function executeDeleteAvatar(sfWebRequest $request) 58 58 { … … 76 76 } 77 77 } 78 78 79 79 public function executeForgotPassword(sfWebRequest $request) 80 80 { … … 87 87 $user->setPassword($password); 88 88 $user->save(); 89 89 90 90 $request->setAttribute('user', $user); 91 91 $request->setAttribute('password', $password); … … 107 107 { 108 108 $this->embedGoogleJavascriptApi(); 109 109 110 110 $this->user = $this->getUser()->getGuardUser(); 111 111 … … 114 114 return sfView::SUCCESS; 115 115 } 116 116 117 117 $profile = $request->getParameter('profile', array()); 118 118 119 119 # 1. Boolean values 120 120 if (!isset($profile['allow_contact'])) … … 130 130 $profile['is_for_hire'] = false; 131 131 } 132 132 133 133 # 2. Dates 134 134 if (!$profile['birthdate']) … … 144 144 unset($profile['symfony_at']); 145 145 } 146 146 147 147 try 148 148 { 149 149 $thumb = ImagesTools::createThumbs ( 150 'profile[avatar_path]', 150 'profile[avatar_path]', 151 151 sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.sfConfig::get('app_people_upload_dir', 'people'), 152 152 md5($this->user->getUsername()).'.jpg', … … 214 214 } 215 215 } 216 216 217 217 public function handleErrorProfile() 218 218 { … … 221 221 return sfView::SUCCESS; 222 222 } 223 223 224 224 public function handleErrorForgotPassword() 225 225 { 226 226 return sfView::SUCCESS; 227 227 } 228 228 229 229 /** 230 230 * Registers a new member … … 239 239 $this->redirect('@homepage'); 240 240 } 241 241 242 242 $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 251 256 if (!$request->isMethod('post') or !$this->form->bindAndSave($params)) 252 257 { 253 258 return sfView::SUCCESS; // redisplay form with errors 254 259 } 255 260 256 261 // At this point we got a valid form and a created sfGuardUser object 257 262 $user = $this->form->getObject(); 258 263 259 264 // Create activation entry 260 265 $activation = new Activation(); … … 262 267 $activation->setHash(md5(rand(100000, 999999))); 263 268 $activation->save(); 264 269 265 270 // Send user an activation email 266 271 $request->setAttribute('user', $user); … … 269 274 $user->getEmail(), 270 275 $this->__('Please confirm your Symfonians account creation request')); 271 272 // If mail sending failed, 276 277 // If mail sending failed, 273 278 if (!$mailSent) 274 279 { … … 282 287 $this->redirect('@user_register_done'); 283 288 } 284 289 285 290 public function executeRegisterDone(sfWebRequest $request) 286 291 { … … 288 293 return sfView::SUCCESS; 289 294 } 290 295 291 296 /** 292 297 * Resend activation mail … … 301 306 { 302 307 $this->form = new ResendActivationForm(); 303 308 304 309 if ($request->isMethod('post')) 305 310 { 306 311 $this->form->bindFromRequest($request); 307 312 308 313 if ($this->form->isValid()) 309 314 { 310 315 $user = sfGuardUserPeer::retrieveByEmail($this->form->getValue('email')); 311 316 $this->forward404Unless($user); // theoricaly, can't happen 312 317 313 318 $c = new Criteria(); 314 319 $c->add(ActivationPeer::USER_ID, $user->getId()); 315 320 $activation = ActivationPeer::doSelectOne($c); 316 321 $request->setAttribute('activation', $activation); 317 322 318 323 $mailSent = $this->sendSwiftSmtpPlainMail('mail', 'resendActivation', 319 324 $user->getEmail(), … … 324 329 return sfView::SUCCESS; 325 330 } 326 331 327 332 $this->getUser()->setFlash('notice', $this->__('Your activation mail has been sent to '.$user->getEmail())); 328 333 $this->redirect('@homepage'); … … 330 335 } 331 336 } 332 337 333 338 public function handleErrorChangePassword() 334 339 { 335 340 return sfView::SUCCESS; 336 341 } 337 342 338 343 public function validateActivate() 339 344 { … … 342 347 $c->add(ActivationPeer::HASH, $key); 343 348 $c->addJoin(ActivationPeer::USER_ID, sfGuardUserPeer::ID); 344 349 345 350 $this->activation = ActivationPeer::doSelectOne($c); 346 351 if (!$this->activation) … … 349 354 return false; 350 355 } 351 356 352 357 $this->user = $this->activation->getsfGuardUser(); 353 358 if (!$this->user) 354 359 { 355 360 $this->getRequest()->setError('errors', $this->__('Unable to find user to activate')); 356 return false; 357 } 358 361 return false; 362 } 363 359 364 if ($this->user->getIsActive()) 360 365 { … … 362 367 return false; 363 368 } 364 369 365 370 return true; 366 371 } 367 372 368 373 public function validateChangePassword() 369 374 { … … 379 384 } 380 385 } 381 386 382 387 public function validateForgotPassword() 383 388 { … … 398 403 return true; 399 404 } 400 405 401 406 } trunk/apps/main/modules/sfGuardAuth/templates/registerSuccess.php
r64 r75 14 14 <?php echo big_button_to(__('Sign in!'), '@sf_guard_signin') ?> 15 15 <p style="text-align:center"> 16 (<?php echo link_to(__('Forgot your password?'), 16 (<?php echo link_to(__('Forgot your password?'), 17 17 '@user_forgot_password') ?>) 18 18 </p> … … 41 41 <fieldset> 42 42 <legend><?php echo __('Security') ?></legend> 43 <?php if (true === sfConfig::get('app_recaptcha_enabled')): ?> 43 44 <?php echo $form['captcha']->renderRow() ?> 45 <?php else: ?> 46 <p>Disabled in dev mode</p> 47 <?php endif; ?> 44 48 </fieldset> 45 49 <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; ?> 6 14 <?php endif; ?> 7 15 trunk/config/ProjectConfiguration.class.php
r66 r75 7 7 public function setup() 8 8 { 9 // Base forms configuration 9 10 sfWidgetFormSchema::setDefaultFormFormatterName('div'); 10 11 sfValidatorBase::setRequiredMessage('This field is required.'); 12 sfValidatorBase::setInvalidMessage('The value provided is invalid.'); 13 11 14 // symfonians constants definition 12 15 if (!defined('SYMFONIANS_MAIN_DOMAIN')) … … 22 25 } 23 26 } 24 27 25 28 public function getWebDir() 26 29 { 27 30 return sfConfig::get('sf_web_dir'); 28 31 } 29 32 30 33 public function getUploadDir() 31 34 { 32 35 return sfConfig::get('sf_upload_dir'); 33 36 } 34 37 35 38 public function getUploadDirName() 36 39 { trunk/config/app.yml-dist
r62 r75 7 7 max_sidebar_tags: 50 8 8 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 13 12 default_screenshot: default_screenshot.png 14 13 … … 24 23 box_max_items: 5 25 24 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 30 28 default_logo: default_logo.png 31 29 … … 89 87 90 88 people: 89 forbidden_names: [admin, contact, info, infos, commercial, tech, support, sales, partnership, webmaster, business, owner] 91 90 max_items: 6 92 91 box_max_items: 5 trunk/data/fixtures/data.yml
r66 r75 1 Event: 2 1 3 sfGuardUser: 2 4 fabpot: trunk/lib/form/ActivationForm.class.php
r71 r75 1 1 <?php 2 3 2 /** 4 3 * Activation form. … … 9 8 class ActivationForm extends BaseActivationForm 10 9 { 10 /** 11 * Form configuration 12 * 13 */ 11 14 public function configure() 12 15 { trunk/lib/form/ApplicationCompanyForm.class.php
r71 r75 8 8 class ApplicationCompanyForm extends BaseApplicationCompanyForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { trunk/lib/form/ApplicationDeveloperForm.class.php
r71 r75 8 8 class ApplicationDeveloperForm extends BaseApplicationDeveloperForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { trunk/lib/form/ApplicationForm.class.php
r71 r75 8 8 class ApplicationForm extends BaseApplicationForm 9 9 { 10 protected $culture = null; 11 10 /** 11 * Form configuration 12 * 13 */ 12 14 public function configure() 13 15 { 14 sfLoader::loadHelpers('I18n');15 $context = sfContext::getInstance();16 $this->culture = $context->getUser()->getCulture();17 18 16 // Unset unused widgets 19 unset($this['id'], 20 $this['created_at'], 17 unset($this['created_at'], 21 18 $this['updated_at'], 22 19 $this['slug'], … … 28 25 29 26 // 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 } 35 51 } 36 52 … … 65 81 new sfValidatorUrl(), 66 82 new sfValidatorChoice(array('choices' => array('http://', ''))), 67 ) );83 ), array(), array('invalid' => 'This url seems to be invalid')); 68 84 69 85 $this->validatorSchema['feed_url'] = new sfValidatorOr(array( 70 86 new sfValidatorUrl(), 71 87 new sfValidatorChoice(array('choices' => array('http://', ''))), 72 ) );88 ), array(), array('invalid' => 'This feed url seems to be invalid')); 73 89 74 90 // 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))), 76 94 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 ))); 79 99 } 80 100 } trunk/lib/form/BaseFormPropel.class.php
r71 r75 1 1 <?php 2 2 /** 3 * Project form baseclass.3 * Project base Propel form class. 4 4 * 5 5 * @package form … … 7 7 abstract class BaseFormPropel extends sfFormPropel 8 8 { 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 */ 9 21 public function setup() 10 22 { 23 // Culture setup 24 sfLoader::loadHelpers('I18n'); 25 $context = sfContext::getInstance(); 26 $this->culture = $context->getUser()->getCulture(); 27 28 // Default formatter 11 29 sfWidgetFormSchema::setDefaultFormFormatterName('div'); 12 30 } trunk/lib/form/BlogPostForm.class.php
r71 r75 8 8 class BlogPostForm extends BaseBlogPostForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { trunk/lib/form/CompanyForm.class.php
r71 r75 8 8 class CompanyForm extends BaseCompanyForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { 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 ))); 12 67 } 13 68 } trunk/lib/form/CompanyPersonForm.class.php
r71 r75 8 8 class CompanyPersonForm extends BaseCompanyPersonForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { 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]'); 12 24 } 13 25 } trunk/lib/form/CountrySelectorForm.class.php
r68 r75 8 8 class CountrySelectorForm extends sfForm 9 9 { 10 protected 10 protected 11 11 $countries = array(), 12 12 $culture = 'en'; 13 13 14 14 /** 15 15 * Public constructor … … 22 22 $this->countries = array_keys($countries); 23 23 $this->culture = sfContext::getInstance()->getUser()->getCulture(); 24 24 25 parent::__construct($defaults, $options, $CSRFSecret); 25 26 } 26 27 27 28 /** 28 29 * Form configuration 29 30 * 30 31 */ 31 public function configure()32 public function setup() 32 33 { 33 34 $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'))), 37 38 )); 38 39 39 40 $this->setValidators(array( 40 41 'country' => new sfValidatorI18nChoiceCountry(array('culture' => $this->culture, trunk/lib/form/EventForm.class.php
r71 r75 8 8 class EventForm extends BaseEventForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { trunk/lib/form/JobForm.class.php
r71 r75 8 8 class JobForm extends BaseJobForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { trunk/lib/form/LocalEventForm.class.php
r71 r75 8 8 class LocalEventForm extends BaseLocalEventForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { trunk/lib/form/RecommendationForm.class.php
r71 r75 8 8 class RecommendationForm extends BaseRecommendationForm 9 9 { 10 /** 11 * Form configuration 12 * 13 */ 10 14 public function configure() 11 15 { trunk/lib/form/RegisterForm.class.php
r68 r75 5 5 * @see sfGuardUserForm 6 6 */ 7 class RegisterForm extends BasesfGuardUserForm 7 class RegisterForm extends BasesfGuardUserForm 8 8 { 9 10 static protected11 $forbidden_names = array('admin', 'niko', 'contact', 'info', 'infos', 'commercial', 'tech', 'support', 'sales', 'partnership', 'webmaster', 'business', 'owner');12 9 /** 10 * Form configuration 11 * 12 */ 13 13 public function configure() 14 14 { … … 19 19 'password' => new sfWidgetFormInputPassword(), 20 20 'password2' => new sfWidgetFormInputPassword(), 21 'captcha' => new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))),22 21 )); 23 22 24 23 // helps 25 24 $this->widgetSchema->setHelps(array( … … 28 27 'password' => 'Your password must be 6 characters length minimum.', 29 28 'password2' => 'Please confirm your password for avoiding typos.', 30 'captcha' => 'This codes aims at detecting if you are a bot or a human person.',31 29 )); 32 30 33 31 // validators 34 32 $this->setValidators(array( … … 36 34 new sfValidatorString(array('min_length' => 3, 'max_length' => 20)), 37 35 new sfValidatorRegex(array('pattern' => '/^[a-zA-Z]([a-zA-Z0-9._-]+)$/'), array('invalid' => 'Name "%value%" contains forbidden characters')), 38 new sfValidatorBlacklist(array('forbidden_values' => s elf::$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')), 39 37 )), 40 38 'email' => new sfValidatorAnd(array( … … 44 42 'password' => new sfValidatorString(array('min_length' => 6, 'max_length' => 128)), 45 43 'password2' => new sfValidatorString(array('min_length' => 6, 'max_length' => 128)), 46 'captcha' => new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))),47 44 )); 48 45 46 $this->addCaptcha(); 47 49 48 // post validator 50 49 $this->validatorSchema->setPostValidator(new sfValidatorAnd(array( 51 new sfValidatorSchemaCompare('password', 'equal', 'password2' , array('throw_global_error' => true)),50 new sfValidatorSchemaCompare('password', 'equal', 'password2'), 52 51 new sfValidatorPropelUnique(array('model' => 'sfGuardUser', 'column' => 'username')), 53 52 new sfValidatorPropelUnique(array('model' => 'sfGuardUser', 'column' => 'email')) 54 53 ))); 55 54 56 55 $this->widgetSchema->setNameFormat('user[%s]'); 57 56 } 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 } 59 71 } trunk/lib/form/ResendActivationForm.class.php
r68 r75 4 4 * 5 5 */ 6 class ResendActivationForm extends sfFormReCaptcha 6 class ResendActivationForm extends sfFormReCaptcha 7 7 { 8 /** 9 * Form configuration 10 * 11 */ 8 12 public function configure() 9 13 { … … 14 18 $this->widgetSchema['captcha'] = new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key'))); 15 19 } 16 20 17 21 // Validators 18 $this->validatorSchema['email'] = new sfValidatorAnd(array( 22 $this->validatorSchema['email'] = new sfValidatorAnd(array( 19 23 new sfValidatorEmail(), 20 new sfValidatorPropelChoice(array('model' => 'sfGuardUser', 'column' => 'email', 'criteria' => self::getActiveCriteria()), 24 new sfValidatorPropelChoice(array('model' => 'sfGuardUser', 'column' => 'email', 'criteria' => self::getActiveCriteria()), 21 25 array('invalid' => 'This email has never been registered here, or is already activated.')), 22 26 )); 23 27 24 28 if (true === sfConfig::get('app_recaptcha_enabled')) 25 29 { 26 30 $this->validatorSchema['captcha'] = new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key'))); 27 31 } 28 32 29 33 $this->widgetSchema->setNameFormat('user[%s]'); 30 34 } 31 35 32 36 /** 33 37 * Generates a Criteria filtering active users only trunk/lib/form/SigninForm.class.php
r68 r75 4 4 * 5 5 */ 6 class SigninForm extends sfGuardFormSignin 6 class SigninForm extends sfGuardFormSignin 7 7 { 8 /** 9 * Form configuration 10 * 11 */ 8 12 public function configure() 9 13 { 10 14 parent::configure(); 11 15 12 16 $this->widgetSchema['remember'] = new sfWidgetFormInputCheckbox(); 13 17 $this->validatorSchema['remember'] = new sfValidatorPass(); trunk/lib/form/shared/BaseConnectionForm.class.php
r72 r75 1 1 <?php 2 2 /** 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: 4 5 * 5 6 * - an Application and a Company … … 13 14 * - ended_at: the date the connection stopped 14 15 * 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 15 29 */ 16 30 class BaseConnectionForm extends sfForm … … 20 34 * 21 35 */ 22 public function configure()36 public function setup() 23 37 { 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); 26 42 27 43 // Widgets … … 29 45 'role' => new sfWidgetFormInput(), 30 46 '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), 33 49 )); 34 50 … … 40 56 'ended_at' => new sfValidatorDate(array('required' => false)), 41 57 )); 58 59 $this->validatorSchema->setPostValidator(new sfValidatorSchemaTimeInterval('started_at', 'ended_at')); 60 61 $this->widgetSchema->setNameFormat('connection[%s]'); 42 62 } 43 63 } trunk/lib/helper/ImageHelper.php
r2 r75 3 3 4 4 /** 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 6 6 * 7 7 * @param string $country_code ISO country code … … 15 15 return ''; 16 16 } 17 17 18 18 $options = _parse_attributes($options); 19 19 20 20 if (isset($options['class'])) 21 21 { … … 26 26 $options['class'] = 'flag'; 27 27 } 28 28 29 29 $options['alt'] = format_country($country_code); 30 30 $flag_image = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'flags'.DIRECTORY_SEPARATOR.strtolower($country_code).'.png'; … … 33 33 return ''; 34 34 } 35 35 36 36 return image_tag('flags/'.strtolower($country_code).'.png', $options); 37 37 } 38 39 /** 40 * Returns the application thumb web path 41 * 42 * @param Application $application 43 * @param mixed $options 44 * @return string|null 45 */ 46 function 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 */ 60 function 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 */ 75 function 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 3 3 4 4 /** 5 * Link to a user profile 5 * Link to a user profile 6 6 * 7 7 * @param sfGuardUser $person … … 15 15 return __('<Removed profile>'); 16 16 } 17 18 $options = _parse_attributes($options); 19 17 18 $options = _parse_attributes($options); 19 20 20 if (isset($options['label'])) 21 21 { … … 27 27 $label = $person->getDisplayName(); 28 28 } 29 29 30 30 $append = ''; 31 31 if (isset($options['include_flag'])) … … 37 37 unset($options['include_flag']); 38 38 } 39 39 40 40 if (!isset($options['title'])) 41 41 { … … 43 43 array('%person%' => $person->getDisplayName())); 44 44 } 45 46 return link_to($label, 45 46 return link_to($label, 47 47 '@person_page?username='.$person->getUsername(), 48 48 $options).$append; … … 50 50 51 51 /** 52 * Link to a company profile 52 * Link to a company profile 53 53 * 54 54 * @param Company $company … … 62 62 return __('<Removed company>'); 63 63 } 64 65 $options = _parse_attributes($options); 66 64 65 $options = _parse_attributes($options); 66 67 67 if (isset($options['label'])) 68 68 { … … 74 74 $label = $company->getName(); 75 75 } 76 76 77 77 $append = ''; 78 78 if (isset($options['include_flag'])) … … 84 84 unset($options['include_flag']); 85 85 } 86 86 87 87 if (!isset($options['title'])) 88 88 { … … 90 90 array('%company%' => $company->getName())); 91 91 } 92 93 return link_to($label, 92 93 return link_to($label, 94 94 '@company_page?slug='.$company->getSlug(), 95 95 $options).$append; … … 97 97 98 98 /** 99 * Link to a application profile 99 * Link to a application profile 100 100 * 101 101 * @param Application $application … … 109 109 return __('<Removed application>'); 110 110 } 111 112 $options = _parse_attributes($options); 113 111 112 $options = _parse_attributes($options); 113 114 114 if (isset($options['label'])) 115 115 { … … 121 121 $label = $application->getName(); 122 122 } 123 123 124 124 $append = ''; 125 125 if (isset($options['include_flag'])) … … 131 131 unset($options['include_flag']); 132 132 } 133 133 134 134 if (!isset($options['title'])) 135 135 { … … 137 137 array('%app%' => $application->getName())); 138 138 } 139 140 return link_to($label, 139 140 return link_to($label, 141 141 '@application_page?slug='.$application->getSlug(), 142 142 $options).$append; … … 144 144 145 145 /** 146 * Link to a job profile 146 * Link to a job profile 147 147 * 148 148 * @param Job $job … … 156 156 return __('<Removed job offer>'); 157 157 } 158 159 $options = _parse_attributes($options); 160 158 159 $options = _parse_attributes($options); 160 161 161 if (isset($options['label'])) 162 162 { … … 168 168 $label = $job->getTitle(); 169 169 } 170 170 171 171 $append = ''; 172 172 if (isset($options['include_flag'])) … … 178 178 unset($options['include_flag']); 179 179 } 180 180 181 181 if (!isset($options['title'])) 182 182 { … … 184 184 array('%jobtitle%' => $job->getTitle())); 185 185 } 186 187 return link_to($label, 186 187 return link_to($label, 188 188 '@job_page?slug='.$job->getSlug(), 189 189 $options).$append; … … 204 204 $options = _parse_attributes($options); 205 205 $image_src = null; 206 206 207 if (isset($options['imgclass'])) 207 208 { … … 213 214 $imgclass = 'avatar'; 214 215 } 216 215 217 $force_reload = false; 216 218 if (isset($options['force_reload'])) … … 219 221 unset($options['force_reload']); 220 222 } 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 239 224 if (isset($options['route'])) 240 225 { … … 246 231 $route = '@person_page?username='.$person->getUsername(); 247 232 } 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); 250 240 } 251 241 trunk/lib/model/Application.php
r71 r75 150 150 } 151 151 return implode($separator, $devs); 152 }153 154 /**155 * Returns full screenshot path for current app156 *157 * @return string158 */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 else166 $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());171 152 } 172 153 trunk/lib/model/Company.php
r49 r75 108 108 } 109 109 return implode($separator, $people); 110 }111 112 /**113 * Returns logo image full path114 *115 * @return string116 */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());127 110 } 128 111 trunk/lib/utils/SymfoniansTestBrowser.class.php
r71 r75 52 52 * Simulates a click on a link or button. 53 53 * 54 * @param string$name The link or button text55 * @param array$arguments56 * 57 * @return sfBrowser54 * @param string $name The link or button text 55 * @param array $arguments 56 * 57 * @return SymfoniansTestBrowser 58 58 */ 59 59 public function click($name, $arguments = array()) … … 68 68 catch (sfException $e) 69 69 { 70 self::$test->fail(sprintf(' %sin "%s"', $e->getMessage(), $this->getResponse()->getContent()));70 self::$test->fail(sprintf('"%s" in "%s"', $e->getMessage(), $this->getResponse()->getContent())); 71 71 return $this; 72 72 } 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; 73 230 } 74 231 … … 80 237 * @return SymfoniansTestBrowser 81 238 */ 82 public function signIn User($goto = '/', $admin = false)239 public function signInTestUser($goto = '/', $admin = false) 83 240 { 84 241 if ($admin) … … 86 243 $user = $this->getAdminTestUser(); 87 244 $pass = 'testpass2'; 245 self::$test->comment('Login admin test user'); 88 246 } 89 247 else … … 91 249 $user = $this->getStandardTestUser(); 92 250 $pass = 'testpass1'; 251 self::$test->comment('Login standard test user'); 93 252 } 94 253 95 254 self::$test->comment('Login user'); 96 255 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)); 97 270 return $this-> 98 click('Signin')->99 setField('signin[username]', $user ->getUsername())->100 setField('signin[password]', $pass )->271 get('/login')-> 272 setField('signin[username]', $username)-> 273 setField('signin[password]', $password)-> 101 274 click('sign in')-> 102 275 followRedirect()-> … … 105 278 106 279 /** 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(); 214 288 } 215 289 trunk/lib/utils/sfValidatedThumb.class.php
r70 r75 1 1 <?php 2 2 /** 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 4 4 * 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 7 7 * validator: 8 * 8 * 9 9 * new sfValidatorFile(array('validated_file_class' => 'sfValidatedThumb')); 10 10 * 11 11 * 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 * 15 28 * @package symfonians 16 29 * @subpackage validator … … 18 31 class sfValidatedThumb extends sfValidatedFile 19 32 { 20 33 const 34 DEFAULT_THUMB_WIDTH = 200, 35 DEFAULT_THUMB_HEIGHT = 140, 36 DEFAULT_THUMB_QUALITY = 90; 37 21 38 /** 22 39 * Allowed types … … 24 41 */ 25 42 protected static $allowedTypes = array('applications', 'people', 'companies'); 26 43 27 44 /** 28 45 * Makes thumb from app.yml configuration and updates Propel related object on … … 40 57 throw new sfConfigurationException('The sfThumbnailPlugin must be installed'); 41 58 } 42 59 43 60 if (!in_array($type, self::$allowedTypes)) 44 61 { 45 62 throw new InvalidArgumentException(sprintf('Type "%s" is invalid', $type)); 46 63 } 47 64 48 65 if (!method_exists($object, $thumbSetter)) 49 66 { 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', 51 68 $thumbSetter, get_class($object))); 52 69 } 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 58 75 $fileName = md5($object->__toString()).'.jpg'; 59 76 60 77 $file = sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR. 61 78 sfConfig::get(sprintf('app_%s_upload_dir', $type)).DIRECTORY_SEPARATOR. 62 79 $fileName; 63 64 $thumbnail = new sfThumbnail($width, $height, true, true, $quality, null);80 81 $thumbnail = new sfThumbnail($width, $height, true, true, $quality, 'sfGDAdapter'); 65 82 $thumbnail->loadFile($this->getTempName()); 66 83 $thumbnail->save($file, 'image/jpeg'); 67 84 $this->savedName = $file; 68 85 69 86 $object->$thumbSetter($fileName); 70 87 71 88 return ($object->save() > 0); 72 89 } 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 */ 74 98 public function save($file, $fileMode = 0666, $create = true, $dirMode = 0777) 75 99 { 76 100 throw new LogicException('You must use the saveThumb() method'); 77 101 } 78 79 102 } trunk/lib/validator/sfValidatorSchemaLicence.class.php
r70 r75 1 1 <?php 2 /** 3 * This validators validates the license and is_opensource fields 4 * 5 */ 2 6 class sfValidatorSchemaLicence extends sfValidatorSchema 3 7 { 8 /** 9 * Apply validation 10 * 11 * @param mixed $values 12 */ 4 13 protected function doClean($values) 5 14 { 6 15 //parent::doClean($values); 7 16 8 17 $errorSchema = new sfValidatorErrorSchema($this); 9 18 10 19 if ($values['is_opensource'] && 0 === strlen(trim($values['licence']))) 11 20 { … … 13 22 throw new sfValidatorErrorSchema($this, array('licence' => $error)); 14 23 } 24 25 return $values; 15 26 } 16 27 } trunk/lib/validator/sfValidatorTags.class.php
r70 r75 1 1 <?php 2 class sfValidatorTags extends sfValidatorBase 2 /** 3 * This validators validates tags string 4 * 5 */ 6 class sfValidatorTags extends sfValidatorBase 3 7 { 4 8 9 /** 10 * Configures the validator 11 * 12 * @param unknown_type $options 13 * @param unknown_type $messages 14 */ 5 15 public function configure($options = array(), $messages = array()) 6 16 { … … 8 18 $this->setMessage('invalid', 'Looks like your tags should be separated by the "%separator%" char'); 9 19 } 10 20 21 /** 22 * Apply validator 23 * 24 * @param mixed $value 25 * @return mixed 26 */ 11 27 public function doClean($value) 12 28 { … … 15 31 return $value; 16 32 } 17 33 18 34 $words = str_word_count($value); 19 35 $seps = substr_count($value, $this->getOption('separator')); 20 36 21 37 if ($seps < $words / 2) 22 38 { 23 39 throw new sfValidatorError($this, 'invalid', array('separator' => $this->getOption('separator'))); 24 40 } 25 41 26 42 return $value; 27 43 } 28 44 29 45 } trunk/lib/widget/sfWidgetFormSchemaFormatterDiv.class.php
r53 r75 7 7 { 8 8 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", 10 10 $errorRowFormat = "%errors%\n", 11 11 $helpFormat = '<div class="form-help">%help%</div>', 12 12 $decoratorFormat = "\n %content%"; 13 13 14 14 public function formatRow($label, $field, $errors = array(), $help = '', $hiddenFields = null) 15 15 { 16 16 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, 18 19 )); 19 20 } trunk/test/functional/main/applicationsActionsTest.php
r71 r75 16 16 isRequestParameter('action', 'home')-> 17 17 isCached(true)-> 18 checkResponseElement('body', '!/This is a temporary page/')->19 18 checkResponseElement('h2', '/Symfony applications/')-> 20 19 checkResponseElement('.thumbs_list h4', '/Yahoo Bookmarks/', array('position' => 0))-> … … 34 33 checkResponseElement('div.summary', '/SplitGames est la première communauté européenne/')-> 35 34 35 // No admin links 36 checkResponseElement('ul.admin_actions', '!/Edit/')-> 37 checkResponseElement('ul.admin_actions', '!/Delete/')-> 38 36 39 // Checking application form in authenticated mode 37 40 click('Add an application')-> 38 41 isStatusCode(401)-> 39 signInUser(' /application/add')->42 signInUser('niko', 'password', '/application/add')-> 40 43 isStatusCode(200)-> 41 44 … … 43 46 responseContains('<input type="checkbox" name="application[is_opensource]" id="application_is_opensource" />')-> 44 47 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 45 55 // Create a new application 46 56 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')-> 47 65 click('Add this application')-> 48 66 isStatusCode(302)-> … … 51 69 followRedirect()-> 52 70 53 // Connect a sdeveloper71 // Connect a developer 54 72 isRequestParameter('module', 'applications')-> 55 73 isRequestParameter('action', 'connectAsDeveloper')-> … … 58 76 setField('connection[role]', 'My role')-> 59 77 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')-> 60 84 click('Connect your profile to this application')-> 61 85 isRequestParameter('module', 'applications')-> … … 64 88 followRedirect()-> 65 89 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))-> 70 99 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/')-> 71 108 72 109 // Connect a company … … 75 112 isRequestParameter('action', 'connectAsCompany')-> 76 113 isStatusCode(200)-> 114 setField('connection[company_id]', CompanyPeer::retrieveBySlug('clever-age')->getId())-> 77 115 setField('connection[role]', 'My company role')-> 116 setField('connection[description]', 'Mostly haking')-> 78 117 click('Connect the company to this application')-> 79 118 isRequestParameter('module', 'applications')-> 80 119 isRequestParameter('action', 'connectAsCompany')-> 81 // FIXME: current testuser doesn't have any companies!82 120 isStatusCode(302)-> 83 121 followRedirect()-> … … 86 124 isRequestParameter('slug', 'my-test-app')-> 87 125 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))-> 88 144 89 145 // Edit application … … 103 159 checkResponseElement('p.notice', '/Application updated/', array('position' => 0))-> 104 160 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()-> 109 203 shutdown() 110 204 ; trunk/test/functional/main/companiesActionsTest.php
r66 r75 5 5 $browser = new SymfoniansTestBrowser($configuration); 6 6 $browser->initialize(); 7 $browser->loadFixtures(); 7 8 8 9 $browser-> 10 get('/logout')-> // Forces the purge of the session 9 11 get('/companies')-> 10 12 isStatusCode(200)-> … … 12 14 isRequestParameter('action', 'home')-> 13 15 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))-> 15 19 checkResponseElement('table.common h4', '/Clever Age/', array('position' => 3))-> 16 20 17 21 click('Clever Age')-> 18 22 isStatusCode(200)-> 23 isRequestMethod('get')-> 19 24 isRequestParameter('module', 'companies')-> 20 25 isRequestParameter('action', 'details')-> 26 isRequestParameter('slug', 'clever-age')-> 21 27 isCached(true)-> 22 28 checkResponseElement('h2', '/Clever Age/')-> … … 47 53 checkResponseElement('table.company_applications_list', '/Mageneration.com/')-> 48 54 49 // C ontact button (check auth)55 // Check security 50 56 click('Contact this company')-> 51 57 isStatusCode(401)-> 52 58 back()-> 53 54 // Add button (check auth)55 59 click('Add your company!')-> 56 60 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()-> 57 89 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('/')-> 58 195 shutdown() 59 196 ; trunk/test/functional/main/conditionalCacheTest.php
r66 r75 5 5 $browser = new SymfoniansTestBrowser($configuration); 6 6 $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(); 13 8 14 9 $browser-> 10 get('/')-> // first load to put content in cache 15 11 get('/')->isCached(true)-> 16 12 get('/applications')->isCached(true)-> … … 22 18 click('Sign in')-> 23 19 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')-> 29 21 30 22 get('/')->isCached(false)-> … … 38 30 shutdown() 39 31 ; 40 41 $user->delete();trunk/test/functional/main/feedsActionsTest.php
r2 r75 3 3 4 4 // create a new test browser 5 $browser = new sfTestBrowser();5 $browser = new SymfoniansTestBrowser($configuration); 6 6 $browser->initialize(); 7 $browser->loadFixtures(); 7 8 8 9 $browser-> 10 get('/feed/applications/fresh')-> 9 11 get('/feed/applications/fresh')-> 10 12 isStatusCode(200)-> trunk/test/functional/main/homeActionsTest.php
r2 r75 3 3 4 4 // create a new test browser 5 $browser = new sfTestBrowser();5 $browser = new SymfoniansTestBrowser($configuration); 6 6 $browser->initialize(); 7 8 // initialize database manager 9 $databaseManager = new sfDatabaseManager(); 10 $databaseManager->initialize(); 11 $con = Propel::getConnection(); 7 $browser->loadFixtures(); 12 8 13 9 $c = new Criteria; … … 18 14 19 15 $browser-> 16 20 17 get('/')-> 21 18 isStatusCode(200)-> 22 19 isRequestParameter('module', 'home')-> 23 20 isRequestParameter('action', 'index')-> 24 checkResponseElement('body', '!/This is a temporary page/')->21 isCached(true)-> 25 22 checkResponseElement('body', '/This website aims to connect coders/')-> 26 23 checkResponseElement('#main h3', 4)-> … … 33 30 checkResponseElement('#main h3', '/Fresh job offers/', array('position' => 3))-> 34 31 checkResponseElement('#main .home_recent_jobs li', sfConfig::get('app_homepage_max_jobs', 5))-> 32 35 33 shutdown() 36 34 ; trunk/test/functional/main/localEventsActionsTest.php
r46 r75 8 8 9 9 $browser-> 10 get('/localEvents /index')->10 get('/localEvents')-> 11 11 isStatusCode(200)-> 12 12 isRequestParameter('module', 'localEvents')-> trunk/test/functional/main/peopleActionsTest.php
r2 r75 3 3 4 4 // create a new test browser 5 $browser = new sfTestBrowser();5 $browser = new SymfoniansTestBrowser($configuration); 6 6 $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(); 16 8 17 9 $browser-> trunk/web/css/style.css
r57 r75 730 730 } 731 731 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], 733 735 .form-row.field_error select, 734 736 .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; 736 740 } 737 741 … … 747 751 font-size: .8em; 748 752 } 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 } 749 765 750 766 .form_help { … … 753 769 } 754 770 755 . form-errors {771 .global-form-errors { 756 772 background: #d00 url(/sf/sf_default/images/icons/cancel48.png) no-repeat 2px 4px; 757 773 color: #fff; … … 759 775 } 760 776 761 . form-errors h4 {777 .global-form-errors h4 { 762 778 margin: 0; 763 779 padding: 0; … … 765 781 } 766 782 783 .global-form-errors ul, 767 784 .form-errors ul { 768 785 list-style-type: none;
