Turba::formatCompositeField PHP Method

formatCompositeField() public static method

Builds and cleans up a composite field.
public static formatCompositeField ( string $format, array $fields ) : string
$format string The sprintf field format.
$fields array The fields that compose the composite field.
return string The formatted composite field.
    public static function formatCompositeField($format, $fields)
    {
        return preg_replace('/ +/', ' ', trim(vsprintf($format, $fields), " \t\n\r\v,"));
    }

Usage Example

Example #1
0
 /**
  * Returns the value of the specified attribute.
  *
  * @param string $attribute  The attribute to retrieve.
  *
  * @return mixed  The value of $attribute, an array (for photo type)
  *                or the empty string.
  */
 public function getValue($attribute)
 {
     global $attributes, $injector;
     if (isset($this->attributes[$attribute]) && ($hooks = $injector->getInstance('Horde_Core_Hooks')) && $hooks->hookExists('decode_attribute', 'turba')) {
         try {
             return $hooks->callHook('decode_attribute', 'turba', array($attribute, $this->attributes[$attribute], $this));
         } catch (Turba_Exception $e) {
         }
     } elseif (isset($this->driver->map[$attribute]) && is_array($this->driver->map[$attribute])) {
         $args = array();
         foreach ($this->driver->map[$attribute]['fields'] as $field) {
             $args[] = $this->getValue($field);
         }
         return Turba::formatCompositeField($this->driver->map[$attribute]['format'], $args);
     } elseif (!isset($this->attributes[$attribute])) {
         if (isset($attributes[$attribute]) && $attributes[$attribute]['type'] == 'Turba:TurbaTags' && ($uid = $this->getValue('__uid'))) {
             $this->synchronizeTags($injector->getInstance('Turba_Tagger')->getTags($uid, 'contact'));
         } else {
             return null;
         }
     } elseif (isset($attributes[$attribute]) && $attributes[$attribute]['type'] == 'image') {
         return empty($this->attributes[$attribute]) ? null : array('load' => array('data' => $this->attributes[$attribute], 'file' => basename(Horde::getTempFile('horde_form_', false, '', false, true))));
     }
     return $this->attributes[$attribute];
 }
All Usage Examples Of Turba::formatCompositeField