public function GetCellData($fieldName, $row, $url = '', $inputTypeOverride = NULL, $valuesOverride = NULL)
 {
     if (is_array($row) && array_key_exists('__module__', $row) && $row['__module__'] != get_class($this)) {
         $obj = utopia::GetInstance($row['__module__']);
         return $obj->GetCellData($fieldName, $row, $url, $inputTypeOverride, $valuesOverride);
     }
     $pkVal = NULL;
     if (is_array($row)) {
         if ($this->UNION_MODULE) {
             $pkField = '__module_pk__';
         } else {
             $pkField = $this->GetPrimaryKey();
         }
         $pkVal = $row[$pkField];
     }
     //		echo "// start PP for $fieldName ".(is_array($row) && array_key_exists($fieldName,$row) ? $row[$fieldName] : '')."\n";
     $value = '';
     if (isset($row[$fieldName])) {
         $value = $row[$fieldName];
     }
     if ($value === '' && isset($this->fields[$fieldName]) && preg_match('/^\'(.+?)\'/', $this->fields[$fieldName]['field'], $match)) {
         $value = $match[1];
     }
     $value = $this->PreProcess($fieldName, $value, $row);
     $fieldData = array();
     if (isset($this->fields[$fieldName])) {
         $fieldData = $this->fields[$fieldName];
     }
     if (!$fieldData && strpos($fieldName, ':') !== FALSE) {
         list($vname) = explode(':', $fieldName);
         if (isset($this->fields[$vname])) {
             $fieldData = $this->fields[$vname];
         }
     }
     $attr = array();
     $styles = $this->FieldStyles_Get($fieldName, $row);
     if ($styles) {
         $attr['style'] = $styles;
     }
     $inputType = !is_null($inputTypeOverride) ? $inputTypeOverride : (isset($fieldData['inputtype']) ? $fieldData['inputtype'] : itNONE);
     if ($inputType !== itNONE && ($inputTypeOverride || $row !== NULL && $this->flag_is_set(ALLOW_EDIT, $fieldName) || $row === NULL && $this->flag_is_set(ALLOW_ADD, $fieldName))) {
         if ($inputType === itFILE) {
             $ret = '';
             if (!$value) {
                 $ret .= '<span class="icon-document-delete uDesaturate"></span>';
                 $ret .= '<span class="icon-document-view uDesaturate"></span>';
                 $ret .= '<span class="icon-document-download uDesaturate"></span>';
             } else {
                 $id = $this->CreateSqlField($fieldName, $pkVal);
                 $ret .= '<a title="Delete File" href="#" name="' . $id . '" class="uf icon-document-delete"></a>';
                 $link = uBlob::GetLink(get_class($this), $fieldName, $pkVal, $row[$fieldName . '_filename']);
                 $ret .= '<a title="View File" target="_blank" href="' . $link . '" class="icon-document-view"></a>';
                 $ret .= '<a title="Download File" href="' . $link . '?attach=attachment" class="icon-document-download"></a>';
             }
             $ret .= '<span title="Upload File" class="icon-document-upload">' . $this->DrawSqlInput($fieldName, $value, $pkVal, $attr, $inputType, $valuesOverride) . '</span>';
         } else {
             if ($pkVal === NULL) {
                 // set a placeholder based on the default value for new records
                 $dv = $this->GetDefaultValue($fieldName);
                 $vals = $valuesOverride;
                 if (!$vals) {
                     $vals = $this->GetValues($fieldName, $pkVal);
                 }
                 if ($dv && $vals && isset($vals[$dv])) {
                     $dv = $vals[$dv];
                 }
                 if (!$value) {
                     $value = $dv;
                 }
                 $attr['placeholder'] = $value;
             }
             $ret = $this->DrawSqlInput($fieldName, $value, $pkVal, $attr, $inputType, $valuesOverride);
         }
     } else {
         $vals = $valuesOverride;
         if (!$vals) {
             $vals = $this->GetValues($fieldName);
         }
         if (isset($vals[$value])) {
             $value = $vals[$value];
         }
         $ret = '';
         if ($url && !$this->GetFieldProperty($fieldName, 'nolink')) {
             if ($this->GetFieldProperty($fieldName, 'button')) {
                 $attr['class'] = isset($attr['class']) ? $attr['class'] . ' btn' : 'btn';
             }
             $attrStr = BuildAttrString($attr);
             $ret = "<a{$attrStr} href=\"{$url}\">{$value}</a>";
         } else {
             $attrStr = BuildAttrString($attr);
             $ret = $value;
             if ($attrStr) {
                 $ret = "<span{$attrStr}>{$value}</span>";
             }
         }
     }
     return $ret;
 }
Exemple #2
0
 public function ProcessDomDocument($o, $e, $doc)
 {
     $head = $doc->getElementsByTagName('head')->item(0);
     // add OG protocol
     if (isset($_GET['news_id'])) {
         $rec = $this->LookupRecord($_GET['news_id']);
         $img = 'http://' . utopia::GetDomainName() . uBlob::GetLink(get_class($this), 'image', $rec['news_id']);
         $meta = $doc->createElement('meta');
         $meta->setAttribute('property', 'og:title');
         $meta->setAttribute('content', $rec['heading']);
         $head->appendChild($meta);
         $meta = $doc->createElement('meta');
         $meta->setAttribute('property', 'og:type');
         $meta->setAttribute('content', 'article');
         $head->appendChild($meta);
         $meta = $doc->createElement('meta');
         $meta->setAttribute('property', 'og:url');
         $meta->setAttribute('content', 'http://' . utopia::GetDomainName() . $_SERVER['REQUEST_URI']);
         $head->appendChild($meta);
         if ($rec['image']) {
             // image exists?
             $meta = $doc->createElement('meta');
             $meta->setAttribute('property', 'og:image');
             $meta->setAttribute('content', $img);
             $head->appendChild($meta);
         }
         $meta = $doc->createElement('meta');
         $meta->setAttribute('property', 'og:site_name');
         $meta->setAttribute('content', modOpts::GetOption('site_name'));
         $head->appendChild($meta);
         $meta = $doc->createElement('meta');
         $meta->setAttribute('property', 'og:description');
         $meta->setAttribute('content', $rec['description']);
         $head->appendChild($meta);
     }
     // add RSS link
     $rssobj = utopia::GetInstance('module_NewsRSS');
     $link = $doc->createElement('link');
     $link->setAttribute('rel', 'alternate');
     $link->setAttribute('type', 'application/atom+xml');
     $link->setAttribute('title', modOpts::GetOption('site_name') . ' News Feed');
     $link->setAttribute('href', $rssobj->GetURL());
     $head->appendChild($link);
 }