Beispiel #1
0
 public function run($do = false)
 {
     $updater = new cmsUpdater();
     $update = $updater->checkUpdate();
     if ($update == cmsUpdater::UPDATE_NOT_AVAILABLE) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_NOT_AVAILABLE);
         $this->redirectToAction('update');
     }
     if ($update == cmsUpdater::UPDATE_CHECK_ERROR || empty($update['version'])) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_CHECK_FAIL, 'error');
         $this->redirectToAction('update');
     }
     if (!function_exists('curl_init')) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_DOWNLOAD_FAIL, 'error');
         $this->redirectToAction('update');
     }
     $url = $update['url'];
     $package_name = basename($url);
     $destination = cmsConfig::get('upload_path') . 'installer/' . $package_name;
     $result = file_save_from_url($url, $destination);
     if ($result === false) {
         cmsUser::addSessionMessage(LANG_CP_UPDATE_DOWNLOAD_FAIL, 'error');
         $this->redirectToAction('update');
     }
     $this->redirectToAction('install', false, array('package_name' => $package_name));
 }
Beispiel #2
0
    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 displayEditor($field_id, $content = '')
    {
        $lang = cmsConfig::get('language');
        $user = cmsUser::getInstance();
        cmsTemplate::getInstance()->addCSS('wysiwyg/ckeditor/samples/sample.css');
        cmsTemplate::getInstance()->addJS('wysiwyg/ckeditor/ckeditor.js');
        $dom_id = str_replace(array('[', ']'), array('_', ''), $field_id);
        echo html_textarea($field_id, $content, array('id' => $dom_id));
        ?>
<script type="text/javascript" >

            <?php 
        if ($user->is_admin) {
            ?>

            $(document).ready(function(){
                CKEDITOR.replace('<?php 
            echo $dom_id;
            ?>
',{
                });
            });

            <?php 
        }
        ?>
        </script>
    <?php 
    }
Beispiel #4
0
 public function __construct($name = '')
 {
     $this->site_config = cmsConfig::getInstance();
     if ($name) {
         $this->setName($name);
     } else {
         $device_type = cmsRequest::getDeviceType();
         $template = $this->site_config->template;
         // шаблон в зависимости от девайса
         if ($device_type !== 'desktop') {
             $device_template = cmsConfig::get('template_' . $device_type);
             if ($device_template) {
                 $template = $device_template;
             }
         }
         // шаблон админки, можем определить только тут
         $controller = cmsCore::getInstance()->uri_controller;
         if ($controller === 'admin' && $this->site_config->template_admin) {
             $template = $this->site_config->template_admin;
         }
         $this->setName($template);
     }
     $this->options = $this->getOptions();
     $this->setInheritNames($this->getInheritTemplates());
     $this->title = $this->site_config->sitename;
     $is_no_def_meta = isset($this->site_config->is_no_meta) ? $this->site_config->is_no_meta : false;
     if (!$is_no_def_meta) {
         $this->metakeys = $this->site_config->metakeys;
         $this->metadesc = $this->site_config->metadesc;
     }
 }
Beispiel #5
0
 public function clean($key)
 {
     if (!cmsConfig::get('cache_enabled')) {
         return false;
     }
     return $this->cacher->clean($key);
 }
