Example #1
0
 /**
  * Convert a display name into a potential variable
  * name that we could use in forms/code
  * 
  * @param  name    Name of the string
  * @return string  An equivalent variable name
  *
  * @access public
  * @return string (or null)
  * @static
  */
 static function titleToVar($title, $maxLength = 31)
 {
     $variable = self::munge($title);
     require_once "CRM/Utils/Rule.php";
     if (CRM_Utils_Rule::title($variable, $maxLength)) {
         return $variable;
     }
     return null;
 }
Example #2
0
 /**
  * Convert a display name into a potential variable
  * name that we could use in forms/code
  *
  * @param  name    Name of the string
  *
  * @param int $maxLength
  *
  * @return string  An equivalent variable name
  *
  * @access public
  *
  * @return string (or null)
  * @static
  */
 static function titleToVar($title, $maxLength = 31)
 {
     $variable = self::munge($title, '_', $maxLength);
     if (CRM_Utils_Rule::title($variable, $maxLength)) {
         return $variable;
     }
     // if longer than the maxLength lets just return a substr of the
     // md5 to prevent errors downstream
     return substr(md5($title), 0, $maxLength);
 }
Example #3
0
 /**
  * Convert a display name into a potential variable
  * name that we could use in forms/code
  * 
  * @param  name    Name of the string
  * @return string  An equivalent variable name
  *
  * @access public
  * @return string (or null)
  * @static
  */
 function titleToVar($title)
 {
     if (!CRM_Utils_Rule::title($title)) {
         return null;
     }
     $variable = CRM_Utils_String::munge($title);
     if (CRM_Utils_Rule::variable($variable)) {
         return $variable;
     }
     return null;
 }