} if ($book->pageList) { $last_page = end($book->pageList); $last_page = $last_page['sort_order']; } else { $last_page = 0; } $book_id = $book->bookID; $marker_type_list = $db->get('marker_type', null, 'id,title'); $marker_type_list = rekey_array($marker_type_list, 'id'); /***** * Actions */ if ($_POST) { // What’s in the import folder? $import_top_list = $fileops->get_dir_list($import_path); if ($import_top_list) { foreach ($import_top_list as $key => $val) { if (is_dir($import_path . '/' . $val)) { $folder_list[$val] = $import_path . '/' . $val; } else { $file_list[$val] = $import_path . '/' . $val; } } } // Build a list of each folder and its contents. if ($folder_list) { foreach ($folder_list as $key => $val) { $file_list = $fileops->get_dir_list($val); if ($file_list && count($file_list) > 0) { $master_folder_list[$key] = $file_list = $fileops->get_dir_list($val);
function image_weight_test($root_folder, $root_list, $image_status_list) { $link = new GrlxLinkStyle(); $fileops = new GrlxFileOps(); $allowed_extension = array('gif', 'png', 'jpg', 'svg'); $overall_status = 0; if ($root_list) { foreach ($root_list as $key => $val) { $folder_list[$root_folder . '/' . $val] = $fileops->get_dir_list($root_folder . '/' . $val); } } if ($folder_list) { foreach ($folder_list as $folder => $set) { if ($set) { foreach ($set as $filename) { $ext = substr($filename, -3, 3); if (in_array($ext, $allowed_extension)) { $image_info = getimagesize($folder . '/' . $filename); $image_bytes = filesize($folder . '/' . $filename); $result = figure_pixel_weight($image_info[0], $image_info[1], $image_bytes); $short = round($result, 3); $status = interpret_image_weight($result); if ($status > $overall_status) { $overall_status = $status; } $pad = $result * 1000; $status = $image_status_list[$status]; if (strlen($filename) > 20) { $abbr = substr($filename, 0, 15) . '…'; } else { $abbr = $filename; } $image_bytes = number_format($image_bytes); $link->url = "{$folder}/{$filename}"; $link->tap = $abbr; $this_link = $link->paint(); $output .= <<<EOL <p> \t<span style="background:{$status['0']};padding-right:{$pad}px;"> </span><br/><strong>{$short} bytes / pixel</strong> <small>({$image_bytes} b / {$image_info['0']} × {$image_info['1']} px)</small> {$this_link} </p> EOL; } } } } } return array($output, $overall_status); }
} // ! Build sets of “new” fields if ($manifest) { for ($i = $number + 2; $i <= $number + $limit + 1; $i++) { foreach ($manifest as $type) { $f = 'build_' . $type . '_field'; if (function_exists($f)) { $new_output .= build_quick_label($number, 'New ' . $label_list[$type], $type); $new_output .= $f($i); } } } } // Next we want to find all patterns that seem to match this page’s XML format. // Heck, just get ’em all to start. $pattern_option_list = $fileops->get_dir_list('../' . DIR_PATTERNS); // Now go through them and remove those that do *not* match the page’s XML format. if ($pattern_option_list && $xml_format) { foreach ($pattern_option_list as $id => $filename) { // The first part of a pattern file’s name is its XML format (a.k.a. “HILT” combo). Compare that // to the page’s XML format. $this_pattern = explode('.', $filename); if ($this_pattern[0] != $xml_format) { unset($pattern_option_list[$id]); } } } $form->row_class('widelabel'); // If anything’s left over, loop through and make radio buttons // to let the artist choose among the appropriate pattern files. if ($pattern_option_list && $static_xml) {