当前位置: 首页>>代码示例>>PHP>>正文


PHP School::findOneBySlug方法代码示例

本文整理汇总了PHP中School::findOneBySlug方法的典型用法代码示例。如果您正苦于以下问题:PHP School::findOneBySlug方法的具体用法?PHP School::findOneBySlug怎么用?PHP School::findOneBySlug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在School的用法示例。


在下文中一共展示了School::findOneBySlug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 function render()
 {
     global $gbCache, $siteName, $keywords;
     $args = func_get_args();
     if (count($args) > 0) {
         $school = $args[0];
     } else {
         $school = null;
     }
     if ($school) {
         $school = School::findOneBySlug($school);
         if (!$school) {
             header("Location: " . BASE_URL);
             exit;
         }
     }
     if (!($schoolJson = $gbCache['schooljson'])) {
         $schoolJson = file_get_contents(BASE_DIR . '/config/schools.json');
         $gbCache['schooljson'] = $schoolJson;
     }
     $this->setTitle('Textbooks made easy.');
     $this->addMetaTag('keywords', (!$school ? '' : $school->getShortName() . ", " . $school->getName() . ",") . "{$siteName}, {$keywords}, college textbooks, lowest " . "textbook prices, affordable textbooks, cheap textbooks, " . "inexpensive textbooks, discount textbooks, textbook price" . " comparison, textbook price-comparison, textbook syllabus" . " information, rent textbooks, college textbooks, search by" . " course, student textbook discounts, better college bookstore," . " alternative college bookstore, cheap text books, compare" . " textbooks prices");
     $this->addMetaTag('description', ($school ? $school->getShortName() . ' ' : '') . "GetchaBooks is a free, " . "student-run service that finds " . ($school ? "textbooks for students of " . $school->getName() : "college students' textbooks") . " at the lowest prices.");
     $this->inlineJS[] = "var Index = {};";
     $this->inlineJS[] = "Index.IS_SCHOOL = " . ($school ? "true" : "false") . ";";
     $this->inlineJS[] = "Index.SCHOOL_SLUG = " . ($school ? "'" . $school->getSlug() . "'" : "false") . ";";
     $this->inlineJS[] = "Index.BASE_URL = '" . BASE_URL . "';";
     $this->inlineJS[] = "Index.ISBN_URL = '" . BASE_URL . "selection/';";
     $this->inlineJS[] = "Index.SCHOOL_NOT_FOUND_MESSAGE = \"<li class='error' data-url='\" + Index.ISBN_URL + \"'><a href='\" + Index.ISBN_URL + \"'><p class='title'>It looks like we don't know your school's courses right now.</p><p>Don't worry, we can still help. If you tell us what books you're looking for, we'll find the best prices for them.</p><p class='link'>Find my books.</p></a></li>\"";
     $this->inlineJS[] = "Index.LIST_OF_ALL_SCHOOLS = " . ($schoolJson ? $schoolJson : "[]") . ";";
     // When we have zero data but still want to look presentable.
     if (defined('ISBN')) {
         $this->renderPage('isbn_index', array());
     } else {
         $this->renderPage('index', array('school' => $school, 'schoolJson' => $schoolJson));
     }
 }
开发者ID:therealchiko,项目名称:getchabooks,代码行数:37,代码来源:IndexController.php

示例2: render

 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} &#8250; {$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' => ''));
 }
开发者ID:therealchiko,项目名称:getchabooks,代码行数:91,代码来源:ResultsController.php

示例3: render

 function render()
 {
     global $app;
     $args = func_get_args();
     if (count($args) > 0) {
         $school = $args[0];
     } else {
         $school = null;
     }
     if ($school) {
         if (defined('EMERGENCY')) {
             $this->redirect_to_index();
         }
         $school = School::findOneBySlug($school);
         if (!$school) {
             $this->redirect_to_index();
         }
         // if the school is unspidered, spider it down to departments.
         // if it fails, continue onwards as long as there is old data,
         // otherwise rethrow, which will cause the error page to be
         // displayed
         try {
             $school->spider(2);
         } catch (BookstoreError $e) {
             $app->getLog()->warn($e->getMessage());
             if ($school->getNbCampuses() == 0) {
                 throw $e;
             }
         }
         $multiCampus = $school->getNbCampuses() > 1;
         $bardHACK = $school->getSlug() == "bard";
         if ($multiCampus) {
             $campusId = null;
             $campusSlug = null;
         } else {
             $campus = CampusQuery::create()->filterBySchool($school)->findOne();
             $campusSlug = $campus->getSlug();
             $campusId = $campus->getId();
         }
         $schoolSlug = $school->getSlug();
         $isbnMode = false;
         $itemName = "course";
     } else {
         $school = null;
         $schoolSlug = null;
         $campusSlug = null;
         $multiCampus = false;
         $isbnMode = true;
         $itemName = "book";
         $campusId = null;
         $bardHACK = false;
     }
     $this->inlineJS[] = "var Selection = {};";
     $this->inlineJS[] = "Globals.SECTION_DELIMITER = '" . SECTION_DELIMITER . "';";
     $this->inlineJS[] = "Globals.MULTICAMPUS = " . ($multiCampus ? "true" : "false") . ";";
     $this->inlineJS[] = "Globals.SCHOOL_SLUG = " . ($school ? "'" . addslashes($school->getSlug()) . "'" : "false") . ";";
     $this->inlineJS[] = "Globals.SCHOOL_NAME = " . ($school ? "'" . addslashes($school->getShortName()) . "'" : "false") . ";";
     $this->inlineJS[] = "Globals.campusId = " . ($campusId ? "'{$campusId}'" : 'null') . ";";
     $this->inlineJS[] = "Globals.CAMPUS_SLUG = " . ($campusSlug ? "'{$campusSlug}'" : 'null') . ";";
     $this->inlineJS[] = "Globals.termId = null;";
     $this->inlineJS[] = "Globals.TYPE = '" . ($isbnMode ? "ISBN" : "course") . "';";
     $this->inlineJS[] = "Globals.ITEM_NAME = '" . $itemName . "';";
     $this->overrideAnalyticsPageUrl("selection/" . ($isbnMode ? "isbn" : "course"));
     $this->setTitle($school ? 'Select Courses' : 'Enter Books');
     if ($school) {
         $description = "Just tell us your " . $school->getShortName() . " courses, " . "and we'll look up your books and find the cheapest prices.";
     } else {
         $description = "Input your books by ISBN and we'll do " . "the comparison shopping for you.";
     }
     $this->addMetaTag('description', "Textbooks made easy. {$description}");
     $this->renderPage('selection', array('breadcrumbFormat' => 'selection', 'schoolSlug' => $schoolSlug, 'isbnMode' => $isbnMode, 'multiCampus' => $multiCampus, 'bardHACK' => $bardHACK, 'school' => $school, 'campusWrapperDisplay' => $multiCampus ? 'inline' : 'none', 'topWrapperDisplay' => $multiCampus ? 'none' : 'inline'));
 }
开发者ID:therealchiko,项目名称:getchabooks,代码行数:72,代码来源:SelectionController.php


注:本文中的School::findOneBySlug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。