Skip to content

Commit d22d0f7

Browse files
authored
Merge pull request #141 from Books4Languages/christos
Christos
2 parents fcbea95 + f3bba31 commit d22d0f7

31 files changed

+835
-242
lines changed

README.md

+17-4
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,31 @@ You can see all of the screenshots of the plugin [here](https://github.com/Books
7878
Implementation of milestone 9.1 (Finishing educational metadata and related metadata)
7979

8080
### Later
81-
Settings page in superadmin -network- level
81+
8282

8383
### Future
8484
New types
8585

8686
## Changelog
8787

88-
## 1.0
88+
## 0.11
89+
* **ADDITIONS**
90+
* Enable the cloning of properties from each site (Book Info/Site-Meta) to (Chapter/Post) #140
91+
92+
* **List of Files revised**
93+
* class-pressbooks-metadata-engine.php
94+
* class-pressbooks-metadata-property-overwrite.php
95+
* class-pressbooks-metadata-property-fields.php
96+
97+
## 0.10
8998
* **ADDITIONS**
9099
* Show parent activation and info for empty Types #113
91100
* Add parent sections under each tab level #123
92101
* Add a link that will pop up a lightbox for the properties for every type #120
93102
* Add the coins and the dublin core vocabulary into the plugin #116
94103
* **ENHANCEMENTS**
95104
* Fix Tab Navigation in Settings #133
96-
* Each type link is opning in a new page #132
105+
* Each type link is opening in a new page #132
97106
* Fixed Positioning of the filters #127
98107
* Fix the loading animation and the saving of the first type #125
99108
* Change color for warnings on settings page #122
@@ -278,7 +287,11 @@ New types
278287

279288
## Upgrade Notice
280289

281-
### 1.0
290+
### 0.11
291+
Administrator can overwrite Chapter and Post property values from Book-Info and Site-Meta.The administrator can populate type property values in all chapters
292+
or posts. This is done by selecting the toPost or toChapter option on a property of any type from the Site-Meta tab of the settings
293+
294+
### 0.10
282295
Code rewriting for optimisation. All the types inherit as classes from a base class called type. The creation of new types is way simpler and faster.
283296
Each property for each level and each type can be enabled and disabled. Dublin core and Coins vocabularies were added, also the schema types now can be
284297
filtered by parent.

pressbooks-metadata/.idea/workspace.xml

+175-139
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Listen for XDebug",
6+
"type": "php",
7+
"request": "launch",
8+
"port": 9000
9+
},
10+
{
11+
"name": "Launch currently open script",
12+
"type": "php",
13+
"request": "launch",
14+
"program": "${file}",
15+
"cwd": "${fileDirname}",
16+
"port": 9000
17+
}
18+
]
19+
}