Beispiel #6
0
 public function run()
 {
     if (cmsUser::isLogged()) {
         $this->redirectToHome();
     }
     $email = $this->request->get('login_email');
     $password = $this->request->get('login_password');
     $remember = (bool) $this->request->get('remember');
     $back_url = $this->request->has('back') ? $this->request->get('back') : false;
     $is_site_offline = !cmsConfig::get('is_site_on');
     if ($this->request->has('submit')) {
         $is_captcha_valid = true;
         if (cmsUser::sessionGet('is_auth_captcha') && $this->options['auth_captcha']) {
             $is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request);
         }
         if ($is_captcha_valid) {
             cmsUser::sessionUnset('is_auth_captcha');
             $logged_id = cmsUser::login($email, $password, $remember);
             if ($logged_id) {
                 if ($is_site_offline) {
                     $userSession = cmsUser::sessionGet('user');
                     if (!$userSession['is_admin']) {
                         cmsUser::addSessionMessage(LANG_LOGIN_ADMIN_ONLY, 'error');
                         cmsUser::logout();
                         $this->redirectBack();
                     }
                 }
                 cmsEventsManager::hook('auth_login', $logged_id);
                 $is_back = $this->request->get('is_back');
                 if ($is_back) {
                     $this->redirectBack();
                 }
                 if ($back_url) {
                     $this->redirect($back_url);
                 } else {
                     $this->redirectToHome();
                 }
             }
         }
         if ($this->options['auth_captcha'] && !$is_site_offline) {
             cmsUser::sessionSet('is_auth_captcha', true);
         }
         if ($is_captcha_valid) {
             cmsUser::addSessionMessage(LANG_LOGIN_ERROR, 'error');
             if ($is_site_offline) {
                 $this->redirectBack();
             }
         } else {
             cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error');
         }
     }
     if ($back_url) {
         cmsUser::addSessionMessage(LANG_LOGIN_REQUIRED, 'error');
     }
     if (cmsUser::sessionGet('is_auth_captcha')) {
         $captcha_html = cmsEventsManager::hook('captcha_html');
     }
     return cmsTemplate::getInstance()->render('login', array('back_url' => $back_url, 'captcha_html' => isset($captcha_html) ? $captcha_html : false));
 }
Beispiel #7
0
 private function isAllowByIp()
 {
     $allow_ips = cmsConfig::get('allow_ips');
     if (!$allow_ips) {
         return true;
     }
     return string_in_mask_list(cmsUser::getIp(), $allow_ips);
 }
Beispiel #8
0
 public function getPathAndFile($key)
 {
     $path = cmsConfig::get('cache_path') . str_replace('.', '/', $key);
     $file = explode('/', $path);
     $path = dirname($path);
     $file = $path . '/' . $file[sizeof($file) - 1] . '.dat';
     return array($path, $file);
 }
 public function init($do)
 {
     $groups = cmsCore::getModel('users')->getGroups();
     return array('basic' => array('type' => 'fieldset', 'childs' => array(new fieldString('title', array('title' => LANG_USERS_MIG_TITLE, 'rules' => array(array('required'), array('max_length', 256)))), new fieldCheckbox('is_active', array('title' => LANG_USERS_MIG_IS_ACTIVE)))), array('type' => 'fieldset', 'childs' => array(new fieldList('is_keep_group', array('title' => LANG_USERS_MIG_ACTION, 'items' => array(0 => LANG_USERS_MIG_ACTION_CHANGE, 1 => LANG_USERS_MIG_ACTION_ADD))), new fieldList('group_from_id', array('title' => LANG_USERS_MIG_FROM, 'generator' => function () use($groups) {
         return array_collection_to_list($groups, 'id', 'title');
     })), new fieldList('group_to_id', array('title' => LANG_USERS_MIG_TO, 'generator' => function () use($groups) {
         return array_collection_to_list($groups, 'id', 'title');
     })))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_passed', array('title' => LANG_USERS_MIG_COND_DATE)), new fieldList('passed_from', array('title' => LANG_USERS_MIG_PASSED_FROM, 'items' => array(0 => LANG_USERS_MIG_PASSED_REG, 1 => LANG_USERS_MIG_PASSED_MIG))), new fieldNumber('passed_days', array('title' => LANG_USERS_MIG_PASSED)))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_rating', array('title' => LANG_USERS_MIG_COND_RATING)), new fieldNumber('rating', array('title' => LANG_USERS_MIG_RATING)))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_karma', array('title' => LANG_USERS_MIG_COND_KARMA)), new fieldNumber('karma', array('title' => LANG_USERS_MIG_KARMA)))), array('type' => 'fieldset', 'childs' => array(new fieldCheckbox('is_notify', array('title' => LANG_USERS_MIG_NOTIFY)), new fieldHtml('notify_text', array('title' => LANG_USERS_MIG_NOTIFY_TEXT, 'options' => array('editor' => cmsConfig::get('default_editor')))))));
 }
