public function content() { load('extend'); $id = $_GET['detail']; //获取完整导航数据 $menu = new Menu(); $nav = $menu->getMenu(); $this->assign('menu', $nav); $navInfo = $menu->getNavInfo($id); //获取热门文章与最新文章 $nhArticle = new Article(); $hotArticle = $nhArticle->getHotArticle(); $newlyArticle = $nhArticle->getNewlyArticle(); $dailyData = $nhArticle->getDailyArticle(); //获取当前一级列表数据 $name = $menu->getLoneMenuName($id); $this->assign('Lone', $name); //获取二级列表数据 $list = $menu->getList($id); $this->assign('subList', $list); //获取内容 $content = new Content($id); $tid = $content->getId(); $this->assign('currentId', $tid); //获取点击导航后的路径数组 $navarr = $content->getNavPath(); $this->assign('navarr', $navarr); //dump($navarr); $tpl = $content->getTpl(); $cont = $content->getDeContent(); if ($tpl == 'Content:index') { $this->assign('list', $cont['list']); $this->assign('hot', $hotArticle); //全局热点资讯 $this->assign('page', $cont['pager']); //翻页 $this->assign('week', $cont['weeklyHot']); //本类别下一周热点 $this->assign('newly', $newlyArticle); //全局最新资讯 $this->assign('count', $cont['count']); //当前分类下资讯总数 $this->assign('weekCount', $cont['weekNewCount']); //当前分类下周新增资讯总数 $this->assign('navInfo', $navInfo); //当前分类详细信息 $this->assign('dailyCount', $dailyData['count']); $this->assign('dailyArticle', $dailyData['data']); //dump($cont['hot']); //dump($cont['count']); //exit; } else { $this->assign('content', $cont['artdetail']); //dump($cont['artdetail']); //exit; $this->assign('hot', $cont['hot']); } $this->display($tpl); }
public function delete(Content $image) { $filename = self::PHOTOS_DIRECTORY . $image->getFilename(); if (file_exists($filename)) { unlink($filename); //delete the file } $query = "DELETE FROM images WHERE id={$image->getId()} LIMIT 1"; self::$mysqli->query($query); }
/** Get the clickthrough-logged equivalent of a sincle URL (http, https or ftp) */ private static function getClickThroughLink($hyperlink, Content &$content, $node, $user) { $node ? $node_id = urlencode($node->getId()) : ($node_id = null); $user ? $user_id = urlencode($user->getId()) : ($user_id = null); return htmlspecialchars(BASE_URL_PATH . "clickthrough.php?destination_url=" . urlencode($hyperlink) . "&content_id=" . urlencode($content->getId()) . "&node_id={$node_id}&user_id={$user_id}"); }
/** * Returns the previous published content in order if sorted by publication date. * Only returns contents that are published and whose publication date does not lie in the future. * The order used is the same as in findPublished(). * * @param Content $currentContent The current content * @param \DateTime $currentDate The date used to determine if a publication date lies in the future. If null or omitted, today is used. * @return null|Content The previous content before $currentContent, or null if $currentContent is the first one. */ public function findPreviousInDateOrder(Content $currentContent, \DateTime $currentDate = null) { if (null === $currentDate) { $currentDate = new \DateTime(); } // Find contents with same date $query = $this->createQueryBuilder('n'); $query->andWhere('n.public = true'); $query->andWhere('n.publicationDate <= :currentDate'); $query->andWhere('n.publicationDate = :contentDate'); $query->andWhere('n.publishedUntil >= :currentDate'); $query->orWhere('n.publishedUntil IS NULL'); $query->setParameter('currentDate', $currentDate); $query->setParameter('contentDate', $currentContent->getPublicationDate()); $contentsSameDate = $query->getQuery()->getResult(); if (!empty($contentsSameDate) && !($contentsSameDate[count($contentsSameDate) - 1]->getId() == $currentContent->getId())) { // Return next in list for ($i = 0; $i < count($contentsSameDate); $i++) { if ($contentsSameDate[$i]->getId() == $currentContent->getId()) { return $contentsSameDate[$i + 1]; } } } // No next one at current date, search for newer ones $query = $this->createQueryBuilder('n'); $query->andWhere('n.public = true'); $query->andWhere('n.publicationDate <= :currentDate'); $query->andWhere('n.publicationDate < :contentDate'); $query->andWhere('n.publishedUntil >= :currentDate'); $query->orWhere('n.publishedUntil IS NULL'); $query->setParameter('currentDate', $currentDate); $query->setParameter('contentDate', $currentContent->getPublicationDate()); $query->addOrderBy('n.publicationDate', 'desc'); $query->addOrderBy('n.id', 'asc'); $query->setMaxResults(1); $nextContent = $query->getQuery()->getResult(); if (empty($nextContent)) { // No older contents return null; } else { return $nextContent[0]; } }
/** Remove content from this node */ public function removeContent(Content $content) { $db = AbstractDb::getObject(); $content_id = $db->escapeString($content->getId()); $sql = "DELETE FROM user_has_content WHERE user_id='{$this->id}' AND content_id='{$content_id}'"; $db->execSqlUpdate($sql, false); return true; }
public function delete(Content $content) { $query = "DELETE FROM albums WHERE id={$content->getId()} LIMIT 1"; self::$mysqli->query($query); }
public function content() { load('extend'); //$id=$_GET['detail']; $id = 1; //获取完整导航数据 $menu = new Menu(); $nav = $menu->getMenu(); $this->assign('menu', $nav); //获取当前一级列表数据 $name = $menu->getLoneMenuName($id); $this->assign('Lone', $name); //获取二级列表数据 $list = $menu->getList($id); $this->assign('subList', $list); //获取内容 $content = new Content($id); $tid = $content->getId(); $this->assign('currentId', $tid); //获取点击导航后的路径数组 $navarr = $content->getNavPath(); $this->assign('navarr', $navarr); $tpl = $content->getTpl(); $cont = $content->getDeContent(); if ($tpl == 'Content:index') { $this->assign('list', $cont['list']); $this->assign('hotNews', $cont['hot']); $this->assign('page', $cont['pager']); } else { $this->assign('content', $cont['artdetail']); $this->assign('hot', $cont['hot']); } dump($tpl); //exit; $this->display($tpl); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Content $value A Content object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Content $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Declares an association between this object and a Content object. * * @param Content $v * @return Cmspage The current object (for fluent API support) * @throws PropelException */ public function setContent(Content $v = null) { if ($v === null) { $this->setContentId(NULL); } else { $this->setContentId($v->getId()); } $this->aContent = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Content object, it will not be re-added. if ($v !== null) { $v->addCmspage($this); } return $this; }
public function delete(Content $object) { $query = "DELETE FROM newsevents WHERE id={$object->getId()} LIMIT 1"; self::$mysqli->query($query); }