Commit 916e07c7 authored by rjsmelo's avatar rjsmelo

[REF] Reformat code

parent a5cad7d5
......@@ -8,20 +8,20 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
$section_class="tiki_wiki_page print";
require_once ('tiki-setup.php');
$section_class = "tiki_wiki_page print";
require_once('tiki-setup.php');
$wikilib = TikiLib::lib('wiki');
$auto_query_args = array('page');
$auto_query_args = ['page'];
$access->check_feature(array('feature_wiki', 'feature_wiki_print'));
$access->check_feature(['feature_wiki', 'feature_wiki_print']);
// Create the HomePage if it doesn't exist
if (!$tikilib->page_exists($prefs['wikiHomePage'])) {
if (! $tikilib->page_exists($prefs['wikiHomePage'])) {
$tikilib->create_page($prefs['wikiHomePage'], 0, '', $tikilib->now, 'Tiki initialization');
}
// Get the page from the request var or default it to HomePage
if (!isset($_REQUEST["page"])) {
if (! isset($_REQUEST["page"])) {
$page = $prefs['wikiHomePage'];
$smarty->assign('page', $prefs['wikiHomePage']);
} else {
......@@ -29,7 +29,7 @@ if (!isset($_REQUEST["page"])) {
$smarty->assign_by_ref('page', $_REQUEST["page"]);
}
// If the page doesn't exist then display an error
if (!($info = $tikilib->get_page_info($page))) {
if (! ($info = $tikilib->get_page_info($page))) {
$smarty->assign('msg', tra('Page cannot be found'));
$smarty->display('error.tpl');
die;
......@@ -75,18 +75,18 @@ if ($prefs['feature_wiki_structure'] == 'y') {
$structure = 'y';
$structure_path = $structlib->get_structure_path($page_ref_id);
$smarty->assign('structure_path', $structure_path);
if (!empty($page_info['page_alias'])) {
if (! empty($page_info['page_alias'])) {
$crumbpage = $page_info['page_alias'];
} else {
$crumbpage = $page;
}
}
}
$pdata = TikiLib::lib('parser')->parse_data($info["data"], array('is_html' => $info["is_html"], 'print' => 'y', 'namespace' => $info["namespace"]));
$pdata = TikiLib::lib('parser')->parse_data($info["data"], ['is_html' => $info["is_html"], 'print' => 'y', 'namespace' => $info["namespace"]]);
//replacing bootstrap classes for print version.
$pdata=str_replace(array('col-sm','col-md','col-lg'),'col-xs',$pdata);
$pdata = str_replace(['col-sm','col-md','col-lg'], 'col-xs', $pdata);
$smarty->assign_by_ref('parsed', $pdata);
$smarty->assign_by_ref('lastModif', $info["lastModif"]);
......@@ -95,7 +95,7 @@ if (empty($info["user"])) {
}
$smarty->assign_by_ref('lastVersion', $info["version"]);
$smarty->assign_by_ref('lastUser', $info["user"]);
$crumbs[] = new Breadcrumb(isset($crumbpage)?$crumbpage:$page, $info["description"], 'tiki-index.php?page=' . urlencode($page), '', '');
$crumbs[] = new Breadcrumb(isset($crumbpage) ? $crumbpage : $page, $info["description"], 'tiki-index.php?page=' . urlencode($page), '', '');
ask_ticket('print');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
......@@ -110,19 +110,19 @@ $smarty->assign('display', isset($_REQUEST['display']) ? $_REQUEST['display'] :
if (isset($_REQUEST['display']) && $_REQUEST['display'] == 'pdf') {
require_once 'lib/pdflib.php';
$generator = new PdfGenerator();
if (!empty($generator->error)) {
if (! empty($generator->error)) {
Feedback::error($generator->error, 'session');
$access->redirect($page);
} else {
$pdf = $generator->getPdf('tiki-print.php', array('page' => $page),$pdata);
$pdf = $generator->getPdf('tiki-print.php', ['page' => $page], $pdata);
$length = strlen($pdf);
header('Cache-Control: private, must-revalidate');
header('Pragma: private');
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename="'. TikiLib::lib('tiki')->remove_non_word_characters_and_accents($page) . '.pdf"');
header('Content-disposition: attachment; filename="' . TikiLib::lib('tiki')->remove_non_word_characters_and_accents($page) . '.pdf"');
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. $length);
header('Content-Length: ' . $length);
echo $pdf;
}
} else {
......
......@@ -9,10 +9,10 @@
// $Id$
$section = 'cms';
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$artlib = TikiLib::lib('art');
$access->check_feature('feature_cms_print');
if (!isset($_REQUEST["articleId"])) {
if (! isset($_REQUEST["articleId"])) {
$smarty->assign('msg', tra("No article indicated"));
$smarty->display("error.tpl");
die;
......@@ -23,13 +23,15 @@ $parserlib = TikiLib::lib('parser');
$article_data = $artlib->get_article($_REQUEST["articleId"]);
$tikilib->get_perm_object($_REQUEST['articleId'], 'article');
if ($article_data === false) {
if (!$user) $_SESSION['loginfrom'] = $_SERVER['REQUEST_URI'];
if (! $user) {
$_SESSION['loginfrom'] = $_SERVER['REQUEST_URI'];
}
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra('Permission denied'));
$smarty->display('error.tpl');
die;
}
if (!$article_data) {
if (! $article_data) {
$smarty->assign('msg', tra("Article not found"));
$smarty->display("error.tpl");
die;
......@@ -46,7 +48,7 @@ if ($article_data['ispublished'] == 'n' && $tiki_p_edit_article != 'y') {
die;
}
if (isset($_REQUEST['switchlang']) && $_REQUEST['switchlang'] == 'y' && $prefs['feature_multilingual'] == 'y' && $prefs['feature_sync_language'] == 'y' && !empty($article_data["lang"]) && $prefs['language'] != $article_data["lang"]) {
if (isset($_REQUEST['switchlang']) && $_REQUEST['switchlang'] == 'y' && $prefs['feature_multilingual'] == 'y' && $prefs['feature_sync_language'] == 'y' && ! empty($article_data["lang"]) && $prefs['language'] != $article_data["lang"]) {
header('Location: tiki-switch_lang.php?language=' . $article_data['lang']);
die;
}
......@@ -101,14 +103,16 @@ if ($article_data['image_x'] > 0) {
} else {
require_once('lib/images/images.php');
$img = new Image($article_data['image_x'], false);
$smarty->assign('width', $img->get_width()+2);
$smarty->assign('width', $img->get_width() + 2);
}
$smarty->assign('heading', $article_data["heading"]);
if ( $prefs['article_paginate'] == 'y' ) {
if (!isset($_REQUEST['page'])) $_REQUEST['page'] = 1;
if ($prefs['article_paginate'] == 'y') {
if (! isset($_REQUEST['page'])) {
$_REQUEST['page'] = 1;
}
// Get ~pp~, ~np~ and <pre> out of the way. --rlpowell, 24 May 2004
$preparsed = array();
$noparsed = array();
$preparsed = [];
$noparsed = [];
$parserlib->plugins_remove($article_data["body"], $noparsed);
$parserlib->parse_first($article_data["body"], $preparsed, $noparsed);
......@@ -134,7 +138,7 @@ if ( $prefs['article_paginate'] == 'y' ) {
if ($prefs["article_custom_attributes"] == 'y') {
$t_article_attributes = $artlib->get_article_attributes($article_data["articleId"]);
$type_attributes = $artlib->get_article_type_attributes($article_data["type"], 'relationId ASC');
$article_attributes = array();
$article_attributes = [];
foreach ($type_attributes as $attname => $att) {
if (in_array($att["itemId"], array_keys($t_article_attributes))) {
$article_attributes[$attname] = $t_article_attributes[$att["itemId"]];
......@@ -142,7 +146,7 @@ if ($prefs["article_custom_attributes"] == 'y') {
}
$smarty->assign('article_attributes', $article_attributes);
} else {
$smarty->assign('article_attributes', array());
$smarty->assign('article_attributes', []);
}
$smarty->assign('body', $article_data["body"]);
$smarty->assign('publishDate', $article_data["publishDate"]);
......@@ -156,27 +160,27 @@ $heading = $article_data["heading"];
// We need to figure out in which theme we are before the page parsing
// in case the page contains pluginModule in which cas the parser triggers tiki-modules.php
// which needs $tc_theme for deciding on the visible modules everywhere in the page
include_once ('tiki-section_options.php');
include_once('tiki-section_options.php');
if ($prefs['feature_theme_control'] == 'y') {
$cat_type = 'article';
$cat_objid = $_REQUEST["articleId"];
include ('tiki-tc.php');
include('tiki-tc.php');
}
$smarty->assign('parsed_body', $parserlib->parse_data($body, array('is_html' => $artlib->is_html($article_data))));
$smarty->assign('parsed_body', $parserlib->parse_data($body, ['is_html' => $artlib->is_html($article_data)]));
$smarty->assign(
'parsed_heading',
$parserlib->parse_data(
$heading,
array(
[
'min_one_paragraph' => true,
'is_html' => $artlib->is_html($article_data, true),
)
]
)
);
if ($prefs['article_related_articles'] == 'y') {
$article_data['related_articles'] = $artlib->get_related_articles($article_data['articleId']);
if (isset($article_data['related_articles']) && !empty($article_data['related_articles'])) {
if (isset($article_data['related_articles']) && ! empty($article_data['related_articles'])) {
$smarty->assign('related_articles', $article_data['related_articles']);
}
}
......@@ -209,7 +213,7 @@ if (isset($is_categorized) && $is_categorized) {
}
if ($prefs['feature_categories'] == 'y' && $prefs['category_morelikethis_algorithm'] != '') {
$freetaglib = TikiLib::lib('freetag');
$category_related_objects = $freetaglib->get_similar('article', $_REQUEST['articleId'], empty($prefs['category_morelikethis_mincommon_max'])? $prefs['maxRecords']: $prefs['category_morelikethis_mincommon_max'], null, 'category');
$category_related_objects = $freetaglib->get_similar('article', $_REQUEST['articleId'], empty($prefs['category_morelikethis_mincommon_max']) ? $prefs['maxRecords'] : $prefs['category_morelikethis_mincommon_max'], null, 'category');
$smarty->assign_by_ref('category_related_objects', $category_related_objects);
}
} else {
......
......@@ -6,11 +6,11 @@
// $Id$
$section = 'blogs';
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$bloglib = TikiLib::lib('blog');
$access->check_feature('feature_blogs');
if (!isset($_REQUEST["postId"])) {
if (! isset($_REQUEST["postId"])) {
$smarty->assign('msg', tra("No post indicated"));
$smarty->display("error.tpl");
die;
......@@ -26,13 +26,13 @@ $access->check_permission('tiki_p_read_blog', '', 'blog', $blogId);
$blog_data = $bloglib->get_blog($blogId);
if (!$blog_data) {
if (! $blog_data) {
$smarty->assign('msg', tra("Blog not found"));
$smarty->display("error.tpl");
die;
}
$parsed_data = TikiLib::lib('parser')->parse_data($post_info["data"], array('is_html' => true));
$parsed_data = TikiLib::lib('parser')->parse_data($post_info["data"], ['is_html' => true]);
$parsed_data = preg_replace('/\.\.\.page\.\.\./', '<hr />', $parsed_data);
$smarty->assign('blog_data', $blog_data);
......
This diff is collapsed.
......@@ -3,17 +3,17 @@
* @package tikiwiki
*/
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$structlib = TikiLib::lib('struct');
$access->check_feature('feature_wiki_multiprint');
if (!isset($_REQUEST['printpages']) && !isset($_REQUEST['printstructures'])) {
if (! isset($_REQUEST['printpages']) && ! isset($_REQUEST['printstructures'])) {
$smarty->assign('msg', tra("No pages indicated"));
$smarty->display("error.tpl");
die;
......@@ -21,27 +21,27 @@ if (!isset($_REQUEST['printpages']) && !isset($_REQUEST['printstructures'])) {
if (isset($_REQUEST['printpages'])) {
$printpages = json_decode(urldecode($_REQUEST['printpages']));
} else {
$printpages = array();
$printpages = [];
}
if (isset($_REQUEST['printstructures'])) {
$printstructures = json_decode(urldecode($_REQUEST['printstructures']));
} else {
$printstructures = array();
$printstructures = [];
}
}
if (isset($_REQUEST["print"]) || isset($_REQUEST["display"])) {
check_ticket('multiprint');
// Create XMLRPC object
$pages = array();
$pages = [];
foreach ($printpages as $page) {
// If the page doesn't exist then display an error
if (!$tikilib->page_exists($page)) {
if (! $tikilib->page_exists($page)) {
$smarty->assign('msg', tra("Page cannot be found"));
$smarty->display("error.tpl");
die;
}
// Now check permissions to access this page
if (!$tikilib->user_has_perm_on_object($user, $page, 'wiki page', 'tiki_p_view')) {
if (! $tikilib->user_has_perm_on_object($user, $page, 'wiki page', 'tiki_p_view')) {
$smarty->assign('errortype', 401);
$smarty->assign('msg', tra("You do not have permission to view this page."));
$smarty->display("error.tpl");
......@@ -58,12 +58,12 @@ if (isset($_REQUEST["print"]) || isset($_REQUEST["display"])) {
continue;
}
$page_info = $tikilib->get_page_print_info($struct_page['pageName']);
// Use the alias as the display name, if an alias is defined
if ( isset($struct_page['page_alias']) ) {
if (isset($struct_page['page_alias'])) {
$page_info['pageName'] = $struct_page['page_alias'];
}
$page_info['pos'] = $struct_page['pos'];
$page_info['h'] = empty($struct_page['pos']) ? 0 : count(explode('.', $struct_page['pos']));
$h = $page_info['h'] + 5;
......@@ -92,21 +92,21 @@ ask_ticket('multiprint');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
$smarty->assign('print_page', 'y');
if (isset($_REQUEST['display'])) $smarty->assign('display', $_REQUEST['display']);
if (isset($_REQUEST['display'])) {
$smarty->assign('display', $_REQUEST['display']);
}
// Allow PDF export by installing a Mod that define an appropriate function
if (isset($_REQUEST['display']) && $_REQUEST['display'] == 'pdf') {
require_once 'lib/pdflib.php';
$generator = new PdfGenerator();
$pdf = $pdfname = '';
if (!empty($printpages)) {
$pdf = $generator->getPdf('tiki-print_multi_pages.php', array('print' => 'print', 'printpages' => $printpages, 'pages' => $pages));
if (! empty($printpages)) {
$pdf = $generator->getPdf('tiki-print_multi_pages.php', ['print' => 'print', 'printpages' => $printpages, 'pages' => $pages]);
$pdfname = implode(', ', $printpages);
} else if (!empty($printstructures)) {
$pdf = $generator->getPdf('tiki-print_multi_pages.php', array('print' => 'print', 'printstructures' => $printstructures, 'pages' => $pages ));
} elseif (! empty($printstructures)) {
$pdf = $generator->getPdf('tiki-print_multi_pages.php', ['print' => 'print', 'printstructures' => $printstructures, 'pages' => $pages ]);
$pdfname = implode(', ', $printstructures);
} else {
$smarty->display("tiki-print_multi_pages.tpl");
die;
......@@ -116,20 +116,19 @@ if (isset($_REQUEST['display']) && $_REQUEST['display'] == 'pdf') {
header('Cache-Control: private, must-revalidate');
header('Pragma: private');
header("Content-Description: File Transfer");
header('Content-disposition: attachment; filename="'. $pdfname . '.pdf"');
header('Content-disposition: attachment; filename="' . $pdfname . '.pdf"');
header("Content-Type: application/pdf");
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. strlen($pdf));
header('Content-Length: ' . strlen($pdf));
echo $pdf;
} else {
Feedback::error($generator->error, 'session');
$tab = '';
if (strpos($_SERVER['HTTP_REFERER'], 'tiki-print_pages.php') !== false && !empty($printpages)) {
if (strpos($_SERVER['HTTP_REFERER'], 'tiki-print_pages.php') !== false && ! empty($printpages)) {
$tab = '#contenttabs_print_pages-2';
}
$access->redirect($_SERVER['HTTP_REFERER'] . $tab);
}
} else {
$smarty->display("tiki-print_multi_pages.tpl");
}
......@@ -3,28 +3,28 @@
* @package tikiwiki
*/
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
$section = 'wiki page';
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$structlib = TikiLib::lib('struct');
$auto_query_args = array('page_ref_id', 'page', 'find', 'pageName', 'structureId', 'offset', 'printpages', 'printstructures');
$auto_query_args = ['page_ref_id', 'page', 'find', 'pageName', 'structureId', 'offset', 'printpages', 'printstructures'];
$access->check_feature('feature_wiki_multiprint');
$access->check_permission('tiki_p_view');
//get_strings tra('Multiple Print');
if (!isset($cookietab)) {
if (! isset($cookietab)) {
$cookietab = '1';
}
if (!isset($_REQUEST['printpages']) && !isset($_REQUEST['printstructures'])) {
$printpages = array();
$printstructures = array();
if (! isset($_REQUEST['printpages']) && ! isset($_REQUEST['printstructures'])) {
$printpages = [];
$printstructures = [];
if (isset($_REQUEST["page_ref_id"])) {
$info = $structlib->s_get_page_info($_REQUEST['page_ref_id']);
if (!empty($info)) {
if (! empty($info)) {
$printstructures[] = $_REQUEST['page_ref_id'];
}
} elseif (isset($_REQUEST["page"]) && $tikilib->page_exists($_REQUEST["page"])) {
......@@ -41,7 +41,7 @@ if (isset($_REQUEST["find"])) {
}
$smarty->assign('find', $find);
if (isset($_REQUEST["addpage"])) {
if (!in_array($_REQUEST["pageName"], $printpages)) {
if (! in_array($_REQUEST["pageName"], $printpages)) {
foreach ($_REQUEST['pageName'] as $value) {
$printpages[] = $value;
}
......@@ -49,31 +49,33 @@ if (isset($_REQUEST["addpage"])) {
$cookietab = 2;
}
if (isset($_REQUEST["removepage"])) {
foreach ($_REQUEST['selectedpages'] as $value) {
unset($printpages[$value]);
}
foreach ($_REQUEST['selectedpages'] as $value) {
unset($printpages[$value]);
}
$printpages = array_merge($printpages);
$cookietab = 2;
}
if (isset($_REQUEST["clearpages"])) {
$printpages = array();
$printpages = [];
$cookietab = 2;
}
if (isset($_REQUEST["clearstructures"])) {
$printstructures = array();
$printstructures = [];
}
if (isset($_REQUEST['addstructurepages'])) {
$struct = $structlib->get_subtree($_REQUEST["structureId"]);
foreach ($struct as $struct_page) {
// Handle dummy last entry
if ($struct_page["pos"] != '' && $struct_page["last"] == 1) continue;
if ($struct_page["pos"] != '' && $struct_page["last"] == 1) {
continue;
}
$printpages[] = $struct_page["pageName"];
}
$cookietab = 2;
}
if (isset($_REQUEST['addstructure'])) {
$info = $structlib->s_get_page_info($_REQUEST['structureId']);
if (!empty($info)) {
if (! empty($info)) {
$printstructures[] = $_REQUEST['structureId'];
}
}
......@@ -97,7 +99,7 @@ foreach ($printstructures as $page_ref_id) {
}
$smarty->assign_by_ref('printnamestructures', $printnamestructures);
include_once ('tiki-section_options.php');
include_once('tiki-section_options.php');
ask_ticket('print-pages');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
......
<?php
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$access->check_feature('feature_stats');
$access->check_permission('tiki_p_view_stats');
require_once ("lib/graph-engine/gd.php");
require_once ("lib/graph-engine/graph.multiline.php");
require_once("lib/graph-engine/gd.php");
require_once("lib/graph-engine/graph.multiline.php");
//Define the object
$renderer = new GD_GRenderer(450, 300);
$graph = new MultilineGraphic;
$graph->setTitle(tra('Pageviews'));
//Set some data
if (!isset($_REQUEST["days"])) $_REQUEST["days"] = 7;
if (! isset($_REQUEST["days"])) {
$_REQUEST["days"] = 7;
}
$statslib = TikiLib::lib('stats');
$data = $statslib->get_pv_chart_data($_REQUEST["days"]);
......@@ -24,7 +26,7 @@ $data = $statslib->get_pv_chart_data($_REQUEST["days"]);
foreach ($data['xdata'] as $key => $date) {
$data['xdata'][$key] = strtotime($date) / 24 / 3600;
}
$graph->setData(array('x' => $data['xdata'], 'y0' => $data['ydata']));
$graph->setData(['x' => $data['xdata'], 'y0' => $data['ydata']]);
$graph->setParam('grid-independant-major-font', false);
$graph->setParam('grid-independant-major-guide', false);
$graph->draw($renderer);
......
<?php
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$access->check_feature('feature_quizzes');
......
......@@ -25,7 +25,7 @@ It is supposed to use 10 questions for this quiz from the tiki_quiz_questions ta
If you leave the data field blank, the default is to use all the questions from the table.
You can also set the same option under the Generl Options section.
*/
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$access->check_feature('feature_quizzes');
//Use 12- or 24-hour clock for $publishDate time selector based on admin and user preferences
......@@ -35,7 +35,7 @@ $smarty->assign('use_24hr_clock', $userprefslib->get_user_clock_pref($user));
// quizId of 0 is used as a placeholder; There should NEVER be a row in the
// tiki_quizzes table with an id of zero.
if (!isset($_REQUEST["quizId"])) {
if (! isset($_REQUEST["quizId"])) {
$_REQUEST["quizId"] = 0;
}
......@@ -45,7 +45,7 @@ $access->check_permission('tiki_p_admin_quizzes');
$cat_type = 'quiz';
$cat_objid = $_REQUEST["quizId"];
include_once ("categorize_list.php");
include_once("categorize_list.php");
if (isset($_REQUEST["preview"]) || isset($_REQUEST["xmlview"]) || isset($_REQUEST["textview"])) {
echo "line: " . __LINE__ . "<br>";
echo "Sorry, preview, xmlview and textview are not supported in this version.<br>";
......@@ -74,7 +74,7 @@ function fetchYNOption(&$quiz, $request, $option)
function quiz_data_load()
{
global $_REQUEST;
$quiz_data = array();
$quiz_data = [];
foreach ($_REQUEST as $key => $val) {
if (preg_match("/^quiz_/", $key)) {
$k = preg_replace("/^quiz_([.]*)/", "\$1", $key);
......@@ -83,14 +83,14 @@ function quiz_data_load()
}
if ($quiz_data["online"] == "online") {
$quiz_data["online"] = "y";
} else if ($quiz_data["online"] == "offline") {
} elseif ($quiz_data["online"] == "offline") {
$quiz_data["online"] = "n";
}
//Convert 12-hour clock hours to 24-hour scale to compute time
if (!empty($_REQUEST['publish_Meridian'])) {
if (! empty($_REQUEST['publish_Meridian'])) {
$_REQUEST['publish_Hour'] = date('H', strtotime($_REQUEST['publish_Hour'] . ':00 ' . $_REQUEST['publish_Meridian']));
}
if (!empty($_REQUEST['expire_Meridian'])) {
if (! empty($_REQUEST['expire_Meridian'])) {
$_REQUEST['expire_Hour'] = date('H', strtotime($_REQUEST['expire_Hour'] . ':00 ' . $_REQUEST['expire_Meridian']));
}
......@@ -110,7 +110,7 @@ function quiz_data_load()
$quiz_data["expire_Day"],
$quiz_data["expire_Year"]
);
$fields = array('nQuestion'
$fields = ['nQuestion'
, 'shuffleAnswers'
, 'shuffleQuestions'
, 'multiSession'
......@@ -120,10 +120,9 @@ function quiz_data_load()
, 'canRepeat'
, 'additionalQuestions'
, 'forum'
);
];
foreach ($fields as $field) {
fetchYNOption($quiz_data, $quiz_data, $field);
}
return $quiz_data;
}
......@@ -138,7 +137,6 @@ if (isset($_REQUEST["save"])) {
if ($quiz->id == 0 || ($quizNew != $quiz)) {
$quizlib->quiz_store($quizNew);
// tell user changes were stored (new quiz stored with id of x or quiz x modified), return to list of admin quizzes
}
die;
echo "line: " . __LINE__ . "<br>";
......@@ -148,7 +146,7 @@ if (isset($_REQUEST["save"])) {
$cat_href = "tiki-quiz.php?quizId=" . $cat_objid;
$cat_name = $_REQUEST["name"];
$cat_desc = substr($_REQUEST["description"], 0, 200);
include_once ("categorize.php");
include_once("categorize.php");
}
die;
}
......@@ -161,25 +159,25 @@ $smarty->assign('quiz', $quiz);
function setup_options(&$tpl)
{
global $prefs;
$tpl['online_choices'] = array('online' => 'Online', 'offline' => 'Offline');
$optionsGrading = array();
$tpl['online_choices'] = ['online' => 'Online', 'offline' => 'Offline'];
$optionsGrading = [];
$optionsGrading[] = "machine";
$optionsGrading[] = "peer review";
$optionsGrading[] = "teacher";
$tpl['optionsGrading'] = $optionsGrading;
$optionsShowScore = array();
$optionsShowScore = [];
$optionsShowScore[] = "immediately";
$optionsShowScore[] = "after expire date";
$optionsShowScore[] = "never";
$tpl['optionsShowScore'] = $optionsShowScore;
// FIXME - This needs to be limited to the session timeout in php.ini
$mins = array();
$mins = [];
for ($i = 1; $i <= 20; $i++) {
$mins[] = $i;
}
$tpl['mins'] = $mins;
$repetitions = array();
$qpp = array();
$repetitions = [];
$qpp = [];
for ($i = 1; $i <= 10; $i++) {
$qpp[] = $i;
$repetitions[] = $i;
......@@ -191,7 +189,7 @@ function setup_options(&$tpl)
$tpl['siteTimeZone'] = $prefs['display_timezone'];
}
$tpl = array();
$tpl = [];
setup_options($tpl);
$smarty->assign('tpl', $tpl);
ask_ticket('edit-quiz-question');
......
......@@ -3,16 +3,16 @@
* @package tikiwiki
*/
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
$section = 'quizzes';
require_once ('tiki-setup.php');
require_once('tiki-setup.php');
$quizlib = TikiLib::lib('quiz');
$access->check_feature('feature_quizzes');
if (!isset($_REQUEST["quizId"])) {
if (! isset($_REQUEST["quizId"])) {
$smarty->assign('msg', tra("No quiz indicated"));
$smarty->display("error.tpl");
die;
......@@ -24,13 +24,13 @@ $access->check_permission('tiki_p_view_user_results');
$smarty->assign('quizId', $_REQUEST["quizId"]);
$quiz_info = $quizlib->get_quiz($_REQUEST["quizId"]);
$smarty->assign('quiz_info', $quiz_info);
if (!isset($_REQUEST["resultId"])) {