Beispiel #1
0
/**
 * Get list of staff contextual actions.
 *
 * @return string		The list
 */
function get_staff_actions_list()
{
    require_lang('lang');
    $list = array('view' => do_lang_tempcode('SCREEN_DEV_TOOLS'));
    $list += array('spacer_1' => do_lang_tempcode('THEME'), 'show_edit_links' => do_lang_tempcode('TEMPLATES_WITH_EDIT_LINKS'), 'show_markers' => do_lang_tempcode('TEMPLATES_WITH_HTML_COMMENT_MARKERS'), 'tree' => do_lang_tempcode('TEMPLATE_TREE'), 'templates' => do_lang_tempcode('TEMPLATES'), 'theme_images' => do_lang_tempcode('THEME_IMAGE_EDITING'), 'code' => do_lang_tempcode('VALIDATION'), 'site_tree' => do_lang_tempcode('FIND_IN_SITE_TREE'));
    require_code('lang2');
    $list += array('spacer_2' => do_lang_tempcode('LANGUAGE'));
    $all_langs = multi_lang() ? find_all_langs() : array(user_lang() => 'lang_custom');
    $tcode = do_lang('lang:TRANSLATE_CODE');
    foreach (array_keys($all_langs) as $lang) {
        $list += array('lang_' . $lang => $tcode . (count($all_langs) == 1 ? '' : ': ' . lookup_language_full_name($lang)));
    }
    if (multi_lang()) {
        $tcontent = do_lang('TRANSLATE_CONTENT');
        foreach (array_keys($all_langs) as $lang) {
            $list['lang_content_' . $lang] = $tcontent . ': ' . lookup_language_full_name($lang);
        }
    }
    $list += array('spacer_3' => do_lang_tempcode('DEVELOPMENT_VIEWS'), 'query' => do_lang_tempcode('VIEW_PAGE_QUERIES'), 'ide_linkage' => do_lang_tempcode('IDE_LINKAGE'));
    if (function_exists('xdebug_enable')) {
        $list['profile'] = do_lang_tempcode('PROFILING');
    }
    if (function_exists('memory_get_usage')) {
        $list['memory'] = do_lang_tempcode('_MEMORY_USAGE');
    }
    $special_page_type = get_param('special_page_type', 'view');
    $staff_actions = '';
    foreach ($list as $name => $text) {
        $disabled = $name[0] == 's' && substr($name, 0, 7) == 'spacer_';
        $staff_actions .= '<option ' . ($disabled ? 'disabled="disabled" ' : '') . ($name == $special_page_type ? 'selected="selected" ' : '') . 'value="' . escape_html($name) . '">' . (is_object($text) ? $text->evaluate() : escape_html($text)) . '</option>';
        // XHTMLXHTML
        //$staff_actions.=static_evaluate_tempcode(form_input_list_entry($name,($name==$special_page_type),$text,false,$disabled));
    }
    return $staff_actions;
}
Beispiel #2
0
 /**
  * Standard modular UI to edit an entry.
  *
  * @return tempcode	The UI
  */
 function _ed()
 {
     $doing = 'EDIT_' . $this->lang_type;
     if ($this->catalogue && get_param('catalogue_name', '') != '') {
         $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name'))));
         if ($this->type_code == 'd') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title));
         } elseif ($this->type_code == 'c') {
             $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title));
         }
     }
     $title = get_page_title($doing);
     //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing);
     //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name;
     $submit_name = do_lang_tempcode('SAVE');
     //$test=$this->choose_catalogue($title);
     //if (!is_null($test)) return $test;
     $id = mixed();
     // Define type as mixed
     $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id'));
     $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id);
     if (get_param('catalogue_name', '') != '') {
         $map['catalogue_name'] = get_param('catalogue_name');
     }
     if (!is_null(get_param('redirect', NULL))) {
         $map['redirect'] = get_param('redirect');
     }
     if (!is_null(get_param('continue', NULL))) {
         $map['continue'] = get_param('continue');
     }
     if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) {
         $map['uploading'] = 1;
     }
     $post_url = build_url($map, '_SELF');
     if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) {
         require_code('lang2');
         $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang()));
         attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn');
     }
     if (method_exists($this, 'get_submitter')) {
         list($submitter, $date_and_time) = $this->get_submitter($id);
     } else {
         $submitter = NULL;
         $date_and_time = NULL;
     }
     if (!is_null($this->permissions_require)) {
         check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name);
     }
     if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) {
         access_denied('CATEGORY_ACCESS');
     }
     $bits = $this->fill_in_edit_form($id);
     $delete_fields = new ocp_tempcode();
     $all_delete_fields_given = false;
     $fields2 = new ocp_tempcode();
     if (is_array($bits)) {
         $fields = $bits[0];
         $hidden = $bits[1];
         if (array_key_exists(2, $bits) && !is_null($bits[2])) {
             $delete_fields = $bits[2];
         }
         if (array_key_exists(3, $bits) && !is_null($bits[3])) {
             $this->edit_text = $bits[3];
         }
         if (array_key_exists(4, $bits) && $bits[4]) {
             $all_delete_fields_given = true;
         }
         if (array_key_exists(5, $bits) && !is_null($bits[5])) {
             $this->posting_form_text = $bits[5];
         }
         if (array_key_exists(6, $bits) && !is_null($bits[6])) {
             $fields2 = $bits[6];
         }
         if (array_key_exists(7, $bits)) {
             $this->posting_form_text_parsed = $bits[7];
         }
     } else {
         $fields = $bits;
         $hidden = new ocp_tempcode();
     }
     // Add in custom fields
     if ($this->has_tied_catalogue()) {
         require_code('fields');
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE'))));
         append_form_custom_fields($this->award_type, $id, $fields, $hidden);
     }
     // SEO?
     if (!is_null($this->seo_type)) {
         require_code('seo2');
         $fields2->attach(seo_get_fields($this->seo_type, $id));
     }
     // Awards?
     if (addon_installed('awards')) {
         if (!is_null($this->award_type)) {
             require_code('awards');
             $fields2->attach(get_award_fields($this->award_type, $id));
         }
     }
     // Action fields / deletion options
     $delete_permission = true;
     if (!is_null($this->permissions_require)) {
         $delete_permission = has_delete_permission($this->permissions_require, get_member(), $submitter, is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)));
     }
     $may_delete = (!method_exists($this, 'may_delete_this') || $this->may_delete_this($id)) && (!is_numeric($id) || intval($id) >= db_get_first_id() + $this->protect_first) && $delete_permission;
     // Deletion options
     $action_fields = new ocp_tempcode();
     if ($may_delete) {
         if (!$all_delete_fields_given) {
             $action_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
         }
         if (addon_installed('points') && !is_null($submitter) && !is_null($date_and_time)) {
             $points_test = $GLOBALS['SITE_DB']->query_value_null_ok('gifts', 'id', array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id()));
             if (!is_null($points_test)) {
                 require_lang('points');
                 $action_fields->attach(form_input_tick(do_lang_tempcode('REVERSE_TITLE'), do_lang_tempcode('REVERSE_TITLE_DESCRIPTION'), 'reverse_point_transaction', false));
             }
         }
         $action_fields->attach($delete_fields);
     }
     if (!$this->appended_actions_already && !$action_fields->is_empty()) {
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
     }
     $fields2->attach($action_fields);
     if (!is_object($this->edit_text)) {
         $this->edit_text = make_string_tempcode(is_null($this->edit_text) ? '' : $this->edit_text);
     }
     if (!is_null($this->upload)) {
         if ($this->upload == 'image') {
             require_code('images');
             $max = floatval(get_max_image_size()) / floatval(1024 * 1024);
             if ($max < 3.0) {
                 require_code('files2');
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         } else {
             require_code('files2');
             $max = floatval(get_max_file_size()) / floatval(1024 * 1024);
             if ($max < 30.0) {
                 $config_url = get_upload_limit_config_url();
                 $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url))));
             }
         }
     }
     if (get_param('type', '_ed') == '_edit_catalogue') {
         require_javascript('javascript_catalogues');
         // Existing fields
         $field_count = 0;
         $c_name = get_param('id', false, true);
         $rows = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $c_name), 'ORDER BY cf_order');
         $fields_existing = new ocp_tempcode();
         foreach ($rows as $i => $myrow) {
             $name = get_translated_text($myrow['cf_name']);
             $description = get_translated_text($myrow['cf_description']);
             $prefix = 'existing_field_' . strval($myrow['id']) . '_';
             list($_fields_existing, $_fields_hidden) = $this->get_field_fields($i == 0 && substr($c_name, 0, 1) != '_', count($rows) + 10, $prefix, $field_count, $name, $description, $myrow['cf_type'], $myrow['cf_defines_order'], $myrow['cf_visible'], $myrow['cf_searchable'], $myrow['cf_default'], $myrow['cf_required'], $myrow['cf_put_in_category'], $myrow['cf_put_in_search']);
             if (!is_ecommerce_catalogue($c_name) || $i > 9) {
                 $_fields_existing->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
                 $_fields_existing->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), $prefix . 'delete', false));
             }
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '1492d973db45cbecff892ad4ac1af28f' . get_class($this), 'NAME' => $name, 'ID' => 'FIELD_' . strval($i + 1), 'FIELDS' => $_fields_existing->evaluate()));
             $fields_existing->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         // New field
         $fields_new = new ocp_tempcode();
         for ($i = 0; $i < 5; $i++) {
             list($_fields_new, $_fields_hidden) = $this->get_field_fields(false, count($rows) + 10, 'new_field_' . strval($i) . '_', $field_count);
             $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '8b9a632eafae003ccc6b007eefb0ce3d' . get_class($this), 'NAME' => do_lang_tempcode('NEW_FIELD', strval($i + 1)), 'ID' => 'NEW_FIELD_' . strval($i + 1), 'FIELDS' => $_fields_new->evaluate()));
             $fields_new->attach($temp);
             $hidden->attach($_fields_hidden);
             $field_count++;
         }
         $fields->attach($fields2);
         return do_template('CATALOGUE_EDITING_SCREEN', array('_GUID' => '584d7dc7c2c13939626102374f13f508' . get_class($this), 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $this->add_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'FIELDS_EXISTING' => $fields_existing->evaluate(), 'FIELDS_NEW' => $fields_new->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
     list($warning_details, $ping_url) = handle_conflict_resolution();
     if (!is_null($this->posting_form_title)) {
         $posting_form = get_posting_form($submit_name, $this->posting_form_text, $post_url, $hidden, $fields, $this->posting_form_title, '', $fields2, $this->posting_form_text_parsed, $this->javascript, NULL, $this->posting_field_required);
         return do_template('POSTING_SCREEN', array('_GUID' => '841b9af3aa80bcab86b907e4b942786a' . get_class($this), 'PREVIEW' => $this->do_preview, 'TITLE' => $title, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $this->add_text, 'POSTING_FORM' => $posting_form->evaluate(), 'JAVASCRIPT' => $this->javascript));
     } else {
         $fields->attach($fields2);
         return do_template('FORM_SCREEN', array('_GUID' => '2d70be34595a16c6f170d966b894bfe2' . get_class($this), 'PREVIEW' => $this->do_preview, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'TITLE' => $title, 'SKIP_VALIDATION' => $this->skip_validation, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => $hidden, 'TEXT' => $this->edit_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript));
     }
 }
Beispiel #3
0
 /**
  * The UI to translate content.
  *
  * @return tempcode		The UI
  */
 function interface_content()
 {
     $title = get_page_title('TRANSLATE_CONTENT');
     if (!multi_lang()) {
         warn_exit(do_lang_tempcode('MULTILANG_OFF'));
     }
     $max = get_param_integer('max', 100);
     $lang = choose_language($title);
     if (is_object($lang)) {
         return $lang;
     }
     // Fiddle around in order to find what we haven't translated. Subqueries and self joins don't work well enough across different db's
     if (!db_has_subqueries($GLOBALS['SITE_DB']->connection_read)) {
         $_done_id_list = collapse_2d_complexity('id', 'text_original', $GLOBALS['SITE_DB']->query_select('translate', array('id', 'text_original'), array('language' => $lang, 'broken' => 0)));
         $done_id_list = '';
         foreach (array_keys($_done_id_list) as $done_id) {
             if ($done_id_list != '') {
                 $done_id_list .= ',';
             }
             $done_id_list .= strval($done_id);
         }
         $and_clause = $done_id_list == '' ? '' : 'AND id NOT IN (' . $done_id_list . ')';
         $query = 'FROM ' . get_table_prefix() . 'translate WHERE ' . db_string_not_equal_to('language', $lang) . ' ' . $and_clause . ' AND ' . db_string_not_equal_to('text_original', '') . ' ORDER BY importance_level';
         $to_translate = $GLOBALS['SITE_DB']->query('SELECT * ' . $query, $max);
     } else {
         $query = 'FROM ' . get_table_prefix() . 'translate a LEFT JOIN ' . get_table_prefix() . 'translate b ON a.id=b.id AND b.broken=0 AND ' . db_string_equal_to('b.language', $lang) . ' WHERE b.id IS NULL AND ' . db_string_not_equal_to('a.language', $lang) . ' AND ' . db_string_not_equal_to('a.text_original', '');
         $to_translate = $GLOBALS['SITE_DB']->query('SELECT a.* ' . $query . (can_arbitrary_groupby() ? ' GROUP BY a.id' : '') . ' ORDER BY a.importance_level', $max);
     }
     $total = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) ' . $query);
     if (count($to_translate) == 0) {
         inform_exit(do_lang_tempcode('NOTHING_TO_TRANSLATE'));
     }
     require_all_lang($lang, true);
     require_all_open_lang_files($lang);
     // Make our translation page
     require_code('lang2');
     $lines = '';
     $intertrans = $this->get_intertran_conv($lang);
     $actions = make_string_tempcode('&nbsp;');
     $last_level = NULL;
     $too_many = count($to_translate) == $max;
     $ids_to_lookup = array();
     foreach ($to_translate as $it) {
         $ids_to_lookup[] = $it['id'];
     }
     $names = find_lang_content_names($ids_to_lookup);
     foreach ($to_translate as $i => $it) {
         if ($it['importance_level'] == 0) {
             continue;
         }
         // Corrupt data
         $id = $it['id'];
         $old = $it['text_original'];
         $current = $this->find_lang_matches($old, $lang);
         $priority = $last_level === $it['importance_level'] ? NULL : do_lang('PRIORITY_' . strval($it['importance_level']));
         $name = $names[$id];
         if (is_null($name)) {
             continue;
         }
         // Orphaned string
         if ($intertrans != '') {
             $actions = do_template('TRANSLATE_ACTION', array('_GUID' => 'f625cf15c9db5e5af30fc772a7f0d5ff', 'LANG_FROM' => $it['language'], 'LANG_TO' => $lang, 'NAME' => 'trans_' . strval($id), 'OLD' => $old));
         }
         $line = do_template('TRANSLATE_LINE_CONTENT', array('_GUID' => '87a0f5298ce9532839f3206cd0e06051', 'NAME' => $name, 'ID' => strval($id), 'OLD' => $old, 'CURRENT' => $current, 'ACTIONS' => $actions, 'PRIORITY' => $priority));
         $lines .= $line->evaluate();
         /*XHTMLXHTML*/
         $last_level = $it['importance_level'];
     }
     $url = build_url(array('page' => '_SELF', 'type' => '_content', 'lang' => $lang), '_SELF');
     require_code('lang2');
     return do_template('TRANSLATE_SCREEN_CONTENT_SCREEN', array('_GUID' => 'af732c5e595816db1c6f025c4b8fa6a2', 'MAX' => integer_format($max), 'TOTAL' => integer_format($total - $max), 'LANG_ORIGINAL_NAME' => get_site_default_lang(), 'LANG_NICE_ORIGINAL_NAME' => lookup_language_full_name(get_site_default_lang()), 'LANG_NICE_NAME' => lookup_language_full_name($lang), 'TOO_MANY' => $too_many, 'INTERTRANS' => $intertrans, 'LANG' => $lang, 'LINES' => $lines, 'TITLE' => $title, 'URL' => $url));
 }