Exemple #1
0
 protected function BuildRow($aRow)
 {
     if (!empty($aRow['copy'])) {
         $this->BuildInlineCopy($aRow['copy']);
     }
     // Check if all the fields are required
     $bRequired = true;
     if (!empty($aRow['element'])) {
         foreach ($aRow['element'] as $aElement) {
             $bRequired &= !empty($aElement['validation']['required']);
         }
     } else {
         $bRequired = false;
     }
     #-> Build Label
     $sLabel = !empty($aRow['label']) ? $aRow['label'] : ' ';
     $sLabel .= $bRequired ? ' <span class="required">*</span>' : '';
     if (!empty($aRow['image'])) {
         $sLabel = '<img align="left" src="' . BuildImage($aRow['image']) . '" /> ' . $sLabel;
     }
     #-> Build Elements
     $sElement = '';
     if (!empty($aRow['element'])) {
         $oElement = new Builder_Form_Element();
         foreach ($aRow['element'] as $aElement) {
             $sElement .= $oElement->Build($aElement, $this->aData);
         }
     }
     #-> Build the row's HTML
     $sRenderMode = !empty($aRow['render-mode']) ? $aRow['render-mode'] : '';
     switch ($sRenderMode) {
         case self::RENDER_MODE_INPUT_ONLY:
             $this->sResult .= "<tr>\n";
             $this->sResult .= "<td class=\"form-value\"" . (!empty($aRow['id']) ? " id=\"" . $aRow['id'] . "-value\"" : "") . " colspan=\"2\">" . $sLabel . " " . $sElement . "</td>\n";
             $this->sResult .= "</tr>\n";
             break;
         case self::RENDER_MODE_LABEL_INPUT:
         default:
             $this->sResult .= "<tr>\n";
             $this->sResult .= "<td class=\"form-label\"" . (!empty($aRow['id']) ? " id=\"" . $aRow['id'] . "-label\"" : "") . ">" . $sLabel . "</td>\n";
             $this->sResult .= "<td class=\"form-value\"" . (!empty($aRow['id']) ? " id=\"" . $aRow['id'] . "-value\"" : "") . ">" . $sElement . "</td>\n";
             $this->sResult .= "</tr>\n";
             break;
     }
 }
Exemple #2
0
 protected function ConstructField($mData, $sKey, $sFormat = '')
 {
     // Are we dealing with a Complex Key?
     if (strpos($sFormat, '|') !== false) {
         return $this->BuildComplexKey($mData, $sKey, $sFormat);
     } else {
         switch ($sFormat) {
             case 'email':
                 return '<a href="mailto:' . $mData[$sKey] . '">' . $mData[$sKey] . '</a>';
             case 'ip_address':
                 return $mData[$sKey] ? inet_ntoa($mData[$sKey]) : '<i>empty</i>';
             case 'coordinates':
                 if (!empty($mData[$sKey])) {
                     $aCoords = explode(',', $mData[$sKey]);
                     if (count($aCoords) == 2) {
                         $sUrl = 'http://maps.google.com/?ll=' . $aCoords[0] . ',' . $aCoords[1] . '&z=16';
                         return '<a href="' . $sUrl . '"><img src="' . BuildImage('16x16/map-pin.png') . '" align="left" />&nbsp;' . $aCoords[0] . ', ' . $aCoords[1] . '</a>';
                     } else {
                         return '<i>Invalid Coords</i>';
                     }
                 } else {
                     return '<i>No Coords</i>';
                 }
                 break;
             case 'relative_time':
                 return $mData[$sKey] ? RelativeTime($mData[$sKey]) : '<i>empty</i>';
             case 'datetime':
                 return $mData[$sKey] ? date('Y-m-d H:i:s', $mData[$sKey]) : '<i>empty</i>';
             case 'date':
                 return $mData[$sKey] ? date('Y-m-d', $mData[$sKey]) : '<i>empty</i>';
             case 'time':
                 return $mData[$sKey] ? date('H:i:s', $mData[$sKey]) : '<i>empty</i>';
             default:
                 if (!is_array($mData)) {
                     return !empty($mData) ? $mData : '&nbsp;';
                 } else {
                     return !empty($mData[$sKey]) ? $mData[$sKey] : '&nbsp;';
                 }
         }
     }
 }
 private function RenderSelectList()
 {
     $sResult = '<select ' . $this->RenderAttributes() . '>' . "\n";
     if (!empty($this->aMeta['list'])) {
         foreach ($this->aMeta['list'] as $aEntry) {
             $sLabel = !empty($aEntry['name']) ? $aEntry['name'] : $aEntry['value'];
             $aAttributes = array('value' => $aEntry['value']);
             if (!empty($aEntry['image'])) {
                 #-> TODO: This only works for Firefox
                 $aAttributes = array('style' => 'background: url(' . BuildImage($aEntry['image']) . ') 1px 3px no-repeat; padding-left: 20px;');
                 //$sLabel = '<img src="'. BuildImage($aEntry['image']) .'" /> '. $sLabel;
             }
             if (!empty($this->aMeta['value']) && $aEntry['value'] == $this->aMeta['value']) {
                 $aAttributes['selected'] = 'selected';
             }
             $sResult .= '<option ' . $this->RenderAttributes($aAttributes) . '>' . $sLabel . '</option>' . "\n";
         }
     }
     $sResult .= '</select>' . "\n";
     return $sResult;
 }