From ab90fa41ce165152f2c247685b0ac63ef4252818 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Fri, 15 Feb 2013 11:38:49 +0100 Subject: [PATCH 1/5] Add doc --- h5p.classes.php | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index a3b1344..be22e9d 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -91,7 +91,7 @@ interface h5pFramework { // TODO: I suspect this is a "skeleton" or more commonl public function storeLibraryData(&$libraryData); /** - * Ask the framework to store contentData + * Stores contentData * * @param int $contentId * Framework specific id identifying the content @@ -103,9 +103,52 @@ interface h5pFramework { // TODO: I suspect this is a "skeleton" or more commonl * Any contentMainId defined by the framework, for instance to support revisioning */ public function storeContentData($contentId, $contentJson, $mainJsonData, $contentMainId = NULL); + + /** + * Copies content data + * + * @param int $contentId + * Framework specific id identifying the content + * @param int $copyFromId + * Framework specific id identifying the content to be copied + * @param int $contentMainId + * Framework specific main id for the content, typically used in frameworks + * That supports versioning. (In this case the content id will typically be + * the version id, and the contentMainId will be the frameworks content id + */ public function copyContentData($contentId, $copyFromId, $contentMainId = NULL); + + /** + * Deletes content data + * + * @param int $contentId + * Framework specific id identifying the content + */ public function deleteContentData($contentId); + + /** + * Saves what libraries the content uses + * + * @param int $contentId + * Framework specific id identifying the content + * @param array $librariesInUse + * List of libraries the content uses. Libraries consist of arrays with: + * - libraryId stored in $librariesInUse[]['library']['libraryId'] + * - libraryId stored in $librariesInUse[]['preloaded'] + */ public function saveLibraryUsage($contentId, $librariesInUse); + + + /** + * Loads a library + * + * @param string $machineName + * @param int $majorVersion + * @param int $minorVersion + * @return array|FALSE + * Array representing the library with dependency descriptions + * FALSE if the library doesn't exist + */ public function loadLibrary($machineName, $majorVersion, $minorVersion); } From a2f179817361b1ebabb19f4117204d025481a375 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 17 Feb 2013 14:05:02 +0100 Subject: [PATCH 2/5] Rename store -> save --- h5p.classes.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index be22e9d..cb92b7b 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -88,7 +88,7 @@ interface h5pFramework { // TODO: I suspect this is a "skeleton" or more commonl * @param object $libraryData * Object holding the information that is to be stored */ - public function storeLibraryData(&$libraryData); + public function saveLibraryData(&$libraryData); /** * Stores contentData @@ -102,7 +102,7 @@ interface h5pFramework { // TODO: I suspect this is a "skeleton" or more commonl * @param int $contentMainId * Any contentMainId defined by the framework, for instance to support revisioning */ - public function storeContentData($contentId, $contentJson, $mainJsonData, $contentMainId = NULL); + public function saveContentData($contentId, $contentJson, $mainJsonData, $contentMainId = NULL); /** * Copies content data @@ -669,7 +669,7 @@ class h5pSaver { // We already have the same or a newer version of this library continue; } - $this->h5pF->storeLibraryData($library, $new); + $this->h5pF->saveLibraryData($library, $new); $current_path = $this->h5pF->getUploadedH5pFolderPath() . DIRECTORY_SEPARATOR . $key; $destination_path = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . $library['libraryId']; @@ -681,7 +681,7 @@ class h5pSaver { rename($current_path, $destination_path); $contentJson = file_get_contents($destination_path . DIRECTORY_SEPARATOR . 'content.json'); - $this->h5pF->storeContentData($contentId, $contentJson, $this->h5pC->mainJsonData, $contentMainId); + $this->h5pF->saveContentData($contentId, $contentJson, $this->h5pC->mainJsonData, $contentMainId); $librariesInUse = array(); $this->getLibraryUsage($librariesInUse, $this->h5pC->mainJsonData); From a5cb1db6d488ca940beabfd8cee9ce955e03c450 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 17 Feb 2013 15:04:30 +0100 Subject: [PATCH 3/5] Rename classes and interfaces --- h5p.classes.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index cb92b7b..87ba184 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2,7 +2,7 @@ /** * Interface defining functions the h5p library needs the framework to implement */ -interface h5pFramework { // TODO: I suspect this is a "skeleton" or more commonly known as a interface for classes to implement, not a framework as the name might suggest. +interface H5PFramework { // TODO: I suspect this is a "skeleton" or more commonly known as a interface for classes to implement, not a framework as the name might suggest. /** * Show the user an error message * @@ -152,7 +152,7 @@ interface h5pFramework { // TODO: I suspect this is a "skeleton" or more commonl public function loadLibrary($machineName, $majorVersion, $minorVersion); } -class h5pValidator { +class H5PValidator { public $h5pF; public $h5pC; @@ -240,14 +240,14 @@ class h5pValidator { ); /** - * Constructor for the h5pValidator + * Constructor for the H5PValidator * - * @param object $h5pFramework - * The frameworks implementation of the h5pFramework interface + * @param object $H5PFramework + * The frameworks implementation of the H5PFramework interface */ - public function __construct($h5pFramework, $h5pCore) { - $this->h5pF = $h5pFramework; - $this->h5pC = $h5pCore; + public function __construct($H5PFramework, $H5PCore) { + $this->h5pF = $H5PFramework; + $this->h5pC = $H5PCore; } /** @@ -639,20 +639,20 @@ class h5pValidator { } } -class h5pSaver { +class H5PStorage { public $h5pF; public $h5pC; /** - * Constructor for the h5pSaver + * Constructor for the H5PStorage * - * @param object $h5pFramework - * The frameworks implementation of the h5pFramework interface + * @param object $H5PFramework + * The frameworks implementation of the H5PFramework interface */ - public function __construct($h5pFramework, $h5pCore) { - $this->h5pF = $h5pFramework; - $this->h5pC = $h5pCore; + public function __construct($H5PFramework, $H5PCore) { + $this->h5pF = $H5PFramework; + $this->h5pC = $H5PCore; } public function savePackage($contentId, $contentMainId = NULL) { @@ -733,20 +733,20 @@ class h5pSaver { } } -class h5pCore { +class H5PCore { public $h5pF; public $librariesJsonData; public $contentJsonData; public $mainJsonData; /** - * Constructor for the h5pSaver + * Constructor for the H5PCore * - * @param object $h5pFramework - * The frameworks implementation of the h5pFramework interface + * @param object $H5PFramework + * The frameworks implementation of the H5PFramework interface */ - public function __construct($h5pFramework) { - $this->h5pF = $h5pFramework; + public function __construct($H5PFramework) { + $this->h5pF = $H5PFramework; } public function isSameVersion($library, $dependency) { From c6567108893f4fbc988d880335d2bb28d2114844 Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 17 Feb 2013 15:39:26 +0100 Subject: [PATCH 4/5] Rename H5PFramework to H5PFrameworkInterface (Adopting drupals naming convention for interfaces) --- h5p.classes.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 87ba184..5fcaa7d 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2,7 +2,7 @@ /** * Interface defining functions the h5p library needs the framework to implement */ -interface H5PFramework { // TODO: I suspect this is a "skeleton" or more commonly known as a interface for classes to implement, not a framework as the name might suggest. +interface H5PFrameworkInterface { /** * Show the user an error message * @@ -243,7 +243,7 @@ class H5PValidator { * Constructor for the H5PValidator * * @param object $H5PFramework - * The frameworks implementation of the H5PFramework interface + * The frameworks implementation of the H5PFrameworkInterface */ public function __construct($H5PFramework, $H5PCore) { $this->h5pF = $H5PFramework; @@ -648,7 +648,7 @@ class H5PStorage { * Constructor for the H5PStorage * * @param object $H5PFramework - * The frameworks implementation of the H5PFramework interface + * The frameworks implementation of the H5PFrameworkInterface */ public function __construct($H5PFramework, $H5PCore) { $this->h5pF = $H5PFramework; @@ -743,7 +743,7 @@ class H5PCore { * Constructor for the H5PCore * * @param object $H5PFramework - * The frameworks implementation of the H5PFramework interface + * The frameworks implementation of the H5PFrameworkInterface */ public function __construct($H5PFramework) { $this->h5pF = $H5PFramework; From b1bc7245789a1e406e43cfce4b2f2d47ce9fce8e Mon Sep 17 00:00:00 2001 From: Svein-Tore Griff With Date: Sun, 17 Feb 2013 15:40:07 +0100 Subject: [PATCH 5/5] Remove already fixed todo item --- h5p.classes.php | 1 - 1 file changed, 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 5fcaa7d..7b941dc 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -283,7 +283,6 @@ class H5PValidator { $libraryJsonData; $mainH5pExists = $imageExists = $contentExists = FALSE; foreach ($files as $file) { - // TODO: Any reason not to just drop anything starting with .? if (in_array(substr($file, 0, 1), array('.', '_'))) { continue; }