diff --git a/fixtures/content.sql b/fixtures/content.sql new file mode 100644 index 000000000..03185e622 --- /dev/null +++ b/fixtures/content.sql @@ -0,0 +1,66 @@ +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET character_set_client = utf8 */; + +CREATE TABLE `content` ( + `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Class` enum('Emergence\\CMS\\Page','Emergence\\CMS\\BlogPost') NOT NULL, + `Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CreatorID` int(11) DEFAULT NULL, + `Modified` timestamp NULL DEFAULT NULL, + `ModifierID` int(10) unsigned DEFAULT NULL, + `ContextClass` varchar(255) DEFAULT NULL, + `ContextID` int(10) unsigned DEFAULT NULL, + `Title` varchar(255) NOT NULL, + `Handle` varchar(255) NOT NULL, + `AuthorID` int(10) unsigned NOT NULL, + `Status` enum('Draft','Published','Hidden','Deleted') NOT NULL DEFAULT 'Published', + `Published` timestamp NULL DEFAULT NULL, + `Visibility` enum('Public','Private') NOT NULL DEFAULT 'Public', + `Summary` text, + `LayoutClass` enum('OneColumn') DEFAULT 'OneColumn', + `LayoutConfig` json DEFAULT NULL, + PRIMARY KEY (`ID`), + UNIQUE KEY `Handle` (`Handle`), + KEY `Published` (`Published`), + KEY `CONTEXT` (`ContextClass`,`ContextID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `content` VALUES (1,'Emergence\\CMS\\BlogPost','2021-12-26 02:44:15',3,'2021-12-26 02:44:39',3,'Slate\\Courses\\Section',2,'1st post from teacher','st_post_from_teacher',3,'Published','2021-12-26 02:44:00','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (2,'Emergence\\CMS\\BlogPost','2021-12-26 02:46:48',4,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student','post_from_student',4,'Published','2021-12-26 02:46:48','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (3,'Emergence\\CMS\\BlogPost','2021-12-26 02:47:16',4,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student','post_from_student-2',4,'Published','2021-12-26 02:47:17','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (4,'Emergence\\CMS\\BlogPost','2021-12-26 02:51:07',6,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student2','post_from_student2',6,'Published','2021-12-26 02:51:08','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (5,'Emergence\\CMS\\BlogPost','2021-12-26 02:51:52',6,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student2','post_from_student2-2',6,'Published','2021-12-26 02:51:52','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (6,'Emergence\\CMS\\BlogPost','2021-12-26 02:52:13',6,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student2','post_from_student2-3',6,'Published','2021-12-26 02:52:13','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (7,'Emergence\\CMS\\BlogPost','2021-12-26 02:53:36',4,'2021-12-26 02:53:45',4,'Slate\\Courses\\Section',2,'Post from student','post_from_student-3',4,'Published','2021-12-26 02:53:00','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (8,'Emergence\\CMS\\BlogPost','2021-12-26 02:54:13',4,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student','post_from_student-4',4,'Published','2021-12-26 02:54:13','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (9,'Emergence\\CMS\\BlogPost','2021-12-26 02:54:33',4,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student','post_from_student-5',4,'Published','2021-12-26 02:54:33','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (10,'Emergence\\CMS\\BlogPost','2021-12-26 02:55:49',3,'2021-12-26 02:56:51',3,'Slate\\Courses\\Section',2,'This is the 2nd post from teacher','this_is_the_2nd_post_from_teacher',3,'Published','2021-12-26 02:55:00','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (11,'Emergence\\CMS\\BlogPost','2021-12-26 02:56:24',3,'2021-12-26 02:57:01',3,'Slate\\Courses\\Section',2,'This is the 3rd post from teacher','this_is_the_3rd_post_from_teacher',3,'Published','2021-12-26 02:56:00','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (12,'Emergence\\CMS\\BlogPost','2021-12-26 02:57:56',6,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student2','post_from_student2-4',6,'Published','2021-12-26 02:57:57','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (13,'Emergence\\CMS\\BlogPost','2021-12-26 02:58:20',6,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student2','post_from_student2-5',6,'Published','2021-12-26 02:58:20','Public',NULL,'OneColumn',NULL); +INSERT INTO `content` VALUES (14,'Emergence\\CMS\\BlogPost','2021-12-26 02:58:47',6,NULL,NULL,'Slate\\Courses\\Section',2,'Post from student2','post_from_student2-6',6,'Published','2021-12-26 02:58:48','Public',NULL,'OneColumn',NULL); + +CREATE TABLE `history_content` ( + `RevisionID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `ID` int(10) unsigned NOT NULL, + `Class` enum('Emergence\\CMS\\Page','Emergence\\CMS\\BlogPost') NOT NULL, + `Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CreatorID` int(11) DEFAULT NULL, + `Modified` timestamp NULL DEFAULT NULL, + `ModifierID` int(10) unsigned DEFAULT NULL, + `ContextClass` varchar(255) DEFAULT NULL, + `ContextID` int(10) unsigned DEFAULT NULL, + `Title` varchar(255) NOT NULL, + `Handle` varchar(255) NOT NULL, + `AuthorID` int(10) unsigned NOT NULL, + `Status` enum('Draft','Published','Hidden','Deleted') NOT NULL DEFAULT 'Published', + `Published` timestamp NULL DEFAULT NULL, + `Visibility` enum('Public','Private') NOT NULL DEFAULT 'Public', + `Summary` text, + `LayoutClass` enum('OneColumn') DEFAULT 'OneColumn', + `LayoutConfig` json DEFAULT NULL, + PRIMARY KEY (`RevisionID`), + KEY `ID` (`ID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `history_content` SELECT NULL AS RevisionID, `content`.* FROM `content`; \ No newline at end of file diff --git a/fixtures/content_items.sql b/fixtures/content_items.sql new file mode 100644 index 000000000..3a1052d69 --- /dev/null +++ b/fixtures/content_items.sql @@ -0,0 +1,55 @@ +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET character_set_client = utf8 */; + +CREATE TABLE `content_items` ( + `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Class` enum('Emergence\\CMS\\Item\\Album','Emergence\\CMS\\Item\\Embed','Emergence\\CMS\\Item\\Media','Emergence\\CMS\\Item\\RichText','Emergence\\CMS\\Item\\Text','Emergence\\CMS\\Item\\Markdown') NOT NULL, + `Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CreatorID` int(11) DEFAULT NULL, + `Modified` timestamp NULL DEFAULT NULL, + `ModifierID` int(10) unsigned DEFAULT NULL, + `Title` varchar(255) DEFAULT NULL, + `ContentID` int(10) unsigned NOT NULL, + `AuthorID` int(10) unsigned NOT NULL, + `Status` enum('Draft','Published','Hidden','Deleted') NOT NULL DEFAULT 'Published', + `Order` int(10) unsigned DEFAULT NULL, + `Data` json NOT NULL, + PRIMARY KEY (`ID`), + KEY `ContentID` (`ContentID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `content_items` VALUES (1,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:44:15',3,'2021-12-26 02:44:39',3,NULL,1,3,'Deleted',1,'\"Here is some information about the course\\n - Lorem ipsum dolor sit amet\\n - consectetur adipiscing elit\"'); +INSERT INTO `content_items` VALUES (2,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:44:39',3,NULL,NULL,NULL,1,3,'Published',1,'\"Here is some information about the course\\n - Lorem ipsum dolor sit amet\\n - consectetur adipiscing elit\"'); +INSERT INTO `content_items` VALUES (3,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:46:48',4,NULL,NULL,NULL,2,4,'Published',1,'\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \"'); +INSERT INTO `content_items` VALUES (4,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:47:16',4,NULL,NULL,NULL,3,4,'Published',1,'\"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"'); +INSERT INTO `content_items` VALUES (5,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:51:07',6,NULL,NULL,NULL,4,6,'Published',1,'\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \"'); +INSERT INTO `content_items` VALUES (6,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:51:52',6,NULL,NULL,NULL,5,6,'Published',1,'\"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\"'); +INSERT INTO `content_items` VALUES (7,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:52:13',6,NULL,NULL,NULL,6,6,'Published',1,'\"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"'); +INSERT INTO `content_items` VALUES (8,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:53:36',4,NULL,NULL,NULL,7,4,'Published',1,'\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\"'); +INSERT INTO `content_items` VALUES (9,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:54:13',4,NULL,NULL,NULL,8,4,'Published',1,'\"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\"'); +INSERT INTO `content_items` VALUES (10,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:54:33',4,NULL,NULL,NULL,9,4,'Published',1,'\"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"'); +INSERT INTO `content_items` VALUES (11,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:55:49',3,NULL,NULL,NULL,10,3,'Published',1,'\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \"'); +INSERT INTO `content_items` VALUES (12,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:56:24',3,NULL,NULL,NULL,11,3,'Published',1,'\"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"'); +INSERT INTO `content_items` VALUES (13,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:57:56',6,NULL,NULL,NULL,12,6,'Published',1,'\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \"'); +INSERT INTO `content_items` VALUES (14,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:58:20',6,NULL,NULL,NULL,13,6,'Published',1,'\"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\"'); +INSERT INTO `content_items` VALUES (15,'Emergence\\CMS\\Item\\Markdown','2021-12-26 02:58:47',6,NULL,NULL,NULL,14,6,'Published',1,'\"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"'); + +CREATE TABLE `history_content_items` ( + `RevisionID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `ID` int(10) unsigned NOT NULL, + `Class` enum('Emergence\\CMS\\Item\\Album','Emergence\\CMS\\Item\\Embed','Emergence\\CMS\\Item\\Media','Emergence\\CMS\\Item\\RichText','Emergence\\CMS\\Item\\Text','Emergence\\CMS\\Item\\Markdown') NOT NULL, + `Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CreatorID` int(11) DEFAULT NULL, + `Modified` timestamp NULL DEFAULT NULL, + `ModifierID` int(10) unsigned DEFAULT NULL, + `Title` varchar(255) DEFAULT NULL, + `ContentID` int(10) unsigned NOT NULL, + `AuthorID` int(10) unsigned NOT NULL, + `Status` enum('Draft','Published','Hidden','Deleted') NOT NULL DEFAULT 'Published', + `Order` int(10) unsigned DEFAULT NULL, + `Data` json NOT NULL, + PRIMARY KEY (`RevisionID`), + KEY `ID` (`ID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `history_content_items` SELECT NULL AS RevisionID, `content_items`.* FROM `content_items`; \ No newline at end of file diff --git a/fixtures/tag_items.sql b/fixtures/tag_items.sql new file mode 100644 index 000000000..cd3314841 --- /dev/null +++ b/fixtures/tag_items.sql @@ -0,0 +1,29 @@ +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET character_set_client = utf8 */; + +CREATE TABLE `tag_items` ( + `Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CreatorID` int(11) DEFAULT NULL, + `ContextClass` varchar(255) DEFAULT NULL, + `ContextID` int(11) DEFAULT NULL, + `TagID` int(11) NOT NULL, + UNIQUE KEY `TagItem` (`TagID`,`ContextClass`,`ContextID`), + KEY `CONTEXT` (`ContextClass`,`ContextID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `tag_items` VALUES ('2021-12-26 02:44:16',3,'Emergence\\CMS\\AbstractContent',1,1); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:56:51',3,'Emergence\\CMS\\AbstractContent',10,1); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:57:01',3,'Emergence\\CMS\\AbstractContent',11,1); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:46:48',4,'Emergence\\CMS\\AbstractContent',2,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:47:16',4,'Emergence\\CMS\\AbstractContent',3,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:51:07',6,'Emergence\\CMS\\AbstractContent',4,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:51:52',6,'Emergence\\CMS\\AbstractContent',5,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:52:13',6,'Emergence\\CMS\\AbstractContent',6,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:53:45',4,'Emergence\\CMS\\AbstractContent',7,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:54:13',4,'Emergence\\CMS\\AbstractContent',8,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:54:33',4,'Emergence\\CMS\\AbstractContent',9,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:56:51',3,'Emergence\\CMS\\AbstractContent',10,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:57:01',3,'Emergence\\CMS\\AbstractContent',11,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:57:56',6,'Emergence\\CMS\\AbstractContent',12,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:58:20',6,'Emergence\\CMS\\AbstractContent',13,2); +INSERT INTO `tag_items` VALUES ('2021-12-26 02:58:47',6,'Emergence\\CMS\\AbstractContent',14,2); diff --git a/fixtures/tags.sql b/fixtures/tags.sql new file mode 100644 index 000000000..3cd9bcfa4 --- /dev/null +++ b/fixtures/tags.sql @@ -0,0 +1,17 @@ +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40101 SET character_set_client = utf8 */; + +CREATE TABLE `tags` ( + `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Class` enum('Tag') NOT NULL, + `Created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `CreatorID` int(11) DEFAULT NULL, + `Title` varchar(255) NOT NULL, + `Handle` varchar(255) NOT NULL, + `Description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`ID`), + UNIQUE KEY `Handle` (`Handle`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `tags` VALUES (1,'Tag','2021-12-26 02:44:16',3,'info','info',NULL); +INSERT INTO `tags` VALUES (2,'Tag','2021-12-26 02:46:48',4,'comment','comment',NULL); diff --git a/html-templates/sections/courseSection.tpl b/html-templates/sections/courseSection.tpl index e024da833..af4280701 100644 --- a/html-templates/sections/courseSection.tpl +++ b/html-templates/sections/courseSection.tpl @@ -30,43 +30,19 @@ {$Section = $data} - scope['limit'] = 10; - $options = [ - 'limit' => $this->scope['limit'], - 'offset' => $_GET['offset'] ?: 0, - 'calcFoundRows' => 'yes', - 'conditions' => [] - ]; - - $sectionTeacherIds = array_map(function($Teacher) { - return $Teacher->ID; - }, $this->scope['Section']->ActiveTeachers); - - $latestTeacherPost = \Emergence\CMS\BlogPost::getAllPublishedByContextObject($this->scope['Section'], array_merge_recursive($options, [ - 'conditions' => [ - 'AuthorID' => [ - 'operator' => 'IN', - 'values' => $sectionTeacherIds - ] - ], - 'limit' => 1 - ])); - - if (count($latestTeacherPost)) { - $this->scope['latestTeacherPost'] = $latestTeacherPost[0]; - $options['conditions'][] = sprintf('ID != %u', $this->scope['latestTeacherPost']->ID); - } - - $this->scope['blogPosts'] = \Emergence\CMS\BlogPost::getAllPublishedByContextObject($this->scope['Section'], $options); - $this->scope['total'] = DB::foundRows(); - ?> -