本文整理汇总了PHP中cmsForm类的典型用法代码示例。如果您正苦于以下问题:PHP cmsForm类的具体用法?PHP cmsForm怎么用?PHP cmsForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了cmsForm类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$template = cmsTemplate::getInstance();
$config = cmsConfig::getInstance();
$user = cmsUser::getInstance();
$contact_id = $this->request->get('contact_id') or cmsCore::error404();
$content = $this->request->get('content') or cmsCore::error404();
$csrf_token = $this->request->get('csrf_token');
// Проверяем валидность
$is_valid = is_numeric($contact_id) && cmsForm::validateCSRFToken($csrf_token, false);
if (!$is_valid) {
$result = array('error' => true, 'message' => '');
$template->renderJSON($result);
}
$contact = $this->model->getContact($user->id, $contact_id);
// Контакт существует?
if (!$contact) {
$result = array('error' => true, 'message' => '');
$template->renderJSON($result);
}
// Контакт не в игноре у отправителя?
if ($contact['is_ignored']) {
$result = array('error' => true, 'message' => LANG_PM_CONTACT_IS_IGNORED);
$template->renderJSON($result);
}
// Отправитель не в игноре у контакта?
if ($this->model->isContactIgnored($contact_id, $user->id)) {
$result = array('error' => true, 'message' => LANG_PM_YOU_ARE_IGNORED);
$template->renderJSON($result);
}
// Контакт принимает сообщения от этого пользователя?
if (!$user->isPrivacyAllowed($contact, 'messages_pm')) {
$result = array('error' => true, 'message' => LANG_PM_CONTACT_IS_PRIVATE);
$template->renderJSON($result);
}
//
// Отправляем сообщение
//
$content_html = cmsEventsManager::hook('html_filter', $content);
if (!$content_html) {
$template->renderJSON(array('error' => false, 'date' => false, 'message' => false));
}
$this->setSender($user->id);
$this->addRecipient($contact_id);
$message_id = $this->sendMessage($content_html);
//
// Отправляем уведомление на почту
//
$user_to = cmsCore::getModel('users')->getUser($contact_id);
if (!$user_to['is_online']) {
$this->sendNoticeEmail('messages_new');
}
//
// Получаем и рендерим добавленное сообщение
//
$message = $this->model->getMessage($message_id);
$message_html = $template->render('message', array('messages' => array($message), 'user' => $user), new cmsRequest(array(), cmsRequest::CTX_INTERNAL));
// Результат
$template->renderJSON(array('error' => false, 'date' => date($config->date_format, time()), 'message' => $message_html));
}
开发者ID:asphix,项目名称:icms2,代码行数:60,代码来源:send.php
示例2: run
public function run($group)
{
if (!cmsUser::isAllowed('groups', 'delete')) {
cmsCore::error404();
}
if (!cmsUser::isAllowed('groups', 'delete', 'all') && $group['owner_id'] != $this->cms_user->id) {
cmsCore::error404();
}
if ($this->request->has('submit')) {
// подтвержение получено
$csrf_token = $this->request->get('csrf_token', '');
$is_delete_content = $this->request->get('is_delete_content', 0);
if (!cmsForm::validateCSRFToken($csrf_token)) {
cmsCore::error404();
}
list($group, $is_delete_content) = cmsEventsManager::hook('group_before_delete', array($group, $is_delete_content));
$this->model->removeContentFromGroup($group['id'], $is_delete_content);
$this->model->deleteGroup($group);
cmsUser::addSessionMessage(sprintf(LANG_GROUPS_DELETED, $group['title']));
$this->redirectToAction('');
} else {
// спрашиваем подтверждение
return $this->cms_template->render('group_delete', array('user' => $this->cms_user, 'group' => $group));
}
}
开发者ID:Val-Git,项目名称:icms2,代码行数:25,代码来源:group_delete.php
示例3: insertForm
function insertForm($form_title){
cmsCore::loadClass('form');
return cmsForm::displayForm(trim($form_title), array(), false);
}
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:7,代码来源:filter.php
示例4: run
public function run($profile)
{
$user = cmsUser::getInstance();
$template = cmsTemplate::getInstance();
// проверяем наличие доступа
if ($profile['id'] != $user->id && !$user->is_admin) {
cmsCore::error404();
}
$pricacy_types = cmsEventsManager::hookAll('user_privacy_types');
$form = new cmsForm();
$fieldset_id = $form->addFieldset();
$default_options = array('', 'anyone', 'friends');
foreach ($pricacy_types as $list) {
foreach ($list as $name => $type) {
$options = array();
if (!isset($type['options'])) {
$type['options'] = $default_options;
}
foreach ($type['options'] as $option) {
if (!$option) {
$options[''] = LANG_USERS_PRIVACY_FOR_NOBODY;
} else {
$options[$option] = constant('LANG_USERS_PRIVACY_FOR_' . mb_strtoupper($option));
}
}
$form->addField($fieldset_id, new fieldList($name, array('title' => $type['title'], 'default' => 'anyone', 'items' => $options)));
}
}
// Форма отправлена?
$is_submitted = $this->request->has('submit');
$options = $this->model->getUserPrivacyOptions($profile['id']);
if ($is_submitted) {
// Парсим форму и получаем поля записи
$options = array_merge($options, $form->parse($this->request, $is_submitted, $options));
// Проверям правильность заполнения
$errors = $form->validate($this, $options);
if (!$errors) {
// Обновляем профиль и редиректим на его просмотр
$this->model->updateUserPrivacyOptions($profile['id'], $options);
$this->redirectTo('users', $profile['id']);
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return $template->render('profile_edit_privacy', array('id' => $profile['id'], 'profile' => $profile, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
开发者ID:asphix,项目名称:icms2,代码行数:47,代码来源:profile_edit_privacy.php
示例5: run
public function run($friend_id)
{
if (!cmsUser::isLogged()) {
cmsCore::error404();
}
$user = cmsUser::getInstance();
if (!$friend_id) {
cmsCore::error404();
}
if ($user->isFriend($friend_id)) {
return false;
}
$friend = $this->model->getUser($friend_id);
if (!$friend) {
cmsCore::error404();
}
//
// Запрос по ссылке из профиля
//
if ($this->request->isStandard()) {
//
// Если запрос от друга уже существует
//
if ($this->model->isFriendshipRequested($friend_id, $user->id)) {
$this->model->addFriendship($user->id, $friend_id);
cmsUser::addSessionMessage(sprintf(LANG_USERS_FRIENDS_DONE, $friend['nickname']), 'success');
$this->sendNoticeAccepted($friend);
$this->redirectToAction($friend_id);
}
//
// Если запроса от друга не было
//
if ($this->request->has('submit')) {
// подтвержение получено
$csrf_token = $this->request->get('csrf_token');
if (!cmsForm::validateCSRFToken($csrf_token)) {
cmsCore::error404();
}
$this->model->addFriendship($user->id, $friend_id);
cmsUser::addSessionMessage(LANG_USERS_FRIENDS_SENT);
$this->sendNoticeRequest($friend);
$this->redirectToAction($friend_id);
} else {
// спрашиваем подтверждение
return cmsTemplate::getInstance()->render('friend_add', array('user' => $user, 'friend' => $friend));
}
}
//
// Запрос из уведомления (внутренний)
//
if ($this->request->isInternal()) {
$this->model->addFriendship($user->id, $friend_id);
$this->sendNoticeAccepted($friend);
return true;
}
}
开发者ID:asphix,项目名称:icms2,代码行数:56,代码来源:friend_add.php
示例6: uploadImage
public function uploadImage()
{
$csrf_token = $this->request->get('csrf_token', '');
if (!cmsForm::validateCSRFToken($csrf_token)) {
return $this->cms_template->renderPlain('upload', array('allowed_extensions' => $this->allowed_extensions, 'error' => LANG_FORM_ERRORS));
}
$result = $this->images_controller->uploadWithPreset('image', 'wysiwyg_live');
if (!$result['success']) {
return $this->cms_template->renderPlain('upload', array('allowed_extensions' => $this->images_controller->getAllowedExtensions(), 'error' => $result['error']));
}
return $this->cms_template->renderPlain('image', array('url' => $result['image']['url']));
}
开发者ID:Val-Git,项目名称:icms2,代码行数:12,代码来源:frontend.php
示例7: run
public function run($profile)
{
// проверяем наличие доступа
if ($profile['id'] != $this->cms_user->id) {
cmsCore::error404();
}
// Форма отправлена?
$is_submitted = $this->request->has('submit');
if (!$is_submitted && !$profile['invites_count']) {
cmsCore::error404();
}
$form = new cmsForm();
$fieldset_id = $form->addFieldset();
if ($profile['invites_count'] > 1) {
$form->addField($fieldset_id, new fieldText('emails', array('title' => LANG_USERS_INVITES_EMAILS, 'hint' => LANG_USERS_INVITES_EMAILS_HINT, 'rules' => array(array('required')))));
}
if ($profile['invites_count'] == 1) {
$form->addField($fieldset_id, new fieldString('emails', array('title' => LANG_USERS_INVITES_EMAIL, 'rules' => array(array('required'), array('email')))));
}
$input = array();
if ($is_submitted) {
// Парсим форму и получаем поля записи
$input = $form->parse($this->request, $is_submitted);
// Проверям правильность заполнения
$errors = $form->validate($this, $input);
if (!$errors) {
$results = $this->sendInvites($profile, $input['emails']);
return $this->cms_template->render('profile_invites_results', array('id' => $profile['id'], 'profile' => $profile, 'results' => $results));
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return $this->cms_template->render('profile_invites', array('id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'input' => $input, 'errors' => isset($errors) ? $errors : false));
}
开发者ID:Val-Git,项目名称:icms2,代码行数:35,代码来源:profile_invites.php
示例8: run
public function run($ctype_id, $parent_id)
{
$items = $this->request->get('selected');
$is_submitted = $this->request->has('items');
$template = cmsTemplate::getInstance();
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentType($ctype_id);
$fields = $content_model->getContentFields($ctype['name']);
$form = new cmsForm();
$fieldset_id = $form->addFieldset(LANG_MOVE_TO_CATEGORY);
$form->addField($fieldset_id, new fieldList('category_id', array('default' => $parent_id, 'generator' => function ($data) {
$content_model = cmsCore::getModel('content');
$tree = $content_model->getCategoriesTree($data['ctype_name']);
foreach ($tree as $c) {
$items[$c['id']] = str_repeat('- ', $c['ns_level']) . ' ' . $c['title'];
}
return $items;
})));
$form->addField($fieldset_id, new fieldHidden('items'));
$data = $form->parse($this->request, $is_submitted);
if ($is_submitted) {
// Проверяем правильность заполнения
$errors = $form->validate($this, $data);
if (!$errors) {
$data['items'] = explode(',', $data['items']);
$content_model->moveContentItemsToCategory($ctype, $data['category_id'], $data['items'], $fields);
$template->renderJSON(array('errors' => false, 'callback' => 'contentItemsMoved'));
}
if ($errors) {
$template->renderJSON(array('errors' => true));
}
$this->halt();
}
return $template->render('content_item_move', array('ctype' => $ctype, 'parent_id' => $parent_id, 'items' => $items, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
开发者ID:rookees,项目名称:icms2,代码行数:35,代码来源:content_item_move.php
示例9: save_controller_options
function save_controller_options($controllers)
{
foreach ($controllers as $controller) {
$controller_root_path = cmsConfig::get('root_path') . 'system/controllers/' . $controller . '/';
$form_file = $controller_root_path . 'backend/forms/form_options.php';
$form_name = $controller . 'options';
cmsCore::loadControllerLanguage($controller);
$form = cmsForm::getForm($form_file, $form_name, false);
if ($form) {
$options = $form->parse(new cmsRequest(cmsController::loadOptions($controller)));
cmsCore::getModel('content')->filterEqual('name', $controller)->updateFiltered('controllers', array('options' => $options));
}
}
}
开发者ID:Val-Git,项目名称:icms2,代码行数:14,代码来源:install.php
示例10: componentUpdate
private function componentUpdate($manifest)
{
$model = new cmsModel();
$controller_root_path = $this->cms_config->root_path . 'system/controllers/' . $manifest['package']['name'] . '/';
$form_file = $controller_root_path . 'backend/forms/form_options.php';
$form_name = $manifest['package']['name'] . 'options';
cmsCore::loadControllerLanguage($manifest['package']['name']);
$form = cmsForm::getForm($form_file, $form_name, false);
if ($form) {
$options = $form->parse(new cmsRequest(cmsController::loadOptions($manifest['package']['name'])));
} else {
$options = null;
}
$model->filterEqual('name', $manifest['package']['name'])->updateFiltered('controllers', array('title' => $manifest['info']['title'], 'options' => $options, 'author' => isset($manifest['author']['name']) ? $manifest['author']['name'] : LANG_CP_PACKAGE_NONAME, 'url' => isset($manifest['author']['url']) ? $manifest['author']['url'] : null, 'version' => $manifest['version']['major'] . '.' . $manifest['version']['minor'] . '.' . $manifest['version']['build'], 'is_backend' => file_exists($controller_root_path . 'backend.php')));
return 'controllers';
}
开发者ID:Val-Git,项目名称:icms2,代码行数:16,代码来源:install_finish.php
示例11: init
public function init($do)
{
return array('basic' => array('type' => 'fieldset', 'childs' => array(new fieldString('name', array('title' => LANG_SYSTEM_NAME, 'rules' => array(array('required'), array('sysname'), array('max_length', 20), $do == 'add' ? array('unique_field') : false))), new fieldString('title', array('title' => LANG_CP_FIELD_TITLE, 'rules' => array(array('required'), array('max_length', 100)))), new fieldString('hint', array('title' => LANG_CP_FIELD_HINT, 'rules' => array(array('max_length', 255)))))), 'type' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_TYPE, 'childs' => array(new fieldList('type', array('default' => 'string', 'generator' => function () {
$field_types = array();
$field_types = cmsForm::getAvailableFormFields();
return $field_types;
})))), 'group' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_FIELDSET, 'childs' => array(new fieldList('fieldset', array('title' => LANG_CP_FIELD_FIELDSET_SELECT, 'generator' => function ($field) {
$model = cmsCore::getModel('content');
$model->setTablePrefix('');
$fieldsets = $model->getContentFieldsets('users');
$items = array('');
foreach ($fieldsets as $fieldset) {
$items[$fieldset] = $fieldset;
}
return $items;
})), new fieldString('new_fieldset', array('title' => LANG_CP_FIELD_FIELDSET_ADD, 'rules' => array(array('max_length', 100)))))), 'visibility' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_VISIBILITY, 'childs' => array(new fieldCheckbox('is_in_filter', array('title' => LANG_CP_FIELD_IN_FILTER)))), 'labels' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_LABELS, 'childs' => array(new fieldList('options:label_in_item', array('title' => LANG_CP_FIELD_LABELS_IN_ITEM, 'default' => 'left', 'items' => array('left' => LANG_CP_FIELD_LABEL_LEFT, 'top' => LANG_CP_FIELD_LABEL_TOP, 'none' => LANG_CP_FIELD_LABEL_NONE))))), 'format' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_FORMAT, 'childs' => array(new fieldCheckbox('options:is_required', array('title' => LANG_VALIDATE_REQUIRED)), new fieldCheckbox('options:is_digits', array('title' => LANG_VALIDATE_DIGITS)), new fieldCheckbox('options:is_alphanumeric', array('title' => LANG_VALIDATE_ALPHANUMERIC)), new fieldCheckbox('options:is_email', array('title' => LANG_VALIDATE_EMAIL)))), 'values' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_VALUES, 'childs' => array(new fieldText('values', array('size' => 8)))), 'read_access' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_GROUPS_READ, 'childs' => array(new fieldListGroups('groups_read', array('show_all' => true)))), 'edit_access' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_GROUPS_EDIT, 'childs' => array(new fieldListGroups('groups_edit', array('show_all' => true)))));
}
开发者ID:asphix,项目名称:icms2,代码行数:17,代码来源:form_field.php
示例12: run
public function run($friend_id)
{
if (!cmsUser::isLogged()) {
cmsCore::error404();
}
$user = cmsUser::getInstance();
if (!$friend_id) {
cmsCore::error404();
}
if (!$this->model->isFriendshipExists($user->id, $friend_id)) {
return false;
}
$friend = $this->model->getUser($friend_id);
if (!$friend) {
cmsCore::error404();
}
//
// Запрос по ссылке из профиля
//
if ($this->request->isStandard()) {
if ($this->request->has('submit')) {
// подтвержение получено
$csrf_token = $this->request->get('csrf_token');
if (!cmsForm::validateCSRFToken($csrf_token)) {
cmsCore::error404();
}
$this->model->deleteFriendship($user->id, $friend_id);
cmsUser::addSessionMessage(sprintf(LANG_USERS_FRIENDS_DELETED, $friend['nickname']));
$this->sendNoticeDeleted($friend);
$this->redirectToAction($friend_id);
} else {
// спрашиваем подтверждение
return cmsTemplate::getInstance()->render('friend_delete', array('user' => $user, 'friend' => $friend));
}
}
//
// Запрос из уведомления (внутренний)
//
if ($this->request->isInternal()) {
$this->model->deleteFriendship($user->id, $friend_id);
$this->sendNoticeDeleted($friend, true);
return true;
}
}
开发者ID:asphix,项目名称:icms2,代码行数:44,代码来源:friend_delete.php
示例13: uploadImage
public function uploadImage()
{
$template = cmsTemplate::getInstance();
$csrf_token = $this->request->get('csrf_token');
if (!cmsForm::validateCSRFToken($csrf_token)) {
$html = $template->render('upload', array('allowed_extensions' => $this->allowed_extensions, 'error' => LANG_FORM_ERRORS));
echo $html;
$this->halt();
}
$images_controller = cmsCore::getController('images');
$result = $images_controller->uploadWithPreset('image', 'wysiwyg_live');
if (!$result['success']) {
$html = $template->render('upload', array('allowed_extensions' => $images_controller->getAllowedExtensions(), 'error' => $result['error']));
echo $html;
$this->halt();
}
$html = $template->render('image', array('url' => $result['image']['url']));
echo $html;
$this->halt();
}
开发者ID:asphix,项目名称:icms2,代码行数:20,代码来源:frontend.php
示例14: init
public function init($do, $ctype_name)
{
$model = cmsCore::getModel('content');
return array('basic' => array('type' => 'fieldset', 'childs' => array(new fieldString('name', array('title' => LANG_SYSTEM_NAME, 'hint' => $do == 'edit' ? LANG_SYSTEM_EDIT_NOTICE : false, 'rules' => array(array('required'), array('sysname'), array('max_length', 20), $do == 'add' ? array('unique_ctype_field', $ctype_name) : false))), new fieldString('title', array('title' => LANG_CP_FIELD_TITLE, 'rules' => array(array('required'), array('max_length', 100)))), new fieldString('hint', array('title' => LANG_CP_FIELD_HINT, 'rules' => array(array('max_length', 255)))))), 'type' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_TYPE, 'childs' => array(new fieldList('type', array('default' => 'string', 'generator' => function () {
$field_types = array();
$field_types = cmsForm::getAvailableFormFields();
asort($field_types, SORT_STRING);
return $field_types;
})))), 'group' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_FIELDSET, 'childs' => array(new fieldList('fieldset', array('title' => LANG_CP_FIELD_FIELDSET_SELECT, 'generator' => function ($field) use($model) {
$fieldsets = $model->getContentFieldsets($field['ctype_id']);
$items = array('');
foreach ($fieldsets as $fieldset) {
$items[$fieldset] = $fieldset;
}
return $items;
})), new fieldString('new_fieldset', array('title' => LANG_CP_FIELD_FIELDSET_ADD, 'rules' => array(array('max_length', 100)))))), 'visibility' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_VISIBILITY, 'childs' => array(new fieldCheckbox('is_in_item', array('title' => LANG_CP_FIELD_IN_ITEM, 'default' => true)), new fieldCheckbox('is_in_list', array('title' => LANG_CP_FIELD_IN_LIST)), new fieldCheckbox('is_in_filter', array('title' => LANG_CP_FIELD_IN_FILTER)))), 'labels' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_LABELS, 'childs' => array(new fieldList('options:label_in_list', array('title' => LANG_CP_FIELD_LABELS_IN_LIST, 'default' => 'left', 'items' => array('left' => LANG_CP_FIELD_LABEL_LEFT, 'top' => LANG_CP_FIELD_LABEL_TOP, 'none' => LANG_CP_FIELD_LABEL_NONE))), new fieldList('options:label_in_item', array('title' => LANG_CP_FIELD_LABELS_IN_ITEM, 'default' => 'left', 'items' => array('left' => LANG_CP_FIELD_LABEL_LEFT, 'top' => LANG_CP_FIELD_LABEL_TOP, 'none' => LANG_CP_FIELD_LABEL_NONE))))), 'wrap' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_WRAP, 'childs' => array(new fieldList('options:wrap_type', array('title' => LANG_CP_FIELD_WRAP_TYPE, 'default' => 'auto', 'items' => array('left' => LANG_CP_FIELD_WRAP_LTYPE, 'right' => LANG_CP_FIELD_WRAP_RTYPE, 'none' => LANG_CP_FIELD_WRAP_NTYPE, 'auto' => LANG_CP_FIELD_WRAP_ATYPE))), new fieldString('options:wrap_width', array('title' => LANG_CP_FIELD_WRAP_WIDTH, 'hint' => LANG_CP_FIELD_WRAP_WIDTH_HINT, 'default' => '')))), 'format' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_FORMAT, 'childs' => array(new fieldCheckbox('options:is_required', array('title' => LANG_VALIDATE_REQUIRED)), new fieldCheckbox('options:is_digits', array('title' => LANG_VALIDATE_DIGITS)), new fieldCheckbox('options:is_alphanumeric', array('title' => LANG_VALIDATE_ALPHANUMERIC)), new fieldCheckbox('options:is_email', array('title' => LANG_VALIDATE_EMAIL)), new fieldCheckbox('options:is_unique', array('title' => LANG_VALIDATE_UNIQUE)))), 'values' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_VALUES, 'childs' => array(new fieldText('values', array('size' => 8)))), 'profile' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_PROFILE_VALUE, 'childs' => array(new fieldList('options:profile_value', array('hint' => LANG_CP_FIELD_PROFILE_VALUE_HINT, 'generator' => function ($field) use($model) {
$model->setTablePrefix('');
// Ниже модель не используется
$fields = $model->filterIn('type', array('string', 'text', 'html', 'list', 'city'))->getContentFields('{users}');
$items = array('' => LANG_NO) + array_collection_to_list($fields, 'name', 'title');
return $items;
})))), 'read_access' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_GROUPS_READ, 'childs' => array(new fieldListGroups('groups_read', array('show_all' => true)))), 'edit_access' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_GROUPS_EDIT, 'childs' => array(new fieldListGroups('groups_edit', array('show_all' => true)))), 'filter_access' => array('type' => 'fieldset', 'title' => LANG_CP_FIELD_IN_FILTER, 'childs' => array(new fieldListGroups('filter_view', array('show_all' => true)))));
}
开发者ID:Val-Git,项目名称:icms2,代码行数:23,代码来源:form_ctypes_field.php
示例15: run
public function run($comment_id)
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$is_submit = $this->request->get('save', 0);
$comment = $this->model->getComment($comment_id);
if (!$is_submit) {
return $this->cms_template->render('backend/text_edit', array('comment' => $comment, 'action' => href_to($this->root_url, 'text_edit', array($comment['id']))));
}
$csrf_token = $this->request->get('csrf_token', '');
if (!cmsForm::validateCSRFToken($csrf_token) || !$comment) {
$this->cms_template->renderJSON(array('errors' => true));
}
$content = $this->request->get('content', '');
// Типографируем текст
$content_html = cmsEventsManager::hook('html_filter', $content);
if (!$content_html) {
$this->cms_template->renderJSON(array('errors' => array('content' => ERR_VALIDATE_REQUIRED)));
}
list($comment_id, $content, $content_html) = cmsEventsManager::hook('comment_before_update', array($comment_id, $content, $content_html));
$this->model->updateCommentContent($comment_id, $content, $content_html);
return $this->cms_template->renderJSON(array('errors' => false, 'callback' => 'successSaveComment', 'comment_id' => $comment_id, 'text' => string_short($content_html, 350)));
}
开发者ID:Val-Git,项目名称:icms2,代码行数:24,代码来源:text_edit.php
示例16: board
//.........这里部分代码省略.........
$info_text = $item['is_overdue'] ? $_LANG['ADV_IS_EXTEND'] : $_LANG['ADV_IS_MODER'];
cmsCore::addSessionMessage($info_text, 'info');
} else {
// увеличиваем кол-во просмотров
cmsCore::c('db')->setFlag('cms_board_items', cmsCore::m('board')->item_id, 'hits', $item['hits']+1);
}
// формируем заголовок и тело сообщения
$item['title'] = $item['obtype'].' '.$item['title'];
$item['content'] = nl2br($item['content']);
$item['content'] = cmsCore::m('board')->config['auto_link'] ? $inCore->parseSmiles($item['content']) : $item['content'];
$category_path = cmsCore::c('db')->getNsCategoryPath('cms_board_cats', $item['NSLeft'], $item['NSRight']);
if ($category_path) {
foreach ($category_path as $pcat) {
cmsCore::c('page')->addPathway($pcat['title'], '/board/'.$pcat['id']);
}
}
cmsCore::c('page')->addPathway($item['title']);
$pagetitle = $item['pagetitle'] ? $item['pagetitle'] : $item['title'];
$pagekeys = $item['meta_keys'] ? $item['meta_keys'] : $item['title'];
$pagedesc = $item['meta_desc'] ? $item['meta_desc'] : $item['content'];
cmsCore::c('page')->setTitle($pagetitle);
cmsCore::c('page')->setDescription(crop($pagedesc));
cmsCore::c('page')->setKeywords($pagekeys);
cmsPage::initTemplate('components', 'com_board_item')->
assign('item', $item)->
assign('cfg', cmsCore::m('board')->config)->
assign('user_id', cmsCore::c('user')->id)->
assign('is_admin', cmsCore::c('user')->is_admin)->
assign('formsdata', cmsForm::getFieldsValues($item['form_id'], $item['form_array']))->
assign('is_moder', cmsCore::m('board')->is_moderator_by_group)->
display();
}
/////////////////////////////// NEW BOARD ITEM /////////////////////////////////
if ($do == 'additem') {
// Получаем категории, в которые может загружать пользователь
$catslist = cmsCore::m('board')->getPublicCats(cmsCore::m('board')->category_id);
if (!$catslist) {
cmsCore::addSessionMessage($_LANG['YOU_CANT_ADD_ADV_ANY'], 'error');
$inCore->redirect('/board');
}
$cat['is_photos'] = 1;
$formsdata = array();
if (cmsCore::m('board')->category_id && cmsCore::m('board')->category_id != cmsCore::m('board')->root_cat['id']) {
$cat = cmsCore::m('board')->getCategory(cmsCore::m('board')->category_id);
$formsdata = cmsForm::getFieldsHtml($cat['form_id']);
}
cmsCore::c('page')->addPathway($_LANG['ADD_ADV']);
if ( !cmsCore::inRequest('submit') ) {
if (IS_BILLING) { cmsBilling::checkBalance('board', 'add_item'); }
cmsCore::c('page')->setTitle($_LANG['ADD_ADV']);
$item = cmsUser::sessionGet('item');
if ($item) { cmsUser::sessionDel('item'); }
$item['city'] = !empty($item['city']) ? $item['city'] : cmsCore::c('user')->city;
cmsPage::initTemplate('components', 'com_board_edit')->
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:67,代码来源:frontend.php
示例17: html_csrf_token
/**
* Возвращает скрытое поле, содержащее актуальный CSRF-токен
* @return string
*/
function html_csrf_token()
{
return html_input('hidden', 'csrf_token', cmsForm::getCSRFToken());
}
开发者ID:selimoves,项目名称:icms2,代码行数:8,代码来源:html.helper.php
示例18: getProfileOptionsForm
public function getProfileOptionsForm()
{
if (!$this->hasProfileThemesOptions()) {
return false;
}
$form_file = $this->path . '/profiles/options.form.php';
$form_name = 'template_profile_options';
$form = cmsForm::getForm($form_file, $form_name);
if (!$form) {
$form = new cmsForm();
}
return $form;
}
开发者ID:mafru,项目名称:icms2,代码行数:13,代码来源:template.php
示例19: getForm
/**
* Загружает и возвращает описание структуры формы
* @param type $form_name
* @param type $params
* @return cmsForm
*/
public function getForm($form_name, $params = false, $path_prefix = '')
{
$form_file = $this->root_path . $path_prefix . 'forms/form_' . $form_name . '.php';
$_form_name = $this->name . $form_name;
$form = cmsForm::getForm($form_file, $_form_name, $params);
list($form, $params) = cmsEventsManager::hook('form_' . $this->name . '_' . $form_name, array($form, $params));
return $form;
}
开发者ID:Val-Git,项目名称:icms2,代码行数:14,代码来源:controller.php
示例20: getItemForm
public function getItemForm($ctype, $fields, $action, $data = array(), $item_id = false, $item = false)
{
$user = cmsUser::getInstance();
// Контейнер для передачи дополнительных списков:
// $groups_list, $folders_list и т.д.
extract($data);
// Строим форму
$form = new cmsForm();
$fieldset_id = $form->addFieldset();
// Если включены категории, добавляем в форму поле выбора категории
if ($ctype['is_cats'] && ($action != 'edit' || $ctype['options']['is_cats_change'])) {
$fieldset_id = $form->addFieldset(LANG_CATEGORY, 'category');
$form->addField($fieldset_id, new fieldList('category_id', array('rules' => array(array('required')), 'generator' => function ($item) {
$content_model = cmsCore::getModel('content');
$ctype = $content_model->getContentTypeByName($item['ctype_name']);
$tree = $content_model->getCategoriesTree($item['ctype_name']);
$level_offset = 0;
$last_header_id = false;
$items = array('' => LANG_CONTENT_SELECT_CATEGORY);
if ($tree) {
foreach ($tree as $c) {
if ($ctype['options']['is_cats_only_last']) {
$dash_pad = $c['ns_level'] - 1 >= 0 ? str_repeat('-', $c['ns_level'] - 1) . ' ' : '';
if ($c['ns_right'] - $c['ns_left'] == 1) {
if ($last_header_id !== false && $last_header_id != $c['parent_id']) {
$items['opt' . $c['id']] = array(str_repeat('-', $c['ns_level'] - 1) . ' ' . $c['title']);
}
$items[$c['id']] = $dash_pad . $c['title'];
} else {
if ($c['parent_id'] > 0) {
$items['opt' . $c['id']] = array($dash_pad . $c['title']);
$last_header_id = $c['id'];
}
}
continue;
}
if (!$ctype['options']['is_cats_only_last']) {
if ($c['parent_id'] == 0 && !$ctype['options']['is_cats_open_root']) {
$level_offset = 1;
continue;
}
$items[$c['id']] = str_repeat('-- ', $c['ns_level'] - $level_offset) . ' ' . $c['title'];
continue;
}
}
}
return $items;
})));
if (cmsUser::isAllowed($ctype['name'], 'add_cat')) {
$form->addField($fieldset_id, new fieldString('new_category', array('title' => LANG_ADD_CATEGORY_QUICK)));
}
if (!empty($ctype['options']['is_cats_multi'])) {
$fieldset_id = $form->addFieldset(LANG_ADDITIONAL_CATEGORIES, 'multi_cats', array('is_empty' => true));
}
}
// Если включены личные папки, добавляем в форму поле выбора личной папки
if ($ctype['is_folders']) {
$fieldset_id = $form->addFieldset(LANG_FOLDER, 'folder');
$folders = array('0' => LANG_CONTENT_SELECT_FOLDER);
if ($folders_list) {
$folders = $folders + $folders_list;
}
$form->addField($fieldset_id, new fieldList('folder_id', array('items' => $folders)));
$form->addField($fieldset_id, new fieldString('new_folder', array('title' => LANG_ADD_FOLDER_QUICK)));
}
// Если есть поля-свойства, то добавляем область для них
if ($ctype['props']) {
$form->addFieldset('', 'props', array('is_empty' => true, 'class' => 'highlight'));
}
// Если этот контент можно создавать в группах (сообществах) то добавляем
// поле выбора группы
if ($action == 'add' && $groups_list && $groups_list != array('0' => '')) {
$fieldset_id = $form->addFieldset(LANG_GROUP);
$form->addField($fieldset_id, new fieldList('parent_id', array('items' => $groups_list)));
}
// Разбиваем поля по группам
$fieldsets = cmsForm::mapFieldsToFieldsets($fields, function ($field, $user) {
// пропускаем системные поля
if ($field['is_system']) {
return false;
}
// проверяем что группа пользователя имеет доступ к редактированию этого поля
if ($field['groups_edit'] && !$user->isInGroups($field['groups_edit'])) {
return false;
}
return true;
});
// Добавляем поля в форму
foreach ($fieldsets as $fieldset) {
$fieldset_id = $form->addFieldset($fieldset['title']);
foreach ($fieldset['fields'] as $field) {
// добавляем поле в форму
$form->addField($fieldset_id, $field['handler']);
}
}
//
// Если включены те
|
请发表评论