Beispiel #10
0
 public function run()
 {
     // автоматическое получение опций через $this->options здесь не
     // работает, потому что форма опций не содержит полей, они заполняются
     // динамически в админке
     $options = $this->loadOptions($this->name);
     if (!$options) {
         return false;
     }
     $sources_list = $options['sources'];
     if (!$sources_list) {
         return false;
     }
     $config = cmsConfig::getInstance();
     if (!is_writable($config->root_path . 'cache/static/sitemaps/')) {
         return false;
     }
     $sources = array();
     $sitemaps = array();
     foreach ($sources_list as $item => $is_enabled) {
         if (!$is_enabled) {
             continue;
         }
         list($controller_name, $source) = explode('|', $item);
         $sources[$controller_name][] = $source;
     }
     foreach ($sources as $controller_name => $items) {
         $urls = array();
         $controller = cmsCore::getController($controller_name);
         foreach ($items as $item) {
             $urls = $controller->runHook('sitemap_urls', array($item));
             if (!$urls) {
                 continue;
             }
             if (count($urls) > $this->max_count) {
                 $chunk_data = array_chunk($urls, $this->max_count, true);
                 foreach ($chunk_data as $index => $chunk_urls) {
                     $index = $index ? '_' . $index : '';
                     $xml = cmsTemplate::getInstance()->renderInternal($this, 'sitemap', array('urls' => $chunk_urls));
                     $sitemap_file = "sitemap_{$controller_name}_{$item}{$index}.xml";
                     file_put_contents($config->root_path . "cache/static/sitemaps/{$sitemap_file}", $xml);
                     $sitemaps[] = $sitemap_file;
                 }
             } else {
                 $xml = cmsTemplate::getInstance()->renderInternal($this, 'sitemap', array('urls' => $urls));
                 $sitemap_file = "sitemap_{$controller_name}_{$item}.xml";
                 file_put_contents($config->root_path . "cache/static/sitemaps/{$sitemap_file}", $xml);
                 $sitemaps[] = $sitemap_file;
             }
         }
     }
     $xml = cmsTemplate::getInstance()->renderInternal($this, 'sitemap_index', array('sitemaps' => $sitemaps, 'host' => $config->host));
     file_put_contents(cmsConfig::get('root_path') . 'cache/static/sitemaps/sitemap.xml', $xml);
     return true;
 }
Beispiel #11
0
 public function getFilterInput($value)
 {
     if ($this->getOption('filter_range')) {
         $from = !empty($value['from']) ? date(cmsConfig::get('date_format'), strtotime($value['from'])) : false;
         $to = !empty($value['to']) ? date(cmsConfig::get('date_format'), strtotime($value['to'])) : false;
         $this->title = false;
         return cmsTemplate::getInstance()->renderFormField($this->class . "_range", array('field' => $this, 'from' => $from, 'to' => $to));
     } else {
         return parent::getFilterInput($value);
     }
 }
Beispiel #12
0
 public function getOptions()
 {
     return array(new fieldList('editor', array('title' => LANG_PARSER_HTML_EDITOR, 'default' => cmsConfig::get('default_editor'), 'generator' => function ($item) {
         $items = array();
         $editors = cmsCore::getWysiwygs();
         foreach ($editors as $editor) {
             $items[$editor] = $editor;
         }
         return $items;
     })), new fieldCheckbox('is_html_filter', array('title' => LANG_PARSER_HTML_FILTERING)), new fieldCheckbox('build_redirect_link', array('title' => LANG_PARSER_BUILD_REDIRECT_LINK)), new fieldNumber('teaser_len', array('title' => LANG_PARSER_HTML_TEASER_LEN, 'hint' => LANG_PARSER_HTML_TEASER_LEN_HINT)), new fieldCheckbox('in_fulltext_search', array('title' => LANG_PARSER_IN_FULLTEXT_SEARCH, 'hint' => LANG_PARSER_IN_FULLTEXT_SEARCH_HINT, 'default' => false)));
 }
