public function departments($term) { $term = TermQuery::create()->findPk($term); if ($term) { $term->spider(0); echo json_encode($term->getDeptSelect()); } else { throw new AjaxError("Expected item doesn't exist."); } }
public function getTermSelect() { /** * There seems to be a consistency issue wherein an object maintains a * cache of its related objects, and if items didn't exist before * and are added by spidering, the cache will not be updated. This * fixes that. */ $this->ensureConsistency(); $terms = TermQuery::create()->filterByCampus($this)->find(); $r = array(); foreach ($terms as $t) { $r[] = array('name' => $t->getName(), 'id' => (string) $t->getId(), 'slug' => $t->getSlug(), 'selected' => $t->getStatus() === 0, 'hasCourseData' => $t->getHasCourseInfo()); } return $r; }
/** * Get the associated Term object * * @param PropelPDO Optional Connection object. * @return Term The associated Term object. * @throws PropelException */ public function getTerm(PropelPDO $con = null) { if ($this->aTerm === null && $this->term_id !== null) { $this->aTerm = TermQuery::create()->findPk($this->term_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aTerm->addDepts($this); */ } return $this->aTerm; }
/** * Returns a new TermQuery object. * * @param string $modelAlias The alias of a model in the query * @param Criteria $criteria Optional Criteria to build the query from * * @return TermQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof TermQuery) { return $criteria; } $query = new TermQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(TermPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = TermQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
function render() { global $vendors; $args = func_get_args(); if (count($args) == 1) { $school = $campus = $term = null; $ids = $args[0]; } else { if (count($args) == 4) { $school = $args[0]; $campus = $args[1]; $term = $args[2]; $ids = isset($args[3]) ? $args[3] : null; } else { $school = $args[0]; $campus = null; $term = $args[1]; $ids = isset($args[2]) ? $args[2] : null; } } if (defined('EMERGENCY') && $school) { $this->redirect_to_index(); } if (!$school) { $isbnMode = true; unset($vendors[array_search('Bookstore', $vendors)]); $schoolSlug = $campusSlug = $termSlug = false; } else { $isbnMode = false; $school = School::findOneBySlug($school); if (!$school) { $this->redirect_to_index(); } $vendors[array_search('Bookstore', $vendors)] = $school->getBookstoreType(); $schoolSlug = $school->getSlug(); if ($campus) { $campus = CampusQuery::create()->filterBySchool($school)->filterBySlug($campus)->findOne(); if (!$campus) { $this->redirect_to_index(); } $campusSlug = $campus->getSlug(); } else { $campusSlug = false; } $q = TermQuery::create(); if ($campus) { $q->filterByCampus($campus); } else { $q->useCampusQuery()->filterBySchool($school)->endUse(); } $term = $q->filterBySlug($term)->findOne(); if (!$term) { $this->redirect_to_index(); } $termSlug = $term->getSlug(); $termName = $term->getName(); } $this->setTitle('Your Books'); $this->inlineJS[] = "Globals.SECTION_DELIMITER = '" . SECTION_DELIMITER . "';"; $this->inlineJS[] = "Globals.SCHOOL_SLUG = " . ($schoolSlug ? "'{$schoolSlug}'" : "false") . ";"; $this->inlineJS[] = "Globals.CAMPUS_SLUG = " . ($campusSlug ? "'{$campusSlug}'" : "false") . ";"; $this->inlineJS[] = "Globals.TERM_SLUG = " . ($termSlug ? "'{$termSlug}'" : "false") . ";"; $this->inlineJS[] = "Globals.IDS = '{$ids}';"; $this->inlineJS[] = "Globals.THIS_PAGE_URL = '" . CURRENT_URL . "';"; $this->overrideAnalyticsPageUrl("results"); // If only one section, use its title as a FB Open Graph title (for share functionality) if ($school) { $sections = SectionQuery::create()->filterBySlug($ids)->filterBySchoolSlug($schoolSlug)->filterByTermSlug($termSlug); if ($campusSlug) { $sections->filterByCampusSlug($campusSlug); } $sections = $sections->find(); if ($sections->count() == 1) { $courseName = $sections[0]->getName(); $shortName = $school->getShortName(); $term = $term->getName(); global $siteName; $this->misc[] = "<meta property='og:title' content='{$courseName} › {$shortName} {$siteName} ({$termName})' />"; } } if ($isbnMode) { $hashPrefix = ""; } else { if ($campusSlug) { $hashPrefix = "{$campusSlug}/{$termSlug}/"; } else { $hashPrefix = "{$termSlug}/"; } } $this->renderPage('results', array('isbnMode' => $isbnMode, 'breadcrumbFormat' => 'results', 'schoolSlug' => $schoolSlug, 'ids' => $ids, 'hashPrefix' => $hashPrefix, 'tableClass' => 'vendor' . count($vendors), 'resultsURL' => '')); }
/** * Returns the number of related Term objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Term objects. * @throws PropelException */ public function countTerms(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if (null === $this->collTerms || null !== $criteria) { if ($this->isNew() && null === $this->collTerms) { return 0; } else { $query = TermQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByCampus($this)->count($con); } } else { return count($this->collTerms); } }