Example #1
0
 /**
  * Get a ContentElementField related to a table and field name
  *
  * @param   NenoContentElementTable $table     Table
  * @param   string                  $fieldName Field name
  *
  * @return NenoContentElementField
  */
 public static function getFieldByTableAndFieldName(NenoContentElementTable $table, $fieldName)
 {
     // Get fields related to this table
     $fields = $table->getFields(false);
     $field = null;
     if (!empty($fields)) {
         $fields = $table->getFields(false);
         $found = false;
         for ($i = 0; $i < count($fields) && !$found; $i++) {
             /* @var $field NenoContentElementField */
             $field = $fields[$i];
             if ($field->getFieldName() == $fieldName) {
                 $found = true;
             }
         }
         if ($found) {
             if ($field->getId() == null) {
                 $field = self::getFieldDataFromDatabase($table->getId(), $fieldName);
             }
             return $field;
         }
         return false;
     } else {
         return self::getFieldDataFromDatabase($table->getId(), $fieldName);
     }
 }