PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/models/link.php

https://github.com/felixding/LonelyThinker
PHP | 45 lines | 23 code | 1 blank | 21 comment | 0 complexity | 1c13614d305a1e3750afb79e4347356b MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /* SVN FILE: $Id: link.php 42 2009-09-24 12:53:07Z $ */
  3. /**
  4. * Short description for file.
  5. *
  6. * Long description for file
  7. *
  8. * PHP versions 5
  9. *
  10. * Licensed under The BSD License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @filesource
  14. * @copyright Copyright 2007-2009, Felix Ding (http://dingyu.me)
  15. * @link http://lonelythinker.org Project LonelyThinker
  16. * @package LonelyThinker
  17. * @author $LastChangedBy: $
  18. * @version $Revision: 42 $
  19. * @modifiedby $LastChangedBy: $
  20. * @lastmodified $Date: 2009-09-24 20:53:07 +0800 (Thu, 24 Sep 2009) $
  21. * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
  22. */
  23. class Link extends AppModel
  24. {
  25. var $name = 'Link';
  26. var $belongsTo = array('LinkCategory');
  27. var $validate = array(
  28. 'link_category_id' => array('rule'=>'validCategoryId', 'message'=>'Make sure you enter a valid link category id'),
  29. 'title' => array(
  30. 'notEmpty'=>array('rule'=>'notEmpty', 'message'=>'You forgot to name a title for the link'),
  31. 'maxLength'=>array('rule'=>array('maxLength', 100), 'message'=>'What? 100 characters are not enough for the title?!')
  32. ),
  33. 'url' => array(
  34. 'notEmpty'=>array('rule'=>'notEmpty', 'message'=>'Make sure you enter a valid URL'),
  35. 'maxLength'=>array('rule'=>array('maxLength', 255), 'message'=>'What? 255 characters are not enough for the URL?!')
  36. )
  37. );
  38. public function validCategoryId($data)
  39. {
  40. $linkCategory = ClassRegistry::init('LinkCategory');
  41. return $linkCategory->findById($data);
  42. }
  43. }
  44. ?>