Permalink
Browse files

Hook into both 'validate_save' and 'validate_publish' steps on the ar…

…ticle tab.
  • Loading branch information...
Robert Wetzlmayr
Robert Wetzlmayr committed Apr 18, 2012
1 parent ca395b0 commit ffc8b4eec6f31958fd4106a20ce709f5329167b3
Showing with 5 additions and 2 deletions.
  1. +5 −2 wet_sample_article_constraints.php
@@ -3,6 +3,9 @@ class wet_sample_article_constraints
{
function __construct()
{
+ register_callback(__CLASS__.'_ignore_status', 'article_ui', 'validate_publish');
+ register_callback(__CLASS__.'_min_title_length', 'article_ui', 'validate_publish');
+
register_callback(__CLASS__.'_ignore_status', 'article_ui', 'validate_save');
register_callback(__CLASS__.'_min_title_length', 'article_ui', 'validate_save');
}
@@ -11,7 +14,7 @@ function __construct()
/**
* Constrain minimum title length
*/
-class wet_TitleLengthConstraint extends Constraint
+class wet_LengthConstraint extends Constraint
{
function validate()
{
@@ -31,7 +34,7 @@ function wet_sample_article_constraints_ignore_status($event, $step, &$rs, &$con
function wet_sample_article_constraints_min_title_length($event, $step, &$rs, &$constraints)
{
// Add a custom constraint to enforce a title length of 5 characters or more
- $constraints['wet_titlelength'] = new wet_TitleLengthConstraint($rs['Title'], array('min' => 5, 'message' => 'title_too_short'));
+ $constraints['wet_titlelength'] = new wet_LengthConstraint($rs['Title'], array('min' => 5, 'message' => 'title_too_short'));
}
if (txpinterface == 'admin') new wet_sample_article_constraints;

0 comments on commit ffc8b4e

Please sign in to comment.