public function run($template_name) { $template = new cmsTemplate($template_name); if (!$template->hasOptions()) { cmsCore::error404(); } $form = $template->getOptionsForm(); // Форма отправлена? $is_submitted = $this->request->has('submit'); $options = $template->getOptions(); if ($is_submitted) { // Парсим форму и получаем поля записи $options = $form->parse($this->request, $is_submitted, $options); // Проверям правильность заполнения $errors = $form->validate($this, $options); if (!$errors) { $template->saveOptions($options); $this->redirectBack('settings'); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('settings_theme', array('template_name' => $template_name, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($template_name) { $template = new cmsTemplate($template_name); if (!$template->hasOptions()) { cmsCore::error404(); } $form = $template->getOptionsForm(); $options = $template->getOptions(); if ($this->request->has('submit')) { // Парсим форму и получаем поля записи $options = $form->parse($this->request, true, $options); // Проверям правильность заполнения $errors = $form->validate($this, $options); if (!$errors) { if ($template->saveOptions($options)) { cmsUser::addSessionMessage(LANG_CP_SAVE_SUCCESS, 'success'); } else { cmsUser::addSessionMessage(LANG_CP_SETTINGS_TPL_NOT_WRITABLE, 'error'); } $this->redirectToAction('settings'); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return $this->cms_template->render('settings_theme', array('template_name' => $template_name, 'options' => $options, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($id) { if (!$id) { cmsCore::error404(); } $form = $this->getForm('preset', array('edit')); $is_submitted = $this->request->has('submit'); $preset = $original_preset = $this->model->getPreset($id); if ($preset['is_internal']) { $form->removeFieldset('basic'); } if ($is_submitted) { $preset = $form->parse($this->request, $is_submitted); $errors = $form->validate($this, $preset); if (!$errors) { $this->model->updatePreset($id, $preset); $this->createDefaultImages(array_merge($original_preset, $preset)); $this->redirectToAction('presets'); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('backend/preset', array('do' => 'edit', 'preset' => $preset, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($tag_id) { if (!$tag_id) { cmsCore::error404(); } $tags_model = cmsCore::getModel('tags'); $form = $this->getForm('tag'); $is_submitted = $this->request->has('submit'); $tag = $tags_model->getTag($tag_id); $original_tag = $tag['tag']; if ($is_submitted) { $tag = $form->parse($this->request, $is_submitted); $errors = $form->validate($this, $tag); if ($original_tag == $tag['tag']) { $this->redirectToAction(); } if (!$errors) { $duplicate_id = $tags_model->getTagId($tag['tag']); if (!$duplicate_id) { $tags_model->updateTag($tag_id, $tag); } if ($duplicate_id) { $tags_model->mergeTags($tag_id, $duplicate_id); cmsUser::addSessionMessage(sprintf(LANG_TAGS_MERGED, $original_tag, $tag['tag']), 'success'); } $this->redirectToAction(); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('backend/tag', array('do' => 'edit', 'tag' => $tag, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($ctype_id) { if (!$ctype_id) { cmsCore::error404(); } $content_model = cmsCore::getModel('content'); $ctype = $content_model->getContentType($ctype_id); if (!$ctype) { cmsCore::error404(); } $form = $this->getForm('ctypes_dataset', array('add', $ctype['id'])); $is_submitted = $this->request->has('submit'); $fields = $content_model->getContentFields($ctype['name']); $dataset = array('sorting' => array(array('by' => 'date_pub', 'to' => 'desc'))); if ($is_submitted) { $dataset = $form->parse($this->request, $is_submitted); $dataset['filters'] = $this->request->get('filters'); $dataset['sorting'] = $this->request->get('sorting'); $errors = $form->validate($this, $dataset); if (!$errors) { $dataset_id = $content_model->addContentDataset($dataset, $ctype); if ($dataset_id) { cmsUser::addSessionMessage(sprintf(LANG_CP_DATASET_CREATED, $dataset['title']), 'success'); } $this->redirectToAction('ctypes', array('datasets', $ctype['id'])); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('ctypes_dataset', array('do' => 'add', 'ctype' => $ctype, 'dataset' => $dataset, 'fields' => $fields, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } $template = cmsTemplate::getInstance(); $entry_id = $this->request->get('id'); // Проверяем валидность $is_valid = is_numeric($entry_id); if (!$is_valid) { $result = array('error' => true, 'message' => LANG_ERROR); $template->renderJSON($result); } $user = cmsUser::getInstance(); $entry = $this->model->getEntry($entry_id); $replies = $this->model->getReplies($entry_id); if (!$replies) { $result = array('error' => true, 'message' => LANG_ERROR); $template->renderJSON($result); } $permissions = array('add' => $user->is_logged, 'delete' => $user->is_admin || $user->id == $entry['profile_id']); $html = $template->renderInternal($this, 'entry', array('entries' => $replies, 'user' => $user, 'permissions' => $permissions)); // Формируем и возвращаем результат $result = array('error' => false, 'html' => $html); $template->renderJSON($result); }
public function run($id) { if (!$id) { cmsCore::error404(); } $users_model = cmsCore::getModel('users'); $group = $users_model->getGroup($id); if (!$group) { cmsCore::error404(); } $controllers = cmsPermissions::getControllersWithRules(); $owners = array(); foreach ($controllers as $controller_name) { $controller = cmsCore::getController($controller_name); $subjects = $controller->getPermissionsSubjects(); $rules = cmsPermissions::getRulesList($controller_name); $values = array(); foreach ($subjects as $subject) { $values[$subject['name']] = cmsPermissions::getPermissions($subject['name']); } $owners[$controller_name] = array('subjects' => $subjects, 'rules' => $rules, 'values' => $values); } $template = cmsTemplate::getInstance(); $template->setMenuItems('users_group', array(array('title' => LANG_CONFIG, 'url' => href_to($this->name, 'users', array('group_edit', $id))), array('title' => LANG_PERMISSIONS, 'url' => href_to($this->name, 'users', array('group_perms', $id))))); return $template->render('users_group_perms', array('group' => $group, 'owners' => $owners)); }
public function run($id = false) { if (!$id) { cmsCore::error404(); } $widgets_model = cmsCore::getModel('widgets'); cmsCore::loadAllControllersLanguages(); $page = $widgets_model->getPage($id); if (!$page) { cmsCore::error404(); } $form = $this->getForm('widgets_page'); if (!$page['is_custom']) { $form->removeField('title', 'title'); } $is_submitted = $this->request->has('submit'); if ($is_submitted) { $page = $form->parse($this->request, $is_submitted); $errors = $form->validate($this, $page); if (!$errors) { $widgets_model->updatePage($id, $page); $this->redirectToAction('widgets'); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('widgets_page', array('do' => 'edit', 'page' => $page, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } if (!cmsUser::isAllowed('comments', 'edit')) { cmsCore::error404(); } $comment_id = $this->request->get('id'); // Проверяем валидность $is_valid = is_numeric($comment_id); if (!$is_valid) { $result = array('error' => true, 'message' => LANG_ERROR); cmsTemplate::getInstance()->renderJSON($result); } $user = cmsUser::getInstance(); $comment = $this->model->getComment($comment_id); if (!cmsUser::isAllowed('comments', 'edit', 'all')) { if (cmsUser::isAllowed('comments', 'edit', 'own') && $comment['user']['id'] != $user->id) { $result = array('error' => true, 'message' => LANG_ERROR); cmsTemplate::getInstance()->renderJSON($result); } } // Формируем и возвращаем результат $result = array('error' => $comment ? false : true, 'id' => $comment_id, 'html' => $comment ? string_strip_br($comment['content']) : false); cmsTemplate::getInstance()->renderJSON($result); }
public function run($pass_token) { if (!$pass_token) { cmsCore::error404(); } $users_model = cmsCore::getModel('users'); $profile = $users_model->getUserByPassToken($pass_token); if (!$profile) { cmsCore::error404(); } $form = $this->getForm('reset'); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $profile = array_merge($profile, $form->parse($this->request, $is_submitted)); $errors = $form->validate($this, $profile); if (!$errors) { $result = $users_model->updateUser($profile['id'], $profile); if ($result['success']) { cmsUser::addSessionMessage(LANG_PASS_CHANGED, 'success'); $users_model->clearUserPassToken($profile['id']); $this->redirectTo('users', $profile['id']); } else { $errors = $result['errors']; } } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('reset', array('profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($ctype_name = false) { $query = $this->request->get('q', false); $type = $this->request->get('type', 'words'); $date = $this->request->get('date', 'all'); $page = $this->request->get('page', 1); if (!in_array($type, array('words', 'exact'), true)) { cmsCore::error404(); } if (!in_array($date, array('all', 'w', 'm', 'y'), true)) { cmsCore::error404(); } if (!is_numeric($page)) { cmsCore::error404(); } if ($this->request->has('q')) { if (!$query) { $this->redirectToAction(''); } $results = $this->search($query, $type, $date, $ctype_name, $page); if ($results && !$ctype_name) { $ctype_name = $results[0]['name']; $page_url = href_to($this->name); } else { $page_url = href_to($this->name, 'index', $ctype_name); } } return cmsTemplate::getInstance()->render('index', array('query' => $query, 'type' => $type, 'date' => $date, 'ctype_name' => $ctype_name, 'page' => $page, 'perpage' => $this->options['perpage'], 'results' => isset($results) ? $results : false, 'page_url' => isset($page_url) ? $page_url : false)); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } $comment_id = $this->request->get('comment_id'); $score = $this->request->get('score'); // Проверяем валидность $is_valid = is_numeric($comment_id) && in_array($score, array(-1, 1)); $template = cmsTemplate::getInstance(); if (!$is_valid) { $template->renderJSON(array('error' => true)); } $user = cmsUser::getInstance(); $is_can_rate = cmsUser::isAllowed('comments', 'rate'); if (!$is_can_rate) { $template->renderJSON(array('error' => true)); } $is_voted = $this->model->isUserVoted($comment_id, $user->id); if ($is_voted) { $template->renderJSON(array('error' => true)); } $comment = $this->model->getComment($comment_id); if ($comment['user_id'] == $user->id) { $template->renderJSON(array('error' => true)); } $success = $this->model->rateComment($comment_id, $user->id, $score); $template->renderJSON(array('error' => !$success)); }
public function run($tab = 'all') { $user = cmsUser::getInstance(); $dataset_name = false; $datasets = $this->getDatasets(); if ($tab && isset($datasets[$tab])) { $dataset_name = $tab; $dataset = $datasets[$tab]; if (isset($dataset['filter']) && is_callable($dataset['filter'])) { $this->model = $dataset['filter']($this->model, $dataset); } } else { if ($tab) { cmsCore::error404(); } } // Сортировка if ($dataset_name) { $this->model->orderBy($datasets[$dataset_name]['order'][0], $datasets[$dataset_name]['order'][1]); } // Формируем базовые URL для страниц $page_url = array('base' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : ''), 'first' => href_to($this->name, $dataset_name ? 'index/' . $dataset_name : '')); // Получаем HTML списка записей $profiles_list_html = $this->renderProfilesList($page_url, $dataset_name); return cmsTemplate::getInstance()->render('index', array('datasets' => $datasets, 'dataset_name' => $dataset_name, 'dataset' => $dataset, 'user' => $user, 'profiles_list_html' => $profiles_list_html), $this->request); }
public function run() { if (!$this->getPackageContentsDir()) { $this->redirectToAction('install/finish'); } $form = $this->getForm('ftp'); $is_submitted = $this->request->has('submit'); $account = cmsUser::isSessionSet('ftp_account') ? cmsUser::sessionGet('ftp_account') : array(); if ($is_submitted) { $account = array_merge($account, $form->parse($this->request, $is_submitted, $account)); cmsUser::sessionSet('ftp_account', $account); $errors = $form->validate($this, $account); if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } if (!$errors) { $account['host'] = trim(str_replace('ftp://', '', $account['host']), '/'); if ($account['path'] != '/') { $account['path'] = '/' . trim($account['path'], '/') . '/'; } $this->uploadPackageToFTP($account); } } return cmsTemplate::getInstance()->render('install_ftp', array('account' => $account, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($feed_id) { if (!$feed_id) { cmsCore::error404(); } $rss_model = cmsCore::getModel('rss'); $feed = $rss_model->getFeed($feed_id); $ctype_id = $feed['ctype_id']; $content_model = cmsCore::getModel('content'); $fields = $content_model->getContentFields($feed['ctype_name']); $fields = array('' => '') + array_collection_to_list($fields, 'name', 'title'); $form = $this->getForm('feed', array($fields)); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $feed = $form->parse($this->request, $is_submitted); $errors = $form->validate($this, $feed); if (!$errors) { $rss_model->updateFeed($feed_id, $feed); $ctype = $content_model->getContentType($ctype_id); $ctype['options']['is_rss'] = $feed['is_enabled']; $content_model->updateContentType($ctype_id, array('options' => $ctype['options'])); $this->redirectToAction(); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('backend/edit', array('feed' => $feed, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run($photo_id = null) { if (!$this->request->isAjax()) { cmsCore::error404(); } if (!$photo_id) { $photo_id = $this->request->get('id'); if (!$photo_id) { cmsCore::error404(); } } $photo = $this->model->getPhoto($photo_id); $success = true; // проверяем наличие доступа $user = cmsUser::getInstance(); if (!cmsUser::isAllowed('albums', 'edit')) { $success = false; } if (!cmsUser::isAllowed('albums', 'edit', 'all') && $photo['user_id'] != $user->id) { $success = false; } if (!$success) { cmsTemplate::getInstance()->renderJSON(array('success' => false)); } $album = cmsCore::getModel('content')->getContentItem('albums', $photo['album_id']); $this->model->deletePhoto($photo_id); $this->model->setRandomAlbumCoverImage($photo['album_id']); cmsTemplate::getInstance()->renderJSON(array('success' => true, 'album_url' => href_to('albums', $album['slug'] . '.html'))); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } $orfo = $this->request->get('orfo'); $url = $this->request->get('url'); $comment = $this->request->get('comment', false); $author = !cmsUser::isLogged() ? cmsUser::getIp() : cmsUser::get('nickname'); $form = $this->getForm('orfo'); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $data = $form->parse($this->request, $is_submitted); $data['date'] = date('Y-m-d H:i:s'); $errors = $form->validate($this, $data); dump($errors); if (!$errors) { $this->model->addComplaints($data); $messenger = cmsCore::getController('messages'); $messenger->addRecipient(1); $notice = array('content' => sprintf(LANG_COMPLAINTS_ADD_NOTICE, $url, $orfo), 'options' => array('is_closeable' => true)); $messenger->ignoreNotifyOptions()->sendNoticePM($notice, 'complaints_add'); } cmsTemplate::getInstance()->renderJSON(array('errors' => false, 'callback' => 'formSuccess')); } $data = array('orfo' => $orfo, 'url' => $url, 'author' => $author, 'comment' => $comment); return cmsTemplate::getInstance()->render('orfo', array('form' => $form, 'data' => $data)); }
public function run($profile_id) { if (!cmsUser::isLogged()) { cmsCore::error404(); } if (!$this->request->isAjax()) { cmsCore::error404(); } $user = cmsUser::getInstance(); $direction = $this->request->get('direction'); $comment = $this->request->get('comment'); // // Проверяем валидность // $is_valid = $user->is_logged && cmsUser::isAllowed('users', 'vote_karma') && is_numeric($profile_id) && $user->id != $profile_id && in_array($direction, array('up', 'down')) && (!$this->options['is_karma_comments'] || $comment); if (!$is_valid) { $result = array('error' => true, 'message' => LANG_ERROR); cmsTemplate::getInstance()->renderJSON($result); } $profile = $this->model->getUser($profile_id); if (!$profile || !$this->model->isUserCanVoteKarma($user->id, $profile_id, $this->options['karma_time'])) { $result = array('error' => true, 'message' => LANG_ERROR); cmsTemplate::getInstance()->renderJSON($result); } // // Сохраняем оценку // $vote = array('user_id' => $user->id, 'profile_id' => $profile_id, 'points' => $direction == 'up' ? 1 : -1, 'comment' => $comment); $vote_id = $this->model->addKarmaVote($vote); $value = $profile['karma'] + $vote['points']; $result = array('error' => $vote_id ? false : true, 'value' => html_signed_num($value), 'css_class' => html_signed_class($value)); cmsTemplate::getInstance()->renderJSON($result); }
public function displayEditor($field_id, $content = '') { $lang = cmsConfig::get('language'); $user = cmsUser::getInstance(); cmsTemplate::getInstance()->addJS('wysiwyg/tinymce/tinymce.min.js'); $dom_id = str_replace(array('[', ']'), array('_', ''), $field_id); echo html_textarea($field_id, $content, array('id' => $dom_id)); ?> <script type="text/javascript" > $(document).ready(function(){ tinymce.init({mode : "exact", elements : "<?php echo $field_id; ?> ", language : "ru", plugins: [ "link image lists media responsivefilemanager " ], relative_urls: false, filemanager_title:"Responsive Filemanager", external_filemanager_path:"/filemanager/", external_plugins: { "filemanager" : "/filemanager/plugin.min.js"}, image_advtab: true, toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect", toolbar2: "| responsivefilemanager | image | media | link unlink anchor | " }); }); </script> <?php }
public function init($do) { $template = cmsTemplate::getInstance(); return array('titles' => array('type' => 'fieldset', 'childs' => array(new fieldString('name', array('title' => LANG_SYSTEM_NAME, 'hint' => LANG_CP_SYSTEM_NAME_HINT, 'rules' => array(array('required'), array('sysname'), $do == 'add' ? array('unique', 'content_types', 'name') : false))), new fieldString('title', array('title' => LANG_TITLE, 'rules' => array(array('required'), array('max_length', 100)))), new fieldString('description', array('title' => LANG_DESCRIPTION, 'rules' => array(array('max_length', 255)))))), 'pub' => array('type' => 'fieldset', 'title' => LANG_CP_PUBLICATION, 'childs' => array(new fieldCheckbox('is_premod_add', array('title' => LANG_CP_PREMOD_ADD)), new fieldCheckbox('is_premod_edit', array('title' => LANG_CP_PREMOD_EDIT)), new fieldCheckbox('is_date_range', array('title' => LANG_CP_IS_PUB_CONTROL, 'hint' => LANG_CP_IS_PUB_CONTROL_HINT)), new fieldList('options:is_date_range_process', array('title' => LANG_CP_IS_PUB_CONTROL_PROCESS, 'default' => 'hide', 'items' => array('hide' => LANG_CP_IS_PUB_CONTROL_PROCESS_HIDE, 'delete' => LANG_CP_IS_PUB_CONTROL_PROCESS_DEL))))), 'categories' => array('type' => 'fieldset', 'title' => LANG_CP_CATEGORIES, 'childs' => array(new fieldCheckbox('is_cats', array('title' => LANG_CP_CATEGORIES_ON)), new fieldCheckbox('is_cats_recursive', array('title' => LANG_CP_CATEGORIES_RECURSIVE)), new fieldCheckbox('options:is_empty_root', array('title' => LANG_CP_CATEGORIES_EMPTY_ROOT)), new fieldCheckbox('options:is_cats_multi', array('title' => LANG_CP_CATEGORIES_MULTI)), new fieldCheckbox('options:is_cats_change', array('title' => LANG_CP_CATEGORIES_CHANGE, 'default' => true)), new fieldCheckbox('options:is_cats_open_root', array('title' => LANG_CP_CATEGORIES_OPEN_ROOT)), new fieldCheckbox('options:is_cats_only_last', array('title' => LANG_CP_CATEGORIES_ONLY_LAST)), new fieldCheckbox('options:is_show_cats', array('title' => LANG_CP_CATEGORIES_SHOW)))), 'folders' => array('type' => 'fieldset', 'title' => LANG_CP_FOLDERS, 'childs' => array(new fieldCheckbox('is_folders', array('title' => LANG_CP_FOLDERS_ON, 'hint' => LANG_CP_FOLDERS_HINT)))), 'groups' => array('type' => 'fieldset', 'title' => LANG_CP_CT_GROUPS, 'childs' => array(new fieldCheckbox('is_in_groups', array('title' => LANG_CP_CT_GROUPS_ALLOW)), new fieldCheckbox('is_in_groups_only', array('title' => LANG_CP_CT_GROUPS_ALLOW_ONLY)))), 'comments' => array('type' => 'fieldset', 'title' => LANG_CP_COMMENTS, 'childs' => array(new fieldCheckbox('is_comments', array('title' => LANG_CP_COMMENTS_ON)))), 'ratings' => array('type' => 'fieldset', 'title' => LANG_CP_RATING, 'childs' => array(new fieldCheckbox('is_rating', array('title' => LANG_CP_RATING_ON)))), 'tags' => array('type' => 'fieldset', 'title' => LANG_TAGS, 'childs' => array(new fieldCheckbox('is_tags', array('title' => LANG_CP_TAGS_ON)), new fieldCheckbox('options:is_tags_in_list', array('title' => LANG_CP_TAGS_IN_LIST)), new fieldCheckbox('options:is_tags_in_item', array('title' => LANG_CP_TAGS_IN_ITEM)))), 'listview' => array('type' => 'fieldset', 'title' => LANG_CP_LISTVIEW_OPTIONS, 'childs' => array(new fieldCheckbox('options:list_on', array('title' => LANG_CP_LISTVIEW_ON, 'default' => true)), new fieldCheckbox('options:profile_on', array('title' => LANG_CP_PROFILELIST_ON, 'default' => true)), new fieldCheckbox('options:list_show_filter', array('title' => LANG_CP_LISTVIEW_FILTER)), new fieldCheckbox('options:list_expand_filter', array('title' => LANG_CP_LISTVIEW_FILTER_EXPAND)), new fieldList('options:list_style', array('title' => LANG_CP_LISTVIEW_STYLE, 'hint' => sprintf(LANG_CP_LISTVIEW_STYLE_HINT, $template->getName()), 'generator' => function () use($template) { return $template->getAvailableContentListStyles(); })), new fieldList('options:privacy_type', array('title' => LANG_CP_PRIVACY_TYPE, 'default' => 'hide', 'items' => array('hide' => LANG_CP_PRIVACY_TYPE_HIDE, 'show_title' => LANG_CP_PRIVACY_TYPE_SHOW_TITLE, 'show_all' => LANG_CP_PRIVACY_TYPE_SHOW_ALL))), new fieldNumber('options:limit', array('title' => LANG_LIST_LIMIT, 'default' => 15, 'rules' => array(array('required')))))), 'itemview' => array('type' => 'fieldset', 'title' => LANG_CP_ITEMVIEW_OPTIONS, 'childs' => array(new fieldCheckbox('options:item_on', array('title' => LANG_CP_ITEMVIEW_ON, 'default' => true)), new fieldCheckbox('options:hits_on', array('title' => LANG_CP_ITEMVIEW_HITS_ON)), new fieldText('item_append_html', array('title' => LANG_CP_ITEMVIEW_APPEND_HTML, 'hint' => LANG_CP_ITEMVIEW_APPEND_HTML_HINT)))), 'seo-items' => array('type' => 'fieldset', 'title' => LANG_CP_SEOMETA, 'childs' => array(new fieldCheckbox('options:is_manual_title', array('title' => LANG_CP_SEOMETA_MANUAL_TITLE)), new fieldCheckbox('is_auto_keys', array('title' => LANG_CP_SEOMETA_AUTO_KEYS, 'default' => true)), new fieldCheckbox('is_auto_desc', array('title' => LANG_CP_SEOMETA_AUTO_DESC, 'default' => true)), new fieldCheckbox('is_auto_url', array('title' => LANG_CP_AUTO_URL, 'default' => true)), new fieldCheckbox('is_fixed_url', array('title' => LANG_CP_FIXED_URL)), new fieldString('url_pattern', array('title' => LANG_CP_URL_PATTERN, 'prefix' => '/articles/', 'suffix' => '.html', 'default' => '{id}-{title}', 'rules' => array(array('required')))))), 'seo-cats' => array('type' => 'fieldset', 'title' => LANG_CP_SEOMETA_CATS, 'childs' => array(new fieldCheckbox('options:is_cats_title', array('title' => LANG_CP_SEOMETA_CATS_TITLE)), new fieldCheckbox('options:is_cats_keys', array('title' => LANG_CP_SEOMETA_CATS_KEYS)), new fieldCheckbox('options:is_cats_desc', array('title' => LANG_CP_SEOMETA_CATS_DESC)), new fieldCheckbox('options:is_cats_auto_url', array('title' => LANG_CP_CATS_AUTO_URL, 'default' => true)))), 'seo' => array('type' => 'fieldset', 'title' => LANG_CP_SEOMETA_DEFAULT, 'childs' => array(new fieldString('seo_title', array('title' => LANG_SEO_TITLE)), new fieldString('seo_keys', array('title' => LANG_SEO_KEYS, 'hint' => LANG_SEO_KEYS_HINT)), new fieldText('seo_desc', array('title' => LANG_SEO_DESC, 'hint' => LANG_SEO_DESC_HINT))))); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } if (!$this->options['is_show']) { cmsCore::error404(); } // Получаем параметры $target_controller = $this->request->get('controller'); $target_subject = $this->request->get('subject'); $target_id = $this->request->get('id'); // Флаг что нужно вывести только голый список $is_list_only = $this->request->get('is_list_only'); $page = $this->request->get('page', 1); $perpage = 10; $template = cmsTemplate::getInstance(); $this->model->filterVotes($target_controller, $target_subject, $target_id)->orderBy('id', 'desc')->limitPage($page, $perpage); $total = $this->model->getVotesCount(); $votes = $this->model->getVotes(); $pages = ceil($total / $perpage); if ($is_list_only) { $template->render('info_list', array('votes' => $votes)); } if (!$is_list_only) { $template->render('info', array('target_controller' => $target_controller, 'target_subject' => $target_subject, 'target_id' => $target_id, 'votes' => $votes, 'page' => $page, 'pages' => $pages, 'perpage' => $perpage)); } }
public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }
public function run($profile) { $user = cmsUser::getInstance(); // проверяем наличие доступа if ($profile['id'] != $user->id && !$user->is_admin) { cmsCore::error404(); } $template = cmsTemplate::getInstance(); if (!$template->hasProfileThemesOptions()) { cmsCore::error404(); } $form = $template->getProfileOptionsForm(); // Форма отправлена? $is_submitted = $this->request->has('submit'); $theme = $profile['theme']; if ($is_submitted) { // Парсим форму и получаем поля записи $theme = array_merge($theme, $form->parse($this->request, $is_submitted, $theme)); // Проверям правильность заполнения $errors = $form->validate($this, $theme); if (!$errors) { // Обновляем профиль и редиректим на его просмотр $this->model->updateUserTheme($profile['id'], $theme); $this->redirectTo('users', $profile['id']); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return $template->render('profile_edit_theme', array('id' => $profile['id'], 'profile' => $profile, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function run() { $user = cmsUser::getInstance(); $id = $this->request->get('id', 0); if (!$id) { cmsCore::error404(); } $folder = $this->model->getContentFolder($id); if (!$folder) { cmsCore::error404(); } if ($folder['user_id'] != $user->id && !$user->is_admin) { cmsCore::error404(); } $ctype = $this->model->getContentType($folder['ctype_id']); $form = $this->getForm('folder'); // Форма отправлена? $is_submitted = $this->request->has('submit'); if ($is_submitted) { // Парсим форму и получаем поля записи $updated_folder = $form->parse($this->request, $is_submitted); // Проверям правильность заполнения $errors = $form->validate($this, $updated_folder); if (!$errors) { // Обновляем папку и редиректим на ее просмотр $this->model->updateContentFolder($id, $updated_folder); $this->redirect(href_to('users', $folder['user_id'], array('content', $ctype['name'], $folder['id']))); } if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } return cmsTemplate::getInstance()->render('folder_form', array('ctype' => $ctype, 'folder' => $folder, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
public function getWidget($title, $target, $permissions = array()) { $user = cmsUser::getInstance(); extract($target); $page = $this->request->get('page', 1); $show_id = $this->request->get('wid'); $go_reply = $this->request->get('reply', 0); $show_reply_id = 0; if ($show_id) { $entry = $this->model->getEntry($show_id); if ($entry) { if ($entry['parent_id'] > 0) { $show_id = $entry['parent_id']; $show_reply_id = $entry['id']; } $page = $this->model->getEntryPageNumber($show_id, $target, self::$perpage); } } $total = $this->model->getEntriesCount($profile_type, $profile_id); $entries = $this->model->getEntries($profile_type, $profile_id, $page); $entries = cmsEventsManager::hook('wall_before_list', $entries); $csrf_token_seed = implode('/', array($profile_type, $profile_id)); $template = cmsTemplate::getInstance(); return $template->renderInternal($this, 'list', array('title' => $title, 'user' => $user, 'controller' => $controller, 'profile_type' => $profile_type, 'profile_id' => $profile_id, 'user' => $user, 'entries' => $entries, 'permissions' => $permissions, 'page' => $page, 'perpage' => wall::$perpage, 'total' => $total, 'max_entries' => $show_id ? 0 : 5, 'csrf_token_seed' => $csrf_token_seed, 'show_id' => $show_id, 'show_reply_id' => $show_reply_id, 'go_reply' => $go_reply)); }
public function getSchemeHTML() { $template = cmsTemplate::getInstance(); $scheme_html = $template->getSchemeHTML(); if (!$scheme_html) { return false; } if (!preg_match_all('/{([a-zA-Z0-9:_\\-]+)}/u', $scheme_html, $matches)) { return false; } $blocks = $matches[1]; foreach ($blocks as $block) { list($type, $value) = explode(':', $block); if ($type == 'position') { $replace_html = '<ul class="position" rel="' . $value . '" id="pos-' . $value . '"></ul>'; } if ($type == 'block') { if (mb_strpos($value, 'LANG_') === 0) { $value = constant($value); } $replace_html = '<div class="block"><span>' . $value . '</span></div>'; } if ($type == 'cell') { if (mb_strpos($value, 'LANG_') === 0) { $value = constant($value); } $replace_html = '<div class="cell"><span>' . $value . '</span></div>'; } $scheme_html = str_replace("{{$block}}", $replace_html, $scheme_html); } return $scheme_html; }
public function run($ctype_name = false) { $user = cmsUser::getInstance(); $template = cmsTemplate::getInstance(); $counts = $this->model->getTasksCounts($user->id); $is_moderator = $this->model->isUserModerator($user->id); if (!$is_moderator) { cmsCore::error404(); } if (!$counts) { return $template->render('empty'); } $is_index = false; $ctypes_list = array_keys($counts); if (!$ctype_name) { $ctype_name = $ctypes_list[0]; $is_index = true; } $content_controller = cmsCore::getController('content'); $ctypes = $content_controller->model->filterIn('name', $ctypes_list)->getContentTypesFiltered(); $ctypes = array_collection_to_list($ctypes, 'name', 'title'); $ctype = $content_controller->model->getContentTypeByName($ctype_name); $content_controller->model->filterByModeratorTask($user->id, $ctype_name); $page_url = $is_index ? href_to($this->name) : href_to($this->name, $ctype_name); $content_controller->model->disableApprovedFilter(); $list_html = $content_controller->renderItemsList($ctype, $page_url, true); return $template->render('index', array('is_index' => $is_index, 'counts' => $counts, 'ctype' => $ctype, 'ctypes' => $ctypes, 'ctype_name' => $ctype_name, 'list_html' => $list_html, 'user' => $user)); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } $ctype_name = $this->request->get('ctype_name', ''); $category_id = $this->request->get('category_id', 0); $item_id = $this->request->get('item_id', 0); if (!$ctype_name || !$category_id) { cmsCore::error404(); } $ctype = $this->model->getContentTypeByName($ctype_name); if (!$ctype) { cmsCore::error404(); } $template = cmsTemplate::getInstance(); $props = $this->model->getContentProps($ctype['name'], $category_id); if (!$props) { $template->renderJSON(array('success' => false, 'html' => '')); } $values = $item_id ? $this->model->getPropsValues($ctype['name'], $item_id) : array(); $fields = $this->getPropsFields($props); $props_html = $template->render('item_props_fields', array('props' => $props, 'fields' => $fields, 'values' => $values), new cmsRequest(array(), cmsRequest::CTX_INTERNAL)); $template->renderJSON(array('success' => true, 'html' => $props_html)); }
public function run($group_id = false) { if (!$this->request->isAjax()) { cmsCore::error404(); } $grid = $this->loadDataGrid('users'); $users_model = cmsCore::getModel('users'); $users_model->setPerPage(admin::perpage); $filter = array(); $filter_str = $this->request->get('filter'); $filter_str = cmsUser::getUPSActual('admin.grid_filter.users', $filter_str); if ($filter_str) { $content_model = cmsCore::getModel('content')->setTablePrefix(''); parse_str($filter_str, $filter); $users_model->applyGridFilter($grid, $filter); if (!empty($filter['advanced_filter'])) { parse_str($filter['advanced_filter'], $dataset_filters); $users_model->applyDatasetFilters($dataset_filters); } } if ($group_id) { $users_model->filterGroup($group_id); } $total = $users_model->getUsersCount(); $perpage = isset($filter['perpage']) ? $filter['perpage'] : admin::perpage; $pages = ceil($total / $perpage); $users = $users_model->getUsers(); cmsTemplate::getInstance()->renderGridRowsJSON($grid, $users, $total, $pages); $this->halt(); }
public function run() { if (!$this->request->isAjax()) { cmsCore::error404(); } if (!cmsUser::isAllowed('comments', 'delete')) { cmsCore::error404(); } $comment_id = $this->request->get('id'); // Проверяем валидность $is_valid = is_numeric($comment_id); if (!$is_valid) { $result = array('error' => true, 'message' => LANG_ERROR); cmsTemplate::getInstance()->renderJSON($result); } $user = cmsUser::getInstance(); $comment = $this->model->getComment($comment_id); if (!cmsUser::isAllowed('comments', 'edit', 'all')) { if (cmsUser::isAllowed('comments', 'edit', 'own') && $comment['user']['id'] != $user->id) { $result = array('error' => true, 'message' => LANG_ERROR); cmsTemplate::getInstance()->renderJSON($result); } } $this->model->deleteComment($comment_id); $result = array('error' => false, 'message' => LANG_COMMENT_DELETED); cmsTemplate::getInstance()->renderJSON($result); }