You are here

function fonts_com_get_projects in @font-your-face 7.2

Same name and namespace in other branches
  1. 6.2 modules/fonts_com/fonts_com.module \fonts_com_get_projects()
  2. 7 modules/fonts_com/fonts_com.module \fonts_com_get_projects()

Gets list of projects from API.

2 calls to fonts_com_get_projects()
fonts_com_get_project_by_id in modules/fonts_com/api.inc
Gets list of projects from API.
fonts_com_project_form in modules/fonts_com/fonts_com.module
Provides project settings form.

File

modules/fonts_com/api.inc, line 355
API functions.

Code

function fonts_com_get_projects() {
  $projects = array();
  $path = '/rest/json/Projects/?wfspstart=0&wfsplimit=100';
  $response = drupal_http_request(FONTS_COM_API_BASE_URL . $path, array(
    'headers' => fonts_com_api_headers($path),
  ));
  if ($response->code == 200) {
    $data = json_decode($response->data);
    if ($data->Projects->TotalRecords > 0) {
      $project = $data->Projects->Project;
      $projects = fonts_com_unknown_to_array($project);
    }

    // if
  }
  else {
    drupal_set_message(t('There was an error importing project list from Fonts.com. Check !configuration.', array(
      '!configuration' => l(t('configuration'), 'admin/config/user-interface/fontyourface/fonts_com'),
    )), 'error');
    fontyourface_log('Invalid drupal_http_request response: @response', array(
      '@response' => print_r($response, TRUE),
    ));
  }

  // else
  return $projects;
}