pressbooks-metadata/admin/adminFunctions/class-pressbooks-metadata-options.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function add_options_page() {
4949
/**
5050
* Render the options page for plugin.
5151
*
52-
* @since 1.0
52+
* @since 0.10
5353
*/
5454
function render_options_page() {
5555
?>
@@ -77,7 +77,7 @@ function render_options_page() {
7777
/**
7878
* Add the metaboxes to the options page.
7979
*
80-
* @since 1.0
80+
* @since 0.10
8181
*/
8282
function add_metaboxes() {
8383
wp_enqueue_script('common');
@@ -91,7 +91,7 @@ function add_metaboxes() {
9191
/**
9292
* Render data for the metabox.
9393
*
94-
* @since 1.0
94+
* @since 0.10
9595
*/
9696
function render_metabox_schema_locations() {
9797
include_once plugin_dir_path( dirname( __FILE__ ) ) . 'partials/pressbooks-metadata-admin-settings-schemaLocations.php';
@@ -100,7 +100,7 @@ function render_metabox_schema_locations() {
100100
/**
101101
* Render data for the specific_metadata metabox.
102102
*
103-
* @since 1.0
103+
* @since 0.10
104104
*/
105105
function render_metabox_specific_metadata(){
106106
include_once plugin_dir_path( dirname( __FILE__ ) ) . 'partials/pressbooks-metadata-admin-settings-specificMeta.php';
@@ -109,7 +109,7 @@ function render_metabox_specific_metadata(){
109109
/**
110110
* Render data for the active_schemas metabox.
111111
*
112-
* @since 1.0
112+
* @since 0.10
113113
*/
114114
function render_metabox_active_schemas(){
115115
include_once plugin_dir_path( dirname( __FILE__ ) ) . 'partials/pressbooks-metadata-admin-settings-activeSchemas.php';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
namespace networkFunctions;
3+
4+
/**
5+
* The class that handles the creation of fields for the network admin settings
6+
*
7+
* @link https://github.com/Books4Languages/pressbooks-metadata
8+
* @since 0.10
9+
*
10+
* @package Pressbooks_Metadata
11+
* @subpackage Pressbooks_Metadata/admin/networkFunctions
12+
* @author Christos Amyrotos <[email protected]>
13+
*/
14+
15+
class Pressbooks_Metadata_Net_Sett_Sections {
16+
17+
/**
18+
* The id for the section of fields.
19+
*
20+
* @since 0.10
21+
*/
22+
public $sectionId;
23+
24+
/**
25+
* The display page for the section of fields.
26+
*
27+
* @since 0.10
28+
*/
29+
public $sectionDisPage;
30+
31+
/**
32+
* The title for the section of fields.
33+
*
34+
* @since 0.10
35+
*/
36+
public $sectionTitle;
37+
38+
/**
39+
* The type name.
40+
*
41+
* @since 0.10
42+
*/
43+
public $typeId;
44+
45+
/**
46+
* The type properties.
47+
*
48+
* @since 0.10
49+
*/
50+
public $typeProperties;
51+
52+
/**
53+
* The type level.
54+
*
55+
* @since 0.10
56+
*/
57+
public $typeLevel;
58+
59+
function __construct($inpSectionId,$inpSectionDisPage,$inpSectionTitle,$inpTypeId,$inpTypeProperties,$inpTypeLevel){
60+
$this->sectionId = $inpSectionId;
61+
$this->sectionDisPage = $inpSectionDisPage;
62+
$this->sectionTitle = $inpSectionTitle;
63+
$this->typeId = $inpTypeId;
64+
$this->typeProperties = $inpTypeProperties;
65+
$this->typeLevel = $inpTypeLevel;
66+
$this->createSection();
67+
$this->createFields($this->typeProperties);
68+
}
69+
70+
/**
71+
* Function that creates the settings section, each schema type has its own section.
72+
*
73+
* @since 0.10
74+
*/
75+
function createSection(){
76+
//Adding the settings section
77+
add_settings_section($this->sectionId,$this->sectionTitle
78+
,false,$this->sectionDisPage);
79+
}
80+
81+
/**
82+
* Function that creates the fields for each section, each schema type property is a field.
83+
*
84+
* @since 0.10
85+
*/
86+
function createFields($data){
87+
//Looping through the properties of the type
88+
foreach($data as $propertyId => $details){
89+
90+
//Creating the name of the options
91+
$propertyOptionName = $propertyId.'_'.$this->typeId.'_'.$this->typeLevel;
92+
$propertyFreeze = $propertyOptionName.'_freeze';
93+
94+
//Registering the setting holding the value
95+
register_setting($this->sectionDisPage,$propertyOptionName);
96+
97+
//Registering the setting for freezing
98+
register_setting($this->sectionDisPage,$propertyFreeze);
99+
100+
//Callback function for the input field
101+
$fieldRenderFunction = function() use ($propertyOptionName){
102+
$html = '<input type="text" class="regular-text" name="'.$propertyOptionName.'" value="'.get_option($propertyOptionName).'"><br>';
103+
echo $html;
104+
};
105+
106+
//Callback function for the freeze checkbox
107+
$checkboxRenderFunction = function() use ($propertyFreeze){
108+
?>
109+
<label><input type="checkbox" name="<?=$propertyFreeze?>"
110+
value="1" <?php checked(get_option($propertyFreeze)); ?> /> <?php
111+
echo 'Check this box if you want to freeze this property.' ?></label>
112+
<?php
113+
};
114+
115+
//Adding the property field
116+
add_settings_field($propertyOptionName,$details[1]
117+
,$fieldRenderFunction,$this->sectionDisPage,$this->sectionId);
118+
119+
//Adding the checkbox field
120+
add_settings_field($propertyFreeze,''
121+
,$checkboxRenderFunction,$this->sectionDisPage,$this->sectionId);
122+
}
123+
}
124+
}

0 commit comments

Comments
 (0)