function fb_admin_applications_form in Drupal for Facebook 7.4
File
- ./
fb.admin.inc, line 685
Code
function fb_admin_applications_form($form, &$form_state) {
// Build the sortable table header.
$header = array(
'title' => array(
'data' => t('Name'),
'field' => 'fba.title',
'sort' => 'asc',
),
'fba' => array(
'data' => t('ID'),
'field' => 'fba.fba',
),
// Needed?
'status' => array(
'data' => t('Status'),
'field' => 'fba.status',
),
'token' => array(
'data' => t('Token'),
'style' => 'display:none;',
'class' => 'fb_access_token',
),
'local' => t('Local Operations'),
'remote' => array(
'data' => t('Facebook Operations'),
),
);
$query = db_select('fb_application', 'fba')
->extend('PagerDefault')
->extend('TableSort');
$query
->leftjoin('cache_fb', 'fbc_fba', 'fbc_fba.cid = fba.fba');
$query
->addField('fbc_fba', 'data', 'fba_data');
$results = $query
->fields('fba')
->limit(50)
->orderByHeader($header)
->execute();
$options = array();
while ($adata = $results
->fetchObject()) {
$adata->data = unserialize($adata->sdata);
$options[$adata->fba] = array(
'fba' => $adata->fba,
'title' => $adata->title,
'status' => $adata->status,
'token' => array(
'data' => $adata->data['access_token'],
'class' => 'fb_access_token',
'style' => 'display:none;',
),
'local' => array(
'data' => array(
'#theme' => 'links',
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
'#links' => array(
'edit' => array(
'title' => t('edit'),
'href' => FB_PATH_ADMIN_APPS . '/' . $adata->fba . '/edit',
),
),
),
),
'remote' => array(
'data' => array(
'#theme' => 'links',
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
'#links' => array(
'settings' => array(
'title' => t('settings'),
'href' => 'https://developers.facebook.com/apps/' . $adata->fba . '/summary',
'attributes' => array(
'target' => '_blank',
),
),
'explore' => array(
'title' => t('explore'),
'href' => 'https://developers.facebook.com/tools/explorer/' . $adata->fba,
'attributes' => array(
'target' => '_blank',
),
'query' => array(
'method' => 'GET',
'path' => $adata->fba,
),
),
),
),
),
);
// Use details from cache, if available.
$fba_data = unserialize($adata->fba_data);
if (!empty($fba_data)) {
$options[$adata->fba]['title'] = array(
'data' => array(
'#type' => 'link',
'#title' => '<img src="' . $fba_data['icon_url'] . '"/> ' . $fba_data['name'],
'#href' => $fba_data['link'],
'#options' => array(
'html' => TRUE,
),
),
);
if (!empty($fba_data['access_token'])) {
$options[$adata->fba]['remote']['data']['#links']['debug'] = array(
'title' => t('debug'),
'href' => 'https://developers.facebook.com/tools/debug/access_token',
'query' => array(
'q' => $adata->fba,
),
'attributes' => array(
'target' => '_blank',
),
);
// TODO: add remote settings link.
}
}
}
$form['applications'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No applications found.'),
);
$form['toggle_tokens'] = array(
'#type' => 'markup',
'#markup' => '<a href=# onclick="jQuery(\'.fb_access_token\').toggle(); return false;">show/hide tokens</a>',
);
$form['pager'] = array(
'#markup' => theme('pager'),
);
return $form;
}