{"id":233,"date":"2008-11-10T04:13:27","date_gmt":"2008-11-10T08:13:27","guid":{"rendered":"http:\/\/itp.indiamos.com\/blog\/?p=233"},"modified":"2013-12-07T22:42:01","modified_gmt":"2013-12-08T03:42:01","slug":"phphun","status":"publish","type":"post","link":"https:\/\/itp.indiamos.com\/blog\/2008\/11\/10\/phphun\/","title":{"rendered":"PHPhun"},"content":{"rendered":"<p><a href=\"http:\/\/www.flickr.com\/photos\/ooocha\/2844442207\/\"><img loading=\"lazy\" src=\"https:\/\/i1.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/2008\/11\/auto-setter.jpg?resize=450%2C134\" alt=\"\" title=\"Auto Setter\" width=\"450\" height=\"134\" class=\"alignnone size-full wp-image-234\" srcset=\"https:\/\/i1.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/auto-setter.jpg?w=450&amp;ssl=1 450w, https:\/\/i1.wp.com\/itp.indiamos.com\/blog\/wp-content\/uploads\/auto-setter.jpg?resize=400%2C119&amp;ssl=1 400w\" sizes=\"(max-width: 450px) 100vw, 450px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<p>I completely spaced the ICM homework last week, which is sad, because it involved a language I actually have some experience with: PHP. I know just enough about it to fiddle with WordPress templates&mdash;and once, in 2002 or so, I spent a few days trying to rebuild the ColdFusion-backed poets.org in PHP, just for kicks.<\/p>\n<p>Yeah, I didn&#x0092;t get very far with that, <!--more-->but it&#x0092;s the thought that counts.<\/p>\n<p>Last week&#x0092;s assignment was to <\/p>\n<blockquote><p>Using HTML and PHP, create a page which contains a form for some kind of (census, survey?) data collection and a second page which tallies up and displays the results (perhaps use Processing for visualizing the results<\/p><\/blockquote>\n<p>Easy peasy. I mean, not that this is stuff I can do off the top of my head&mdash;HTML forms are one of the many things I rarely have occasion to create from scratch, so I&#x0092;ve never gotten enough practice at it to not have to look up the syntax for every single type of control&mdash;but it&#x0092;s certainly stuff I&#x0092;ve done dozens of times. So on Friday, while I was waiting for it to be time to go to a party, I started putting together a little cast-off calculator.<\/p>\n<p><i>Casting off<\/i>, for those who do not work in publishing, is the process of figuring out how long a typeset book will be, based on its typed or word-processed manuscript. It can be surprisingly accurate, when one has reliable character-per-pica (CPP) charts with which to estimate the volume of the typeset page. This problem is, of course, that there are a zillion factors that can affect the CPP. Which font are you using&mdash;that is, which typeface, and in which size? You have to be very specific about this. Just saying &#8220;Garamond 9&#8221; won&#x0092;t do; you need to know <em>which<\/em> Garamond&mdash;Adobe? Postscript or OpenType (or metal, or photoset)? The old Adobe Garamond, or the new Adobe Garamond Premier Pro? What typesetting program are you using&mdash;InDesign CS3, Quark XPress 4.11, PageMaker 6 Win, Pages? LaTeX? What <acronym title=\"hyphenation and justification settings\">H&#038;J<\/acronym>s are you using? Does the text use a lot of italics? Blah, blah, blah.<\/p>\n<p>So, this calculator is actually pretty useless, because the CPP figures for my various font options are pulled from a couple of sources, none of them good. Somewhere I have a real list of CPPs from Westchester, a major U.S. typesetter, which I know are reliable . . . for the conditions under which Westchester was setting books for me at the time: Quark XPress 4 or 5, PostScript fonts, fixed H&#038;Js, etc. Somewhere I also have a more detailed, and therefore accurate, cast-off formula that takes into account the number of chapters and parts a book has, and how much front or back matter there is. Maybe later I&#x0092;ll update this code to reflect those real-life samples. For now, though, it gives you the basic gist: you plug in some numbers, you get some numbers back.<\/p>\n<p>The input form&mdash;adapted from an example in the <cite><a href=\"http:\/\/www.chicagomanualofstyle.org\/\">Chicago Manual of Style<\/a><\/cite> (Fig. A.4)&mdash;is okay, but the output page is quite nasty so far. Not sure what&#x0092;s the best way to present all that information, so for now I&#x0092;ve just left it where the PHP flang it.<\/p>\n<p>Try it out: <a href=\" http:\/\/itp.indiamos.com\/ICM\/week9\/castoff.html\">Cast-off Calculator<\/a><\/p>\n<p>The PHP portion is as follows:<\/p>\n<p><code>&lt;?php<br \/>\n\t\t\t$chars_per_line = $_GET['chars_per_line'];<br \/>\n \t\t\t$lines_per_page = $_GET['lines_per_page'];<br \/>\n\t\t\t$ms_page_count = $_GET['ms_page_count'];<br \/>\n            $total_ms_chars = $chars_per_line * $lines_per_page * $ms_page_count;<\/p>\n<p>\t\t\tlist($font, $cpp) = split(\";\", $_GET['typeface'], 2);<br \/>\n\t\t\t$measure = $_GET['measure'];<br \/>\n\t\t\t$depth = $_GET['depth'];<br \/>\n            $total_page_chars = $cpp * $measure * $depth;<br \/>\n            $chars_tight = round($total_page_chars * .9);<br \/>\n            $chars_loose = round($total_page_chars * 1.10);<\/p>\n<p>            $castoff = round($total_ms_chars \/ $total_page_chars);<br \/>\n            $pages_tight = round($castoff * .9);<br \/>\n            $pages_loose = round($castoff * 1.10);<\/p>\n<p>\t\t\techo \"&lt;p>&lt;b>Characters per line:&lt;\/b> \" . $chars_per_line . \"&lt;br \/><br \/>\n\t\t\t&amp;times;&lt;br \/><br \/>\n\t\t\t&lt;b>Lines per page:&lt;\/b> \" . $lines_per_page . \"&lt;br \/><br \/>\n\t\t\t&amp;times;&lt;br \/><br \/>\n\t\t\t&lt;b>Number of manuscript pages:&lt;\/b> \" . $ms_page_count . \"&lt;br \/><br \/>\n\t\t\t=&lt;br \/><br \/>\n\t\t\t\" . number_format($total_ms_chars) . \" total characters in manuscript&lt;\/p><br \/>\n\t\t\t&lt;p>&lt;b>Font:&lt;\/b> \" . $font . \"&lt;br \/><br \/>\n\t\t\t&lt;b>Characters per pica:&lt;\/b> \" . $cpp . \"&lt;br \/><br \/>\n\t\t\t&amp;times;&lt;br \/>&lt;b>Picas per line:&lt;\/b> \" . $measure . \"&lt;br \/><br \/>\n\t\t\t&amp;times;&lt;br \/><br \/>\n\t\t\t&lt;b>Lines per typeset page:&lt;\/b> \" . $depth . \"&lt;br \/><br \/>\n\t\t\t=&lt;br \/><br \/>\n\t\t\t\" . number_format($total_page_chars) . \" total characters per typeset page&lt;br \/><br \/>\n\t\t\t&lt;b>Tight:&lt;\/b> \" . number_format($chars_tight) . \"&lt;br \/><br \/>\n\t\t\t&lt;b>Loose:&lt;\/b> \" . number_format($chars_loose) . \"&lt;\/p><br \/>\n\t\t\t&lt;p>Characters in manuscript &divide; characters per typeset page =&lt;br \/><br \/>\n\t\t\t&lt;b>Normal:&lt;\/b> \" .  number_format($castoff) . \" pages &amp;#8594; \" . floor($castoff \/ 8) . \" &amp;times; 8 + \" . bcmod($castoff, '8') . \" pages&lt;br \/><br \/>\n\t\t\t&lt;b>Tight:&lt;\/b> \" . number_format($pages_tight) . \" pages &amp;#8594; \" . floor($pages_tight \/ 8) . \" &amp;times; 8 + \" . bcmod($pages_tight, '8') . \" pages&lt;br \/><br \/>\n\t\t\t&lt;b>Loose:&lt;\/b> \" . number_format($pages_loose) . \" pages &amp;#8594; \" . floor($pages_loose \/ 8) . \" &amp;times; 8 + \" . bcmod($pages_loose, '8') . \" pages&lt;\/p>\";<\/p>\n<p>?><\/code><br \/>\n<span style=\"font-size:smaller;color:#666;\">Photo: <a href=\"http:\/\/www.flickr.com\/photos\/ooocha\/2844442207\/\">Auto Setter<\/a> by Marion Doss; <a href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/2.0\/deed.en\">some rights reserved<\/a>.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I completely spaced the ICM homework last week, which is sad, because it involved a language I actually have some experience with: PHP. I know just enough about it to fiddle with WordPress templates&mdash;and once, in 2002 or so, I spent a few days trying to rebuild the ColdFusion-backed poets.org in PHP, just for kicks. &hellip; <a href=\"https:\/\/itp.indiamos.com\/blog\/2008\/11\/10\/phphun\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">PHPhun<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[4,3,22],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/s3qY10-phphun","_links":{"self":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/233"}],"collection":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/comments?post=233"}],"version-history":[{"count":15,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/233\/revisions"}],"predecessor-version":[{"id":893,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/posts\/233\/revisions\/893"}],"wp:attachment":[{"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/media?parent=233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/categories?post=233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itp.indiamos.com\/blog\/wp-json\/wp\/v2\/tags?post=233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}