Beispiel #13
0
 public function run($data)
 {
     list($ctype, $profile) = $data;
     if (!empty($ctype['options']['is_rss'])) {
         $title = $profile['nickname'] . ' - ' . $ctype['title'];
         $feed_title = sprintf(LANG_RSS_FEED_TITLE_FORMAT, $title, cmsConfig::get('sitename'));
         $feed_url = href_to_abs($this->name, 'feed', $ctype['name']) . '?user='******'id'];
         $link_tag = '<link title="' . $feed_title . '" type="application/rss+xml" rel="alternate" href="' . $feed_url . '">';
         cmsTemplate::getInstance()->addHead($link_tag);
     }
     return array($ctype, $profile);
 }
Beispiel #14
0
 public function parse($value)
 {
     $href = $value;
     if ($this->getOption('auto_http')) {
         if (!preg_match('/^([a-z]+):\\/\\/(.+)$/i', $href)) {
             $href = 'http://' . $href;
         }
     }
     if ($this->getOption('redirect')) {
         $href = cmsConfig::get('root') . 'redirect?url=' . $href;
     }
     return '<a href="' . htmlspecialchars($href) . '">' . $value . '</a>';
 }
Beispiel #15
0
 public function init()
 {
     return array('basic' => array('type' => 'fieldset', 'title' => LANG_RSS_FEED_BASIC, 'childs' => array(new fieldCheckbox('is_enabled', array('title' => LANG_RSS_FEED_ENABLED)), new fieldString('description', array('title' => LANG_RSS_FEED_DESC)), new fieldNumber('limit', array('title' => LANG_RSS_FEED_LIMIT, 'rules' => array(array('required'), array('digits'), array('min', 1), array('max', 50)))), new fieldList('template', array('title' => LANG_RSS_FEED_TEMPLATE, 'hint' => LANG_RSS_FEED_TEMPLATE_HINT, 'generator' => function ($item) {
         $tpls = cmsCore::getFilesList('templates/' . cmsConfig::get('template') . '/controllers/rss/', '*.tpl.php');
         $items = array();
         if ($tpls) {
             foreach ($tpls as $tpl) {
                 $items[str_replace('.tpl.php', '', $tpl)] = $tpl;
             }
         }
         return $items;
     })))), 'image' => array('type' => 'fieldset', 'title' => LANG_RSS_FEED_IMAGE, 'childs' => array(new fieldImage('image', array()))), 'cache' => array('type' => 'fieldset', 'title' => LANG_RSS_FEED_CACHING, 'childs' => array(new fieldCheckbox('is_cache', array('title' => LANG_RSS_FEED_CACHE)), new fieldNumber('cache_interval', array('title' => LANG_RSS_FEED_CACHE_INT, 'rules' => array(array('digits'), array('min', 1)))))));
 }
Beispiel #16
0
 public function run()
 {
     $today = date(cmsConfig::get('date_format'));
     $this->title = 'Курсы валют на ' . $today;
     $file = simplexml_load_file("http://www.cbr.ru/scripts/XML_daily.asp?date_req=" . date("d/m/Y"));
     if ($file != '') {
         $valutes = array();
         foreach ($file as $el) {
             $valutes[strval($el->CharCode)] = strval($el->Value);
         }
         return array('USD' => $valutes['USD'], 'EUR' => $valutes['EUR']);
     }
     return array();
 }
