static function validateStockAvatar($parameters)
 {
     return isset($parameters[Stock::AVATAR_FIELD]) && ValidateHelper::validateFileField($parameters[Stock::AVATAR_FIELD]);
 }
 static function validateBaseDocumentParameters($parameters)
 {
     return isset($parameters[DocumentItem::TITLE_FIELD]) && ValidateHelper::validateTextField($parameters[DocumentItem::TITLE_FIELD], DocumentItem::MIN_TITLE_LENGTH, DocumentItem::MAX_TITLE_LENGTH) && (isset($parameters[DocumentItem::INFO_FIELD]) && ValidateHelper::validateTextField($parameters[DocumentItem::INFO_FIELD], DocumentItem::MIN_INFO_LENGTH, DocumentItem::MAX_INFO_LENGTH));
 }
 static function validateOrphanageAvatar($parameters)
 {
     return isset($parameters[Orphanage::AVATAR_FIELD]) && ValidateHelper::validateFileField($parameters[Orphanage::AVATAR_FIELD]);
 }
Exemplo n.º 4
0
 /**
  * Limits the words in a string. Words are separated by spaces.
  * If string is composed of a single word, it will be shortened
  * with the limit length function.
  *
  * @param   string $textString
  * @param   int    $textWordsLimit
  * @param   string $textPlaceholder
  * @return  bool|string Returns false if bad arguments were provided.
  */
 public static function textLimitWords($textString, $textWordsLimit = 5, $textPlaceholder = '...')
 {
     if (ValidateHelper::validString($textString) && ValidateHelper::validString($textPlaceholder) && ValidateHelper::validInt($textWordsLimit)) {
         $textStringToArray = explode(' ', $textString);
         $textShortString = '';
         if (count($textStringToArray) == 1) {
             // Assume 5 is the average word length.
             return self::textLimitLength($textString, $textWordsLimit * 5);
         } elseif (count($textStringToArray) <= $textWordsLimit) {
             return $textString;
         } else {
             for ($i = 0; $i < $textWordsLimit; $i++) {
                 $textShortString .= $textStringToArray[$i] . ' ';
             }
             // Removing the last \space\.
             return substr($textShortString, 0, -1) . $textPlaceholder;
         }
     } else {
         return false;
     }
 }