Commit 42ba5b2b authored by Malcolm Blaney's avatar Malcolm Blaney

Moved template description inserts from start.php to the respective

modules for each template. Added Base->AddTemplateDescription to
help. Switched SimplePie image handler to just the path rather than
the full url, which means Reader->ImageHandler can be removed. Bug
fix / typo in auth.php, $this->user->name should be $domain. Rewrote
most of start.php and tests/bootstrap.php so they are cleaner and
share more code, which also makes the latter a better test of the
former. Also all modules are now installed when testing, though
there's still a lot of work to do writing tests... made a start on
that too by improving existing tests and adding a couple of new ones.
parent fcbf9805
Pipeline #18365085 failed with stage
in 1 minute and 23 seconds
......@@ -34,7 +34,7 @@ class Analytics extends Base {
}
public function CanRemove($id) {
return true;
return false;
}
public function Content($id) {
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -207,23 +207,29 @@ class Banking extends Base {
// Note that the module is only available when logged in.
$this->AppendScript($path, 'dobrado.banking.js', false);
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS banking ('.
'user VARCHAR(50) NOT NULL,'.
'reference VARCHAR(20) NOT NULL,'.
'name VARCHAR(100),'.
'number VARCHAR(20),'.
'bsb VARCHAR(7),'.
'credit TINYINT(1),'.
'surcharge TINYINT(1),'.
'deposit TINYINT(1),'.
'next_week INT(10) UNSIGNED NOT NULL,'.
'buyer_group ENUM("", "wholesale", "retail"),'.
'PRIMARY KEY(user)'.
$query = 'CREATE TABLE IF NOT EXISTS banking (' .
'user VARCHAR(50) NOT NULL,' .
'reference VARCHAR(20) NOT NULL,' .
'name VARCHAR(100),' .
'number VARCHAR(20),' .
'bsb VARCHAR(7),' .
'credit TINYINT(1),' .
'surcharge TINYINT(1),' .
'deposit TINYINT(1),' .
'next_week INT(10) UNSIGNED NOT NULL,' .
'buyer_group ENUM("", "wholesale", "retail"),' .
'PRIMARY KEY(user)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log("Banking->Install: ".$mysqli->error);
$this->Log("Banking->Install: " . $mysqli->error);
}
$mysqli->close();
$description = ['banking-default-group' => 'Either \'retail\', ' .
'\'wholesale\' or empty to set which stock price ' .
'should be used for new members.'];
$this->AddTemplateDescription($description);
$site_style = ['"",".banking .edit a","color","#222222"',
'"",".banking .edit a","font-family","Verdana"',
'"",".banking .edit a","font-size","0.8em"',
......
......@@ -351,14 +351,36 @@ class Cart extends Base {
'"cart-checkout","","Your order will be sent to:<br>' .
'!first !last<br>!address<br>!postcode<br>!city<br>' .
'!state<br>!country<br>"',
'"cart-display-item","","<h2>!name</h2><img src="!image">' .
'!description',
'"cart-display-item","","<h2>!name</h2><img src=\"!image\">' .
'!description"',
'"cart-email","","To !first !last<br>Thanks for your order! ' .
'The following is a confirmation of your purchases and ' .
'contact details:<br><br>!items<br><b>Total: ' .
'$!amount</b><br><br>Email: !email<br>Address:<br>!address' .
'<br>!city<br>!postcode<br>!state<br>!country<br><br>"'];
$this->AddTemplate($template);
$description = ['cart-price-text' => 'The text before the price for ' .
'each item.',
'cart-quantity-text' => 'The text before the quantity ' .
'for each item.',
'cart-title' => 'The text for the title above the cart ' .
'items.',
'cart-checkout' => 'The text to display at checkout, ' .
'will substitute the following to show where items ' .
'will be sent: !first, !last, !address, !postcode, ' .
'!city, !state, !country, !description.',
'cart-email' => 'The full text of the email that will be ' .
'sent to the customer, confirming their order. It will ' .
'also be sent to the admin email address set in the ' .
'cart checkout settings. Substitutes: !items, !amount, ' .
'!first, !last, !email, !address, !postcode, !city, ' .
'!state, !country.',
'cart-description-label' => 'A label for the input ' .
'option set in the \'cart-description-input\' template.',
'cart-description-input' => 'A configurable input option ' .
'added to \'cart-customer-details-form\' to request ' .
'custom details.'];
$this->AddTemplateDescription($description);
$site_style = ['"","#cart-summary","margin-bottom","40px"',
'"","#cart-confirm-button","float","right"',
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -339,6 +339,118 @@ class Invoice extends Base {
'purchased this month."',
'"invoice-surcharge-description", "", "Surcharge"'];
$this->AddTemplate($template);
$description = ['pre-order-reminder' => 'The string \'true\' or ' .
'\'false\' to add a reminder to invoices to place an ' .
'order for the following week.',
'invoice-day' => 'The day invoices are sent out.',
'invoice-day-count' => 'The number of days to look back ' .
'for purchases to include in the invoice.',
'invoice-group-attach-files' => 'The string \'true\' or ' .
'\'false\' to attach order lists to group stock emails. '.
'Useful if there is no parent organisation for the ' .
'group receiving the attachments.',
'invoice-send-orders' => 'The day of the week to send ' .
'orders to individual members. (Separate from ' .
'pre-order-final so that orders can be sent closer to ' .
'co-op-day as a reminder).',
'invoice-send-orders-time' => 'The time of day to send ' .
'orders to individual members.',
'invoice-ignore-group' => 'The name of a group to ignore ' .
'when counting the number of real buyers groups in an ' .
'organisation, such as \'non-purchasing\'.',
'invoice-start-no-purchase' => 'The start of the invoice ' .
'for when no purchases have been made. Substitutes: ' .
'!date, !first and !last.',
'invoice-start-purchase' => 'The start of the invoice ' .
'for when purchases are made. Substitutes: !number ' .
'(invoice number), !date, !first, !last.',
'invoice-after-purchase' => 'Only included when purchases '.
'are made, allows custom text to say that this is the ' .
'formal end of the invoice.',
'invoice-user-info' => 'Substitutes personal information: '.
'!user (username), !volunteer (volunteer message), ' .
'!reference (bank reference) and also !server. This is ' .
'where bank details should go.',
'invoice-balance' => 'The amount used to consider an ' .
'account as \'in balance\'.',
'invoice-current-balance' => 'Allows !balance to be ' .
'substituted without qualifying when transaction ' .
'processing was last done.',
'invoice-old-balance' => 'Substitutes !balance, and also ' .
'!date (the date the transactions were last processed) ' .
'so that users can work out if their balance is ' .
'accurate.',
'invoice-sign-off' => 'A final massage at the end of the ' .
'invoice.',
'invoice-subject' => 'A subject line for the invoice ' .
'email.',
'invoice-sender' => 'The \'from\' address of invoice ' .
'email, must be on the domain.',
'invoice-sender-name' => 'A descriptive name prepended ' .
'to the \'from\' address of the invoice email.',
'invoice-cc' => 'The cc address to use when an email is ' .
'sent from invoice-sender',
'invoice-bcc' => 'The bcc address to use when an email ' .
'is sent from invoice-sender',
'invoice-order-subject' => 'The subject of the individual '.
'orders email',
'invoice-order-start' => 'The start of the individual ' .
'orders email',
'invoice-order-cc' => 'The cc address to use when ' .
'sending individual order emails',
'invoice-bcc' => 'The bcc address to use when sending ' .
'individual order emails',
'invoice-group-subject' => 'A subject of the orders email '.
'for the group.',
'invoice-remove-orders' => 'The day of the week the ' .
'orders are removed.',
'invoice-group-email' => 'The \'to\' address for the ' .
'orders email for the group.',
'invoice-group-cc' => 'A cc address for the orders email ' .
'for the group.',
'invoice-group-bcc' => 'A bcc address for the orders ' .
'email for the group.',
'invoice-intro-no-orders' => 'Intro to orders email when ' .
'there are no orders recorded.',
'invoice-intro-orders' => 'Intro to orders email when ' .
'there are orders recorded.',
'invoice-attendance-hello' => 'A custom message at the ' .
'start of the attendance email.',
'invoice-attendance-email' => 'The \'to\' address for the '.
'attendance email.',
'invoice-attendance-cc' => 'The cc address to use when an '.
'email is sent from invoice-attendance-email',
'invoice-attendance-bcc' => 'The bcc address to use when ' .
'an email is sent from invoice-attendance-email',
'invoice-attendance-subject' => 'The subject line for the '.
'attendance email.',
'invoice-order-rounding' => 'A value between zero and ' .
'one, used to decide if the number of packs should be ' .
'rounded up or down. If empty the number of packs will ' .
'be left as a fraction.',
'invoice-organisation-sender' => 'The \'from\' address ' .
'of the orders email for the organisation, must be on ' .
'the domain.',
'invoice-organisation-sender-name' => 'A descriptive ' .
'name for the \'from\' address for the organisation ' .
'orders email.',
'invoice-organisation-email' => 'The \'to\' address of ' .
'the orders email for the organisation.',
'invoice-organisation-subject' => 'The subject line of ' .
'the orders email for the organisation.',
'invoice-group-format' => 'The string \'user\' or ' .
'\'product\' for choosing the display format. The ' .
'group email will be ordered by this category.',
'invoice-organisation-format' => 'The string ' .
'\'vertical\' or \'horizontal\' for choosing the ' .
'display format. Horizontal is useful for more than ' .
'one group, as it displays the group names in their ' .
'own columns. Vertical only displays a row for a group ' .
'if there is an order for that item by the group.',
'invoice-extra-column' => 'The name of an extra column ' .
'in the supplier spreadsheet, in case they want to ' .
'provide feedback on the order.'];
$this->AddTemplateDescription($description);
$site_style = ['"",".invoice .export-data","float","right"',
'"","#invoice-list-all","float","right"',
......
......@@ -359,6 +359,14 @@ class Payment extends Base {
}
$mysqli->close();
$description = ['payment-surcharge-type' => 'The name of the custom ' .
'surcharge type used, options are: ' .
'\'sliding-scale-capped\', \'zero-one-two-fifty\'. ' .
'If left blank the surcharge value is taken from the ' .
'payment settings. See Payment module Surcharge ' .
'function for details on custom types.'];
$this->AddTemplateDescription($description);
$site_style = ['"","#payment-form","background-color","#eeeeee"',
'"","#payment-form","border","1px solid #aaaaaa"',
'"","#payment-form","border-radius","2px"',
......
......@@ -605,7 +605,12 @@ class Post extends Base {
'"permalink-post-with-title", "", ' .
'"' . $mysqli->escape_string($permalink_with_title) . '"'];
$mysqli->close();
$this->AddTemplate($template);
$description = ['post-format' => 'The template for a blog post, ' .
'substitutes: !title, !description, !author, !category, '.
'!media and !date.'];
$this->AddTemplateDescription($description);
}
public function Placement() {
......
This diff is collapsed.
......@@ -151,7 +151,7 @@ class Reader extends Base {
$feed = new SimplePie();
$feed->force_feed(true);
$feed->enable_order_by_date(false);
$feed->set_image_handler($this->ImageHandler());
$feed->set_image_handler('/php/image.php');
$daily = $this->Run('12am');
$us_updated = [];
foreach ($this->FeedList() as $us_xml_url) {
......@@ -370,7 +370,14 @@ class Reader extends Base {
'"reader-format-no-title", "", ' .
'"' . $mysqli->escape_string($format_no_title) . '"'];
$mysqli->close();
$this->AddTemplate($template);
$description = ['reader-item-count' => 'The number of items to return ' .
'when more are requested.',
'reader-format' => 'The template for a reader item, ' .
'substitutes: !title, !description, !author, ' .
'!category, !media and !date.'];
$this->AddTemplateDescription($description);
$site_style = ['"",".reader .feed-item","padding","5px"',
'"",".reader .feed-text.added","background-color","#ff5500"',
......@@ -580,7 +587,7 @@ class Reader extends Base {
// to do feed discovery.
$feed = new SimplePie();
$feed->enable_order_by_date(false);
$feed->set_image_handler($this->ImageHandler());
$feed->set_image_handler('/php/image.php');
$feed->set_feed_url($us_xml_url);
$feed->force_feed($force);
// get_all_discoverd_feeds doesn't work if caching is used.
......@@ -1200,11 +1207,6 @@ class Reader extends Base {
return [$class, $reader_item];
}
private function ImageHandler() {
$scheme = $this->user->config->Secure() ? 'https://' : 'http://';
return $scheme.$this->user->config->ServerName().'/php/image.php';
}
private function ImportFile() {
$max_file_size = $this->user->config->MaxFileSize();
// ['upload']['size'] is given in bytes, MaxFileSize is in megabytes.
......@@ -1867,7 +1869,7 @@ class Reader extends Base {
$feed = new SimplePie();
$feed->set_feed_url($us_xml_url);
$feed->enable_order_by_date(false);
$feed->set_image_handler($this->ImageHandler());
$feed->set_image_handler('/php/image.php');
$feed->force_feed(true);
$feed->set_cache_duration(0);
$feed->set_raw_data($data);
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -191,30 +191,35 @@ class Roster extends Base {
// Note that the module is only available when logged in.
$this->AppendScript($path, 'dobrado.roster.js', false);
$mysqli = connect_db();
$query = 'CREATE TABLE IF NOT EXISTS roster ('.
'user VARCHAR(50) NOT NULL,'.
'first VARCHAR(50),'.
'last VARCHAR(50),'.
'phone VARCHAR(50),'.
'role VARCHAR(50),'.
'timestamp INT(10) UNSIGNED NOT NULL,'.
'PRIMARY KEY(user, timestamp)'.
$query = 'CREATE TABLE IF NOT EXISTS roster (' .
'user VARCHAR(50) NOT NULL,' .
'first VARCHAR(50),' .
'last VARCHAR(50),' .
'phone VARCHAR(50),' .
'role VARCHAR(50),' .
'timestamp INT(10) UNSIGNED NOT NULL,' .
'PRIMARY KEY(user, timestamp)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Roster->Install 1: '.$mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS roster_role ('.
'system_group VARCHAR(50) NOT NULL,'.
'role VARCHAR(50) NOT NULL,'.
'description TEXT,'.
'display TINYINT(1),'.
'requires INT UNSIGNED,'.
'PRIMARY KEY(system_group, role)'.
$this->Log('Roster->Install 1: ' . $mysqli->error);
}
$query = 'CREATE TABLE IF NOT EXISTS roster_role (' .
'system_group VARCHAR(50) NOT NULL,' .
'role VARCHAR(50) NOT NULL,' .
'description TEXT,' .
'display TINYINT(1),' .
'requires INT UNSIGNED,' .
'PRIMARY KEY(system_group, role)' .
') ENGINE=MyISAM';
if (!$mysqli->query($query)) {
$this->Log('Roster->Install 2: '.$mysqli->error);
$this->Log('Roster->Install 2: ' . $mysqli->error);
}
$mysqli->close();
$description = ['roster-reminder' => 'The string \'true\' or \'false\' ' .
'to turn reminders on or off.'];
$this->AddTemplateDescription($description);
$site_style = ['"","#roster-form","background-color","#eeeeee"',
'"","#roster-form","border","1px solid #aaaaaa"',
'"","#roster-form","border-radius","2px"',
......
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -298,10 +298,18 @@ class Sell extends Base {
'"sell-checkout","","Thanks for providing your '.
'details !first."'];
$this->AddTemplate($template);
$site_style = ['"","#sell-customer-details-form","background-color",'.
$description = ['sell-items-description' => 'A description used by the ' .
'Point of Sale Checkout when submitting a payment. ' .
'Will substitute !date.',
'sell-checkout' => 'A message to display at the Point of ' .
'Sale Checkout, above the list of purchases. Will ' .
'substitute all the details the user provided: !first, ' .
'!last, !address, !postcode, !city, !state, !country.'];
$this->AddTemplateDescription($description);
$site_style = ['"","#sell-customer-details-form","background-color",' .
'"#eeeeee"',
'"","#sell-customer-details-form","border",'.
'"","#sell-customer-details-form","border",' .
'"1px solid #aaaaaa"',
'"","#sell-customer-details-form","border-radius","2px"',
'"","#sell-customer-details-form","padding","5px"',
......
......@@ -171,7 +171,7 @@ class Settings extends Base {
'"",".settings-section","background-color","#eeeeee"',
'"",".settings-section","border","1px solid #aaaaaa"',
'"",".settings-section","margin","5px"',
'"",".settings-section","border","5px"',
'"",".settings-section","padding","5px"',
'"",".settings-section h2","margin-top","5px"',
'"",".settings fieldset","margin-bottom","5px"',
'"",".settings-info","font-size","0.8em"',
......
This diff is collapsed.
<?php
// Dobrado Content Management System
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -194,6 +194,14 @@ class Summary extends Base {
'processed on !date)"',
'"summary-available-orders","","Select a group:"'];
$this->AddTemplate($template);
$description = ['summary-pre-order' => 'Descriptive text for the ' .
'summary page specifying when pre-orders are ' .
'finalised. Will replace !final with ' .
'\'pre-order-final\' substitution.',
'summary-balance' => 'Descriptive text to display after ' .
'a negative balance. Substitutes !date for when ' .
'payments were last processed.'];
$this->AddTemplateDescription($description);
// Check module dependenices.
$dependencies = ['detail', 'invite', 'payment', 'purchase', 'roster'];
......
<?php
// Dobrado Content Management System
// Copyright (C) 2016 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -112,49 +112,40 @@ class Workgroup extends Base {
}
public function Install($path) {
$site_style = array('"",".workgroup-profile .thumb","float","left"',
'"",".workgroup-profile .thumb","padding","5px"',
'"",".workgroup-profile","clear","both"',
'"",".workgroup-fullname","font-size","1.4em"',
'"",".workgroup-role","clear","both"',
'"",".workgroup-role","padding","10px"',
'"",".workgroup-role","margin","10px"',
'"",".workgroup-role","background-color","#eeeeee"',
'"",".workgroup-role","border","1px solid #aaaaaa"',
'"",".workgroup-role","border-radius","2px"',
'"",".workgroup-role .clear","clear","both"',
'"",".workgroup-description","margin","10px"',
'"",".workgroup-non-active","clear","both"',
'"",".workgroup-non-active","margin","10px"');
$site_style = ['"",".workgroup-profile .thumb","float","left"',
'"",".workgroup-profile .thumb","padding","5px"',
'"",".workgroup-profile","clear","both"',
'"",".workgroup-fullname","font-size","1.4em"',
'"",".workgroup-role","clear","both"',
'"",".workgroup-role","padding","10px"',
'"",".workgroup-role","margin","10px"',
'"",".workgroup-role","background-color","#eeeeee"',
'"",".workgroup-role","border","1px solid #aaaaaa"',
'"",".workgroup-role","border-radius","2px"',
'"",".workgroup-role .clear","clear","both"',
'"",".workgroup-description","margin","10px"',
'"",".workgroup-non-active","clear","both"',
'"",".workgroup-non-active","margin","10px"'];
$this->AddSiteStyle($site_style);
$template = array('"workgroup-start-text", "", "Members are listed below '.
'in their working groups or based on recent roster '.
'information.<br>To get involved in a working group, '.
'please see the contact information for members in '.
'each group."',
'"workgroup-non-active-text", "", "If your name is '.
'listed below, we would love you to get involved in '.
'running the co-op op. You can start by adding your '.
'name to the roster."');
$template = ['"workgroup-start-text", "", "Members are listed below ' .
'in their working groups or based on recent roster ' .
'information.<br>To get involved in a working group, ' .
'please see the contact information for members in ' .
'each group."',
'"workgroup-non-active-text", "", "If your name is ' .
'listed below, we would love you to get involved in ' .
'running the co-op op. You can start by adding your ' .
'name to the roster."'];
$this->AddTemplate($template);
$description = ['workgroup-start-text' => 'A description to display at ' .
'the start of the Workgroup module content.',
'workgroup-non-active-text' => 'A description to display ' .
'at the start of the non-active user group.'];
$this->AddTemplateDescription($description);
// Check module dependenices.
$detail = new Module($this->user, $this->owner, 'detail');
$roster = new Module($this->user, $this->owner, 'roster');
if (!$detail->IsInstalled() && !$roster->IsInstalled()) {
$error = "Please also install 'detail' and 'roster' modules.";
return array('error' => $error);
}
if (!$detail->IsInstalled()) {
$error = "Please also install 'detail' module.";
return array('error' => $error);
}
if (!$roster->IsInstalled()) {
$error = "Please also install 'roster' module.";
return array('error' => $error);
}
return array('done' => true);
return $this->Dependencies(['detail', 'roster']);
}
public function Placement() {
......
......@@ -181,13 +181,13 @@ if (!$exists) {
if (isset($_SESSION['micropub-endpoint'])) {
// Store or update the micropub endpoint in case the session is reset.
$micropub = $mysqli->escape_string($_SESSION['micropub-endpoint']);
$query = 'INSERT INTO settings VALUES ("' . $this->user->name . '", ' .
$query = 'INSERT INTO settings VALUES ("' . $domain . '", ' .
'"micropub", "endpoint", "' . $micropub . '") ON DUPLICATE KEY UPDATE ' .
'value = "' . $micropub . '"';
}
else {
// Try removing any existing micropub endpoint in case it was set previously.
$query = 'DELETE FROM settings WHERE user = "' . $this->user->name . '" ' .
$query = 'DELETE FROM settings WHERE user = "' . $domain . '" ' .
'AND label = "micropub" AND name = "endpoint"';
}
if (!$mysqli->query($query)) {
......
......@@ -310,3 +310,124 @@ function create_tables() {
$mysqli->close();
}
function create_site_style() {
$mysqli = connect_db();
// This is a default media query for mobile devices. Note '.dobrado-mobile'
// visibility is used by javascript to do some dynamic configuration.
$media = '@media screen and (max-device-width: 480px)';
// Add some site wide style rules that aren't set by modules.
$site_style = ['"","body","margin","0"',
'"","body","padding","0"',
'"","iframe","max-width","100%"',
'"","img","max-width","100%"',
'"","img","height","auto"',
'"","img","border-style","none"',
'"",".form-spacing","margin-top","4px"',
'"",".form-spacing","margin-bottom","4px"',
'"",".form-spacing","clear","both"',
'"",".form-spacing > input[type=text]","height","25px"',
'"",".form-spacing > input[type=text]","width","300px"',
'"",".form-spacing > input[type=password]","height","25px"',
'"",".form-spacing > input[type=password]","width","300px"',
'"",".form-spacing > input[type=checkbox]","height","20px"',
'"",".form-spacing > input","max-width","100%"',
'"",".form-spacing > textarea","height","75px"',
'"",".form-spacing > textarea","width","300px"',
'"",".form-spacing > textarea","max-width","100%"',
'"",".form-spacing > textarea","padding","8px"',
'"",".form-spacing > select","height","30px"',
'"",".form-spacing > label","float","left"',
'"",".form-spacing > label","margin-top","0.3em"',
'"",".form-spacing > label","margin-right","0.3em"',
'"",".form-spacing > label","text-align","right"',
'"",".hidden","display","none"',
'"",".show","display","block"',
'"",".main > .header","min-height","100px"',
'"",".main > .left","position","relative"',
'"",".main > .left","left","0"',
'"",".main > .left","top","0"',
'"",".main > .left","width","0"',
'"",".main > .left","float","left"',
'"",".main > .left","min-height","100px"',
'"",".main > .right","position","relative"',
'"",".main > .right","right","0"',
'"",".main > .right","top","0"',
'"",".main > .right","width","0"',
'"",".main > .right","float","right"',
'"",".main > .right","min-height","100px"',
'"",".main > .middle","position","relative"',
'"",".main > .middle","width","760px"',
'"",".main > .middle","margin-left","auto"',
'"",".main > .middle","margin-right","auto"',
'"",".main > .middle","min-height","350px"',
'"",".main > .footer","clear","both"',
'"",".main > .footer","min-height","100px"',
'"",".dobrado-editable","min-height","100px"',
'"",".dobrado-editable.border","border","1px dashed #828282"',
'"",".cke_skin_kama a.cke_button_extended .cke_icon",' .
'"background-image","url(\"/images/extended.png\")"',
'"",".cke_skin_kama a.cke_button_extended .cke_icon",' .
'"background-position","center"',
'"",".ui-sortable-placeholder","height","50px"',
'"",".ui-sortable-placeholder","border",' .
'"4px dashed #828282"',
'"",".ui-layout-resizer","background-color","#dddddd"',
'"",".ui-dialog","box-shadow",' .
'"20px 20px 10px rgba(0, 0, 0, 0.3)"',
'"",".ui-dialog","max-width","100%"',
'"",".no-close .ui-dialog-titlebar-close","display","none"',
'"",".ui-button-text-only .ui-button-text",' .
'"padding","0.1em 0.6em"',
'"",".ui-autocomplete","max-height","300px"',
'"",".ui-autocomplete","max-width","200px"',
'"",".ui-autocomplete","overflow-y","auto"',
'"",".ui-autocomplete","overflow-x","hidden"',
'"",".control .ui-button-icon-only","height","28px"',
'"",".control .ui-button-icon-only","width","28px"',
'"",".ui-tabs","padding","0"',
'"",".ui-tabs-nav li a","padding","0.3em 0.6em"',
'"",".ui-accordion-header a","padding","0.3em"',
'"",".ui-dialog-content","padding","0.5em 0"',
'"",".ui-selectmenu-menu","position","fixed"',
'"",".ui-menu .ui-state-active","font-weight","normal"',
'"",".horizontal-menu:after","clear","both"',
'"",".horizontal-menu:after","content","\".\""',
'"",".horizontal-menu:after","display","block"',
'"",".horizontal-menu:after","height","0"',
'"",".horizontal-menu:after","line-height","0"',
'"",".horizontal-menu:after","visibility","hidden"',
'"",".horizontal-menu > .ui-menu-item","display",' .
'"inline-block"',
'"",".horizontal-menu > .ui-menu-item","float","left"',
'"",".horizontal-menu > .ui-menu-item","margin","0 15px"',
'"",".horizontal-menu > .ui-menu-item","padding","0"',
'"",".horizontal-menu > .ui-menu-item","width","auto"',
'"",".horizontal-menu > .ui-menu-item .ui-icon",' .
'"margin-top","0.3em"',
'"","indie-action","display","none"',
'"","indie-action","white-space","nowrap"',
'"","indie-action .ui-icon","display","inline-block"',
'"","indie-action .ui-icon","height","14px"',
'"","#indie-action-twitter","margin-left","10px"',
'"","#indie-action-facebook","margin-left","10px"',
'"",".indie-config .ui-icon","display","inline-block"',
'"",".indie-config .ui-icon","height","14px"',
'"",".indie-config","white-space","nowrap"',
'"",".indie-config-settings","margin-left","10px"',
'"","#indie-config-ok","float","right"',
'"",".dobrado-mobile","display","none"',
'"' . $media . '",".dobrado-mobile","display","block"'];
$values = '';
foreach ($site_style as $style) {
if ($values !== '') $values .= ',';
$values .= '("admin",' . $style . ')';
}
$query = 'INSERT INTO site_style VALUES ' . $values;
if (!$mysqli->query($query)) {
log_db('start insert site_style: ' . $mysqli->error);
}
$mysqli->close();
}
......@@ -130,10 +130,7 @@ function discover_endpoint($url, $rels) {
// Use SimplePie to cache images.
include_once 'autoloader.php';
$simple_pie = new SimplePie();
$scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== '' ?
'https://' : 'http://';
$image_handler = $scheme . $_SERVER['SERVER_NAME'] . '/php/image.php';
$simple_pie->set_image_handler($image_handler);
$simple_pie->set_image_handler('/php/image.php');
$simple_pie->init();
// Use the url without the scheme for more lenient matching.
$domain = $url;
......@@ -279,10 +276,7 @@ function parse_hcard($author) {
// Use SimplePie to cache images.
include_once 'autoloader.php';
$simple_pie = new SimplePie();
$scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== '' ?
'https://' : 'http://';
$image_handler = $scheme . $_SERVER['SERVER_NAME'] . '/php/image.php';
$simple_pie->set_image_handler($image_handler);
$simple_pie->set_image_handler('/php/image.php');
$simple_pie->init();
$us_photo = $simple_pie->sanitize($us_photo, SIMPLEPIE_CONSTRUCT_IRI,
'', true);
......
......@@ -205,14 +205,28 @@ abstract class Base {
protected function AddTemplate($template) {
$values = '';
// Warning: template must already be escaped here.
// Note: template must already be escaped here.
foreach ($template as $t) {
if ($values !== '') $values .= ',';
$values .= '('.$t.')';
$values .= '(' . $t . ')';
}
$mysqli = connect_db();
if (!$mysqli->query('INSERT INTO template VALUES ' . $values)) {
$this->Log('Base->AddTemplate: ' . $mysqli->error);
}
$mysqli->close();
}
protected function AddTemplateDescription($description) {
$values = '';
// Note: label and description must already be escaped here.
foreach ($description as $label => $content) {
if ($values !== '') $values .= ',';
$values .= '("' . $label . '", "' . $content . '")';
}
$mysqli = connect_db();
if (!$mysqli->query('INSERT INTO template VALUES '.$values)) {
$this->Log('Base->AddTemplate: '.$mysqli->error);
if (!$mysqli->query('INSERT INTO template_description VALUES ' . $values)) {
$this->Log('Base->AddTemplateDescription: ' . $mysqli->error);
}