Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- drupal_add_css(drupal_get_path('module', 'freeway') . '/css/dashboard_file.css');
- function freeway_menu() {
- $type_url_str = "";
- $items['admin/config/freeway'] = array(
- 'title' => 'Freeway',
- 'description' => 'Freeway functionalities.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('freeway_admin_settings'),
- 'access arguments' => array('translate content'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'freeway.admin.inc',
- );
- $items['user/%user/createFreewayProject'] = array(
- 'title' => 'Create Freeway Project',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('create_freeway_project'),
- 'access callback' => 'node_access',
- 'access arguments' => array('update', 1),
- 'weight' => 1,
- 'file' => 'freeway.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- );
- $items['user/%user/freewayDashboard'] = array(
- 'title' => 'Freeway Dashboard',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('freeway_dashboard'),
- 'access callback' => 'node_access',
- 'access arguments' => array('update', 1),
- 'weight' => 1,
- 'file' => 'freeway.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- );
- $items['user/%user/freewayDashboardDetails'] = array(
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('freeway_dashboard_details'),
- 'access callback' => 'node_access',
- 'access arguments' => array('update', 1),
- 'weight' => 1,
- 'file' => 'freeway.admin.inc',
- );
- $items['user/%user/freewayRetrieve'] = array(
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('freeway_retrieve'),
- 'access callback' => 'node_access',
- 'access arguments' => array('update', 1),
- 'weight' => 1,
- 'file' => 'freeway.admin.inc',
- );
- $items['user/%user/freewayUserMapping'] = array(
- 'title' => 'Freeway User Mapping',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('freeway_user_mapping'),
- 'access callback' => 'node_access',
- 'access arguments' => array('update', 1),
- 'weight' => 1,
- 'file' => 'freeway.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- );
- $items['user/%user/freewayGlobalUser'] = array(
- 'title' => 'Freeway Global User Mapping',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('freeway_user_mapping_global'),
- 'access callback' => 'node_access',
- 'access arguments' => array('update', 1),
- 'weight' => 1,
- 'file' => 'freeway.admin.inc',
- 'type' => MENU_CALLBACK,
- );
- $items['user/%user/freewayNonGlobalUser'] = array(
- 'title' => 'Freeway Non Global User Mapping',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('freeway_user_mapping_non_global'),
- 'access callback' => 'node_access',
- 'access arguments' => array('update', 1),
- 'weight' => 1,
- 'file' => 'freeway.admin.inc',
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
- function freeway_permission() {
- return array(
- 'translate content' => array(
- 'title' => t('translate content'),
- 'description' => t('TODO Add a description for \'translate content\''),
- ),
- );
- }
- function freeway_theme() {
- drupal_add_js(drupal_get_path('module', 'freeway') . '/js/dashboardscript.js');
- return array('freeway_dashboard' => array('render element' => 'form'), 'freeway_dashboard_details' => array('render element' => 'form'), 'freeway_user_mapping_non_global' => array('render element' => 'form'));
- }
- function theme_freeway_dashboard($variables) {
- $form = $variables['form'];
- $url = "";
- drupal_add_js(drupal_get_path('module', 'freeway') . '/js/dashboardscript.js');
- global $user;
- $rows = array();
- foreach (element_children($form) as $key) {
- $row = array();
- if (isset($form[$key]['projectID'])) {
- $status = drupal_render($form['featured'][$key]);
- $row[] = array('data' => l(drupal_render($form[$key]['projectID']), 'user/' . $user->uid . '/freewayDashboardDetails', array('query' => array('project_id' => $form[$key]['projectID']['#markup']))));
- $row[] = array('data' => drupal_render($form[$key]['projectDesc']));
- $row[] = array('data' => drupal_render($form[$key]['projectStatusCode']));
- $rows[] = $row;
- l(t('Title'), $url, array('attributes' => array('target' => '_blank')));
- }
- }
- $header = array();
- $header[] = t('Project ID');
- $header[] = t('Project Description');
- $header[] = t('Project Status');
- $output = drupal_render_children($form) .'<div class="table_overflow">' . theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('size' => 10, 'class' => array('table_class')))) . '</div>';
- return $output;
- }
- function theme_freeway_dashboard_details($variables) {
- $form = $variables['form'];
- drupal_add_js(drupal_get_path('module', 'freeway') . '/js/dashboardscript.js');
- global $user;
- $pidobtained = $_GET['project_id'];
- $rows = array();
- foreach (element_children($form) as $key) {
- $row = array();
- $row[] = array('data' => drupal_render($form[$key]['FileID']));
- $row[] = array('data' => drupal_render($form[$key]['Filename']));
- $row[] = array('data' => drupal_render($form[$key]['SourceLanguageID']));
- $row[] = array('data' => drupal_render($form[$key]['TargetLanguageID']));
- if ($form[$key]['StatusID']['#markup'] == 'READY') {
- $row[] = array(
- 'data' => l(drupal_render($form[$key]['StatusID']), 'user/' . $user->uid . '/freewayRetrieve', array('query' => array('fileId' => $form[$key]['FileID']['#markup'], 'projectID' => $pidobtained, 'fileName' => $form[$key]['Filename']['#markup']), 'attributes' => array('class' => 'common_link_class'))),
- );
- }
- else {
- $row[] = array('data' => drupal_render($form[$key]['StatusID']));
- }
- // $row[] = array('data' => drupal_render($form[$key]['StatusDescription']));
- $rows[] = $row;
- }
- $header = array();
- $header[] = t('File ID');
- $header[] = t('File Name');
- $header[] = t('Source Language');
- $header[] = t('Target Language');
- $header[] = t('Status ID');
- // $header[] = t('Status Description');
- $output = '<div class="table_overflow">' . theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('size' => 10, 'class' => array('table_class')))) . '</div>';
- $output .= drupal_render_children($form);
- return $output;
- }
- function theme_freeway_user_mapping_non_global($variables) {
- $form = $variables['form'];
- drupal_add_js(drupal_get_path('module', 'freeway') . '/js/dashboardscript.js');
- global $user;
- $rows = array();
- foreach ($form['users']['#value'] as $key => $value) {
- $rows[] = array($value, drupal_render($form['textfield1_' . $value]), drupal_render($form['textfield2_' . $value]));
- }
- $header = array();
- $header[] = t('Drupal UserName');
- $header[] = t('Freeway UserName');
- $header[] = t('Freeway Password');
- $output = '<div class="table_overflow">' . theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('size' => 10, 'class' => array('table_class')))) . '</div>';
- $output .= drupal_render_children($form);
- return $output;
- }
- function freeway_node_load($node, $types) {
- global $language;
- $resultLangMode = db_query("SELECT lang_mode_id FROM {freeway_language_mode}");
- $langMode = $resultLangMode -> rowCount();
- $nodeSrc = '';
- $frewayLang = '';
- foreach($node as $n){
- $tempId = $n->nid;
- $tempSrcLang = $n->language;
- }
- $tempTarLang = $language->language;
- $resultLangsSrc = db_query("SELECT freeway_lang_id FROM {freeway_language_map} where drupal_lang_id = '$tempSrcLang'");
- $rowsLanguage = $resultLangsSrc->rowCount();
- if ($rowsLanguage == 0) {
- drupal_get_messages();
- drupal_set_message("Log in with Freeway Credentials to avail Freeway language offerings!");
- drupal_goto('user');
- }
- else {
- foreach($resultLangsSrc as $recordLang )
- {
- $nodeSrc = $recordLang->freeway_lang_id;
- }
- }
- $resultLangsTar = db_query("SELECT freeway_lang_id FROM {freeway_language_map} where drupal_lang_id = '$tempTarLang '");
- $rowsLanguageTar = $resultLangsTar->rowCount();
- if ($rowsLanguageTar == 0) {
- drupal_get_messages();
- drupal_set_message("This Drupal language is unavailable for your Freeway account!");
- drupal_goto('user');
- }
- else {
- foreach($resultLangsTar as $recordLangTar )
- {
- $frewayLang = $recordLangTar->freeway_lang_id;
- }
- }
- if ($tempSrcLang == $tempTarLang) {
- $frewayLang = 'same';
- }
- $result = db_query("SELECT node_title,node_body FROM {freeway}
- WHERE node_id = '$tempId'
- AND src_lang ='$nodeSrc'
- AND tar_lang='$frewayLang'");
- $rowsUsPw = $result->rowCount();
- if($rowsUsPw != 0)
- {
- foreach ($result as $record) {
- foreach($node as $inner){
- $inner->body['und'][0]['safe_value']= $record->node_body.' Translated from Freeway';
- $inner->title = $record->node_title.' Translated from Freeway';
- }
- }
- }
- else if ($frewayLang!= 'same'){
- drupal_get_messages();
- drupal_set_message("The version of the content belonging to the chosen language is unavailable.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement