本文整理汇总了PHP中cmsCore::arrayToYaml方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::arrayToYaml方法的具体用法?PHP cmsCore::arrayToYaml怎么用?PHP cmsCore::arrayToYaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::arrayToYaml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: votePoll
public function votePoll($poll, $answer){
if(!$poll['answers']){ return false; }
$inUser = cmsUser::getInstance();
//Прибавляем голос к переданному нам варианту ответа
foreach($poll['answers'] as $key=>$value){
if ($key == stripslashes($answer)){
$poll['answers'][$key] += 1;
}
}
$answers = $this->inDB->escape_string(cmsCore::arrayToYaml($poll['answers']));
//Сохраняем результаты опроса
$sql = "UPDATE cms_polls SET answers = '{$answers}' WHERE id = '{$poll['id']}'";
$this->inDB->query($sql);
// помечаем кто за что проголосовал
$sql = "INSERT cms_polls_log (poll_id, answer, user_id, ip)
VALUES ('{$poll['id']}', '$answer', '{$inUser->id}', '{$inUser->ip}')";
$this->inDB->query($sql);
return true;
}
示例2: setupAnswers
function setupAnswers($answers_title) {
$answers = array();
foreach ($answers_title as $answer) {
if ($answer) { $answers[$answer] = 0; }
}
return cmsCore::arrayToYaml($answers);
}
示例3: array
$cat['pagetitle'] = cmsCore::request('pagetitle', 'str', '');
$cat['meta_desc'] = cmsCore::request('meta_desc', 'str', '');
$cat['meta_keys'] = cmsCore::request('meta_keys', 'str', '');
if (!is_numeric($cat['cost'])) { $cat['cost'] = ''; }
if (cmsCore::request('copy_parent_struct')) {
$fstruct = cmsCore::c('db')->get_field('cms_uc_cats', "id='{$cat['parent_id']}'", 'fieldsstruct');
} else {
$fstruct = cmsCore::request('fstruct', 'array', array());
foreach ($fstruct as $key=>$value) {
if ($value=='') { unset($fstruct[$key]); continue; }
if ($_REQUEST['fformat'][$key]=='html') { $fstruct[$key] .= '/~h~/'; }
if ($_REQUEST['fformat'][$key]=='link') { $fstruct[$key] .= '/~l~/'; }
if ($_REQUEST['flink'][$key]) { $fstruct[$key] .= '/~m~/'; }
}
$fstruct = cmsCore::arrayToYaml($fstruct);
}
$cat['fieldsstruct'] = cmsCore::c('db')->escape_string($fstruct);
if ($opt == 'submit_cat') {
$cat_id = cmsCore::c('db')->addNsCategory('cms_uc_cats', cmsCore::callEvent('ADD_CATALOG_CAT', $cat));
} else {
$cat_id = cmsCore::request('item_id', 'int', 0);
$model->updateCategory($cat_id, $cat);
}
if ($cat['is_public']) {
$showfor = cmsCore::request('showfor', 'array_int', array());
if ($showfor) {
$model->setCategoryAccess($cat_id, $showfor);
}
示例4: board
//.........这里部分代码省略.........
// проверяем наличие категории
if (!$cat['id']) {
cmsCore::addSessionMessage($_LANG['NEED_CAT_ADV'], 'error');
$errors = true;
}
// Проверяем количество добавленных за сутки
if (!cmsCore::m('board')->checkLoadedByUser24h($cat)){
cmsCore::addSessionMessage($_LANG['MAX_VALUE_OF_ADD_ADV'], 'error');
$errors = true;
}
// Можем ли добавлять в эту рубрику
if (!cmsCore::m('board')->checkAdd($cat)){
cmsCore::addSessionMessage($_LANG['YOU_CANT_ADD_ADV'], 'error');
$errors = true;
}
// входные данные
$obtype = icms_ucfirst(cmsCore::request('obtype', 'str', ''));
$title = trim(str_ireplace($obtype, '', cmsCore::request('title', 'str', '')));
$content = cmsCore::request('content', 'str', '');
$city = cmsCore::request('city', 'str', '');
if ((cmsCore::m('board')->config['seo_user_access'] && cmsCore::c('user')->id) || cmsCore::c('user')->is_admin) {
$pagetitle = cmsCore::request('pagetitle', 'str', '');
$meta_keys = cmsCore::request('meta_keys', 'str', '');
$meta_desc = cmsCore::request('meta_desc', 'str', '');
} else {
$pagetitle = $meta_keys = $meta_desc = '';
}
$form_input = cmsForm::getFieldsInputValues($cat['form_id']);
$formsdata = cmsCore::c('db')->escape_string(cmsCore::arrayToYaml($form_input['values']));
$vipdays = cmsCore::request('vipdays', 'int', 0);
$published = cmsCore::m('board')->checkPublished($cat);
if (cmsCore::m('board')->config['srok']){ $pubdays = (cmsCore::request('pubdays', 'int') <= 50) ? cmsCore::request('pubdays', 'int') : 50; }
if (!cmsCore::m('board')->config['srok']){ $pubdays = isset(cmsCore::m('board')->config['pubdays']) ? cmsCore::m('board')->config['pubdays'] : 14; }
// Проверяем значения
if (!$title) {
cmsCore::addSessionMessage($_LANG['NEED_TITLE'], 'error');
$errors = true;
}
if (!$content) {
cmsCore::addSessionMessage($_LANG['NEED_TEXT_ADV'], 'error');
$errors = true;
}
if (!$city) {
cmsCore::addSessionMessage($_LANG['NEED_CITY'], 'error');
$errors = true;
}
if (!cmsCore::c('user')->id && !cmsCore::checkCaptchaCode()) {
cmsCore::addSessionMessage($_LANG['ERR_CAPTCHA'], 'error');
$errors = true;
}
// Проверяем значения формы
foreach ($form_input['errors'] as $field_error) {
if ($field_error) {
cmsCore::addSessionMessage($field_error, 'error');
$errors = true;
}
示例5: applet_modules
//.........这里部分代码省略.........
}
}
if ($do == 'hide') {
if (!isset($_REQUEST['item'])) {
if ($id >= 0) { cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '0'); }
cmsCore::halt('1');
} else {
cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '0');
cmsCore::redirectBack();
}
}
if ($do == 'delete') {
if (!cmsCore::inRequest('item')) {
$inCore->removeModule($id);
} else {
$inCore->removeModule(cmsCore::request('item', 'array_int', array()));
}
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
cmsCore::redirect('index.php?view=modules');
}
if ($do == 'update') {
if (!cmsUser::checkCsrfToken()) { cmsCore::error404(); }
$id = cmsCore::request('id', 'int', 0);
$mod = cmsCore::c('db')->get_fields('cms_modules', "id = ". $id ."", '*');
$module = array(
'name' => cmsCore::request('name', 'str', ''),
'title' => cmsCore::request('title', 'str', ''),
'titles' => cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())),
'position' => cmsCore::request('position', 'str', ''),
'showtitle' => cmsCore::request('showtitle', 'int', 0),
'published' => cmsCore::request('published', 'int', 0),
'css_prefix' => cmsCore::request('css_prefix', 'str', ''),
'is_strict_bind' => cmsCore::request('is_strict_bind', 'int', 0),
'is_strict_bind_hidden' => cmsCore::request('is_strict_bind_hidden', 'int', 0),
'template' => cmsCore::request('template', 'str', ''),
'cache' => cmsCore::request('cache', 'int', 0),
'cachetime' => cmsCore::request('cachetime', 'int', 0),
'cacheint' => cmsCore::request('cacheint', 'str', ''),
'access_list' => '',
'hidden_menu_ids' => ''
);
if (!$mod['is_external']) {
$module['content'] = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', ''));
}
$is_public = cmsCore::request('is_public', 'int', '');
if (!$is_public) {
$module['access_list'] = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
}
cmsCore::c('db')->update('cms_modules', $module, $id);
cmsCore::c('db')->delete('cms_modules_bind', "module_id=". $id ." AND tpl='". cmsCore::c('config')->template ."'");
if (cmsCore::request('show_all', 'int', 0)) {
cmsCore::c('db')->insert(
'cms_modules_bind',
array(
'module_id' => $id,
'menu_id' => 0,
示例6: users
//.........这里部分代码省略.........
$letter = cmsCore::getLanguageTextFile('change_email');
$letter = str_replace(array('{nickname}', '{codelink}'), array($inUser->nickname, $codelink), $letter);
cmsCore::mailText($usr['email'], '', $letter);
cmsCore::addSessionMessage(sprintf($_LANG['YOU_CHANGE_EMAIL'], $usr['email']), 'info');
// email не меняем
$users['email'] = $usr['email'];
}
}
$profiles['showphone'] = cmsCore::request('showphone', 'int', 0);
$profiles['showmail'] = cmsCore::request('showmail', 'int');
$profiles['email_newmsg'] = cmsCore::request('email_newmsg', 'int');
$profiles['showbirth'] = cmsCore::request('showbirth', 'int');
$profiles['description'] = cmsCore::request('description', 'str', '');
$users['birthdate'] = (int) $_REQUEST['birthdate']['year'] . '-' . (int) $_REQUEST['birthdate']['month'] . '-' . (int) $_REQUEST['birthdate']['day'];
$profiles['signature'] = $inDB->escape_string(cmsCore::badTagClear(cmsCore::request('signature', 'html', '')));
$profiles['signature_html'] = $inDB->escape_string(cmsCore::parseSmiles(cmsCore::request('signature', 'html', ''), true));
$profiles['allow_who'] = cmsCore::request('allow_who', 'str');
if (!preg_match('/^([a-zA-Z]+)$/ui', $profiles['allow_who'])) {
$errors = true;
}
$users['icq'] = cmsCore::request('icq', 'str', '');
$profiles['showicq'] = cmsCore::request('showicq', 'int');
$profiles['cm_subscribe'] = cmsCore::request('cm_subscribe', 'str');
if (!preg_match('/^([a-zA-Z]+)$/ui', $profiles['cm_subscribe'])) {
$errors = true;
}
$users['phone'] = cmsCore::request('phone', 'int', 0);
// получаем данные форм
$profiles['formsdata'] = '';
if (isset($model->config['privforms'])) {
if (is_array($model->config['privforms'])) {
foreach ($model->config['privforms'] as $form_id) {
$form_input = cmsForm::getFieldsInputValues($form_id);
$profiles['formsdata'] .= $inDB->escape_string(cmsCore::arrayToYaml($form_input['values']));
// Проверяем значения формы
foreach ($form_input['errors'] as $field_error) {
if ($field_error) {
cmsCore::addSessionMessage($field_error, 'error');
$errors = true;
}
}
}
}
}
if ($errors) {
cmsCore::redirectBack();
}
$inDB->update('cms_user_profiles', cmsCore::callEvent('UPDATE_USER_PROFILES', array_merge(array('id' => $usr['pid'], 'user_id' => $usr['id']), $profiles)), $usr['pid']);
$inDB->update('cms_users', cmsCore::callEvent('UPDATE_USER_USERS', array_merge(array('id' => $usr['id']), $users)), $usr['id']);
cmsCore::addSessionMessage($_LANG['PROFILE_SAVED'], 'info');
cmsCore::redirect(cmsUser::getProfileURL($usr['login']));
}
if ($opt == 'changepass') {
$errors = false;
$oldpass = cmsCore::request('oldpass', 'str');
$newpass = cmsCore::request('newpass', 'str');
$newpass2 = cmsCore::request('newpass2', 'str');
if ($inUser->password != md5($oldpass)) {
cmsCore::addSessionMessage($_LANG['OLD_PASS_WRONG'], 'error');
$errors = true;
}
if ($newpass != $newpass2) {
cmsCore::addSessionMessage($_LANG['WRONG_PASS'], 'error');
$errors = true;
}
if ($oldpass && $newpass && $newpass2 && mb_strlen($newpass) < 6) {
示例7: applet_menu
function applet_menu()
{
$inCore = cmsCore::getInstance();
$inDB = cmsDatabase::getInstance();
global $_LANG;
global $adminAccess;
if (!cmsUser::isAdminCan('admin/menu', $adminAccess)) {
cpAccessDenied();
}
$GLOBALS['cp_page_title'] = $_LANG['AD_MENU'];
cpAddPathway($_LANG['AD_MENU'], 'index.php?view=menu');
$do = cmsCore::request('do', 'str', 'list');
$id = cmsCore::request('id', 'int', -1);
if ($do == 'list') {
$toolmenu[] = array('icon' => 'new.gif', 'title' => $_LANG['AD_MENU_POINT_ADD'], 'link' => '?view=menu&do=add');
$toolmenu[] = array('icon' => 'newmenu.gif', 'title' => $_LANG['AD_MENU_ADD'], 'link' => '?view=menu&do=addmenu');
$toolmenu[] = array('icon' => 'edit.gif', 'title' => $_LANG['AD_EDIT_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=edit&multiple=1');");
$toolmenu[] = array('icon' => 'delete.gif', 'title' => $_LANG['AD_DELETE_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=delete&multiple=1');");
$toolmenu[] = array('icon' => 'show.gif', 'title' => $_LANG['AD_ALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=show&multiple=1');");
$toolmenu[] = array('icon' => 'hide.gif', 'title' => $_LANG['AD_DISALLOW_SELECTED'], 'link' => "javascript:checkSel('?view=menu&do=hide&multiple=1');");
$toolmenu[] = array('icon' => 'help.gif', 'title' => $_LANG['AD_HELP'], 'link' => '?view=help&topic=menu');
cpToolMenu($toolmenu);
$fields[] = array('title' => 'Lt', 'field' => 'NSLeft', 'width' => '30');
$fields[] = array('title' => $_LANG['TITLE'], 'field' => 'title', 'width' => '', 'link' => '?view=menu&do=edit&id=%id%');
$fields[] = array('title' => $_LANG['SHOW'], 'field' => 'published', 'width' => '60');
$fields[] = array('title' => $_LANG['AD_ORDER'], 'field' => 'ordering', 'width' => '100');
$fields[] = array('title' => $_LANG['AD_LINK'], 'field' => array('linktype', 'linkid', 'link'), 'width' => '240', 'prc' => 'cpMenutypeById');
$fields[] = array('title' => $_LANG['AD_MENU'], 'field' => 'menu', 'width' => '70', 'filter' => '10', 'filterlist' => cpGetList('menu'), 'prc' => 'list_menu');
$fields[] = array('title' => $_LANG['TEMPLATE'], 'field' => 'template', 'width' => '70', 'prc' => 'cpTemplateById');
$actions[] = array('title' => $_LANG['EDIT'], 'icon' => 'edit.gif', 'link' => '?view=menu&do=edit&id=%id%');
$actions[] = array('title' => $_LANG['DELETE'], 'icon' => 'delete.gif', 'confirm' => $_LANG['AD_MENU_POINT_CONFIRM'], 'link' => '?view=menu&do=delete&id=%id%');
cpListTable('cms_menu', $fields, $actions, 'parent_id>0', 'NSLeft, ordering');
} else {
$toolmenu[] = array('icon' => 'save.gif', 'title' => $_LANG['SAVE'], 'link' => 'javascript:document.addform.submit();');
$toolmenu[] = array('icon' => 'cancel.gif', 'title' => $_LANG['CANCEL'], 'link' => 'index.php?view=menu');
cpToolMenu($toolmenu);
}
if ($do == 'move_up') {
$inDB->moveNsCategory('cms_menu', $id, 'up');
cmsCore::redirectBack();
}
if ($do == 'move_down') {
$inDB->moveNsCategory('cms_menu', $id, 'down');
cmsCore::redirectBack();
}
if ($do == 'show') {
if (!isset($_REQUEST['item'])) {
if ($id >= 0) {
dbShow('cms_menu', $id);
}
echo '1';
exit;
} else {
dbShowList('cms_menu', $_REQUEST['item']);
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
cmsCore::redirectBack();
}
}
if ($do == 'hide') {
if (!isset($_REQUEST['item'])) {
if ($id >= 0) {
dbHide('cms_menu', $id);
}
echo '1';
exit;
} else {
dbHideList('cms_menu', cmsCore::request('item', 'array_int', array()));
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
cmsCore::redirectBack();
}
}
if ($do == 'delete') {
if (!isset($_REQUEST['item'])) {
if ($id >= 0) {
$inDB->deleteNS('cms_menu', (int) $id);
}
} else {
$items = cmsCore::request('item', 'array_int', array());
foreach ($items as $item_id) {
$inDB->deleteNS('cms_menu', $item_id);
}
}
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
cmsCore::redirectBack();
}
if ($do == 'update') {
if (!cmsUser::checkCsrfToken()) {
cmsCore::error404();
}
$id = cmsCore::request('id', 'int', 0);
if (!$id) {
cmsCore::redirectBack();
}
$title = cmsCore::request('title', 'str', '');
$menu = cmsCore::arrayToYaml(cmsCore::request('menu', 'array_str', ''));
$linktype = cmsCore::request('mode', 'str', '');
$linkid = cmsCore::request($linktype, 'str', '');
$link = $inCore->getMenuLink($linktype, $linkid);
$target = cmsCore::request('target', 'str', '');
$published = cmsCore::request('published', 'int', 0);
//.........这里部分代码省略.........
示例8: applet_modules
//.........这里部分代码省略.........
cmsCore::redirectBack();
}
}
if ($do == 'hide') {
if (!isset($_REQUEST['item'])) {
if ($id >= 0) {
dbHide('cms_modules', $id);
}
echo '1';
exit;
} else {
dbHideList('cms_modules', cmsCore::request('item', 'array_int', array()));
cmsCore::redirectBack();
}
}
if ($do == 'delete') {
if (!isset($_REQUEST['item'])) {
$inCore->removeModule($id);
} else {
$inCore->removeModule(cmsCore::request('item', 'array_int', array()));
}
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
cmsCore::redirect('index.php?view=modules');
}
//============================================================================//
//============================================================================//
if ($do == 'update') {
if (!cmsUser::checkCsrfToken()) {
cmsCore::error404();
}
$id = cmsCore::request('id', 'int', 0);
$name = cmsCore::request('name', 'str', '');
$title = cmsCore::request('title', 'str', '');
$titles = cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array()));
$position = cmsCore::request('position', 'str', '');
$showtitle = cmsCore::request('showtitle', 'int', 0);
$content = $inDB->escape_string(cmsCore::request('content', 'html', ''));
$published = cmsCore::request('published', 'int', 0);
$css_prefix = cmsCore::request('css_prefix', 'str', '');
$is_strict_bind = cmsCore::request('is_strict_bind', 'int', 0);
$is_strict_bind_hidden = cmsCore::request('is_strict_bind_hidden', 'int', 0);
$is_public = cmsCore::request('is_public', 'int', '');
if (!$is_public) {
$access_list = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
}
$template = cmsCore::request('template', 'str', '');
$cache = cmsCore::request('cache', 'int', 0);
$cachetime = cmsCore::request('cachetime', 'int', 0);
$cacheint = cmsCore::request('cacheint', 'str', '');
$sql = "UPDATE cms_modules\r\n SET name='{$name}',\r\n title='{$title}',\r\n titles='{$titles}',\r\n position='{$position}',\r\n template='{$template}',\r\n showtitle={$showtitle},";
if ($content) {
$sql .= "content='{$content}',";
}
$sql .= "\r\n published={$published},\r\n css_prefix='{$css_prefix}',\r\n access_list='{$access_list}',\r\n hidden_menu_ids='',\r\n cachetime = '{$cachetime}',\r\n cacheint = '{$cacheint}',\r\n cache = '{$cache}',\r\n is_strict_bind = '{$is_strict_bind}',\r\n is_strict_bind_hidden = '{$is_strict_bind_hidden}'\r\n WHERE id = '{$id}'\r\n LIMIT 1";
$inDB->query($sql);
$sql = "DELETE FROM cms_modules_bind WHERE module_id = {$id}";
$inDB->query($sql);
if (cmsCore::request('show_all', 'int', 0)) {
$sql = "INSERT INTO cms_modules_bind (module_id, menu_id, position)\r\n VALUES ({$id}, 0, '{$position}')";
$inDB->query($sql);
$hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
if ($hidden_menu_ids) {
$hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
$inDB->query("UPDATE cms_modules SET hidden_menu_ids='{$hidden_menu_ids}' WHERE id = '{$id}' LIMIT 1");
}
} else {
示例9: registerFields
/**
* Регистрирует поля подлежащие переводу
* @param str $target Цель
* @param array $fields массив подлежащих переводу полей и их типов 'поле'=>'str|html'
*/
public static function registerFields($target, $fields)
{
cmsDatabase::getInstance()->insert('cms_translations_fields', array('target' => $target, 'fields' => cmsCore::arrayToYaml($fields)), true);
}
示例10: applet_modules
//.........这里部分代码省略.........
}
cmsCore::halt('1');
} else {
cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '1');
cmsCore::redirectBack();
}
}
if ($do == 'hide') {
if (!isset($_REQUEST['item'])) {
if ($id >= 0) {
cmsCore::c('db')->setFlag('cms_modules', $id, 'published', '0');
}
cmsCore::halt('1');
} else {
cmsCore::c('db')->setFlags('cms_modules', $_REQUEST['item'], 'published', '0');
cmsCore::redirectBack();
}
}
if ($do == 'delete') {
if (!cmsCore::inRequest('item')) {
$inCore->removeModule($id);
} else {
$inCore->removeModule(cmsCore::request('item', 'array_int', array()));
}
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
cmsCore::redirect('index.php?view=modules');
}
if ($do == 'update') {
if (!cmsUser::checkCsrfToken()) {
cmsCore::error404();
}
$id = cmsCore::request('id', 'int', 0);
$mod = cmsCore::c('db')->get_fields('cms_modules', "id = " . $id . "", '*');
$module = array('name' => cmsCore::request('name', 'str', ''), 'title' => cmsCore::request('title', 'str', ''), 'titles' => cmsCore::arrayToYaml(cmsCore::request('titles', 'array_str', array())), 'position' => cmsCore::request('position', 'str', ''), 'showtitle' => cmsCore::request('showtitle', 'int', 0), 'published' => cmsCore::request('published', 'int', 0), 'css_prefix' => cmsCore::request('css_prefix', 'str', ''), 'is_strict_bind' => cmsCore::request('is_strict_bind', 'int', 0), 'is_strict_bind_hidden' => cmsCore::request('is_strict_bind_hidden', 'int', 0), 'template' => cmsCore::request('template', 'str', ''), 'cache' => cmsCore::request('cache', 'int', 0), 'cachetime' => cmsCore::request('cachetime', 'int', 0), 'cacheint' => cmsCore::request('cacheint', 'str', ''), 'access_list' => '', 'hidden_menu_ids' => '');
if (!$mod['is_external']) {
$module['content'] = cmsCore::c('db')->escape_string(cmsCore::request('content', 'html', ''));
}
$is_public = cmsCore::request('is_public', 'int', '');
if (!$is_public) {
$module['access_list'] = cmsCore::arrayToYaml(cmsCore::request('allow_group', 'array_int', array()));
}
cmsCore::c('db')->update('cms_modules', $module, $id);
cmsCore::c('db')->delete('cms_modules_bind', "module_id=" . $id . " AND tpl='" . cmsCore::c('config')->template . "'");
if (cmsCore::request('show_all', 'int', 0)) {
cmsCore::c('db')->insert('cms_modules_bind', array('module_id' => $id, 'menu_id' => 0, 'position' => $module['position'], 'tpl' => cmsCore::c('config')->template));
$hidden_menu_ids = cmsCore::request('hidden_menu_ids', 'array_int', array());
if (!empty($hidden_menu_ids)) {
$hidden_menu_ids = cmsCore::arrayToYaml($hidden_menu_ids);
cmsCore::c('db')->query("UPDATE cms_modules SET hidden_menu_ids='" . $hidden_menu_ids . "' WHERE id = '" . $id . "' LIMIT 1");
}
} else {
$showin = cmsCore::request('showin', 'array_int', array());
$showpos = cmsCore::request('showpos', 'array_str', array());
if (count($showin) > 0) {
foreach ($showin as $key => $value) {
cmsCore::c('db')->insert('cms_modules_bind', array('module_id' => $id, 'menu_id' => $value, 'position' => $showpos[$value], 'tpl' => cmsCore::c('config')->template));
}
}
}
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS'], 'success');
if (!isset($_SESSION['editlist']) || count($_SESSION['editlist']) == 0) {
cmsCore::redirect('index.php?view=modules');
} else {
cmsCore::redirect('index.php?view=modules&do=edit');
}
}
示例11: catalog
//.........这里部分代码省略.........
if(!$cat){ cmsCore::error404(); }
if ($opt == 'add'){
if(!$inUser->is_admin &&
!$model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id)){
cmsCore::error404();
}
} else {
$item = $inDB->get_fields('cms_uc_items', "id='{$item_id}'", '*');
if(!$item){ cmsCore::error404(); }
if(!$inUser->is_admin &&
!($cat['can_edit'] && ($inUser->id == $item['user_id']) &&
$model->checkCategoryAccess($cat['id'], $cat['is_public'], $inUser->group_id))){
cmsCore::error404();
}
}
$item['title'] = cmsCore::request('title', 'str');
if (!$item['title']) { cmsCore::addSessionMessage($_LANG['NEED_TITLE'], 'error'); cmsCore::redirectBack(); }
$item['category_id'] = $cat_id;
$item['published'] = ($cfg['premod'] && !$inUser->is_admin ? 0 : 1);
$item['on_moderate'] = ($cfg['premod'] && !$inUser->is_admin ? 1 : 0);
$item['fdata'] = cmsCore::request('fdata', 'array', array());;
foreach($item['fdata'] as $key=>$value) {
$item['fdata'][$key] = cmsCore::badTagClear($value);
}
$item['fieldsdata'] = $inDB->escape_string(cmsCore::arrayToYaml($item['fdata']));
$item['is_comments'] = $inUser->is_admin ? cmsCore::request('is_comments', 'int', 0) : $cfg['is_comments'];
$item['tags'] = cmsCore::request('tags', 'str', '');
$item['canmany'] = 1;
$item['imageurl'] = ($opt == 'add' ? '' : $item['imageurl']);
$item['price'] = 0;
$item['canmany'] = 1;
if($inUser->is_admin){
$meta_desc = cmsCore::request('meta_desc', 'str', '');
$meta_keys = cmsCore::request('meta_keys', 'str', '');
$item['meta_desc'] = $meta_desc ? $meta_desc : $item['title'];
$item['meta_keys'] = $meta_keys ? $meta_keys : $item['tags'];
} else {
$item['meta_desc'] = @$item['meta_desc'] ? $item['meta_desc'] : $item['title'];
$item['meta_keys'] = @$item['meta_keys'] ? $item['meta_keys'] : $item['tags'];
}
if (cmsCore::inRequest('price')) {
$price = cmsCore::request('price', 'str', '');
$price = str_replace(',', '.', $price);
$item['price'] = round($price, 2);
$item['canmany']= cmsCore::request('canmany', 'int', 0);
}
if (cmsCore::request('delete_img', 'int', 0)){
@unlink(PATH."/images/catalog/".$item['imageurl']);
@unlink(PATH."/images/catalog/small/".$item['imageurl']);
@unlink(PATH."/images/catalog/medium/".$item['imageurl']);
$item['imageurl'] = '';
示例12: while
$plg_nconfig = cmsCore::arrayToYaml($plg_nconfig);
cmsCore::c('db')->query("UPDATE cms_plugins SET config='". cmsCore::c('db')->escape_string($plg_nconfig) ."' WHERE plugin='p_content_imgs' LIMIT 1");
}
// ========== /p_content_imgs =========
//======================================================================
// --------------- Добавляем всем модулям настройку tpl ----------------
$results = cmsCore::c('db')->query('SELECT id, content, config FROM cms_modules WHERE is_external = 1');
while ($mod = cmsCore::c('db')->fetch_assoc($results)) {
$mod['config'] = cmsCore::yamlToArray($mod['config']);
if (empty($mod['config']['tpl'])) {
$mod['config']['tpl'] = $mod['content'];
}
$mod['config'] = cmsCore::arrayToYaml($mod['config']);
cmsCore::c('db')->update(
'cms_modules',
array(
'config' => cmsCore::c('db')->escape_string($mod['config'])
),
$mod['id']
);
}
//======================================================================
$last_user_menu = cmsCore::c('db')->get_fields('cms_modules', "title = 'Меню пользователя' AND content = 'mod_usermenu'", '*');
if (!empty($last_user_menu)) {
cmsCore::c('db')->query("UPDATE `cms_modules` SET
`position` = '". $last_user_menu['position'] ."',
示例13: unset
}
$type = $fields[$field];
// получаем все данные по $target_id и $target
$translation = translations::getTranslation($lang, $target, $target_id);
// получаем текущее значение поля
if ($translation && isset($translation['data'][$field])) {
$value = $translation['data'][$field];
} else {
$value = '';
}
if (cmsCore::inRequest('save')) {
if (!cmsUser::checkCsrfToken()) {
cmsCore::halt();
}
$field_data = cmsCore::request('field_data', $type, '');
// если есть запись, обновляем
if ($translation) {
if ($field_data) {
$translation['data'][$field] = $field_data;
}
if (!$field_data && isset($translation['data'][$field])) {
unset($translation['data'][$field]);
}
$inDB->update('cms_translations', array('data' => $inDB->escape_string(cmsCore::arrayToYaml($translation['data']))), $translation['id']);
} else {
$inDB->insert('cms_translations', array('data' => $inDB->escape_string(cmsCore::arrayToYaml(array($field => $field_data))), 'lang' => $lang, 'fieldsset_id' => translations::getFieldsetId($target), 'target_id' => $target_id));
}
cmsCore::halt();
} else {
cmsPage::includeTemplateFile('admin/translations.php', array('type' => $type, 'value' => $value, 'action' => $_SERVER['REQUEST_URI']));
}
示例14: while
case 'menu':
$item['config']['items'] = cmsCore::request('f_menu_list', 'str', '');
$item['config']['size'] = cmsCore::request('f_menu_size', 'int');
break;
case 'file':
$exts = cmsCore::request('f_file_ext', 'str', '');
while (mb_strpos($exts, 'htm') || mb_strpos($exts, 'php') || mb_strpos($exts, 'ht')) {
$exts = str_replace(array('htm', 'php', 'ht'), '', mb_strtolower($exts));
}
$item['config']['ext'] = str_replace(' ', '', $exts);
$item['config']['size'] = cmsCore::request('f_file_size', 'int');
break;
}
$item['config'] = $inDB->escape_string(cmsCore::arrayToYaml($item['config']));
if (!cmsCore::request('is_public', 'int', 0)) {
$item['show_for_group'] = cmsCore::arrayToYaml(cmsCore::request('show_for_group', 'array_int'));
} else {
$item['show_for_group'] = '';
}
if ($opt == 'add_field') {
$inDB->insert('cms_form_fields', cmsCore::callEvent('ADD_FORM_FIELD', $item));
} else {
$inDB->update('cms_form_fields', cmsCore::callEvent('UPDATE_FORM_FIELD', $item), cmsCore::request('field_id', 'int'));
}
cmsCore::addSessionMessage($_LANG['AD_DO_SUCCESS']);
cmsCore::redirect('?view=components&do=config&id=' . $id . '&opt=edit&item_id=' . $item['form_id']);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (in_array($opt, array('submit', 'update'))) {
if (!cmsUser::checkCsrfToken()) {
cmsCore::error404();
示例15: setModCfgs
/**
* Обновляет конфигурацию модулей
*/
public function setModCfgs() {
if (!empty($this->cfg['mod_cfgs'])) {
foreach ($this->cfg['mod_cfgs'] as $mod) {
$results = cmsCore::c('db')->query("SELECT id,config FROM cms_modules WHERE content='". $mod['name'] ."'");
if (!cmsCore::c('db')->num_rows($results)) { continue; }
while ($module = cmsCore::c('db')->fetch_assoc($results)) {
if (!empty($module['config'])) {
$module['config'] = cmsCore::yamlToArray($module['config']);
if (!empty($mod['unset_keys'])) {
foreach ($mod['unset_keys'] as $key) {
unset($module['config'][$key]);
}
}
} else {
$module['config'] = array();
}
if (!empty($mod['merge_cfgs'])) {
$module['config'] = array_merge($mod['merge_cfgs'], $module['config']);
}
$module['config'] = cmsCore::arrayToYaml($module['config']);
cmsCore::c('db')->update(
'cms_modules',
array(
'config' => cmsCore::c('db')->escape_string($module['config'])
),
$module['id']
);
}
}
}
}