GetStylesheetOperations(); $db =& $gCms->GetDb(); #****************************************************************************** # global variables definitions #****************************************************************************** # this variable is used to store an eventual error message. $error = ""; #****************************************************************************** # we get the content of the form if there are not empty. #****************************************************************************** # first ; the content of the css $css_text = ""; if (isset($_POST["css_text"])) $css_text = $_POST["css_text"]; # then its name $css_name = ""; if (isset($_POST["css_name"])) $css_name = $_POST["css_name"]; // Now clean up name $css_name = htmlspecialchars($css_name, ENT_QUOTES); $media_type = array(); if (isset($_POST['media_type'])) $media_type = $_POST['media_type']; // media queries $media_query = ''; if (isset($_POST['media_query'])) $media_query = $_POST['media_query']; #****************************************************************************** # if the form was cancelled, we get back to the CSS list #****************************************************************************** if (isset($_POST["cancel"])) { redirect("listcss.php".$urlext); return; } #****************************************************************************** # we now check that user has access to add CSS #****************************************************************************** $userid = get_userid(); $access = check_permission($userid, 'Add Stylesheets'); if ($access) { #****************************************************************************** # if the var "addcss" is set, this means that the form has been submitted. # we check if params are valid #****************************************************************************** if (isset($_POST["addcss"])) { # used to check if we will save the form or not $validinfo = true; # if no CSS name was given if ("" == $css_name) { $error .= "
  • ".lang('nofieldgiven', array(lang('name')))."
  • "; $validinfo = false; } # the CSS has a name, we check if it already exists or not else { $query = "SELECT css_id from ".cms_db_prefix()."css WHERE css_name = " . $db->qstr($css_name); $result = $db->Execute($query); if ($result && $result->RecordCount() > 0) { $error .= "
  • ".lang('cssalreadyused')."
  • "; $validinfo = false; } } # now checking the content of the CSS if ("" == $css_text) { $error .= "
  • ".lang('nofieldgiven', array(lang('content')))."
  • "; $validinfo = false; } #****************************************************************************** # everythings seems to be ok, we can try to save the form #****************************************************************************** if ($validinfo) { $newstylesheet = new Stylesheet(); $newstylesheet->name = $css_name; $newstylesheet->value = $css_text; $types = ""; #generate comma separated list foreach ($media_type as $onetype) { $types .= "$onetype, "; } if ($types!='') { $types = substr($types, 0, -2); #strip last space and comma } else { $types=''; } $newstylesheet->media_type = $types; $newstylesheet->media_query = $media_query; Events::SendEvent('Core', 'AddStylesheetPre', array('stylesheet' => &$newstylesheet)); $result = $newstylesheet->Save(); # we now have to check that everything went well if ($result) { #Sent the post event Events::SendEvent('Core', 'AddStylesheetPost', array('stylesheet' => &$newstylesheet)); # it's ok, we record the operation in the admin log audit($newstylesheet->id, 'Stylesheet: '.$css_name, 'Added'); # and goes back to the css list redirect("listcss.php".$urlext); return; } else { $error .= "
  • ".lang('errorinsertingcss')."
  • "; } } } } include_once("header.php"); #****************************************************************************** # the user does not have access : error message #****************************************************************************** if (!$access) { echo "

    ".lang('noaccessto', array(lang('addstylesheet')))."

    "; } #****************************************************************************** # the user has access, we display the form #****************************************************************************** else { # the user has correct rights, we display error message if any if ("" != $error) { echo "
    "; } #****************************************************************************** # we now display the content of the form, in HTML #****************************************************************************** ?>
    ShowHeader('addstylesheet'); ?>

    *:

    *:

    :

    :

    \n"; $types .= "Media type\n"; $i = 0; foreach ($existingtypes as $onetype) { $i++; $types .= ''. lang("mediatype_".$onetype) ."\n
    "; } $types .= ""; echo $types; ?>

     

    « '.lang('back').'

    '; } # end of displaying the form include_once("footer.php"); # vim:ts=4 sw=4 noet ?>