public function get_display_path($catID = false, $s = array()) { if ($catID === false) { $Cat = $this; } else { $Categories = new PerchCategories_Categories(); $Cat = $Categories->find($catID); } if (is_object($Cat)) { $s[] = $Cat->catTitle(); } if (!is_object($Cat) || $Cat->catParentID() === '0') { $s = array_reverse($s); return implode(' › ', $s); } return $this->get_display_path($Cat->catParentID(), $s); }
<?php if (!$CurrentUser->has_priv('categories.delete')) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } $Categories = new PerchCategories_Categories(); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $catID = (int) $_GET['id']; $Category = $Categories->find($catID); } if (!$Category || !is_object($Category)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } /* --------- Delete Form ----------- */ $Form = new PerchForm('delete'); if ($Form->posted() && $Form->validate()) { $Category->delete(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/apps/categories/sets/?id=' . $Category->setID(); exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/sets/?id=' . $Category->setID()); } }
public function get_categories() { $cats = $this->get_field('categories', false); if (PerchUtil::count($cats)) { $Categories = new PerchCategories_Categories(); $out = array(); foreach ($cats as $catID) { $out[] = $Categories->find((int) $catID); } return $out; } return false; }
public function update_category_counts() { $sql = 'SELECT COUNT(*) AS qty, c.catID FROM ' . PERCH_DB_PREFIX . $this->index_table . ' i, ' . PERCH_DB_PREFIX . 'categories c, ' . $this->table . ' p WHERE i.indexValue=c.catPath AND i.indexKey=\'_category\' AND i.itemKey=\'postID\' AND i.itemID=p.postID AND p.postStatus=\'Published\' AND p.postDateTime<=' . $this->db->pdb(date('Y-m-d H:i:00')) . ' GROUP BY i.indexValue '; $rows = $this->db->get_rows($sql); $sql = 'DELETE FROM ' . PERCH_DB_PREFIX . 'category_counts WHERE countType=' . $this->db->pdb('blog.post'); $this->db->execute($sql); if (PerchUtil::count($rows)) { $Categories = new PerchCategories_Categories(); foreach ($rows as $row) { $Category = $Categories->find((int) $row['catID']); if ($Category) { $Category->update_count('blog.post', $row['qty']); } } } }
public function get_index($raw = false) { if ($raw === false) { $raw = $this->get_raw(); } $id = $this->Tag->id(); $out = array(); if (is_array($raw)) { $Categories = new PerchCategories_Categories(); foreach ($raw as $key => $val) { if (!is_array($val)) { $Cat = $Categories->find((int) $val); if (is_object($Cat)) { $out[] = array('key' => '_category', 'value' => $Cat->catPath()); } } } } return $out; }
*/ $catID = false; $Category = false; $Set = false; $ParentCat = false; // Success or failure message $message = false; $details = array(); /* Figure out what mode we're in by testing what's on the query string. Load up instances of the Category and Set where appropriate. */ if (PerchUtil::get('id')) { // Edit mode $catID = (int) PerchUtil::get('id'); $Category = $Categories->find($catID); $Set = $Sets->find($Category->setID()); $details = $Category->to_array(); } else { // New category mode if (PerchUtil::get('sid')) { // New in set $Set = $Sets->find((int) PerchUtil::get('sid')); } if (PerchUtil::get('pid')) { // New based on parent category $ParentCat = $Categories->find((int) PerchUtil::get('pid')); $Set = $Sets->find($ParentCat->setID()); } } /*