Beispiel #17
0
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));
        }
    }
}
Beispiel #18
0
 public function run($type)
 {
     if (!in_array($type, array('css', 'js'))) {
         cmsCore::error404();
     }
     $cache_folder = "cache/static/{$type}";
     $cache_folder_path = cmsConfig::get('root_path') . $cache_folder;
     if (files_clear_directory($cache_folder_path)) {
         cmsUser::addSessionMessage(sprintf(LANG_CP_SETTINGS_MERGED_CLEANED, '/' . $cache_folder), 'success');
     } else {
         cmsUser::addSessionMessage(sprintf(LANG_CP_SETTINGS_MERGED_CLEAN_FAIL, '/' . $cache_folder), 'error');
     }
     $this->redirectBack();
 }
Beispiel #19
0
 private function componentUpdate($manifest)
 {
     $model = new cmsModel();
     $controller_root_path = cmsConfig::get('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';
 }
Beispiel #20
0
 public function run($user)
 {
     if (!$user['is_admin']) {
         return $user;
     }
     if (!cmsConfig::get('is_check_updates')) {
         return $user;
     }
     $updater = new cmsUpdater();
     $update = $updater->checkUpdate();
     if (!empty($update['version'])) {
         $message = sprintf(LANG_CP_UPDATE_AVAILABLE, $update['version']);
         $message .= '&mdash; <a href="' . href_to('admin', 'update') . '">' . LANG_INSTALL . '</a>';
         cmsUser::addSessionMessage($message);
     }
     return $user;
 }
Beispiel #21
0
 function __construct($request)
 {
     self::loadControllers();
     $this->name = $this->name ? $this->name : mb_strtolower(get_called_class());
     $this->root_url = $this->name;
     $this->root_path = cmsConfig::get('root_path') . 'system/controllers/' . $this->name . '/';
     $this->request = $request;
     cmsCore::loadControllerLanguage($this->name);
     $title_constant = 'LANG_' . strtoupper($this->name) . '_CONTROLLER';
     $this->title = defined($title_constant) ? constant($title_constant) : $this->name;
     if (cmsCore::isModelExists($this->name)) {
         $this->model = cmsCore::getModel($this->name);
     }
     if ($this->useOptions) {
         $this->options = $this->getOptions();
     }
 }
    public function displayEditor($field_id, $content = '')
    {
        $lang = cmsConfig::get('language');
        $user = cmsUser::getInstance();
        $template = cmsTemplate::getInstance();
        $template->addCSSFromContext('wysiwyg/redactor/css/redactor.css');
        $template->addJSFromContext('wysiwyg/redactor/js/redactor.js');
        $template->addJSFromContext('wysiwyg/redactor/js/video.js');
        $template->addJSFromContext('wysiwyg/redactor/js/fullscreen.js');
        $template->addJSFromContext('wysiwyg/redactor/js/fontsize.js');
        $template->addJSFromContext('wysiwyg/redactor/js/fontfamily.js');
        $template->addJSFromContext('wysiwyg/redactor/js/fontcolor.js');
        $template->addJSFromContext("wysiwyg/redactor/lang/{$lang}.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(){
                    $('#<?php 
        echo $dom_id;
        ?>
').redactor({
                        lang: '<?php 
        echo $lang;
        ?>
',
                        plugins: ['video', 'fontfamily', 'fontsize', 'fontcolor', 'fullscreen'],
                        imageUpload: '<?php 
        echo href_to('redactor/upload');
        ?>
',
						minHeight: 250,
						<?php 
        if ($user->is_admin) {
            ?>
                            buttonSource: true
						<?php 
        }
        ?>
                    });
                });
            </script>

        <?php 
    }
 public function run($data)
 {
     list($ctype, $category) = $data;
     if (!empty($ctype['options']['is_rss'])) {
         $title = $ctype['title'];
         if ($category['id'] > 1) {
             $title = $title . ' / ' . $category['title'];
         }
         $feed_title = sprintf(LANG_RSS_FEED_TITLE_FORMAT, $title, cmsConfig::get('sitename'));
         $feed_url = href_to_abs($this->name, 'feed', $ctype['name']);
         if ($category['id'] > 1) {
             $feed_url .= '?category=' . $category['id'];
         }
         $link_tag = '<link title="' . htmlspecialchars($feed_title) . '" type="application/rss+xml" rel="alternate" href="' . $feed_url . '">';
         cmsTemplate::getInstance()->addHead($link_tag);
     }
     return array($ctype, $category);
 }
