本文整理汇总了PHP中CMS::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CMS::delete方法的具体用法?PHP CMS::delete怎么用?PHP CMS::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMS
的用法示例。
在下文中一共展示了CMS::delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
function postProcess()
{
global $cookie, $link, $currentIndex;
if (Tools::isSubmit('viewcms') and $id_cms = (int) Tools::getValue('id_cms') and $cms = new CMS($id_cms, (int) $cookie->id_lang) and Validate::isLoadedObject($cms)) {
$redir = $link->getCMSLink($cms);
if (!$cms->active) {
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$redir .= '?adtoken=' . Tools::encrypt('PreviewCMS' . $cms->id) . '&ad=' . $admin_dir;
}
Tools::redirectAdmin($redir);
} elseif (Tools::isSubmit('deletecms')) {
if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID')) {
Configuration::updateValue('PS_CONDITIONS', 0);
Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0);
}
$cms = new CMS((int) Tools::getValue('id_cms'));
$cms->cleanPositions($cms->id_cms_category);
if (!$cms->delete()) {
$this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . ' (' . mysql_error() . ')</b>';
} else {
Tools::redirectAdmin($currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=1&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
}
} elseif (Tools::getValue('submitDel' . $this->table)) {
if ($this->tabAccess['delete'] === '1') {
if (isset($_POST[$this->table . 'Box'])) {
$cms = new CMS();
$result = true;
$result = $cms->deleteSelection(Tools::getValue($this->table . 'Box'));
if ($result) {
$cms->cleanPositions((int) Tools::getValue('id_cms_category'));
Tools::redirectAdmin($currentIndex . '&conf=2&token=' . Tools::getAdminTokenLite('AdminCMSContent') . '&id_category=' . (int) Tools::getValue('id_cms_category'));
}
$this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
} else {
$this->_errors[] = Tools::displayError('You must select at least one element to delete.');
}
} else {
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
}
} elseif (Tools::isSubmit('submitAddcms') or Tools::isSubmit('submitAddcmsAndPreview')) {
parent::validateRules();
if (!sizeof($this->_errors)) {
if (!($id_cms = (int) Tools::getValue('id_cms'))) {
$cms = new CMS();
$this->copyFromPost($cms, 'cms');
if (!$cms->add()) {
$this->_errors[] = Tools::displayError('An error occurred while creating object.') . ' <b>' . $this->table . ' (' . mysql_error() . ')</b>';
} elseif (Tools::isSubmit('submitAddcmsAndPreview')) {
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int) $cookie->id_lang);
if (!$cms->active) {
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$token = Tools::encrypt('PreviewCMS' . $cms->id);
$preview_url .= $object->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir;
}
Tools::redirectAdmin($preview_url);
} else {
Tools::redirectAdmin($currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=3&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
}
} else {
$cms = new CMS($id_cms);
$this->copyFromPost($cms, 'cms');
if (!$cms->update()) {
$this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . ' (' . mysql_error() . ')</b>';
} elseif (Tools::isSubmit('submitAddcmsAndPreview')) {
$preview_url = $link->getCMSLink($cms, $this->getFieldValue($object, 'link_rewrite', $this->_defaultFormLanguage), (int) $cookie->id_lang);
if (!$cms->active) {
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$token = Tools::encrypt('PreviewCMS' . $cms->id);
$preview_url .= $object->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir;
}
Tools::redirectAdmin($preview_url);
} else {
Tools::redirectAdmin($currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=4&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
}
}
}
} elseif (Tools::getValue('position')) {
if ($this->tabAccess['edit'] !== '1') {
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
} elseif (!Validate::isLoadedObject($object = $this->loadObject())) {
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
} elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
$this->_errors[] = Tools::displayError('Failed to update the position.');
} else {
Tools::redirectAdmin($currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=4' . (($id_category = (int) Tools::getValue('id_cms_category')) ? '&id_cms_category=' . $id_category : '') . '&token=' . Tools::getAdminTokenLite('AdminCMSContent'));
}
} elseif (Tools::isSubmit('status') and Tools::isSubmit($this->identifier)) {
if ($this->tabAccess['edit'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->toggleStatus()) {
Tools::redirectAdmin($currentIndex . '&conf=5' . ((int) Tools::getValue('id_cms_category') ? '&id_cms_category=' . (int) Tools::getValue('id_cms_category') : '') . '&token=' . Tools::getValue('token'));
} else {
$this->_errors[] = Tools::displayError('An error occurred while updating status.');
}
} else {
$this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
//.........这里部分代码省略.........
示例2: postProcess
public function postProcess()
{
if (Tools::isSubmit('viewcms') && ($id_cms = (int) Tools::getValue('id_cms')) && ($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms)) {
$redir = $this->context->link->getCMSLink($cms);
if (!$cms->active) {
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$redir .= '?adtoken=' . Tools::getAdminTokenLite('AdminCmsContent') . '&ad=' . $admin_dir . '&id_employee=' . (int) $this->context->employee->id;
}
Tools::redirectAdmin($redir);
} elseif (Tools::isSubmit('deletecms')) {
if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID')) {
Configuration::updateValue('PS_CONDITIONS', 0);
Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0);
}
$cms = new CMS((int) Tools::getValue('id_cms'));
$cms->cleanPositions($cms->id_cms_category);
if (!$cms->delete()) {
$this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
} else {
Tools::redirectAdmin(self::$currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=1&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
}
} elseif (Tools::getValue('submitDel' . $this->table)) {
if ($this->tabAccess['delete'] === '1') {
if (Tools::isSubmit($this->table . 'Box')) {
$cms = new CMS();
$result = true;
$result = $cms->deleteSelection(Tools::getValue($this->table . 'Box'));
if ($result) {
$cms->cleanPositions((int) Tools::getValue('id_cms_category'));
$token = Tools::getAdminTokenLite('AdminCmsContent');
Tools::redirectAdmin(self::$currentIndex . '&conf=2&token=' . $token . '&id_cms_category=' . (int) Tools::getValue('id_cms_category'));
}
$this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
} else {
$this->errors[] = Tools::displayError('You must select at least one element to delete.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndPreview')) {
parent::validateRules();
if (count($this->errors)) {
return false;
}
if (!($id_cms = (int) Tools::getValue('id_cms'))) {
$cms = new CMS();
$this->copyFromPost($cms, 'cms');
if (!$cms->add()) {
$this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
} else {
$this->updateAssoShop($cms->id);
}
} else {
$cms = new CMS($id_cms);
$this->copyFromPost($cms, 'cms');
if (!$cms->update()) {
$this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
} else {
$this->updateAssoShop($cms->id);
}
}
if (Tools::isSubmit('submitAddcmsAndPreview')) {
$alias = $this->getFieldValue($cms, 'link_rewrite', $this->context->language->id);
$preview_url = $this->context->link->getCMSLink($cms, $alias, $this->context->language->id);
if (!$cms->active) {
$admin_dir = dirname($_SERVER['PHP_SELF']);
$admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
$params = http_build_query(array('adtoken' => Tools::getAdminTokenLite('AdminCmsContent'), 'ad' => $admin_dir, 'id_employee' => (int) $this->context->employee->id));
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$params = '?' . $params;
} else {
$params = '&' . $params;
}
$preview_url .= $cms->active ? '' : $params;
}
Tools::redirectAdmin($preview_url);
} elseif (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . $cms->id . '&conf=4&update' . $this->table . '&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
} else {
Tools::redirectAdmin(self::$currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=4&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
}
} elseif (Tools::isSubmit('way') && Tools::isSubmit('id_cms') && Tools::isSubmit('position')) {
if ($this->tabAccess['edit'] !== '1') {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
} elseif (!Validate::isLoadedObject($object = $this->loadObject())) {
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
} elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
$this->errors[] = Tools::displayError('Failed to update the position.');
} else {
Tools::redirectAdmin(self::$currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=4&id_cms_category=' . (int) $object->id_cms_category . '&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
}
} elseif (Tools::isSubmit('statuscms') && Tools::isSubmit($this->identifier)) {
if ($this->tabAccess['edit'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->toggleStatus()) {
Tools::redirectAdmin(self::$currentIndex . '&conf=5&id_cms_category=' . (int) $object->id_cms_category . '&token=' . Tools::getValue('token'));
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the status.');
}
//.........这里部分代码省略.........
示例3: postProcess
public function postProcess()
{
if (Tools::isSubmit('viewcms') && ($id_cms = (int) Tools::getValue('id_cms'))) {
parent::postProcess();
if (($cms = new CMS($id_cms, $this->context->language->id)) && Validate::isLoadedObject($cms)) {
$this->redirect_after = $this->getPreviewUrl($cms);
Tools::redirectAdmin($this->redirect_after);
}
} elseif (Tools::isSubmit('deletecms')) {
if (Tools::getValue('id_cms') == Configuration::get('PS_CONDITIONS_CMS_ID')) {
Configuration::updateValue('PS_CONDITIONS', 0);
Configuration::updateValue('PS_CONDITIONS_CMS_ID', 0);
}
$cms = new CMS((int) Tools::getValue('id_cms'));
$cms->cleanPositions($cms->id_cms_category);
if (!$cms->delete()) {
$this->errors[] = Tools::displayError('An error occurred while deleting the object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
} else {
Tools::redirectAdmin(self::$currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=1&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
}
} elseif (Tools::getValue('submitDel' . $this->table)) {
if ($this->tabAccess['delete'] === '1') {
if (Tools::isSubmit($this->table . 'Box')) {
$cms = new CMS();
$result = true;
$result = $cms->deleteSelection(Tools::getValue($this->table . 'Box'));
if ($result) {
$cms->cleanPositions((int) Tools::getValue('id_cms_category'));
$token = Tools::getAdminTokenLite('AdminCmsContent');
Tools::redirectAdmin(self::$currentIndex . '&conf=2&token=' . $token . '&id_cms_category=' . (int) Tools::getValue('id_cms_category'));
}
$this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
} else {
$this->errors[] = Tools::displayError('You must select at least one element to delete.');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
}
} elseif (Tools::isSubmit('submitAddcms') || Tools::isSubmit('submitAddcmsAndPreview')) {
parent::validateRules();
if (count($this->errors)) {
return false;
}
if (!($id_cms = (int) Tools::getValue('id_cms'))) {
$cms = new CMS();
$this->copyFromPost($cms, 'cms');
if (!$cms->add()) {
$this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
} else {
$this->updateAssoShop($cms->id);
}
} else {
$cms = new CMS($id_cms);
$this->copyFromPost($cms, 'cms');
if (!$cms->update()) {
$this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
} else {
$this->updateAssoShop($cms->id);
}
}
if (Tools::isSubmit('view' . $this->table)) {
$this->redirect_after = $this->getPreviewUrl($cms);
Tools::redirectAdmin($this->redirect_after);
} elseif (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . $cms->id . '&conf=4&update' . $this->table . '&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
} else {
Tools::redirectAdmin(self::$currentIndex . '&id_cms_category=' . $cms->id_cms_category . '&conf=4&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
}
} elseif (Tools::isSubmit('way') && Tools::isSubmit('id_cms') && Tools::isSubmit('position')) {
if ($this->tabAccess['edit'] !== '1') {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
} elseif (!Validate::isLoadedObject($object = $this->loadObject())) {
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
} elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
$this->errors[] = Tools::displayError('Failed to update the position.');
} else {
Tools::redirectAdmin(self::$currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=4&id_cms_category=' . (int) $object->id_cms_category . '&token=' . Tools::getAdminTokenLite('AdminCmsContent'));
}
} elseif (Tools::isSubmit('statuscms') && Tools::isSubmit($this->identifier)) {
if ($this->tabAccess['edit'] === '1') {
if (Validate::isLoadedObject($object = $this->loadObject())) {
if ($object->toggleStatus()) {
Tools::redirectAdmin(self::$currentIndex . '&conf=5&id_cms_category=' . (int) $object->id_cms_category . '&token=' . Tools::getValue('token'));
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the status.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
} elseif (Tools::isSubmit('submitBulkdeletecms')) {
if ($this->tabAccess['delete'] === '1') {
$this->action = 'bulkdelete';
$this->boxes = Tools::getValue($this->table . 'Box');
if (is_array($this->boxes) && array_key_exists(0, $this->boxes)) {
$firstCms = new CMS((int) $this->boxes[0]);
$id_cms_category = (int) $firstCms->id_cms_category;
if (!($res = parent::postProcess(true))) {
//.........这里部分代码省略.........