diff --git a/codepot/README b/codepot/README index 8fc0ff26..1dcf8455 100644 --- a/codepot/README +++ b/codepot/README @@ -7,6 +7,15 @@ CODEPOT multiple subversion repositories independent of each other. Going beyond it, you can track issues, write documents, and upload release files. +UPGRADING FROM 0.2.0 + + The code_hide_details column in the user_settings table has been renamed + to code_hide_metadata. You must rename your existing database manually. + + mysql> ALTER TABLE user_settings CHANGE code_hide_details code_hide_metadata char(1) NOT NULL; + oracle> ALTER TABLE user_settings RENAME COLUMN code_hide_details TO code_hide_metadata; + + INSTALLATION ON CENTOS A RPM package is provided for RedHat/CentOS Linux. The RPM package specifies diff --git a/codepot/etc/codepot.mysql b/codepot/etc/codepot.mysql index d199150a..f4d02cc4 100644 --- a/codepot/etc/codepot.mysql +++ b/codepot/etc/codepot.mysql @@ -192,7 +192,7 @@ CREATE TABLE log ( CREATE TABLE user_settings ( userid VARCHAR(32) PRIMARY KEY, code_hide_line_num CHAR(1) NOT NULL, - code_hide_details CHAR(1) NOT NULL, + code_hide_metadata CHAR(1) NOT NULL, icon_name VARCHAR(255) UNIQUE NULL ) charset=utf8 engine=InnoDB; diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index 3bbf8794..fd94d7bf 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -37,6 +37,7 @@ class Project extends Controller $search->id = ''; $search->name = ''; $search->summary = ''; + $search->or = ''; } else { @@ -44,6 +45,7 @@ class Project extends Controller if (!array_key_exists ('id', $search)) $search['id'] = ''; if (!array_key_exists ('name', $search)) $search['name'] = ''; if (!array_key_exists ('summary', $search)) $search['summary'] = ''; + if (!array_key_exists ('or', $search)) $search['or'] = ''; $search = (object) $search; } @@ -486,6 +488,7 @@ class Project extends Controller $search->id = ''; $search->name = ''; $search->summary = ''; + $search->or = ''; } else { @@ -493,6 +496,7 @@ class Project extends Controller if (!array_key_exists ('id', $search)) $search['id'] = ''; if (!array_key_exists ('name', $search)) $search['name'] = ''; if (!array_key_exists ('summary', $search)) $search['summary'] = ''; + if (!array_key_exists ('or', $search)) $search['or'] = ''; $search = (object) $search; } @@ -581,7 +585,8 @@ class Project extends Controller foreach ($projects as &$p) { - if ($p->id != $p->value) $p->value = $p->id . ' - ' . $p->value; + $p->label = ($p->id != $p->value)? ($p->id . ' - ' . $p->value): $p->value; + //$p->value = $p->id; } print codepot_json_encode ($projects); diff --git a/codepot/src/codepot/controllers/user.php b/codepot/src/codepot/controllers/user.php index 8c07e4fe..84e0bc10 100644 --- a/codepot/src/codepot/controllers/user.php +++ b/codepot/src/codepot/controllers/user.php @@ -200,7 +200,7 @@ class User extends Controller } $settings->code_hide_line_num = $this->input->post('code_hide_line_num'); - $settings->code_hide_details = $this->input->post('code_hide_details'); + $settings->code_hide_metadata = $this->input->post('code_hide_metadata'); $settings->icon_name = $icon_fname; $settings->uploaded_icon_name = $uploaded_fname; @@ -227,7 +227,7 @@ class User extends Controller { if ($settings === FALSE) $data['message'] = 'DATABASE ERROR'; $settings->code_hide_line_num = ' '; - $settings->code_hide_details = ' '; + $settings->code_hide_metadata = ' '; $settings->icon_name = ''; } diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 874b3dc8..031637d6 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -1,6 +1,7 @@ diff --git a/codepot/src/codepot/language/english/user_lang.php b/codepot/src/codepot/language/english/user_lang.php index a134b0f6..20f1c9f3 100644 --- a/codepot/src/codepot/language/english/user_lang.php +++ b/codepot/src/codepot/language/english/user_lang.php @@ -1,4 +1,4 @@ diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index a935fcff..1cec63b6 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -1,6 +1,7 @@ diff --git a/codepot/src/codepot/language/korean/user_lang.php b/codepot/src/codepot/language/korean/user_lang.php index f84f6d35..01d13db9 100644 --- a/codepot/src/codepot/language/korean/user_lang.php +++ b/codepot/src/codepot/language/korean/user_lang.php @@ -1,4 +1,4 @@ diff --git a/codepot/src/codepot/models/projectmodel.php b/codepot/src/codepot/models/projectmodel.php index a9ad2563..7fd21c1a 100644 --- a/codepot/src/codepot/models/projectmodel.php +++ b/codepot/src/codepot/models/projectmodel.php @@ -58,9 +58,19 @@ class ProjectModel extends Model $this->db->select ('count(id) as count'); $this->db->order_by ('name', 'asc'); - if (!empty($search->id)) $this->db->like ('id', $search->id); - if (!empty($search->name)) $this->db->like ('name', $search->name); - if (!empty($search->summary)) $this->db->like ('summary', $search->summary); + + if ($search->or == 'Y') + { + if (!empty($search->id)) $this->db->or_like ('id', $search->id); + if (!empty($search->name)) $this->db->or_like ('name', $search->name); + if (!empty($search->summary)) $this->db->or_like ('summary', $search->summary); + } + else + { + if (!empty($search->id)) $this->db->like ('id', $search->id); + if (!empty($search->name)) $this->db->like ('name', $search->name); + if (!empty($search->summary)) $this->db->like ('summary', $search->summary); + } $query = $this->db->get ('project'); if ($this->db->trans_status() === FALSE) @@ -83,9 +93,19 @@ class ProjectModel extends Model { $this->db->trans_start (); $this->db->order_by ('name', 'asc'); - if (!empty($search->id)) $this->db->like ('id', $search->id); - if (!empty($search->name)) $this->db->like ('name', $search->name); - if (!empty($search->summary)) $this->db->like ('summary', $search->summary); + + if ($search->or == 'Y') + { + if (!empty($search->id)) $this->db->or_like ('id', $search->id); + if (!empty($search->name)) $this->db->or_like ('name', $search->name); + if (!empty($search->summary)) $this->db->or_like ('summary', $search->summary); + } + else + { + if (!empty($search->id)) $this->db->like ('id', $search->id); + if (!empty($search->name)) $this->db->like ('name', $search->name); + if (!empty($search->summary)) $this->db->like ('summary', $search->summary); + } $query = $this->db->get ('project', $limit, $offset); $this->db->trans_complete (); if ($this->db->trans_status() === FALSE) return FALSE; @@ -332,8 +352,8 @@ class ProjectModel extends Model $this->db->set ('type', 'project'); $this->db->set ('action', 'delete'); $this->db->set ('projectid', $project->id); - $this->db->set ('userid', $userid); - $this->db->set ('message', $project->name); + $this->db->set ('userid', $userid); + $this->db->set ('message', $project->name); $this->db->insert ('log'); if ($this->db->trans_status() === FALSE) diff --git a/codepot/src/codepot/models/usermodel.php b/codepot/src/codepot/models/usermodel.php index 6798e951..c18247e2 100644 --- a/codepot/src/codepot/models/usermodel.php +++ b/codepot/src/codepot/models/usermodel.php @@ -53,7 +53,7 @@ class UserModel extends Model { $this->db->set ('userid', $userid); $this->db->set ('code_hide_line_num', (string)$settings->code_hide_line_num); - $this->db->set ('code_hide_details', (string)$settings->code_hide_details); + $this->db->set ('code_hide_metadata', (string)$settings->code_hide_metadata); if ($icon_name_set) $this->db->set ('icon_name', (string)$settings->icon_name); $this->db->insert ('user_settings'); } @@ -61,7 +61,7 @@ class UserModel extends Model { $this->db->where ('userid', $userid); $this->db->set ('code_hide_line_num', (string)$settings->code_hide_line_num); - $this->db->set ('code_hide_details', (string)$settings->code_hide_details); + $this->db->set ('code_hide_metadata', (string)$settings->code_hide_metadata); if ($icon_name_set) $this->db->set ('icon_name', (string)$settings->icon_name); $this->db->update ('user_settings'); } @@ -90,7 +90,7 @@ class UserModel extends Model $this->db->where ('userid', $userid); $this->db->set ('code_hide_line_num', (string)$settings->code_hide_line_num); - $this->db->set ('code_hide_details', (string)$settings->code_hide_details); + $this->db->set ('code_hide_metadata', (string)$settings->code_hide_metadata); if (strlen($icon_name_set) $this->db->set ('icon_name', (string)$settings->icon_name); $this->db->update ('user_settings'); @@ -104,7 +104,7 @@ class UserModel extends Model { $this->db->set ('userid', $userid); $this->db->set ('code_hide_line_num', (string)$settings->code_hide_line_num); - $this->db->set ('code_hide_details', (string)$settings->code_hide_details); + $this->db->set ('code_hide_metadata', (string)$settings->code_hide_metadata); $this->db->insert ('user_settings'); if ($this->db->trans_status() === FALSE) diff --git a/codepot/src/codepot/views/code_blame.php b/codepot/src/codepot/views/code_blame.php index 0285c2d8..2c53bca0 100644 --- a/codepot/src/codepot/views/code_blame.php +++ b/codepot/src/codepot/views/code_blame.php @@ -30,23 +30,23 @@ $(function () { ?> if ($("#code_blame_mainarea_result_info").is(":visible")) - btn_label = "lang->line('Hide details')?>"; + btn_label = "lang->line('Hide metadata')?>"; else - btn_label = "lang->line('Show details')?>"; + btn_label = "lang->line('Show metadata')?>"; - btn = $("#code_blame_mainarea_details_button").button({"label": btn_label}).click (function () { + btn = $("#code_blame_mainarea_metadata_button").button({"label": btn_label}).click (function () { if ($("#code_blame_mainarea_result_info").is(":visible")) { $("#code_blame_mainarea_result_info").hide("blind",{},200); - $("#code_blame_mainarea_details_button").button( - "option", "label", "lang->line('Show details')?>"); + $("#code_blame_mainarea_metadata_button").button( + "option", "label", "lang->line('Show metadata')?>"); } else { $("#code_blame_mainarea_result_info").show("blind",{},200); - $("#code_blame_mainarea_details_button").button( - "option", "label", "lang->line('Hide details')?>"); + $("#code_blame_mainarea_metadata_button").button( + "option", "label", "lang->line('Hide metadata')?>"); } }); @@ -189,7 +189,7 @@ print anchor ("code/fetch/{$project->id}/${xpar}{$revreq}", $this->lang->line('D print ' | '; printf ('%s: %s', $this->lang->line('Size'), $file['size']); ?> - lang->line('Details')?> + lang->line('Metadata')?>
diff --git a/codepot/src/codepot/views/code_file.php b/codepot/src/codepot/views/code_file.php index 5ef38030..e0fb9720 100644 --- a/codepot/src/codepot/views/code_file.php +++ b/codepot/src/codepot/views/code_file.php @@ -29,22 +29,22 @@ $(function () { ?> if ($("#code_file_mainarea_result_info").is(":visible")) - btn_label = "lang->line('Hide details')?>"; + btn_label = "lang->line('Hide metadata')?>"; else - btn_label = "lang->line('Show details')?>"; + btn_label = "lang->line('Show metadata')?>"; - btn = $("#code_file_mainarea_details_button").button({"label": btn_label}).click (function () { + btn = $("#code_file_mainarea_metadata_button").button({"label": btn_label}).click (function () { if ($("#code_file_mainarea_result_info").is(":visible")) { $("#code_file_mainarea_result_info").hide("blind",{},200); - $("#code_file_mainarea_details_button").button( - "option", "label", "lang->line('Show details')?>"); + $("#code_file_mainarea_metadata_button").button( + "option", "label", "lang->line('Show metadata')?>"); } else { $("#code_file_mainarea_result_info").show("blind",{},200); - $("#code_file_mainarea_details_button").button( - "option", "label", "lang->line('Hide details')?>"); + $("#code_file_mainarea_metadata_button").button( + "option", "label", "lang->line('Hide metadata')?>"); } }); @@ -226,7 +226,7 @@ $this->load->view ( print ' | '; printf ('%s: %s', $this->lang->line('Size'), $file['size']); ?> - lang->line('Details')?> + lang->line('Metadata')?>
diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index 3bf4d6fa..9957859d 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -168,23 +168,23 @@ $(function () { ?> if ($("#code_folder_mainarea_result_info").is(":visible")) - btn_label = "lang->line('Hide details')?>"; + btn_label = "lang->line('Hide metadata')?>"; else - btn_label = "lang->line('Show details')?>"; + btn_label = "lang->line('Show metadata')?>"; - btn = $("#code_folder_mainarea_details_button").button({"label": btn_label}).click (function () { + btn = $("#code_folder_mainarea_metadata_button").button({"label": btn_label}).click (function () { if ($("#code_folder_mainarea_result_info").is(":visible")) { $("#code_folder_mainarea_result_info").hide("blind",{},200); - $("#code_folder_mainarea_details_button").button( - "option", "label", "lang->line('Show details')?>"); + $("#code_folder_mainarea_metadata_button").button( + "option", "label", "lang->line('Show metadata')?>"); } else { $("#code_folder_mainarea_result_info").show("blind",{},200); - $("#code_folder_mainarea_details_button").button( - "option", "label", "lang->line('Hide details')?>"); + $("#code_folder_mainarea_metadata_button").button( + "option", "label", "lang->line('Hide metadata')?>"); } }); @@ -400,7 +400,7 @@ $this->load->view ( if ($file_count > 0) { print ' | '; - printf ('%s', $this->lang->line('Details')); + printf ('%s', $this->lang->line('Metadata')); } print form_close(); diff --git a/codepot/src/codepot/views/file_show.php b/codepot/src/codepot/views/file_show.php index 0754752e..32334620 100644 --- a/codepot/src/codepot/views/file_show.php +++ b/codepot/src/codepot/views/file_show.php @@ -35,24 +35,24 @@ function render_wiki() $(function () { if ($("#file_show_mainarea_result_info").is(":visible")) - btn_label = "lang->line('Hide details')?>"; + btn_label = "lang->line('Hide metadata')?>"; else - btn_label = "lang->line('Show details')?>"; + btn_label = "lang->line('Show metadata')?>"; - btn = $("#file_show_mainarea_details_button").button({"label": btn_label}).click (function () { + btn = $("#file_show_mainarea_metadata_button").button({"label": btn_label}).click (function () { if ($("#file_show_mainarea_result_info").is(":visible")) { $("#file_show_mainarea_result_info").hide("blind",{},200); - $("#file_show_mainarea_details_button").button( - "option", "label", "lang->line('Show details')?>"); + $("#file_show_mainarea_metadata_button").button( + "option", "label", "lang->line('Show metadata')?>"); } else { $("#file_show_mainarea_result_info").show("blind",{},200); - $("#file_show_mainarea_details_button").button( - "option", "label", "lang->line('Hide details')?>"); + $("#file_show_mainarea_metadata_button").button( + "option", "label", "lang->line('Hide metadata')?>"); } }); @@ -104,7 +104,7 @@ $this->load->view (
id}/". $this->converter->AsciiToHex($file->name), $this->lang->line('Download')) ?> - | lang->line('Details')?> + | lang->line('Metadata')?>
diff --git a/codepot/src/codepot/views/log.php b/codepot/src/codepot/views/log.php index c1eb6bba..40d15400 100644 --- a/codepot/src/codepot/views/log.php +++ b/codepot/src/codepot/views/log.php @@ -6,13 +6,13 @@ - - + + @@ -213,25 +199,19 @@ $this->load->view (
-
-lang->line('PROJECT_MSG_TOTAL_NUM_PROJECTS'), $total_num_projects); - print ' | '; - printf ('%s', $this->lang->line('Search')); -?> -
-
+
+ lang->line('Filter'); ?> + %d', $this->lang->line('PROJECT_MSG_TOTAL_PROJECTS'), $total_num_projects); ?> +
-
+
lang->line('ID'), 'id'); print ' '; print form_input('id', set_value('owner', $search->id), 'id="project_search_id"'); ?> -
-
lang->line('Name'), 'name'); print ' '; @@ -239,14 +219,22 @@ $this->load->view ( ?>
-
+
lang->line('Summary'), 'summary'); print ' '; print form_input('summary', set_value('summary', $search->summary), 'id="project_search_summary" size="50"'); ?> -
+ or), 'id="project_search_or"'); + ?> +
+ %s', $this->lang->line('Apply')); + ?>
@@ -262,7 +250,9 @@ else print '
    '; foreach ($projects as $project) { - $cap = "{$project->name} ({$project->id})"; + /* the formatting here must match the render_project_list() javascript function */ + if ($project->name == $project->id) $cap = $project->name; + else $cap = "{$project->name} ({$project->id})"; $anc = anchor ("project/home/{$project->id}", htmlspecialchars($cap)); $sum = htmlspecialchars ($project->summary); print "
  • {$anc} - {$sum}
  • "; diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index 9b6c8ef0..0bfcf873 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -155,7 +155,7 @@ foreach ($urls as $url)
    -id}", $this->lang->line('Change log')) ?> +id}", $this->lang->line('Change log')) ?>
    0) @@ -260,7 +260,7 @@ foreach ($urls as $url) print htmlspecialchars (sprintf($fmt, $log['userid'])); print ''; print ''; - + print ''; } } diff --git a/codepot/src/codepot/views/site_home.php b/codepot/src/codepot/views/site_home.php index ba49a393..e7e007d2 100644 --- a/codepot/src/codepot/views/site_home.php +++ b/codepot/src/codepot/views/site_home.php @@ -11,6 +11,13 @@ + + + + + + + @@ -19,11 +26,13 @@ function render_wiki() { creole_render_wiki ( - "site_home_mainarea_wiki_text", - "site_home_mainarea_wiki", + "site_home_mainarea_result_wiki_text", + "site_home_mainarea_result_wiki", "/site/wiki/", "/site/image/" ); + + prettyPrint (); } @@ -228,10 +237,12 @@ foreach ($latest_projects as $project)
    +
    + 0): ?> -
    +
    lang->line('Open issues')?>
    -
      +
        0): ?> -
        +
        lang->line('Recently resolved issues')?>
        -
          +
            - -
            -
        diff --git a/codepot/src/codepot/views/taskbar.php b/codepot/src/codepot/views/taskbar.php index 6cebb86e..0c8f52ad 100644 --- a/codepot/src/codepot/views/taskbar.php +++ b/codepot/src/codepot/views/taskbar.php @@ -157,6 +157,7 @@ $(function () { $("#taskbar_project_to_find").button().autocomplete({ minLength: 1, // is this too small? + delay: 1000, source: function (request, response) { var term = codepot_string_to_hex(request.term); diff --git a/codepot/src/codepot/views/user_settings.php b/codepot/src/codepot/views/user_settings.php index b168b960..3f0fe5ab 100644 --- a/codepot/src/codepot/views/user_settings.php +++ b/codepot/src/codepot/views/user_settings.php @@ -7,17 +7,9 @@ - - - <?php print htmlspecialchars($login['id'])?> @@ -70,10 +62,10 @@ $this->load->view ( ?> lang->line('USER_MSG_HIDE_LINE_NUMBER')?> - code_hide_details == 'Y') + code_hide_metadata == 'Y') ?> - lang->line('USER_MSG_HIDE_DETAILS')?> + lang->line('USER_MSG_HIDE_METADATA')?>
        lang->line('Icon').': ', 'icon_img_file_name')?> diff --git a/codepot/src/codepot/views/wiki_show.php b/codepot/src/codepot/views/wiki_show.php index 6d1c99b5..11a805ac 100644 --- a/codepot/src/codepot/views/wiki_show.php +++ b/codepot/src/codepot/views/wiki_show.php @@ -57,23 +57,23 @@ function render_wiki() $(function () { if ($("#wiki_show_mainarea_result_info").is(":visible")) - btn_label = "lang->line('Hide details')?>"; + btn_label = "lang->line('Hide metadata')?>"; else - btn_label = "lang->line('Show details')?>"; + btn_label = "lang->line('Show metadata')?>"; - btn = $("#wiki_show_mainarea_details_button").button({"label": btn_label}).click (function () { + btn = $("#wiki_show_mainarea_metadata_button").button({"label": btn_label}).click (function () { if ($("#wiki_show_mainarea_result_info").is(":visible")) { $("#wiki_show_mainarea_result_info").hide("blind",{},200); - $("#wiki_show_mainarea_details_button").button( - "option", "label", "lang->line('Show details')?>"); + $("#wiki_show_mainarea_metadata_button").button( + "option", "label", "lang->line('Show metadata')?>"); } else { $("#wiki_show_mainarea_result_info").show("blind",{},200); - $("#wiki_show_mainarea_details_button").button( - "option", "label", "lang->line('Hide details')?>"); + $("#wiki_show_mainarea_metadata_button").button( + "option", "label", "lang->line('Hide metadata')?>"); } }); @@ -120,7 +120,7 @@ $this->load->view (
        name)?>
        diff --git a/codepot/src/css/common.css b/codepot/src/css/common.css index c6949af6..c7cfb683 100644 --- a/codepot/src/css/common.css +++ b/codepot/src/css/common.css @@ -574,8 +574,6 @@ pre.prettyprint li.L9 { background: #eee } background: #E5ECF9 none repeat scroll 0 0; border: #D4DBE8 1px solid; - /*background: #DDDDDD none repeat scroll 0 0; - border: 1px solid #CCCCCC;*/ margin: 0.3em 0em 0em 0em; padding: 0.3em 0.3em 0.3em 0.3em; diff --git a/codepot/src/css/project.css b/codepot/src/css/project.css index 75d56283..2d567765 100644 --- a/codepot/src/css/project.css +++ b/codepot/src/css/project.css @@ -58,16 +58,41 @@ } #project_catalog_mainarea_result_list { - margin: 1em; + margin-left: 1em; + margin-right: 1em; + margin-top: 0; + margin-bottom: 0; padding: 1em; white-space: nowrap; line-height: 1.5em; } #project_catalog_mainarea_result_pages { - margin: 1em; + margin-left: 1em; + margin-right: 1em; + margin-top: 0.5em; + margin-bottom: 0.5em; } +#project_catalog_mainarea_search_form { + margin-top: 1em; +} + +#project_catalog_mainarea_search_form .ui-accordion-header { + /* trying to emulate infostrip with the header of a jquery-ui's accordion widget */ + background: #E5ECF9 none repeat scroll 0 0; + border: #D4DBE8 1px solid; +} + +#project_catalog_mainarea_search_form form { + line-height: 2.5em; +} + +#project_catalog_mainarea_total_projects_holder { + position: absolute; + right: 1em; + font-weight: normal; +} /*----------------------------------------------- * project source folder view *-----------------------------------------------*/ @@ -159,7 +184,7 @@ border: 0; margin: 0; font-size: 0.8em; - text-align: right; + text-align: right; } #project_code_blame_mainarea_result_info .title a { diff --git a/codepot/src/css/site.css b/codepot/src/css/site.css index 6ba09291..aada41ca 100644 --- a/codepot/src/css/site.css +++ b/codepot/src/css/site.css @@ -44,6 +44,23 @@ white-space: pre-wrap; } +#site_home_mainarea_result_open_issues_list { + margin-left: 1em; + margin-right: 1em; + margin-top: 0; + margin-bottom: 0; + padding: 1em; + line-height: 1.5em; +} + +#site_home_mainarea_result_resolved_issues_list { + margin-left: 1em; + margin-right: 1em; + margin-top: 0; + margin-bottom: 0; + padding: 1em; + line-height: 1.5em; +} /*----------------------------------------------- * site show view *-----------------------------------------------*/ diff --git a/codepot/src/js/Makefile.in b/codepot/src/js/Makefile.in index f32a883a..548953e8 100644 --- a/codepot/src/js/Makefile.in +++ b/codepot/src/js/Makefile.in @@ -240,6 +240,7 @@ top_srcdir = @top_srcdir@ wwwdir = $(WWWDIR)/js SUBDIRS = prettify www_DATA = \ + codepot.js \ creole.js \ jquery.min.js \ jquery-ui.min.js \ diff --git a/codepot/src/js/codepot.js b/codepot/src/js/codepot.js index 579820fc..16f92925 100644 --- a/codepot/src/js/codepot.js +++ b/codepot/src/js/codepot.js @@ -312,6 +312,76 @@ function codepot_sprintf() { return format.replace(regex, doFormat); } + +function codepot_htmlspecialchars(string, quote_style, charset, double_encode) { + // discuss at: http://phpjs.org/functions/htmlspecialchars/ + // original by: Mirek Slugen + // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // bugfixed by: Nathan + // bugfixed by: Arno + // bugfixed by: Brett Zamir (http://brett-zamir.me) + // bugfixed by: Brett Zamir (http://brett-zamir.me) + // revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // input by: Ratheous + // input by: Mailfaker (http://www.weedem.fr/) + // input by: felix + // reimplemented by: Brett Zamir (http://brett-zamir.me) + // note: charset argument not supported + // example 1: htmlspecialchars("Test", 'ENT_QUOTES'); + // returns 1: '<a href='test'>Test</a>' + // example 2: htmlspecialchars("ab\"c'd", ['ENT_NOQUOTES', 'ENT_QUOTES']); + // returns 2: 'ab"c'd' + // example 3: htmlspecialchars('my "&entity;" is still here', null, null, false); + // returns 3: 'my "&entity;" is still here' + + var optTemp = 0, + i = 0, + noquotes = false; + if (typeof quote_style === 'undefined' || quote_style === null) { + quote_style = 2; + } + string = string.toString(); + if (double_encode !== false) { + // Put this first to avoid double-encoding + string = string.replace(/&/g, '&'); + } + string = string.replace(//g, '>'); + + var OPTS = { + 'ENT_NOQUOTES': 0, + 'ENT_HTML_QUOTE_SINGLE': 1, + 'ENT_HTML_QUOTE_DOUBLE': 2, + 'ENT_COMPAT': 2, + 'ENT_QUOTES': 3, + 'ENT_IGNORE': 4 + }; + if (quote_style === 0) { + noquotes = true; + } + if (typeof quote_style !== 'number') { + // Allow for a single string or an array of string flags + quote_style = [].concat(quote_style); + for (i = 0; i < quote_style.length; i++) { + // Resolve string input to bitwise e.g. 'ENT_IGNORE' becomes 4 + if (OPTS[quote_style[i]] === 0) { + noquotes = true; + } else if (OPTS[quote_style[i]]) { + optTemp = optTemp | OPTS[quote_style[i]]; + } + } + quote_style = optTemp; + } + if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) { + string = string.replace(/'/g, '''); + } + if (!noquotes) { + string = string.replace(/"/g, '"'); + } + + return string; +} + function codepot_ascii_to_hex (x) { var r="";