本文整理汇总了PHP中CMS::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CMS::add方法的具体用法?PHP CMS::add怎么用?PHP CMS::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMS
的用法示例。
在下文中一共展示了CMS::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addInDB
public function addInDB()
{
$cms = new CMS();
foreach (Language::getLanguages() as $lang) {
$cms->meta_title[$lang['id_lang']] = $this->title;
$cms->meta_description[$lang['id_lang']] = $this->title;
$cms->meta_keywords[$lang['id_lang']] = '';
$cms->content[$lang['id_lang']] = $this->content;
$cms->link_rewrite[$lang['id_lang']] = pSQL(preg_replace('/-(-)+/', '', preg_replace('/([^a-z\\-])+/', '', str_replace(' ', '-', Tools::strtolower($this->title)))));
}
$cms->id_cms_category = 1;
$cms->indexation = 1;
$cms->active = 1;
$cms->add();
}
示例2: postProcess
public function postProcess()
{
$this->_errors = array();
// Generelle Einstellungen
if (Tools::isSubmit('submitSaveOptions')) {
// Global Settings
if (!Configuration::updateGlobalValue('PS_EU_PAYMENT_API', (bool) Tools::getValue('PS_EU_PAYMENT_API'))) {
$this->_errors[] = $this->l('Could not update') . ': PS_EU_PAYMENT_API';
}
$values = array();
foreach ($this->languages as $language) {
$values[$language['id_lang']] = Tools::getValue('SHOPPING_CART_TEXT_BEFORE_' . $language['id_lang']);
}
if (!Configuration::updateValue('SHOPPING_CART_TEXT_BEFORE', $values)) {
$this->_errors[] = $this->l('Could not update') . ': SHOPPING_CART_TEXT_BEFORE';
}
$values = array();
foreach ($this->languages as $language) {
$values[$language['id_lang']] = Tools::getValue('SHOPPING_CART_TEXT_AFTER_' . $language['id_lang']);
}
if (!Configuration::updateValue('SHOPPING_CART_TEXT_AFTER', $values)) {
$this->_errors[] = $this->l('Could not update') . ': SHOPPING_CART_TEXT_AFTER';
}
if (!Configuration::updateValue('LEGAL_SHIPTAXMETH', (bool) Tools::getValue('LEGAL_SHIPTAXMETH'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_SHIPTAXMETH';
}
// Produktverfügbarkeit
$values = array();
foreach ($this->languages as $language) {
$values[$language['id_lang']] = Tools::getValue('LEGAL_DELIVERY_NOW_' . $language['id_lang']);
}
if (!Configuration::updateValue('LEGAL_DELIVERY_NOW', $values)) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_DELIVERY_NOW';
}
$values = array();
foreach ($this->languages as $language) {
$values[$language['id_lang']] = Tools::getValue('LEGAL_DELIVERY_LATER_' . $language['id_lang']);
}
if (!Configuration::updateValue('LEGAL_DELIVERY_LATER', $values)) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_DELIVERY_LATER';
}
if (!Configuration::updateValue('LEGAL_SHOW_WEIGHTS', (bool) Tools::getValue('LEGAL_SHOW_WEIGHTS'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_SHOW_WEIGHTS';
}
if (!Configuration::updateValue('LEGAL_SHOW_FANCY', (bool) Tools::getValue('LEGAL_SHOW_FANCY'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_SHOW_FANCY';
}
// CMS IDs festlegen
if (!Configuration::updateValue('LEGAL_CMS_ID_LEGAL', (int) Tools::getValue('LEGAL_CMS_ID_LEGAL'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_CMS_ID_LEGAL';
}
if (!Configuration::updateValue('PS_CONDITIONS_CMS_ID', (int) Tools::getValue('PS_CONDITIONS_CMS_ID'))) {
$this->_errors[] = $this->l('Could not update') . ': PS_CONDITIONS_CMS_ID';
}
if (!Configuration::updateValue('LEGAL_CMS_ID_REVOCATION', (int) Tools::getValue('LEGAL_CMS_ID_REVOCATION'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_CMS_ID_REVOCATION';
}
if (!Configuration::updateValue('LEGAL_CMS_ID_REVOCATIONFORM', (int) Tools::getValue('LEGAL_CMS_ID_REVOCATIONFORM'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_CMS_ID_REVOCATIONFORM';
}
if (!Configuration::updateValue('LEGAL_CMS_ID_PRIVACY', (int) Tools::getValue('LEGAL_CMS_ID_PRIVACY'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_CMS_ID_PRIVACY';
}
if (!Configuration::updateValue('LEGAL_CMS_ID_ENVIRONMENTAL', (int) Tools::getValue('LEGAL_CMS_ID_ENVIRONMENTAL'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_CMS_ID_ENVIRONMENTAL';
}
if (!Configuration::updateValue('LEGAL_CMS_ID_SHIPPING', (int) Tools::getValue('LEGAL_CMS_ID_SHIPPING'))) {
$this->_errors[] = $this->l('Could not update') . ': LEGAL_CMS_ID_SHIPPING';
}
if (count($this->_errors) <= 0) {
return $this->displayConfirmation($this->l('Settings updated'));
}
} elseif (Tools::isSubmit('submitAddCMSPages')) {
// install all cms pages
foreach ($this->cms_pages as $cms_page) {
if ($content = @Tools::file_get_contents($this->local_path . 'cms/' . $cms_page['name'] . '.txt')) {
$cms = new CMS();
$cms->active = true;
$cms->id_cms_category = 1;
$content = preg_replace('#src="(.*)"#u', 'src="' . Context::getContext()->shop->getBaseURL() . '\\1"', $content);
foreach ($this->languages as $language) {
$cms->meta_title[$language['id_lang']] = $cms_page['title'];
$cms->meta_description[$language['id_lang']] = $cms_page['title'];
$cms->meta_keywords[$language['id_lang']] = $cms_page['title'];
$cms->link_rewrite[$language['id_lang']] = Tools::link_rewrite($cms_page['title']);
$cms->content[$language['id_lang']] = trim($content);
}
if (!$cms->add()) {
$this->_errors[] = $this->l('Could not add new cms page') . ': ' . $cms_page['name'];
}
Configuration::updateValue($cms_page['config'], $cms->id);
$_POST[$cms_page['config']] = $cms->id;
} else {
$this->_errors[] = $this->l('Could not open file') . ': cms/' . $cms_page['name'] . '.txt';
}
}
// copy cms images
try {
$this->rcopy('modules/' . $this->name . '/img/cms/', 'img/cms/', array('root' => _PS_ROOT_DIR_));
} catch (Exception $e) {
//.........这里部分代码省略.........
示例3: generateAndLinkCMSPages
public function generateAndLinkCMSPages()
{
$cms_pages = array(self::LEGAL_NOTICE => array('meta_title' => $this->l('Legal notice', 'ps_legalcompliance'), 'link_rewrite' => 'legal-notice', 'content' => $this->l('Please add your legal information to this site.', 'ps_legalcompliance')), self::LEGAL_CONDITIONS => array('meta_title' => $this->l('Terms of Service (ToS)', 'ps_legalcompliance'), 'link_rewrite' => 'terms-of-service-tos', 'content' => $this->l('Please add your Terms of Service (ToS) to this site.', 'ps_legalcompliance')), self::LEGAL_REVOCATION => array('meta_title' => $this->l('Revocation terms', 'ps_legalcompliance'), 'link_rewrite' => 'revocation-terms', 'content' => $this->l('Please add your Revocation terms to this site.', 'ps_legalcompliance')), self::LEGAL_PRIVACY => array('meta_title' => $this->l('Privacy', 'ps_legalcompliance'), 'link_rewrite' => 'privacy', 'content' => $this->l('Please insert here your content about privacy. If you have activated Social Media modules, please provide a notice about third-party access to data.', 'ps_legalcompliance')), self::LEGAL_SHIP_PAY => array('meta_title' => $this->l('Shipping and payment', 'ps_legalcompliance'), 'link_rewrite' => 'shipping-and-payment', 'content' => $this->l('Please add your Shipping and payment information to this site.', 'ps_legalcompliance')), self::LEGAL_ENVIRONMENTAL => array('meta_title' => $this->l('Environmental notice', 'ps_legalcompliance'), 'link_rewrite' => 'environmental-notice', 'content' => $this->l('Please add your Environmental information to this site.', 'ps_legalcompliance')));
$cms_role_repository = $this->entity_manager->getRepository('CMSRole');
$langs_repository = $this->entity_manager->getRepository('Language');
$langs = $langs_repository->findAll();
foreach ($cms_pages as $cms_page_role => $cms_page) {
$cms_role = $cms_role_repository->findOneByName($cms_page_role);
if ((int) $cms_role->id_cms == 0) {
$cms = new CMS();
$cms->id_cms_category = 1;
foreach ($langs as $lang) {
$cms->meta_title[(int) $lang->id] = $cms_page['meta_title'];
$cms->link_rewrite[(int) $lang->id] = 'aeu-legal-' . $cms_page['link_rewrite'];
$cms->content[(int) $lang->id] = $cms_page['content'];
}
$cms->active = 1;
$cms->add();
$cms_role->id_cms = (int) $cms->id;
$cms_role->update();
}
}
return true;
}
示例4: CMS
<?php
if (Tools::P('saveCMS') == 'add') {
$cms = new CMS();
$cms->copyFromPost();
if ($cms->add()) {
if (!$cms->updateCategories($_POST['categoryBox']) or !$cms->updateTags($_POST['tags'])) {
$cms->_errors = '添加CMS内容时发生了一个错误';
}
}
if (is_array($cms->_errors) and count($cms->_errors) > 0) {
$errors = $cms->_errors;
} else {
$_GET['id'] = $cms->id;
UIAdminAlerts::conf('文章已添加');
}
}
if (isset($_GET['id'])) {
$id = (int) Tools::G('id');
$obj = new CMS($id);
}
if (Tools::P('saveCMS') == 'edit') {
if (Validate::isLoadedObject($obj)) {
$obj->copyFromPost();
if ($obj->update()) {
if (!$obj->updateCategories($_POST['categoryBox']) or !$obj->updateTags($_POST['tags'])) {
$obj->_errors = '更新CMS内容时发生了一个错误';
}
}
}
if (is_array($obj->_errors) and count($obj->_errors) > 0) {
示例5: importCMS
protected function importCMS()
{
$new_path = new Sampledatainstall();
$file = $new_path->sendPath() . 'input/cms_pages.csv';
// do nothing if file is empty
if (Tools::isEmpty(trim(file_get_contents($file)))) {
return;
}
$this->truncateTables(array('cms', 'cms_lang', 'cms_shop'));
$handle = $this->openCsvFile('cms_pages.csv');
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
$res = false;
$fields = $this->filterFields('CMS', $this->cms_pages_fields, $line);
if (!isset($fields['id'])) {
$cms = new CMS((int) $line[0]);
$cms->id = $line[0];
} else {
$cms = new CMS((int) $fields['id']);
}
foreach ($fields as $key => $field) {
if ($key == 'meta_title' || $key == 'meta_description' || $key == 'meta_keywords' || $key == 'content' || $key == 'link_rewrite') {
$cms->{$key} = $this->multilFild($field);
} else {
$cms->{$key} = $field;
}
}
$cms->force_id = true;
if (!$res) {
$cms->add();
}
}
$this->closeCsvFile($handle);
return true;
}