require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Extension/Asset.php'; require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Extension/URI.php'; /************************************* * Init Plates Tpl Engine */ $platesTpl = new League\Plates\Engine(GSPLUGINPATH . OGM_SUB_FOLDER . '/templates'); /************************************* * Register Tpl Helper Function */ $platesTpl->registerFunction('imageExists', function ($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($code == 200) { $status = true; } else { $status = false; } curl_close($ch); return $status; }); /************************************* * Load saved data */ $params = array(); if (file_exists(GSDATAOTHERPATH . OGM_SETTINGS_FILE)) { $data = getXML(GSDATAOTHERPATH . OGM_SETTINGS_FILE); if ($data) { foreach ($data->children() as $child) { if (!array_key_exists($child->getName(), $params)) {
require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Template/Functions.php'; require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Template/Name.php'; require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Template/Template.php'; require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Extension/ExtensionInterface.php'; require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Extension/Asset.php'; require_once GSPLUGINPATH . OGM_SUB_FOLDER . '/plates/Extension/URI.php'; /************************************* * Init Plates Tpl Engine */ $platesTpl = new League\Plates\Engine(GSPLUGINPATH . OGM_SUB_FOLDER . '/templates'); /************************************* * Register Tpl Helper Function */ $platesTpl->registerFunction('isTab', function ($string) { if (@$_POST['tab'] == $string) { return true; } return false; }); /************************************* * Get & save data */ $params = $_REQUEST; $allowedXmlVars = array("general_author", "general_publisher", "general_image_path", "twitter_site", "twitter_creator", "facebook_page_id", "facebook_admins"); foreach ($params as $key => $value) { if (!in_array($key, $allowedXmlVars)) { unset($params[$key]); } } if (file_exists(GSDATAOTHERPATH . OGM_SETTINGS_FILE)) { $data = getXML(GSDATAOTHERPATH . OGM_SETTINGS_FILE); if ($data) {
* it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; If not, see <http://www.gnu.org/licenses/>. */ require __DIR__ . '/install_lang.php'; require __DIR__ . '/../vendor/autoload.php'; $template = new \League\Plates\Engine(__DIR__ . '/../templates/builtin/html'); $template->registerFunction('_', 'lng'); error_reporting(0); // E_ERROR | E_WARNING | E_PARSE function create_tables(PDO $pdo, $delete_existing) { static $migrations = []; if (empty($migrations)) { $migrations[] = (include 'updates/ThWboardMigration.0.php'); $migrations[] = (include 'updates/ThWboardMigration.1.php'); $migrations[] = (include 'updates/ThWboardMigration.2.php'); $migrations[] = (include 'updates/ThWboardMigration.3.php'); $migrations[] = (include 'updates/ThWboardMigration.4.php'); $migrations[] = (include 'updates/ThWboardMigration.5.php'); } if ($delete_existing) { foreach (array_reverse($migrations) as $migration) {
if ($c['themes']->has($themeName = $c['config']->get('theme'))) { return $c['themes']->read($themeName); } else { throw new Exception('Theme `' . $themeName . '` does not exists'); } }; $app['view'] = function (Container $c) { $theme = $c['theme']; $config = $c['config']; // Create new Plates instance to render theme files $path = $theme->getPath(); $view = new League\Plates\Engine($path, $theme->getExtension()); // Helper function // List pages $view->registerFunction('listPages', function ($pages, $options) { return listPagesAndChildren(listPagesRoot($pages), $options); }); // System date format $view->registerFunction('dateFormat', function (DateTime $date) use($config) { return $date->format($config->get('dateFormat')); }); // System date format $view->registerFunction('pageDateFormat', function (Parvula\Models\Page $page) use($config) { return $page->getDateTime()->format($config->get('dateFormat')); }); // Excerpt strings $view->registerFunction('excerpt', function ($text, $length = 275) { $text = strip_tags($text); $excerpt = substr($text, 0, $length); if ($excerpt !== $text) { $lastDot = strrpos($excerpt, '. ');