function getPageImages() { $sql = "\nSELECT\n\turl,\n\tdescription,\n\tir.id AS image_reference_id,\n\tim.id\nFROM\n\tgrlx_image_reference ir,\n\tgrlx_image_match im\nWHERE\n\tim.rel_id = ?\n\tAND im.rel_type = 'page'\n\tAND im.image_reference_id = ir.id\nORDER BY\n\tim.sort_order\n"; $info = $this->db->rawQuery($sql, array($this->pageID)); $info = rekey_array($info, 'id'); $this->imageList = $info; }
function getLastPage() { $this->db->where('book_id', $this->bookID); $this->db->orderBy('sort_order', 'DESC'); $result = $this->db->get('book_page', null, 'id,title,sort_order'); $result = rekey_array($result, 'sort_order'); $this->lastPage = reset($result); }
/** * Get list of all static pages */ public function getPageList() { $cols = array('sp.id', 'sp.title', 'sp.description', 'sp.tone_id', 'sp.options', 'p.edit_path'); $result = $this->db->join('path p', 'sp.id = p.rel_id', 'INNER')->where('rel_type', 'static')->orderBy('p.title', 'ASC')->get('static_page sp', null, $cols); $result = rekey_array($result, 'id'); $this->pageList = $result; return $this->pageList; }
function getMarkerTypeList() { $this->db->where('id', $this->markerTypeID); $this->db->orderBy('rank', 'ASC'); $result = $this->db->get('marker_type', null, 'id,title,rank'); $result = rekey_array($result, 'id'); if ($result) { foreach ($result as $key => $val) { $this->db->where('marker_type_id', $val['id']); $tally = $this->db->getOne('marker', 'COUNT(id) AS tally'); $result[$key]['tally'] = $tally['tally']; } } return $result; }
function get_menu_items() { global $_db; $cols = array('id,url,title,rel_type,rel_id,in_menu,sort_order'); $result = $_db->get('path', null, $cols); if ($result) { $list = rekey_array($result, 'id'); // Build paths for archive items foreach ($list as $key => $val) { if ($val['rel_type'] == 'archive') { $comic_url = $list[$val['rel_id']]['url']; $list[$key]['url'] = $comic_url . $val['url']; } } $list = rekey_array($list, 'url'); } return $list; }
function gather_ad_data($service = 'Project Wonderful', $db) { $sql = "\nSELECT\n\tlabel,\n\tvalue,\n\tsm.id\nFROM\n\tmilieu sm,\n\tmilieu_group smg\nWHERE\n\tsmg.title = ?\n\tAND sm.group_id = smg.id"; $list = $db->rawQuery($sql, array($service)); $list = rekey_array($list, 'label'); return $list; }
} if ($total_pages <= 100) { $pages_per_view = 10; } elseif ($total_pages <= 200) { $pages_per_view = 20; } elseif ($total_pages <= 500) { $pages_per_view = 50; } else { $pages_per_view = 70; } if ($start_sort_order > $total_pages) { $start_sort_order = $total_pages - $pages_per_view; } // For reference later $marker_type_list = $db->get('marker_type', null, 'id,title'); $marker_type_list = rekey_array($marker_type_list, 'id'); ///// Alerts and warnings if (!$book->info) { $alert_output .= $message->alert_dialog('This book ID ' . $book_id . ' doesn’t seem to exist.'); } if (!is_dir('../' . DIR_COMICS_IMG)) { @mkdir('../' . DIR_COMICS_IMG); $alert_output .= $message->info_dialog('The ' . DIR_COMICS_IMG . ' folder was missing, so I created it. Just sayin’.'); } elseif (!is_writable('../' . DIR_COMICS_IMG)) { $alert_output .= $message->alert_dialog('I can’t work with the ' . DIR_COMICS_IMG . ' folder. Looks like a permissions problem you need to fix via FTP.'); } /* $link-> title = 'Add a marker'; $link-> url = 'marker.create.php'; $link-> tap = 'Do something about that';
function check_comic_seo($db) { $errors = false; // Be optimistic $link = new GrlxLink(); $total_comic_pages = $db->get('book_page', null, 'COUNT(id) AS total'); $total_comic_pages = $total_comic_pages[0]; $db->orderBy('title', 'ASC'); $page_list = $db->get('book_page', null, 'id,title,sort_order'); $page_list = rekey_array($page_list, 'id'); if ($page_list) { foreach ($page_list as $key => $val) { if (trim($val['title']) == '') { $untitled_list[$key] = $val; $errors = true; } else { $title_count[$val['title']]++; } if ($val['title'] && strlen($val['title']) < 8) { $short_name_list[$key] = $val; $errors = true; } if ($val['title'] && strlen($val['title']) > 60) { $long_name_list[$key] = $val; $errors = true; } } } if ($title_count) { $duplicate_title_error = false; foreach ($title_count as $key => $val) { if ($val > 1) { $duplicate_title_error = true; } } } if ($short_name_list) { $output .= '<p>' . count($short_name_list) . ' comic pages have short titles.</p><ul>' . "\n"; $link->rel = null; foreach ($short_name_list as $key => $val) { $link->tap = $val['title']; $link->url = 'book.page-edit.php?page_id=' . $val['id']; $output .= '<li>' . $link->paint() . '</li>' . "\n"; } $output .= '</ul>' . "\n"; } else { // $output .= '<p>Good news: Every page has a title.</p>'."\n"; } if ($long_name_list) { $link->rel = null; $output .= '<p>' . count($long_name_list) . ' comic pages have overlong titles. ' . $link->paint() . ' titles no longer than about 60 characters.</p><ul>' . "\n"; foreach ($long_name_list as $key => $val) { $link->tap = $val['title']; $link->url = 'book.chapter-edit.php?chapter_id=' . $val['chapter_id']; $output .= '<li>' . $link->paint() . '</li>' . "\n"; } $output .= '</ul>' . "\n"; } if ($untitled_list) { $link->rel = null; $output .= '<p>' . count($untitled_list) . ' comic pages have no titles.</p><ul>' . "\n"; foreach ($untitled_list as $key => $val) { $link->tap = 'Untitled (ID ' . $key . ')'; $link->url = 'book.chapter-edit.php?chapter_id=' . $val['chapter_id']; $output .= '<li>' . $link->paint() . '</li>' . "\n"; } $output .= '</ul>' . "\n"; } else { $output .= '<p>Good news: Every page has a unique title.</p>' . "\n"; } if ($duplicate_title_error === true) { $output .= '<p>These titles are used more than once:</p><ul>' . "\n"; foreach ($title_count as $key => $val) { if ($val > 1) { $output .= '<li>“' . $key . '”</li>' . "\n"; } } $output .= '</ul>'; } return array($errors, $output); }
/** * Format menu items, ignore those not in menu * * @return string $menu - html for menu as list items */ protected function formatSiteMenu() { $this->menu = rekey_array($this->menu, 'sort_order'); ksort($this->menu); foreach ($this->menu as $key => $val) { if ($val['in_menu'] == 1) { if ($val['url'] == $this->request) { $li_class = ' class="active"'; } elseif ($val['url'] == '/' && $this->request == '/index.php') { $li_class = ' class="active"'; } else { $li_class = null; } $menu .= '<li' . $li_class . '><a href="' . $this->milieu['directory'] . $val['url'] . '">' . $val['title'] . '</a></li>'; } } return $menu; }
/***** * Display logic */ if ($slot_id) { // Get basic information about this slot. $slot_info = get_slot_info($slot_id, $db); // What ads are in this slot? $match_list = get_ad_slot_matches($slot_id, null, $db); } // What ads might fit into this slot? if ($slot_info) { // $possible_ad_list = $db->where('large_width', $slot_info['max_width'],'<=') // ->where('large_height', $slot_info['max_height'],'<=') $possible_ad_list = $db->get('ad_reference', null, 'id,title,source_id,source_rel_id,large_width,large_height,large_image_url,code'); if ($possible_ad_list) { $possible_ad_list = rekey_array($possible_ad_list, 'id'); } } if ($possible_ad_list) { $image = new GrlxImage(); $image->style = 'max-height:100px;max-width:468px'; foreach ($possible_ad_list as $key => $val) { if ($match_list[$key]) { $action = '<input type="checkbox" id="change_to[' . $key . ']" name="change_to[' . $key . ']" checked="checked" value="on"/> <label for="change_to[' . $key . ']">on</label>' . "\n"; $action .= '<input type="hidden" name="change_from[' . $key . ']" value="on"/>' . "\n"; } else { $action = '<input type="checkbox" id="change_to[' . $key . ']" name="change_to[' . $key . ']" value="on"/> <label for="change_to[' . $key . ']">off</label>' . "\n"; $action .= '<input type="hidden" name="change_from[' . $key . ']" value="off"/>' . "\n"; } $title = $val['title']; $title ? $title : ($title = 'Untitled');
$current_alert_output = $message->alert_dialog('Edits were not saved.'); } } } /***** * Display logic */ // Fetch site navigation $cols = array('id', 'title', 'url', 'rel_id', 'rel_type', 'in_menu'); $result = $db->orderBy('sort_order', 'ASC')->get('path', NULL, $cols); if ($result) { $nav_item = rekey_array($result, 'id'); } // Fetch site static pages $result = $db->get('static_page', null, 'id,title'); $static_list = rekey_array($result, 'id'); // Replace static pages’ labels with the pages’ actual meta titles. if ($static_list && $nav_item) { foreach ($nav_item as $key => $val) { if ($val['rel_type'] == 'static') { $rel_id = $val['rel_id']; $nav_item[$key]['title'] = $static_list[$rel_id]['title']; } } } if ($nav_item) { foreach ($nav_item as $key => $item) { // Construct archive paths if ($item['rel_type'] == 'archive') { $nav_item[$key]['url'] = $nav_item[$item['rel_id']]['url'] . $item['url']; }
function getPageIDs() { if (!$this->startPage || !$this->endPage) { $this->getPageRange(); } if ($this->startPage && $this->endPage) { $this->db->where('book_id', $this->markerInfo['book_id']); $this->db->where("sort_order >= {$this->startPage}"); $this->db->where("sort_order <= {$this->endPage}"); $this->db->orderBy('sort_order', 'ASC'); $page_list = $this->db->get('book_page', null, 'id,book_id,title,tone_id,date_publish,sort_order'); $page_list = rekey_array($page_list, 'id'); $this->pageList = $page_list; } }