Beispiel #24
0
 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $page_id = $this->request->get('page_id', 0);
     $template = $this->request->get('template', '');
     if (!is_numeric($page_id)) {
         cmsCore::error404();
     }
     $tpls = cmsCore::getTemplates();
     if (!$template || !in_array($template, $tpls)) {
         $template = cmsConfig::get('template');
     }
     $widgets_model = cmsCore::getModel('widgets');
     $scheme = $widgets_model->getWidgetBindingsScheme($page_id, $template);
     cmsTemplate::getInstance()->renderJSON(array('is_exists' => $scheme !== false, 'scheme' => $scheme));
 }
Beispiel #25
0
 public function init()
 {
     return array(array('type' => 'fieldset', 'childs' => array(new fieldString('title', array('title' => LANG_CATEGORY_TITLE, 'options' => array('max_length' => 200), 'rules' => array(array('required')))), new fieldList('parent_id', array('title' => LANG_PARENT_CATEGORY, 'generator' => function ($cat) {
         $tree = cmsCore::getModel('content')->getCategoriesTree($cat['ctype_name']);
         if ($tree) {
             foreach ($tree as $item) {
                 // при редактировании исключаем себя и вложенные
                 // подкатегории из списка выбора родителя
                 if (isset($cat['ns_left'])) {
                     if ($item['ns_left'] >= $cat['ns_left'] && $item['ns_right'] <= $cat['ns_right']) {
                         continue;
                     }
                 }
                 $items[$item['id']] = str_repeat('- ', $item['ns_level']) . ' ' . $item['title'];
             }
         }
         return $items;
     })), new fieldHtml('description', array('title' => LANG_CATEGORY_DESCRIPTION, 'options' => array('editor' => cmsConfig::get('default_editor')))))));
 }
Beispiel #26
0
 public function actionDownload($id, $url_key)
 {
     if (!$id || !$url_key) {
         return cmsCore::error404();
     }
     $file = $this->model->getFile($id);
     if ($file['url_key'] != $url_key) {
         cmsCore::error404();
     }
     $filename = cmsConfig::get('upload_path') . $file['path'];
     $original_filename = $file['name'];
     $this->model->incrementDownloadsCounter($file['id']);
     header("Content-Type: application/force-download");
     header("Content-Length: " . filesize($filename));
     header('Content-Disposition: attachment; filename="' . $original_filename . '"');
     if (ob_get_length()) {
         ob_end_clean();
     }
     readfile($filename);
     $this->halt();
 }
Beispiel #27
0
 public function run($do = false)
 {
     // если нужно, передаем управление другому экшену
     if ($do) {
         $this->runAction('widgets_' . $do, array_slice($this->params, 1));
         return;
     }
     cmsCore::loadAllControllersLanguages();
     $widgets_model = cmsCore::getModel('widgets');
     $controllers = $widgets_model->getPagesControllers();
     $widgets_list = $widgets_model->getAvailableWidgets();
     $tpls = cmsCore::getTemplates();
     $template_name = $this->request->get('template_name', '');
     if (!$template_name || !in_array($template_name, $tpls)) {
         $template_name = cmsConfig::get('template');
     }
     foreach ($tpls as $tpl) {
         $templates[$tpl] = $tpl;
     }
     $scheme_html = $this->getSchemeHTML($template_name);
     return $this->cms_template->render('widgets', array('controllers' => $controllers, 'template_name' => $template_name, 'templates' => $templates, 'widgets_list' => $widgets_list, 'scheme_html' => $scheme_html));
 }
