/** * Saves the typed content item */ function save($option, $task) { global $database, $my, $mosConfig_offset; josSpoofCheck(); $nullDate = $database->getNullDate(); $menu = strval(mosGetParam($_POST, 'menu', 'mainmenu')); $menuid = intval(mosGetParam($_POST, 'menuid', 0)); $row = new mosContent($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if ($row->id) { $row->modified = date('Y-m-d H:i:s'); $row->modified_by = $my->id; } $row->created_by = $row->created_by ? $row->created_by : $my->id; if ($row->created && strlen(trim($row->created)) <= 10) { $row->created .= ' 00:00:00'; } $row->created = $row->created ? mosFormatDate($row->created, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset) : date('Y-m-d H:i:s'); if (strlen(trim($row->publish_up)) <= 10) { $row->publish_up .= ' 00:00:00'; } $row->publish_up = mosFormatDate($row->publish_up, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset); if (trim($row->publish_down) == 'Never' || trim($row->publish_down) == '') { $row->publish_down = $nullDate; } else { if (strlen(trim($row->publish_down)) <= 10) { $row->publish_down .= ' 00:00:00'; } $row->publish_down = mosFormatDate($row->publish_down, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset); } $row->state = intval(mosGetParam($_REQUEST, 'published', 0)); // Save Parameters $params = mosGetParam($_POST, 'params', ''); if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { $txt[] = "{$k}={$v}"; } $row->attribs = implode("\n", $txt); } // code cleaner for xhtml transitional compliance $row->introtext = str_replace('<br>', '<br />', $row->introtext); $row->title = ampReplace($row->title); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->checkin(); // clean any existing cache files mosCache::cleanCache('com_content'); switch ($task) { case 'go2menu': mosRedirect('index2.php?option=com_menus&menutype=' . $menu); break; case 'go2menuitem': mosRedirect('index2.php?option=com_menus&menutype=' . $menu . '&task=edit&hidemainmenu=1&id=' . $menuid); break; case 'menulink': menuLink($option, $row->id); break; case 'resethits': resethits($option, $row->id); break; case 'save': $msg = 'Typed Content Item saved'; mosRedirect('index2.php?option=' . $option, $msg); break; case 'apply': default: $msg = 'Changes to Typed Content Item saved'; mosRedirect('index2.php?option=' . $option . '&task=edit&hidemainmenu=1&id=' . $row->id, $msg); break; } }
/** * Saves the content item an edit form submit * @param database A database connector object */ function saveContent($sectionid, $task) { global $database, $my, $mainframe, $mosConfig_offset; josSpoofCheck(); $menu = strval(mosGetParam($_POST, 'menu', 'mainmenu')); $menuid = intval(mosGetParam($_POST, 'menuid', 0)); $nullDate = $database->getNullDate(); $row = new mosContent($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // sanitise id field $row->id = (int) $row->id; if ($row->id) { $row->modified = date('Y-m-d H:i:s'); $row->modified_by = $my->id; } $row->created_by = $row->created_by ? $row->created_by : $my->id; if ($row->created && strlen(trim($row->created)) <= 10) { $row->created .= ' 00:00:00'; } $row->created = $row->created ? mosFormatDate($row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset) : date('Y-m-d H:i:s'); if (strlen(trim($row->publish_up)) <= 10) { $row->publish_up .= ' 00:00:00'; } $row->publish_up = mosFormatDate($row->publish_up, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset); if (trim($row->publish_down) == 'Never' || trim($row->publish_down) == '') { $row->publish_down = $nullDate; } else { if (strlen(trim($row->publish_down)) <= 10) { $row->publish_down .= ' 00:00:00'; } $row->publish_down = mosFormatDate($row->publish_down, _CURRENT_SERVER_TIME_FORMAT, -$mosConfig_offset); } $row->state = intval(mosGetParam($_REQUEST, 'published', 0)); $params = mosGetParam($_POST, 'params', ''); if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { if (get_magic_quotes_gpc()) { $v = stripslashes($v); } $txt[] = "{$k}={$v}"; } $row->attribs = implode("\n", $txt); } // code cleaner for xhtml transitional compliance $row->introtext = str_replace('<br>', '<br />', $row->introtext); $row->fulltext = str_replace('<br>', '<br />', $row->fulltext); // remove <br /> take being automatically added to empty fulltext $length = strlen($row->fulltext) < 9; $search = strstr($row->fulltext, '<br />'); if ($length && $search) { $row->fulltext = NULL; } $row->title = ampReplace($row->title); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->version++; if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // manage frontpage items require_once $mainframe->getPath('class', 'com_frontpage'); $fp = new mosFrontPage($database); if (intval(mosGetParam($_REQUEST, 'frontpage', 0))) { // toggles go to first place if (!$fp->load((int) $row->id)) { // new entry $query = "INSERT INTO #__content_frontpage" . "\n VALUES ( " . (int) $row->id . ", 1 )"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->stderr() . "');</script>\n"; exit; } $fp->ordering = 1; } } else { // no frontpage mask if (!$fp->delete((int) $row->id)) { $msg .= $fp->stderr(); } $fp->ordering = 0; } $fp->updateOrder(); $row->checkin(); $row->updateOrder("catid = " . (int) $row->catid . " AND state >= 0"); // clean any existing cache files mosCache::cleanCache('com_content'); $redirect = mosGetParam($_POST, 'redirect', $sectionid); switch ($task) { case 'go2menu': mosRedirect('index2.php?option=com_menus&menutype=' . $menu); break; case 'go2menuitem': mosRedirect('index2.php?option=com_menus&menutype=' . $menu . '&task=edit&hidemainmenu=1&id=' . $menuid); break; case 'menulink': menuLink($redirect, $row->id); break; case 'resethits': resethits($redirect, $row->id); break; case 'apply': $msg = 'Successfully Saved changes to Item: ' . $row->title; mosRedirect('index2.php?option=com_content§ionid=' . $redirect . '&task=edit&hidemainmenu=1&id=' . $row->id, $msg); break; case 'save': default: $msg = 'Successfully Saved Item: ' . $row->title; mosRedirect('index2.php?option=com_content§ionid=' . $redirect, $msg); break; } }
/** * Saves the typed content item */ function save($option, $task) { global $database, $my, $mainframe; $menu = mosGetParam($_POST, 'menu', 'mainmenu'); $menuid = mosGetParam($_POST, 'menuid', 0); $row = new mosContent($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if ($row->id) { $row->modified = date('Y-m-d H:i:s'); $row->modified_by = $my->id; } else { $row->created = date('Y-m-d H:i:s'); $row->created_by = $my->id; } if (trim($row->publish_down) == 'Never') { $row->publish_down = '0000-00-00 00:00:00'; } // Save Parameters $params = mosGetParam($_POST, 'params', ''); if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { $txt[] = "{$k}={$v}"; } $row->attribs = implode("\n", $txt); } // code cleaner for xhtml transitional compliance $row->introtext = str_replace('<br>', '<br />', $row->introtext); $row->state = mosGetParam($_REQUEST, 'published', 0); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // manage frontpage items require_once $mainframe->getPath('class', 'com_frontpage'); $fp = new mosFrontPage($database); if (mosGetParam($_REQUEST, 'frontpage', 0)) { // toggles go to first place if (!$fp->load($row->id)) { // new entry $database->setQuery("INSERT INTO #__content_frontpage VALUES ('{$row->id}','1')"); if (!$database->query()) { echo "<script> alert('" . $database->stderr() . "');</script>\n"; exit; } $fp->ordering = 1; } } else { // no frontpage mask if (!$fp->delete($row->id)) { $msg .= $fp->stderr(); } $fp->ordering = 0; } $fp->updateOrder(); $row->checkin(); switch ($task) { case 'go2menu': mosRedirect('index2.php?option=com_menus&menutype=' . $menu); break; case 'go2menuitem': mosRedirect('index2.php?option=com_menus&menutype=' . $menu . '&task=edit&hidemainmenu=1&id=' . $menuid); break; case 'menulink': menuLink($option, $row->id); break; case 'resethits': resethits($option, $row->id); break; case 'save': $msg = T_('Typed Content Item saved'); mosRedirect('index2.php?option=' . $option, $msg); break; case 'apply': default: $msg = T_('Changes to Typed Content Item saved'); mosRedirect('index2.php?option=' . $option . '&task=edit&hidemainmenu=1&id=' . $row->id, $msg); break; } }
/** * Saves the content item an edit form submit * @param database A database connector object */ function saveContent($sectionid, $task) { global $database, $my, $mainframe, $mosConfig_offset; $menu = mosGetParam($_POST, 'menu', 'mainmenu'); $menuid = mosGetParam($_POST, 'menuid', 0); $row = new mosContent($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $isNew = $row->id < 1; if ($isNew) { //$row->created = $row->created ? $row->created : date( "Y-m-d H:i:s" ); $row->created = $row->created ? mosFormatDate($row->created, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset * 60 * 60) : date("Y-m-d H:i:s"); $row->created_by = $row->created_by ? $row->created_by : $my->id; } else { $row->modified = date("Y-m-d H:i:s"); $row->modified_by = $my->id; } if (strlen(trim($row->publish_up)) <= 10) { $row->publish_up .= " 00:00:00"; } $row->publish_up = mosFormatDate($row->publish_up, '%Y-%m-%d %H:%M:%S', -$mosConfig_offset); if (trim($row->publish_down) == T_("Never")) { $row->publish_down = "0000-00-00 00:00:00"; } $row->state = mosGetParam($_REQUEST, 'published', 0); $params = mosGetParam($_POST, 'params', ''); if (is_array($params)) { $txt = array(); foreach ($params as $k => $v) { $txt[] = "{$k}={$v}"; } $row->attribs = implode("\n", $txt); } // code cleaner for xhtml transitional compliance $row->introtext = str_replace('<br>', '<br />', $row->introtext); $row->fulltext = str_replace('<br>', '<br />', $row->fulltext); // remove <br /> take being automatically added to empty fulltext $length = strlen($row->fulltext) < 9; $search = strstr($row->fulltext, '<br />'); if ($length && $search) { $row->fulltext = NULL; } if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->version++; if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } // manage frontpage items require_once $mainframe->getPath('class', 'com_frontpage'); $fp = new mosFrontPage($database); if (mosGetParam($_REQUEST, 'frontpage', 0)) { // toggles go to first place if (!$fp->load($row->id)) { // new entry $database->setQuery("INSERT INTO #__content_frontpage VALUES ('{$row->id}','1')"); if (!$database->query()) { echo "<script> alert('" . $database->stderr() . "');</script>\n"; exit; } $fp->ordering = 1; } } else { // no frontpage mask if (!$fp->delete($row->id)) { $msg .= $fp->stderr(); } $fp->ordering = 0; } $fp->updateOrder(); $row->checkin(); $row->updateOrder("catid='{$row->catid}' AND state >= 0"); $redirect = mosGetParam($_POST, 'redirect', $sectionid); switch ($task) { case 'go2menu': mosRedirect('index2.php?option=com_menus&menutype=' . $menu); break; case 'go2menuitem': mosRedirect('index2.php?option=com_menus&menutype=' . $menu . '&task=edit&hidemainmenu=1&id=' . $menuid); break; case 'menulink': menuLink($redirect, $row->id); break; case 'resethits': resethits($redirect, $row->id); break; case 'apply': $msg = T_('Successfully Saved changes to Item: ') . $row->title; mosRedirect('index2.php?option=com_content§ionid=' . $redirect . '&task=edit&hidemainmenu=1&id=' . $row->id, $msg); case 'save': default: $msg = T_('Successfully Saved Item: ') . $row->title; mosRedirect('index2.php?option=com_content§ionid=' . $redirect, $msg); break; } }