When viewing a class that has geoPoint enabled the them render function seems to fail. Looking at the object quickly with dsm I was unable to even see geoPoint data from the query even though its in my class.

This was returned

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Service unavailable (with message)
ResponseText: Recoverable fatal error: Object of class Parse\ParseGeoPoint could not be converted to string in _theme_table_cell() (line 2417 of /var/www/mysite.com/includes/theme.inc).

..

How to repo, I would assume just add a geoPoint to your class and add a longitude and latitude in.

Rest Example..

https://parse.com/docs/rest/guide#geopoints

CommentFileSizeAuthor
#5 GeoPointandPointers-2669276.patch1.7 KBgateway69

Comments

gateway69 created an issue. See original summary.

issa.haddadin’s picture

Assigned: gateway69 » issa.haddadin

Yes GeoPoints are still not handled, i will work on it very soon.

gateway69’s picture

I spent the time today to add in GeoPoint support and very basic Pointer support which just displays the Object Id.. here is your function with my extra code in it..

function parse_crud_get_class_objects_table($chosen_class = '') {
  // initializing arrays 
  $table_header = array();
  $data = array();

  if (isset($chosen_class)) {
    $query = new ParseQuery($chosen_class);
    // Get class fields
    $class = parse_crud_get_class($chosen_class);
    if (isset($class)) {
      // Setting up table headers
      foreach ($class['fields'] as $fieldName => $type) {
        if ($type['type'] != 'Relation') {
          // Don't include relation in the table,
          // we are not intrested in relations, 
          // this module is just for simple CRUD operations
          $table_header[] = $fieldName;
        }
        // lets add pointers 
        if ($type['type'] == 'Pointer') {
          $includeKey = $type['targetClass'];
          // Pointers require includeKey
          $query->includeKey($includeKey);
        }
      }
      // select the pasre columns
      $query->select($table_header);
      $results = $query->find();
      // for the edit and delete links.
      $table_header[] = 'links';
      foreach ($results as $row_key => $row) {
        // get each column value for each row (object)
        foreach ($class['fields'] as $fieldName => $type) {
          if ($type['type'] == 'File') {
            $file = $row->get($fieldName);
            if (isset($file)) {
              $data[$row_key][$fieldName] = '<a target="_blank" href="' . $file->getURL() . '">' . t('View File') . '</a>';
            }
            else {
              $data[$row_key][$fieldName] = t('No file attached');
            }
          }
          elseif ($fieldName == 'createdAt') {
            $dateObj = $row->getCreatedAt();
            $data[$row_key][$fieldName] = $dateObj->format('Y-m-d H:i:s');
          }
          elseif ($fieldName == 'updatedAt') {
            $dateObj = $row->getUpdatedAt();
            $data[$row_key][$fieldName] = $dateObj->format('Y-m-d H:i:s');
          }
          elseif ($fieldName == 'objectId') {
            $rowObjId = $row->getObjectId();
            $data[$row_key][$fieldName] = $rowObjId;
          }
          elseif ($type['type'] == 'Relation') {
            // do nothing, we are not intrested in relations, 
            // this module is just for simple CRUD operations
          }
          elseif ($type['type'] == 'GeoPoint') {
            $geo = $row->get($fieldName);
            $latitude = (string)$geo->getLatitude();
            $longitude = (string)$geo->getLongitude();
            $data[$row_key][$fieldName] = $latitude . ',' . $longitude;
          }
          elseif ($type['type'] == 'Pointer') {
            //@todo figure out what data to pull out ..
            // right now just the object id which we can then refrence and load or pop
            // up a modal dialog with the info from that class
            $pointer = $row->get($fieldName);
            $id = $row->getObjectId();
            $data[$row_key][$fieldName] = $id;
          }
          else {
            // default behaviour for any other column
            $data[$row_key][$fieldName] = $row->get($fieldName);
          }
        }
        $data[$row_key]['links'] = "<a href='/parse/edit/" . $chosen_class . "/" . $rowObjId . "'>" . t('Edit') . "</a><br><a href='/parse/delete/" . $chosen_class . "/" . $rowObjId . "'>" . t('Delete') . "</a>";
      }
    }
  }

  if (!empty($data)) {
    return theme('table', array('header' => $table_header, 'rows' => $data));
  }
  else {
    return FALSE;
  }
}

I would like to continue to work on this , I just have limited time.

issa.haddadin’s picture

Thank you very much gateway69, can you please submit it as a patch so i can port it on the next release so your name will be on the commit.

Issa.

gateway69’s picture

StatusFileSize
new1.7 KB

Here is a patch that includes GeoPoint ability and Basic Pointer stuff..

We should look into the ability to create resizable columns.. kinda like in parse where you can drag it out to see more.. but limit it so the rows are not super long.

gateway69’s picture

issa.haddadin’s picture

Status: Active » Needs review

I applied patch #5 and did some changes, i can confirm that the module now handles geopoints, all those changes are deployed.