Beispiel #28
0
 public function setQuery($query)
 {
     $this->original_query = $query;
     $this->query = array();
     $stopwords = string_get_stopwords(cmsConfig::get('language'));
     $words = explode(' ', $query);
     foreach ($words as $word) {
         $word = strip_tags(mb_strtolower(trim(urldecode($word))));
         if (mb_strlen($word) < 3 || is_numeric($word)) {
             continue;
         }
         if ($stopwords && in_array($word, $stopwords)) {
             continue;
         }
         if (mb_strlen($word) == 3) {
             $this->query[] = $this->db->escape($word);
             continue;
         }
         if (mb_strlen($word) >= 12) {
             $word = mb_substr($word, 0, mb_strlen($word) - 4);
         } else {
             if (mb_strlen($word) >= 10) {
                 $word = mb_substr($word, 0, mb_strlen($word) - 3);
             } else {
                 if (mb_strlen($word) >= 6) {
                     $word = mb_substr($word, 0, mb_strlen($word) - 2);
                 } else {
                     $word = mb_substr($word, 0, mb_strlen($word) - 1);
                 }
             }
         }
         $this->query[] = $this->db->escape($word) . '*';
     }
     if (empty($this->query)) {
         return false;
     }
     return true;
 }
Beispiel #29
0
 public function run()
 {
     if (!$this->request->isAjax()) {
         cmsCore::error404();
     }
     $widget_id = $this->request->get('widget_id', 0);
     $page_id = $this->request->get('page_id', 0);
     $position = $this->request->get('position', '');
     $template = $this->request->get('template', '');
     $tpls = cmsCore::getTemplates();
     if (!$template || !in_array($template, $tpls)) {
         $template = cmsConfig::get('template');
     }
     $widgets_model = cmsCore::getModel('widgets');
     $widget = $widgets_model->getWidget($widget_id);
     $binded_id = $widgets_model->addWidgetBinding($widget, $page_id, $position, $template);
     $bind_widget = $widgets_model->getWidgetBinding($binded_id);
     cmsCore::loadWidgetLanguage($bind_widget['name'], $bind_widget['controller']);
     $form = cmsCore::getWidgetOptionsForm($bind_widget['name'], $bind_widget['controller'], false, $bind_widget['template']);
     $data = $form->parse(new cmsRequest($bind_widget));
     $widgets_model->updateWidgetBinding($binded_id, $data);
     $this->cms_template->renderJSON(array('error' => !(bool) $binded_id, 'id' => $binded_id));
 }
Beispiel #30
0
 public function init()
 {
     return array(array('type' => 'fieldset', 'title' => LANG_OPTIONS, 'childs' => array(new fieldList('options:menu', array('title' => LANG_MENU, 'generator' => function ($item) {
         $menu_model = cmsCore::getModel('menu');
         $tree = $menu_model->getMenus();
         $items = array();
         if ($tree) {
             foreach ($tree as $item) {
                 $items[$item['name']] = $item['title'];
             }
         }
         return $items;
     })), new fieldList('options:template', array('title' => LANG_WD_MENU_TEMPLATE, 'hint' => LANG_WD_MENU_TEMPLATE_HINT, 'generator' => function ($item) {
         $tpls = cmsCore::getFilesList('templates/' . cmsConfig::get('template') . '/assets/ui/', 'menu*.tpl.php');
         $items = array();
         if ($tpls) {
             foreach ($tpls as $tpl) {
                 $items[str_replace('.tpl.php', '', $tpl)] = $tpl;
             }
         }
         return $items;
     })), new fieldCheckbox('options:is_detect', array('title' => LANG_WD_MENU_DETECT_ACTIVE, 'default' => 1)), new fieldNumber('options:max_items', array('title' => LANG_WD_MENU_MAX_ITEMS, 'hint' => LANG_WD_MENU_MAX_ITEMS_HINT, 'default' => 0)))));
 }