\\n\";\n\n $query = \"SELECT id, term, definition FROM glossary WHERE id='\".$_GET['id'].\"'\";\n $result = mysql_query($query) or die(mysql_error());\n\n while ( $line = mysql_fetch_array($result)) {\n $results['term'] = $line['term'];\n $results['definition'] = $line['definition'];\n }\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n }\n else\n {\n not_admin();\n }\n\n break;\n ###############################################\n case \"show_tree\":\n\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n draw_tree((int)$_GET['id']);\n }\n\n break;\n\n ###############################################\n case \"show_graph\":\n\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n echo \"
\\n\";\n echo \"Advisors and Advisees of \".get_person_link($_GET['id']);\n echo \"
\\n\";\n draw_graph((int)$_GET['id']);\n }\n\n break;\n\n ###############################################\n case \"statistics\":\n\n echo \"
\\n\";\n echo \"LIS Incomplete - \\n\";\n echo \"Top A -\\n\";\n echo \"Top C -\\n\";\n echo \"Top A+C -\\n\";\n echo \"Top T -\\n\";\n echo \"Top G -\\n\";\n echo \"Top W -\\n\";\n echo \"Top TD -\\n\";\n echo \"Top TA\\n\";\n echo \"
\\n\";\n\n echo \"
Overall MPACT Statistics
\\n\";\n\n echo \"
\\n\";\n\n # disciplines\n $query = \"SELECT count(*) as disciplinecount FROM disciplines\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n echo \"
Disciplines
\".$disciplinecount.\"
\\n\";\n\n # schools\n $query = \"SELECT count(*) as schoolcount FROM schools\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n echo \"
Schools
\".$schoolcount.\"
\\n\";\n\n # diss\n $query = \"SELECT count(*) as disscount FROM dissertations\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n echo \"
Dissertations
\".$disscount.\"
\\n\";\n\n # a\n $query = \"SELECT count(*) as advisorcount FROM advisorships\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n echo \"
Advisorships
\".$advisorcount.\"
\\n\";\n\n # c\n $query = \"SELECT count(*) as committeeshipscount FROM committeeships\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n echo \"
Committeeships
\".$committeeshipscount.\"
\\n\";\n\n # full\n $query = \"SELECT count(*) as peoplecount FROM people\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n echo \"
People
\".$peoplecount.\"
\\n\";\n echo \"
\\n\";\n\n\n # dissertations by country\n echo \"
\\n\";\n echo \"
Dissertations by Country:
\\n\";\n $query = \"SELECT count(*) as dissnone FROM dissertations WHERE school_id IN (SELECT id FROM schools WHERE country = \\\"\\\")\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n $query = \"SELECT count(*) as dissusa FROM dissertations WHERE school_id IN (SELECT id FROM schools WHERE country = \\\"USA\\\")\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n $query = \"SELECT count(*) as disscanada FROM dissertations WHERE school_id IN (SELECT id FROM schools WHERE country = \\\"Canada\\\")\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n $query = \"SELECT count(*) as dissother FROM dissertations WHERE school_id IN\n (SELECT id FROM schools WHERE (country != \\\"\\\" AND country != \\\"USA\\\" AND country != \\\"Canada\\\"))\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n echo \"
\\n\";\n $query = \"SELECT completedyear, count(*) as disscount FROM dissertations GROUP BY completedyear\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $counts[$line['completedyear']] = $line['disscount'];\n }\n echo \"
\\n\";\n echo \"
\\n\";\n foreach ($counts as $one => $two)\n {\n echo \"
\\n\";\n }\n echo \"
\";\n echo \"
\\n\";\n foreach ($counts as $one => $two)\n {\n echo \"
\";\n if ($one%10==0)\n {\n echo $one;\n }\n echo \"
\\n\";\n }\n echo \"
\";\n echo \"
\\n\";\n\n break;\n\n\n ###############################################\n case \"show_logs\":\n\n if (is_admin())\n {\n echo \"
\\n\";\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"lis_profsnotfromlis\":\n\n if (is_admin())\n {\n\n echo \"
LIS Professors without LIS Dissertations
\\n\";\n\n # and then once the data collection is done\n # cassidy wants a list of all the people who were advisors and committee\n # members for lis, but were not themselves lis\n\n # get list of LIS dissertations\n $query = \"SELECT\n d.id\n FROM\n dissertations d\n WHERE\n d.discipline_id = '1'\n \";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $lis_dissertations[] = $line['id'];\n }\n # get advisors for each diss\n $advisors = array();\n foreach ($lis_dissertations as $id){\n $query = \"SELECT person_id\n FROM advisorships\n WHERE dissertation_id = $id\n \";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $advisors[] = $line['person_id'];\n }\n }\n # get committeeships for each diss\n $committeemembers = array();\n foreach ($lis_dissertations as $id){\n $query = \"SELECT person_id\n FROM committeeships\n WHERE dissertation_id = $id\n \";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $committeemembers[] = $line['person_id'];\n }\n }\n $total = array_merge($advisors,$committeemembers);\n $unique = array_unique($total);\n\n $unique_list = implode(\",\",$unique);\n $listed = array();\n $query = \"SELECT person_id\n FROM dissertations\n WHERE\n person_id IN ($unique_list)\n AND\n discipline_id = '1'\n \";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $listed[] = $line['person_id'];\n }\n $notlisted = array_diff($unique,$listed);\n\n # print them out\n echo \"
\\n\";\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"top_a\":\n case \"top_c\":\n case \"top_ac\":\n case \"top_g\":\n case \"top_td\":\n case \"top_w\":\n case \"top_t\":\n case \"top_ta\":\n\n $list_type = strtoupper(substr($_GET['op'],4));\n echo \"
Top \";\n if ($list_type == \"TD\"){echo \"TD\";}\n else if ($list_type == \"TA\"){echo \"TA\";}\n else if ($list_type == \"AC\"){echo \"A+C\";}\n else {echo $list_type;}\n echo \" List
\";\n if ($two != $lasttotal){echo $count.\".\";}\n echo \"
\";\n echo \"
\";\n echo get_person_link($one);\n echo \"
\";\n echo \"
\";\n echo $two;\n echo \"
\";\n echo \"
\\n\";\n $lasttotal = $two;\n }\n echo \"
\\n\";\n break;\n\n ###############################################\n case \"create_discipline\":\n\n if (is_admin())\n {\n echo \"
Creating a New Discipline
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"edit_discipline\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n elseif (!is_empty_discipline($_GET['id']))\n {\n action_box(\"Discipline must be empty to edit...\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_disciplines\");\n }\n else{\n \n $query = \"SELECT title FROM disciplines WHERE id=\".$_GET['id'];\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n\n echo \"
Editing a Discipline
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"create_school\":\n\n if (is_admin())\n {\n echo \"
Creating a New School
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"edit_school\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n elseif (!is_empty_school($_GET['id']))\n {\n action_box(\"School must be empty to edit...\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_schools\");\n }\n else{\n \n $query = \"SELECT fullname, country FROM schools WHERE id=\".$_GET['id'];\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n\n echo \"
Editing a School
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"create_person\":\n\n if (is_admin())\n {\n echo \"
Creating a New Person
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"add_mentor\":\n\n if (is_admin())\n {\n echo \"
\\n\";\n\n echo \"\";\n\n draw_tree($url['person_id']);\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"edit_degree\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['id']);\n\n echo \"
Editing a Degree
\";\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n echo \"
\";\n draw_tree($_GET['id']);\n echo \"
\";\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n\n ###############################################\n case \"add_name\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['id']);\n\n echo \"
Adding an Alias
\";\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n echo \"
\";\n draw_tree($_GET['id']);\n echo \"
\";\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n \n break;\n \n ###############################################\n case \"edit_name\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['id']);\n\n echo \"
Editing a Name
\";\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n echo \"
\";\n draw_tree($_GET['id']);\n echo \"
\";\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"create_dissertation\":\n\n if (is_admin())\n {\n\n $disciplines = find_disciplines();\n $schools = find_schools();\n\n if (!$_GET['person_id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['person_id']);\n if (!$person)\n {\n action_box(\"Person not found.\");\n }\n else{\n\n echo \"
CREATE DISSERTATION
\\n\";\n\n echo \"\";\n\n echo \"
\";\n echo \"Currently:\";\n echo \"
\";\n echo \"
\";\n draw_tree($person['id']);\n echo \"
\";\n }\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n\n ###############################################\n case \"edit_dissertation\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $disciplines = find_disciplines();\n $schools = find_schools();\n $dissertation = find_dissertation(intval($_GET['id']));\n if (!$dissertation)\n {\n action_box(\"Dissertation not found.\");\n }\n else{\n \n $person = find_person($dissertation['person_id']);\n\n echo \"
EDIT DISSERTATION DETAILS
\\n\";\n\n echo \"\";\n\n echo \"
\";\n echo \"Currently:\";\n echo \"
\";\n echo \"
\";\n draw_tree($person['id']);\n echo \"
\";\n }\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"delete_name\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_name($_GET['name']);\n\n echo \"
\";\n\n echo \"Are you sure you want to delete this name?\";\n\n echo \"
\";\n\n echo \"\";\n\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n \n ###############################################\n case \"set_preferred_name\":\n\n if (is_admin())\n {\n\n set_preferred_name($_GET['id'],$_GET['name']);\n\n action_box(\"Preferred Name Selected\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_tree&id=\".$_GET['id']);\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"recalculate_mpact\":\n\n if (is_admin()){\n\n # recalculate MPACT scores for passed person id\n calculate_scores($_GET['id']);\n\n action_box(\"MPACT Scores Recalculated\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_tree&id=\".$_GET['id']);\n\n }\n else\n {\n not_admin();\n } \n\n break;\n\n ###############################################\n case \"show_orphans\":\n\n if (is_admin())\n {\n\n $orphans = find_orphans();\n\n echo \"
Orphans
\\n\";\n\n echo \"
\\n\";\n $counter = 0;\n foreach ($orphans as $orphan)\n {\n $counter++;\n echo $counter.\" \";\n echo get_person_link($orphan['person_id']);\n echo \" (Delete from Database)\";\n echo \" \\n\";\n }\n if ($counter < 1){echo \" - No orphans at this time.\";}\n echo \"
\\n\";\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"delete_person\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n if (is_orphan($_GET['id']))\n {\n echo \"
\";\n\n echo \"Are you sure you want to delete this person?\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n action_box(\"This person cannot be deleted.\");\n }\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n\n ###############################################\n case \"show_disciplines\":\n\n $statustotals = array(0,0,0,0,0);\n $disciplines = find_disciplines();\n $disciplinecounts = find_discipline_counts();\n\n if (is_admin()){\n echo \"
\\n\";\n echo \"\\n\";\n\n break;\n\n ###############################################\n case \"show_discipline\":\n\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $discipline_id = intval($_GET['id']);\n\n # Show Discipline Name\n $query = \"SELECT d.title as disciplinename\n FROM disciplines d\n WHERE\n d.id = '$discipline_id'\n \";\n\n $result = mysql_query($query) or die(mysql_error());\n \n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n\n echo \"
$disciplinename
\";\n\n # Show Histograph\n $counts = array();\n echo \"
\\n\";\n echo \"Dissertations by Year: \\n\";\n $query = \"SELECT completedyear, count(*) as disscount FROM dissertations WHERE discipline_id='$discipline_id' GROUP BY completedyear\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $counts[$line['completedyear']] = $line['disscount'];\n }\n if (count($counts)>0)\n {\n $bigyear = max($counts);\n echo \"
\\n\";\n }\n\n break;\n\n ###############################################\n case \"show_school\":\n\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $school_id = intval($_GET['id']);\n\n # Show School Name\n $query = \"SELECT s.fullname as schoolname, s.country\n FROM schools s\n WHERE\n s.id = '$school_id'\n \";\n\n $result = mysql_query($query) or die(mysql_error());\n \n while ( $line = mysql_fetch_array($result)) {\n extract($line);\n }\n\n echo \"
$schoolname ($country)
\";\n\n # Show Histograph\n echo \"
\\n\";\n echo \"Dissertations by Year: \\n\";\n $query = \"SELECT completedyear, count(*) as disscount FROM dissertations WHERE school_id='$school_id' GROUP BY completedyear\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $counts[$line['completedyear']] = $line['disscount'];\n }\n $bigyear = max($counts);\n echo \"
\n \";\n\n # Advisor and Committee Activity\n echo \"
Dissertation Activity and MPACT Scores (click table headings to sort)
\";\n \n echo \"
\";\n $theprofs = find_profs_at_dept($school_id,$discipline_id);\n if (count($theprofs)>0)\n {\n $sortedprofs = array();\n $proflist = \"\";\n $query = \"SELECT id FROM people WHERE id IN (\";\n foreach ($theprofs as $prof){$proflist .= \"$prof,\";}\n $proflist = rtrim($proflist, \",\");\n $query .= \"$proflist) ORDER BY ac_score DESC\";\n $result = mysql_query($query) or die(mysql_error());\n while ( $line = mysql_fetch_array($result)) {\n $sortedprofs[] = $line['id'];\n }\n $profcount = 0;\n echo \"
\\n\";\n echo \"
\n
-
\n
Name
\n
A
\n
C
\n
A+C
\n
G
\n
T
\n
TA
\n
TD
\n
W
\n
\\n\";\n foreach ($sortedprofs as $one)\n {\n echo \"
\";\n\n }\n\n break;\n \n ###############################################\n default:\n // oops - not supposed to be here\n action_box(\"invalid action\",1);\n }\n }\n else\n {\n\n if (isset($_GET['show']))\n {\n if ($_GET['show'] == \"all\")\n {\n $alphabet_limiter = \"\"; // set it to show everything\n }\n else\n {\n $alphabet_limiter = $_GET['show'];\n }\n\n show_alphabet();\n\n if (is_admin())\n {\n echo \"
\\n\";\n\n $query = \"SELECT id, term, definition FROM glossary WHERE id='\".$_GET['id'].\"'\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n\n while ( $line = mysqli_fetch_array($result)) {\n $results['term'] = $line['term'];\n $results['definition'] = $line['definition'];\n }\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n }\n else\n {\n not_admin();\n }\n\n break;\n ###############################################\n case \"show_tree\":\n\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n draw_tree((int)$_GET['id']);\n }\n\n break;\n\n ###############################################\n case \"show_graph\":\n\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n echo \"
\\n\";\n echo \"Advisors and Advisees of \".get_person_link($_GET['id']);\n echo \"
\\n\";\n draw_graph((int)$_GET['id']);\n }\n\n break;\n\n ###############################################\n case \"statistics\":\n\n echo \"
\\n\";\n echo \"LIS Incomplete - \\n\";\n echo \"Top A -\\n\";\n echo \"Top C -\\n\";\n echo \"Top A+C -\\n\";\n echo \"Top T -\\n\";\n echo \"Top G -\\n\";\n echo \"Top W -\\n\";\n echo \"Top TD -\\n\";\n echo \"Top TA\\n\";\n echo \"
\\n\";\n\n echo \"
Overall MPACT Statistics
\\n\";\n\n echo \"
\\n\";\n\n # disciplines\n $query = \"SELECT count(*) as disciplinecount FROM disciplines\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n echo \"
Disciplines
\".$disciplinecount.\"
\\n\";\n\n # schools\n $query = \"SELECT count(*) as schoolcount FROM schools\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n echo \"
Schools
\".$schoolcount.\"
\\n\";\n\n # diss\n $query = \"SELECT count(*) as disscount FROM dissertations\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n echo \"
Dissertations
\".$disscount.\"
\\n\";\n\n # a\n $query = \"SELECT count(*) as advisorcount FROM advisorships\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n echo \"
Advisorships
\".$advisorcount.\"
\\n\";\n\n # c\n $query = \"SELECT count(*) as committeeshipscount FROM committeeships\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n echo \"
Committeeships
\".$committeeshipscount.\"
\\n\";\n\n # full\n $query = \"SELECT count(*) as peoplecount FROM people\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n echo \"
People
\".$peoplecount.\"
\\n\";\n echo \"
\\n\";\n\n\n # dissertations by country\n echo \"
\\n\";\n echo \"
Dissertations by Country:
\\n\";\n $query = \"SELECT count(*) as dissnone FROM dissertations WHERE school_id IN (SELECT id FROM schools WHERE country = \\\"\\\")\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n $query = \"SELECT count(*) as dissusa FROM dissertations WHERE school_id IN (SELECT id FROM schools WHERE country = \\\"USA\\\")\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n $query = \"SELECT count(*) as disscanada FROM dissertations WHERE school_id IN (SELECT id FROM schools WHERE country = \\\"Canada\\\")\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n $query = \"SELECT count(*) as dissother FROM dissertations WHERE school_id IN\n (SELECT id FROM schools WHERE (country != \\\"\\\" AND country != \\\"USA\\\" AND country != \\\"Canada\\\"))\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n echo \"
\\n\";\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"lis_profsnotfromlis\":\n\n if (is_admin())\n {\n\n echo \"
LIS Professors without LIS Dissertations
\\n\";\n\n # and then once the data collection is done\n # cassidy wants a list of all the people who were advisors and committee\n # members for lis, but were not themselves lis\n\n # get list of LIS dissertations\n $query = \"SELECT\n d.id\n FROM\n dissertations d\n WHERE\n d.discipline_id = '1'\n \";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n $lis_dissertations[] = $line['id'];\n }\n # get advisors for each diss\n $advisors = array();\n foreach ($lis_dissertations as $id){\n $query = \"SELECT person_id\n FROM advisorships\n WHERE dissertation_id = $id\n \";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n $advisors[] = $line['person_id'];\n }\n }\n # get committeeships for each diss\n $committeemembers = array();\n foreach ($lis_dissertations as $id){\n $query = \"SELECT person_id\n FROM committeeships\n WHERE dissertation_id = $id\n \";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n $committeemembers[] = $line['person_id'];\n }\n }\n $total = array_merge($advisors,$committeemembers);\n $unique = array_unique($total);\n\n $unique_list = implode(\",\",$unique);\n $listed = array();\n $query = \"SELECT person_id\n FROM dissertations\n WHERE\n person_id IN ($unique_list)\n AND\n discipline_id = '1'\n \";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n $listed[] = $line['person_id'];\n }\n $notlisted = array_diff($unique,$listed);\n\n # print them out\n echo \"
\\n\";\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"top_a\":\n case \"top_c\":\n case \"top_ac\":\n case \"top_g\":\n case \"top_td\":\n case \"top_w\":\n case \"top_t\":\n case \"top_ta\":\n\n $list_type = strtoupper(substr($_GET['op'],4));\n echo \"
Top \";\n if ($list_type == \"TD\"){echo \"TD\";}\n else if ($list_type == \"TA\"){echo \"TA\";}\n else if ($list_type == \"AC\"){echo \"A+C\";}\n else {echo $list_type;}\n echo \" List
\";\n if ($two != $lasttotal){echo $count.\".\";}\n echo \"
\";\n echo \"
\";\n echo get_person_link($one);\n echo \"
\";\n echo \"
\";\n echo $two;\n echo \"
\";\n echo \"
\\n\";\n $lasttotal = $two;\n }\n echo \"
\\n\";\n break;\n\n ###############################################\n case \"create_discipline\":\n\n if (is_admin())\n {\n echo \"
Creating a New Discipline
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"edit_discipline\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n elseif (!is_empty_discipline($_GET['id']))\n {\n action_box(\"Discipline must be empty to edit...\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_disciplines\");\n }\n else{\n\n $query = \"SELECT title FROM disciplines WHERE id=\".$_GET['id'];\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n\n echo \"
Editing a Discipline
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"create_school\":\n\n if (is_admin())\n {\n echo \"
Creating a New School
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"edit_school\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n elseif (!is_empty_school($_GET['id']))\n {\n action_box(\"School must be empty to edit...\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_schools\");\n }\n else{\n\n $query = \"SELECT fullname, country FROM schools WHERE id=\".$_GET['id'];\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n\n echo \"
Editing a School
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"create_person\":\n\n if (is_admin())\n {\n echo \"
Creating a New Person
\\n\";\n\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"add_mentor\":\n\n if (is_admin())\n {\n echo \"
\\n\";\n\n echo \"\";\n\n draw_tree($url['person_id']);\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"edit_degree\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['id']);\n\n echo \"
Editing a Degree
\";\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n echo \"
\";\n draw_tree($_GET['id']);\n echo \"
\";\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n\n ###############################################\n case \"add_name\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['id']);\n\n echo \"
Adding an Alias
\";\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n echo \"
\";\n draw_tree($_GET['id']);\n echo \"
\";\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"edit_name\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['id']);\n\n echo \"
Editing a Name
\";\n echo \"
\";\n\n echo \"
\";\n\n echo \"\";\n\n\n echo \"
\";\n draw_tree($_GET['id']);\n echo \"
\";\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"create_dissertation\":\n\n if (is_admin())\n {\n\n $disciplines = find_disciplines();\n $schools = find_schools();\n\n if (!$_GET['person_id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_person($_GET['person_id']);\n if (!$person)\n {\n action_box(\"Person not found.\");\n }\n else{\n\n echo \"
CREATE DISSERTATION
\\n\";\n\n echo \"\";\n\n echo \"
\";\n echo \"Currently:\";\n echo \"
\";\n echo \"
\";\n draw_tree($person['id']);\n echo \"
\";\n }\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n\n ###############################################\n case \"edit_dissertation\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $disciplines = find_disciplines();\n $schools = find_schools();\n $dissertation = find_dissertation(intval($_GET['id']));\n if (!$dissertation)\n {\n action_box(\"Dissertation not found.\");\n }\n else{\n\n $person = find_person($dissertation['person_id']);\n\n echo \"
EDIT DISSERTATION DETAILS
\\n\";\n\n echo \"\";\n\n echo \"
\";\n echo \"Currently:\";\n echo \"
\";\n echo \"
\";\n draw_tree($person['id']);\n echo \"
\";\n }\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"delete_name\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $person = find_name($_GET['name']);\n\n echo \"
\";\n\n echo \"Are you sure you want to delete this name?\";\n\n echo \"
\";\n\n echo \"\";\n\n\n\n\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"set_preferred_name\":\n\n if (is_admin())\n {\n\n set_preferred_name($_GET['id'],$_GET['name']);\n\n action_box(\"Preferred Name Selected\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_tree&id=\".$_GET['id']);\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"recalculate_mpact\":\n\n if (is_admin()){\n\n # recalculate MPACT scores for passed person id\n calculate_scores($_GET['id']);\n\n action_box(\"MPACT Scores Recalculated\",2,$_SERVER['SCRIPT_NAME'].\"?op=show_tree&id=\".$_GET['id']);\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"show_orphans\":\n\n if (is_admin())\n {\n\n $orphans = find_orphans();\n\n echo \"
Orphans
\\n\";\n\n echo \"
\\n\";\n $counter = 0;\n foreach ($orphans as $orphan)\n {\n $counter++;\n echo $counter.\" \";\n echo get_person_link($orphan['person_id']);\n echo \" (Delete from Database)\";\n echo \" \\n\";\n }\n if ($counter < 1){echo \" - No orphans at this time.\";}\n echo \"
\\n\";\n\n }\n else\n {\n not_admin();\n }\n\n break;\n\n ###############################################\n case \"delete_person\":\n\n if (is_admin())\n {\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n if (is_orphan($_GET['id']))\n {\n echo \"
\";\n\n echo \"Are you sure you want to delete this person?\";\n\n echo \"
\";\n\n echo \"\";\n }\n else\n {\n action_box(\"This person cannot be deleted.\");\n }\n }\n }\n else\n {\n not_admin();\n }\n\n break;\n\n\n ###############################################\n case \"show_disciplines\":\n\n $statustotals = array(0,0,0,0,0);\n $disciplines = find_disciplines();\n $disciplinecounts = find_discipline_counts();\n\n if (is_admin()){\n echo \"
\\n\";\n echo \"\\n\";\n\n break;\n\n ###############################################\n case \"show_discipline\":\n\n if (!$_GET['id']){action_box(\"No ID given.\");}\n else\n {\n\n $discipline_id = intval($_GET['id']);\n\n # Show Discipline Name\n $query = \"SELECT d.title as disciplinename\n FROM disciplines d\n WHERE\n d.id = '$discipline_id'\n \";\n\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n\n while ( $line = mysqli_fetch_array($result)) {\n extract($line);\n }\n\n echo \"
$disciplinename
\";\n\n # Show Histograph\n $counts = array();\n echo \"
\\n\";\n echo \"Dissertations by Year: \\n\";\n $query = \"SELECT completedyear, count(*) as disscount FROM dissertations WHERE discipline_id='$discipline_id' GROUP BY completedyear\";\n $result = mysqli_query($dbh, $query) or die(mysqli_error($dbh));\n while ( $line = mysqli_fetch_array($result)) {\n $counts[$line['completedyear']] = $line['disscount'];\n }\n if (count($counts)>0)\n {\n $bigyear = max($counts);\n echo \"
\";\n\n }\n\n break;\n\n ###############################################\n default:\n // oops - not supposed to be here\n action_box(\"invalid action\",1);\n }\n }\n else\n {\n\n if (isset($_GET['show']))\n {\n if ($_GET['show'] == \"all\")\n {\n $alphabet_limiter = \"\"; // set it to show everything\n }\n else\n {\n $alphabet_limiter = $_GET['show'];\n }\n\n show_alphabet();\n\n if (is_admin())\n {\n echo \"
\";\n echo $printme;\n\n }\n\n }\n\n\n}\n\n\n?>\n"}}
{"repo": "trac-hacks/trac-dashboard", "pr_number": 2, "title": "Unpack one-element tuple correctly", "state": "closed", "merged_at": "2016-08-27T20:14:18Z", "additions": 2, "deletions": 2, "files_changed": ["dashboard/dashboard.py"], "files_before": {"dashboard/dashboard.py": "from trac.core import *\nfrom pkg_resources import resource_filename\nfrom trac.config import Option, IntOption, ListOption, BoolOption\nfrom trac.web.api import IRequestHandler, Href\nfrom trac.util.translation import _\nfrom trac.web.chrome import add_stylesheet, add_script, INavigationContributor, ITemplateProvider\nfrom trac.web.chrome import Chrome\nfrom trac.util.datefmt import utc, to_timestamp\nfrom genshi.template import TemplateLoader\nfrom genshi.filters.transform import Transformer\nfrom trac.web.api import ITemplateStreamFilter\nfrom trac.perm import IPermissionRequestor\nfrom trac.util import escape, Markup\n\nimport time\nfrom datetime import datetime, timedelta\n\n\n\n\nclass DashBoard(Component):\n implements(IRequestHandler, ITemplateProvider, IPermissionRequestor, INavigationContributor)\n \n permission = Option('dashboard', 'permission', '')\n default_milestone = Option('dashboard', 'default_milestone', '')\n\n def __init__(self):\n self.db = self.env.get_db_cnx()\n self.username = None\n self.backDate = 30\n self.ticket_closed = ['checkedin', 'closed']\n\n self.ticket_closed_sql = \"','\".join(self.ticket_closed)\n\n self.milestone = self.default_milestone\n \n if self.permission:\n self.perm = self.permission\n else:\n self.perm = 'DASHBOARD_VIEW'\n\n self.env.log.debug(\"Using Permission: %s\" % self.permission)\n\n \n # INavigationContributor methods\n def get_active_navigation_item(self, req):\n return 'dashboard'\n\n def get_navigation_items(self, req):\n if self.perm in req.perm or 'TRAC_ADMIN' in req.perm:\n yield 'mainnav', 'dashboard', Markup('Dashboard' % (\n self.env.href.dashboard() ) )\n\n\n\n def get_permission_actions(self):\n yield self.perm\n\n \n # IRequestHandler methods\n def match_request(self, req):\n serve = False\n self.env.log.debug(\"Match Request\")\n\n\n uri = req.path_info.lstrip('/').split('/')\n if uri[0] == 'dashboard':\n serve = True\n\n self.env.log.debug(\"Handle Request: %s\" % serve)\n self.baseURL = req.href('dashboard', '/')\n self.baseQueryURL = req.href('query', '/')\n self.username = req.authname\n if 'milestone' in req.args:\n self.milestone = req.args.get('milestone')\n else:\n self.milestone = self.default_milestone\n\n if self.milestone == '':\n cursor = self.db.cursor()\n sql = \"select name from milestone where (completed = 0) limit 0, 1\"\n cursor.execute(sql)\n for name in cursor:\n self.milestone = name\n\n if 'dev' in req.args:\n self.username = req.args.get('dev')\n else:\n self.username = req.authname\n\n return serve\n\n if not self.perm in req.perm:\n self.env.log.debug(\"NO Permission to view\")\n return False\n\n return serve\n \n def get_updated_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, status from ticket where (owner = '%s') and (changetime >= %s) and (status not in ('%s', 'new')) order by changetime desc\" % (self.username, self.stamp, self.ticket_closed_sql)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, status in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_new_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, status, component, summary, changetime, priority from ticket where (owner = '%s') and (status in ('new', 'assigned')) and (type = 'defect') order by changetime desc\" % self.username\n cursor.execute(sql)\n out = []\n idx = 0\n for id, status, component, summary, changetime, priority in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'status': status,\n 'component': component,\n 'summary': summary,\n 'priority': priority,\n 'changetime': datetime.fromtimestamp(changetime, utc)\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_closed_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, changetime, status from ticket where (owner = '%s') and (status in ('%s')) and (changetime >= %s) order by component, status, changetime desc\" % (self.username, self.ticket_closed_sql, self.stamp)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, changetime, status in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status,\n 'changetime': datetime.fromtimestamp(changetime, utc)\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_milestone_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, status, priority from ticket where (owner = '%s') and (status not in ('%s', 'new')) and (type in ('defect', 'enhancement')) and (milestone = '%s') order by component, priority\" % (self.username, self.ticket_closed_sql, self.milestone)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, status, priority in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status,\n 'priority': priority\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_todo_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, status from ticket where (owner = '%s') and (status not in ('%s')) and (type = 'task') order by changetime desc\" % (self.username, self.ticket_closed_sql)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, status in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_ticket_counts(self):\n cursor = self.db.cursor()\n sql = \"select count(*) as total, type, status from ticket where (owner = '%s') and (status not in ('%s')) group by type, status order by total desc\" % (self.username, self.ticket_closed_sql)\n cursor.execute(sql)\n out = []\n idx = 0\n for total, type, status in cursor:\n data = {\n '__idx__': idx,\n 'total': total,\n 'status': status,\n 'type': type\n }\n idx = idx + 1\n out.append(data)\n\n return out\n\n def get_action_counts(self):\n cursor = self.db.cursor()\n #sql = \"select count(*) as total, concat(oldvalue, ' => ', newvalue) as status from ticket_change where (author = '%s') and (time > %s) and (field = 'status') group by status order by total desc\" % (self.username, self.stamp)\n sql = \"select count(*) as total, (%s) as status from ticket_change where (author = '%s') and (time > %s) and (field = 'status') group by status order by total desc\" % (self.db.concat('oldvalue', \"' => '\", 'newvalue'), self.username, self.stamp)\n cursor.execute(sql)\n \n out = []\n idx = 0\n for total, status in cursor:\n data = {\n '__idx__': idx,\n 'total': total,\n 'status': status\n }\n idx = idx + 1\n out.append(data)\n\n return out\n\n\n def get_milestone_data(self):\n cursor = self.db.cursor()\n out = {\n 'total': 0,\n 'closed': 0,\n 'closed_percent': 0,\n 'new': 0,\n 'new_percent': 0,\n 'inprogress': 0,\n 'inprogress_percent': 0,\n 'name': self.milestone\n }\n #sql = \"select count(*) as total, ticket.status from ticket, ticket_custom where (ticket.milestone = '%s') and (ticket.owner = '%s') and (ticket.id = ticket_custom.ticket) and (ticket_custom.name = 'location') and (ticket_custom.value = 'Library Code')\" % (self.milestone, self.username)\n sql = \"select count(*) as total, status from ticket where (milestone = '%s') and (owner = '%s') and (type = 'defect') group by status\" % (self.milestone, self.username)\n cursor.execute(sql)\n\n for total, status in cursor:\n out['total'] = out['total'] + total\n\n if status in self.ticket_closed:\n out['closed'] = out['closed'] + total\n elif status == 'new':\n out['new'] = out['new'] + total\n else:\n out['inprogress'] = out['inprogress'] + total\n\n if out['closed'] > 0:\n out['closed_percent'] = int(round((float(out['closed']) / out['total']), 3) * 100)\n\n if out['new'] > 0:\n out['new_percent'] = int(round((float(out['new']) / out['total']), 1) * 100)\n\n if out['inprogress'] > 0:\n out['inprogress_percent'] = int(round((float(out['inprogress']) / out['total']), 3) * 100)\n\n\n return out\n\n def get_milestones(self):\n cursor = self.db.cursor()\n sql = \"select name from milestone where (name not in ('%s')) and (completed = 0)\" % self.milestone\n cursor.execute(sql)\n data = []\n for name in cursor:\n data.append(name)\n\n return data\n\n def get_users(self):\n devs = self.env.get_known_users()\n odevs = []\n for username,name,email in devs:\n if username != self.username:\n data = {\n 'username': username,\n 'name': name or username\n }\n odevs.append(data)\n return odevs\n\n\n def process_request(self, req):\n data = {}\n self.stamp = time.time() - (60 * 60 * 24 * self.backDate)\n today = datetime.now(req.tz)\n\n\n data['backDate'] = self.backDate\n data['stamp'] = self.stamp\n data['username'] = self.username\n data['milestone'] = self.milestone\n\n #Updated Tickets \n data['updated_tickets'] = self.get_updated_tickets()\n data['has_updated_tickets'] = len(data['updated_tickets'])\n\n #New Tickets\n data['new_tickets'] = self.get_new_tickets()\n data['has_new_tickets'] = len(data['new_tickets'])\n\n #Closed Tickets\n data['closed_tickets'] = self.get_closed_tickets()\n data['has_closed_tickets'] = len(data['closed_tickets'])\n\n #Ticket Counts\n data['ticket_counts'] = self.get_ticket_counts()\n data['has_ticket_counts'] = len(data['ticket_counts'])\n\n #Action Counts\n data['action_counts'] = self.get_action_counts()\n data['has_action_counts'] = len(data['action_counts'])\n\n #TODO Lists\n data['todo_tickets'] = self.get_todo_tickets()\n data['has_todo_tickets'] = len(data['todo_tickets'])\n\n #Milestones\n data['milestone_data'] = self.get_milestone_data()\n data['has_milestones'] = len(data['milestone_data'])\n\n #Milestone Tickets\n data['milestone_tickets'] = self.get_milestone_tickets()\n data['has_milestone_tickets'] = len(data['milestone_tickets'])\n\n #Milestones\n data['milestones'] = self.get_milestones()\n\n #Users\n data['users'] = self.get_users()\n\n\n add_script(req, \"dashboard/dashboard.js\")\n add_stylesheet(req, \"dashboard/dashboard.css\")\n return 'dashboard.html', data, None\n\n\n def get_htdocs_dirs(self):\n \"\"\"Return the absolute path of a directory containing additional\n static resources (such as images, style sheets, etc).\n \"\"\"\n return [('dashboard', resource_filename(__name__, 'htdocs'))]\n \n def get_templates_dirs(self):\n \"\"\"Return the absolute path of the directory containing the provided\n genshi templates.\n \"\"\"\n rtn = [resource_filename(__name__, 'templates')]\n return rtn\n"}, "files_after": {"dashboard/dashboard.py": "from trac.core import *\nfrom pkg_resources import resource_filename\nfrom trac.config import Option, IntOption, ListOption, BoolOption\nfrom trac.web.api import IRequestHandler, Href\nfrom trac.util.translation import _\nfrom trac.web.chrome import add_stylesheet, add_script, INavigationContributor, ITemplateProvider\nfrom trac.web.chrome import Chrome\nfrom trac.util.datefmt import utc, to_timestamp\nfrom genshi.template import TemplateLoader\nfrom genshi.filters.transform import Transformer\nfrom trac.web.api import ITemplateStreamFilter\nfrom trac.perm import IPermissionRequestor\nfrom trac.util import escape, Markup\n\nimport time\nfrom datetime import datetime, timedelta\n\n\n\n\nclass DashBoard(Component):\n implements(IRequestHandler, ITemplateProvider, IPermissionRequestor, INavigationContributor)\n \n permission = Option('dashboard', 'permission', '')\n default_milestone = Option('dashboard', 'default_milestone', '')\n\n def __init__(self):\n self.db = self.env.get_db_cnx()\n self.username = None\n self.backDate = 30\n self.ticket_closed = ['checkedin', 'closed']\n\n self.ticket_closed_sql = \"','\".join(self.ticket_closed)\n\n self.milestone = self.default_milestone\n \n if self.permission:\n self.perm = self.permission\n else:\n self.perm = 'DASHBOARD_VIEW'\n\n self.env.log.debug(\"Using Permission: %s\" % self.permission)\n\n \n # INavigationContributor methods\n def get_active_navigation_item(self, req):\n return 'dashboard'\n\n def get_navigation_items(self, req):\n if self.perm in req.perm or 'TRAC_ADMIN' in req.perm:\n yield 'mainnav', 'dashboard', Markup('Dashboard' % (\n self.env.href.dashboard() ) )\n\n\n\n def get_permission_actions(self):\n yield self.perm\n\n \n # IRequestHandler methods\n def match_request(self, req):\n serve = False\n self.env.log.debug(\"Match Request\")\n\n\n uri = req.path_info.lstrip('/').split('/')\n if uri[0] == 'dashboard':\n serve = True\n\n self.env.log.debug(\"Handle Request: %s\" % serve)\n self.baseURL = req.href('dashboard', '/')\n self.baseQueryURL = req.href('query', '/')\n self.username = req.authname\n if 'milestone' in req.args:\n self.milestone = req.args.get('milestone')\n else:\n self.milestone = self.default_milestone\n\n if self.milestone == '':\n cursor = self.db.cursor()\n sql = \"select name from milestone where (completed = 0) limit 0, 1\"\n cursor.execute(sql)\n for name, in cursor:\n self.milestone = name\n\n if 'dev' in req.args:\n self.username = req.args.get('dev')\n else:\n self.username = req.authname\n\n return serve\n\n if not self.perm in req.perm:\n self.env.log.debug(\"NO Permission to view\")\n return False\n\n return serve\n \n def get_updated_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, status from ticket where (owner = '%s') and (changetime >= %s) and (status not in ('%s', 'new')) order by changetime desc\" % (self.username, self.stamp, self.ticket_closed_sql)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, status in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_new_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, status, component, summary, changetime, priority from ticket where (owner = '%s') and (status in ('new', 'assigned')) and (type = 'defect') order by changetime desc\" % self.username\n cursor.execute(sql)\n out = []\n idx = 0\n for id, status, component, summary, changetime, priority in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'status': status,\n 'component': component,\n 'summary': summary,\n 'priority': priority,\n 'changetime': datetime.fromtimestamp(changetime, utc)\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_closed_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, changetime, status from ticket where (owner = '%s') and (status in ('%s')) and (changetime >= %s) order by component, status, changetime desc\" % (self.username, self.ticket_closed_sql, self.stamp)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, changetime, status in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status,\n 'changetime': datetime.fromtimestamp(changetime, utc)\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_milestone_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, status, priority from ticket where (owner = '%s') and (status not in ('%s', 'new')) and (type in ('defect', 'enhancement')) and (milestone = '%s') order by component, priority\" % (self.username, self.ticket_closed_sql, self.milestone)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, status, priority in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status,\n 'priority': priority\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_todo_tickets(self):\n cursor = self.db.cursor()\n sql = \"select id, component, summary, status from ticket where (owner = '%s') and (status not in ('%s')) and (type = 'task') order by changetime desc\" % (self.username, self.ticket_closed_sql)\n cursor.execute(sql)\n out = []\n idx = 0\n for id, component, summary, status in cursor:\n data = {\n '__idx__': idx,\n 'id': id,\n 'component': component,\n 'summary': summary,\n 'status': status\n }\n idx = idx + 1\n out.append(data)\n return out\n\n def get_ticket_counts(self):\n cursor = self.db.cursor()\n sql = \"select count(*) as total, type, status from ticket where (owner = '%s') and (status not in ('%s')) group by type, status order by total desc\" % (self.username, self.ticket_closed_sql)\n cursor.execute(sql)\n out = []\n idx = 0\n for total, type, status in cursor:\n data = {\n '__idx__': idx,\n 'total': total,\n 'status': status,\n 'type': type\n }\n idx = idx + 1\n out.append(data)\n\n return out\n\n def get_action_counts(self):\n cursor = self.db.cursor()\n #sql = \"select count(*) as total, concat(oldvalue, ' => ', newvalue) as status from ticket_change where (author = '%s') and (time > %s) and (field = 'status') group by status order by total desc\" % (self.username, self.stamp)\n sql = \"select count(*) as total, (%s) as status from ticket_change where (author = '%s') and (time > %s) and (field = 'status') group by status order by total desc\" % (self.db.concat('oldvalue', \"' => '\", 'newvalue'), self.username, self.stamp)\n cursor.execute(sql)\n \n out = []\n idx = 0\n for total, status in cursor:\n data = {\n '__idx__': idx,\n 'total': total,\n 'status': status\n }\n idx = idx + 1\n out.append(data)\n\n return out\n\n\n def get_milestone_data(self):\n cursor = self.db.cursor()\n out = {\n 'total': 0,\n 'closed': 0,\n 'closed_percent': 0,\n 'new': 0,\n 'new_percent': 0,\n 'inprogress': 0,\n 'inprogress_percent': 0,\n 'name': self.milestone\n }\n #sql = \"select count(*) as total, ticket.status from ticket, ticket_custom where (ticket.milestone = '%s') and (ticket.owner = '%s') and (ticket.id = ticket_custom.ticket) and (ticket_custom.name = 'location') and (ticket_custom.value = 'Library Code')\" % (self.milestone, self.username)\n sql = \"select count(*) as total, status from ticket where (milestone = '%s') and (owner = '%s') and (type = 'defect') group by status\" % (self.milestone, self.username)\n cursor.execute(sql)\n\n for total, status in cursor:\n out['total'] = out['total'] + total\n\n if status in self.ticket_closed:\n out['closed'] = out['closed'] + total\n elif status == 'new':\n out['new'] = out['new'] + total\n else:\n out['inprogress'] = out['inprogress'] + total\n\n if out['closed'] > 0:\n out['closed_percent'] = int(round((float(out['closed']) / out['total']), 3) * 100)\n\n if out['new'] > 0:\n out['new_percent'] = int(round((float(out['new']) / out['total']), 1) * 100)\n\n if out['inprogress'] > 0:\n out['inprogress_percent'] = int(round((float(out['inprogress']) / out['total']), 3) * 100)\n\n\n return out\n\n def get_milestones(self):\n cursor = self.db.cursor()\n sql = \"select name from milestone where (name not in ('%s')) and (completed = 0)\" % self.milestone\n cursor.execute(sql)\n data = []\n for name, in cursor:\n data.append(name)\n\n return data\n\n def get_users(self):\n devs = self.env.get_known_users()\n odevs = []\n for username,name,email in devs:\n if username != self.username:\n data = {\n 'username': username,\n 'name': name or username\n }\n odevs.append(data)\n return odevs\n\n\n def process_request(self, req):\n data = {}\n self.stamp = time.time() - (60 * 60 * 24 * self.backDate)\n today = datetime.now(req.tz)\n\n\n data['backDate'] = self.backDate\n data['stamp'] = self.stamp\n data['username'] = self.username\n data['milestone'] = self.milestone\n\n #Updated Tickets \n data['updated_tickets'] = self.get_updated_tickets()\n data['has_updated_tickets'] = len(data['updated_tickets'])\n\n #New Tickets\n data['new_tickets'] = self.get_new_tickets()\n data['has_new_tickets'] = len(data['new_tickets'])\n\n #Closed Tickets\n data['closed_tickets'] = self.get_closed_tickets()\n data['has_closed_tickets'] = len(data['closed_tickets'])\n\n #Ticket Counts\n data['ticket_counts'] = self.get_ticket_counts()\n data['has_ticket_counts'] = len(data['ticket_counts'])\n\n #Action Counts\n data['action_counts'] = self.get_action_counts()\n data['has_action_counts'] = len(data['action_counts'])\n\n #TODO Lists\n data['todo_tickets'] = self.get_todo_tickets()\n data['has_todo_tickets'] = len(data['todo_tickets'])\n\n #Milestones\n data['milestone_data'] = self.get_milestone_data()\n data['has_milestones'] = len(data['milestone_data'])\n\n #Milestone Tickets\n data['milestone_tickets'] = self.get_milestone_tickets()\n data['has_milestone_tickets'] = len(data['milestone_tickets'])\n\n #Milestones\n data['milestones'] = self.get_milestones()\n\n #Users\n data['users'] = self.get_users()\n\n\n add_script(req, \"dashboard/dashboard.js\")\n add_stylesheet(req, \"dashboard/dashboard.css\")\n return 'dashboard.html', data, None\n\n\n def get_htdocs_dirs(self):\n \"\"\"Return the absolute path of a directory containing additional\n static resources (such as images, style sheets, etc).\n \"\"\"\n return [('dashboard', resource_filename(__name__, 'htdocs'))]\n \n def get_templates_dirs(self):\n \"\"\"Return the absolute path of the directory containing the provided\n genshi templates.\n \"\"\"\n rtn = [resource_filename(__name__, 'templates')]\n return rtn\n"}}
{"repo": "lowendbox/lowendscript", "pr_number": 12, "title": "Added functionality for Drupal installation, made readme file, and fixed some bugs.", "state": "open", "merged_at": null, "additions": 524, "deletions": 24, "files_changed": ["setup-debian.sh"], "files_before": {"setup-debian.sh": "#!/bin/bash\n\nfunction check_install {\n if [ -z \"`which \"$1\" 2>/dev/null`\" ]\n then\n executable=$1\n shift\n while [ -n \"$1\" ]\n do\n DEBIAN_FRONTEND=noninteractive apt-get -q -y install \"$1\"\n print_info \"$1 installed for $executable\"\n shift\n done\n else\n print_warn \"$2 already installed\"\n fi\n}\n\nfunction check_remove {\n if [ -n \"`which \"$1\" 2>/dev/null`\" ]\n then\n DEBIAN_FRONTEND=noninteractive apt-get -q -y remove --purge \"$2\"\n print_info \"$2 removed\"\n else\n print_warn \"$2 is not installed\"\n fi\n}\n\nfunction check_sanity {\n # Do some sanity checking.\n if [ $(/usr/bin/id -u) != \"0\" ]\n then\n die 'Must be run by root user'\n fi\n\n if [ ! -f /etc/debian_version ]\n then\n die \"Distribution is not supported\"\n fi\n}\n\nfunction die {\n echo \"ERROR: $1\" > /dev/null 1>&2\n exit 1\n}\n\nfunction get_domain_name() {\n # Getting rid of the lowest part.\n domain=${1%.*}\n lowest=`expr \"$domain\" : '.*\\.\\([a-z][a-z]*\\)'`\n case \"$lowest\" in\n com|net|org|gov|edu|co)\n domain=${domain%.*}\n ;;\n esac\n lowest=`expr \"$domain\" : '.*\\.\\([a-z][a-z]*\\)'`\n [ -z \"$lowest\" ] && echo \"$domain\" || echo \"$lowest\"\n}\n\nfunction get_password() {\n # Check whether our local salt is present.\n SALT=/var/lib/radom_salt\n if [ ! -f \"$SALT\" ]\n then\n head -c 512 /dev/urandom > \"$SALT\"\n chmod 400 \"$SALT\"\n fi\n password=`(cat \"$SALT\"; echo $1) | md5sum | base64`\n echo ${password:0:13}\n}\n\nfunction install_dash {\n check_install dash dash\n rm -f /bin/sh\n ln -s dash /bin/sh\n}\n\nfunction install_dropbear {\n check_install dropbear dropbear\n check_install /usr/sbin/xinetd xinetd\n\n # Disable SSH\n touch /etc/ssh/sshd_not_to_be_run\n invoke-rc.d ssh stop\n\n # Enable dropbear to start. We are going to use xinetd as it is just\n # easier to configure and might be used for other things.\n cat > /etc/xinetd.d/dropbear < /etc/mysql/conf.d/lowendbox.cnf < ~/.my.cnf < /etc/nginx/conf.d/lowendbox.conf < /etc/init.d/php-cgi <&2\n exit 1\n ;;\nesac\nexit 0\nEND\n chmod 755 /etc/init.d/php-cgi\n mkdir -p /var/run/www\n chown www-data:www-data /var/run/www\n\n cat > /etc/nginx/fastcgi_php < /etc/syslog.conf < /etc/logrotate.d/inetutils-syslogd </dev/null\n endscript\n}\nEND\n\n invoke-rc.d inetutils-syslogd start\n}\n\nfunction install_wordpress {\n check_install wget wget\n if [ -z \"$1\" ]\n then\n die \"Usage: `basename $0` wordpress \"\n fi\n\n # Downloading the WordPress' latest and greatest distribution.\n mkdir /tmp/wordpress.$$\n wget -O - http://wordpress.org/latest.tar.gz | \\\n tar zxf - -C /tmp/wordpress.$$\n mv /tmp/wordpress.$$/wordpress \"/var/www/$1\"\n rm -rf /tmp/wordpress.$$\n chown root:root -R \"/var/www/$1\"\n\n # Setting up the MySQL database\n dbname=`echo $1 | tr . _`\n userid=`get_domain_name $1`\n # MySQL userid cannot be more than 15 characters long\n userid=\"${userid:0:15}\"\n passwd=`get_password \"$userid@mysql\"`\n cp \"/var/www/$1/wp-config-sample.php\" \"/var/www/$1/wp-config.php\"\n sed -i \"s/database_name_here/$dbname/; s/username_here/$userid/; s/password_here/$passwd/\" \\\n \"/var/www/$1/wp-config.php\"\n mysqladmin create \"$dbname\"\n echo \"GRANT ALL PRIVILEGES ON \\`$dbname\\`.* TO \\`$userid\\`@localhost IDENTIFIED BY '$passwd';\" | \\\n mysql\n\n # Setting up Nginx mapping\n cat > \"/etc/nginx/sites-enabled/$1.conf\" <&2\n exit 1\nfi\n\nfunction check_install {\n if [ -z \"`which \"$1\" 2>/dev/null`\" ]\n then\n executable=$1\n shift\n while [ -n \"$1\" ]\n do\n DEBIAN_FRONTEND=noninteractive apt-get -q -y install \"$1\"\n print_info \"$1 installed for $executable\"\n shift\n done\n else\n print_warn \"$2 already installed\"\n fi\n}\n\nfunction check_remove {\n if [ -n \"`which \"$1\" 2>/dev/null`\" ]\n then\n DEBIAN_FRONTEND=noninteractive apt-get -q -y remove --purge \"$2\"\n print_info \"$2 removed\"\n else\n print_warn \"$2 is not installed\"\n fi\n}\n\nfunction check_sanity {\n # Do some sanity checking.\n if [ $(/usr/bin/id -u) != \"0\" ]\n then\n die 'Must be run by root user'\n fi\n\n if [ ! -f /etc/debian_version ]\n then\n die \"Distribution is not supported\"\n fi\n}\n\nfunction die {\n echo \"ERROR: $1\" > /dev/null 1>&2\n exit 1\n}\n\nfunction get_domain_name() {\n # Getting rid of the lowest part.\n domain=${1%.*}\n lowest=`expr \"$domain\" : '.*\\.\\([a-z][a-z]*\\)'`\n case \"$lowest\" in\n com|net|org|gov|edu|co)\n domain=${domain%.*}\n ;;\n esac\n lowest=`expr \"$domain\" : '.*\\.\\([a-z][a-z]*\\)'`\n [ -z \"$lowest\" ] && echo \"$domain\" || echo \"$lowest\"\n}\n\nfunction get_password() {\n # Check whether our local salt is present.\n SALT=/var/lib/radom_salt\n if [ ! -f \"$SALT\" ]\n then\n head -c 512 /dev/urandom > \"$SALT\"\n chmod 400 \"$SALT\"\n fi\n password=`(cat \"$SALT\"; echo $1) | md5sum | base64`\n echo ${password:0:13}\n}\n\nfunction install_dash {\n check_install dash dash\n rm -f /bin/sh\n ln -s dash /bin/sh\n}\n\nfunction install_htop {\n check_install htop htop\n}\n\nfunction install_smart {\n\tcheck_install smartmontools smartmontools\n}\n\nfunction install_locate {\n check_install locate locate\n}\n\nfunction fix_locale {\n dpkg-reconfigure locales\n}\n\nfunction var_www {\n mkdir -p /var/www/\n}\n\nfunction install_dropbear {\n check_install dropbear dropbear\n check_install /usr/sbin/xinetd xinetd\n\n # Disable SSH\n touch /etc/ssh/sshd_not_to_be_run\n invoke-rc.d ssh stop\n\n # Enable dropbear to start. We are going to use xinetd as it is just\n # easier to configure and might be used for other things.\n cat > /etc/xinetd.d/dropbear < /etc/mysql/conf.d/lowendbox.cnf < ~/.my.cnf < /etc/nginx/conf.d/lowendbox.conf < /etc/init.d/php-cgi <&2\n exit 1\n ;;\nesac\nexit 0\nEND\n chmod 755 /etc/init.d/php-cgi\n mkdir -p /var/lib/www\n chown www-data:www-data /var/lib/www\n\n cat > /etc/nginx/fastcgi_php < /etc/syslog.conf < /etc/logrotate.d/inetutils-syslogd </dev/null\n endscript\n}\nEND\n\n invoke-rc.d inetutils-syslogd start\n}\n\nfunction install_wordpress {\n# Needs fixing, soon!!!\n check_install wget wget\n if [ -z \"$1\" ]\n then\n die \"Usage: `basename $0` wordpress \"\n fi\n\n # Downloading the WordPress' latest and greatest distribution.\n mkdir /tmp/wordpress.$$\n wget -O - http://wordpress.org/latest.tar.gz | \\\n tar zxf - -C /tmp/wordpress.$$\n\tmkdir -p /var/www/$1\n mv /tmp/wordpress.$$/wordpress/* \"/var/www/$1\"\n rm -rf /tmp/wordpress.$$\n chown root:root -R \"/var/www/$1\"\n\n # Setting up the MySQL database\n dbname=`echo $1 | tr . _`\n\techo Database Name = 'echo $1 | tr . _'\n userid=`get_domain_name $1`\n # MySQL userid cannot be more than 15 characters long\n userid=\"${userid:0:15}\"\n passwd=`get_password \"$userid@mysql\"`\n cp \"/var/www/$1/wp-config-sample.php\" \"/var/www/$1/wp-config.php\"\n sed -i \"s/database_name_here/$dbname/; s/username_here/$userid/; s/password_here/$passwd/\" \\\n \"/var/www/$1/wp-config.php\"\n mysqladmin create \"$dbname\"\n echo \"GRANT ALL PRIVILEGES ON \\`$dbname\\`.* TO \\`$userid\\`@localhost IDENTIFIED BY '$passwd';\" | \\\n mysql\n\n # Setting up Nginx mapping\n cat > \"/etc/nginx/sites-enabled/$1.conf\" < \"/usr/share/nginx/www/$1/index.html\" < \"/etc/nginx/sites-enabled/$1.conf\" <\"\n fi\n\t\n\t#Download PHP5-gd package\n\tapt-get -q -y install php5-gd\n /etc/init.d/php-cgi restart\n\t\n # Downloading the Drupal' latest and greatest distribution.\n mkdir /tmp/drupal.$$\n wget -O - http://ftp.drupal.org/files/projects/drupal-6.30.tar.gz | \\\n tar zxf - -C /tmp/drupal.$$/\n mkdir -p /var/www/$1\n cp -Rf /tmp/drupal.$$/drupal*/* \"/var/www/$1\"\n rm -rf /tmp/drupal*\n chown root:root -R \"/var/www/$1\"\n\n # Setting up the MySQL database\n dbname=`echo $1 | tr . _`\n\t\n\t# MySQL dbname cannot be more than 15 characters long\n dbname=\"${dbname:0:15}\"\n \n\tuserid=`get_domain_name $1`\n \n\t# MySQL userid cannot be more than 15 characters long\n userid=\"${userid:0:15}\"\n passwd=`get_password \"$userid@mysql\"`\n cp \"/var/www/$1/sites/default/default.settings.php\" \"/var/www/$1/sites/default/settings.php\"\n\tchmod 777 /var/www/$1/sites/default/settings.php\n\tmkdir /var/www/$1/sites/default/files\n\tchmod -R 777 /var/www/$1/sites/default/files\n mysqladmin create \"$dbname\"\n echo \"GRANT ALL PRIVILEGES ON \\`$dbname\\`.* TO \\`$userid\\`@localhost IDENTIFIED BY '$passwd';\" | \\\n mysql\n\n\t#Copy DB Name, User, and Pass to settings.php and set to read only.\n\tsed -i \"91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/\" \"/var/www/$1/sites/default/settings.php\"\n\tchmod 644 /var/www/$1/sites/default/settings.php\n \n\t# Setting up Nginx mapping\n cat > \"/etc/nginx/sites-enabled/$1.conf\" <\"\n fi\n\t\n\t#Download PHP5-gd package\n\tapt-get -q -y install php5-gd\n /etc/init.d/php-cgi restart\n\t\n # Downloading the Drupal' latest and greatest distribution.\n mkdir /tmp/drupal.$$\n wget -O - http://ftp.drupal.org/files/projects/drupal-7.26.tar.gz | \\\n tar zxf - -C /tmp/drupal.$$/\n mkdir -p /var/www/$1\n cp -Rf /tmp/drupal.$$/drupal*/* \"/var/www/$1\"\n rm -rf /tmp/drupal*\n chown root:root -R \"/var/www/$1\"\n\n # Setting up the MySQL database\n dbname=`echo $1 | tr . _`\n\t\n\t# MySQL dbname cannot be more than 15 characters long\n dbname=\"${dbname:0:15}\"\n\t\n userid=`get_domain_name $1`\n\t\n # MySQL userid cannot be more than 15 characters long\n userid=\"${userid:0:15}\"\n passwd=`get_password \"$userid@mysql\"`\n\t\n\t# Copy default.settings.php to settings.php and set write permissions.\n cp \"/var/www/$1/sites/default/default.settings.php\" \"/var/www/$1/sites/default/settings.php\"\n\tchmod 777 /var/www/$1/sites/default/settings.php\n\tmkdir /var/www/$1/sites/default/files\n\tchmod -R 777 /var/www/$1/sites/default/files\n \n\t# Create MySQL database\n\tmysqladmin create \"$dbname\"\n echo \"GRANT ALL PRIVILEGES ON \\`$dbname\\`.* TO \\`$userid\\`@localhost IDENTIFIED BY '$passwd';\" | \\\n mysql\n\t\t\n #Copy DB Name, User, and Pass to settings.php and set to read only.\n echo \"\\$databases['default']['default'] = array(\" >> /var/www/$1/sites/default/settings.php\n echo \"'driver' => 'mysql',\" >> /var/www/$1/sites/default/settings.php\n echo \"'database' => '$dbname',\" >> /var/www/$1/sites/default/settings.php\n echo \"'username' => '$userid',\" >> /var/www/$1/sites/default/settings.php\n echo \"'password' => '$passwd',\" >> /var/www/$1/sites/default/settings.php\n echo \"'host' => 'localhost');\" >> /var/www/$1/sites/default/settings.php\n chmod 644 /var/www/$1/sites/default/settings.php\n\t\n\t#Echo DB Name\n\techo -e $COL_BLUE\"*** COPY FOR SAFE KEEPING ***\"\n\tCOL_BLUE=\"\\x1b[34;01m\"\n COL_RESET=\"\\x1b[39;49;00m\"\n echo -e $COL_BLUE\"Database Name: \"$COL_RESET\"$dbname\"\n\t\n #Echo DB User value\n\techo -e $COL_BLUE\"Database User: \"$COL_RESET\"${userid:0:15}\"\n\t\n\t#Echo DB Password\n\techo -e $COL_BLUE\"Database Password: \"$COL_RESET\"$passwd\"\n\t\n\t#Echo Install URL\n\techo -e $COL_BLUE\"Visit to finalize installation: \"$COL_RESET\"http://$1/install.php\"\n\t\n\n\n # Setting up Nginx mapping\n cat > \"/etc/nginx/sites-enabled/$1.conf\" <args = $args;\n\t\t\n\t\tif (!$this->args[\"username\"]){\n\t\t\tthrow new exception(\"No username was given.\");\n\t\t}\n\t\t\n\t\tif (!$this->args[\"password\"]){\n\t\t\tthrow new exception(\"No password was given.\");\n\t\t}\n\t\t\n\t\trequire_once \"knj/http.php\";\n\t\t$this->http = new knj_httpbrowser();\n\t\t$this->http->connect(\"betaling.wannafind.dk\", 443);\n\t\t\n\t\t$html = $this->http->getaddr(\"index.php\");\n\t\t\n\t\t$html = $this->http->post(\"pg.loginauth.php\", array(\n\t\t\t\"username\" => $this->args[\"username\"],\n\t\t\t\"password\" => $this->args[\"password\"]\n\t\t));\n\t\t\n\t\tif (strpos($html, \"Brugernavn eller password, blev ikke godkendt.\") !== false){\n\t\t\tthrow new exception(\"Could not log in.\");\n\t\t}\n\t}\n\t\n\tfunction http(){\n\t\treturn $this->http;\n\t}\n\t\n\tfunction listPayments($args = array()){\n\t\tif ($args[\"awaiting\"]){\n\t\t\t$html = $this->http->getaddr(\"pg.frontend/pg.transactions.php\");\n\t\t}else{\n\t\t\t$sargs = array(\n\t\t\t\t\"searchtype\" => \"\",\n\t\t\t\t\"fromday\" => \"01\",\n\t\t\t\t\"frommonth\" => \"01\",\n\t\t\t\t\"fromyear\" => date(\"Y\"),\n\t\t\t\t\"today\" => \"31\",\n\t\t\t\t\"tomonth\" => \"12\",\n\t\t\t\t\"toyear\" => date(\"Y\"),\n\t\t\t\t\"transacknum\" => \"\"\n\t\t\t);\n\t\t\t\n\t\t\tif ($args[\"order_id\"]){\n\t\t\t\t$sargs[\"orderid\"] = $args[\"order_id\"];\n\t\t\t}\n\t\t\t\n\t\t\t$html = $this->http->post(\"pg.frontend/pg.search.php?search=doit\", $sargs);\n\t\t}\n\t\t\n\t\tif (!preg_match_all(\"/([0-9]+)<\\/a><\\/td>\\s*(.+)<\\/td>\\s*(.+)<\\/td>\\s*(.+)<\\/td>\\s*.*<\\/td>\\s*(.*)<\\/td>\\s*(.*)<\\/td>/U\", $html, $matches)){\n\t\t\treturn array(); //no payments were found - return empty array.\n\t\t\t//echo $html . \"\\n\\n\";\n\t\t\tthrow new exception(\"Could not parse payments.\");\n\t\t}\n\t\t\n\t\t$payments = array();\n\t\tforeach($matches[0] AS $key => $value){\n\t\t\t$id = $matches[1][$key];\n\t\t\t\n\t\t\t$amount = str_replace(\" DKK\", \"\", $matches[6][$key]);\n\t\t\t$amount = strtr($amount, array(\n\t\t\t\t\".\" => \"\",\n\t\t\t\t\",\" => \".\"\n\t\t\t));\n\t\t\t\n\t\t\t$card_type = $matches[7][$key];\n\t\t\tif (strpos($card_type, \"dk.png\") !== false){\n\t\t\t\t$card_type = \"dk\";\n\t\t\t}elseif(strpos($card_type, \"visa-elec.png\") !== false){\n\t\t\t\t$card_type = \"visa_electron\";\n\t\t\t}elseif(strpos($card_type, \"mc.png\") !== false){\n\t\t\t\t$card_type = \"mastercard\";\n\t\t\t}elseif(strpos($card_type, \"visa.png\") !== false){\n\t\t\t\t$card_type = \"visa\";\n\t\t\t}else{\n\t\t\t\tthrow new exception(\"Unknown card-type image: \" . $card_type);\n\t\t\t}\n\t\t\t\n\t\t\t$date = strtr($matches[5][$key], array(\n\t\t\t\t\"januar\" => 1,\n\t\t\t\t\"februar\" => 2,\n\t\t\t\t\"marts\" => 3,\n\t\t\t\t\"april\" => 4,\n\t\t\t\t\"maj\" => 5,\n\t\t\t\t\"juni\" => 6,\n\t\t\t\t\"juli\" => 7,\n\t\t\t\t\"august\" => 8,\n\t\t\t\t\"september\" => 9,\n\t\t\t\t\"oktober\" => 10,\n\t\t\t\t\"november\" => 11,\n\t\t\t\t\"december\" => 12\n\t\t\t));\n\t\t\t\n\t\t\tif (preg_match(\"/(\\d+) (\\d+) (\\d+) (\\d+):(\\d+):(\\d+)/\", $date, $match)){\n\t\t\t\t$unixt = mktime($match[4], $match[5], $match[6], $match[2], $match[1], $match[3]);\n\t\t\t}elseif(preg_match(\"/(\\d+) ([a-z]{3}) (\\d{4}) (\\d{2}):(\\d{2}):(\\d{2})/\", $date, $match)){\n\t\t\t\t$month = $match[2];\n\t\t\t\tif ($month == \"jan\"){\n\t\t\t\t\t$month_no = 1;\n\t\t\t\t}elseif($month == \"feb\"){\n\t\t\t\t\t$month_no = 2;\n\t\t\t\t}elseif($month == \"mar\"){\n\t\t\t\t\t$month_no = 3;\n\t\t\t\t}elseif($month == \"apr\"){\n\t\t\t\t\t$month_no = 4;\n\t\t\t\t}elseif($month == \"maj\"){\n\t\t\t\t\t$month_no = 5;\n\t\t\t\t}elseif($month == \"jun\"){\n\t\t\t\t\t$month_no = 6;\n\t\t\t\t}elseif($month == \"jul\"){\n\t\t\t\t\t$month_no = 7;\n\t\t\t\t}elseif($month == \"aug\"){\n\t\t\t\t\t$month_no = 8;\n\t\t\t\t}elseif($month == \"sep\"){\n\t\t\t\t\t$month_no = 9;\n\t\t\t\t}elseif($month == \"okt\"){\n\t\t\t\t\t$month_no = 10;\n\t\t\t\t}elseif($month == \"nov\"){\n\t\t\t\t\t$month_no = 11;\n\t\t\t\t}elseif($month == \"dec\"){\n\t\t\t\t\t$month_no = 12;\n\t\t\t\t}else{\n\t\t\t\t\tthrow new exception(\"Unknown month string: \" . $month);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t$unixt = mktime($match[4], $match[5], $match[6], $month_no, $match[1], $match[3]);\n\t\t\t}else{\n\t\t\t\tthrow new exception(\"Could not parse date: \" . $date);\n\t\t\t}\n\t\t\t\n\t\t\t$state = $matches[8][$key];\n\t\t\tif ($state == \"Gennemf\u00f8rt\"){\n\t\t\t\t$state = \"done\";\n\t\t\t}elseif(strpos($state, \"Gennemf\u00f8r\") !== false){\n\t\t\t\t$state = \"waiting\";\n\t\t\t}elseif($state == \"Annulleret\"){\n\t\t\t\t$state = \"canceled\";\n\t\t\t}elseif($state == \"Refunderet\"){\n\t\t\t\t$state = \"returned\";\n\t\t\t}else{\n\t\t\t\tthrow new exception(\"Unknown state: \" . $state);\n\t\t\t}\n\t\t\t\n\t\t\tif ($this->payments[$id]){\n\t\t\t\t$payment = $this->payments[$id];\n\t\t\t\t$payment->set(\"state\", $state);\n\t\t\t}else{\n\t\t\t\t$payment = new wfpayment_payment($this, array(\n\t\t\t\t\t\"id\" => $id,\n\t\t\t\t\t\"order_id\" => substr($matches[4][$key], 4),\n\t\t\t\t\t\"customer_id\" => $matches[3][$key],\n\t\t\t\t\t\"customer_string\" => $matches[4][$key],\n\t\t\t\t\t\"date\" => $unixt,\n\t\t\t\t\t\"amount\" => $amount,\n\t\t\t\t\t\"card_type\" => $card_type,\n\t\t\t\t\t\"state\" => $state\n\t\t\t\t));\n\t\t\t}\n\t\t\t\n\t\t\t$payments[] = $payment;\n\t\t}\n\t\t\n\t\treturn $payments;\n\t}\n}\n\nclass wfpayment_payment{\n\tfunction __construct($wfpayment, $args){\n\t\t$this->wfpayment = $wfpayment;\n\t\t$this->http = $this->wfpayment->http();\n\t\t$this->args = $args;\n\t}\n\t\n\tfunction set($key, $value){\n\t\t$this->args[$key] = $value;\n\t}\n\t\n\tfunction get($key){\n\t\tif (!array_key_exists($key, $this->args)){\n\t\t\tthrow new exception(\"No such key: \" . $key);\n\t\t}\n\t\t\n\t\treturn $this->args[$key];\n\t}\n\t\n\tfunction args(){\n\t\treturn $this->args;\n\t}\n\t\n\tfunction accept(){\n\t\tif ($this->state() == \"done\"){\n\t\t\tthrow new exception(\"This payment is already accepted.\");\n\t\t}\n\t\t\n\t\t$html = $this->http->getaddr(\"pg.frontend/pg.transactions.php?capture=singlecapture&transid=\" . $this->get(\"id\") . \"&page=1&orderby=&direction=\");\n\t\t\n\t\tif ($this->state() != \"done\"){\n\t\t\tthrow new exception(\"Could not accept the payment. State: \" . $this->state());\n\t\t}\n\t}\n\t\n\tfunction cancel(){\n\t\tif ($this->state() != \"waiting\"){\n\t\t\tthrow new exception(\"This is not waiting and cannot be canceled.\");\n\t\t}\n\t\t\n\t\t$html = $this->http->getaddr(\"pg.frontend/pg.transactionview.php?action=cancel&id=\" . $this->get(\"id\") . \"&page=1\");\n\t\t\n\t\tif ($this->state() != \"canceled\"){\n\t\t\tthrow new exception(\"Could not cancel the payment.\");\n\t\t}\n\t}\n\t\n\tfunction state(){\n\t\t$payments = $this->wfpayment->listPayments(array(\"order_id\" => $this->get(\"order_id\")));\n\t\tif (!$payments or !$payments[0]){\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\treturn $payments[0]->get(\"state\");\n\t}\n}", "strings.php": "\n\nclass knj_strings{\n\tstatic function substr($string, $len1, $len2){\n\t\t$string = utf8_decode($string);\n\t\t$string = substr($string, $len1, $len2);\n\t\t$string = utf8_encode($string);\n\t\treturn $string;\n\t}\n\t\n\tstatic function utf8wrapper($func, $arg1){\n\t\treturn utf8_encode(call_user_func($func, utf8_decode($arg1)));\n\t}\n\t\n\tstatic function utf8force($string){\n\t\t$values = array();\n\t\t$special = array(\"\u00f8\", \"\u00e6\", \"\u00e5\", \"\u00d8\", \"\u00c6\", \"\u00c5\");\n\t\tforeach($special AS $value){\n\t\t\t$values[utf8_decode($value)] = $value;\n\t\t}\n\t\t\n\t\t$string = str_replace(\"\u00c3\u00a6\", \"\u00e6\", $string);\n\t\t\n\t\treturn strtr($string, $values);\n\t}\n\t\n\t/** Parses a string into an array of strings, which should all be searched for. */\n\tstatic function searchstring($string){\n\t\t$array = array();\n\t\t\n\t\tif (preg_match_all(\"/\\\"(.*)\\\"/U\", $string, $matches)){\n\t\t\tforeach($matches[1] AS $key => $value){\n\t\t\t\t$array[] = $value;\n\t\t\t\t$string = str_replace($matches[0][$key], \"\", $string);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (strlen($string) > 0){\n\t\t\tforeach(preg_split(\"/\\s/\", $string) AS $value){\n\t\t\t\tif (strlen(trim($value)) > 0){\n\t\t\t\t\t$array[] = $value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn $array;\n\t}\n\t\n\tstatic function parseImageHTML($content){\n\t\tif (preg_match_all(\"//U\", $content, $matches)){\n\t\t\tforeach($matches[0] AS $key => $value){\n\t\t\t\t$img_html = $value;\n\t\t\t\t\n\t\t\t\tif (preg_match(\"/src=\\\"([\\s\\S]+)\\\"/U\", $img_html, $match_src)){\n\t\t\t\t\t$src = $match_src[1];\n\t\t\t\t\tif (substr($src, 0, 1) == \"/\"){\n\t\t\t\t\t\t$src = substr($src, 1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t$replace_with = \"image.php?picture=\" . $src;\n\t\t\t\t\t\n\t\t\t\t\tif (preg_match(\"/width: ([0-9]+)(px|)/\", $img_html, $match_width)){\n\t\t\t\t\t\t$size[\"width\"] = $match_width[1];\n\t\t\t\t\t\t$replace_with .= \"&width=\" . $match_width[1];\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (preg_match(\"/height: ([0-9]+)(px|)/\", $img_html, $match_height)){\n\t\t\t\t\t\t$size[\"height\"] = $match_height[1];\n\t\t\t\t\t\t$replace_with .= \"&height=\" . $match_width[1];\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (preg_match_all(\"/(width|height)=\\\"([0-9]+)(px|)\\\"/\", $img_html, $match_sizes)){\n\t\t\t\t\t\t$size = array();\n\t\t\t\t\t\tforeach($match_sizes[1] AS $key => $sizetype){\n\t\t\t\t\t\t\tif (!$size[$sizetype]){\n\t\t\t\t\t\t\t\t$size[$sizetype] = $match_sizes[2][$key];\n\t\t\t\t\t\t\t\t$replace_with .= \"&\" . $sizetype . \"=\" . $match_sizes[2][$key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif ($size){\n\t\t\t\t\t\t$img_html = str_replace($src, $replace_with, $img_html);\n\t\t\t\t\t\t$content = str_replace($value, $img_html, $content);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn $content;\n\t}\n\t\n\tstatic function UnixSafe($string){\n\t\t$string = str_replace(\"\\\\\", \"\\\\\\\\\", $string);\n\t\t$string = str_replace(\" \", \"\\\\ \", $string);\n\t\t$string = str_replace(\"\\$\", \"\\\\\\$\", $string);\n\t\t$string = str_replace(\"(\", \"\\\\(\", $string);\n\t\t$string = str_replace(\")\", \"\\\\)\", $string);\n\t\t$string = str_replace(\";\", \"\\\\;\", $string);\n\t\t$string = str_replace(\",\", \"\\\\,\", $string);\n\t\t$string = str_replace(\"'\", \"\\\\'\", $string);\n\t\t$string = str_replace(\">\", \"\\\\>\", $string);\n\t\t$string = str_replace(\"<\", \"\\\\<\", $string);\n\t\t$string = str_replace(\"\\\"\", \"\\\\\\\"\", $string);\n\t\t$string = str_replace(\"&\", \"\\\\&\", $string);\n\t\t\n\t\t//Replace the end & - if any.\n\t\t//$string = preg_replace(\"/&\\s*$/\", \"\\\\&\", $string);\n\t\t\n\t\treturn $string;\n\t}\n\t\n\tstatic function RegexSafe($string){\n\t\treturn strtr($string, array(\n\t\t\t\"/\" => \"\\\\/\",\n\t\t\t\".\" => \"\\\\.\",\n\t\t\t\"(\" => \"\\\\(\",\n\t\t\t\")\" => \"\\\\)\",\n\t\t\t\"[\" => \"\\\\[\",\n\t\t\t\"]\" => \"\\\\]\",\n\t\t\t\"^\" => \"\\\\^\",\n\t\t\t\"\\$\" => \"\\\\\\$\",\n\t\t\t\"+\" => \"\\\\+\"\n\t\t));\n\t}\n\t\n\tstatic function HeaderSafe($string){\n\t\treturn strtr($string, array(\n\t\t\t\"\\r\" => \"\",\n\t\t\t\"\\n\" => \" \"\n\t\t));\n\t}\n\t\n\tstatic function csvsafe($string){\n\t\t$string = htmlspecialchars($string);\n\t\t$string = str_replace(\"\\\"\", \"\", $string);\n\t\t$string = str_replace(\""\", \"\", $string);\n\t\t$string = str_replace(\"&\", \"&\", $string);\n\t\t$string = str_replace(\"\\r\", \"\", $string);\n\t\t$string = str_replace(\"\\n\", \"\", $string);\n\t\t$string = str_replace(\"<\", \"<\", $string);\n\t\t$string = str_replace(\">\", \">\", $string);\n\t\t\n\t\treturn $string;\n\t}\n\t\n\tstatic function htmlspecialchars_textarea($text){\n\t\treturn preg_replace(\"/<\\/textarea>/i\", \"</textarea>\", $text);\n\t}\n\t\n\tstatic function jsparse($string, $paras = array()){\n\t\t$string = strtr($string, array(\n\t\t\t\"'\" => \"\\\\'\",\n\t\t\t\"\\\"\" => \""\",\n\t\t\t\"\\r\" => \"\",\n\t\t\t\"\\n\" => \"\\\\n\"\n\t\t));\n\t\t\n\t\tif ($paras[\"parse_quotes\"]){\n\t\t\t$string = str_replace(\"\\\"\", \"\\\\\\\"\", $string);\n\t\t}\n\t\t\n\t\treturn $string;\n\t}\n\t\n\tstatic function tf_str($value, $yesstr, $nostr){\n\t\tif ($value){\n\t\t\treturn $yesstr;\n\t\t}\n\t\t\n\t\treturn $nostr;\n\t}\n\t\n\tstatic function shorten($text, $maxlength = nil){\n\t\tif (!$maxlength or strlen($text) <= $maxlength){\n\t\t\treturn $text;\n\t\t}\n\t\t\n\t\treturn trim(substr($text, 0, $maxlength)) . \"...\";\n\t}\n\t\n\tstatic function is_email($str){\n\t\tif (preg_match(\"/^(.+)@(.+)\\.(.+)/\", $str)){\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n}\n\n/**\n\t* Parses the quotes of a string.\n\t* \n\t* FIXME: DONT USE THIS FUNCTION! It will be removed soon... Look in the SQL-functions instead.\n*/\nfunction parse_quotes($string){\n\t$string = str_replace(\"'\", \"\\\\'\", $string);\n\t\n\tif (substr($string, -1, 1) == \"\\\\\" && substr($string, -2, 2) !== \"\\\\\\\\\"){\n\t\t$string = substr($string, 0, -1) . \"\\\\\\\\\";\n\t}\n\t\n\treturn $string;\n}\n\n/** Parse a string so it fits into the command-line of Linux. */\nfunction knj_string_unix_safe($string){\n\treturn knj_strings::UnixSafe($string);\n}\n\n/** Parse a string so it will be a valid filename. */\nfunction knj_string_filename($string, $os = null){\n\tif (!$os){\n\t\trequire_once(\"knj/os.php\");\n\t\t$os = knj_os::getOS();\n\t\t$os = $os[\"os\"];\n\t}\n\t\n\tif ($os == \"windows\"){\n\t\t//parse windows-filename here.\n\t}elseif($os == \"linux\"){\n\t\t$string = strtr($string, array(\n\t\t\t\"\u00e5\" => \"aa\",\n\t\t\t\"\u00f8\" => \"oe\",\n\t\t\t\"\u00e6\" => \"ae\",\n\t\t\tutf8_decode(\"\u00e5\") => \"aa\",\n\t\t\tutf8_decode(\"\u00e6\") => \"ae\",\n\t\t\tutf8_decode(\"\u00f8\") => \"oe\",\n\t\t\t\"|\" => \"\",\n\t\t\t\"&\" => \"\",\n\t\t\t\"/\" => \"\",\n\t\t\t\"\\\\\" => \"\"\n\t\t));\n\t}else{\n\t\tthrow new Exception(\"Unsupported OS.\");\n\t}\n\t\n\treturn $string;\n}\n\n/** Parse a string to it is safe in a regex-command. */\nfunction knj_string_regex($string){\n\treturn knj_strings::RegexSafe($string);\n}", "epay.php": "\n\nclass epay{\n\tprivate $payments = array();\n\t\n\tfunction __construct($args){\n\t\t$this->args = $args;\n\t\t\n\t\tif (!$this->args[\"username\"]){\n\t\t\tthrow new exception(\"No username was given.\");\n\t\t}\n\t\t\n\t\tif (!$this->args[\"password\"]){\n\t\t\tthrow new exception(\"No password was given.\");\n\t\t}\n\t\t\n\t\t$this->soap_client = new SoapClient(\"https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL\", array(\n\t\t\t\"verify_peer\" => false,\n\t\t\t\"allow_self_signed\" => true\n\t\t));\n\t}\n\t\n\tfunction transactions($args = array()){\n\t\t$res = $this->soap_client->__soapCall(\"gettransactionlist\", array(\"parameters\" => array_merge($args, array(\n\t\t\t\"merchantnumber\" => $this->args[\"merchant_no\"]\n\t\t))));\n\t\t$ret = array();\n\t\t\n\t\tif (is_array($res->transactionInformationAry->TransactionInformationType)){\n\t\t\tforeach($res->transactionInformationAry->TransactionInformationType as $trans_obj){\n\t\t\t\t$ret[] = new epay_payment(array(\n\t\t\t\t\t\"epay\" => $this,\n\t\t\t\t\t\"obj\" => $trans_obj,\n\t\t\t\t\t\"soap_client\" => $this->soap_client\n\t\t\t\t));\n\t\t\t}\n\t\t}elseif($res->transactionInformationAry->TransactionInformationType){\n\t\t\t$ret[] = new epay_payment(array(\n\t\t\t\t\"epay\" => $this,\n\t\t\t\t\"obj\" => $res->transactionInformationAry->TransactionInformationType,\n\t\t\t\t\"soap_client\" => $this->soap_client\n\t\t\t));\n\t\t}\n\t\t\n\t\treturn $ret;\n\t}\n\t\n\tfunction transaction($args = array()){\n\t\t$res = $this->soap_client->__soapCall(\"gettransaction\", array(\"parameters\" => array_merge($args, array(\n\t\t\t\"merchantnumber\" => $this->args[\"merchant_no\"],\n\t\t\t\"epayresponse\" => true\n\t\t))));\n\t\t\n\t\treturn new epay_payment(array(\n\t\t\t\"epay\" => $this,\n\t\t\t\"obj\" => $res->transactionInformation,\n\t\t\t\"soap_client\" => $this->soap_client\n\t\t));\n\t}\n}\n\nclass epay_payment{\n\tfunction __construct($args){\n\t\t$this->args = $args;\n\t\t$this->soap_client = $args[\"soap_client\"];\n\t\t\n\t\t$this->data = array(\n\t\t\t\"amount\" => floatval($args[\"obj\"]->authamount),\n\t\t\t\"orderid\" => intval($args[\"obj\"]->orderid),\n\t\t\t\"status\" => $args[\"obj\"]->status,\n\t\t\t\"transactionid\" => $args[\"obj\"]->transactionid\n\t\t);\n\t}\n\t\n\tfunction get($key){\n\t\tif ($key == \"id\"){\n\t\t\t$key = \"transactionid\";\n\t\t}\n\t\t\n\t\tif (!array_key_exists($key, $this->data)){\n\t\t\tthrow new exception(\"No such key: \" . $key);\n\t\t}\n\t\t\n\t\treturn $this->data[$key];\n\t}\n\t\n\tfunction args(){\n\t\treturn $this->args;\n\t}\n\t\n\tfunction accept(){\n\t\tif ($this->data[\"status\"] == \"PAYMENT_CAPTURED\"){\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t$res = $this->soap_client->__soapCall(\"capture\", array(\"parameters\" => array(\n\t\t\t\"merchantnumber\" => $this->args[\"epay\"]->args[\"merchant_no\"],\n\t\t\t\"transactionid\" => $this->data[\"transactionid\"],\n\t\t\t\"amount\" => $this->data[\"amount\"],\n\t\t\t\"epayresponse\" => true,\n\t\t\t\"pbsResponse\" => true\n\t\t)));\n\t\t\n\t\tif (!$res->captureResult){\n\t\t\tthrow new exception(\"Could not accept payment.\\n\\n\" . print_r($res, true));\n\t\t}\n\t}\n\t\n\tfunction delete(){\n\t\t$res = $this->soap_client->__soapCall(\"delete\", array(\"parameters\" => array(\n\t\t\t\"merchantnumber\" => $this->args[\"epay\"]->args[\"merchant_no\"],\n\t\t\t\"transactionid\" => $this->data[\"transactionid\"],\n\t\t\t\"epayresponse\" => true\n\t\t)));\n\t\t\n\t\tif (!$res->deleteResult){\n\t\t\tthrow new exception(\"Could not delete payment.\\n\\n\" . print_r($res, true));\n\t\t}\n\t}\n\t\n\tfunction state(){\n\t\tthrow new exception(\"stub!\");\n\t}\n}"}, "files_after": {"wfpayment.php": "\n\nclass wfpayment{\n\tprivate $payments = array();\n\t\n\tfunction __construct($args){\n\t\t$this->args = $args;\n\t\t\n\t\tif (!$this->args[\"username\"]){\n\t\t\tthrow new exception(\"No username was given.\");\n\t\t}\n\t\t\n\t\tif (!$this->args[\"password\"]){\n\t\t\tthrow new exception(\"No password was given.\");\n\t\t}\n\t\t\n\t\trequire_once \"knj/http.php\";\n\t\t$this->http = new knj_httpbrowser();\n\t\t$this->http->connect(\"betaling.wannafind.dk\", 443);\n\t\t\n\t\t$html = $this->http->getaddr(\"index.php\");\n\t\t\n\t\t$html = $this->http->post(\"pg.loginauth.php\", array(\n\t\t\t\"username\" => $this->args[\"username\"],\n\t\t\t\"password\" => $this->args[\"password\"]\n\t\t));\n\t\t\n\t\tif (strpos($html, \"Brugernavn eller password, blev ikke godkendt.\") !== false){\n\t\t\tthrow new exception(\"Could not log in.\");\n\t\t}\n\t}\n\t\n\tfunction http(){\n\t\treturn $this->http;\n\t}\n\t\n\tfunction listPayments($args = array()){\n\t\tif ($args[\"awaiting\"]){\n\t\t\t$html = $this->http->getaddr(\"pg.frontend/pg.transactions.php\");\n\t\t}else{\n\t\t\t$sargs = array(\n\t\t\t\t\"searchtype\" => \"\",\n\t\t\t\t\"fromday\" => \"01\",\n\t\t\t\t\"frommonth\" => \"01\",\n\t\t\t\t\"fromyear\" => date(\"Y\"),\n\t\t\t\t\"today\" => \"31\",\n\t\t\t\t\"tomonth\" => \"12\",\n\t\t\t\t\"toyear\" => date(\"Y\"),\n\t\t\t\t\"transacknum\" => \"\"\n\t\t\t);\n\t\t\t\n\t\t\tif ($args[\"order_id\"]){\n\t\t\t\t$sargs[\"orderid\"] = $args[\"order_id\"];\n\t\t\t}\n\t\t\t\n\t\t\t$html = $this->http->post(\"pg.frontend/pg.search.php?search=doit\", $sargs);\n\t\t}\n\t\t\n\t\tif (!preg_match_all(\"/
]+)>\\s*([\\s\\S]+)<\\/tr>/U\", $html, $matches_tr)){\n\t\t\treturn array();\n\t\t}\n\t\t\n\t\tif (count($matches_tr[2]) == 1 or strlen(trim($matches_tr[2][0])) <= 0){\n\t\t\treturn array();\n\t\t}\n\t\t\n\t\t$payments = array();\n\t\tforeach($matches_tr[0] AS $key => $value){\n\t\t\tif (!preg_match_all(\"/
]+)>(.*)<\\/td>/U\", $value, $matches_td)){\n\t\t\t\tthrow new exception(\"Could not match TDs.\");\n\t\t\t}\n\t\t\t\n\t\t\tif (!preg_match(\"/id=(\\d+)/\", $matches_td[2][0], $match_id)){\n\t\t\t\tthrow new exception(\"Could not match ID.\");\n\t\t\t}\n\t\t\t\n\t\t\t$id = $match_id[1];\n\t\t\t\n\t\t\t$amount = str_replace(\" DKK\", \"\", $matches_td[2][3]);\n\t\t\t$amount = strtr($amount, array(\n\t\t\t\t\".\" => \"\",\n\t\t\t\t\",\" => \".\"\n\t\t\t));\n\t\t\t\n\t\t\t$card_type = $matches_td[2][6];\n\t\t\t\n\t\t\tif (strpos($card_type, \"dk.png\") !== false){\n\t\t\t\t$card_type = \"dk\";\n\t\t\t}elseif(strpos($card_type, \"visa-elec.png\") !== false){\n\t\t\t\t$card_type = \"visa_electron\";\n\t\t\t}elseif(strpos($card_type, \"mc.png\") !== false){\n\t\t\t\t$card_type = \"mastercard\";\n\t\t\t}elseif(strpos($card_type, \"visa.png\") !== false){\n\t\t\t\t$card_type = \"visa\";\n\t\t\t}else{\n\t\t\t\tthrow new exception(\"Unknown card-type image: \" . $card_type);\n\t\t\t}\n\t\t\t\n\t\t\t$date = strtr($matches_td[2][2], array(\n\t\t\t\t\"januar\" => 1,\n\t\t\t\t\"februar\" => 2,\n\t\t\t\t\"marts\" => 3,\n\t\t\t\t\"april\" => 4,\n\t\t\t\t\"maj\" => 5,\n\t\t\t\t\"juni\" => 6,\n\t\t\t\t\"juli\" => 7,\n\t\t\t\t\"august\" => 8,\n\t\t\t\t\"september\" => 9,\n\t\t\t\t\"oktober\" => 10,\n\t\t\t\t\"november\" => 11,\n\t\t\t\t\"december\" => 12\n\t\t\t));\n\t\t\t\n\t\t\tif (preg_match(\"/(\\d+) (\\d+) (\\d+) (\\d+):(\\d+):(\\d+)/\", $date, $match)){\n\t\t\t\t$unixt = mktime($match[4], $match[5], $match[6], $match[2], $match[1], $match[3]);\n\t\t\t}elseif(preg_match(\"/(\\d+) ([a-z]{3}) (\\d{4}) (\\d{2}):(\\d{2}):(\\d{2})/\", $date, $match)){\n\t\t\t\t$month = $match[2];\n\t\t\t\tif ($month == \"jan\"){\n\t\t\t\t\t$month_no = 1;\n\t\t\t\t}elseif($month == \"feb\"){\n\t\t\t\t\t$month_no = 2;\n\t\t\t\t}elseif($month == \"mar\"){\n\t\t\t\t\t$month_no = 3;\n\t\t\t\t}elseif($month == \"apr\"){\n\t\t\t\t\t$month_no = 4;\n\t\t\t\t}elseif($month == \"maj\"){\n\t\t\t\t\t$month_no = 5;\n\t\t\t\t}elseif($month == \"jun\"){\n\t\t\t\t\t$month_no = 6;\n\t\t\t\t}elseif($month == \"jul\"){\n\t\t\t\t\t$month_no = 7;\n\t\t\t\t}elseif($month == \"aug\"){\n\t\t\t\t\t$month_no = 8;\n\t\t\t\t}elseif($month == \"sep\"){\n\t\t\t\t\t$month_no = 9;\n\t\t\t\t}elseif($month == \"okt\"){\n\t\t\t\t\t$month_no = 10;\n\t\t\t\t}elseif($month == \"nov\"){\n\t\t\t\t\t$month_no = 11;\n\t\t\t\t}elseif($month == \"dec\"){\n\t\t\t\t\t$month_no = 12;\n\t\t\t\t}else{\n\t\t\t\t\tthrow new exception(\"Unknown month string: \" . $month);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t$unixt = mktime($match[4], $match[5], $match[6], $month_no, $match[1], $match[3]);\n\t\t\t}else{\n\t\t\t\tthrow new exception(\"Could not parse date: \" . $date);\n\t\t\t}\n\t\t\t\n\t\t\t$state = $matches_td[2][7];\n\t\t\tif (strpos($state, \"Gennemf\u00f8rt\") !== false){\n\t\t\t\t$state = \"done\";\n\t\t\t}elseif(strpos($state, \"Gennemf\u00f8r\") !== false){\n\t\t\t\t$state = \"waiting\";\n\t\t\t}elseif(strpos($state, \"Annulleret\") !== false){\n\t\t\t\t$state = \"canceled\";\n\t\t\t}elseif(strpos($state, \"Refunderet\") !== false){\n\t\t\t\t$state = \"returned\";\n\t\t\t}else{\n\t\t\t\tthrow new exception(\"Unknown state: \" . $state);\n\t\t\t}\n\t\t\t\n\t\t\tif ($this->payments[$id]){\n\t\t\t\t$payment = $this->payments[$id];\n\t\t\t\t$payment->set(\"state\", $state);\n\t\t\t}else{\n\t\t\t\t$payment = new wfpayment_payment($this, array(\n\t\t\t\t\t\"id\" => $id,\n\t\t\t\t\t\"order_id\" => substr($matches_td[2][1], 4),\n\t\t\t\t\t\"customer_id\" => $matches_td[2][1],\n\t\t\t\t\t\"customer_string\" => $matches_td[2][1],\n\t\t\t\t\t\"date\" => $unixt,\n\t\t\t\t\t\"amount\" => $amount,\n\t\t\t\t\t\"card_type\" => $card_type,\n\t\t\t\t\t\"state\" => $state\n\t\t\t\t));\n\t\t\t}\n\t\t\t\n\t\t\t$payments[] = $payment;\n\t\t}\n\t\t\n\t\treturn $payments;\n\t}\n}\n\nclass wfpayment_payment{\n\tfunction __construct($wfpayment, $args){\n\t\t$this->wfpayment = $wfpayment;\n\t\t$this->http = $this->wfpayment->http();\n\t\t$this->args = $args;\n\t}\n\t\n\tfunction set($key, $value){\n\t\t$this->args[$key] = $value;\n\t}\n\t\n\tfunction get($key){\n\t\tif (!array_key_exists($key, $this->args)){\n\t\t\tthrow new exception(\"No such key: \" . $key);\n\t\t}\n\t\t\n\t\treturn $this->args[$key];\n\t}\n\t\n\tfunction args(){\n\t\treturn $this->args;\n\t}\n\t\n\tfunction accept(){\n\t\tif ($this->state() == \"done\"){\n\t\t\tthrow new exception(\"This payment is already accepted.\");\n\t\t}\n\t\t\n\t\t$html = $this->http->getaddr(\"pg.frontend/pg.transactions.php?capture=singlecapture&transid=\" . $this->get(\"id\") . \"&page=1&orderby=&direction=\");\n\t\t\n\t\tif ($this->state() != \"done\"){\n\t\t\tthrow new exception(\"Could not accept the payment. State: \" . $this->state());\n\t\t}\n\t}\n\t\n\tfunction cancel(){\n\t\tif ($this->state() != \"waiting\"){\n\t\t\tthrow new exception(\"This is not waiting and cannot be canceled.\");\n\t\t}\n\t\t\n\t\t$html = $this->http->getaddr(\"pg.frontend/pg.transactionview.php?action=cancel&id=\" . $this->get(\"id\") . \"&page=1\");\n\t\t\n\t\tif ($this->state() != \"canceled\"){\n\t\t\tthrow new exception(\"Could not cancel the payment.\");\n\t\t}\n\t}\n\t\n\tfunction state(){\n\t\t$payments = $this->wfpayment->listPayments(array(\"order_id\" => $this->get(\"order_id\")));\n\t\tif (!$payments or !$payments[0]){\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\treturn $payments[0]->get(\"state\");\n\t}\n}", "strings.php": "\n\nclass knj_strings{\n\tstatic function substr($string, $len1, $len2){\n\t\t$string = utf8_decode($string);\n\t\t$string = substr($string, $len1, $len2);\n\t\t$string = utf8_encode($string);\n\t\treturn $string;\n\t}\n\t\n\tstatic function utf8wrapper($func, $arg1){\n\t\treturn utf8_encode(call_user_func($func, utf8_decode($arg1)));\n\t}\n\t\n\tstatic function utf8force($string){\n\t\tif (is_array($string)){\n\t\t\tforeach($string as $key => $value){\n\t\t\t\t$string[$key] = knj_strings::utf8force($value);\n\t\t\t}\n\t\t\t\n\t\t\treturn $string;\n\t\t}else{\n\t\t\t$values = array();\n\t\t\t$special = array(\"\u00f8\", \"\u00e6\", \"\u00e5\", \"\u00d8\", \"\u00c6\", \"\u00c5\");\n\t\t\tforeach($special AS $value){\n\t\t\t\t$values[utf8_decode($value)] = $value;\n\t\t\t}\n\t\t\t\n\t\t\t$string = str_replace(\"\u00c3\u00a6\", \"\u00e6\", $string);\n\t\t\t\n\t\t\treturn strtr($string, $values);\n\t\t}\n\t}\n\t\n\t/** Parses a string into an array of strings, which should all be searched for. */\n\tstatic function searchstring($string){\n\t\t$array = array();\n\t\t\n\t\tif (preg_match_all(\"/\\\"(.*)\\\"/U\", $string, $matches)){\n\t\t\tforeach($matches[1] AS $key => $value){\n\t\t\t\t$array[] = $value;\n\t\t\t\t$string = str_replace($matches[0][$key], \"\", $string);\n\t\t\t}\n\t\t}\n\t\t\n\t\tif (strlen($string) > 0){\n\t\t\tforeach(preg_split(\"/\\s/\", $string) AS $value){\n\t\t\t\tif (strlen(trim($value)) > 0){\n\t\t\t\t\t$array[] = $value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn $array;\n\t}\n\t\n\tstatic function parseImageHTML($content){\n\t\tif (preg_match_all(\"//U\", $content, $matches)){\n\t\t\tforeach($matches[0] AS $key => $value){\n\t\t\t\t$img_html = $value;\n\t\t\t\t\n\t\t\t\tif (preg_match(\"/src=\\\"([\\s\\S]+)\\\"/U\", $img_html, $match_src)){\n\t\t\t\t\t$src = $match_src[1];\n\t\t\t\t\tif (substr($src, 0, 1) == \"/\"){\n\t\t\t\t\t\t$src = substr($src, 1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t$replace_with = \"image.php?picture=\" . $src;\n\t\t\t\t\t\n\t\t\t\t\tif (preg_match(\"/width: ([0-9]+)(px|)/\", $img_html, $match_width)){\n\t\t\t\t\t\t$size[\"width\"] = $match_width[1];\n\t\t\t\t\t\t$replace_with .= \"&width=\" . $match_width[1];\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (preg_match(\"/height: ([0-9]+)(px|)/\", $img_html, $match_height)){\n\t\t\t\t\t\t$size[\"height\"] = $match_height[1];\n\t\t\t\t\t\t$replace_with .= \"&height=\" . $match_width[1];\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (preg_match_all(\"/(width|height)=\\\"([0-9]+)(px|)\\\"/\", $img_html, $match_sizes)){\n\t\t\t\t\t\t$size = array();\n\t\t\t\t\t\tforeach($match_sizes[1] AS $key => $sizetype){\n\t\t\t\t\t\t\tif (!$size[$sizetype]){\n\t\t\t\t\t\t\t\t$size[$sizetype] = $match_sizes[2][$key];\n\t\t\t\t\t\t\t\t$replace_with .= \"&\" . $sizetype . \"=\" . $match_sizes[2][$key];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif ($size){\n\t\t\t\t\t\t$img_html = str_replace($src, $replace_with, $img_html);\n\t\t\t\t\t\t$content = str_replace($value, $img_html, $content);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn $content;\n\t}\n\t\n\tstatic function UnixSafe($string){\n\t\t$string = str_replace(\"\\\\\", \"\\\\\\\\\", $string);\n\t\t$string = str_replace(\" \", \"\\\\ \", $string);\n\t\t$string = str_replace(\"\\$\", \"\\\\\\$\", $string);\n\t\t$string = str_replace(\"(\", \"\\\\(\", $string);\n\t\t$string = str_replace(\")\", \"\\\\)\", $string);\n\t\t$string = str_replace(\";\", \"\\\\;\", $string);\n\t\t$string = str_replace(\",\", \"\\\\,\", $string);\n\t\t$string = str_replace(\"'\", \"\\\\'\", $string);\n\t\t$string = str_replace(\">\", \"\\\\>\", $string);\n\t\t$string = str_replace(\"<\", \"\\\\<\", $string);\n\t\t$string = str_replace(\"\\\"\", \"\\\\\\\"\", $string);\n\t\t$string = str_replace(\"&\", \"\\\\&\", $string);\n\t\t\n\t\t//Replace the end & - if any.\n\t\t//$string = preg_replace(\"/&\\s*$/\", \"\\\\&\", $string);\n\t\t\n\t\treturn $string;\n\t}\n\t\n\tstatic function RegexSafe($string){\n\t\treturn strtr($string, array(\n\t\t\t\"/\" => \"\\\\/\",\n\t\t\t\".\" => \"\\\\.\",\n\t\t\t\"(\" => \"\\\\(\",\n\t\t\t\")\" => \"\\\\)\",\n\t\t\t\"[\" => \"\\\\[\",\n\t\t\t\"]\" => \"\\\\]\",\n\t\t\t\"^\" => \"\\\\^\",\n\t\t\t\"\\$\" => \"\\\\\\$\",\n\t\t\t\"+\" => \"\\\\+\"\n\t\t));\n\t}\n\t\n\tstatic function HeaderSafe($string){\n\t\treturn strtr($string, array(\n\t\t\t\"\\r\" => \"\",\n\t\t\t\"\\n\" => \" \"\n\t\t));\n\t}\n\t\n\tstatic function csvsafe($string){\n\t\t$string = htmlspecialchars($string);\n\t\t$string = str_replace(\"\\\"\", \"\", $string);\n\t\t$string = str_replace(\""\", \"\", $string);\n\t\t$string = str_replace(\"&\", \"&\", $string);\n\t\t$string = str_replace(\"\\r\", \"\", $string);\n\t\t$string = str_replace(\"\\n\", \"\", $string);\n\t\t$string = str_replace(\"<\", \"<\", $string);\n\t\t$string = str_replace(\">\", \">\", $string);\n\t\t\n\t\treturn $string;\n\t}\n\t\n\tstatic function htmlspecialchars_textarea($text){\n\t\treturn preg_replace(\"/<\\/textarea>/i\", \"</textarea>\", $text);\n\t}\n\t\n\tstatic function jsparse($string, $paras = array()){\n\t\t$string = strtr($string, array(\n\t\t\t\"'\" => \"\\\\'\",\n\t\t\t\"\\\"\" => \""\",\n\t\t\t\"\\r\" => \"\",\n\t\t\t\"\\n\" => \"\\\\n\"\n\t\t));\n\t\t\n\t\tif ($paras[\"parse_quotes\"]){\n\t\t\t$string = str_replace(\"\\\"\", \"\\\\\\\"\", $string);\n\t\t}\n\t\t\n\t\treturn $string;\n\t}\n\t\n\tstatic function tf_str($value, $yesstr, $nostr){\n\t\tif ($value){\n\t\t\treturn $yesstr;\n\t\t}\n\t\t\n\t\treturn $nostr;\n\t}\n\t\n\tstatic function shorten($text, $maxlength = nil){\n\t\tif (!$maxlength or strlen($text) <= $maxlength){\n\t\t\treturn $text;\n\t\t}\n\t\t\n\t\treturn trim(substr($text, 0, $maxlength)) . \"...\";\n\t}\n\t\n\tstatic function is_email($str){\n\t\tif (preg_match(\"/^(.+)@(.+)\\.(.+)/\", $str)){\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n}\n\n/**\n\t* Parses the quotes of a string.\n\t* \n\t* FIXME: DONT USE THIS FUNCTION! It will be removed soon... Look in the SQL-functions instead.\n*/\nfunction parse_quotes($string){\n\t$string = str_replace(\"'\", \"\\\\'\", $string);\n\t\n\tif (substr($string, -1, 1) == \"\\\\\" && substr($string, -2, 2) !== \"\\\\\\\\\"){\n\t\t$string = substr($string, 0, -1) . \"\\\\\\\\\";\n\t}\n\t\n\treturn $string;\n}\n\n/** Parse a string so it fits into the command-line of Linux. */\nfunction knj_string_unix_safe($string){\n\treturn knj_strings::UnixSafe($string);\n}\n\n/** Parse a string so it will be a valid filename. */\nfunction knj_string_filename($string, $os = null){\n\tif (!$os){\n\t\trequire_once(\"knj/os.php\");\n\t\t$os = knj_os::getOS();\n\t\t$os = $os[\"os\"];\n\t}\n\t\n\tif ($os == \"windows\"){\n\t\t//parse windows-filename here.\n\t}elseif($os == \"linux\"){\n\t\t$string = strtr($string, array(\n\t\t\t\"\u00e5\" => \"aa\",\n\t\t\t\"\u00f8\" => \"oe\",\n\t\t\t\"\u00e6\" => \"ae\",\n\t\t\tutf8_decode(\"\u00e5\") => \"aa\",\n\t\t\tutf8_decode(\"\u00e6\") => \"ae\",\n\t\t\tutf8_decode(\"\u00f8\") => \"oe\",\n\t\t\t\"|\" => \"\",\n\t\t\t\"&\" => \"\",\n\t\t\t\"/\" => \"\",\n\t\t\t\"\\\\\" => \"\"\n\t\t));\n\t}else{\n\t\tthrow new Exception(\"Unsupported OS.\");\n\t}\n\t\n\treturn $string;\n}\n\n/** Parse a string to it is safe in a regex-command. */\nfunction knj_string_regex($string){\n\treturn knj_strings::RegexSafe($string);\n}", "epay.php": "\n\nclass epay{\n\tprivate $payments = array();\n\t\n\tfunction __construct($args){\n\t\t$this->args = $args;\n\t\t\n\t\tif (!$this->args[\"username\"]){\n\t\t\tthrow new exception(\"No username was given.\");\n\t\t}\n\t\t\n\t\tif (!$this->args[\"password\"]){\n\t\t\tthrow new exception(\"No password was given.\");\n\t\t}\n\t\t\n\t\t$this->soap_client = new SoapClient(\"https://ssl.ditonlinebetalingssystem.dk/remote/payment.asmx?WSDL\", array(\n\t\t\t\"verify_peer\" => false,\n\t\t\t\"allow_self_signed\" => true\n\t\t));\n\t}\n\t\n\tfunction transactions($args = array()){\n\t\t$res = $this->soap_client->__soapCall(\"gettransactionlist\", array(\"parameters\" => array_merge($args, array(\n\t\t\t\"merchantnumber\" => $this->args[\"merchant_no\"]\n\t\t))));\n\t\t$ret = array();\n\t\t\n\t\tif (is_array($res->transactionInformationAry->TransactionInformationType)){\n\t\t\tforeach($res->transactionInformationAry->TransactionInformationType as $trans_obj){\n\t\t\t\t$ret[] = new epay_payment(array(\n\t\t\t\t\t\"epay\" => $this,\n\t\t\t\t\t\"obj\" => $trans_obj,\n\t\t\t\t\t\"soap_client\" => $this->soap_client\n\t\t\t\t));\n\t\t\t}\n\t\t}elseif($res->transactionInformationAry->TransactionInformationType){\n\t\t\t$ret[] = new epay_payment(array(\n\t\t\t\t\"epay\" => $this,\n\t\t\t\t\"obj\" => $res->transactionInformationAry->TransactionInformationType,\n\t\t\t\t\"soap_client\" => $this->soap_client\n\t\t\t));\n\t\t}\n\t\t\n\t\treturn $ret;\n\t}\n\t\n\tfunction transaction($args = array()){\n\t\t$res = $this->soap_client->__soapCall(\"gettransaction\", array(\"parameters\" => array_merge($args, array(\n\t\t\t\"merchantnumber\" => $this->args[\"merchant_no\"],\n\t\t\t\"epayresponse\" => true\n\t\t))));\n\t\t\n\t\treturn new epay_payment(array(\n\t\t\t\"epay\" => $this,\n\t\t\t\"obj\" => $res->transactionInformation,\n\t\t\t\"soap_client\" => $this->soap_client\n\t\t));\n\t}\n}\n\nclass epay_payment{\n\tfunction __construct($args){\n\t\t$this->args = $args;\n\t\t$this->soap_client = $args[\"soap_client\"];\n\t\t\n\t\tif ($args[\"obj\"]->capturedamount){\n\t\t\t$amount = floatval($args[\"obj\"]->capturedamount);\n\t\t}else{\n\t\t\t$amount = floatval($args[\"obj\"]->authamount);\n\t\t}\n\t\t\n\t\t$this->data = array(\n\t\t\t\"amount\" => $amount,\n\t\t\t\"orderid\" => intval($args[\"obj\"]->orderid),\n\t\t\t\"status\" => $args[\"obj\"]->status,\n\t\t\t\"transactionid\" => $args[\"obj\"]->transactionid\n\t\t);\n\t}\n\t\n\tfunction get($key){\n\t\tif ($key == \"id\"){\n\t\t\t$key = \"transactionid\";\n\t\t}\n\t\t\n\t\tif (!array_key_exists($key, $this->data)){\n\t\t\tthrow new exception(\"No such key: \" . $key);\n\t\t}\n\t\t\n\t\treturn $this->data[$key];\n\t}\n\t\n\tfunction args(){\n\t\treturn $this->args;\n\t}\n\t\n\tfunction accept(){\n\t\tif ($this->data[\"status\"] == \"PAYMENT_CAPTURED\"){\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\t$res = $this->soap_client->__soapCall(\"capture\", array(\"parameters\" => array(\n\t\t\t\"merchantnumber\" => $this->args[\"epay\"]->args[\"merchant_no\"],\n\t\t\t\"transactionid\" => $this->data[\"transactionid\"],\n\t\t\t\"amount\" => $this->data[\"amount\"],\n\t\t\t\"epayresponse\" => true,\n\t\t\t\"pbsResponse\" => true\n\t\t)));\n\t\t\n\t\tif (!$res->captureResult){\n\t\t\tthrow new exception(\"Could not accept payment.\\n\\n\" . print_r($res, true));\n\t\t}\n\t}\n\t\n\tfunction delete(){\n\t\t$res = $this->soap_client->__soapCall(\"delete\", array(\"parameters\" => array(\n\t\t\t\"merchantnumber\" => $this->args[\"epay\"]->args[\"merchant_no\"],\n\t\t\t\"transactionid\" => $this->data[\"transactionid\"],\n\t\t\t\"epayresponse\" => true\n\t\t)));\n\t\t\n\t\tif (!$res->deleteResult){\n\t\t\tthrow new exception(\"Could not delete payment.\\n\\n\" . print_r($res, true));\n\t\t}\n\t}\n\t\n\tfunction state(){\n\t\tthrow new exception(\"stub!\");\n\t}\n}"}}
{"repo": "collective/collective.setuphandlertools", "pr_number": 1, "title": "Depend on Products.CMFPlone instead of Plone to not fetch unnecessary\u2026", "state": "closed", "merged_at": "2018-02-08T13:11:26Z", "additions": 8, "deletions": 1, "files_changed": ["setup.py"], "files_before": {"setup.py": "from setuptools import setup, find_packages\nimport os\n\nversion = '1.0b4'\n\nsetup(name='collective.setuphandlertools',\n version=version,\n description=\"Tools for setting up a Plone site.\",\n long_description=open(\"README.txt\").read() + \"\\n\\n\" +\n open(os.path.join(\"docs\", \"HISTORY.txt\")).read(),\n # Get more strings from http://pypi.python.org/pypi?:action=list_classifiers\n classifiers=[\n \"Framework :: Plone\",\n \"Programming Language :: Python\",\n ],\n keywords='plone zope setup',\n author='Johannes Raggam',\n author_email='raggam-nl@adm.at',\n url='http://github.com/collective/collective.setuphandlertools',\n license='GPL',\n packages=find_packages(exclude=['ez_setup']),\n namespace_packages=['collective'],\n include_package_data=True,\n zip_safe=False,\n install_requires=[\n 'setuptools',\n # -*- Extra requirements: -*-\n 'Plone',\n 'Products.ATContentTypes',\n 'Products.CMFCore',\n 'Products.PortalTransforms',\n ],\n )\n"}, "files_after": {"setup.py": "from setuptools import setup, find_packages\nimport os\n\nversion = '1.0b4'\n\nsetup(name='collective.setuphandlertools',\n version=version,\n description=\"Tools for setting up a Plone site.\",\n long_description=open(\"README.txt\").read() + \"\\n\\n\" +\n open(os.path.join(\"docs\", \"HISTORY.txt\")).read(),\n # Get more strings from http://pypi.python.org/pypi?:action=list_classifiers\n classifiers=[\n \"Framework :: Plone\",\n \"Programming Language :: Python\",\n ],\n keywords='plone zope setup',\n author='Johannes Raggam',\n author_email='raggam-nl@adm.at',\n url='http://github.com/collective/collective.setuphandlertools',\n license='GPL',\n packages=find_packages(exclude=['ez_setup']),\n namespace_packages=['collective'],\n include_package_data=True,\n zip_safe=False,\n install_requires=[\n 'setuptools',\n # -*- Extra requirements: -*-\n 'Products.CMFPlone',\n 'Products.ATContentTypes',\n 'Products.CMFCore',\n 'Products.PortalTransforms',\n ],\n )\n"}}
{"repo": "balinterdi/balinterdi.github.com", "pr_number": 13, "title": "Sales web changes", "state": "closed", "merged_at": "2016-03-07T13:05:36Z", "additions": 13, "deletions": 1, "files_changed": ["source/_layouts/rarwe_book.html"], "files_before": {"source/_layouts/rarwe_book.html": "\n\n\n\n \n \n \n \n\n \n \n \n \n \n \n\n \n \n\n Cut your learning curve and build ambitious apps with Ember.js.\n\n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n\n\n\n
\n\n \n \n
\n\n
\n
\n
The most up-to-date book to learn Ember.js
\n
\n Trusted by:\n \n \n \n \n
\n
\n
\n\n
\n
\n
\n \n
\n
\n
\n
\n
Build ambitious apps with confidence
\n
Ember.js is a kick-ass framework for building\n web applications. It's the only tool you need\n (on the client-side) to craft your idea into a working\n wonder. However, its strong opinions and heavy reliance of\n \u201cconvention over configuration\u201d can give developers who\n are new to the framework a hard time figuring out how\n Ember wants them to do things.
\n\n
This book helps to overcome that initial\n frustration, and help you grok Ember a lot\n faster, by pinpointing the core concepts and\n explaining them in detail. Once you understand them you\n are on your way to taming and mastering Ember.js.\n So don't fear the learning curve.
\n\n
\n
\n
\n
This is a really great book. I think it will be very helpful to many people. I\u2019m definitely going to recommend it to beginners.
\n
\n
\n \n \n \n
\n — Taras Mankowski\n EmberSherpa\n
\n
\n
\n
\n
The book guides you through the steps of building a real application so that you can see how the concepts are applied in practice. You'll learn about the building blocks of Ember one by one, in a way that crushes the steep learning curve. Knowledge is dripped in slowly, chapter by chapter, to prevent you from drowning in a sea of novel information. By improving an existing and working application, you will learn more quickly and new knowledge will sink in deeper.
\n It all started in September 2013. Having just returned from the first European\n Ember.js conference, my enthusiasm went through the roof. I wanted to spread the\n word, for people to realize how beautiful Ember is, for them to know\n that Ember.js is not that hard to learn. It's just a matter of having the core\n concepts internalized.\n
\n
\n So without proper equipment (and after a few episodes, with a ~$80 mic) I started producing screencasts, a series in\n which a simple application is developed step-by-step. I sent the first few to my\n subscribers and kept producing them. And people seemed to have liked them.\n
\n\n
\n
\n
\n
\n
\n
Great episode! Pace and depth was perfect. Thanks for such a great webcast series!
\n
\n
\n \n \n \n
\n — Curtis Wallen\n
\n
\n
\n
\n\n
\n
\n
\n
I really appreciate the effort you want to put up. Just wanted to thank you for this and let you know that your video series rock!
\n
\n
\n \n \n \n
\n — Antonio Antillon\n
\n
\n
\n
\n
\n
\n\n
\n Once the screencast series was finished, I switched to blog posts and lengthier\n articles, and in 2014 I committed to posting something of\n value each week. Then, after a long labor of (mostly) love,\n I published the 1st edition of the book in Feburary\n 2015, that used the then stable Ember version, 1.10.\n
\n
\n I was not done, though. As Ember made progress in a\n neck breaking pace, I kept the book up-to-date with the\n actual stable version of the framework, and adding material\n that covered the new features.\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n
\n
Buy once, get all updates for free
\n
\n
\n
\n\n
\n
The first edition of this book followed Ember's journey to\n its 2.0 release. As Ember gracefully shedded old syntaxes, the\n book's content was updated not to use those syntaxes, either.\n When a new feature appeared, I added a section about it, trying\n to find a practical example for it in the application.
\n\n
Since Ember follows a 6-week release cycle, that meant\n frequent book updates, precisely 8 \"minor book releases\" in a\n little less than 7 months. These updates came free for all of my\n customers, no matter which package they chose. I aim to follow a\n similar path and update policy with Ember 2.x. The framework\n makes progress really fast but I'll keep in sync with the latest\n stable version of Ember and keep the content fresh. And\n free until at least the next major version.
\n
\n
\n\n
\n
\n
\n
\n
\n
I really like it! It is super difficult to find the right balance between pacing and detail\nand put it all together in an understandable form but you pulled it off.
\n
\n
\n \n \n \n
\n — Cory Forsyth\n 201 Created\n
\n
\n
\n
\n\n
\n
\n
\n
Just wanted to say thanks for the ongoing updates of the book. Even after finishing the book, it\u2019s becoming a great reference for the changes Ember is going through (even more so than the official docs).
\n
\n
\n \n \n \n
\n — Gabriel Rotbart\n
\n
\n
\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n
\n
\n
Table of Contents
\n
\n
\n
\n
\n\n
\n
\n
\n \n
\n
\n
Preface\n\n
\n
My love affair with Ember.js
\n
Acknowledgements
\n
\n
Introduction to Ember.js\n\n
\n
Why Ember.js
\n
Backstage - Dial M for Model
\n
About this book
\n
Is this book for you?
\n
Ambitious goal for an ambitious framework
\n
The application we are going to build
\n
Errata
\n
\n
Ember CLI\n\n
\n
Setting up Ember CLI
\n
Creating our application
\n
\n
Templates and data bindings\n\n
\n
The first template
\n
Showing a list of songs in the application template
\n
Backstage - Handlebar's fail-softness
\n
Backstage - ES2015 modules
\n
Backstage - Class and instance properties
\n
Adding libraries to the build
\n
Importing needed assets manually
\n
Using an Ember add-on
\n
Auto-updating templates
\n
\n
Routing\n\n
\n
What do we want to achieve?
\n
New styles
\n
Routes set up data
\n
Backstage - A word about generated test files
\n
Moving around with link-to
\n
Using the model property
\n
Showing a list of bands
\n
Showing a list of songs
\n
\n
Nested routes\n\n
\n
Defining the nested routes
\n
Full route names
\n
Backstage - Resource routes
\n
Stepping through a router transition
\n
Backstage - Computed properties
\n
Nested templates
\n
{{outlet}} is the default template for routes
\n
\n
Actions\n\n
\n
Extracting model classes
\n
The class-level mutable attribute property
\n
Capturing the event
\n
Turning event into intent
\n
\n
Components\n\n
\n
The idea behind components
\n
Component specification
\n
Defining the component's properties
\n
Using the component
\n
Displaying the rating with stars
\n
Backstage - The default component template
\n
Backstage - On the utility of explicit dependency definitions
\n
Speaking to the outside world through actions
\n
Closure actions
\n
\n
Controllers\n\n
\n
Preventing the creation of bands without a name
\n
Smooth UI flows
\n
Going to the band page after it is created
\n
Nudging the user to create the first song
\n
Showing the text field when the call to action has been acted on
\n
Creating new bands and songs by pressing return
\n
Backstage - Where to handle actions?
\n
\n
Advanced routing\n\n
\n
Route hooks
\n
Route actions
\n
Redirection
\n
Redirecting before the model is known
\n
Redirecting after the model is known
\n
Backstage - Skipping model resolution
\n
Leaving routes and arriving at them
\n
Setting descriptive page titles
\n
Warning about losing data
\n
\n
Talking to a backend - with Ember Data\n\n
\n
The concept behind Ember Data
\n
The API
\n
Model classes
\n
Transforming the app to use Ember Data
\n
Loading bands
\n
Fetching a single band
\n
Loading songs for a band
\n
Creating a band
\n
Updating a band's description
\n
Updating song ratings
\n
Backstage - Promises
\n
\n
Testing\n\n
\n
Clarifying the vocabulary
\n
Acceptance tests
\n
To mock or not to mock?
\n
Unit tests
\n
Integration tests
\n
Adding an acceptance test
\n
Analyzing an Ember acceptance test
\n
Making the first test pass
\n
Safeguarding critical user scenarios
\n
Creating a band
\n
Creating a song
\n
Backstage \u2013 Fake synchronous tests
\n
Writing your own test helpers
\n
Registering a synchronous helper
\n
Registering an async helper
\n
Refactoring stubs
\n
Integration tests in Ember
\n
Unit tests in Ember
\n
\n
Sorting and searching with query parameters\n\n
\n
Query parameters
\n
Query parameters in Ember
\n
Sorting the list of songs
\n
Sorting an array of items
\n
Backstage - Computed property macros
\n
Changing the sorting criteria
\n
Filtering songs by a search term
\n
Adding a dash of query parameters
\n
Using links instead of buttons
\n
Taking a look at what we made
\n
\n
Loading and error routes\n\n
\n
Loading routes
\n
Backstage - Rendering the loading template is an overridable default
\n
Error routes
\n
\n
Helpers\n\n
\n
About helpers
\n
Capitalizing each word of a name
\n
Using it in templates, or elsewhere
\n
Use dashed names for helpers
\n
\n
Animations\n\n
\n
Setting up liquid-fire
\n
liquid-fire architecture
\n
Transition map
\n
Transition functions
\n
Template helpers
\n
Putting it all together
\n
Debugging transitions
\n
Animate moving between routes
\n
Adding a custom animation
\n
Animate a value change
\n
\n
Making an Ember addon\n\n
\n
What is an Ember addon?
\n
Developing the addon
\n
Integrating our addon into our app
\n
Adding a block form
\n
Customizing the star-rating component's look and behavior
\n
Publishing the addon
\n
Using a published addon from the app
\n
\n
ES2015 - Writing modern JavaScript\n\n
\n
Modernizing the app
\n
Modules
\n
Template strings
\n
Short-hand method definitions
\n
Replacing var (let & const)
\n
Arrow functions
\n
Destructuring
\n
Other useful ES2015 features
\n
Backstage - ember-watson
\n
Computed property macros
\n
\n
Deployment\n\n
\n
FrontPage
\n
Heroku
\n
ember-cli-deploy
\n
\n
Afterword\n\n
\n
Your journey with Ember.js
\n
\n
\n\n
\n\n \n
\n \n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n\n
\n
About me
\n
Hello there, I'm Balint Erdi.
\n
\n I have a long history of building web applications and have mostly been a back-end\n guy.\n
\n
\n On a grey, chilly February day in 2013 that I\u2019ll never forget (maybe it was\n January?) I got acquainted with Ember.js. Ember.js made that day bright and the\n ones that came after that. After learning the ropes I shifted gears and have been\n proselytizing for Ember since last summer.\n
\n
\n I gave a beginner\u2019s workshop at Eurucamp, and held presentations at Arrrrcamp, The Geek Gathering and EmberFest. I started an Ember.js mailing list, made an introductory\n screencast series and have been sending Ember content to my dear subscribers on a\n weekly basis. I have also written guest articles for Safari Books Online, Firebase\n and Toptal.\n
\n
\n I guess you could say I\u2019m pretty passionate about Ember.\n
\n
\n Oh, and I love rock & roll, obviously.\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n
\n
Bonus: Exclusive hack.hands() deal
\n
\n
\n
\n
\n
\n hack.hands()\n is your SOS button for live programming support, available 24/7. hack.hands() instantly connects developers with a network of expert programmers at the click of a button. Never get stuck, learn more and keep coding!\n If you buy any package, you will receive $25 to spend on their platform that you can use to get your Ember project unstuck.\n
\n
\n
\n\n
\n
\n
\n
\n
\n
Even though I have worked with Ember for the past 6 months, the book helped clarify a lot of things, especially new features and their deprecated counterparts. Such a great book, and looking forward to the second one!
\n
\n
\n \n \n \n
\n — David Tang\n
\n
\n
\n
\n\n
\n
\n
\n
There is almost nowhere to go to get a good grounding in Ember. In months of searching this is the best resource that exists... so much so I'm going to try to get a few copies sorted out for my team at work. Thanks Balint!
\n
\n
\n \n \n \n
\n — Andy Davison\n
\n
\n
\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n
\n
Stairway to Heaven Package
\n
\n
\n
\n\n
\n
\n
\n The path to Ember.js bliss, this package contains all you need to take your Ember.js skills to the next level. It contains:
\n \n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n
This was a truly great series of screencasts. Very, very well done. Simple enough while not being simplistic.
\n
\n
\n \n \n \n
\n — Claude Pr\u00e9court\n
\n
\n
\n
\n\n
\n
\n
\n
Nice work with these Ember tutorials. You're doing a really nice thing for the community.
\n
\n
\n \n \n \n
\n — Steven Kane\n
\n
\n
\n
\n
\n
\n \n \n \n
\n
\n
\n
\n
\n
\n \n
\n
The book
\n 18 chapters\n
This is what you absolutely need to get up & running with Ember.js. Comes in pdf, mobi and epub formats for your reading pleasure.
\n
\n
\n\n
\n
\n
\n \n
\n
Access to the code
\n All of the source code\n
in the application so that you can check how the app looks & works at each step. Or tweak it to your liking.
\n
\n
\n\n
\n
\n
\n \n
\n
Screencasts
\n 4 screencasts\n
They run around 10 minutes each and cover the following,\n advanced topics: Pods in Ember CLI, Animations,\n Authentication & Authorization, and ES2015 &\n computed macros.
I\u2019m REALLY enjoying the book and find it to be very thorough and informative. You\u2019ve done a great job of answering questions I had about various concepts that were not detailed clearly elsewhere.
It\u2019s been an invaluable resource in learning Ember and one I would recommend to any developer wanting to get started with the framework.
\n
\n
\n \n \n \n
\n — Jonathan Rowley\n
\n
\n
\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n
\n
Hmm, I\u2019m not sure...
\n
\n
\n
\n\n
\n
\n
\n
Is the book ready for Ember 2?
\n
\n Yes, it is! The app in the book runs Ember (and Ember Data)\n 2 and does not use any deprecated stuff.\n
\n
\n\n
\n
Is this book for me?
\n
\n The book starts from the very basics (installing\n ember-cli, writing your first template, etc.) so if you\n completely get Ember, this book is probably not for you. If\n you are just starting out (or about to) or want to\n understand fundamental concepts in Ember, the book is\n definitely for you.\n
\n
\n\n
\n
What if I don't like the book?
\n
\n I offer a 60-day moneyback guarantee. No strings attached,\n just send your purchase receipt (or email address) to\n rarwe-book@balinterdi.com or answer to the welcome email\n that you received when you purchased.\n
\n
\n\n
\n
Everything is changing so fast; won't the content be outdated by next week?
\n
\n As Ember.js moves towards 3.0, I will keep updating the\n content of the book so that it stays void of deprecation\n warnings and does not promote practices that are no longer\n considered idiomatic. For the 1st edition of the book,\n I released an update once about every four weeks,\n more often than Ember stable versions came out.\n Expect the same for the this book edition.\n
\n
\n\n
\n
I heard Ember is so hard. Will this book help me understand it?
\n
\n I think there are a handful of key concepts in Ember.js\n that you need to understand to master it (probably the main\n one among these is routing). Once you understand these,\n Ember is not that hard. The intention of the book is\n to introduce concepts by way of building an actual\n application, so you see them applied in practice right away.\n That also helps the learning process. I also encourage you\n to work through the book as you read it, since that makes\n things sink in even deeper. You have access to the code\n repository if you have purchased the middle- or\n high-tier package. If I failed to explain Ember for you, please\n send me your purchase receipt to rarwe-book@balinterdi.com\n within 60 days of purchase and I\u2019ll issue a refund.\n
\n
\n\n
\n
Is the book DRM protected?
\n
\n No, it\u2019s not. If you would like to share it with\n colleagues (or a class), please contact me at rarwe-book@balinterdi.com.
\n
\n\n
\n
What if I buy the book-only package and later realize I want to switch to a higher package?
\n
No problem! Just send me your purchase receipt to rarwe-book@balinterdi.com, and I will upgrade you for the difference between the package prices.
This book is a fabulous, approachable, foray into Emberjs that makes the learning curve much less scary. I just wish it had been available sooner for students in my previous classes.
\n
\n
\n \n \n \n
\n — Matt Hale\n Assistant Professor at the University of Nebraska\n
\n
\n
\n
\n\n
\n
\n
\n
I\u2019ve gone through the first four chapters and I am already loving it.
Ember.js is a kick-ass framework for building\n web applications. It's the only tool you need\n (on the client-side) to craft your idea into a working\n wonder. However, its strong opinions and heavy reliance of\n \u201cconvention over configuration\u201d can give developers who\n are new to the framework a hard time figuring out how\n Ember wants them to do things.
\n\n
This book helps to overcome that initial\n frustration, and help you grok Ember a lot\n faster, by pinpointing the core concepts and\n explaining them in detail. Once you understand them you\n are on your way to taming and mastering Ember.js.\n So don't fear the learning curve.
\n\n
\n
\n
\n
This is a really great book. I think it will be very helpful to many people. I\u2019m definitely going to recommend it to beginners.
\n
\n
\n \n \n \n
\n — Taras Mankowski\n EmberSherpa\n
\n
\n
\n
\n
The book guides you through the steps of building a real application so that you can see how the concepts are applied in practice. You'll learn about the building blocks of Ember one by one, in a way that crushes the steep learning curve. Knowledge is dripped in slowly, chapter by chapter, to prevent you from drowning in a sea of novel information. By improving an existing and working application, you will learn more quickly and new knowledge will sink in deeper.
\n It all started in September 2013. Having just returned from the first European\n Ember.js conference, my enthusiasm went through the roof. I wanted to spread the\n word, for people to realize how beautiful Ember is, for them to know\n that Ember.js is not that hard to learn. It's just a matter of having the core\n concepts internalized.\n
\n
\n So without proper equipment (and after a few episodes, with a ~$80 mic) I started producing screencasts, a series in\n which a simple application is developed step-by-step. I sent the first few to my\n subscribers and kept producing them. And people seemed to have liked them.\n
\n\n
\n
\n
\n
\n
\n
Great episode! Pace and depth was perfect. Thanks for such a great webcast series!
\n
\n
\n \n \n \n
\n — Curtis Wallen\n
\n
\n
\n
\n\n
\n
\n
\n
I really appreciate the effort you want to put up. Just wanted to thank you for this and let you know that your video series rock!
\n
\n
\n \n \n \n
\n — Antonio Antillon\n
\n
\n
\n
\n
\n
\n\n
\n Once the screencast series was finished, I switched to blog posts and lengthier\n articles, and in 2014 I committed to posting something of\n value each week. Then, after a long labor of (mostly) love,\n I published the 1st edition of the book in Feburary\n 2015, that used the then stable Ember version, 1.10.\n
\n
\n I was not done, though. As Ember made progress in a\n neck breaking pace, I kept the book up-to-date with the\n actual stable version of the framework, and adding material\n that covered the new features.\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n
\n
Buy once, get all updates for free
\n
\n
\n
\n\n
\n
The first edition of this book followed Ember's journey to\n its 2.0 release. As Ember gracefully shedded old syntaxes, the\n book's content was updated not to use those syntaxes, either.\n When a new feature appeared, I added a section about it, trying\n to find a practical example for it in the application.
\n\n
Since Ember follows a 6-week release cycle, that meant\n frequent book updates, precisely 8 \"minor book releases\" in a\n little less than 7 months. These updates came free for all of my\n customers, no matter which package they chose. I aim to follow a\n similar path and update policy with Ember 2.x. The framework\n makes progress really fast but I'll keep in sync with the latest\n stable version of Ember and keep the content fresh. And\n free until at least the next major version.
\n
\n
\n\n
\n
\n
\n
\n
\n
I really like it! It is super difficult to find the right balance between pacing and detail\nand put it all together in an understandable form but you pulled it off.
\n
\n
\n \n \n \n
\n — Cory Forsyth\n 201 Created\n
\n
\n
\n
\n\n
\n
\n
\n
Just wanted to say thanks for the ongoing updates of the book. Even after finishing the book, it\u2019s becoming a great reference for the changes Ember is going through (even more so than the official docs).
\n
\n
\n \n \n \n
\n — Gabriel Rotbart\n
\n
\n
\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n
\n
\n
Table of Contents
\n
\n
\n
\n
\n\n
\n
\n
\n \n
\n
\n
Preface\n\n
\n
My love affair with Ember.js
\n
Acknowledgements
\n
\n
Introduction to Ember.js\n\n
\n
Why Ember.js
\n
Backstage - Dial M for Model
\n
About this book
\n
Is this book for you?
\n
Ambitious goal for an ambitious framework
\n
The application we are going to build
\n
Errata
\n
\n
Ember CLI\n\n
\n
Setting up Ember CLI
\n
Creating our application
\n
\n
Templates and data bindings\n\n
\n
The first template
\n
Showing a list of songs in the application template
\n
Backstage - Handlebar's fail-softness
\n
Backstage - ES2015 modules
\n
Backstage - Class and instance properties
\n
Adding libraries to the build
\n
Importing needed assets manually
\n
Using an Ember add-on
\n
Auto-updating templates
\n
\n
Routing\n\n
\n
What do we want to achieve?
\n
New styles
\n
Routes set up data
\n
Backstage - A word about generated test files
\n
Moving around with link-to
\n
Using the model property
\n
Showing a list of bands
\n
Showing a list of songs
\n
\n
Nested routes\n\n
\n
Defining the nested routes
\n
Full route names
\n
Backstage - Resource routes
\n
Stepping through a router transition
\n
Backstage - Computed properties
\n
Nested templates
\n
{{outlet}} is the default template for routes
\n
\n
Actions\n\n
\n
Extracting model classes
\n
The class-level mutable attribute property
\n
Capturing the event
\n
Turning event into intent
\n
\n
Components\n\n
\n
The idea behind components
\n
Component specification
\n
Defining the component's properties
\n
Using the component
\n
Displaying the rating with stars
\n
Backstage - The default component template
\n
Backstage - On the utility of explicit dependency definitions
\n
Speaking to the outside world through actions
\n
Closure actions
\n
\n
Controllers\n\n
\n
Preventing the creation of bands without a name
\n
Smooth UI flows
\n
Going to the band page after it is created
\n
Nudging the user to create the first song
\n
Showing the text field when the call to action has been acted on
\n
Creating new bands and songs by pressing return
\n
Backstage - Where to handle actions?
\n
\n
Advanced routing\n\n
\n
Route hooks
\n
Route actions
\n
Redirection
\n
Redirecting before the model is known
\n
Redirecting after the model is known
\n
Backstage - Skipping model resolution
\n
Leaving routes and arriving at them
\n
Setting descriptive page titles
\n
Warning about losing data
\n
\n
Talking to a backend - with Ember Data\n\n
\n
The concept behind Ember Data
\n
The API
\n
Model classes
\n
Transforming the app to use Ember Data
\n
Loading bands
\n
Fetching a single band
\n
Loading songs for a band
\n
Creating a band
\n
Updating a band's description
\n
Updating song ratings
\n
Backstage - Promises
\n
\n
Testing\n\n
\n
Clarifying the vocabulary
\n
Acceptance tests
\n
To mock or not to mock?
\n
Unit tests
\n
Integration tests
\n
Adding an acceptance test
\n
Analyzing an Ember acceptance test
\n
Making the first test pass
\n
Safeguarding critical user scenarios
\n
Creating a band
\n
Creating a song
\n
Backstage \u2013 Fake synchronous tests
\n
Writing your own test helpers
\n
Registering a synchronous helper
\n
Registering an async helper
\n
Refactoring stubs
\n
Integration tests in Ember
\n
Unit tests in Ember
\n
\n
Sorting and searching with query parameters\n\n
\n
Query parameters
\n
Query parameters in Ember
\n
Sorting the list of songs
\n
Sorting an array of items
\n
Backstage - Computed property macros
\n
Changing the sorting criteria
\n
Filtering songs by a search term
\n
Adding a dash of query parameters
\n
Using links instead of buttons
\n
Taking a look at what we made
\n
\n
Loading and error routes\n\n
\n
Loading routes
\n
Backstage - Rendering the loading template is an overridable default
\n
Error routes
\n
\n
Helpers\n\n
\n
About helpers
\n
Capitalizing each word of a name
\n
Using it in templates, or elsewhere
\n
Use dashed names for helpers
\n
\n
Animations\n\n
\n
Setting up liquid-fire
\n
liquid-fire architecture
\n
Transition map
\n
Transition functions
\n
Template helpers
\n
Putting it all together
\n
Debugging transitions
\n
Animate moving between routes
\n
Adding a custom animation
\n
Animate a value change
\n
\n
Making an Ember addon\n\n
\n
What is an Ember addon?
\n
Developing the addon
\n
Integrating our addon into our app
\n
Adding a block form
\n
Customizing the star-rating component's look and behavior
\n
Publishing the addon
\n
Using a published addon from the app
\n
\n
ES2015 - Writing modern JavaScript\n\n
\n
Modernizing the app
\n
Modules
\n
Template strings
\n
Short-hand method definitions
\n
Replacing var (let & const)
\n
Arrow functions
\n
Destructuring
\n
Other useful ES2015 features
\n
Backstage - ember-watson
\n
Computed property macros
\n
\n
Deployment\n\n
\n
FrontPage
\n
Heroku
\n
ember-cli-deploy
\n
\n
Afterword\n\n
\n
Your journey with Ember.js
\n
\n
\n\n
\n\n \n
\n \n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n\n
\n
About me
\n
Hello there, I'm Balint Erdi.
\n
\n I have a long history of building web applications and have mostly been a back-end\n guy.\n
\n
\n On a grey, chilly February day in 2013 that I\u2019ll never forget (maybe it was\n January?) I got acquainted with Ember.js. Ember.js made that day bright and the\n ones that came after that. After learning the ropes I shifted gears and have been\n proselytizing for Ember since last summer.\n
\n
\n I gave a beginner\u2019s workshop at Eurucamp, and held presentations at Arrrrcamp, The Geek Gathering and EmberFest. I started an Ember.js mailing list, made an introductory\n screencast series and have been sending Ember content to my dear subscribers on a\n weekly basis. I have also written guest articles for Safari Books Online, Firebase\n and Toptal.\n
\n
\n I guess you could say I\u2019m pretty passionate about Ember.\n
\n
\n Oh, and I love rock & roll, obviously.\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n
\n
Bonus: Exclusive hack.hands() deal
\n
\n
\n
\n
\n
\n hack.hands()\n is your SOS button for live programming support, available 24/7. hack.hands() instantly connects developers with a network of expert programmers at the click of a button. Never get stuck, learn more and keep coding!\n If you buy any package, you will receive $25 to spend on their platform that you can use to get your Ember project unstuck.\n
\n
\n
\n\n
\n
\n
\n
\n
\n
Even though I have worked with Ember for the past 6 months, the book helped clarify a lot of things, especially new features and their deprecated counterparts. Such a great book, and looking forward to the second one!
\n
\n
\n \n \n \n
\n — David Tang\n
\n
\n
\n
\n\n
\n
\n
\n
There is almost nowhere to go to get a good grounding in Ember. In months of searching this is the best resource that exists... so much so I'm going to try to get a few copies sorted out for my team at work. Thanks Balint!
\n
\n
\n \n \n \n
\n — Andy Davison\n
\n
\n
\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n
\n
Stairway to Heaven Package
\n
\n
\n
\n\n
\n
\n
\n The path to Ember.js bliss, this package contains all you need to take your Ember.js skills to the next level. It contains:
\n \n
\n
\n
\n
\n\n
\n
\n
\n
\n
\n
This was a truly great series of screencasts. Very, very well done. Simple enough while not being simplistic.
\n
\n
\n \n \n \n
\n — Claude Pr\u00e9court\n
\n
\n
\n
\n\n
\n
\n
\n
Nice work with these Ember tutorials. You're doing a really nice thing for the community.
\n
\n
\n \n \n \n
\n — Steven Kane\n
\n
\n
\n
\n
\n
\n \n \n \n
\n
\n
\n
\n
\n
\n \n
\n
The book
\n 18 chapters\n
This is what you absolutely need to get up & running with Ember.js. Comes in pdf, mobi and epub formats for your reading pleasure.
\n
\n
\n\n
\n
\n
\n \n
\n
Access to the code
\n All of the source code\n
in the application so that you can check how the app looks & works at each step. Or tweak it to your liking.
\n
\n
\n\n
\n
\n
\n \n
\n
Screencasts
\n 4 screencasts\n
They run around 10 minutes each and cover the following,\n advanced topics: Pods in Ember CLI, Animations,\n Authentication & Authorization, and ES2015 &\n computed macros.
I\u2019m REALLY enjoying the book and find it to be very thorough and informative. You\u2019ve done a great job of answering questions I had about various concepts that were not detailed clearly elsewhere.
It\u2019s been an invaluable resource in learning Ember and one I would recommend to any developer wanting to get started with the framework.
\n
\n
\n \n \n \n
\n — Jonathan Rowley\n
\n
\n
\n
\n
\n
\n
\n \n \n\n \n \n
\n
\n
\n \n
\n
\n
Hmm, I\u2019m not sure...
\n
\n
\n
\n\n
\n
\n
\n
Is the book ready for Ember 2?
\n
\n Yes, it is! The app in the book runs Ember (and Ember Data)\n 2 and does not use any deprecated stuff.\n
\n
\n\n
\n
Is this book for me?
\n
\n The book starts from the very basics (installing\n ember-cli, writing your first template, etc.) so if you\n completely get Ember, this book is probably not for you. If\n you are just starting out (or about to) or want to\n understand fundamental concepts in Ember, the book is\n definitely for you.\n
\n
\n\n
\n
What if I don't like the book?
\n
\n I offer a 60-day moneyback guarantee. No strings attached,\n just send your purchase receipt (or email address) to\n rarwe-book@balinterdi.com or answer to the welcome email\n that you received when you purchased.\n
\n
\n\n
\n
Everything is changing so fast; won't the content be outdated by next week?
\n
\n As Ember.js moves towards 3.0, I will keep updating the\n content of the book so that it stays void of deprecation\n warnings and does not promote practices that are no longer\n considered idiomatic. For the 1st edition of the book,\n I released an update once about every four weeks,\n more often than Ember stable versions came out.\n Expect the same for the this book edition.\n
\n
\n\n
\n
I heard Ember is so hard. Will this book help me understand it?
\n
\n I think there are a handful of key concepts in Ember.js\n that you need to understand to master it (probably the main\n one among these is routing). Once you understand these,\n Ember is not that hard. The intention of the book is\n to introduce concepts by way of building an actual\n application, so you see them applied in practice right away.\n That also helps the learning process. I also encourage you\n to work through the book as you read it, since that makes\n things sink in even deeper. You have access to the code\n repository if you have purchased the middle- or\n high-tier package. If I failed to explain Ember for you, please\n send me your purchase receipt to rarwe-book@balinterdi.com\n within 60 days of purchase and I\u2019ll issue a refund.\n
\n
\n\n
\n
Is the book DRM protected?
\n
\n No, it\u2019s not. If you would like to share it with\n colleagues (or a class), please contact me at rarwe-book@balinterdi.com.
\n
\n\n
\n
What if I buy the book-only package and later realize I want to switch to a higher package?
\n
No problem! Just send me your purchase receipt to rarwe-book@balinterdi.com, and I will upgrade you for the difference between the package prices.
This book is a fabulous, approachable, foray into Emberjs that makes the learning curve much less scary. I just wish it had been available sooner for students in my previous classes.
\n
\n
\n \n \n \n
\n — Matt Hale\n Assistant Professor at the University of Nebraska\n
\n
\n
\n
\n\n
\n
\n
\n
I\u2019ve gone through the first four chapters and I am already loving it.
\n
\n
\n \n \n \n
\n — Sergio Arbeo\n EmberMadrid\n
\n
\n
\n
\n
\n
\n \n \n\n \n \n \n\n \n\n \n \n \n \n\n \n \n\n\n\n"}}
{"repo": "sebastianbergmann/phpcpd", "pr_number": 206, "title": "Fixing regressed bug-fix for Issue#147", "state": "closed", "merged_at": null, "additions": 1, "deletions": 1, "files_changed": ["src/CLI/Application.php"], "files_before": {"src/CLI/Application.php": "\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\nnamespace SebastianBergmann\\PHPCPD;\n\nuse const PHP_EOL;\nuse function count;\nuse function printf;\nuse SebastianBergmann\\FileIterator\\Facade;\nuse SebastianBergmann\\PHPCPD\\Detector\\Detector;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\AbstractStrategy;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\DefaultStrategy;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\StrategyConfiguration;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\SuffixTreeStrategy;\nuse SebastianBergmann\\PHPCPD\\Log\\PMD;\nuse SebastianBergmann\\PHPCPD\\Log\\Text;\nuse SebastianBergmann\\Timer\\ResourceUsageFormatter;\nuse SebastianBergmann\\Timer\\Timer;\nuse SebastianBergmann\\Version;\n\nfinal class Application\n{\n private const VERSION = '7.0';\n\n public function run(array $argv): int\n {\n $this->printVersion();\n\n try {\n $arguments = (new ArgumentsBuilder)->build($argv);\n } catch (Exception $e) {\n print PHP_EOL . $e->getMessage() . PHP_EOL;\n\n return 1;\n }\n\n if ($arguments->version()) {\n return 0;\n }\n\n print PHP_EOL;\n\n if ($arguments->help()) {\n $this->help();\n\n return 0;\n }\n\n $files = (new Facade)->getFilesAsArray(\n $arguments->directories(),\n $arguments->suffixes(),\n '',\n $arguments->exclude()\n );\n\n if (empty($files)) {\n print 'No files found to scan' . PHP_EOL;\n\n return 1;\n }\n\n $config = new StrategyConfiguration($arguments);\n\n try {\n $strategy = $this->pickStrategy($arguments->algorithm(), $config);\n } catch (InvalidStrategyException $e) {\n print $e->getMessage() . PHP_EOL;\n\n return 1;\n }\n\n $timer = new Timer;\n $timer->start();\n\n $clones = (new Detector($strategy))->copyPasteDetection($files);\n\n (new Text)->printResult($clones, $arguments->verbose());\n\n if ($arguments->pmdCpdXmlLogfile()) {\n (new PMD($arguments->pmdCpdXmlLogfile()))->processClones($clones);\n }\n\n print (new ResourceUsageFormatter)->resourceUsage($timer->stop()) . PHP_EOL;\n\n return count($clones) > 0 ? 1 : 0;\n }\n\n private function printVersion(): void\n {\n printf(\n 'phpcpd %s by Sebastian Bergmann.' . PHP_EOL,\n (new Version(self::VERSION, dirname(__DIR__)))->getVersion()\n );\n }\n\n /**\n * @throws InvalidStrategyException\n */\n private function pickStrategy(?string $algorithm, StrategyConfiguration $config): AbstractStrategy\n {\n return match ($algorithm) {\n null, 'rabin-karp' => new DefaultStrategy($config),\n 'suffixtree' => new SuffixTreeStrategy($config),\n default => throw new InvalidStrategyException('Unsupported algorithm: ' . $algorithm),\n };\n }\n\n private function help(): void\n {\n print <<<'EOT'\nUsage:\n phpcpd [options] \n\nOptions for selecting files:\n\n --suffix Include files with names ending in in the analysis\n (default: .php; can be given multiple times)\n --exclude Exclude files with in their path from the analysis\n (can be given multiple times)\n\nOptions for analysing files:\n\n --fuzzy Fuzz variable names\n --min-lines Minimum number of identical lines (default: 5)\n --min-tokens Minimum number of identical tokens (default: 70)\n --algorithm Select which algorithm to use ('rabin-karp' (default) or 'suffixtree')\n --edit-distance Distance in number of edits between two clones (only for suffixtree; default: 5)\n --head-equality Minimum equality at start of clone (only for suffixtree; default 10)\n\nOptions for report generation:\n\n --log-pmd Write log in PMD-CPD XML format to \n\nEOT;\n }\n}\n"}, "files_after": {"src/CLI/Application.php": "\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\nnamespace SebastianBergmann\\PHPCPD;\n\nuse const PHP_EOL;\nuse function count;\nuse function printf;\nuse SebastianBergmann\\FileIterator\\Facade;\nuse SebastianBergmann\\PHPCPD\\Detector\\Detector;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\AbstractStrategy;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\DefaultStrategy;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\StrategyConfiguration;\nuse SebastianBergmann\\PHPCPD\\Detector\\Strategy\\SuffixTreeStrategy;\nuse SebastianBergmann\\PHPCPD\\Log\\PMD;\nuse SebastianBergmann\\PHPCPD\\Log\\Text;\nuse SebastianBergmann\\Timer\\ResourceUsageFormatter;\nuse SebastianBergmann\\Timer\\Timer;\nuse SebastianBergmann\\Version;\n\nfinal class Application\n{\n private const VERSION = '7.0';\n\n public function run(array $argv): int\n {\n $this->printVersion();\n\n try {\n $arguments = (new ArgumentsBuilder)->build($argv);\n } catch (Exception $e) {\n print PHP_EOL . $e->getMessage() . PHP_EOL;\n\n return 1;\n }\n\n if ($arguments->version()) {\n return 0;\n }\n\n print PHP_EOL;\n\n if ($arguments->help()) {\n $this->help();\n\n return 0;\n }\n\n $files = (new Facade)->getFilesAsArray(\n $arguments->directories(),\n $arguments->suffixes(),\n '',\n $arguments->exclude()\n );\n\n if (empty($files)) {\n print 'No files found to scan' . PHP_EOL;\n\n return 0;\n }\n\n $config = new StrategyConfiguration($arguments);\n\n try {\n $strategy = $this->pickStrategy($arguments->algorithm(), $config);\n } catch (InvalidStrategyException $e) {\n print $e->getMessage() . PHP_EOL;\n\n return 1;\n }\n\n $timer = new Timer;\n $timer->start();\n\n $clones = (new Detector($strategy))->copyPasteDetection($files);\n\n (new Text)->printResult($clones, $arguments->verbose());\n\n if ($arguments->pmdCpdXmlLogfile()) {\n (new PMD($arguments->pmdCpdXmlLogfile()))->processClones($clones);\n }\n\n print (new ResourceUsageFormatter)->resourceUsage($timer->stop()) . PHP_EOL;\n\n return count($clones) > 0 ? 1 : 0;\n }\n\n private function printVersion(): void\n {\n printf(\n 'phpcpd %s by Sebastian Bergmann.' . PHP_EOL,\n (new Version(self::VERSION, dirname(__DIR__)))->getVersion()\n );\n }\n\n /**\n * @throws InvalidStrategyException\n */\n private function pickStrategy(?string $algorithm, StrategyConfiguration $config): AbstractStrategy\n {\n return match ($algorithm) {\n null, 'rabin-karp' => new DefaultStrategy($config),\n 'suffixtree' => new SuffixTreeStrategy($config),\n default => throw new InvalidStrategyException('Unsupported algorithm: ' . $algorithm),\n };\n }\n\n private function help(): void\n {\n print <<<'EOT'\nUsage:\n phpcpd [options] \n\nOptions for selecting files:\n\n --suffix Include files with names ending in in the analysis\n (default: .php; can be given multiple times)\n --exclude Exclude files with in their path from the analysis\n (can be given multiple times)\n\nOptions for analysing files:\n\n --fuzzy Fuzz variable names\n --min-lines Minimum number of identical lines (default: 5)\n --min-tokens Minimum number of identical tokens (default: 70)\n --algorithm Select which algorithm to use ('rabin-karp' (default) or 'suffixtree')\n --edit-distance Distance in number of edits between two clones (only for suffixtree; default: 5)\n --head-equality Minimum equality at start of clone (only for suffixtree; default 10)\n\nOptions for report generation:\n\n --log-pmd Write log in PMD-CPD XML format to \n\nEOT;\n }\n}\n"}}
{"repo": "jezdez/limechat-whisper", "pr_number": 1, "title": "fix display of #channame or www.link.com", "state": "closed", "merged_at": "2012-08-03T20:35:28Z", "additions": 1, "deletions": 1, "files_changed": ["Whisper.css"], "files_before": {"Whisper.css": "html.normal {\n color: #4b4b4b;\n background-color: white;\n font: 12px/1.3em 'Lucida Grande' sans-serif;\n margin: 0;\n padding: 0;\n}\n\nbody.normal .sender[type=myself]:hover:before {\n content: \"\u2022 \";\n color: #bebebe;\n}\n\nbody.normal a img {\n border: 0;\n}\n\nbody.normal img {\n display: block;\n padding-top: 5px;\n padding-bottom: 5px;\n padding-left: 8px;\n max-width: 95%;\n}\n\nbody.normal a:link, a:visited, a:hover, a:active {\n color: #184586;\n}\n\nbody.normal .text span {\n display: block;\n}\n\nbody.normal .line {\n padding: 0;\n margin: 0;\n background-color: #eee;\n line-height: 130%;\n}\n\nbody.normal .event {\n padding: 0.2em;\n margin: 0;\n color: #363636;\n background: #e5edf7;\n}\n\nbody.normal .event + .event {\n border-top: #fff 1px solid;\n}\n\nbody.normal .text span.message {\n border-bottom: #efefef 1px solid;\n}\n\nbody.normal .text + .event {\n margin-top: -1px;\n}\n\nbody.normal .sender {\n padding: 0.4em 0;\n float: left;\n text-align: right;\n font-weight: bold;\n width: 130px;\n overflow: hidden;\n}\n\nbody.normal .line .message {\n margin: 0 0 0 134px;\n padding: 0.4em;\n color: #303030;\n border-left: 1px solid #dcdcdc;\n background-color: #fff;\n}\n\nbody.normal .event .message {\n margin: 0;\n padding: 0.4em;\n border: 0;\n color: #a6b9c0;\n background: none;\n font: bold 11px \"Helvetica Neue\", Arial, Helvetica, sans-serif;\n}\n\nbody.normal .line .time {\n float: right;\n margin-right: 6px;\n margin-top: 5px;\n margin-left: 4px;\n color: #999;\n font: bold 11px \"Helvetica Neue\", Arial, Helvetica, sans-serif;\n}\n\nbody.normal .line .place {\n display: block;\n color: #999;\n margin: 0;\n font-size: 12px;\n}\n\nbody.normal .event .time {\n margin: 1px 3px;\n float: right;\n text-align: right;\n font-size: 11px;\n color: #a6b9c0;\n}\n\nbody.normal .line[highlight=true] span.message {\n background-color: #ffc;\n}\n\nbody.normal .member {\n text-decoration: none !important;\n color: inherit !important;\n}\n\nbody.normal .member:hover {\n text-decoration: underline;\n}\n\nbody.normal {\n \n}\n\nbody.console {\n \n}\n\nbody[type=channel] {\n \n}\n\nbody[type=talk] {\n \n}\n\nbody[type=console] {\n \n}\n\nbody.normal hr {\n margin: 0;\n padding: 2px;\n border: none;\n background-color: #d33b54;\n height: 2px;\n text-align: center;\n}\n\na {\n \n}\n\n/* lines */\n\n.line[alternate=even] {\n \n}\n\n.line[alternate=odd] {\n \n}\n\n.line[type=action] .sender:before {\n content: \"\";\n}\n\nbody.normal .line[type=action] .sender {\n font-style: italic;\n}\n\nbody.normal .line[type=action] .message {\n background: #eee;\n border-left: none;\n margin: 0 0 0 130px;\n}\n\nbody.normal .url {\n word-break: break-all;\n}\n\nbody.normal .address {\n text-decoration: underline;\n word-break: break-all;\n}\n\nbody.normal .highlight {\n color: #d33b54;\n font-weight: bold;\n}\n\n/* nickname for text messages */\n\nbody.normal .sender[type=myself] {\n color: #333;\n}\n\nbody.normal .sender[type=normal] {\n color: #333;\n}\n\nbody.normal .sender[type=normal][colornumber='0'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='1'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='2'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='3'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='4'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='5'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='6'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='7'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='8'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='9'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='10'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='11'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='12'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='13'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='14'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='15'] {\n \n}\n\n/* message body */\n\nbody.normal .message[type=system] {\n color: #303030;\n}\n\nbody.normal .message[type=error] {\n color: #d14025;\n font-weight: bold;\n}\n\nbody.normal .message[type=reply] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=error_reply] {\n color: #d33b54;\n}\n\nbody.normal .message[type=dcc_send_send] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=dcc_send_receive] {\n color: #153b7c;\n}\n\nbody.normal .message[type=privmsg] {\n \n}\n\nbody.normal .message[type=notice] {\n color: #888;\n}\n\nbody.normal .message[type=action] {\n color: #303030;\n font-style: italic;\n font-weight: bold;\n}\n\nbody.normal .message[type=join] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=part] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=kick] {\n color: #303030;\n}\n\nbody.normal .message[type=quit] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=kill] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=nick] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=mode] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=topic] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=invite] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=wallops] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=debug_send] {\n color: #aaa;\n}\n\nbody.normal .message[type=debug_receive] {\n color: #444;\n}"}, "files_after": {"Whisper.css": "html.normal {\n color: #4b4b4b;\n background-color: white;\n font: 12px/1.3em 'Lucida Grande' sans-serif;\n margin: 0;\n padding: 0;\n}\n\nbody.normal .sender[type=myself]:hover:before {\n content: \"\u2022 \";\n color: #bebebe;\n}\n\nbody.normal a img {\n border: 0;\n}\n\nbody.normal img {\n display: block;\n padding-top: 5px;\n padding-bottom: 5px;\n padding-left: 8px;\n max-width: 95%;\n}\n\nbody.normal a:link, a:visited, a:hover, a:active {\n color: #184586;\n}\n\nbody.normal .text > span {\n display: block;\n}\n\nbody.normal .line {\n padding: 0;\n margin: 0;\n background-color: #eee;\n line-height: 130%;\n}\n\nbody.normal .event {\n padding: 0.2em;\n margin: 0;\n color: #363636;\n background: #e5edf7;\n}\n\nbody.normal .event + .event {\n border-top: #fff 1px solid;\n}\n\nbody.normal .text span.message {\n border-bottom: #efefef 1px solid;\n}\n\nbody.normal .text + .event {\n margin-top: -1px;\n}\n\nbody.normal .sender {\n padding: 0.4em 0;\n float: left;\n text-align: right;\n font-weight: bold;\n width: 130px;\n overflow: hidden;\n}\n\nbody.normal .line .message {\n margin: 0 0 0 134px;\n padding: 0.4em;\n color: #303030;\n border-left: 1px solid #dcdcdc;\n background-color: #fff;\n}\n\nbody.normal .event .message {\n margin: 0;\n padding: 0.4em;\n border: 0;\n color: #a6b9c0;\n background: none;\n font: bold 11px \"Helvetica Neue\", Arial, Helvetica, sans-serif;\n}\n\nbody.normal .line .time {\n float: right;\n margin-right: 6px;\n margin-top: 5px;\n margin-left: 4px;\n color: #999;\n font: bold 11px \"Helvetica Neue\", Arial, Helvetica, sans-serif;\n}\n\nbody.normal .line .place {\n display: block;\n color: #999;\n margin: 0;\n font-size: 12px;\n}\n\nbody.normal .event .time {\n margin: 1px 3px;\n float: right;\n text-align: right;\n font-size: 11px;\n color: #a6b9c0;\n}\n\nbody.normal .line[highlight=true] span.message {\n background-color: #ffc;\n}\n\nbody.normal .member {\n text-decoration: none !important;\n color: inherit !important;\n}\n\nbody.normal .member:hover {\n text-decoration: underline;\n}\n\nbody.normal {\n \n}\n\nbody.console {\n \n}\n\nbody[type=channel] {\n \n}\n\nbody[type=talk] {\n \n}\n\nbody[type=console] {\n \n}\n\nbody.normal hr {\n margin: 0;\n padding: 2px;\n border: none;\n background-color: #d33b54;\n height: 2px;\n text-align: center;\n}\n\na {\n \n}\n\n/* lines */\n\n.line[alternate=even] {\n \n}\n\n.line[alternate=odd] {\n \n}\n\n.line[type=action] .sender:before {\n content: \"\";\n}\n\nbody.normal .line[type=action] .sender {\n font-style: italic;\n}\n\nbody.normal .line[type=action] .message {\n background: #eee;\n border-left: none;\n margin: 0 0 0 130px;\n}\n\nbody.normal .url {\n word-break: break-all;\n}\n\nbody.normal .address {\n text-decoration: underline;\n word-break: break-all;\n}\n\nbody.normal .highlight {\n color: #d33b54;\n font-weight: bold;\n}\n\n/* nickname for text messages */\n\nbody.normal .sender[type=myself] {\n color: #333;\n}\n\nbody.normal .sender[type=normal] {\n color: #333;\n}\n\nbody.normal .sender[type=normal][colornumber='0'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='1'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='2'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='3'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='4'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='5'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='6'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='7'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='8'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='9'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='10'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='11'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='12'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='13'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='14'] {\n \n}\n\nbody.normal .sender[type=normal][colornumber='15'] {\n \n}\n\n/* message body */\n\nbody.normal .message[type=system] {\n color: #303030;\n}\n\nbody.normal .message[type=error] {\n color: #d14025;\n font-weight: bold;\n}\n\nbody.normal .message[type=reply] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=error_reply] {\n color: #d33b54;\n}\n\nbody.normal .message[type=dcc_send_send] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=dcc_send_receive] {\n color: #153b7c;\n}\n\nbody.normal .message[type=privmsg] {\n \n}\n\nbody.normal .message[type=notice] {\n color: #888;\n}\n\nbody.normal .message[type=action] {\n color: #303030;\n font-style: italic;\n font-weight: bold;\n}\n\nbody.normal .message[type=join] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=part] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=kick] {\n color: #303030;\n}\n\nbody.normal .message[type=quit] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=kill] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=nick] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=mode] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=topic] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=invite] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=wallops] {\n color: #a6b9c0;\n}\n\nbody.normal .message[type=debug_send] {\n color: #aaa;\n}\n\nbody.normal .message[type=debug_receive] {\n color: #444;\n}"}}
{"repo": "paveltyk/technical-test", "pr_number": 1, "title": "improve CLI", "state": "closed", "merged_at": "2010-09-30T09:53:36Z", "additions": 7, "deletions": 1, "files_changed": ["lib/editor.rb"], "files_before": {"lib/editor.rb": "require 'image'\nrequire 'readline'\n\nclass Editor\n def initialize(output)\n @output = output\n end\n def start\n @output.puts 'Welcome to Image Editor!'\n listen\n end\n\n def listen\n loop do\n cmd = Readline::readline '> ', true\n execute(cmd)\n end\n end\n\n def execute(cmd)\n case cmd\n when /^i (\\d+)+ (\\d+)+$/i\n @image = Image.new($1.to_i, $2.to_i)\n when /^c/i\n @image.clear\n when /^l (\\d+) (\\d+) ([a-z])$/i\n @image.colorize($1.to_i, $2.to_i,$3)\n when /^v (\\d+) (\\d+) (\\d+) ([a-z])$/i\n @image.draw_vertical_segment($1.to_i, $2.to_i, $3.to_i, $4)\n when /^h (\\d+) (\\d+) (\\d+) ([a-z])$/i\n @image.draw_horizontal_segment($1.to_i, $2.to_i, $3.to_i, $4)\n when /^f (\\d+) (\\d+) ([a-z])$/i\n @image.fill($1.to_i, $2.to_i, $3)\n when /^s$/i\n @output.puts @image.to_s\n when /^x$/i\n exit\n else\n puts 'Unknown command'\n end\n end\n \nend"}, "files_after": {"lib/editor.rb": "require 'image'\nrequire 'readline'\n\n# trap SIGINT and restore the state of the terminal\nstty_save = `stty -g`.chomp\ntrap('INT') { system('stty', stty_save); exit }\n\nclass Editor\n def initialize(output)\n @output = output\n end\n def start\n @output.puts 'Welcome to Image Editor!'\n listen\n end\n\n def listen\n loop do\n cmd = Readline::readline '> ', true\n # exit if user press CTRL-D\n exit if cmd.nil?\n execute(cmd)\n end\n end\n\n def execute(cmd)\n case cmd\n when /^i (\\d+)+ (\\d+)+$/i\n @image = Image.new($1.to_i, $2.to_i)\n when /^c/i\n @image.clear\n when /^l (\\d+) (\\d+) ([a-z])$/i\n @image.colorize($1.to_i, $2.to_i,$3)\n when /^v (\\d+) (\\d+) (\\d+) ([a-z])$/i\n @image.draw_vertical_segment($1.to_i, $2.to_i, $3.to_i, $4)\n when /^h (\\d+) (\\d+) (\\d+) ([a-z])$/i\n @image.draw_horizontal_segment($1.to_i, $2.to_i, $3.to_i, $4)\n when /^f (\\d+) (\\d+) ([a-z])$/i\n @image.fill($1.to_i, $2.to_i, $3)\n when /^s$/i\n @output.puts @image.to_s\n when /^x$/i\n exit\n else\n puts 'Unknown command'\n end\n end\n \nend\n"}}
{"repo": "nhowell/subdomain-fu", "pr_number": 1, "title": "Path url_for to work on on Rails 4.2", "state": "closed", "merged_at": null, "additions": 14, "deletions": 2, "files_changed": ["lib/subdomain_fu/url_rewriter.rb"], "files_before": {"lib/subdomain_fu/url_rewriter.rb": "require 'action_dispatch/routing/route_set'\n\nmodule ActionDispatch\n module Routing\n class RouteSet #:nodoc:\n def url_for_with_subdomains(options, path_segments=nil)\n if SubdomainFu.needs_rewrite?(options[:subdomain], (options[:host] || @request.host_with_port)) || options[:only_path] == false\n options[:only_path] = false if SubdomainFu.override_only_path?\n options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || @request.host_with_port)\n # puts \"options[:host]: #{options[:host].inspect}\"\n else\n options.delete(:subdomain)\n end\n url_for_without_subdomains(options)\n end\n alias_method_chain :url_for, :subdomains\n end\n end\nend\n"}, "files_after": {"lib/subdomain_fu/url_rewriter.rb": "require 'action_dispatch/routing/route_set'\n\nmodule ActionDispatch\n module Routing\n class RouteSet #:nodoc:\n # Known Issue: Monkey-patching `url_for` is error-prone.\n # For example, in rails 4.2, the method signature changed from\n #\n # def url_for(options)\n #\n # to\n #\n # def url_for(options, route_name = nil, url_strategy = UNKNOWN)\n #\n # Is there an alternative design using composition or class\n # inheritance?\n\n def url_for_with_subdomains(options, *args)\n if SubdomainFu.needs_rewrite?(options[:subdomain], (options[:host] || @request.host_with_port)) || options[:only_path] == false\n options[:only_path] = false if SubdomainFu.override_only_path?\n options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || @request.host_with_port)\n # puts \"options[:host]: #{options[:host].inspect}\"\n else\n options.delete(:subdomain)\n end\n url_for_without_subdomains(options, *args)\n end\n alias_method_chain :url_for, :subdomains\n end\n end\nend\n"}}
{"repo": "jcsalterego/nagios-rb", "pr_number": 1, "title": "unbreak adding further options", "state": "closed", "merged_at": "2012-02-16T16:25:17Z", "additions": 1, "deletions": 1, "files_changed": ["lib/nagios/config.rb"], "files_before": {"lib/nagios/config.rb": "require 'optparse'\n\nmodule Nagios\n class Config\n\n attr_accessor :options\n\n def initialize\n @settings = {}\n @options = OptionParser.new do |options|\n options.on(\"-wWARNING\",\n \"--warning=WARNING\",\n \"Warning Threshold\") do |x|\n @settings[:warning] = int_if_possible(x)\n end\n options.on(\"-cCRITICAL\",\n \"--critical=CRITICAL\",\n \"Critical Threshold\") do |x|\n @settings[:critical] = int_if_possible(x)\n end\n end\n end\n\n def [](setting)\n @settings[setting]\n end\n\n def []=(field, value)\n @settings[field] = vaule\n end\n\n def parse!\n @options.parse!\n end\n\n private\n def int_if_possible(x)\n (x.to_i > 0 || x == '0') ? x.to_i : x\n end\n end\nend\n"}, "files_after": {"lib/nagios/config.rb": "require 'optparse'\n\nmodule Nagios\n class Config\n\n attr_accessor :options\n\n def initialize\n @settings = {}\n @options = OptionParser.new do |options|\n options.on(\"-wWARNING\",\n \"--warning=WARNING\",\n \"Warning Threshold\") do |x|\n @settings[:warning] = int_if_possible(x)\n end\n options.on(\"-cCRITICAL\",\n \"--critical=CRITICAL\",\n \"Critical Threshold\") do |x|\n @settings[:critical] = int_if_possible(x)\n end\n end\n end\n\n def [](setting)\n @settings[setting]\n end\n\n def []=(field, value)\n @settings[field] = value\n end\n\n def parse!\n @options.parse!\n end\n\n private\n def int_if_possible(x)\n (x.to_i > 0 || x == '0') ? x.to_i : x\n end\n end\nend\n"}}
{"repo": "aconbere/evented", "pr_number": 1, "title": "Correct the URL for the github repo.", "state": "open", "merged_at": null, "additions": 1, "deletions": 1, "files_changed": ["lib/evented.js"], "files_before": {"lib/evented.js": "/*\n * YO check out the repository for updates\n * http://github.com/aconbere/event-emitter\n *\n */\nvar Evented = function () {\n this.listeners = {};\n this.listenersOnce = {};\n};\n\nEvented.prototype.withListeners = function (ev, callback) {\n if (!this.listeners[ev]) {\n this.listeners[ev] = [];\n }\n\n if (!this.listenersOnce[ev]) {\n this.listenersOnce[ev] = [];\n }\n\n if (callback) {\n callback(this.listeners[ev], this.listenersOnce[ev]);\n }\n};\n\nEvented.prototype.trigger = function (ev, data) {\n data = data || [];\n\n var that = this;\n this.withListeners(ev, function (listeners, listenersOnce) {\n for (var i = 0; i < listeners.length; i++) {\n listeners[i].apply(null, data);\n }\n\n for (var i = 0; i < listenersOnce.length; i++) {\n listenersOnce[i].apply(null, data);\n }\n // reset any of the once listeners for this event\n that.listenersOnce[ev] = [];\n });\n};\n\n\nEvented.prototype.bind = function (ev, callback) {\n this.withListeners(ev, function (listeners, _listenersOnce) {\n listeners.push(callback);\n });\n};\n\nEvented.prototype.bindOnce = function (ev, callback) {\n this.withListeners(ev, function (_listeners, listenersOnce) {\n listenersOnce.push(callback);\n });\n};\n\nEvented.prototype.unbindAll = function () {\n this.listeners = {};\n};\n\nif (typeof window === \"undefined\") {\n exports.Evented = Evented;\n}\n"}, "files_after": {"lib/evented.js": "/*\n * YO check out the repository for updates\n * http://github.com/aconbere/evented\n *\n */\nvar Evented = function () {\n this.listeners = {};\n this.listenersOnce = {};\n};\n\nEvented.prototype.withListeners = function (ev, callback) {\n if (!this.listeners[ev]) {\n this.listeners[ev] = [];\n }\n\n if (!this.listenersOnce[ev]) {\n this.listenersOnce[ev] = [];\n }\n\n if (callback) {\n callback(this.listeners[ev], this.listenersOnce[ev]);\n }\n};\n\nEvented.prototype.trigger = function (ev, data) {\n data = data || [];\n\n var that = this;\n this.withListeners(ev, function (listeners, listenersOnce) {\n for (var i = 0; i < listeners.length; i++) {\n listeners[i].apply(null, data);\n }\n\n for (var i = 0; i < listenersOnce.length; i++) {\n listenersOnce[i].apply(null, data);\n }\n // reset any of the once listeners for this event\n that.listenersOnce[ev] = [];\n });\n};\n\n\nEvented.prototype.bind = function (ev, callback) {\n this.withListeners(ev, function (listeners, _listenersOnce) {\n listeners.push(callback);\n });\n};\n\nEvented.prototype.bindOnce = function (ev, callback) {\n this.withListeners(ev, function (_listeners, listenersOnce) {\n listenersOnce.push(callback);\n });\n};\n\nEvented.prototype.unbindAll = function () {\n this.listeners = {};\n};\n\nif (typeof window === \"undefined\") {\n exports.Evented = Evented;\n}\n"}}
{"repo": "jtauber/web-graphics", "pr_number": 1, "title": "Fixed 'open' to write binary data in Windows too", "state": "closed", "merged_at": "2013-08-23T12:31:06Z", "additions": 1, "deletions": 1, "files_changed": ["web_graphics.py"], "files_before": {"web_graphics.py": "import zlib\nimport struct\nimport array\nimport random\nimport colorsys\n\n\ndef output_chunk(out, chunk_type, data):\n out.write(struct.pack(\"!I\", len(data)))\n out.write(chunk_type)\n out.write(data)\n checksum = zlib.crc32(data, zlib.crc32(chunk_type))\n out.write(struct.pack(\"!i\", checksum))\n\n\ndef get_data(width, height, rgb_func):\n fw = float(width)\n fh = float(height)\n compressor = zlib.compressobj()\n data = array.array(\"B\")\n for y in range(height):\n data.append(0)\n fy = float(y)\n for x in range(width):\n fx = float(x)\n data.extend([min(255, max(0, int(v * 255))) for v in rgb_func(fx / fw, fy / fh)])\n compressed = compressor.compress(data.tostring())\n flushed = compressor.flush()\n return compressed + flushed\n\n\ndef write_png(filename, width, height, rgb_func):\n out = open(filename, \"w\")\n out.write(struct.pack(\"8B\", 137, 80, 78, 71, 13, 10, 26, 10))\n output_chunk(out, \"IHDR\", struct.pack(\"!2I5B\", width, height, 8, 2, 0, 0, 0))\n output_chunk(out, \"IDAT\", get_data(width, height, rgb_func))\n output_chunk(out, \"IEND\", \"\")\n out.close()\n\n\ndef linear_gradient(start_value, stop_value, start_offset=0.0, stop_offset=1.0):\n return lambda offset: (start_value + ((offset - start_offset) / (stop_offset - start_offset) * (stop_value - start_value))) / 255.0\n\n\ndef LINEAR_Y(x, y):\n return y\n\n\ndef LINEAR_X(x, y):\n return x\n\n\ndef RADIAL(center_x, center_y):\n return lambda x, y: (x - center_x) ** 2 + (y - center_y) ** 2\n\n\ndef NO_NOISE(r, g, b):\n return r, g, b\n\n\ndef GAUSSIAN(sigma):\n def add_noise(r, g, b):\n d = random.gauss(0, sigma)\n return r + d, g + d, b + d\n return add_noise\n\n\ndef HSV(h, s, v):\n r, g, b = colorsys.hsv_to_rgb(h, s, v)\n return 255 * r, 255 * g, 255 * b\n\n\ndef hexstring_to_rgb(s):\n r = int(s[1:3], 16)\n g = int(s[3:5], 16)\n b = int(s[5:7], 16)\n return r, g, b\n\n\ndef gradient(value_func, noise_func, DATA):\n def gradient_function(x, y):\n initial_offset = 0.0\n v = value_func(x, y)\n for offset, start, end in DATA:\n if isinstance(start, str) and start.startswith(\"#\"):\n start = hexstring_to_rgb(start)\n if isinstance(end, str) and end.startswith(\"#\"):\n end = hexstring_to_rgb(end)\n if v < offset:\n r = linear_gradient(start[0], end[0], initial_offset, offset)(v)\n g = linear_gradient(start[1], end[1], initial_offset, offset)(v)\n b = linear_gradient(start[2], end[2], initial_offset, offset)(v)\n return noise_func(r, g, b)\n initial_offset = offset\n return noise_func(end[0] / 255.0, end[1] / 255.0, end[2] / 255.0)\n return gradient_function\n"}, "files_after": {"web_graphics.py": "import zlib\nimport struct\nimport array\nimport random\nimport colorsys\n\n\ndef output_chunk(out, chunk_type, data):\n out.write(struct.pack(\"!I\", len(data)))\n out.write(chunk_type)\n out.write(data)\n checksum = zlib.crc32(data, zlib.crc32(chunk_type))\n out.write(struct.pack(\"!i\", checksum))\n\n\ndef get_data(width, height, rgb_func):\n fw = float(width)\n fh = float(height)\n compressor = zlib.compressobj()\n data = array.array(\"B\")\n for y in range(height):\n data.append(0)\n fy = float(y)\n for x in range(width):\n fx = float(x)\n data.extend([min(255, max(0, int(v * 255))) for v in rgb_func(fx / fw, fy / fh)])\n compressed = compressor.compress(data.tostring())\n flushed = compressor.flush()\n return compressed + flushed\n\n\ndef write_png(filename, width, height, rgb_func):\n out = open(filename, \"wb\")\n out.write(struct.pack(\"8B\", 137, 80, 78, 71, 13, 10, 26, 10))\n output_chunk(out, \"IHDR\", struct.pack(\"!2I5B\", width, height, 8, 2, 0, 0, 0))\n output_chunk(out, \"IDAT\", get_data(width, height, rgb_func))\n output_chunk(out, \"IEND\", \"\")\n out.close()\n\n\ndef linear_gradient(start_value, stop_value, start_offset=0.0, stop_offset=1.0):\n return lambda offset: (start_value + ((offset - start_offset) / (stop_offset - start_offset) * (stop_value - start_value))) / 255.0\n\n\ndef LINEAR_Y(x, y):\n return y\n\n\ndef LINEAR_X(x, y):\n return x\n\n\ndef RADIAL(center_x, center_y):\n return lambda x, y: (x - center_x) ** 2 + (y - center_y) ** 2\n\n\ndef NO_NOISE(r, g, b):\n return r, g, b\n\n\ndef GAUSSIAN(sigma):\n def add_noise(r, g, b):\n d = random.gauss(0, sigma)\n return r + d, g + d, b + d\n return add_noise\n\n\ndef HSV(h, s, v):\n r, g, b = colorsys.hsv_to_rgb(h, s, v)\n return 255 * r, 255 * g, 255 * b\n\n\ndef hexstring_to_rgb(s):\n r = int(s[1:3], 16)\n g = int(s[3:5], 16)\n b = int(s[5:7], 16)\n return r, g, b\n\n\ndef gradient(value_func, noise_func, DATA):\n def gradient_function(x, y):\n initial_offset = 0.0\n v = value_func(x, y)\n for offset, start, end in DATA:\n if isinstance(start, str) and start.startswith(\"#\"):\n start = hexstring_to_rgb(start)\n if isinstance(end, str) and end.startswith(\"#\"):\n end = hexstring_to_rgb(end)\n if v < offset:\n r = linear_gradient(start[0], end[0], initial_offset, offset)(v)\n g = linear_gradient(start[1], end[1], initial_offset, offset)(v)\n b = linear_gradient(start[2], end[2], initial_offset, offset)(v)\n return noise_func(r, g, b)\n initial_offset = offset\n return noise_func(end[0] / 255.0, end[1] / 255.0, end[2] / 255.0)\n return gradient_function\n"}}
{"repo": "chnm/thatcamp-registrations", "pr_number": 28, "title": "Simplifies user creation.", "state": "closed", "merged_at": "2012-02-09T21:10:49Z", "additions": 5, "deletions": 18, "files_changed": ["thatcamp-registrations-functions.php"], "files_before": {"thatcamp-registrations-functions.php": "prefix . \"thatcamp_registrations\";\n \n $_POST = stripslashes_deep($_POST); \n \n // The user_id is set to the posted user ID, or null.\n $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : null;\n \n $applicant_info = array();\n \n // Array of applicant info fields. May set up an option in plugin so admins can modify this list.\n $applicant_fields = array(\n 'first_name',\n 'last_name',\n 'user_email',\n 'user_url',\n 'description',\n 'previous_thatcamps',\n 'user_title',\n 'user_organization',\n 'user_twitter',\n 'tshirt_size',\n 'dietary_preferences'\n );\n \n foreach ( $applicant_fields as $field) {\n $applicant_info[$field] = isset($_POST[$field]) ? $_POST[$field] : null;\n }\n \n $date = isset($_POST['date']) ? $_POST['date'] : null;\n $applicationText = isset($_POST['application_text']) ? $_POST['application_text'] : null;\n\n // Let's serialize the applicant_info before putting it in the database.\n $applicant_info = maybe_serialize($applicant_info);\n $applicant_email = isset($_POST['user_email']) ? $_POST['user_email'] : null;\n \n if ( $registration = thatcamp_registrations_get_registration_by_user_id($user_id) \n || $registration = thatcamp_registrations_get_registration_by_applicant_email($applicant_email) ) {\n return 'You have already submitted an application.';\n } else {\n $wpdb->insert(\n $table,\n array(\n 'applicant_info' => $applicant_info,\n 'applicant_email' => $applicant_email,\n 'application_text' => $applicationText,\n 'status' => $status,\n 'date' => $date,\n 'user_id' => $user_id\n )\n );\n thatcamp_registrations_send_applicant_email($applicant_email);\n }\n}\n\n/**\n * Returns registration records based on type\n * \n * @param array The parameters on which to retrieve registrations\n **/\nfunction thatcamp_registrations_get_registrations($params = array()) {\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n \n $sql = \"SELECT * FROM \" . $registrations_table;\n \n if( isset($params['id']) && $id = $params['id']) {\n $sql .= \" WHERE id=\".$params['id'];\n if( isset($params['status']) && $status = $params['status']) {\n $sql .= \" AND status = CONVERT( _utf8 '$status' USING latin1 )\";\n }\n } elseif ( isset($params['status']) && $status = $params['status']) {\n $sql .= \" WHERE status = CONVERT( _utf8 '$status' USING latin1 )\";\n }\n \n // echo $sql; exit;\n $results = $wpdb->get_results($sql, OBJECT);\n return $results;\n}\n\n/**\n * Processes an array of registrations based on ID. Used mainly in the admin.\n * \n * @param array The IDs of the registration records.\n * @param string The status for the registration records.\n **/\nfunction thatcamp_registrations_process_registrations($ids = array(), $status) {\n global $wpdb;\n $table = $wpdb->prefix . \"thatcamp_registrations\";\n \n $idArray = array();\n foreach ($ids as $id) {\n $idArray['id'] = $id;\n }\n \n if ($status && !empty($idArray)) { \n $wpdb->update(\n $table,\n array('status' => $status),\n $idArray\n );\n if ($status == 'approved' && thatcamp_registrations_create_user_accounts()) {\n foreach ($ids as $id) {\n thatcamp_registrations_process_user($id);\n }\n }\n }\n \n return;\n}\n\n/**\n * Process a single registration based on ID. Uses mainly in the admin.\n * \n * @param int The ID of the registration record.\n * @param string The status for the registration record.\n **/\nfunction thatcamp_registrations_process_registration($id, $status) {\n if (isset($id) && isset($status)) {\n thatcamp_registrations_process_registrations(array($id), $status);\n }\n return;\n}\n\n/**\n * Processes a WP user when adding/updating a registration record. Only \n * should be used if we're creating users with approved registrations.\n *\n * @param integer|null The User ID\n * @param array The array of user information.\n * @param $registrationId\n * @return integer The User ID\n **/\nfunction thatcamp_registrations_process_user($registrationId = null, $role = 'author') {\n global $wpdb;\n \n /**\n * If the Registration ID is set, it means we already have a registration \n * record! Booyah. We'll use the user_id and application_info columns from \n * that record to process the user.\n */\n \n if ($registration = thatcamp_registrations_get_registration_by_id($registrationId)) { \n \n $userInfo = maybe_unserialize($registration->applicant_info);\n $userId = $registration->user_id ? $registration->user_id : email_exists($registration->applicant_email);\n \n // If we have a valid a User ID, we're dealing with an existing user.\n if ($userId) {\n add_existing_user_to_blog(array('user_id' => $userId, 'role' => $role));\n wp_new_user_notification($userId);\n }\n // We're probably dealing with a new user. Let's create one and associate it to our blog.\n else { \n $randomPassword = wp_generate_password( 12, false );\n $userEmail = $registration->applicant_email;\n $uarray = split( '@', $userEmail );\n $userName = sanitize_user( $uarray[0] );\n $userId = wp_create_user( $userName, $randomPassword, $userEmail );\n add_user_to_blog($wpdb->blogid, $userId, $role);\n thatcamp_registrations_update_user_data($userId, $userInfo);\n wp_new_user_notification($userId, $randomPassword);\n }\n }\n \n return $userId;\n}\n\n/**\n * Updates the user data. \n * Note: this needs to be altered so that user_url goes in the wp_users table and not the wp_usermeta table. --AF Sample: wp_update_user( array ('ID' => $user_id, 'user_url' => 'http://www.site.com' ) ) ; and http://wordpress.org/support/topic/wordpress-33-update_user_meta-and-wp_userswp_usermeta-issue?replies=8 \n **/\nfunction thatcamp_registrations_update_user_data($userId, $params)\n{\n\n if ( isset( $userId ) && $userData = get_userdata($userId) ) {\n foreach ($params as $key => $value) {\n update_user_meta( $userId, $key, $value );\n }\n } \n}\n\n/**\n * Gets registration record by ID.\n *\n **/\nfunction thatcamp_registrations_get_registration_by_id($id)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE id = \" .$id;\n return $wpdb->get_row($sql, OBJECT);\n}\n\n/**\n * Gets registration record by applicant_email.\n *\n **/\nfunction thatcamp_registrations_get_registration_by_applicant_email($applicant_email)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE applicant_email = '\" .$applicant_email .\"'\";\n return $wpdb->get_row($sql, OBJECT);\n}\n\n/**\n * Gets registration record by user_id.\n *\n * @param int $user_id The User ID.\n * @return object Registration record.\n **/\nfunction thatcamp_registrations_get_registration_by_user_id($user_id)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE user_id = \" .$user_id;\n return $wpdb->get_row($sql, OBJECT);\n}\n\n/**\n * Deletes a registration record by ID.\n *\n **/\nfunction thatcamp_registrations_delete_registration($id)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n if($id) {\n $wpdb->query(\"DELETE FROM \" . $registrations_table . \" WHERE id = '\" . $id . \"'\");\n }\n}\n\n/**\n * Creates a user from a registration record.\n *\n * @param integer $registrationId \n **/\nfunction thatcamp_registrations_create_user($registrationId)\n{\n if ($applicant = thatcamp_registrations_get_registration_applicant($registrationId)) {\n \n // if ( !is_int($applicant) ) {\n return $applicant;\n // }\n }\n}\n\n/**\n * Returns the value for thatcamp_registrations_options\n *\n * @uses get_option()\n * @return array The array of options\n **/\nfunction thatcamp_registrations_options() \n{\n return get_option('thatcamp_registrations_options');\n}\n\n/**\n * Returns the value for a single THATCamp Registrations option.\n *\n * @uses thatcamp_registrations_options()\n * @param string The name of the option\n * @return string\n **/\nfunction thatcamp_registrations_option($optionName) \n{\n if (isset($optionName)) {\n $options = thatcamp_registrations_options();\n return $options[$optionName];\n }\n return false;\n}\n\nfunction thatcamp_registrations_get_applicant_info($registration) \n{\n global $wpdb;\n \n if ($registration) {\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE id = \" .$registration->id;\n $record = $wpdb->get_row($sql, OBJECT);\n if (($record->user_id == 0 || $record->user_id == null) && !empty($record->applicant_info)) {\n return (object) maybe_unserialize($record->applicant_info);\n } else {\n return get_userdata($record->user_id);\n }\n }\n}\n\n/**\n * Send a notification email to a THATCamp Registrations applicant\n *\n * @param string The applicant email address.\n * @param string The status of the application. Options are 'pending',\n * 'approved', and 'rejected. Default is pending.\n */\nfunction thatcamp_registrations_send_applicant_email($to, $status = \"pending\")\n{\n if (is_email($to)) {\n switch ($status) {\n case 'approved':\n $subject = __('Application Approved', 'thatcamp-registrations');\n $message = thatcamp_registrations_option('accepted_application_email');\n break;\n \n case 'rejected':\n $subject = __('Application Rejected', 'thatcamp-registrations');\n $message = thatcamp_registrations_option('rejected_application_email');\n break;\n case 'pending':\n default:\n $subject = __('Application Pending', 'thatcamp-registrations');\n $message = thatcamp_registrations_option('pending_application_email');\n break;\n }\n \n $subject = $subject . ': '.get_bloginfo('name');\n wp_mail($to, $subject, $message);\n \n return __('Email successfully sent!');\n }\n return false;\n}\n\n/**\n * Checks the option to create user accounts upon application approval.\n *\n * @return boolean\n **/\nfunction thatcamp_registrations_create_user_accounts() \n{\n return (bool) thatcamp_registrations_option('create_user_accounts');\n}\n\n/**\n * Checks to see if user authentication is required.\n *\n * @return boolean\n **/\nfunction thatcamp_registrations_user_required() \n{\n return (bool) thatcamp_registrations_option('require_login');\n}\n\n/**\n * Checks if registration is open.\n *\n * @return boolean\n */\nfunction thatcamp_registrations_registration_is_open()\n{\n return (bool) thatcamp_registrations_option('open_registration');\n}\n\n/**\n * Generates a random string for a token\n **/\nfunction thatcamp_registrations_generate_token()\n{\n return sha1(microtime() . mt_rand(1, 100000));\n}\n"}, "files_after": {"thatcamp-registrations-functions.php": "prefix . \"thatcamp_registrations\";\n \n $_POST = stripslashes_deep($_POST); \n \n // The user_id is set to the posted user ID, or null.\n $user_id = isset($_POST['user_id']) ? $_POST['user_id'] : null;\n \n $applicant_info = array();\n \n // Array of applicant info fields. May set up an option in plugin so admins can modify this list.\n $applicant_fields = array(\n 'first_name',\n 'last_name',\n 'user_email',\n 'user_url',\n 'description',\n 'previous_thatcamps',\n 'user_title',\n 'user_organization',\n 'user_twitter',\n 'tshirt_size',\n 'dietary_preferences'\n );\n \n foreach ( $applicant_fields as $field) {\n $applicant_info[$field] = isset($_POST[$field]) ? $_POST[$field] : null;\n }\n \n $date = isset($_POST['date']) ? $_POST['date'] : null;\n $applicationText = isset($_POST['application_text']) ? $_POST['application_text'] : null;\n\n // Let's serialize the applicant_info before putting it in the database.\n $applicant_info = maybe_serialize($applicant_info);\n $applicant_email = isset($_POST['user_email']) ? $_POST['user_email'] : null;\n \n if ( $registration = thatcamp_registrations_get_registration_by_user_id($user_id) \n || $registration = thatcamp_registrations_get_registration_by_applicant_email($applicant_email) ) {\n return 'You have already submitted an application.';\n } else {\n $wpdb->insert(\n $table,\n array(\n 'applicant_info' => $applicant_info,\n 'applicant_email' => $applicant_email,\n 'application_text' => $applicationText,\n 'status' => $status,\n 'date' => $date,\n 'user_id' => $user_id\n )\n );\n thatcamp_registrations_send_applicant_email($applicant_email);\n }\n}\n\n/**\n * Returns registration records based on type\n * \n * @param array The parameters on which to retrieve registrations\n **/\nfunction thatcamp_registrations_get_registrations($params = array()) {\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n \n $sql = \"SELECT * FROM \" . $registrations_table;\n \n if( isset($params['id']) && $id = $params['id']) {\n $sql .= \" WHERE id=\".$params['id'];\n if( isset($params['status']) && $status = $params['status']) {\n $sql .= \" AND status = CONVERT( _utf8 '$status' USING latin1 )\";\n }\n } elseif ( isset($params['status']) && $status = $params['status']) {\n $sql .= \" WHERE status = CONVERT( _utf8 '$status' USING latin1 )\";\n }\n \n // echo $sql; exit;\n $results = $wpdb->get_results($sql, OBJECT);\n return $results;\n}\n\n/**\n * Processes an array of registrations based on ID. Used mainly in the admin.\n * \n * @param array The IDs of the registration records.\n * @param string The status for the registration records.\n **/\nfunction thatcamp_registrations_process_registrations($ids = array(), $status) {\n global $wpdb;\n $table = $wpdb->prefix . \"thatcamp_registrations\";\n \n $idArray = array();\n foreach ($ids as $id) {\n $idArray['id'] = $id;\n }\n \n if ($status && !empty($idArray)) { \n $wpdb->update(\n $table,\n array('status' => $status),\n $idArray\n );\n if ($status == 'approved' && thatcamp_registrations_create_user_accounts()) {\n foreach ($ids as $id) {\n thatcamp_registrations_process_user($id);\n }\n }\n }\n \n return;\n}\n\n/**\n * Process a single registration based on ID. Uses mainly in the admin.\n * \n * @param int The ID of the registration record.\n * @param string The status for the registration record.\n **/\nfunction thatcamp_registrations_process_registration($id, $status) {\n if (isset($id) && isset($status)) {\n thatcamp_registrations_process_registrations(array($id), $status);\n }\n return;\n}\n\n/**\n * Processes a WP user when adding/updating a registration record. Only \n * should be used if we're creating users with approved registrations.\n *\n * @param integer|null The User ID\n * @param array The array of user information.\n * @param $registrationId\n * @return integer The User ID\n **/\nfunction thatcamp_registrations_process_user($registrationId = null, $role = 'author') {\n global $wpdb;\n \n /**\n * If the Registration ID is set, it means we already have a registration \n * record! Booyah. We'll use the user_id and application_info columns from \n * that record to process the user.\n */\n \n if ($registration = thatcamp_registrations_get_registration_by_id($registrationId)) { \n \n $userInfo = maybe_unserialize($registration->applicant_info);\n $userId = $registration->user_id ? $registration->user_id : email_exists($registration->applicant_email);\n \n // If we have a valid a User ID, we're dealing with an existing user.\n if ($userId) {\n add_existing_user_to_blog(array('user_id' => $userId, 'role' => $role));\n wp_new_user_notification($userId);\n }\n // We're probably dealing with a new user. Let's create one and associate it to our blog.\n else { \n $userEmail = $registration->applicant_email;\n $uarray = split( '@', $userEmail );\n $userName = sanitize_user( $uarray[0] );\n $userInfo['user_login'] = $userName;\n $userInfo['user_email'] = $userEmail;\n\n $userId = wp_insert_user( $userInfo );\n add_user_to_blog($wpdb->blogid, $userId, $role);\n wp_new_user_notification($userId);\n }\n }\n \n return $userId;\n}\n\n/**\n * Gets registration record by ID.\n *\n **/\nfunction thatcamp_registrations_get_registration_by_id($id)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE id = \" .$id;\n return $wpdb->get_row($sql, OBJECT);\n}\n\n/**\n * Gets registration record by applicant_email.\n *\n **/\nfunction thatcamp_registrations_get_registration_by_applicant_email($applicant_email)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE applicant_email = '\" .$applicant_email .\"'\";\n return $wpdb->get_row($sql, OBJECT);\n}\n\n/**\n * Gets registration record by user_id.\n *\n * @param int $user_id The User ID.\n * @return object Registration record.\n **/\nfunction thatcamp_registrations_get_registration_by_user_id($user_id)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE user_id = \" .$user_id;\n return $wpdb->get_row($sql, OBJECT);\n}\n\n/**\n * Deletes a registration record by ID.\n *\n **/\nfunction thatcamp_registrations_delete_registration($id)\n{\n global $wpdb;\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n if($id) {\n $wpdb->query(\"DELETE FROM \" . $registrations_table . \" WHERE id = '\" . $id . \"'\");\n }\n}\n\n/**\n * Creates a user from a registration record.\n *\n * @param integer $registrationId \n **/\nfunction thatcamp_registrations_create_user($registrationId)\n{\n if ($applicant = thatcamp_registrations_get_registration_applicant($registrationId)) {\n \n // if ( !is_int($applicant) ) {\n return $applicant;\n // }\n }\n}\n\n/**\n * Returns the value for thatcamp_registrations_options\n *\n * @uses get_option()\n * @return array The array of options\n **/\nfunction thatcamp_registrations_options() \n{\n return get_option('thatcamp_registrations_options');\n}\n\n/**\n * Returns the value for a single THATCamp Registrations option.\n *\n * @uses thatcamp_registrations_options()\n * @param string The name of the option\n * @return string\n **/\nfunction thatcamp_registrations_option($optionName) \n{\n if (isset($optionName)) {\n $options = thatcamp_registrations_options();\n return $options[$optionName];\n }\n return false;\n}\n\nfunction thatcamp_registrations_get_applicant_info($registration) \n{\n global $wpdb;\n \n if ($registration) {\n $registrations_table = $wpdb->prefix . \"thatcamp_registrations\";\n $sql = \"SELECT * from \" . $registrations_table . \" WHERE id = \" .$registration->id;\n $record = $wpdb->get_row($sql, OBJECT);\n if (($record->user_id == 0 || $record->user_id == null) && !empty($record->applicant_info)) {\n return (object) maybe_unserialize($record->applicant_info);\n } else {\n return get_userdata($record->user_id);\n }\n }\n}\n\n/**\n * Send a notification email to a THATCamp Registrations applicant\n *\n * @param string The applicant email address.\n * @param string The status of the application. Options are 'pending',\n * 'approved', and 'rejected. Default is pending.\n */\nfunction thatcamp_registrations_send_applicant_email($to, $status = \"pending\")\n{\n if (is_email($to)) {\n switch ($status) {\n case 'approved':\n $subject = __('Application Approved', 'thatcamp-registrations');\n $message = thatcamp_registrations_option('accepted_application_email');\n break;\n \n case 'rejected':\n $subject = __('Application Rejected', 'thatcamp-registrations');\n $message = thatcamp_registrations_option('rejected_application_email');\n break;\n case 'pending':\n default:\n $subject = __('Application Pending', 'thatcamp-registrations');\n $message = thatcamp_registrations_option('pending_application_email');\n break;\n }\n \n $subject = $subject . ': '.get_bloginfo('name');\n wp_mail($to, $subject, $message);\n \n return __('Email successfully sent!');\n }\n return false;\n}\n\n/**\n * Checks the option to create user accounts upon application approval.\n *\n * @return boolean\n **/\nfunction thatcamp_registrations_create_user_accounts() \n{\n return (bool) thatcamp_registrations_option('create_user_accounts');\n}\n\n/**\n * Checks to see if user authentication is required.\n *\n * @return boolean\n **/\nfunction thatcamp_registrations_user_required() \n{\n return (bool) thatcamp_registrations_option('require_login');\n}\n\n/**\n * Checks if registration is open.\n *\n * @return boolean\n */\nfunction thatcamp_registrations_registration_is_open()\n{\n return (bool) thatcamp_registrations_option('open_registration');\n}\n\n/**\n * Generates a random string for a token\n **/\nfunction thatcamp_registrations_generate_token()\n{\n return sha1(microtime() . mt_rand(1, 100000));\n}\n"}}
{"repo": "roman/warden_oauth", "pr_number": 4, "title": "Added a way to modify the oauth_callback url", "state": "open", "merged_at": null, "additions": 465, "deletions": 4, "files_changed": ["lib/warden_oauth.rb", "lib/warden_oauth/strategy.rb", "lib/warden_oauth2/base.rb", "lib/warden_oauth2/config.rb", "lib/warden_oauth2/config_extension.rb", "lib/warden_oauth2/errors.rb", "lib/warden_oauth2/strategy.rb", "lib/warden_oauth2/strategy_builder.rb", "lib/warden_oauth2/utils.rb"], "files_before": {"lib/warden_oauth/strategy.rb": "module Warden\n module OAuth\n\n #\n # Holds all the main logic of the OAuth authentication, all the generated\n # OAuth classes will extend from this class\n #\n class Strategy < Warden::Strategies::Base\n extend StrategyBuilder\n\n ######################\n ### Strategy Logic ###\n ######################\n\n\n def self.access_token_user_finders\n (@_user_token_finders ||= {})\n end\n\n #\n # An OAuth strategy will be valid to execute if:\n # * A 'warden_oauth_provider' parameter is given, with the name of the OAuth service\n # * A 'oauth_token' is being receive on the request (response from an OAuth provider)\n #\n def valid?\n (params.include?('warden_oauth_provider') && params['warden_oauth_provider'] == config.provider_name.to_s) ||\n params.include?('oauth_token') \n end\n\n\n #\n # Manages the OAuth authentication process, there can be 3 outcomes from this Strategy:\n # 1. The OAuth credentials are invalid and the FailureApp is called\n # 2. The OAuth credentials are valid, but there is no user associated to them. In this case\n # the FailureApp is called, but the env['warden.options'][:oauth][:access_token] will be \n # available.\n # 3. The OAuth credentials are valid, and the user is authenticated successfuly\n #\n # @note\n # If you want to signup users with the twitter credentials, you can manage the creation of a new \n # user in the FailureApp with the given access_token\n #\n def authenticate!\n if params.include?('warden_oauth_provider')\n store_request_token_on_session\n redirect!(request_token.authorize_url)\n throw(:warden)\n elsif params.include?('oauth_token')\n load_request_token_from_session\n if missing_stored_token?\n fail!(\"There is no OAuth authentication in progress\")\n elsif !stored_token_match_recieved_token?\n fail!(\"Received OAuth token didn't match stored OAuth token\")\n else\n user = find_user_by_access_token(access_token)\n if user.nil?\n fail!(\"User with access token not found\")\n throw_error_with_oauth_info\n else\n success!(user)\n end\n end\n end\n\n end\n\n def fail!(msg) #:nodoc:\n self.errors.add(service_param_name.to_sym, msg)\n super\n end\n \n ###################\n ### OAuth Logic ###\n ###################\n\n def consumer\n @consumer ||= ::OAuth::Consumer.new(config.consumer_key, config.consumer_secret, config.options)\n end\n\n def request_token\n host_with_port = Warden::OAuth::Utils.host_with_port(request)\n @request_token ||= consumer.get_request_token(:oauth_callback => host_with_port)\n end\n\n def access_token\n @access_token ||= request_token.get_access_token(:oauth_verifier => params['oauth_verifier'])\n end\n\n protected\n\n def find_user_by_access_token(access_token)\n raise RuntimeError.new(<<-ERROR_MESSAGE) unless self.respond_to?(:_find_user_by_access_token)\n \nYou need to define a finder by access_token for this strategy.\nWrite on the warden initializer the following code:\nWarden::OAuth.access_token_user_finder(:#{config.provider_name}) do |access_token|\n # Logic to get your user from an access_token\nend\n\nERROR_MESSAGE\n self._find_user_by_access_token(access_token)\n end\n\n def throw_error_with_oauth_info\n throw(:warden, :oauth => { \n self.config.provider_name => {\n :provider => config.provider_name,\n :access_token => access_token,\n :consumer_key => config.consumer_key,\n :consumer_secret => config.consumer_secret\n }\n })\n end\n\n def store_request_token_on_session\n session[:request_token] = request_token.token\n session[:request_secret] = request_token.secret\n end\n\n def load_request_token_from_session\n token = session.delete(:request_token)\n secret = session.delete(:request_secret)\n @request_token = ::OAuth::RequestToken.new(consumer, token, secret)\n end\n\n def missing_stored_token? \n !request_token\n end\n\n def stored_token_match_recieved_token?\n request_token.token == params['oauth_token']\n end\n\n def service_param_name\n '%s_oauth' % config.provider_name\n end\n\n def config\n self.class::CONFIG\n end\n\n end\n\n end\nend\n", "lib/warden_oauth.rb": "require \"rack\"\nrequire \"warden\"\nrequire \"oauth\"\n\nmodule Warden\n module OAuth\n\n base_path = File.dirname(__FILE__) + \"/warden_oauth\"\n \n require base_path + \"/base\"\n require base_path + \"/errors\"\n autoload :Utils, base_path + '/utils'\n autoload :StrategyBuilder, base_path + '/strategy_builder'\n autoload :Strategy, base_path + '/strategy'\n autoload :Config, base_path + \"/config\"\n require base_path + \"/config_extension\"\n \n\n end\nend\n"}, "files_after": {"lib/warden_oauth/strategy.rb": "module Warden\n module OAuth\n\n #\n # Holds all the main logic of the OAuth authentication, all the generated\n # OAuth classes will extend from this class\n #\n class Strategy < Warden::Strategies::Base\n extend StrategyBuilder\n\n ######################\n ### Strategy Logic ###\n ######################\n\n\n def self.access_token_user_finders\n (@_user_token_finders ||= {})\n end\n\n #\n # An OAuth strategy will be valid to execute if:\n # * A 'warden_oauth_provider' parameter is given, with the name of the OAuth service\n # * A 'oauth_token' is being receive on the request (response from an OAuth provider)\n #\n def valid?\n (params.include?('warden_oauth_provider') && params['warden_oauth_provider'] == config.provider_name.to_s) ||\n params.include?('oauth_token') \n end\n\n\n #\n # Manages the OAuth authentication process, there can be 3 outcomes from this Strategy:\n # 1. The OAuth credentials are invalid and the FailureApp is called\n # 2. The OAuth credentials are valid, but there is no user associated to them. In this case\n # the FailureApp is called, but the env['warden.options'][:oauth][:access_token] will be \n # available.\n # 3. The OAuth credentials are valid, and the user is authenticated successfuly\n #\n # @note\n # If you want to signup users with the twitter credentials, you can manage the creation of a new \n # user in the FailureApp with the given access_token\n #\n def authenticate!\n if params.include?('warden_oauth_provider')\n store_request_token_on_session\n redirect!(request_token.authorize_url(config.options))\n throw(:warden)\n elsif params.include?('oauth_token')\n load_request_token_from_session\n if missing_stored_token?\n fail!(\"There is no OAuth authentication in progress\")\n elsif !stored_token_match_recieved_token?\n fail!(\"Received OAuth token didn't match stored OAuth token\")\n else\n user = find_user_by_access_token(access_token)\n if user.nil?\n fail!(\"User with access token not found\")\n throw_error_with_oauth_info\n else\n success!(user)\n end\n end\n end\n\n end\n\n def fail!(msg) #:nodoc:\n self.errors.add(service_param_name.to_sym, msg)\n super\n end\n \n ###################\n ### OAuth Logic ###\n ###################\n\n def consumer\n @consumer ||= ::OAuth::Consumer.new(config.consumer_key, config.consumer_secret, config.options)\n end\n\n def request_token\n @request_token ||= consumer.get_request_token(:oauth_callback => config.options[:oauth_callback])\n end\n\n def access_token\n @access_token ||= request_token.get_access_token(:oauth_verifier => params['oauth_verifier'])\n end\n\n protected\n\n def find_user_by_access_token(access_token)\n raise RuntimeError.new(<<-ERROR_MESSAGE) unless self.respond_to?(:_find_user_by_access_token)\n \nYou need to define a finder by access_token for this strategy.\nWrite on the warden initializer the following code:\nWarden::OAuth.access_token_user_finder(:#{config.provider_name}) do |access_token|\n # Logic to get your user from an access_token\nend\n\nERROR_MESSAGE\n self._find_user_by_access_token(access_token)\n end\n\n def throw_error_with_oauth_info\n throw(:warden, :oauth => { \n self.config.provider_name => {\n :provider => config.provider_name,\n :access_token => access_token,\n :consumer_key => config.consumer_key,\n :consumer_secret => config.consumer_secret\n }\n })\n end\n\n def store_request_token_on_session\n session[:request_token] = request_token.token\n session[:request_secret] = request_token.secret\n end\n\n def load_request_token_from_session\n token = session.delete(:request_token)\n secret = session.delete(:request_secret)\n @request_token = ::OAuth::RequestToken.new(consumer, token, secret)\n end\n\n def missing_stored_token? \n !request_token\n end\n\n def stored_token_match_recieved_token?\n request_token.token == params['oauth_token']\n end\n\n def service_param_name\n '%s_oauth' % config.provider_name\n end\n\n def config\n self.class::CONFIG\n end\n\n end\n\n end\nend\n", "lib/warden_oauth.rb": "require \"rack\"\nrequire \"warden\"\nrequire \"oauth\"\n\nmodule Warden\n module OAuth\n\n base_path = File.dirname(__FILE__) + \"/warden_oauth\"\n \n require base_path + \"/base\"\n require base_path + \"/errors\"\n autoload :Utils, base_path + '/utils'\n autoload :StrategyBuilder, base_path + '/strategy_builder'\n autoload :Strategy, base_path + '/strategy'\n autoload :Config, base_path + \"/config\"\n require base_path + \"/config_extension\"\n \n\n end\nend\n\nrequire \"oauth2\"\n\nmodule Warden\n module OAuth2\n\n base_path = File.dirname(__FILE__) + \"/warden_oauth2\"\n \n require base_path + \"/base\"\n require base_path + \"/errors\"\n autoload :Utils, base_path + '/utils'\n autoload :StrategyBuilder, base_path + '/strategy_builder'\n autoload :Strategy, base_path + '/strategy'\n autoload :Config, base_path + \"/config\"\n require base_path + \"/config_extension\"\n \n\n end\nend\n\n"}}
{"repo": "railsfactory-shiv/rupees", "pr_number": 2, "title": "Spacing fix", "state": "closed", "merged_at": null, "additions": 43, "deletions": 38, "files_changed": ["lib/rupees.rb"], "files_before": {"lib/rupees.rb": "module NumberToRupees\n WORDS = {0=>\"zero\", 1=>\"One\", 2=>\"Two\", 3=>\"Three\", 4=>\"Four\", 5=>\"Five\", 6=>\"six\", 7=>\"seven\", 8=>\"Eight\", 9=>\"Nine\",10=>\"Ten\",11=>\"Eleven\",12=>\"Twelve\",13=>\"Thirteen\",14=>\"Fourteen\",15=>\"Fifteen\",16=>\"Sixteen\",17=>\"Seventeen\",18=>\"Eighteen\",19=>\"Nineteen\",20=>\"Twenty\",30=>\"Thirty\",40=>\"Fourty\",50=>\"Fifty\",60=>\"Sixty\",70=>\"Seventy\",80=>\"Eighty\",90=>\"Ninty\"}\n SUFIXES = {0=>\"hundred & \", 1=>\" Crore, \", 2=>\" Lakh, \", 3=>\" Thousand, \", 4=>\" Hundred, \"} # 5=>''\n module Fixnum\n def self.included(recipient)\n recipient.extend(ClassMethods)\n recipient.class_eval do\n include InstanceMethods\n end\n end\n \n module ClassMethods\n end\n \n module InstanceMethods\n def rupees\n result = self >= 0 ? \"\" : \"(-) \"\n\t num = self.abs\n \n # I would prefer One Rupee, insead of One Rupees\n return \"One Rupee.\" if num==1\n\t \n if num > 99\n num.to_s.rjust(11,'0').insert(-4,'0').scan(/../).each_with_index{|x,i| result += self.def_calc(x,i) }\n \t else\t \n result = spell_two_digits(num)\n end\n\t result.sub(/,\\s$/,'')+ \" Rupees.\"\n end\n\n protected\n def def_calc(x,i)\n str=self.proc_unit(x)\n\t return '' if str.length==0\n return \"#{str}#{SUFIXES[i]}\"\n end\n\n def proc_unit(x)\n return \"\" unless x.to_i > 0\n return spell_two_digits(x.to_i)\n end\n\t \n\t def spell_two_digits(x)\n return WORDS[x] if WORDS[x]\n r,f = x.divmod(10)\n return \"#{WORDS[r*10]}#{WORDS[f]}\"\n\t end\n end\n end \nend \nFixnum.send :include, NumberToRupees::Fixnum\n"}, "files_after": {"lib/rupees.rb": "module NumberToRupees\n WORDS = { 0 => 'zero', 1 => 'One', 2 => 'Two', 3 => 'Three', 4 => 'Four', 5 => 'Five', 6 => 'six', 7 => 'seven', 8 => 'Eight', 9 => 'Nine',\n 10 => 'Ten', 11 => 'Eleven', 12 => 'Twelve', 13 => 'Thirteen', 14 => 'Fourteen', 15 => 'Fifteen', 16 => 'Sixteen', 17 => 'Seventeen', 18 => 'Eighteen', 19 => 'Nineteen', 20 => 'Twenty', 30 => 'Thirty', 40 => 'Fourty', 50 => 'Fifty', 60 => 'Sixty', 70 => 'Seventy', 80 => 'Eighty', 90 => 'Ninty' }\n SUFIXES = { 0 => 'hundred & ', 1 => ' Crore, ', 2 => ' Lakh, ', 3 => ' Thousand, ', 4 => ' Hundred, ' } # 5=>''\n module Integer\n def self.included(recipient)\n recipient.extend(ClassMethods)\n recipient.class_eval do\n include InstanceMethods\n end\n end\n\n module ClassMethods\n end\n\n module InstanceMethods\n def rupees\n result = self >= 0 ? '' : '(-) '\n num = abs\n\n # I would prefer One Rupee, insead of One Rupees\n return 'One Rupee.' if num == 1\n\n if num > 99\n num.to_s.rjust(11, '0').insert(-4, '0').scan(/../).each_with_index { |x, i| result += def_calc(x, i) }\n else\n result = spell_two_digits(num)\n end\n result.sub(/,\\s$/, '')\n end\n\n protected\n\n def def_calc(x, i)\n str = proc_unit(x)\n return '' if str.length == 0\n\n \"#{str}#{SUFIXES[i]}\"\n end\n\n def proc_unit(x)\n return '' unless x.to_i > 0\n\n spell_two_digits(x.to_i)\n end\n\n def spell_two_digits(x)\n return WORDS[x] if WORDS[x]\n\n r, f = x.divmod(10)\n f.zero? ? \"#{WORDS[r*10]}\" : \"#{WORDS[r*10]} #{WORDS[f]}\"\n end\n end\n end\nend\nInteger.include NumberToRupees::Integer\n"}}
{"repo": "mediavrog/cfe", "pr_number": 1, "title": "update to mootools 1.3", "state": "closed", "merged_at": null, "additions": 83, "deletions": 68, "files_changed": ["cfe/addons/cfe.addon.dependencies.js", "cfe/addons/cfe.addon.toolTips.js", "cfe/base/cfe.base.js", "cfe/modules/button/cfe.module.button.js", "cfe/modules/check/cfe.module.checkbox.js", "cfe/modules/check/cfe.module.radio.js", "cfe/modules/file/cfe.module.file.js", "cfe/modules/select/cfe.module.select.js", "cfe/modules/select/cfe.module.select.multiple.js", "cfe/replace/cfe.replace.js", "demo.html"], "files_before": {"cfe/modules/file/cfe.module.file.js": "/**\n * @module File\n */\n\n/**\n * replaces file upload fields\n *\n *
is not resetted onReset
\n * \n *
Tested in:
\n *
\n *
Safari 4 - implicitly labelled triggers when deletin a file; reset doesnt trigger
\n *
Firefox 3.6.
\n *
Google Chrome 6 - implicitly labelled triggers twice, when using alias button & triggers when deletin a file.
\n *
Opera 10.62.
\n *
IE 7 - gaga.
\n *
IE 8 - implicitly labelled triggers when deletin a file.
\n *
\n *\n * @class File\n * @namespace cfe.modules\n *\n * @extends cfe.module.Button\n */\n\ncfe.module.File = new Class({\n \n Extends: cfe.module.Button,\n \n instance: 0,\n\n /**\n * CSS Selector to fetch \"original\" HTMLElements for replacement with this module\n * @property selector\n * @type string\n */\n selector: \"input[type=file]\",\n\t\n options: {\n /**\n * enables the use of fileicons through a bit of markup and css\n * @config fileIcons\n * @type boolean\n * @default true\n */\n fileIcons: true,\n /**\n * show only the filename, not the whole path\n * @config trimFilePath\n * @type boolean\n * @default true\n */\n trimFilePath: true,\n\n innerLabel: \"Choose File\"\n },\n\n hideOriginalElement: false,\n\n toElement: function()\n {\n return this.wrapa\n },\n\n /**\n * retreive the filepath\n *\n * @method getFilePath\n * @return {HTMLElement}\n */\n getFilePath: function()\n {\n return this.v;\n },\n\n afterInitialize: function()\n {\n this.a = this.button;\n \n if(this.hideOriginalElement) this.o.hideInPlace();\n\n if(this.o.id) this.wrapa.addClass(cfe.prefix+this.type+this.o.id.capitalize());\n\n // various additions\n if(!this.o.implicitLabel && !Browser.Engine.webkit) this.wrapa.addEvent(\"click\", this.clicked.bindWithEvent(this));\n\n if(this.isDisabled()) this.disable();\n\n if(!this.options.slidingDoors) this.wrapa.addClass(cfe.prefix+this.type)\n\n if(this.options.buttonStyle) this.a.addClass(cfe.prefix+\"Button\")\n\n this.a.removeClass(cfe.prefix+this.type)\n },\n\n build: function()\n {\n this.parent();\n this.innerlabel.set(\"text\", $pick(this.options.innerLabel, \"\"));\n\n // make original element follow mouse\n // setup wrapper\n this.wrapa = new Element(\"span\",{\n \"class\": cfe.prefix+this.type,\n styles:\n {\n overflow: \"hidden\",\n position: \"relative\"\n }\n }).cloneEvents(this.a)\n \n this.wrapa.inject(this.a, \"after\").adopt(this.a, this.o);\n\n // add positioning styles and events to \"hidden\" file input\n this.o.addEvents({\n \"mouseout\": this.update.bind(this),\n \"change\": this.update.bind(this),\n onDisable: this.disable.bind(this),\n onEnable: this.enable.bind(this)\n }).setStyles({\n opacity: \"0\",\n visibility: \"visible\",\n height: \"100%\",\n width: \"auto\",\n position: \"absolute\",\n top: 0,\n right: 0,\n margin: 0\n });\n\n this.wrapa.addEvent(\"mousemove\", this.follow.bindWithEvent(this));\n\n this.button = this.a;\n this.a = this.wrapa;\n \n // add filepath\n this.v = new Element(\"span\").addClass(cfe.prefix+this.type+\"Path hidden\");\n\t\t\n this.path = new Element(\"span\").addClass(\"filePath\");\n\n if(this.options.fileIcons)\n {\n this.path.addClass(\"fileIcon\");\n }\n\n this.cross = $( new cfe.module.Button({delegateClick: false}).addEvent(\"click\", this.deleteCurrentFile.bind(this)) ).addClass(\"delete\");\n\n this.v.adopt(this.path, this.cross).inject(this.wrapa, \"after\");\n\n this.update();\n },\n\n /**\n * Method to programmatically create an \"original\" HTMLElement\n *\n * @method createOriginal\n * @return {HTMLElement} an input field of type \"file\"\n */\n createOriginal: function()\n {\n return new Element(\"input\",{\n type: \"file\"\n });\n },\n\t\n follow: function(ev)\n {\n this.o.setStyle(\"left\",(ev.client.x-this.a.getLeft()-(this.o.getWidth()-30)));\n\t\t\n /* special treatment for internet explorer as the fileinput will not be cut off by overflow:hidden */\n if(Browser.Engine.trident){\n if(ev.client.x < this.a.getLeft() || ev.client.x > this.a.getLeft()+this.a.getWidth())\n this.o.setStyle(\"left\", -9999);\n }\n },\n\t\n update: function()\n {\n // only do stuff if original element is not disabled\n if( !$chk(this.o.disabled) )\n {\n if( this.o.value != \"\" )\n {\n this.o.disable().blur();\n\n this.oldValue = this.o.getProperty(\"value\");\n if(this.options.trimFilePath) this.oldValue = this.oldValue.trimFilePath();\n this.path.set(\"html\", this.oldValue);\n\n if(this.options.fileIcons)\n {\n var ind = this.oldValue.lastIndexOf(\".\");\n this.path.setProperty(\"class\",\"filePath fileIcon \" + this.oldValue.substring(++ind).toLowerCase());\n }\n this.v.removeClass(\"hidden\");\n }\n else\n {\n this.o.enable().focus();\n\n this.path.set(\"html\", \"\");\n this.v.addClass(\"hidden\");\n }\n\n this.parent();\n }\n },\n\t\n deleteCurrentFile: function()\n {\n // we dont clone the old file input here, since the attribute \"value\" would be cloned, too\n // and we cannot modify the value of an file input field without user interaction\n this.o = this.createOriginal().addClass(this.o.getProperty(\"class\")).setProperties({\n name: this.o.getProperty(\"name\"),\n id: this.o.getProperty(\"id\"),\n style: this.o.getProperty(\"style\"),\n title: this.o.getProperty(\"title\")\n }).cloneEvents(this.o).replaces(this.o);\n\t\t\n this.update();\n }\n});\n\n// add trimFilePath to Native String for convenience\nString.implement({\n trimFilePath: function()\n {\n var ind = false;\n if(!(ind = this.lastIndexOf(\"\\\\\")))\n if(!(ind = this.lastIndexOf(\"\\/\")))\n ind = 0;\n\n return this.substring(++ind);\n }\n});", "cfe/base/cfe.base.js": "/**\n * The core of custom form elements. Includes cfe.Generic and some slight addons to the native Element object. \n *\n * @module Core\n * @namespace cfe\n */\n\nvar cfe = {\n version: \"0.9.9\",\n prefix: \"cfe\",\n module: {},\n addon: {}\n};\n\n/**\n * extend Elements with some Helper functions\n * @class Helpers\n * @namespace Element\n */\nElement.Helpers = new Class({\n\n /**\n * cross-browser method for disabling the text selection by setting css attributes\n * \n * @method disableTextSelection\n */\n disableTextSelection: function(){\n if(Browser.Engine.trident || Browser.Engine.presto){\n this.setProperty(\"unselectable\",\"on\");\n }\n else if(Browser.Engine.gecko){\n this.setStyle(\"MozUserSelect\",\"none\");\n }\n else if(Browser.Engine.webkit){\n this.setStyle(\"KhtmlUserSelect\",\"none\");\n }\n\n return this;\n },\n\n /**\n * disables a HTMLElement if its a form element by setting the disabled attribute to true\n *\n * @method disable\n * @return boolean true, if element could be disabled\n */\n disable: function()\n {\n if($type(this) === \"element\" && [\"button\", \"input\", \"option\", \"optgroup\", \"select\", \"textarea\"].contains( this.get(\"tag\") ) )\n {\n this.setProperty(\"disabled\", true);\n this.fireEvent(\"onDisable\");\n }\n\n return this;\n },\n\n /**\n * enables a HTMLElement if its a form element by setting the disabled attribute to false\n *\n * @method enable\n * @return {boolean} true, if element could be enabled\n */\n enable: function()\n {\n if($type(this) === \"element\" && [\"button\", \"input\", \"option\", \"optgroup\", \"select\", \"textarea\"].contains( this.get(\"tag\") ) )\n {\n this.setProperty(\"disabled\", false);\n this.fireEvent(\"onEnable\");\n }\n\n return this;\n },\n\n /**\n * enables or disabled a HTMLElement if its a form element depending on it's current state\n *\n * @method toggleDisabled\n * @return {boolean} true, if element could be toggled\n */\n toggleDisabled: function()\n {\n if($type(this) === \"element\" && [\"button\", \"input\", \"option\", \"optgroup\", \"select\", \"textarea\"].contains( this.get(\"tag\") ) )\n {\n this.setProperty(\"disabled\", !this.getProperty(\"disabled\") );\n this.fireEvent(this.getProperty(\"disabled\")?\"onDisable\":\"onEnable\");\n }\n return this;\n },\n\n /**\n * returns the label-element which belongs to this element\n *\n * @method getLabel\n * @return HTMLElement or NULL\n */\n getLabel: function()\n {\n var label = null;\n\n // get label by id/for-combo\n if(this.id) label = $$(\"label[for=\"+this.id+\"]\")[0];\n \n // no label was found for id/for, let's see if it's implicitly labelled\n if(!label)\n {\n label = this.getParent('label');\n\n if(label) this.implicitLabel = true;\n }\n\n return label;\n },\n\n /**\n * generates the markup used by sliding doors css technique to use with this element\n *\n * @method setSlidingDoors\n *\n * @param count\n * @param type\n * @param prefix\n * \n * @return HTMLElement or NULL the wrapped HTMLElement\n */\n setSlidingDoors: function(count, type, prefix, suffixes)\n {\n var slide = null;\n var wrapped = this;\n prefix = $pick(prefix, \"sd\");\n\n suffixes = $pick(suffixes, []);\n\n for(var i = count; i > 0; --i)\n {\n wrapped.addClass( prefix+\"Slide\"+( (i == 1 && count == i) ? \"\" : (suffixes[i] || i) ));\n slide = new Element(type);\n try{\n wrapped = slide.wraps(wrapped);\n }catch(e){\n wrapped = slide.grab(wrapped);\n }\n }\n\n wrapped = null;\n\n return slide;\n },\n\n /**\n * hide an element but keep it's vertical position and leave it tab- & screenreader-able :)\n *\n * @method hideInPlace\n *\n * @return HTMLElement\n */\n hideInPlace: function()\n {\n return this.setStyles({\n position: \"absolute\",\n left: -99999,\n width: 1,\n height: 1\n });\n }\n});\n\nElement.implement(new Element.Helpers);", "cfe/modules/check/cfe.module.radio.js": "/**\n * @module Checkable\n */\n\n/**\n *
replaces radiobuttons
\n *\n *
Tested in:
\n *
\n *
Safari 4.
\n *
Firefox 3.6.
\n *
Google Chrome 6.
\n *
Opera 10.62.
\n *
IE 7.
\n *\n *
IE 8\n *
\n *
labels dont work for normal labelled elements
\n *
\n *
\n *\n *
\n *\n * @class Radiobutton\n * @namespace cfe.module\n *\n * @extends cfe.modules.Checkbox\n */\ncfe.module.Radiobutton = new Class({\n\n Extends: cfe.module.Checkbox,\n\n instance: 0,\n\n /**\n * CSS Selector to fetch \"original\" HTMLElements for replacement with this module\n * @property selector\n * @type string\n */\n selector: \"input[type=radio]\",\n\n /**\n * Method to programmatically create an \"original\" HTMLElement\n *\n * @method createOriginal\n * @return {HTMLElement} an input field of type \"radio\"\n */\n createOriginal: function()\n {\n return new Element(\"input\",{\n \"type\": \"radio\",\n \"checked\": this.options.checked\n });\n },\n\n /**\n * @method initializeAdv\n * @protected\n */\n afterInitialize: function()\n {\n this.parent();\n \n if( !(Browser.Engine.trident || Browser.Engine.gecko) ) this.o.addEvent(\"click\", this.update.bind(this));\n\n // on check, disable all other radiobuttons in this group\n this.addEvent(\"check\", function(){\n $$(\"input[name='\"+this.o.get(\"name\")+\"']\").each(function(el)\n {\n if(el != this.o && el.retrieve(\"cfe\")) el.retrieve(\"cfe\").uncheck();\n }.bind(this));\n })\n }\n});", "cfe/replace/cfe.replace.js": "/**\n * replacement class for automated replacment of scoped form elements\n *\n * @module replace\n * @namespace cfe\n *\n */\n\ncfe.Replace = new Class(\n{\n Implements: [new Options, new Events],\n\n options:{\n scope: false,\n\t\t\n onInit: $empty,\n onInitSingle: $empty,\n onBeforeInitSingle: $empty,\n onSetModuleOption: $empty,\n onRegisterModule: $empty,\n onUnregisterModule: $empty,\n onComplete: $empty\n },\n\t\t\n modules: {},\n moduleOptions: {},\n moduleOptionsAll: {},\n\t\n initialize: function()\n {\n this.registerAllModules.bind(this)();\n },\n\t\n /**\n * @method registerAllModules\n\t * registeres all loaded modules onInitialize\n\t */\n registerAllModules: function(){\n\t\t\n //console.log(\"Register all modules\");\n\t\t\n $each(cfe.module, function(modObj, modType){\n //console.log(\"Registering type \"+modType);\n if(modType != \"Generic\")\n this.registerModule(modType);\n\t\t\t\t\n }.bind(this));\n },\n\t\n /* call to register module */\n registerModule: function(mod){\n\t\t\n //console.log(\"Call to registerModule with arg:\"+mod);\n modObj = cfe.module[mod];\n\t\t\n this.fireEvent(\"onRegisterModule\", [mod,modObj]);\n this.modules[mod] = modObj;\n this.moduleOptions[mod] = {};\n\n return true;\n },\n\t\n registerModules: function(mods)\n {\n $each(mods,function(mod){\n this.registerModule(mod);\n },this);\n },\n\t\n unregisterModule: function(mod)\n {\n modObj = cfe.module[mod];\n\t\t\n this.fireEvent(\"onUnregisterModule\", [mod,modObj]);\n\n delete this.modules[mod];\n },\n\t\n unregisterModules: function(mods)\n {\n $each(mods,function(mod){\n this.unregisterModule(mod);\n },this);\n },\n /**\n\t * sets a single option for a specified module\n\t * if no module was given, it sets the options for all modules\n\t *\n * @method setModuleOption\n *\n\t * @param {String} \tmod \tName of the module\n\t * @param {String} \topt \tName of the option\n\t * @param {Mixed} \tval\t\tThe options value\n\t */\n setModuleOption: function(mod,opt,val){\n\t\t\n modObj = cfe.module[mod];\n\t\t\n this.fireEvent(\"onSetModuleOption\", [mod,modObj,opt,val]);\n\t\t\n if(!modObj){\n this.moduleOptionsAll[opt] = val;\n }\n else{\n this.moduleOptions[mod][opt] = val;\n }\n },\n\n setModuleOptions: function(mod,opt){\n\t\t\n $each(opt, function(optionValue, optionName){\n this.setModuleOption(mod,optionName,optionValue);\n }.bind(this));\n\t\t\n },\n\n engage: function(options){\n\n this.setOptions(this.options, options);\n\n if($type(this.options.scope) != \"element\"){\n this.options.scope = $(document.body);\n }\n\n this.fireEvent(\"onInit\");\n\t\t\n $each(this.modules,function(module,moduleName,i){\n\t\t\t\n var selector = module.prototype.selector;\n\t\t\t\n this.options.scope.getElements(selector).each(function(el,i){\n\n if(el.retrieve(\"cfe\") != null){\n\n var basicOptions = {\n replaces: el\n };\n\n this.fireEvent(\"onBeforeInitSingle\", [el,i,basicOptions]);\n\n var single = new module($merge(basicOptions,$merge(this.moduleOptions[moduleName],this.moduleOptionsAll)));\n\t\t\t\t\n this.fireEvent(\"onInitSingle\", single);\n }else{\n this.fireEvent(\"onSkippedInitSingle\", [el,i,basicOptions]); \n }\n\t\t\t\t\n },this);\n },this);\n\t\t\n this.fireEvent(\"onComplete\");\n }\n});", "cfe/modules/check/cfe.module.checkbox.js": "/**\n * @module Checkable\n */\n\n/**\n *
replaces checkboxes
\n * \n *
Tested in:
\n *
\n *
Safari 4.
\n *
Firefox 3.6.
\n *
Google Chrome 6.
\n *
Opera 10.62.
\n *
IE 7.
\n *
IE 8.
\n *
\n *\n * @class Checkbox\n * @namespace cfe.module\n * \n * @extends cfe.module.Button\n */\ncfe.module.Checkbox = new Class({\n \n Extends: cfe.module.Button,\n \n instance: 0,\n\n /**\n * CSS Selector to fetch \"original\" HTMLElements for replacement with this module\n * @property selector\n * @type string\n */\n selector: \"input[type=checkbox]\",\n\n options:{\n /**\n * @inherit\n */\n slidingDoors: false\n /**\n * Fired when the original element gets checked\n * @event onCheck\n */\n //onCheck: Class.empty,\n /**\n * Fired when the original element's checked state is set to false\n * @event onUnCheck\n */\n //onUncheck: Class.empty\n },\n\n afterInitialize: function()\n {\n this.parent();\n\n // important for resetting dynamically created cfe\n this.o.defaultChecked = this.o.checked;\n\n if( Browser.Engine.presto || Browser.Engine.trident )\n {\n //console.log(\"fix for element update (IE and Opera)\")\n this.o.addEvent(\"click\", this.update.bind(this) );\n }\n\n\n if(Browser.Engine.trident && this.o.implicitLabel)\n {\n //console.log(\"fix for implicit labels (IE) element[\"+this.o.id+\"]\")\n this.l.removeEvents(\"click\")\n this.a.removeEvents(\"click\").addEvent(\"click\", function(e){\n e.stop();\n this.clicked.bind(this)();\n }.bind(this))\n }\n\n this.update();\n },\n\n /**\n * Method to programmatically create an \"original\" HTMLElement\n *\n * @method createOriginal\n * @return {HTMLElement} an input field of type \"checkbox\"\n * @protected\n */\n createOriginal: function()\n {\n return new Element(\"input\",{\n type: \"checkbox\",\n checked: this.options.checked\n });\n },\n\n clicked: function(e)\n {\n if(Browser.Engine.trident && e) e.stop();\n\n this.parent()\n },\n\n /**\n * public method to check a checkbox programatically\n *\n * @method check\n * @public\n */\n check: function()\n {\n this.a.addClass(\"A\");\n this.fireEvent(\"onCheck\");\n },\n\n /**\n * public method to uncheck a checkbox programatically\n *\n * @method uncheck\n * @public\n */\n uncheck: function()\n {\n this.a.removeClass(\"A\");\n this.fireEvent(\"onUncheck\");\n },\n\n update: function()\n {\n this.o.checked ? this.check() : this.uncheck();\n this.parent();\n }\n});", "cfe/addons/cfe.addon.toolTips.js": "/**\n * @module Addon\n */\n\n/**\n * pretty simple integration of auto-generated tooltips (from title-attribute)\n * depends on mootools Tips\n *\n * @class Tips\n * @namespace cfe.addon\n *\n */\ncfe.addon.Tips = new Class({\n\t\n options: $merge(this.parent, {\n enableTips: true,\n ttStyle: \"label\",\n ttClass: cfe.prefix+\"Tip\"\n }),\n\t\n initToolTips: function(){\n\t\t\n if(!window.Tips || !this.options.enableTips){\n if(this.options.debug){\n this.throwMsg.bind(this)(\"CustomFormElements: initialization of toolTips failed.\\nReason: Mootools Plugin 'Tips' not available.\");\n }\n \n return false;\n }\n\t\n switch(this.options.ttStyle){\n default:case 'label': this.toolTipsLabel.bind(this)();break;\n }\n\n return true;\n },\n\t\n toolTipsLabel: function(){\n\t\t\n var labels = this.options.scope.getElements('label');\n \t\t\n labels.each(function(lbl,i){\n\n forEl = lbl.getProperty(\"for\");\n\t\t\t\n if(!forEl){\n var cl = lbl.getProperty(\"class\");\n\t\t\t\t\n if( $defined(cl) ){\n var forEl = cl.match(/for_[a-zA-Z0-9\\-]+/);\n\n if(forEl){\n forEl = forEl.toString();\n el = $( forEl.replace(/for_/,\"\") );\n } \n }\n\t\t\t\t\n if(!el){\n el = lbl.getElement(\"input\");\n }\n }else{\n el = $(forEl);\n }\n\n if(el){\n if($chk(qmTitle = el.getProperty(\"title\"))){\n\t\t\t\t\t\n el.setProperty(\"title\",\"\").setProperty(\"hint\", qmTitle)\n\t\t\t\t\t\n var qm = new Element(\"span\",{\n \"class\": this.options.ttClass,\n \"title\": qmTitle\n });\n \n // check if implicit label span is present\n var impLabel = lbl.getFirst(\"span[class=label]\");\n \n qm.injectInside($chk(impLabel)?impLabel:lbl);\n }\n }\n },this);\n\t\t\n new Tips($$('.'+this.options.ttClass+'[title]'));\n }\n});\n\ncfe.Replace.implement(new cfe.addon.Tips);\ncfe.Replace.prototype.addEvent(\"onComplete\", function(){\n this.initToolTips();\n});", "cfe/addons/cfe.addon.dependencies.js": "/**\n * @module Addon\n */\n\n/**\n * adds dependencies to checkboxes\n *\n * @class Dependencies\n * @namespace cfe.addon\n *\n */\ncfe.addon.Dependencies = new Class({\n\t\n /**\n\t * adds dependencies for an element \n\t * @param {Object} el\n\t * @param {Array} dep\n\t */\n addDependencies: function(el, deps){\n $each(deps,function(dep){\n this.addDependency(el,dep);\n }.bind(this));\n },\n\t\n /**\n\t * adds dependency for an element \n\t * @param {Object} el\n\t * @param {Object} dep\n\t */\n addDependency: function(el, dep){\n\t\t\n // create an array if needed\n if($type( el.retrieve('deps') ) !== \"array\"){\n el.store('deps', []);\n }\n\t\t\n // deps may be objects or strings > if a string was given, try to interpret it as id and fetch element by $()\n if($type(dep) === \"string\" || $type(dep) === \"element\"){\n el.retrieve('deps').push( $(dep) );\n return true;\n }\n\t\t\n return false;\n },\n\t\n getDependencies: function(el)\n {\n return el.retrieve('deps');\n },\n\t\n /**\n\t * this is called when a new item of a cfemodule gets initialized\n\t * it checks, whether there are dependencies for this element and adds them to its options\n\t * \n\t * @param {Object} el\n\t */\n attachDependencies: function(el,i,baseOptions)\n {\n var deps = this.getDependencies(el);\n\t\t\n if($type(deps) === \"array\"){\n baseOptions.deps = deps;\n return true;\n }\n\t\n return false;\n }\n\t\t\n});\ncfe.Replace.implement(new cfe.addon.Dependencies);\ncfe.Replace.prototype.addEvent(\"onBeforeInitSingle\", cfe.Replace.prototype.attachDependencies);\n\ncfe.addon.Dependencies.Helper = new Class({\n resolveDependencies: function()\n {\n var deps = this.o.retrieve('deps');\n\t\t\n if(deps){\n $each(deps, function(dep,i){\n dep.checked = true;\n dep.fireEvent(\"change\");\n }.bind(this));\n }\n }\n});\n\n// support for checkboxes\ncfe.module.Checkbox.implement(new cfe.addon.Dependencies.Helper);\ncfe.module.Checkbox.prototype.addEvent(\"onCheck\", function(){\n this.resolveDependencies();\n});", "cfe/modules/button/cfe.module.button.js": "/**\n * @module Button\n */\n\n/**\n * gets extended by modules to start off with standard, button-like behaviours.\n *\n * when focused and pressed, form gets submitted\n *\n * @class Button\n * @namespace cfe.module\n *\n */\ncfe.module.Button = new Class(\n{\n Implements: [new Options, new Events],\n\n selector: \"button\",\n\n instance: 0,\n\n /**\n * basic options for all cfes and always available\n * @property options\n */\n options: {\n /**\n * if > 0, it will create markup for css sliding doors tech \n * the number defines the amount of wrappers to create around this element \n * 2: standard sliding doors (x- or y-Axis) \n * 4: sliding doors in all directions (x/y-Axis)\n *\n * @config slidingDoors\n * @type int\n * @default 4\n */\n slidingDoors: 2,\n\n /**\n * if this element shall replace an existing html form element, pass it here\n * @config replaces\n * @type HTMLElement\n */\n replaces: null,\n\n /**\n * determines if a click on the decorator should be delegated to the original element\n * @config delegateClick\n * @type Boolean\n */\n delegateClick: true,\n\n /**\n * may pass any element as a label (toggling, hovering,..) for this cfe\n * @config label\n * @type HTMLElement\n */\n label: null,\n\n /**\n * if this cfe is created programatically, it's possible to set the name attribute of the generated input element\n * @config name\n * @type string\n */\n name: \"\",\n\n /**\n * setting this to true will create a disabled element\n * @config disabled\n * @type boolean\n */\n disabled: false,\n\n buttonStyle: true\n\n /**\n * Fired when the mouse is moved over the \"decorator\" element\n * @event onMouseOver\n */\n //onMouseOver: Class.empty,\n\n /**\n * Fired when the mouse is moved away from the \"decorator\" element\n * @event onMouseOut\n */\n //onMouseOut: Class.empty,\n\n /**\n * Fired when the \"original\" element gets focus (e.g. by tabbing)\n * @event onFocus\n */\n //onFocus: Class.empty,\n\n /**\n * Fired when the \"original\" element loses focus\n * @event onBlur\n */\n //onBlur: Class.empty,\n\n /**\n * Fired when \"decorator\" is clicked by mouse\n * @event onClick\n */\n //onClick: Class.empty,\n\n /**\n * Fired when pressing down with the mouse button on the \"decorator\"\n * Fired when pressing the space key while \"original\" has focus\n * @event onPress\n */\n //onPress: Class.empty,\n\n /**\n * Fired when \"decorator\" was pressed and the mouse button is released\n * Fired when \"original\" was pressed by space key and this key is released\n * @event onRelease\n */\n //onRelease: Class.empty,\n\n /**\n * Fired when \"original\"'s value changes\n * @event onUpdate\n */\n //onUpdate: Class.empty,\n\n /**\n * Fired when \"original\" gets disabled by HTMLElement.enable()\n * @event onEnable\n */\n //onEnable: Class.empty,\n\n /**\n * Fired when \"original\" gets disabled by HTMLElement.disable()\n * @event onDisable\n */\n //onDisable: Class.empty,\n\n /**\n * Fired when decorator is completely loaded and is ready to use\n * @event onLoad\n */\n //onLoad: Class.empty\n\n\n },\n\n hideOriginalElement: true,\n\n /**\n * constructor \n * building algorithm for cfe (template method) \n * \n *
setOptions: set Options
\n *
buildWrapper: setup the \"decorator\"
\n *
setupOriginal: procede the \"original\" element (add Events...)
\n *
addLabel: add and procede the label
\n *
initializeAdv: last chance for subclasses to do initialization
\n *
build: various specific dom handling and \"decorator\" building
\n *\n * @method initialize\n * @constructor\n *\n * @param {Object} options\n **/\n initialize: function(opt)\n {\n // sets instance id\n this.instance = this.constructor.prototype.instance++;\n\n this.setOptions(opt);\n\n this.type = $pick(this.options.type, $H(cfe.module).keyOf(this.constructor));\n\n this.buildWrapper();\n\n // prepares original html element for use with cfe and injects decorator into dom\n this.setupOriginal();\n\n // add a label, if present\n this.addLabel( $pick(this.o.getLabel(), this.setupLabel(this.options.label) ) );\n\n this.build();\n\n // add events to wrapping element\n this.setupWrapperEvents();\n\n // specific initialization\n this.afterInitialize();\n\n this.fireEvent(\"load\")\n },\n\n /**\n * retreive the \"decorator\"\n * mootools supports the use of $(myCfe) if toElement is defined\n *\n * @method toElement\n * @return {HTMLElement}\n */\n toElement: function()\n {\n return this.a;\n },\n\n /**\n * retreive the label\n *\n * @method getLabel\n * @return {HTMLElement}\n */\n getLabel: function()\n {\n return this.l;\n },\n\n /**\n * template method STEP 1\n */\n buildWrapper: function(){\n this.a = new Element(\"span\");\n },\n\n /**\n * handles the creation of the underlying original form element \n * stores a reference to the cfe object in the original form element\n * template method STEP 2\n *\n * @method setupOriginal\n * @protected\n */\n setupOriginal: function()\n {\n // get original element\n if( $defined(this.options.replaces) )\n {\n this.o = this.options.replaces;\n this.a.inject(this.o, 'before');\n }\n else // standalone\n {\n this.o = this.createOriginal();\n\n if(this.options.id) this.o.setProperty(\"id\", this.options.id);\n\n if(this.options.disabled) this.o.disable();\n\n if(this.options.name)\n {\n this.o.setProperty(\"name\", this.options.name);\n\n if( !$chk(this.o.id) ) this.o.setProperty(\"id\", this.options.name+this.instance);\n }\n\n if(this.options.value) this.o.setProperty(\"value\", this.options.value);\n\n this.a.adopt(this.o);\n }\n\n this.o.addEvents({\n focus: this.setFocus.bind(this),\n blur: this.removeFocus.bind(this),\n change: this.update.bind(this),\n keydown: function(e){\n if(e.key == \"space\") this.press();\n }.bind(this),\n keyup: function(e){\n if(e.key == \"space\") this.release();\n }.bind(this),\n onDisable: function(){\n this.a.fireEvent(\"disable\");\n }.bind(this),\n onEnable: function(){\n this.a.fireEvent(\"enable\");\n }.bind(this)\n });\n\n // store a reference to this cfe \"in\" the original form element\n this.o.store(\"cfe\", this);\n },\n\n /*\n * adds a label element to this cfe\n * template method STEP 3\n *\n * @method addLabel\n * @protected\n *\n * @param {HTMLElement} the label element to set as label for this cfe\n */\n addLabel: function(label)\n {\n if( !$defined(label) ) return;\n\n this.l = label;\n\n // remove for property\n if(!this.dontRemoveForFromLabel) this.l.removeProperty(\"for\");\n\n // add adequate className, add stdEvents\n this.l.addClass(cfe.prefix+this.type+\"L\");\n\n if(this.o.id || this.o.name) this.l.addClass(\"for_\"+ (this.o.id || (this.o.name+this.o.value).replace(\"]\",\"-\").replace(\"[\",\"\") ));\n\n // add stdevents\n this.l.addEvents({\n mouseover: this.hover.bind(this),\n mouseout: this.unhover.bind(this),\n mousedown: this.press.bind(this),\n mouseup: this.release.bind(this),\n click: this.clicked.bindWithEvent(this)\n });\n\n this.addEvents({\n press: function()\n {\n this.l.addClass(\"P\");\n },\n release: function()\n {\n this.l.removeClass(\"P\");\n },\n mouseOver: function()\n {\n this.l.addClass(\"H\");\n },\n mouseOut: function()\n {\n this.l.removeClass(\"H\");\n this.l.removeClass(\"P\");\n },\n focus: function()\n {\n this.l.addClass(\"F\");\n },\n blur: function()\n {\n this.l.removeClass(\"F\");\n //this.l.removeClass(\"P\");\n },\n enable: function()\n {\n this.l.removeClass(\"D\");\n },\n disable: function()\n {\n this.l.addClass(\"D\");\n }\n });\n },\n\n /**\n * part of the main template method for building the \"decorator\" \n * must be extended by subclasses\n *\n * template method STEP 4\n *\n * @method build\n * @protected\n */\n build: function(){\n\n this.innerlabel = this.setupInnerLabel();\n this.a.adopt(this.innerlabel);\n\n if( $chk(this.options.slidingDoors) )\n {\n this.a = this.a.setSlidingDoors(this.options.slidingDoors-1, \"span\", cfe.prefix).addClass(cfe.prefix+this.type);\n }\n },\n\n\n /**\n * adds events and mousepointer style to the \"decorator\"\n * usually gets called by buildWrapper\n *\n * template method STEP 5\n *\n * @method setupWrapperEvents\n * @protected\n */\n setupWrapperEvents: function()\n {\n if(!this.o.implicitLabel)\n {\n this.a.addEvents({\n mouseover: this.hover.bind(this),\n mouseout: this.unhover.bind(this),\n mousedown: this.press.bind(this),\n mouseup: this.release.bind(this)\n });\n }\n\n this.a.addEvents({\n disable: this.disable.bind(this),\n enable: this.enable.bind(this)\n })\n \n },\n\n /**\n * part of the main template method for building the \"decorator\" \n * gets called immediately before the build-method \n * may be extended by subclasses\n *\n * template method STEP 6\n *\n * @method initializeAdv\n * @protected\n */\n afterInitialize: function()\n {\n if(this.hideOriginalElement) this.o.hideInPlace();\n\n if(this.o.id) this.a.addClass(cfe.prefix+this.type+this.o.id.capitalize());\n\n // various additions\n if(!this.o.implicitLabel) this.a.addEvent(\"click\", this.clicked.bindWithEvent(this));\n\n if(this.isDisabled()) this.a.fireEvent(\"disable\");\n\n if(!this.options.slidingDoors) this.a.addClass(cfe.prefix+this.type)\n\n if(this.options.buttonStyle) this.a.addClass(cfe.prefix+\"Button\")\n },\n\n setupInnerLabel: function(){\n return new Element(\"span\").addClass(\"label\").disableTextSelection();\n },\n\n\n /**\n * getter for retrieving the disabled state of the \"original\" element\n *\n * @method isDisabled\n * @return boolean\n */\n isDisabled: function()\n {\n return this.o.getProperty(\"disabled\")\n },\n\n /**\n * programatically creates an \"original\" element \n * each subclass has to implement this\n *\n * @method createOriginal\n * @return {HTMLElement}\n */\n createOriginal: function()\n {\n return new Element(\"button\")\n },\n\n /*\n * creates a label element and fills it with the contents (may be html) given by option \"label\"\n *\n * @method setupLabel\n * @protected\n *\n * @return {HTMLElement or NULL} if option \"label\" is not set\n */\n setupLabel: function()\n {\n if( $defined(this.options.label) ) return new Element(\"label\").set(\"html\", this.options.label).setProperty(\"for\", this.o.id);\n\n return null;\n },\n\n /**\n * wrapper method for event onPress \n * may be extended by subclasses\n *\n * @method press\n * @protected\n */\n press: function()\n {\n if(this.isDisabled()) return\n\n this.a.addClass(\"P\");\n this.fireEvent(\"onPress\");\n\n //console.log(this.type + \"pressed\");\n },\n\n /**\n * wrapper method for event onRelease \n * may be extended by subclasses\n *\n * @method release\n * @protected\n */\n release: function()\n {\n if(this.isDisabled()) return\n\n this.a.removeClass(\"P\");\n this.fireEvent(\"onRelease\");\n \n //console.log(this.type + \"released\");\n\n },\n\n /**\n * wrapper method for event onMouseOver \n * may be extended by subclasses\n *\n * @method onMouseOver\n * @protected\n */\n hover: function()\n {\n if(this.isDisabled()) return\n\n this.a.addClass(\"H\");\n this.fireEvent(\"onMouseOver\");\n\n //console.log(this.type + \"hovered\");\n },\n\n /**\n * wrapper method for event onMouseOut \n * may be extended by subclasses\n *\n * @method unhover\n * @protected\n */\n unhover: function()\n {\n if(this.isDisabled()) return\n\n this.a.removeClass(\"H\");\n this.fireEvent(\"onMouseOut\");\n this.release();\n\n //console.log(this.type + \"unhovered\");\n },\n\n /**\n * wrapper method for event onFocus \n * may be extended by subclasses\n *\n * @method setFocus\n * @protected\n */\n setFocus: function()\n {\n this.a.addClass(\"F\");\n this.fireEvent(\"onFocus\");\n\n //console.log(this.type + \"focused\");\n },\n\n /**\n * wrapper method for event onBlur \n * may be extended by subclasses\n *\n * @method removeFocus\n * @protected\n */\n removeFocus: function()\n {\n //console.log(\"o blurred\");\n this.a.removeClass(\"F\");\n // if cfe gets blurred, also clear press state\n //this.a.removeClass(\"P\");\n this.fireEvent(\"onBlur\");\n\n //console.log(this.type + \"blurred\");\n\n },\n\n /**\n * wrapper method for event onClick \n * delegates the click to the \"original\" element \n * may be extended by subclasses\n *\n * @method clicked\n * @protected\n */\n clicked: function(e)\n {\n //causes problems in other browsers than ie - gonna took into this later; its the best approach to stop the event from bubbling right here though imho\n //e.stop();\n\n if(this.isDisabled()) return\n\n if( $chk(this.o.click) && $chk(this.options.delegateClick) ) this.o.click();\n this.o.focus();\n\n this.fireEvent(\"onClick\");\n\n //console.log(this.type + \" clicked\");\n },\n\n /**\n * wrapper method for event onUpdate \n * may be extended by subclasses\n *\n * @method update\n * @protected\n */\n update: function()\n {\n this.fireEvent(\"onUpdate\");\n\n //console.log(\"o was updated\");\n },\n\n /**\n * wrapper method for event onEnable \n * may be extended by subclasses\n *\n * @method enable\n * @protected\n */\n enable: function()\n {\n this.a.removeClass(\"D\");\n this.fireEvent(\"onEnable\");\n\n //console.log(this.type+\"-\"+this.instance+\" now enabled\");\n },\n\n /**\n * wrapper method for event onDisable \n * may be extended by subclasses\n *\n * @method disable\n * @protected\n */\n disable: function()\n {\n this.a.addClass(\"D\");\n this.fireEvent(\"onDisable\");\n\n //console.log(this.type+\"-\"+this.instance+\" now disabled\");\n }\n});", "cfe/modules/select/cfe.module.select.js": "/**\n * @module Scrollable\n */\n\n/**\n * SCROLLING functionality for select boxes;\n * TODO: refactor to standalone module\n * \n * creates handles and sets up a slider object\n *\n * @class Scrollable\n * @namespace cfe.helper\n *\n * \n */\ncfe.helper = cfe.helper || {}\n\ncfe.helper.Scrollable = {\n\n options: {\n size: 4,\n scrolling: true\n },\n \n setupScrolling: function()\n {\n // slider config\n this.scrollerWrapper = new Element(\"span\",{\n \"class\": cfe.prefix+\"ScrollerWrapper\",\n \"styles\":{\n height: this.container.getHeight()\n }\n }).inject(this.container, \"after\");\n\n var scrollTimer, scrollTimeout;\n var scrollStepHeight = this.allOptions[0].getHeight();\n\n function scroll(by){\n clearInterval(scrollTimer);\n clearTimeout(scrollTimeout);\n\n slider.set(slider.step+by);\n\n scrollTimeout = (function(){\n scrollTimer = (function(){\n slider.set(slider.step+by);\n }.bind(this)).periodical(50)\n }.bind(this)).delay(200)\n }\n\n function clearScroll(){\n clearInterval(scrollTimer);\n clearTimeout(scrollTimeout);\n }\n\n this.scrollerTop = $(new cfe.module.Button({\n delegateClick: false\n }).addEvent(\"release\", clearScroll).addEvent(\"press\", scroll.pass(-1))).addClass(\"scrollTop\");\n\n this.scrollerBottom = $(new cfe.module.Button({\n delegateClick: false\n }).addEvent(\"release\", clearScroll).addEvent(\"press\", scroll.pass(1))).addClass(\"scrollBottom\")\n\n this.scrollerKnob = new Element(\"span\").addClass(\"scrollKnob\");\n this.scrollerBack = new Element(\"span\").addClass(\"scrollRail\");\n\n this.scrollerBack.adopt(this.scrollerKnob);\n this.scrollerWrapper.adopt(this.scrollerBack, this.scrollerTop, this.scrollerBottom);\n\n var slider = new Slider(this.scrollerBack, this.scrollerKnob, {\n steps: this.allOptions.length-this.options.size,\n mode: \"vertical\" ,\n onChange: function(step){\n this.container.scrollTo(false,step*scrollStepHeight);\n }.bind(this)\n }).set(this.selectedIndex);\n\n this.scrollerKnob.setStyle(\"position\", \"absolute\");\n\n // scrolling\n function wheelListener(ev)\n {\n ev.stop();\n slider.set(slider.step-ev.wheel);\n }\n\n this.boundWheelListener = wheelListener.bindWithEvent(this)\n\n this.addEvent(\"containerShow\", function(){\n $(document.body).addEvent(\"mousewheel\", this.boundWheelListener)\n\n slider.set(this.o.selectedIndex);\n this.container.scrollTo(false,this.o.selectedIndex*scrollStepHeight);\n })\n\n this.addEvent(\"containerHide\", function(){\n $(document.body).removeEvent(\"mousewheel\", this.boundWheelListener);\n })\n\n this.o.addEvent(\"change\", function(){\n slider.set(this.o.selectedIndex)\n }.bind(this))\n }\n}\n\n/**\n * @module Selectable\n */\n\n/**\n * replaces select fields\n *\n *
Safari 4 - implicitly labelled triggers when deletin a file; reset doesnt trigger
\n *
Firefox 3.6.
\n *
Google Chrome 6 - implicitly labelled triggers twice, when using alias button & triggers when deletin a file.
\n *
Opera 10.62.
\n *
IE 7 - gaga.
\n *
IE 8 - implicitly labelled triggers when deletin a file.
\n *
\n *\n * @class File\n * @namespace cfe.modules\n *\n * @extends cfe.module.Button\n */\n\ncfe.module.File = new Class({\n \n Extends: cfe.module.Button,\n \n instance: 0,\n\n /**\n * CSS Selector to fetch \"original\" HTMLElements for replacement with this module\n * @property selector\n * @type string\n */\n selector: \"input[type=file]\",\n\t\n options: {\n /**\n * enables the use of fileicons through a bit of markup and css\n * @config fileIcons\n * @type boolean\n * @default true\n */\n fileIcons: true,\n /**\n * show only the filename, not the whole path\n * @config trimFilePath\n * @type boolean\n * @default true\n */\n trimFilePath: true,\n\n innerLabel: \"Choose File\"\n },\n\n hideOriginalElement: false,\n\n toElement: function()\n {\n return this.wrapa\n },\n\n /**\n * retreive the filepath\n *\n * @method getFilePath\n * @return {HTMLElement}\n */\n getFilePath: function()\n {\n return this.v;\n },\n\n afterInitialize: function()\n {\n this.a = this.button;\n \n if(this.hideOriginalElement) this.o.hideInPlace();\n\n if(this.o.id) this.wrapa.addClass(cfe.prefix+this.type+this.o.id.capitalize());\n\n // various additions\n if(!this.o.implicitLabel && !Browser.safari && !Browser.chrome) this.wrapa.addEvent(\"click\", this.clicked.pass([e],this));\n\n if(this.isDisabled()) this.disable();\n\n if(!this.options.slidingDoors) this.wrapa.addClass(cfe.prefix+this.type)\n\n if(this.options.buttonStyle) this.a.addClass(cfe.prefix+\"Button\")\n\n this.a.removeClass(cfe.prefix+this.type)\n },\n\n build: function()\n {\n this.parent();\n this.innerlabel.set(\"text\", Array.pick(this.options.innerLabel, \"\"));\n\n // make original element follow mouse\n // setup wrapper\n this.wrapa = new Element(\"span\",{\n \"class\": cfe.prefix+this.type,\n styles:\n {\n overflow: \"hidden\",\n position: \"relative\"\n }\n }).cloneEvents(this.a)\n \n this.wrapa.inject(this.a, \"after\").adopt(this.a, this.o);\n\n // add positioning styles and events to \"hidden\" file input\n this.o.addEvents({\n \"mouseout\": this.update.bind(this),\n \"change\": this.update.bind(this),\n onDisable: this.disable.bind(this),\n onEnable: this.enable.bind(this)\n }).setStyles({\n opacity: \"0\",\n visibility: \"visible\",\n height: \"100%\",\n width: \"auto\",\n position: \"absolute\",\n top: 0,\n right: 0,\n margin: 0\n });\n\n this.wrapa.addEvent(\"mousemove\", this.follow.pass([e],this));\n\n this.button = this.a;\n this.a = this.wrapa;\n \n // add filepath\n this.v = new Element(\"span\").addClass(cfe.prefix+this.type+\"Path hidden\");\n\t\t\n this.path = new Element(\"span\").addClass(\"filePath\");\n\n if(this.options.fileIcons)\n {\n this.path.addClass(\"fileIcon\");\n }\n\n this.cross = $( new cfe.module.Button({delegateClick: false}).addEvent(\"click\", this.deleteCurrentFile.bind(this)) ).addClass(\"delete\");\n\n this.v.adopt(this.path, this.cross).inject(this.wrapa, \"after\");\n\n this.update();\n },\n\n /**\n * Method to programmatically create an \"original\" HTMLElement\n *\n * @method createOriginal\n * @return {HTMLElement} an input field of type \"file\"\n */\n createOriginal: function()\n {\n return new Element(\"input\",{\n type: \"file\"\n });\n },\n\t\n follow: function(ev)\n {\n this.o.setStyle(\"left\",(ev.client.x-this.a.getLeft()-(this.o.getWidth()-30)));\n\t\t\n /* special treatment for internet explorer as the fileinput will not be cut off by overflow:hidden */\n if(Browser.ie){\n if(ev.client.x < this.a.getLeft() || ev.client.x > this.a.getLeft()+this.a.getWidth())\n this.o.setStyle(\"left\", -9999);\n }\n },\n\t\n update: function()\n {\n // only do stuff if original element is not disabled\n if( this.o.disabled == null )\n {\n if( this.o.value != \"\" )\n {\n this.o.disable().blur();\n\n this.oldValue = this.o.getProperty(\"value\");\n if(this.options.trimFilePath) this.oldValue = this.oldValue.trimFilePath();\n this.path.set(\"html\", this.oldValue);\n\n if(this.options.fileIcons)\n {\n var ind = this.oldValue.lastIndexOf(\".\");\n this.path.setProperty(\"class\",\"filePath fileIcon \" + this.oldValue.substring(++ind).toLowerCase());\n }\n this.v.removeClass(\"hidden\");\n }\n else\n {\n this.o.enable().focus();\n\n this.path.set(\"html\", \"\");\n this.v.addClass(\"hidden\");\n }\n\n this.parent();\n }\n },\n\t\n deleteCurrentFile: function()\n {\n // we dont clone the old file input here, since the attribute \"value\" would be cloned, too\n // and we cannot modify the value of an file input field without user interaction\n this.o = this.createOriginal().addClass(this.o.getProperty(\"class\")).setProperties({\n name: this.o.getProperty(\"name\"),\n id: this.o.getProperty(\"id\"),\n style: this.o.getProperty(\"style\"),\n title: this.o.getProperty(\"title\")\n }).cloneEvents(this.o).replaces(this.o);\n\t\t\n this.update();\n }\n});\n\n// add trimFilePath to Native String for convenience\nString.implement({\n trimFilePath: function()\n {\n var ind = false;\n if(!(ind = this.lastIndexOf(\"\\\\\")))\n if(!(ind = this.lastIndexOf(\"\\/\")))\n ind = 0;\n\n return this.substring(++ind);\n }\n});", "cfe/base/cfe.base.js": "/**\n * The core of custom form elements. Includes cfe.Generic and some slight addons to the native Element object. \n *\n * @module Core\n * @namespace cfe\n */\n\nvar cfe = {\n version: \"0.9.9\",\n prefix: \"cfe\",\n module: {},\n addon: {}\n};\n\n/**\n * extend Elements with some Helper functions\n * @class Helpers\n * @namespace Element\n */\nElement.Helpers = new Class({\n\n /**\n * cross-browser method for disabling the text selection by setting css attributes\n * \n * @method disableTextSelection\n */\n disableTextSelection: function(){\n if(Browser.ie || Browser.opera){\n this.setProperty(\"unselectable\",\"on\");\n }\n else if(Browser.firefox){\n this.setStyle(\"MozUserSelect\",\"none\");\n }\n else if(Browser.safari || Browser.chrome){\n this.setStyle(\"KhtmlUserSelect\",\"none\");\n }\n\n return this;\n },\n\n /**\n * disables a HTMLElement if its a form element by setting the disabled attribute to true\n *\n * @method disable\n * @return boolean true, if element could be disabled\n */\n disable: function()\n {\n if(typeOf(this) === \"element\" && [\"button\", \"input\", \"option\", \"optgroup\", \"select\", \"textarea\"].contains( this.get(\"tag\") ) )\n {\n this.setProperty(\"disabled\", true);\n this.fireEvent(\"onDisable\");\n }\n\n return this;\n },\n\n /**\n * enables a HTMLElement if its a form element by setting the disabled attribute to false\n *\n * @method enable\n * @return {boolean} true, if element could be enabled\n */\n enable: function()\n {\n if(typeOf(this) === \"element\" && [\"button\", \"input\", \"option\", \"optgroup\", \"select\", \"textarea\"].contains( this.get(\"tag\") ) )\n {\n this.setProperty(\"disabled\", false);\n this.fireEvent(\"onEnable\");\n }\n\n return this;\n },\n\n /**\n * enables or disabled a HTMLElement if its a form element depending on it's current state\n *\n * @method toggleDisabled\n * @return {boolean} true, if element could be toggled\n */\n toggleDisabled: function()\n {\n if(typeOf(this) === \"element\" && [\"button\", \"input\", \"option\", \"optgroup\", \"select\", \"textarea\"].contains( this.get(\"tag\") ) )\n {\n this.setProperty(\"disabled\", !this.getProperty(\"disabled\") );\n this.fireEvent(this.getProperty(\"disabled\")?\"onDisable\":\"onEnable\");\n }\n return this;\n },\n\n /**\n * returns the label-element which belongs to this element\n *\n * @method getLabel\n * @return HTMLElement or NULL\n */\n getLabel: function()\n {\n var label = null;\n\n // get label by id/for-combo\n if(this.id) label = $$(\"label[for=\"+this.id+\"]\")[0];\n \n // no label was found for id/for, let's see if it's implicitly labelled\n if(!label)\n {\n label = this.getParent('label');\n\n if(label) this.implicitLabel = true;\n }\n\n return label;\n },\n\n /**\n * generates the markup used by sliding doors css technique to use with this element\n *\n * @method setSlidingDoors\n *\n * @param count\n * @param type\n * @param prefix\n * \n * @return HTMLElement or NULL the wrapped HTMLElement\n */\n setSlidingDoors: function(count, type, prefix, suffixes)\n {\n var slide = null;\n var wrapped = this;\n prefix = Array.pick(prefix, \"sd\");\n\n suffixes = Array.pick(suffixes, []);\n\n for(var i = count; i > 0; --i)\n {\n wrapped.addClass( prefix+\"Slide\"+( (i == 1 && count == i) ? \"\" : (suffixes[i] || i) ));\n slide = new Element(type);\n try{\n wrapped = slide.wraps(wrapped);\n }catch(e){\n wrapped = slide.grab(wrapped);\n }\n }\n\n wrapped = null;\n\n return slide;\n },\n\n /**\n * hide an element but keep it's vertical position and leave it tab- & screenreader-able :)\n *\n * @method hideInPlace\n *\n * @return HTMLElement\n */\n hideInPlace: function()\n {\n return this.setStyles({\n position: \"absolute\",\n left: -99999,\n width: 1,\n height: 1\n });\n }\n});\n\nElement.implement(new Element.Helpers);", "cfe/modules/check/cfe.module.radio.js": "/**\n * @module Checkable\n */\n\n/**\n *
replaces radiobuttons
\n *\n *
Tested in:
\n *
\n *
Safari 4.
\n *
Firefox 3.6.
\n *
Google Chrome 6.
\n *
Opera 10.62.
\n *
IE 7.
\n *\n *
IE 8\n *
\n *
labels dont work for normal labelled elements
\n *
\n *
\n *\n *
\n *\n * @class Radiobutton\n * @namespace cfe.module\n *\n * @extends cfe.modules.Checkbox\n */\ncfe.module.Radiobutton = new Class({\n\n Extends: cfe.module.Checkbox,\n\n instance: 0,\n\n /**\n * CSS Selector to fetch \"original\" HTMLElements for replacement with this module\n * @property selector\n * @type string\n */\n selector: \"input[type=radio]\",\n\n /**\n * Method to programmatically create an \"original\" HTMLElement\n *\n * @method createOriginal\n * @return {HTMLElement} an input field of type \"radio\"\n */\n createOriginal: function()\n {\n return new Element(\"input\",{\n \"type\": \"radio\",\n \"checked\": this.options.checked\n });\n },\n\n /**\n * @method initializeAdv\n * @protected\n */\n afterInitialize: function()\n {\n this.parent();\n \n if( !(Browser.ie || Browser.firefox) ) this.o.addEvent(\"click\", this.update.bind(this));\n\n // on check, disable all other radiobuttons in this group\n this.addEvent(\"check\", function(){\n $$(\"input[name='\"+this.o.get(\"name\")+\"']\").each(function(el)\n {\n if(el != this.o && el.retrieve(\"cfe\")) el.retrieve(\"cfe\").uncheck();\n }.bind(this));\n })\n }\n});", "cfe/replace/cfe.replace.js": "/**\n * replacement class for automated replacment of scoped form elements\n *\n * @module replace\n * @namespace cfe\n *\n */\n\ncfe.Replace = new Class(\n{\n Implements: [new Options, new Events],\n\n options:{\n scope: false,\n\t\t\n onInit: function(){},\n onInitSingle: function(){},\n onBeforeInitSingle: function(){},\n onSetModuleOption: function(){},\n onRegisterModule: function(){},\n onUnregisterModule: function(){},\n onComplete: function(){}\n },\n\t\t\n modules: {},\n moduleOptions: {},\n moduleOptionsAll: {},\n\t\n initialize: function()\n {\n this.registerAllModules.bind(this)();\n },\n\t\n /**\n * @method registerAllModules\n\t * registeres all loaded modules onInitialize\n\t */\n registerAllModules: function(){\n\t\t\n //console.log(\"Register all modules\");\n\t\t\n Object.each(cfe.module, function(modObj, modType){\n //console.log(\"Registering type \"+modType);\n if(modType != \"Generic\")\n this.registerModule(modType);\n\t\t\t\t\n },this);\n },\n\t\n /* call to register module */\n registerModule: function(mod){\n\t\t\n //console.log(\"Call to registerModule with arg:\"+mod);\n modObj = cfe.module[mod];\n\t\t\n this.fireEvent(\"onRegisterModule\", [mod,modObj]);\n this.modules[mod] = modObj;\n this.moduleOptions[mod] = {};\n\n return true;\n },\n\t\n registerModules: function(mods)\n {\n Object.each(mods,function(mod){\n this.registerModule(mod);\n },this);\n },\n\t\n unregisterModule: function(mod)\n {\n modObj = cfe.module[mod];\n\t\t\n this.fireEvent(\"onUnregisterModule\", [mod,modObj]);\n\n delete this.modules[mod];\n },\n\t\n unregisterModules: function(mods)\n {\n Object.each(mods,function(mod){\n this.unregisterModule(mod);\n },this);\n },\n /**\n\t * sets a single option for a specified module\n\t * if no module was given, it sets the options for all modules\n\t *\n * @method setModuleOption\n *\n\t * @param {String} \tmod \tName of the module\n\t * @param {String} \topt \tName of the option\n\t * @param {Mixed} \tval\t\tThe options value\n\t */\n setModuleOption: function(mod,opt,val){\n\t\t\n modObj = cfe.module[mod];\n\t\t\n this.fireEvent(\"onSetModuleOption\", [mod,modObj,opt,val]);\n\t\t\n if(!modObj){\n this.moduleOptionsAll[opt] = val;\n }\n else{\n this.moduleOptions[mod][opt] = val;\n }\n },\n\n setModuleOptions: function(mod,opt){\n\t\t\n Object.each(opt, function(optionValue, optionName){\n this.setModuleOption(mod,optionName,optionValue);\n },this);\n\t\t\n },\n\n engage: function(options){\n\n this.setOptions(this.options, options);\n\n if(typeOf(this.options.scope) != \"element\"){\n this.options.scope = $(document.body);\n }\n\n this.fireEvent(\"onInit\");\n\t\t\n Object.each(this.modules,function(module,moduleName,i){\n\t\t\t\n var selector = module.prototype.selector;\n\t\t\t\n this.options.scope.getElements(selector).each(function(el,i){\n\n if(el.retrieve(\"cfe\") != null){\n\n var basicOptions = {\n replaces: el\n };\n\n this.fireEvent(\"onBeforeInitSingle\", [el,i,basicOptions]);\n\n var single = new module(Object.merge({},basicOptions,Object.merge({},this.moduleOptions[moduleName],this.moduleOptionsAll)));\n\t\t\t\t\n this.fireEvent(\"onInitSingle\", single);\n }else{\n this.fireEvent(\"onSkippedInitSingle\", [el,i,basicOptions]); \n }\n\t\t\t\t\n },this);\n },this);\n\t\t\n this.fireEvent(\"onComplete\");\n }\n});", "cfe/modules/check/cfe.module.checkbox.js": "/**\n * @module Checkable\n */\n\n/**\n *
replaces checkboxes
\n * \n *
Tested in:
\n *
\n *
Safari 4.
\n *
Firefox 3.6.
\n *
Google Chrome 6.
\n *
Opera 10.62.
\n *
IE 7.
\n *
IE 8.
\n *
\n *\n * @class Checkbox\n * @namespace cfe.module\n * \n * @extends cfe.module.Button\n */\ncfe.module.Checkbox = new Class({\n \n Extends: cfe.module.Button,\n \n instance: 0,\n\n /**\n * CSS Selector to fetch \"original\" HTMLElements for replacement with this module\n * @property selector\n * @type string\n */\n selector: \"input[type=checkbox]\",\n\n options:{\n /**\n * @inherit\n */\n slidingDoors: false\n /**\n * Fired when the original element gets checked\n * @event onCheck\n */\n //onCheck: Class.empty,\n /**\n * Fired when the original element's checked state is set to false\n * @event onUnCheck\n */\n //onUncheck: Class.empty\n },\n\n afterInitialize: function()\n {\n this.parent();\n\n // important for resetting dynamically created cfe\n this.o.defaultChecked = this.o.checked;\n\n if( Browser.ie || Browser.opera )\n {\n //console.log(\"fix for element update (IE and Opera)\")\n this.o.addEvent(\"click\", this.update.bind(this) );\n }\n\n\n if(Browser.ie && this.o.implicitLabel)\n {\n //console.log(\"fix for implicit labels (IE) element[\"+this.o.id+\"]\")\n this.l.removeEvents(\"click\")\n this.a.removeEvents(\"click\").addEvent(\"click\", function(e){\n e.stop();\n this.clicked.bind(this)();\n }.bind(this))\n }\n\n this.update();\n },\n\n /**\n * Method to programmatically create an \"original\" HTMLElement\n *\n * @method createOriginal\n * @return {HTMLElement} an input field of type \"checkbox\"\n * @protected\n */\n createOriginal: function()\n {\n return new Element(\"input\",{\n type: \"checkbox\",\n checked: this.options.checked\n });\n },\n\n clicked: function(e)\n {\n if(Browser.ie && e) e.stop();\n\n this.parent()\n },\n\n /**\n * public method to check a checkbox programatically\n *\n * @method check\n * @public\n */\n check: function()\n {\n this.a.addClass(\"A\");\n this.fireEvent(\"onCheck\");\n },\n\n /**\n * public method to uncheck a checkbox programatically\n *\n * @method uncheck\n * @public\n */\n uncheck: function()\n {\n this.a.removeClass(\"A\");\n this.fireEvent(\"onUncheck\");\n },\n\n update: function()\n {\n this.o.checked ? this.check() : this.uncheck();\n this.parent();\n }\n});", "cfe/addons/cfe.addon.toolTips.js": "/**\n * @module Addon\n */\n\n/**\n * pretty simple integration of auto-generated tooltips (from title-attribute)\n * depends on mootools Tips\n *\n * @class Tips\n * @namespace cfe.addon\n *\n */\ncfe.addon.Tips = new Class({\n\t\n options: Object.merge({},this.parent, {\n enableTips: true,\n ttStyle: \"label\",\n ttClass: cfe.prefix+\"Tip\"\n }),\n\t\n initToolTips: function(){\n\t\t\n if(!window.Tips || !this.options.enableTips){\n if(this.options.debug){\n this.throwMsg.bind(this)(\"CustomFormElements: initialization of toolTips failed.\\nReason: Mootools Plugin 'Tips' not available.\");\n }\n \n return false;\n }\n\t\n switch(this.options.ttStyle){\n default:case 'label': this.toolTipsLabel.bind(this)();break;\n }\n\n return true;\n },\n\t\n toolTipsLabel: function(){\n\t\t\n var labels = this.options.scope.getElements('label');\n \t\t\n labels.each(function(lbl,i){\n\n forEl = lbl.getProperty(\"for\");\n\t\t\t\n if(!forEl){\n var cl = lbl.getProperty(\"class\");\n\t\t\t\t\n if( cl != null ){\n var forEl = cl.match(/for_[a-zA-Z0-9\\-]+/);\n\n if(forEl){\n forEl = forEl.toString();\n el = $( forEl.replace(/for_/,\"\") );\n } \n }\n\t\t\t\t\n if(!el){\n el = lbl.getElement(\"input\");\n }\n }else{\n el = $(forEl);\n }\n\n if(el){\n if((qmTitle = el.getProperty(\"title\")) != null){\n\t\t\t\t\t\n el.setProperty(\"title\",\"\").setProperty(\"hint\", qmTitle)\n\t\t\t\t\t\n var qm = new Element(\"span\",{\n \"class\": this.options.ttClass,\n \"title\": qmTitle\n });\n \n // check if implicit label span is present\n var impLabel = lbl.getFirst(\"span[class=label]\");\n \n qm.inject((impLabel != null)?impLabel:lbl,'inside');\n }\n }\n },this);\n\t\t\n new Tips($$('.'+this.options.ttClass+'[title]'));\n }\n});\n\ncfe.Replace.implement(new cfe.addon.Tips);\ncfe.Replace.prototype.addEvent(\"onComplete\", function(){\n this.initToolTips();\n});", "cfe/addons/cfe.addon.dependencies.js": "/**\n * @module Addon\n */\n\n/**\n * adds dependencies to checkboxes\n *\n * @class Dependencies\n * @namespace cfe.addon\n *\n */\ncfe.addon.Dependencies = new Class({\n\t\n /**\n\t * adds dependencies for an element \n\t * @param {Object} el\n\t * @param {Array} dep\n\t */\n addDependencies: function(el, deps){\n Array.each(deps,function(dep){\n this.addDependency(el,dep);\n },this);\n },\n\t\n /**\n\t * adds dependency for an element \n\t * @param {Object} el\n\t * @param {Object} dep\n\t */\n addDependency: function(el, dep){\n\t\t\n // create an array if needed\n if(typeOf( el.retrieve('deps') ) !== \"array\"){\n el.store('deps', []);\n }\n\t\t\n // deps may be objects or strings > if a string was given, try to interpret it as id and fetch element by $()\n if(typeOf(dep) === \"string\" || typeOf(dep) === \"element\"){\n el.retrieve('deps').push( $(dep) );\n return true;\n }\n\t\t\n return false;\n },\n\t\n getDependencies: function(el)\n {\n return el.retrieve('deps');\n },\n\t\n /**\n\t * this is called when a new item of a cfemodule gets initialized\n\t * it checks, whether there are dependencies for this element and adds them to its options\n\t * \n\t * @param {Object} el\n\t */\n attachDependencies: function(el,i,baseOptions)\n {\n var deps = this.getDependencies(el);\n\t\t\n if(typeOf(deps) === \"array\"){\n baseOptions.deps = deps;\n return true;\n }\n\t\n return false;\n }\n\t\t\n});\ncfe.Replace.implement(new cfe.addon.Dependencies);\ncfe.Replace.prototype.addEvent(\"onBeforeInitSingle\", cfe.Replace.prototype.attachDependencies);\n\ncfe.addon.Dependencies.Helper = new Class({\n resolveDependencies: function()\n {\n var deps = this.o.retrieve('deps');\n\t\t\n if(deps){\n Array.each(deps, function(dep,i){\n dep.checked = true;\n dep.fireEvent(\"change\");\n },this);\n }\n }\n});\n\n// support for checkboxes\ncfe.module.Checkbox.implement(new cfe.addon.Dependencies.Helper);\ncfe.module.Checkbox.prototype.addEvent(\"onCheck\", function(){\n this.resolveDependencies();\n});", "cfe/modules/button/cfe.module.button.js": "/**\n * @module Button\n */\n\n/**\n * gets extended by modules to start off with standard, button-like behaviours.\n *\n * when focused and pressed, form gets submitted\n *\n * @class Button\n * @namespace cfe.module\n *\n */\ncfe.module.Button = new Class(\n{\n Implements: [new Options, new Events],\n\n selector: \"button\",\n\n instance: 0,\n\n /**\n * basic options for all cfes and always available\n * @property options\n */\n options: {\n /**\n * if > 0, it will create markup for css sliding doors tech \n * the number defines the amount of wrappers to create around this element \n * 2: standard sliding doors (x- or y-Axis) \n * 4: sliding doors in all directions (x/y-Axis)\n *\n * @config slidingDoors\n * @type int\n * @default 4\n */\n slidingDoors: 2,\n\n /**\n * if this element shall replace an existing html form element, pass it here\n * @config replaces\n * @type HTMLElement\n */\n replaces: null,\n\n /**\n * determines if a click on the decorator should be delegated to the original element\n * @config delegateClick\n * @type Boolean\n */\n delegateClick: true,\n\n /**\n * may pass any element as a label (toggling, hovering,..) for this cfe\n * @config label\n * @type HTMLElement\n */\n label: null,\n\n /**\n * if this cfe is created programatically, it's possible to set the name attribute of the generated input element\n * @config name\n * @type string\n */\n name: \"\",\n\n /**\n * setting this to true will create a disabled element\n * @config disabled\n * @type boolean\n */\n disabled: false,\n\n buttonStyle: true\n\n /**\n * Fired when the mouse is moved over the \"decorator\" element\n * @event onMouseOver\n */\n //onMouseOver: Class.empty,\n\n /**\n * Fired when the mouse is moved away from the \"decorator\" element\n * @event onMouseOut\n */\n //onMouseOut: Class.empty,\n\n /**\n * Fired when the \"original\" element gets focus (e.g. by tabbing)\n * @event onFocus\n */\n //onFocus: Class.empty,\n\n /**\n * Fired when the \"original\" element loses focus\n * @event onBlur\n */\n //onBlur: Class.empty,\n\n /**\n * Fired when \"decorator\" is clicked by mouse\n * @event onClick\n */\n //onClick: Class.empty,\n\n /**\n * Fired when pressing down with the mouse button on the \"decorator\"\n * Fired when pressing the space key while \"original\" has focus\n * @event onPress\n */\n //onPress: Class.empty,\n\n /**\n * Fired when \"decorator\" was pressed and the mouse button is released\n * Fired when \"original\" was pressed by space key and this key is released\n * @event onRelease\n */\n //onRelease: Class.empty,\n\n /**\n * Fired when \"original\"'s value changes\n * @event onUpdate\n */\n //onUpdate: Class.empty,\n\n /**\n * Fired when \"original\" gets disabled by HTMLElement.enable()\n * @event onEnable\n */\n //onEnable: Class.empty,\n\n /**\n * Fired when \"original\" gets disabled by HTMLElement.disable()\n * @event onDisable\n */\n //onDisable: Class.empty,\n\n /**\n * Fired when decorator is completely loaded and is ready to use\n * @event onLoad\n */\n //onLoad: Class.empty\n\n\n },\n\n hideOriginalElement: true,\n\n /**\n * constructor \n * building algorithm for cfe (template method) \n * \n *
setOptions: set Options
\n *
buildWrapper: setup the \"decorator\"
\n *
setupOriginal: procede the \"original\" element (add Events...)
\n *
addLabel: add and procede the label
\n *
initializeAdv: last chance for subclasses to do initialization
\n *
build: various specific dom handling and \"decorator\" building
\n *\n * @method initialize\n * @constructor\n *\n * @param {Object} options\n **/\n initialize: function(opt)\n {\n // sets instance id\n this.instance = this.constructor.prototype.instance++;\n\n this.setOptions(opt);\n\n this.type = Array.pick(this.options.type, cfe.module.keyOf(this.constructor));\n\n this.buildWrapper();\n\n // prepares original html element for use with cfe and injects decorator into dom\n this.setupOriginal();\n\n // add a label, if present\n this.addLabel( Array.pick(this.o.getLabel(), this.setupLabel(this.options.label) ) );\n\n this.build();\n\n // add events to wrapping element\n this.setupWrapperEvents();\n\n // specific initialization\n this.afterInitialize();\n\n this.fireEvent(\"load\")\n },\n\n /**\n * retreive the \"decorator\"\n * mootools supports the use of $(myCfe) if toElement is defined\n *\n * @method toElement\n * @return {HTMLElement}\n */\n toElement: function()\n {\n return this.a;\n },\n\n /**\n * retreive the label\n *\n * @method getLabel\n * @return {HTMLElement}\n */\n getLabel: function()\n {\n return this.l;\n },\n\n /**\n * template method STEP 1\n */\n buildWrapper: function(){\n this.a = new Element(\"span\");\n },\n\n /**\n * handles the creation of the underlying original form element \n * stores a reference to the cfe object in the original form element\n * template method STEP 2\n *\n * @method setupOriginal\n * @protected\n */\n setupOriginal: function()\n {\n // get original element\n if( this.options.replaces != null )\n {\n this.o = this.options.replaces;\n this.a.inject(this.o, 'before');\n }\n else // standalone\n {\n this.o = this.createOriginal();\n\n if(this.options.id) this.o.setProperty(\"id\", this.options.id);\n\n if(this.options.disabled) this.o.disable();\n\n if(this.options.name)\n {\n this.o.setProperty(\"name\", this.options.name);\n\n if( this.o.id == null ) this.o.setProperty(\"id\", this.options.name+this.instance);\n }\n\n if(this.options.value) this.o.setProperty(\"value\", this.options.value);\n\n this.a.adopt(this.o);\n }\n\n this.o.addEvents({\n focus: this.setFocus.bind(this),\n blur: this.removeFocus.bind(this),\n change: this.update.bind(this),\n keydown: function(e){\n if(e.key == \"space\") this.press();\n }.bind(this),\n keyup: function(e){\n if(e.key == \"space\") this.release();\n }.bind(this),\n onDisable: function(){\n this.a.fireEvent(\"disable\");\n }.bind(this),\n onEnable: function(){\n this.a.fireEvent(\"enable\");\n }.bind(this)\n });\n\n // store a reference to this cfe \"in\" the original form element\n this.o.store(\"cfe\", this);\n },\n\n /*\n * adds a label element to this cfe\n * template method STEP 3\n *\n * @method addLabel\n * @protected\n *\n * @param {HTMLElement} the label element to set as label for this cfe\n */\n addLabel: function(label)\n {\n if( label == null ) return;\n\n this.l = label;\n\n // remove for property\n if(!this.dontRemoveForFromLabel) this.l.removeProperty(\"for\");\n\n // add adequate className, add stdEvents\n this.l.addClass(cfe.prefix+this.type+\"L\");\n\n if(this.o.id || this.o.name) this.l.addClass(\"for_\"+ (this.o.id || (this.o.name+this.o.value).replace(\"]\",\"-\").replace(\"[\",\"\") ));\n\n // add stdevents\n this.l.addEvents({\n mouseover: this.hover.bind(this),\n mouseout: this.unhover.bind(this),\n mousedown: this.press.bind(this),\n mouseup: this.release.bind(this),\n click: this.clicked.bind(this,[e])\n });\n\n this.addEvents({\n press: function()\n {\n this.l.addClass(\"P\");\n },\n release: function()\n {\n this.l.removeClass(\"P\");\n },\n mouseOver: function()\n {\n this.l.addClass(\"H\");\n },\n mouseOut: function()\n {\n this.l.removeClass(\"H\");\n this.l.removeClass(\"P\");\n },\n focus: function()\n {\n this.l.addClass(\"F\");\n },\n blur: function()\n {\n this.l.removeClass(\"F\");\n //this.l.removeClass(\"P\");\n },\n enable: function()\n {\n this.l.removeClass(\"D\");\n },\n disable: function()\n {\n this.l.addClass(\"D\");\n }\n });\n },\n\n /**\n * part of the main template method for building the \"decorator\" \n * must be extended by subclasses\n *\n * template method STEP 4\n *\n * @method build\n * @protected\n */\n build: function(){\n\n this.innerlabel = this.setupInnerLabel();\n this.a.adopt(this.innerlabel);\n\n if( this.options.slidingDoors != null )\n {\n this.a = this.a.setSlidingDoors(this.options.slidingDoors-1, \"span\", cfe.prefix).addClass(cfe.prefix+this.type);\n }\n },\n\n\n /**\n * adds events and mousepointer style to the \"decorator\"\n * usually gets called by buildWrapper\n *\n * template method STEP 5\n *\n * @method setupWrapperEvents\n * @protected\n */\n setupWrapperEvents: function()\n {\n if(!this.o.implicitLabel)\n {\n this.a.addEvents({\n mouseover: this.hover.bind(this),\n mouseout: this.unhover.bind(this),\n mousedown: this.press.bind(this),\n mouseup: this.release.bind(this)\n });\n }\n\n this.a.addEvents({\n disable: this.disable.bind(this),\n enable: this.enable.bind(this)\n })\n \n },\n\n /**\n * part of the main template method for building the \"decorator\" \n * gets called immediately before the build-method \n * may be extended by subclasses\n *\n * template method STEP 6\n *\n * @method initializeAdv\n * @protected\n */\n afterInitialize: function()\n {\n if(this.hideOriginalElement) this.o.hideInPlace();\n\n if(this.o.id) this.a.addClass(cfe.prefix+this.type+this.o.id.capitalize());\n\n // various additions\n if(!this.o.implicitLabel) this.a.addEvent(\"click\", this.clicked.pass([e],this));\n\n if(this.isDisabled()) this.a.fireEvent(\"disable\");\n\n if(!this.options.slidingDoors) this.a.addClass(cfe.prefix+this.type)\n\n if(this.options.buttonStyle) this.a.addClass(cfe.prefix+\"Button\")\n },\n\n setupInnerLabel: function(){\n return new Element(\"span\").addClass(\"label\").disableTextSelection();\n },\n\n\n /**\n * getter for retrieving the disabled state of the \"original\" element\n *\n * @method isDisabled\n * @return boolean\n */\n isDisabled: function()\n {\n return this.o.getProperty(\"disabled\")\n },\n\n /**\n * programatically creates an \"original\" element \n * each subclass has to implement this\n *\n * @method createOriginal\n * @return {HTMLElement}\n */\n createOriginal: function()\n {\n return new Element(\"button\")\n },\n\n /*\n * creates a label element and fills it with the contents (may be html) given by option \"label\"\n *\n * @method setupLabel\n * @protected\n *\n * @return {HTMLElement or NULL} if option \"label\" is not set\n */\n setupLabel: function()\n {\n if( this.options.label != null ) return new Element(\"label\").set(\"html\", this.options.label).setProperty(\"for\", this.o.id);\n\n return null;\n },\n\n /**\n * wrapper method for event onPress \n * may be extended by subclasses\n *\n * @method press\n * @protected\n */\n press: function()\n {\n if(this.isDisabled()) return\n\n this.a.addClass(\"P\");\n this.fireEvent(\"onPress\");\n\n //console.log(this.type + \"pressed\");\n },\n\n /**\n * wrapper method for event onRelease \n * may be extended by subclasses\n *\n * @method release\n * @protected\n */\n release: function()\n {\n if(this.isDisabled()) return\n\n this.a.removeClass(\"P\");\n this.fireEvent(\"onRelease\");\n \n //console.log(this.type + \"released\");\n\n },\n\n /**\n * wrapper method for event onMouseOver \n * may be extended by subclasses\n *\n * @method onMouseOver\n * @protected\n */\n hover: function()\n {\n if(this.isDisabled()) return\n\n this.a.addClass(\"H\");\n this.fireEvent(\"onMouseOver\");\n\n //console.log(this.type + \"hovered\");\n },\n\n /**\n * wrapper method for event onMouseOut \n * may be extended by subclasses\n *\n * @method unhover\n * @protected\n */\n unhover: function()\n {\n if(this.isDisabled()) return\n\n this.a.removeClass(\"H\");\n this.fireEvent(\"onMouseOut\");\n this.release();\n\n //console.log(this.type + \"unhovered\");\n },\n\n /**\n * wrapper method for event onFocus \n * may be extended by subclasses\n *\n * @method setFocus\n * @protected\n */\n setFocus: function()\n {\n this.a.addClass(\"F\");\n this.fireEvent(\"onFocus\");\n\n //console.log(this.type + \"focused\");\n },\n\n /**\n * wrapper method for event onBlur \n * may be extended by subclasses\n *\n * @method removeFocus\n * @protected\n */\n removeFocus: function()\n {\n //console.log(\"o blurred\");\n this.a.removeClass(\"F\");\n // if cfe gets blurred, also clear press state\n //this.a.removeClass(\"P\");\n this.fireEvent(\"onBlur\");\n\n //console.log(this.type + \"blurred\");\n\n },\n\n /**\n * wrapper method for event onClick \n * delegates the click to the \"original\" element \n * may be extended by subclasses\n *\n * @method clicked\n * @protected\n */\n clicked: function(e)\n {\n //causes problems in other browsers than ie - gonna took into this later; its the best approach to stop the event from bubbling right here though imho\n //e.stop();\n\n if(this.isDisabled()) return\n\n if( $chk(this.o.click) && this.options.delegateClick != null ) this.o.click();\n this.o.focus();\n\n this.fireEvent(\"onClick\");\n\n //console.log(this.type + \" clicked\");\n },\n\n /**\n * wrapper method for event onUpdate \n * may be extended by subclasses\n *\n * @method update\n * @protected\n */\n update: function()\n {\n this.fireEvent(\"onUpdate\");\n\n //console.log(\"o was updated\");\n },\n\n /**\n * wrapper method for event onEnable \n * may be extended by subclasses\n *\n * @method enable\n * @protected\n */\n enable: function()\n {\n this.a.removeClass(\"D\");\n this.fireEvent(\"onEnable\");\n\n //console.log(this.type+\"-\"+this.instance+\" now enabled\");\n },\n\n /**\n * wrapper method for event onDisable \n * may be extended by subclasses\n *\n * @method disable\n * @protected\n */\n disable: function()\n {\n this.a.addClass(\"D\");\n this.fireEvent(\"onDisable\");\n\n //console.log(this.type+\"-\"+this.instance+\" now disabled\");\n }\n});", "cfe/modules/select/cfe.module.select.js": "/**\n * @module Scrollable\n */\n\n/**\n * SCROLLING functionality for select boxes;\n * TODO: refactor to standalone module\n * \n * creates handles and sets up a slider object\n *\n * @class Scrollable\n * @namespace cfe.helper\n *\n * \n */\ncfe.helper = cfe.helper || {}\n\ncfe.helper.Scrollable = {\n\n options: {\n size: 4,\n scrolling: true\n },\n \n setupScrolling: function()\n {\n // slider config\n this.scrollerWrapper = new Element(\"span\",{\n \"class\": cfe.prefix+\"ScrollerWrapper\",\n \"styles\":{\n height: this.container.getHeight()\n }\n }).inject(this.container, \"after\");\n\n var scrollTimer, scrollTimeout;\n var scrollStepHeight = this.allOptions[0].getHeight();\n\n function scroll(by){\n clearInterval(scrollTimer);\n clearTimeout(scrollTimeout);\n\n slider.set(slider.step+by);\n\n scrollTimeout = (function(){\n scrollTimer = (function(){\n slider.set(slider.step+by);\n }.bind(this)).periodical(50)\n }.bind(this)).delay(200)\n }\n\n function clearScroll(){\n clearInterval(scrollTimer);\n clearTimeout(scrollTimeout);\n }\n\n this.scrollerTop = $(new cfe.module.Button({\n delegateClick: false\n }).addEvent(\"release\", clearScroll).addEvent(\"press\", scroll.pass(-1))).addClass(\"scrollTop\");\n\n this.scrollerBottom = $(new cfe.module.Button({\n delegateClick: false\n }).addEvent(\"release\", clearScroll).addEvent(\"press\", scroll.pass(1))).addClass(\"scrollBottom\")\n\n this.scrollerKnob = new Element(\"span\").addClass(\"scrollKnob\");\n this.scrollerBack = new Element(\"span\").addClass(\"scrollRail\");\n\n this.scrollerBack.adopt(this.scrollerKnob);\n this.scrollerWrapper.adopt(this.scrollerBack, this.scrollerTop, this.scrollerBottom);\n\n var slider = new Slider(this.scrollerBack, this.scrollerKnob, {\n steps: this.allOptions.length-this.options.size,\n mode: \"vertical\" ,\n onChange: function(step){\n this.container.scrollTo(false,step*scrollStepHeight);\n }.bind(this)\n }).set(this.selectedIndex);\n\n this.scrollerKnob.setStyle(\"position\", \"absolute\");\n\n // scrolling\n function wheelListener(ev)\n {\n ev.stop();\n slider.set(slider.step-ev.wheel);\n }\n\n this.boundWheelListener = wheelListener.pass([e],this)\n\n this.addEvent(\"containerShow\", function(){\n $(document.body).addEvent(\"mousewheel\", this.boundWheelListener)\n\n slider.set(this.o.selectedIndex);\n this.container.scrollTo(false,this.o.selectedIndex*scrollStepHeight);\n })\n\n this.addEvent(\"containerHide\", function(){\n $(document.body).removeEvent(\"mousewheel\", this.boundWheelListener);\n })\n\n this.o.addEvent(\"change\", function(){\n slider.set(this.o.selectedIndex)\n }.bind(this))\n }\n}\n\n/**\n * @module Selectable\n */\n\n/**\n * replaces select fields\n *\n *
This is a really great book. I think it will be very helpful to many people. I\u2019m definitely going to recommend it to beginners.
\n