function build_item_category_chart_data($s_item_type) { $category_attribute_type = fetch_sfieldtype_item_attribute_type($s_item_type, 'CATEGORY'); if ($category_attribute_type) { $results = fetch_attribute_type_lookup_rs($category_attribute_type, 'order_no, value ASC'); if ($results) { while ($attribute_type_r = db_fetch_assoc($results)) { $num_total = fetch_category_item_cnt($attribute_type_r['value'], $s_item_type); if ($num_total > 0) { $data[] = array('display' => $attribute_type_r['display'], 'value' => $num_total); } } db_free_result($results); } } return $data; }
function display_lookup_attribute_type_form($HTTP_VARS) { global $PHP_SELF; global $ADMIN_TYPE; echo "<div class=\"tabContainer\"><form name=\"s_attribute_type_lookup\" action=\"{$PHP_SELF}\" method=\"POST\">" . "<input type=\"hidden\" name=\"type\" value=\"" . $ADMIN_TYPE . "\">" . "<input type=\"hidden\" name=\"op\" value=\"update-lookups\">" . "<input type=\"hidden\" name=\"s_attribute_type\" value=\"" . $HTTP_VARS['s_attribute_type'] . "\">" . "<input type=\"hidden\" name=\"active_tab\" value=\"" . $HTTP_VARS['active_tab'] . "\">"; $row = 0; $attribute_type_rows = NULL; $results = fetch_attribute_type_lookup_rs($HTTP_VARS['s_attribute_type'], 'order_no, value ASC', FALSE); if ($results) { // value, display, img, checked_ind, order_no while ($attribute_type_lookup_r = db_fetch_assoc($results)) { $attribute_type_rows[] = get_s_attribute_type_lookup_row($attribute_type_lookup_r, $row++); } db_free_result($results); } $emptyrows = 20 - count($attribute_type_rows) % 20; if ($emptyrows == 0) { $emptyrows = 20; } for ($i = 0; $i < $emptyrows; $i++) { $attribute_type_rows[] = get_s_attribute_type_lookup_row(array(), $row++); } $pageno = 1; $count = 0; echo "<ul class=\"tabMenu\" id=\"tab-menu\">"; for ($i = 0; $i < count($attribute_type_rows); $i++) { if ($count == 20) { $count = 0; $pageno++; } if ($count == 0) { echo "<li id=\"menu-pane{$pageno}\"" . ($pageno == 1 ? " class=\"first activetab\" " : "") . " onclick=\"return activateTab('pane{$pageno}')\">Page {$pageno}</li>"; } $count++; } echo "</ul>"; $pageno = 1; $count = 0; echo '<div id="tab-content"><ul class="saveButtons"> <li><input type="submit" class="submit" value="Update"></li> </ul>'; for ($i = 0; $i < count($attribute_type_rows); $i++) { if ($count == 20) { $count = 0; $pageno++; echo "</table></div>"; } if ($count == 0) { echo "<div id=\"pane{$pageno}\" class=\"" . ($pageno == 1 ? "tabContent" : "tabContentHidden") . "\">\n\t\t\t\t<table>\n\t\t\t\t<tr class=\"navbar\">\n\t\t\t\t<th>Delete</th>\n\t\t\t\t<th>Order</th>\n\t\t\t\t<th>Value</th>\n\t\t\t\t<th>Display</th>\n\t\t\t\t<th colspan=2>Image</th>\n\t\t\t\t<th>No Image</th>\n \t\t\t<th>Checked</th>\n\t\t\t\t</tr>"; } echo $attribute_type_rows[$i]; $count++; } echo "</table></div></div>"; echo "</form></div>"; }
function display_site_plugin_s_attribute_type_lookup_map_row($record_r, $row) { global $PHP_SELF; global $ADMIN_TYPE; if (is_not_empty_array($record_r)) { echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"Y\">"; echo "<input type=\"hidden\" name=\"sequence_number[{$row}]\" value=\"" . $record_r['sequence_number'] . "\">"; echo "<td class=\"data\">" . get_input_field("s_attribute_type[{$row}]", NULL, "Attribute Type", "readonly", "Y", $record_r['s_attribute_type'], FALSE) . "</td>"; echo "<td class=\"data\">" . get_input_field("value[{$row}]", NULL, "Site Value", "readonly", "Y", $record_r['value'], FALSE) . "</td>"; $results = fetch_attribute_type_lookup_rs($record_r['s_attribute_type'], 'order_no, value ASC'); echo "\n<td class=\"data\">" . custom_select("lookup_attribute_val[{$row}]", $results, "%value% - %display%", 1, $record_r['lookup_attribute_val']) . "</td>"; } else { echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"N\">"; $attribute_types[] = ''; $results = fetch_lookup_s_attribute_type_rs(); if ($results) { while ($attribute_type_r = db_fetch_assoc($results)) { $attribute_types[] = $attribute_type_r['s_attribute_type']; } db_free_result($results); } echo "\n<td class=\"data\">" . custom_select("s_attribute_type[{$row}]", $attribute_types, "%value%", 1, NULL, 'value', NULL, NULL, "populateList(this.options[this.options.selectedIndex].value, this.form['lookup_attribute_val[{$row}]'], arrayOfLookupValues, false, null, false);") . "</td>"; echo "<td class=\"data\">" . get_input_field("value[{$row}]", NULL, "Site Value", "text(20,100)", "Y", NULL, FALSE) . "</td>"; echo "\n<td class=\"data\">" . custom_select("lookup_attribute_val[{$row}]", array(array('value' => '', 'display' => '')), "%value% - %display%", 1, NULL) . "</td>"; } echo "\n<td class=\"data\">"; if (is_not_empty_array($record_r)) { echo "<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=delete_site_plugin_s_attribute_type_lookup_map&site_type=" . $record_r['site_type'] . "&sequence_number=" . $record_r['sequence_number'] . "\">Delete</a>"; } else { echo " "; } echo "\n</td>"; }
function get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value = NULL, $dowrap = TRUE, $prompt_mask = NULL, $onchange_event = NULL, $disabled = FALSE) { if (is_array($item_attribute_type_r)) { $s_attribute_type = $item_attribute_type_r['s_attribute_type']; $order_no = $item_attribute_type_r['order_no']; $prompt = $item_attribute_type_r['prompt']; $input_type = $item_attribute_type_r['input_type']; $compulsory_ind = $item_attribute_type_r['compulsory_ind']; $widget['type'] = $item_attribute_type_r['input_type']; $widget['args'][0] = $item_attribute_type_r['input_type_arg1']; $widget['args'][1] = $item_attribute_type_r['input_type_arg2']; $widget['args'][2] = $item_attribute_type_r['input_type_arg3']; $widget['args'][3] = $item_attribute_type_r['input_type_arg4']; $widget['args'][4] = $item_attribute_type_r['input_type_arg5']; } if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') { $multi_value = TRUE; if (!is_array($value)) { $old_value = ifempty($value, ""); unset($value); $value[] = $old_value; } } else { $multi_value = FALSE; // an array will be a lookup value if (!is_array($value)) { // Escape all html entities so they are displayed correctly! if (strlen($value) > 0) { $value = htmlspecialchars($value); } } } $field = NULL; $field_mask = NULL; // Now we have to work out how to parse the input_type if ($item_attribute_type_r['input_type'] == 'hidden') { return hidden_field($fieldname, $value); } else { if ($item_attribute_type_r['input_type'] == 'readonly') { $field = readonly_field($fieldname, $value); } else { if ($item_attribute_type_r['input_type'] == 'textarea' || $item_attribute_type_r['input_type'] == 'htmlarea') { // arg[0] = rows, arg[1] = cols, arg[2] = length $field = textarea_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['widget']['2'], $compulsory_ind, $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'text') { // arg[0] = length of field, arg[1] = maxlength of field $field = text_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'password') { // arg[0] = length of field, arg[1] = maxlength of field $field = password_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'email') { // arg[0] = length of field, arg[1] = maxlength of field $field = email_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'filtered') { // arg[0] = length of field, arg[1] = maxlength of field, arg[2] = legalChars $field = filtered_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'datetime') { // arg[0] = datetime mask, arg[1] = auto_datetime $field = datetime_field($fieldname, $prompt, ifempty($widget['args']['0'], 'DD/MM/YYYY'), $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'number') { // arg[0] = length of field, arg[0] = maxlength of field $field = number_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['0'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value); } else { if ($item_attribute_type_r['input_type'] == 'simple_checkbox') { // arg[0] = checked $field = checkbox_field($fieldname, $prompt, strcasecmp(trim($widget['args']['0']), 'CHECKED') === 0, $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'checkbox') { // arg[0] = checked, arg[1] = unchecked $field = enhanced_checkbox_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'checkbox_grid') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display_mask, arg[1] = orientation $field = checkbox_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'radio_grid') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display_mask, arg[1] = orientation $field = radio_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'value_radio_grid') { //arg[0] = "comma delimited list of values" $field = value_radio_grid($fieldname, explode(',', $widget['args']['0']), $value, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'single_select') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display mask, arg[1] = max value length $field = single_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'multi_select') { $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC'); if ($lookup_results) { //arg[0] = display mask, arg[1] = max value length, arg[2] = select box number of visible rows $field = multi_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'value_select') { //arg[0] = "comma delimited list of values"; arg[1] = number of visible rows (Defaults to single select $field = value_select($fieldname, explode(',', $widget['args']['0']), $widget['args']['1'], $value, $onchange_event, $disabled); } else { if ($item_attribute_type_r['input_type'] == 'review_options') { //arg[1] = display_mask, arg[1] = orientation $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'value DESC'); //We want the rows highest value first. if ($lookup_results) { $field = review_options($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled); } } else { if ($item_attribute_type_r['input_type'] == 'url') { //arg[0] = length of field, arg[1] = maxlength of field, arg[2] = extensions $field = url($fieldname, $item_r, $item_attribute_type_r, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled, $multi_value); } else { $field = ">>> ERROR (input_type = {$input_type}) <<<"; } } } } } } } } } } } } } } } } } } } if ($dowrap) { return format_item_data_field($item_attribute_type_r, $field, $prompt_mask); } else { return $field; } }
function queryItem($search_attributes_r, $s_item_type) { $page = $this->fetchURI('http://www.michaeldvd.com.au/Discs/Disc.asp?ID=' . $search_attributes_r['michaeldid']); if ($page) { // First translate things like into "real" characters. This // achieves the reverse of htmlentities(): $page = strtr($page, array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES))); // But is translated to a hard space, which trim() doesn't trim. // Work around that: $page = strtr($page, chr(160), ' '); // The image may not even exist! if (preg_match("#/CoverArt/" . $search_attributes_r['michaeldid'] . ".jpg#i", $page)) { $this->addItemAttribute('imageurl', 'http://www.michaeldvd.com.au/CoverArt/' . $search_attributes_r['michaeldid'] . '.jpg'); } else { if (preg_match("#/CoverArtUnverified/" . $search_attributes_r['michaeldid'] . ".jpg#i", $page)) { $this->addItemAttribute('imageurl', 'http://www.michaeldvd.com.au/CoverArtUnverified/' . $search_attributes_r['michaeldid'] . '.jpg'); } } if (preg_match('#<title.*?>(.*?)</title#is', $page, $matches)) { $title = strip_tags($matches[1]); if (preg_match("/(.*)\\(([0-9]+)\\)/", $title, $matches)) { $title = $matches[1]; $this->addItemAttribute('year', $matches[2]); } if (($idx = strpos($title, "(Blu-ray)")) !== FALSE) { $title = substr($title, 0, $idx); } $this->addItemAttribute('title', $title); } if (preg_match('#best version.*?best version.*?<td.*?>(.+?)</td#is', $page, $matches)) { $p = trim(strip_tags(str_replace('<br>', "\n", $matches[1]))); // No point in putting "undetermined" in the database. Leave it // blank so that a refresh can correct it later. If there is no difference, // do not provide option, as its annoying. if (strcasecmp($p, 'undetermined') !== 0 && strcasecmp($p, 'Same') !== 0) { $this->addItemAttribute('miker4r1', $p); } } if (preg_match('#<!.*?blurb.*?>(.*?)<!#is', $page, $matches)) { $p = trim(strip_tags($matches[1])); // If a blurb defined. if (strcasecmp($p, 'no blurb yet') !== 0) { $this->addItemAttribute('blurb', $p); } } if (preg_match('#http://www\\.imdb\\.com/title/tt([0-9]+)/#i', $page, $matches)) { $this->addItemAttribute('imdb_id', $matches[1]); } if (preg_match('#/Graphics/Ratings/(.+?).gif"#i', $page, $matches)) { $this->addItemAttribute('age_rating', strip_tags($matches[1])); } if (preg_match('#Starring/dir/music.*?</tr.*?<td.*?>(.*?)</td#is', $page, $matches)) { $block = strip_tags(str_replace('<br>', ',', $matches[1])); $this->addItemAttribute('actors', explode(",", $block)); } if (preg_match('#Director\\(s\\).*?</tr.*?<td.*?>(.*?)</td#is', $page, $matches)) { $block = strip_tags(str_replace('<br>', ',', $matches[1])); $this->addItemAttribute('director', explode(",", $block)); } if (preg_match('#<!--\\s*genre.*?<td[^>]*>(.*?)</td#is', $page, $matches)) { $this->addItemAttribute('genre', strtolower(trim(strip_tags($matches[1])))); } if (preg_match('#Movie release year.*?<td.*?>([0-9]*)</td#is', $page, $matches)) { $this->addItemAttribute('year', strip_tags($matches[1])); } if (preg_match('#<!--\\s*Running time.*?<td.*?>\\s*(\\d*).*?</td#is', $page, $matches)) { // OpenDb can only handle four-digit running times; MichaelD has minutes and seconds as "xxx:xx" $this->addItemAttribute('run_time', strip_tags($matches[1])); } if (preg_match('#<!--\\s*Region coding.*?<td.*?>(.*?)</td#is', $page, $matches)) { $this->addItemAttribute('dvd_region', explode(' ', strip_tags($matches[1]))); } if (preg_match('#<!--[\\s]*widescreen/full.*?<td.*?>(.*?)</td#is', $page, $matches)) { if (preg_match('#full\\s*frame#i', $matches[1])) { $this->addItemAttribute('ratio', '1.33'); } else { if (preg_match('#(\\d+(?:\\.\\d+)):1#', $matches[1], $submatches)) { $this->addItemAttribute('ratio', $submatches[1]); } } if (stristr($matches[1], '16x9 enhanced')) { $this->addItemAttribute('anamorphic', 'Y'); } } if (preg_match('#<!--\\s*audio parameters.*?<tr.*?audio.*?<tr.*?>(.*?)</tr#is', $page, $matches)) { $subresource = fetch_attribute_type_lookup_rs('AUDIO_LANG', NULL); while ($sub = db_fetch_assoc($subresource)) { if (preg_match('#' . $sub['value'] . '#i', $matches[1])) { $this->addItemAttribute('audio_lang', $sub['value']); } } if (preg_match('#english[^,]dolby digital 5\\.1#i', $matches[1])) { $this->addItemAttribute('audio_lang', 'ENGLISH_5.1'); } if (preg_match('#english dts#i', $matches[1])) { $this->addItemAttribute('audio_lang', 'ENGLISH_DTS'); } if (preg_match('#commentary#i', $matches[1])) { $this->addItemAttribute('audio_xtra', 'DIR_COMMENT'); } } if (preg_match('#<!--\\s*audio parameters.*?</tr.*?subtitles.*?</tr>.*?<tr.*?>(.*?)</tr#is', $page, $matches)) { $subtitles = strip_tags($matches[1]); $subresource = fetch_attribute_type_lookup_rs('SUBTITLES', NULL); while ($sub = db_fetch_assoc($subresource)) { if (preg_match('#' . $sub['value'] . '#i', $subtitles)) { $this->addItemAttribute('subtitles', $sub['value']); } } } if (preg_match('#<!--\\s*extras.*?</tr.*?<td.*?>(.*?)</td#is', $page, $matches)) { $this->addItemAttribute('dvd_extras', strip_tags(preg_replace('#\\s*,\\s*#', "\n", $matches[1]))); } // MichaelD puts the disc's year in parenthesis after the // title. OpenDb shifts articles to the end of the title, // after a comma, then optionally appends the year in item // listings. So "The Animatrix" becomes // "Animatrix (2003), The (2003)". // "Brazil" becomes "Brazil (1985) (1985)". // "Blues Brothers 2000 (2000) (2000)". See the problem? // // This block removes the year from the disc's title, provided // it is at the end and parenthesised. "Blues Brothers 2000" // should remain intact. ARD. if (strlen($this->getItemAttribute('title')) > 0 && is_numeric($this->getItemAttribute('year')) && preg_match('/\\(' . $this->getItemAttribute('year') . '\\)$/', $this->getItemAttribute('title'))) { $this->replaceItemAttribute('title', preg_replace('/\\s*\\(' . $this->getItemAttribute('year') . '\\)$/', '', $this->getItemAttribute('title'))); } // Attempt to include data from IMDB if available if (is_numeric($this->getItemAttribute('imdb_id'))) { $sitePlugin =& get_site_plugin_instance('imdb'); if ($sitePlugin !== FALSE) { if ($sitePlugin->queryItem(array('imdb_id' => $this->getItemAttribute('imdb_id')), $s_item_type)) { // no mapping process is performed here, as no $s_item_type was provided. $itemData = $sitePlugin->getItemData(); if (is_array($itemData)) { // merge data in here. while (list($key, $value) = each($itemData)) { if ($key == 'actors') { $this->replaceItemAttribute('actors', $value); } else { if ($key == 'director') { $this->replaceItemAttribute('director', $value); } else { if ($key == 'year') { $this->replaceItemAttribute('year', $value); } else { if ($key == 'actors') { $this->replaceItemAttribute('actors', $value); } else { if ($key == 'plot') { //have to map from imdb to michaeld attribute type. $this->addItemAttribute('blurb', $value); } else { if ($key != 'age_rating' && $key != 'run_time') { $this->addItemAttribute($key, $value); } } } } } } } } } } } return TRUE; } else { //if ($page) return FALSE; } }
/** */ function get_row_column_mappings_table($s_item_type, $owner_id, $header_row, $field_column_r, $field_default_r, $field_initcap_r) { $buffer = "\n<table>"; $buffer .= "\n<tr class=\"navbar\"><th></th>" . "<th>" . get_opendb_lang_var('field') . "</th>" . "<th>" . get_opendb_lang_var('default') . "</th>" . "<th> " . get_opendb_lang_var('initcap') . "</th></tr>"; // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r['s_item_type'])) { for ($i = 0; $i < count($header_row); $i++) { if ($header_row[$i] == 's_item_type' || $header_row[$i] == get_opendb_lang_var('s_item_type')) { $field_column_r['s_item_type'] = $i; break; } } } // If your data includes the item_type, then specify the column, so we // can ignore records that are not of the chosen item_type. $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . get_opendb_lang_var('s_item_type') . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[s_item_type]", $header_row, $field_column_r['s_item_type']) . "</td>" . "<td class=\"data defaultColumn\"> </td>" . "<td class=\"data initcapColumn\"> </td>" . "</tr>"; // --------- Now the main input fields start.... $results = fetch_item_attribute_type_rs($s_item_type); if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // purely readonly if ($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if ($item_attribute_type_r['s_field_type'] == 'STATUSTYPE') { $lookup_results = fetch_newitem_status_type_rs(); $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname], FALSE); // do not include 'None' option $initcap_field = NULL; // No initcap for these types of fields. } else { if ($item_attribute_type_r['input_type'] !== "textarea" && $item_attribute_type_r['input_type'] !== "url") { // Check if any lookup values for this field. $lookup_results = fetch_attribute_type_lookup_rs($item_attribute_type_r['s_attribute_type'], 'order_no, value ASC'); if ($lookup_results) { $default_field = build_select("field_default[{$fieldname}]", $lookup_results, $field_default_r[$fieldname]); $initcap_field = NULL; // No initcap for these types of fields. } else { //use normal input field. if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') { $item_attribute_type_r['multi_attribute_ind'] = 'N'; } $default_field = get_item_input_field("field_default[{$fieldname}]", $item_attribute_type_r, NULL, $field_default_r[$fieldname], FALSE); if ($item_attribute_type_r['input_type'] === 'text') { $initcap_field = get_input_field("field_initcap[{$fieldname}]", NULL, NULL, "checkbox(true,false,)", "N", ifempty($field_initcap_r[$fieldname], get_opendb_config_var('import', 'row_import_default_initcap_checked') ? "true" : "false"), FALSE); } else { //Only for text fields. $initcap_field = NULL; } } } else { $field = NULL; $default_field = NULL; $initcap_field = NULL; } } // If the prompt for this field, matches any of the $tokens, then select that token. if (!is_numeric($field_column_r[$fieldname])) { for ($i = 0; $i < count($header_row); $i++) { // A direct export from CSV Export, so lets match the columns for you. if ($header_row[$i] == $fieldname || $header_row[$i] == $item_attribute_type_r['prompt'] || $item_attribute_type_r['s_field_type'] == 'CATEGORY' && $header_row[$i] == 'Genre') { $field_column_r[$fieldname] = $i; break; } } } $buffer .= "\n<tr>" . "<th class=\"prompt\" scope=\"row\">" . $item_attribute_type_r['prompt'] . "</th>" . "<td class=\"data fieldColumn\">" . get_column_select_block("field_column[{$fieldname}]", $header_row, $field_column_r[$fieldname]) . "</td>" . "<td class=\"data defaultColumn\">" . $default_field . "</td>" . "<td class=\"data initcapColumn\">" . $initcap_field . "</td>" . "</tr>"; } //if($item_attribute_type_r['s_field_type'] !== 'ITEM_ID') } //while db_free_result($results); } //if($results) $buffer .= "\n</table>"; return $buffer; }
function encode_search_javascript_arrays(&$item_type_rs, &$arrayOfUniqueCategories, &$item_attribute_type_rs) { $buffer = ""; $arrayOfCategoryTypes = array(); $arrayOfUniqueAttributes = array(); $itemTypeBlock = ""; $attrTypeSelect = ""; $jsArrayOfAttributes = ""; $jsArrayOfAttributesCount = 0; $itemresults = fetch_item_type_rs(); while ($item_type_r = db_fetch_assoc($itemresults)) { $results = fetch_item_attribute_type_rs($item_type_r['s_item_type'], NULL, 'prompt'); // For the case where we have a s_item_type with no attributes associated with it! if ($results) { while ($item_attribute_type_r = db_fetch_assoc($results)) { // Do not include any attributes which do not exist as item attributes if ($item_attribute_type_r['s_field_type'] != 'TITLE' && $item_attribute_type_r['s_field_type'] != 'DURATION' && $item_attribute_type_r['s_field_type'] != 'STATUSTYPE' && $item_attribute_type_r['s_field_type'] != 'STATUSCMNT' && $item_attribute_type_r['s_field_type'] != 'ITEM_ID') { // Only unique attributes should be added to attribute options object. if (!is_array($arrayOfUniqueAttributes) || !in_array($item_attribute_type_r['s_attribute_type'], $arrayOfUniqueAttributes)) { // This array, is only so we can make sure that we have unique attributes only! $arrayOfUniqueAttributes[] = $item_attribute_type_r['s_attribute_type']; $jsArrayOfUniqueAttributes .= "\narrayOfAttributes[{$jsArrayOfAttributesCount}] = new LookupAttribute(\"\",\"" . $item_attribute_type_r['s_attribute_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . " - " . $item_attribute_type_r['description'] . "\");"; $item_attribute_type_rs[] = $item_attribute_type_r; } $jsArrayOfAttributes .= "\narrayOfAttributes[{$jsArrayOfAttributesCount}] = new LookupAttribute(\"" . $item_type_r['s_item_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . "\",\"" . $item_attribute_type_r['s_attribute_type'] . " - " . $item_attribute_type_r['description'] . "\");"; $jsArrayOfAttributesCount++; } } } // Get the category_attribute_type for this item_type $category_attribute_type = fetch_sfieldtype_item_attribute_type($item_type_r['s_item_type'], 'CATEGORY'); // We need this list further down, to work out which of the lookup items are actually categories. $arrayOfCategoryTypes[] = $category_attribute_type; $item_type_rs[] = $item_type_r; } // Give us the whole s_attribute_type_lookup table, whoo baby... $jsArrayOfLookupValues = ""; $jsArrayOfLookupValuesCount = 0; $attresults = fetch_attribute_type_lookup_rs(NULL, 's_attribute_type ASC'); while ($attribute_type_r = db_fetch_assoc($attresults)) { if ($attribute_type_r['s_field_type'] != 'ADDRESS' && $attribute_type_r['s_field_type'] != 'S_RATING') { if (in_array($attribute_type_r['s_attribute_type'], $arrayOfCategoryTypes) && (!is_array($arrayOfUniqueCategories) || !in_array($attribute_type_r['value'], $arrayOfUniqueCategories))) { $arrayOfUniqueCategories[$attribute_type_r['value']] = $attribute_type_r['display']; } $jsArrayOfLookupValues .= "\narrayOfLookupValues[{$jsArrayOfLookupValuesCount}] = new LookupAttribute(\"" . $attribute_type_r['s_attribute_type'] . "\",\"" . $attribute_type_r['value'] . "\",\"" . $attribute_type_r['display'] . "\");"; $jsArrayOfLookupValuesCount++; } } $buffer .= "\n\narrayOfLookupValues = new Array({$jsArrayOfLookupValuesCount});"; $buffer .= $jsArrayOfLookupValues; $buffer .= "\n\narrayOfAttributes = new Array({$jsArrayOfAttributesCount});"; $buffer .= $jsArrayOfAttributes; $arrayOfUniqueCategoryValues = ""; $arrayOfUniqueCatValuesCount = 0; // Now sort all values into alphabetical order! if (is_array($arrayOfUniqueCategories)) { asort($arrayOfUniqueCategories); reset($arrayOfUniqueCategories); while (list($value, $display) = each($arrayOfUniqueCategories)) { $arrayOfUniqueCatValues .= "\narrayOfUniqueCatValues[{$arrayOfUniqueCatValuesCount}] = new LookupAttribute('',\"{$value}\",\"{$display}\");"; $arrayOfUniqueCatValuesCount++; } } // Now wrap and return return "\n<script language=\"JavaScript\">\n<!-- // hide from stupid browsers\n" . $buffer . "\n// -->\n</script>\n"; }
/** * Generate a complete s_item_type script. * * Data generated: * s_item_type * s_attribute_type's (Those not included in $_ATTRIBUTE_TYPES['core']) * s_item_attribute_type's * s_item_attribute_type_lookup (Those not included in $_ATTRIBUTE_TYPES['core']) */ function generate_s_item_type_sql($s_item_type) { global $_CORE_ATTRIBUTE_TYPES; $CRLF = get_user_browser_crlf(); $s_item_type_r = fetch_s_item_type_r($s_item_type); if ($s_item_type_r !== FALSE) { $type_sql = $CRLF . '#' . $CRLF . '# Item Type' . $CRLF . '#' . $CRLF . 'INSERT INTO s_item_type ( s_item_type, description, image ) VALUES ( \'' . $s_item_type . '\', \'' . addslashes($s_item_type_r['description']) . '\', \'' . addslashes($s_item_type_r['image']) . '\' );' . $CRLF; $results = fetch_item_type_group_rlshp_rs(NULL, $s_item_type); if ($results) { $type_sql .= $CRLF . '#' . $CRLF . '# Item Type Group Relationships' . $CRLF . '#' . $CRLF; while ($item_type_group_rlshp_r = db_fetch_assoc($results)) { $type_sql .= 'INSERT INTO s_item_type_group_rltshp ( s_item_type_group, s_item_type ) VALUES ( \'' . $item_type_group_rlshp_r['s_item_type_group'] . '\', \'' . $item_type_group_rlshp_r['s_item_type'] . '\' );' . $CRLF; } db_fetch_assoc($results); } $attr_sql = ''; $item_attr_sql = $CRLF . '#' . $CRLF . '# Item Attribute Relationships' . $CRLF . '#'; $attr_lookup_sql = ''; $result = fetch_s_item_attribute_type_rs($s_item_type); if ($result) { $attr_added = array(); while ($s_item_attribute_type_r = db_fetch_assoc($result)) { // Ensure to also check that the attribute has not already been encountered, in case we have duplicates // in s_item_attribute_type structure (such as CDTRACK for instance) if (strlen($s_item_attribute_type_r['site_type']) == 0 && (!is_array($_CORE_ATTRIBUTE_TYPES) || !in_array($s_item_attribute_type_r['s_attribute_type'], $_CORE_ATTRIBUTE_TYPES)) && !in_array($s_item_attribute_type_r['s_attribute_type'], $attr_added)) { // Add s_attribute_type, so we do not insert it twice. $attr_added[] = $s_item_attribute_type_r['s_attribute_type']; $s_attribute_type_r = fetch_s_attribute_type_r($s_item_attribute_type_r['s_attribute_type']); $attr_sql .= $CRLF . "INSERT INTO s_attribute_type ( s_attribute_type, description, prompt, input_type, input_type_arg1, input_type_arg2, input_type_arg3, input_type_arg4, input_type_arg5, display_type, display_type_arg1, display_type_arg2, display_type_arg3, display_type_arg4, display_type_arg5, listing_link_ind, file_attribute_ind, lookup_attribute_ind, multi_attribute_ind, s_field_type, site_type ) " . "VALUES ( '" . $s_attribute_type_r['s_attribute_type'] . "', " . "'" . addslashes($s_attribute_type_r['description']) . "', " . "'" . addslashes($s_attribute_type_r['prompt']) . "', " . "'" . $s_attribute_type_r['input_type'] . "', " . (strlen($s_attribute_type_r['input_type_arg1']) > 0 ? "'" . addslashes($s_attribute_type_r['input_type_arg1']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['input_type_arg2']) > 0 ? "'" . addslashes($s_attribute_type_r['input_type_arg2']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['input_type_arg3']) > 0 ? "'" . addslashes($s_attribute_type_r['input_type_arg3']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['input_type_arg4']) > 0 ? "'" . addslashes($s_attribute_type_r['input_type_arg4']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['input_type_arg5']) > 0 ? "'" . addslashes($s_attribute_type_r['input_type_arg5']) . "'" : "NULL") . ", " . "'" . $s_attribute_type_r['display_type'] . "'," . (strlen($s_attribute_type_r['display_type_arg1']) > 0 ? "'" . addslashes($s_attribute_type_r['display_type_arg1']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['display_type_arg2']) > 0 ? "'" . addslashes($s_attribute_type_r['display_type_arg2']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['display_type_arg3']) > 0 ? "'" . addslashes($s_attribute_type_r['display_type_arg3']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['display_type_arg4']) > 0 ? "'" . addslashes($s_attribute_type_r['display_type_arg4']) . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['display_type_arg5']) > 0 ? "'" . addslashes($s_attribute_type_r['display_type_arg5']) . "'" : "NULL") . ", " . "'" . $s_attribute_type_r['listing_link_ind'] . "', " . "'" . $s_attribute_type_r['file_attribute_ind'] . "', " . "'" . $s_attribute_type_r['lookup_attribute_ind'] . "', " . "'" . $s_attribute_type_r['multi_attribute_ind'] . "', " . (strlen($s_attribute_type_r['s_field_type']) > 0 ? "'" . $s_attribute_type_r['s_field_type'] . "'" : "NULL") . ", " . (strlen($s_attribute_type_r['site_type']) > 0 ? "'" . $s_attribute_type_r['s_field_type'] . "'" : "NULL") . ");"; $result2 = fetch_attribute_type_lookup_rs($s_item_attribute_type_r['s_attribute_type'], 'value ASC', FALSE); if ($result2) { $attr_lookup_sql .= $CRLF . '#' . $CRLF . '# Attribute Type Lookup (' . $s_item_attribute_type_r['s_attribute_type'] . ')' . $CRLF . '#'; while ($s_attribute_type_lookup_r = db_fetch_assoc($result2)) { $attr_lookup_sql .= $CRLF . 'INSERT INTO s_attribute_type_lookup ( s_attribute_type, order_no, value, display, img, checked_ind ) VALUES ( \'' . $s_item_attribute_type_r['s_attribute_type'] . '\', ' . (is_numeric($s_attribute_type_lookup_r['order_no']) ? $s_attribute_type_lookup_r['order_no'] : 'NULL') . ', \'' . addslashes($s_attribute_type_lookup_r['value']) . '\', \'' . addslashes($s_attribute_type_lookup_r['display']) . '\', \'' . addslashes($s_attribute_type_lookup_r['img']) . '\', \'' . $s_attribute_type_lookup_r['checked_ind'] . '\' );'; } db_fetch_assoc($result2); $attr_lookup_sql .= $CRLF; } } $item_attr_sql .= $CRLF . 'INSERT INTO s_item_attribute_type ( s_item_type, s_attribute_type, order_no, prompt, instance_attribute_ind, compulsory_ind, printable_ind, rss_ind ) VALUES ( \'' . $s_item_type . '\', \'' . $s_item_attribute_type_r['s_attribute_type'] . '\', ' . $s_item_attribute_type_r['order_no'] . ', ' . (strlen($s_item_attribute_type_r['prompt']) > 0 ? '\'' . $s_item_attribute_type_r['prompt'] . '\'' : 'NULL') . ', \'' . $s_item_attribute_type_r['instance_attribute_ind'] . '\', \'' . $s_item_attribute_type_r['compulsory_ind'] . '\', \'' . $s_item_attribute_type_r['printable_ind'] . '\', \'' . $s_item_attribute_type_r['rss_ind'] . '\' );'; } db_fetch_assoc($result); } if (strlen($attr_sql) > 0) { $attr_sql = $CRLF . '#' . $CRLF . '# Attributes (non-core)' . $CRLF . '#' . $attr_sql; } $sqlscript = '#########################################################' . $CRLF . '# OpenDb ' . get_opendb_version() . ' \'' . $s_item_type . '\' Item Type' . $CRLF . '#########################################################' . $CRLF . $type_sql . $attr_sql . $CRLF . $item_attr_sql . $CRLF . $attr_lookup_sql; return $sqlscript; } else { return NULL; } }
/** * @param $borrowed_item_rs Items that this action will be performed against. It may actually * be an array of 'sequence_number' values, in which case the borrow * record for the sequence_number will be fetched. * @param $HTTP_VARS * */ function more_information_form($op, $borrowed_item_rs, $HTTP_VARS, $email_notification = TRUE) { global $PHP_SELF; $duration_attr_type = NULL; $default_borrow_duration = NULL; echo "\n<form action=\"{$PHP_SELF}\" method=\"POST\">"; // In case no detail is required. echo "\n<input type=\"hidden\" name=\"more_info_requested\" value=\"true\">"; // Pass all http variables onto next instance... // Includes empty fields... echo get_url_fields($HTTP_VARS, NULL, NULL); // Display the items to be operated on. if (is_not_empty_array($borrowed_item_rs)) { echo "<div id=\"moreInfoListing\">"; // no pagination. $HTTP_VARS['items_per_page'] = ''; $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS); $listingObject->setIncludeHrefLinks(TRUE); $listingObject->setIncludeFooter(FALSE); $listingObject->startListing(); $listingObject->addHeaderColumn(get_opendb_lang_var('type')); $listingObject->addHeaderColumn(get_opendb_lang_var('title')); if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') { $listingObject->addHeaderColumn(get_opendb_lang_var('owner')); } else { if ($op == 'check_in') { $listingObject->addHeaderColumn(get_opendb_lang_var('borrower')); } } if (get_opendb_config_var('borrow', 'duration_support')) { if ($op == 'check_out' || $op == 'quick_check_out') { $listingObject->addHeaderColumn(get_opendb_lang_var('borrow_duration')); } } //initialise $max_overdue_duration = NULL; $default_borrow_duration = NULL; reset($borrowed_item_rs); while (list(, $borrowed_item_r) = each($borrowed_item_rs)) { $listingObject->startRow(); // If only a sequence_number, we need to fetch the borrow record. if (!is_array($borrowed_item_r) && is_numeric($borrowed_item_r)) { $borrowed_item_r = fetch_borrowed_item_r($borrowed_item_r); } // TODO - add borrowed item history this to be displayed as readonly. //$results = fetch_borrowed_item_hist_rs($borrowed_item_r['sequence_number']); $item_r = fetch_item_instance_r($borrowed_item_r['item_id'], $borrowed_item_r['instance_no']); $listingObject->addItemTypeImageColumn($item_r['s_item_type']); $listingObject->addTitleColumn($item_r); if ($op == 'reserve' || $op == 'cancel_reserve' || $op == 'quick_check_out') { $listingObject->addUserNameColumn($item_r['owner_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number'])); } else { if ($op == 'check_in') { $listingObject->addUserNameColumn($borrowed_item_r['borrower_id'], array('bi_sequence_number' => $borrowed_item_r['sequence_number'])); } } if (get_opendb_config_var('borrow', 'duration_support')) { if ($op == 'check_out' || $op == 'quick_check_out') { if (is_numeric($item_r['borrow_duration'])) { // todo - change $duration_attr_type_r = fetch_sfieldtype_item_attribute_type_r($item_r['s_item_type'], 'DURATION'); $listingObject->addDisplayColumn($duration_attr_type_r['s_attribute_type'], NULL, $duration_attr_type_r['display_type'], $item_r['borrow_duration']); } else { $listingObject->addColumn(get_opendb_lang_var('undefined')); } } } // While we are here, we are going to calculate the default duration value. // We want to choose the least duration value. If any of the items use a // different s_attribute_type for duration, then we should not try to get // a default value. This is indicated by the $duration_attr_type===FALSE // if we have encountered a difference. if (get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type !== FALSE) { $new_duration_attr_type = fetch_sfieldtype_item_attribute_type($item_r['s_item_type'], 'DURATION'); if ($duration_attr_type == NULL) { $duration_attr_type = $new_duration_attr_type; } else { if ($duration_attr_type !== $new_duration_attr_type) { // Different s_attribute_type's for DURATION, so cannot display Duration chooser. $duration_attr_type = FALSE; } } if ($duration_attr_type !== FALSE) { if ($op == 'check_out' || $op == 'quick_check_out') { // The default borrow duration should be the least amount of days or undefined // if no records have a borrow duration. if ($default_borrow_duration === NULL) { $default_borrow_duration = $item_r['borrow_duration']; } else { if ($default_borrow_duration !== '') { // Undefined empty value. if (is_numeric($default_borrow_duration) && is_numeric($item_r['borrow_duration']) && $item_r['borrow_duration'] < $default_borrow_duration) { $default_borrow_duration = $item_r['borrow_duration']; } } } } else { if ($op == 'extension') { if ($borrowed_item_r['total_duration'] > $borrowed_item_r['borrow_duration']) { $tmp_overdue_duration = $borrowed_item_r['total_duration'] - $borrowed_item_r['borrow_duration']; } // We want to get the max overdue duration, so we can give the User granting the extension a // default, that will bring all selected items back into non-overdue status. if (!is_numeric($max_overdue_duration) || $max_overdue_duration < $tmp_overdue_duration) { $max_overdue_duration = $tmp_overdue_duration; } } } } } //if(get_opendb_config_var('borrow', 'duration_support') && $duration_attr_type!==FALSE) $listingObject->endRow(); } //while(list(,$borrowed_item_r) = each($borrowed_item_rs)) $listingObject->endListing(); echo "</div>"; } echo "<table class=\"moreInfo\">"; // Do not display this more information section unless email is enabled. if (is_valid_opendb_mailer() && $email_notification !== FALSE) { echo get_input_field("more_information", NULL, get_opendb_lang_var('more_information'), "textarea(50,10)", "N", NULL, TRUE); } // Include a Borrower ID select, minus the current user. if ($op == 'quick_check_out') { if (strlen($HTTP_VARS['borrower_id']) == 0 || !is_user_granted_permission(PERM_USER_BORROWER, $HTTP_VARS['borrower_id'])) { $current_user_mode = EXCLUDE_CURRENT_USER; if (get_opendb_config_var('borrow', 'owner_self_checkout') !== FALSE) { $current_user_mode = INCLUDE_CURRENT_USER; } $results = fetch_user_rs(PERM_USER_BORROWER, INCLUDE_ROLE_PERMISSIONS, $current_user_mode, EXCLUDE_DEACTIVATED_USER, 'fullname', 'ASC'); if ($results) { echo format_field(get_opendb_lang_var('borrower'), custom_select('borrower_id', $results, '%fullname% (%user_id%)', 1, NULL, 'user_id')); } else { echo format_field(get_opendb_lang_var('borrower'), get_opendb_lang_var('no_records_found')); } } } //Only for check_out/quick_check_out operations - makes no sense otherwise! if (get_opendb_config_var('borrow', 'duration_support') !== FALSE && ($op == 'check_out' || $op == 'quick_check_out' || $op == 'extension')) { // Display default borrow duration. if (strlen($duration_attr_type) > 0) { $duration_attr_type_r = fetch_attribute_type_r($duration_attr_type); // We have to find the matching DURATION lookup value, which is at least // as many days as the max_overdue value, or the highest possible // duration value, if none found as large as the $max_overdue_duration if ($op == 'extension') { $default_borrow_duration = NULL; $result = fetch_attribute_type_lookup_rs($duration_attr_type_r['s_attribute_type'], 'order_no, value ASC'); if ($result) { while ($lookup_r = db_fetch_assoc($result)) { if (is_numeric($lookup_r['value']) && (!is_numeric($max_overdue_duration) || is_numeric($max_overdue_duration) && $max_overdue_duration <= $lookup_r['value'])) { $default_borrow_duration = $lookup_r['value']; break; } // backup, in case we need to use outside while loop $lookup_r2 = $lookup_r; } db_free_result($result); // If still null, then set to the largest option if ($default_borrow_duration == NULL) { $default_borrow_duration = $lookup_r2['value']; } } } if ($op != 'extension' && strlen(get_opendb_lang_var('default_borrow_duration')) > 0 && is_array($borrowed_item_rs)) { $duration_attr_type_r['prompt'] = get_opendb_lang_var('default_borrow_duration'); } $duration_attr_type_r['compulsory_ind'] = 'N'; echo get_item_input_field("default_borrow_duration", $duration_attr_type_r, NULL, $op != 'quick_check_out' ? $default_borrow_duration : NULL); // Not appropriate for extension operation if ($op == 'check_out' || $op == 'quick_check_out') { echo get_input_field("override_item_duration", NULL, get_opendb_lang_var('override_item_duration'), "simple_checkbox(" . ($default_borrow_duration === NULL ? "CHECKED" : "") . ")", "N", "Y", TRUE); } } else { //otherwise tell checkout to use item_instance borrow duration instead. if ($op == 'check_out' || $op == 'quick_check_out') { echo "\n<input type=\"hidden\" name=\"override_item_duration\" value=\"N\">"; } } } echo "</table>"; echo "<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('submit') . "\">"; echo "</form>"; echo format_help_block(get_opendb_lang_var('more_information_help')); }