Changeset 35
- Timestamp:
- 09/26/07 17:45:24 (1 year ago)
- Files:
-
- trunk/src/includes/editam/behaviours/form_behaviour.php (modified) (5 diffs)
- trunk/src/includes/editam/helpers/editags_helper.php (modified) (3 diffs)
- trunk/src/includes/editam/models/editam_setup.php (modified) (4 diffs)
- trunk/src/includes/editam/models/page.php (modified) (2 diffs)
- trunk/src/includes/editam/test/unit/app/models/page.php (modified) (13 diffs)
- trunk/src/includes/editam/views/login/authenticate.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/includes/editam/behaviours/form_behaviour.php
r2 r35 34 34 // +----------------------------------------------------------------------+ 35 35 36 defined('AK_EMAIL_REGULAR_EXPRESSION') ? null : define('AK_EMAIL_REGULAR_EXPRESSION',"/^([a-z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-z0-9\-]+\.)+))([a-z]{2,4}|[0-9]{1,3})(\]?)$/i"); 37 36 38 class FormBehaviour extends BaseBehaviour 37 39 { … … 44 46 function isPageVirtual() 45 47 { 46 return true;48 return false; 47 49 } 48 50 … … 66 68 $errors = array(); 67 69 if(count($post)){ 68 define('AK_EMAIL_REGULAR_EXPRESSION',"/^([a-z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-z0-9\-]+\.)+))([a-z]{2,4}|[0-9]{1,3})(\]?)$/i");69 if(empty($ post['email']) || !preg_match(AK_EMAIL_REGULAR_EXPRESSION,$post['email'])){70 $email = $this->getSenderEmail(); 71 if(empty($email) || !preg_match(AK_EMAIL_REGULAR_EXPRESSION,$email)){ 70 72 $errors['email'] = Ak::t("Please insert a valid email.", array(), 'form_behaviour'); 71 73 } 72 74 } 73 74 75 if(count($post) && count($errors) == 0){ 75 76 $message = ''; … … 78 79 $message .= ucfirst(str_replace("_"," ",$k)).": ".stripslashes($v)."\r\n"; 79 80 } 80 $this->Controller->form_sent = Ak::mail($this->getSender(), $this->getDestinationEmail(), $this->getSubject(), $message);81 $this->Controller->form_message_contents = $this->getSender().' >> '.$this->getDestinationEmail()."\n". 82 $this-> getSubject()."\n-------------------\n".$message;81 $this->Controller->form_sent = mail($this->getDestinationEmail(), $this->getSubject(), $message, $this->getFromHeader()."\r\nContent-Type: text/plain;charset=UTF-8;\r\n"); 82 83 $this->Controller->form_message_contents = $email.' >> '.$this->getDestinationEmail()."\n".$this->getSubject()."\n-------------------\n".$message; 83 84 } 84 $this->Controller->form_errors = $errors; 85 $this->Controller->form_errors = $errors; 85 86 } 86 87 … … 97 98 } 98 99 99 function getSender ()100 function getSenderEmail() 100 101 { 101 return $this->Controller->params['form']['email'].'<'.$this->Controller->params['form']['email'].'>'; 102 return empty($this->Controller->params['form']['email']) ? '' : $this->Controller->params['form']['email']; 103 } 104 105 function getSenderName() 106 { 107 return empty($this->Controller->params['form']['name']) ? '' : $this->Controller->params['form']['name']; 108 } 109 110 function getFromHeader() 111 { 112 $sender_name = $this->getSenderName(); 113 $email = $this->getSenderEmail(); 114 return preg_replace('/(\n|\r)*/','', 'From: '.(empty($sender_name) ? $email : $sender_name)." <{$email}>"); 102 115 } 103 116 trunk/src/includes/editam/helpers/editags_helper.php
r26 r35 35 35 36 36 defined('EDITAM_CSS_MEDIA_TYPES') ? null : define('EDITAM_CSS_MEDIA_TYPES', 'screen|print|handheld|tv|projection|all|aural|braille|embossed|tty'); 37 defined('AK_ACTION_CONTROLLER_AVAILABLE_HELPERS') ? null : define('AK_ACTION_CONTROLLER_AVAILABLE_HELPERS', 'url_helper,text_helper,tag_helper,scriptaculous_helper,prototype_helper,pagination_helper,number_helper,menu_helper,javascript_macros_helper,javascript_helper,form_tag_helper,form_options_helper,form_helper,file_upload_helper,date_helper,capture_helper,asset_tag_helper,active_record_helper,editags_helper,layout_helper'); 38 37 39 38 40 require_once(AK_LIB_DIR.DS.'AkActionView'.DS.'AkActionViewHelper.php'); … … 103 105 104 106 105 function snippet($name )107 function snippet($name, $local_assigns = array()) 106 108 { 107 109 if($Snippet =& $this->_controller->Snippet->findFirstBy('name',$name)){ 108 return $Snippet->render($this->_controller );110 return $Snippet->render($this->_controller, $local_assigns); 109 111 } 110 112 } … … 251 253 { 252 254 $args = func_get_args(); 253 return preg_replace('/^('.str_replace('/','\/',AK_ASSET_URL_PREFIX).')/', '', call_user_func_array(array(&$this->_controller->asset_tag_helper,'_compute_public_path'), $args)); 255 $computed_path = call_user_func_array(array(&$this->_controller->asset_tag_helper,'_compute_public_path'), $args); 256 return strlen(AK_ASSET_URL_PREFIX) > 1 ? preg_replace('/^('.str_replace('/','\/',AK_ASSET_URL_PREFIX).')/', '', $computed_path) : $computed_path; 254 257 } 255 258 trunk/src/includes/editam/models/editam_setup.php
r29 r35 43 43 var $available_locales = array('en', 'es'); 44 44 var $locales = array('en'); 45 var $stylesheets = array('akelos','content_layout','default',46 'editam-ie','editam','login','modalbox','page','permission','role',47 'snippet','tab_canvas','tree');48 45 49 46 function __construct() … … 290 287 } 291 288 292 function relativizeStylesheet sUrls()289 function relativizeStylesheetPaths() 293 290 { 294 291 $suffix = $this->getUrlSuffix(); … … 303 300 return true; 304 301 } 305 302 306 303 function getUrlSuffix() 307 304 { … … 780 777 return 'localhost'; 781 778 } 782 783 function relativizeStylesheetPaths()784 {785 if($this->hasUrlSuffix()){786 $url_suffix = trim($this->getUrlSuffix(),'/');787 foreach ($this->stylesheets as $stylesheet) {788 $filename = AK_PUBLIC_DIR.DS.'stylesheets'.DS.$stylesheet.'.css';789 $relativized_css = preg_replace("/url\((\'|\")?\/images/","url($1/$url_suffix/images", @Ak::file_get_contents($filename));790 empty($relativized_css) ? null : @Ak::file_put_contents($filename, $relativized_css);791 }792 }793 }794 779 } 795 780 trunk/src/includes/editam/models/page.php
r2 r35 55 55 ); 56 56 57 var $acts_as = array('nested_set' => array('order' => 'virtual DESC, title ASC','scope' => "locale = ?")); 58 59 /* 57 60 function __construct() 58 61 { 59 if(empty($this->__testing_mode)){60 $this->acts_as = array('nested_set' => array('order' => 'virtual DESC, title ASC','scope' => "locale = '".61 $this->getLang(@$attributes['locale']).62 "'"));63 }64 65 62 $attributes = (array)func_get_args(); 66 return $this->init($attributes); 67 } 68 69 function getLang($proposed_lang = null) 63 $Page = $this->init($attributes); 64 $Page->_fixed_locale = $Page->get('locale'); 65 } 66 */ 67 68 function getLocale() 70 69 { 71 70 $default_lang = Ak::lang(); 72 $lang = empty($proposed_lang) ? (empty($this->locale) ? $default_lang : $this->locale) : $proposed_lang; 73 return in_array($lang, Ak::langs()) ? $lang : $default_lang; 71 $lang = empty($this->locale) ? $default_lang : $this->locale; 72 $locale = in_array($lang, Ak::langs()) ? $lang : $default_lang; 73 $this->_original_locale = empty($this->_original_locale) ? $locale : $this->_original_locale; 74 return $locale; 74 75 } 75 76 … … 163 164 164 165 $this->validatesInclusionOf('locale', Ak::langs()); 166 167 if(isset($this->_original_locale) && $this->_original_locale != $this->get('locale')){ 168 $this->addError('locale', $this->t('Page locale can\'t be changed once it has been set.')); 169 } 165 170 } 166 171 trunk/src/includes/editam/test/unit/app/models/page.php
r28 r35 18 18 Mock::generate('EditagsHelper'); 19 19 20 20 21 // Page without nested for creating initial pages from yaml data 21 22 class TestingPage extends Page … … 31 32 32 33 33 class PageTestCase extends AkUnitTest 34 class PageTestCase extends AkUnitTest 34 35 { 35 36 function setup() … … 40 41 $installer->do_not_create_sample_data = true; 41 42 $installer->uninstall(); 42 43 43 44 $installer->install(); 44 45 45 46 $Pages = Ak::convert('yaml','array', Ak::file_get_contents(AK_TEST_DIR.DS.'fixtures'.DS.'db'.DS.'pages.yaml')); 46 47 $this->_loadPage(); 47 48 48 49 $Layouts = Ak::convert('yaml','array', Ak::file_get_contents(AK_TEST_DIR.DS.'fixtures'.DS.'db'.DS.'content_layouts.yaml')); 49 50 $this->Layout =& new ContentLayout(); … … 51 52 $this->Layout->create($Layout); 52 53 } 53 54 54 55 $this->Page =& new TestingPage(); 55 56 foreach ($Pages as $Page){ … … 65 66 66 67 } 67 68 68 69 $this->_loadPage(); 69 70 } 70 71 71 72 function _loadPage() 72 73 { … … 74 75 $this->_loadPageDependencies($this->Page); 75 76 } 76 77 77 78 function _loadPageDependencies(&$Page) 78 79 { … … 95 96 $this->assertNoPattern('/is invalid/',$Page->getErrorsOn('slug')); 96 97 } 97 98 98 99 return; 99 100 … … 235 236 236 237 } 237 238 238 239 function test_published_at_not_updated_on_save_because_already_published() 239 240 { … … 258 259 259 260 } 260 261 261 262 262 263 function test_page_should_return_current_layout() … … 264 265 $Page =& $this->Page->findByUrl('/'); 265 266 $this->assertPattern('/base_template/',$Page->getLayout()); 266 267 267 268 $Page =& $this->Page->findByUrl('/docs'); 268 269 $this->assertPattern('/docs_template/',$Page->getLayout()); … … 275 276 $Layout =& $Page->getLayoutInstance(); 276 277 $this->assertPattern('/base_template/',$Layout->get('content')); 277 278 278 279 $Page =& $this->Page->findByUrl('/docs/tutorials'); 279 280 $Layout =& $Page->getLayoutInstance(); 280 281 $this->assertPattern('/docs_template/',$Layout->get('content')); 281 282 } 282 283 283 284 284 285 function test_should_return_part_instance() 285 286 { … … 302 303 $this->_loadPageDependencies($Page); 303 304 $this->assertEqual($Page->getFilteredPart('body'), 'Documentation body'); 304 305 } 306 305 306 } 307 307 308 308 309 … … 312 313 $Page->part->load(); 313 314 314 $part_id = $Page->parts[0]->getId(); 315 $part_id = $Page->parts[0]->getId(); 315 316 $this->assertTrue($Page->destroy()); 316 317 $this->assertFalse($this->PagePart->find($part_id)); 317 318 } 318 319 319 320 320 321 function test_destroy_nested_elements_and_their_dependent_parts() 321 322 { 322 323 323 324 $Page =& $this->Page->findByUrl('/docs/tutorials/creating-a-bookstore/introduction', true); 324 325 $outermost_page_id = $Page->getId(); 325 326 $Page->part->load(); 326 327 $outermost_part_id = $Page->parts[0]->getId(); 327 328 328 329 $Page =& $this->Page->findByUrl('/docs/tutorials/creating-a-bookstore', true); 329 330 $child_page_id = $Page->getId(); 330 331 $Page->part->load(); 331 $child_part_id = $Page->parts[0]->getId(); 332 332 $child_part_id = $Page->parts[0]->getId(); 333 333 334 $Page =& $this->Page->findByUrl('docs/tutorials'); 334 335 $Page->part->load(); 335 336 $part_id = $Page->parts[0]->getId(); 336 337 337 338 $this->assertTrue($Page->destroy()); 338 339 339 340 $this->assertFalse($this->PagePart->find($part_id)); 340 341 $this->assertFalse($this->PagePart->find($child_part_id)); 341 342 $this->assertFalse($this->PagePart->find($outermost_part_id)); 342 343 343 344 $this->assertFalse($this->Page->find($child_page_id)); 344 345 $this->assertFalse($this->Page->find($outermost_page_id)); 345 346 } 346 347 348 function test_should_not_allow_changing_page_locale() 349 { 350 $Page =& $this->Page->findByUrl('/about/our-team/bermi',true); 351 $this->assertEqual($Page->get('locale'), 'en'); 352 353 $Page->set('locale','es'); 354 355 $this->assertFalse($Page->save()); 356 357 $this->assertPattern('/change/', $Page->getErrorsOn('locale')); 358 359 $Page =& $this->Page->findByUrl('/about/our-team/bermi',true); 360 $this->assertEqual($Page->get('locale'), 'en'); 361 362 } 347 363 } 348 364 trunk/src/includes/editam/views/login/authenticate.tpl
r2 r35 16 16 <? if($controller->Request->isPost()) : ?> 17 17 <p id="forgot_password_block" class="form_field_block"> 18 <%= link_to translate('I have forgotten my account'), :controller => 'login', :action => 'account_recovery' %>18 <%= link_to translate('I forgot my password'), :controller => 'login', :action => 'account_recovery' %> 19 19 </p> 20 20 <? endif; ?> 21 21 </div> 22 <div class="form_operations">23 <input type="submit" value="_{Sign in}" class="primary" /> _{or} <a href="/" title="_{Go to the public website}">_{Go to the public website}</a>24 </div>25 22 </form> 26 23 </div>
