protected function get_input_lis() { $input_lis = array(); $visible_fields = $this->get_visible_fields(); $row_renderer = $this->row->get_renderer(); foreach ($visible_fields as $visible_field) { $input_li = new HTMLTags_LI(); $l_t_l_o_ws = Formatting_ListOfWordsHelper::get_list_of_words_for_string($visible_field->get_name(), '_'); $label_text = $l_t_l_o_ws->get_words_as_capitalised_string(); $input_label = new HTMLTags_Label($label_text); $input_label->set_attribute_str('for', $visible_field->get_name()); #$input_label->set_attribute_str('id', $name); $input_li->append_tag_to_content($input_label); #$field_renderer = $visible_field->get_renderer(); # #$input_tag = $field_renderer->get_form_input(); # #echo '$visible_field->get_name(): ' . $visible_field->get_name() . "\n"; # #$input_tag->set_value( # $this->row->get($visible_field->get_name()) #); $input_tag = $row_renderer->get_input_tag_for_field($visible_field); $input_li->append_tag_to_content($input_tag); $input_lis[] = $input_li; } return $input_lis; }
public static function get_module_name(HaddockProjectOrganisation_ModuleDirectory $module_directory) { /* * Does the module have name file? */ $name_file_name = self::get_name_file_name($module_directory); if (is_file($name_file_name)) { return trim(file_get_contents($name_file_name)); } /* * Does this module have a module config file? */ if ($module_directory->has_module_config_file()) { $module_config_file = $module_directory->get_module_config_file(); if ($module_config_file->has_module_name()) { return $module_config_file->get_module_name(); } } /* * There isn't a module name set in the file, * so we should work out the name algorithmically. */ if (preg_match('{([^\\\\/]+)$}', $module_directory->get_name(), $matches)) { $c_c_m_n_l_o_ws = Formatting_ListOfWordsHelper::get_list_of_words_for_string($matches[1], '-'); return $c_c_m_n_l_o_ws->get_words_as_capitalised_string(); } return ''; }
protected function get_input_lis() { $input_lis = array(); $visible_fields = $this->get_visible_fields(); foreach ($visible_fields as $visible_field) { if ($visible_field->get_name() != 'id') { $input_li = new HTMLTags_LI(); $l_t_l_o_ws = Formatting_ListOfWordsHelper::get_list_of_words_for_string($visible_field->get_name(), '_'); $label_text = $l_t_l_o_ws->get_words_as_capitalised_string(); $input_label = new HTMLTags_Label($label_text); $input_label->set_attribute_str('for', $visible_field->get_name()); #$input_label->set_attribute_str('id', $visible_field->get_name()); $input_li->append_tag_to_content($input_label); $field_renderer = $visible_field->get_renderer(); $input_tag = $field_renderer->get_form_input(); #print_r($visible_field); if ($visible_field->has_default()) { $input_tag->set_value($visible_field->get_default()); } $input_li->append_tag_to_content($input_tag); $input_lis[] = $input_li; } } return $input_lis; }
public function add_input_tag($name, HTMLTags_InputTag $input_tag, $label_text = NULL, $post_content = NULL) { #echo "In HTMLTags_SimpleOLForm::add_input_tag(...)\n"; $input_li = new HTMLTags_LI(); if (!isset($label_text)) { $l_t_l_o_ws = Formatting_ListOfWordsHelper::get_list_of_words_for_string($name, '_'); $label_text = $l_t_l_o_ws->get_words_as_capitalised_string(); # echo "\$label_text: $label_text\n"; #} else { # echo "\$label_text: $label_text\n"; } #echo "After if\n"; $input_label = new HTMLTags_Label($label_text); $input_label->set_attribute_str('for', $name); #$input_label->set_attribute_str('id', $name); $input_li->append_tag_to_content($input_label); $input_li->append_tag_to_content($input_tag); if (isset($post_content)) { #print_r($post_content); $input_li->append($post_content); #} else { # echo "No post_content!\n"; } $input_msg_box = new HTMLTags_Span(); $input_msg_box->set_attribute_str('id', $name . 'msg'); $input_msg_box->set_attribute_str('class', 'rules'); $input_li->append_tag_to_content($input_msg_box); if (count($this->input_lis) == 0) { $this->first_input_name = $name; } $this->input_lis[] = $input_li; }
public function get_module_name_as_l_o_w() { $module_name_as_l_o_w = null; if (preg_match('{([^\\\\/]+)$}', $this->get_name(), $matches)) { $module_name_as_l_o_w = Formatting_ListOfWordsHelper::get_list_of_words_for_string($matches[1], '-'); } return $module_name_as_l_o_w; }
public function append_nonsortable_field_name($field_name, $title = NULL) { $th = new HTMLTags_TH(); if (!isset($title)) { $f_n_l_o_ws = Formatting_ListOfWordsHelper::get_list_of_words_for_string($field_name, '_'); $title = $f_n_l_o_ws->get_words_as_capitalised_string(); } $th->append_str_to_content($title); $this->append_tag_to_content($th); }
public function get_camel_case_root() { $project_title = ''; $project_tag = $this->get_project_tag(); if ($project_tag->hasAttribute('camel_case_root')) { $project_title = $project_tag->getAttribute('camel_case_root'); } else { $project_name = $this->get_project_name(); $pn_low = Formatting_ListOfWordsHelper::get_list_of_words_for_string($project_name, '-'); $project_title = $pn_low->get_words_as_camel_case_string(); } return $project_title; }
/** * Makes links to other DB pages. */ public static function replace_double_square_brackets_with_link_to_db_page($in) { #echo "\$in: \n\n$in\n"; #$out = $in; #$out = ''; # #$lines = Strings_Splitter::line_separated($in); # #foreach ($lines as $line) { # if ($line) # # $out .= "$line\n"; #} # #return $out; /* * Split the string on all the square bracket links. */ $parts = preg_split('/(?:(?<!\\\\)|(?<=\\\\\\\\))(\\[\\[[-\\w]+(?:\\|[- \\w\'".\\/]+)?\\]\\])/', $in, -1, PREG_SPLIT_DELIM_CAPTURE); #echo "\nParts: \n\n"; # #print_r($parts); /* * Make the appropriate stings into links. */ $out = ''; foreach ($parts as $part) { if (preg_match('/^\\[\\[([-\\w]+)(?:\\|([- \\w\'".\\/]+))?\\]\\]$/', $part, $matches)) { #print_r($matches); $page_name = $matches[1]; if (isset($matches[2])) { $title = $matches[2]; } else { $title = Formatting_ListOfWordsHelper::capitalise_delimited_string($page_name, '-'); } $page_url = DPPages_URLsHelper::get_db_page_url($page_name); #$out .= "<a href=\"/db-pages/$page_name.html\">$title</a>"; $out .= '<a href="' . $page_url->get_as_string() . "\">{$title}</a>"; } else { #echo "\$part: $part\n"; /* * Remove any back slashes that were used to escape any * brackets. */ $part = preg_replace('/(?<!\\\\)\\\\(?=\\[\\[)/', '', $part); $out .= $part; } } #echo "$out\n"; return $out; }
public function get_managed_object_name_plural() { $table_name = $this->get_table_name(); #echo $table_name; if (preg_match('/^(?:ps_|hpi_|hci_)(\\w+)/', $table_name, $matches)) { #echo "Match\n"; # #print_r($matches); $table_name = $matches[1]; } else { echo "No match!\n"; } $c = Formatting_ListOfWordsHelper::capitalise_delimited_string($table_name, '_'); #echo $c; #exit; return $c; }
protected function render_form_li_textarea($name, $value = NULL, $title = NULL, $cols = 50, $rows = 20) { #echo $value; exit; if (!isset($title)) { $title = Formatting_ListOfWordsHelper::capitalise_delimited_string($name, '_'); } ?> <li> <label for="page"><?php echo $title; ?> </label> <textarea name="<?php echo $name; ?> " id="<?php echo $name; ?> " cols="<?php echo $cols; ?> " rows="<?php echo $rows; ?> " ><?php if (isset($value)) { $value = stripcslashes($value); echo $value; } ?> </textarea> <span id="<?php echo $name; ?> msg" class="rules" ></span> </li> <?php }
public static function get_camel_case_root() { #$config_file = self::get_project_specific_config_file(); #return $config_file->get_project_title(); $camel_case_root_file_name = self::get_camel_case_root_file_name(); if (is_file($camel_case_root_file_name)) { return trim(file_get_contents($camel_case_root_file_name)); } else { $name = self::get_name(); $name_low = Formatting_ListOfWordsHelper::get_list_of_words_for_string($name, '-'); return $name_low->get_words_as_camel_case_string(); } }
public function get_display_field_titles() { $display_field_titles = array(); foreach ($this->get_display_fields() as $df) { if (isset($df['title'])) { $display_field_titles[] = $df['title']; } else { $display_field_titles[] = Formatting_ListOfWordsHelper::capitalise_delimited_string($df['name'], '_'); } } return $display_field_titles; }
/** * Renders an array of assocs in a table. * * @param array $array_of_assocs The array of assocs to render. * @param array $title_overrides Optional assoc of titles to override the default capitalisation. */ public static function render_array_of_assocs_in_table($array_of_assocs, $title_overrides = NULL) { if (count($array_of_assocs) > 0) { /* * Make the titles. */ $titles = array(); foreach (array_keys($array_of_assocs[0]) as $key) { $titles[$key] = Formatting_ListOfWordsHelper::capitalise_delimited_string($key, '_'); } /* * Has the user overridden one of the titles? */ if (isset($title_overrides)) { foreach (array_keys($title_overrides) as $key) { $titles[$key] = $title_overrides[$key]; } } /* * Make the columns the correct width. */ $column_widths = array(); foreach (array_keys($titles) as $key) { $column_widths[$key] = strlen($titles[$key]); foreach ($array_of_assocs as $assoc) { $field_width = strlen($assoc[$key]); $column_widths[$key] = $column_widths[$key] > $field_width ? $column_widths[$key] : $field_width; } } /* * Put the titles together. */ $title_str = '|'; foreach (array_keys($titles) as $key) { $title_str .= str_pad($titles[$key], $column_widths[$key], ' ', STR_PAD_BOTH); $title_str .= '|'; } /* * Make a horizontal rule to separate the titles from the data. */ $hr = str_repeat('-', strlen($title_str) - 2); $title_str = $title_str . PHP_EOL; #$hr = "|$hr|" . PHP_EOL; $hr = "+{$hr}+" . PHP_EOL; echo $hr; echo $title_str; echo $hr; /* * Render the data. */ foreach ($array_of_assocs as $assoc) { echo '|'; foreach (array_keys($assoc) as $key) { echo str_pad($assoc[$key], $column_widths[$key], ' ', STR_PAD_BOTH); echo '|'; } echo PHP_EOL; } echo $hr; } }
public function get_title() { if (isset($this->title)) { return $this->title; } if ($this->has_page_config_file()) { $page_config_file = $this->get_page_config_file(); if ($page_config_file->has_page_title()) { return $page_config_file->get_page_title(); } } /** * Work out the title from the link. */ $title_as_l_o_w = Formatting_ListOfWordsHelper::get_list_of_words_for_string($this->get_page_name(), '-'); return $title_as_l_o_w->get_words_as_capitalised_string(); }
public function get_title_for_page_in_module_in_section($page, $module, $section) { $page_element = $this->get_page_element_in_module_in_section($page, $module, $section); $title = ''; if ($page_element->hasAttribute('title')) { $title = $page_element->getAttribute('title'); } else { $ptlow = Formatting_ListOfWordsHelper::get_list_of_words_for_string($page_element->getAttribute('name'), $separator = '-'); $title = $ptlow->get_words_as_capitalised_string(); } return $title; }
protected function get_form_li_text_input($name, $value = NULL, $title = NULL) { if (!isset($title)) { $title = Formatting_ListOfWordsHelper::capitalise_delimited_string($name, '_'); } $html = <<<HTML <li> \t<label for="{$name}">{$title}</label> \t<input \t\ttype="text" \t\tname="{$name}" \t\tid="{$name}" HTML; if (isset($value)) { $html .= "value=\"{$value}\""; } $html .= <<<HTML \t/> </li> HTML; return $html; }
public static function get_action_th($action_str) { $title_low = Formatting_ListOfWordsHelper::get_list_of_words_for_string($action_str); return new HTMLTags_TH($title_low->get_words_as_capitalised_string()); }
public function get_module_name_as_l_o_w() { #$project_directory = $this->get_project_directory(); #$project_name = $project_directory->get_current_project_name(); #$p_n_l_o_ws = Formatting_ListOfWords::get_list_of_words_for_string($project_name, '-'); # #return $p_n_l_o_ws; #$hpo_cm # = Configuration_ConfigManagerHelper # ::get_config_manager( # 'haddock', # 'haddock-project-organisation' # ); # #$project_name = $hpo_cm->get_project_name(); $project_name = HaddockProjectOrganisation_ProjectInformationHelper::get_name(); return Formatting_ListOfWordsHelper::get_list_of_words_for_string($project_name, '-'); }