本文整理汇总了PHP中cmsConfig::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsConfig::getInstance方法的具体用法?PHP cmsConfig::getInstance怎么用?PHP cmsConfig::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsConfig
的用法示例。
在下文中一共展示了cmsConfig::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadWithPreset
public function uploadWithPreset($name, $preset_name)
{
$config = cmsConfig::getInstance();
$uploader = new cmsUploader();
$result = $uploader->upload($name, $this->allowed_extensions);
if ($result['success']) {
if (!$uploader->isImage($result['path'])) {
$result['success'] = false;
$result['error'] = LANG_UPLOAD_ERR_MIME;
}
}
if (!$result['success']) {
if (!empty($result['path'])) {
$uploader->remove($result['path']);
}
return $result;
}
$preset = $this->model->getPresetByName($preset_name);
if (!$preset) {
return array('success' => false, 'error' => '');
}
$path = $uploader->resizeImage($result['path'], array('width' => $preset['width'], 'height' => $preset['height'], 'square' => $preset['is_square'], 'quality' => $preset['is_watermark'] && $preset['wm_image'] ? 100 : $preset['quality']));
$image = array('path' => $path, 'url' => $config->upload_host . '/' . $path);
if ($preset['is_watermark'] && $preset['wm_image']) {
img_add_watermark($image['path'], $preset['wm_image']['original'], $preset['wm_origin'], $preset['wm_margin'], $preset['quality']);
}
$result['image'] = $image;
@unlink($result['path']);
unset($result['path']);
return $result;
}
示例2: 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));
}
示例3: start
public function start()
{
$config = cmsConfig::getInstance();
$this->memcache = new Memcache();
$this->memcache->connect($config->cache_host, $config->cache_port) or die('Memcache connect error');
return true;
}
示例4: getInput
public function getInput($value)
{
if ($value) {
if (is_array($value)) {
if (!empty($value['date'])) {
$value = sprintf('%s %02d:%02d', $value['date'], $value['hours'], $value['mins']);
}
}
}
$this->data['show_time'] = $this->getOption('show_time');
$this->data['date'] = $value ? date(cmsConfig::getInstance()->date_format, strtotime($value)) : '';
if ($this->data['show_time']) {
if (!$value) {
$this->data['hours'] = 0;
$this->data['mins'] = 0;
} else {
list($this->data['hours'], $this->data['mins']) = explode(':', date('H:i', strtotime($value)));
}
$this->data['fname_date'] = $this->element_name . '[date]';
$this->data['fname_hours'] = $this->element_name . '[hours]';
$this->data['fname_mins'] = $this->element_name . '[mins]';
} else {
$this->data['fname_date'] = $this->element_name;
}
return parent::getInput($value);
}
示例5: __construct
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;
}
}
示例6: processUpload
public function processUpload($album_id)
{
$config = cmsConfig::getInstance();
$uploader = new cmsUploader();
$result = $uploader->upload('qqfile');
if (!$result['success']) {
cmsTemplate::getInstance()->renderJSON($result);
$this->halt();
}
$preset = array('width' => 600, 'height' => 460, 'is_square' => false, 'is_watermark' => false);
if (!empty($this->options['preset'])) {
$preset = cmsCore::getModel('images')->getPresetByName($this->options['preset']);
}
$result['paths'] = array('big' => $uploader->resizeImage($result['path'], array('width' => $preset['width'], 'height' => $preset['height'], 'square' => $preset['is_square'])), 'normal' => $uploader->resizeImage($result['path'], array('width' => 160, 'height' => 160, 'square' => true)), 'small' => $uploader->resizeImage($result['path'], array('width' => 64, 'height' => 64, 'square' => true)), 'original' => $result['url']);
if ($preset['is_watermark'] && !empty($preset['wm_image'])) {
$images_controller = cmsCore::getController('images');
$images_controller->addWatermark($result['paths']['big'], $preset['wm_image']['original'], $preset['wm_origin'], $preset['wm_margin']);
}
$result['filename'] = basename($result['path']);
if (empty($this->options['is_origs'])) {
@unlink($result['path']);
unset($result['paths']['original']);
}
unset($result['path']);
$result['url'] = $config->upload_host . '/' . $result['paths']['small'];
$result['id'] = $this->model->addPhoto($album_id, $result['paths']);
cmsTemplate::getInstance()->renderJSON($result);
$this->halt();
}
示例7: addContentType
public function addContentType($ctype)
{
$id = $this->insert('content_types', $ctype);
$config = cmsConfig::getInstance();
// получаем структуру таблиц для хранения контента данного типа
$content_table_struct = $this->getContentTableStruct();
$fields_table_struct = $this->getFieldsTableStruct();
$props_table_struct = $this->getPropsTableStruct();
$props_bind_table_struct = $this->getPropsBindTableStruct();
$props_values_table_struct = $this->getPropsValuesTableStruct();
// создаем таблицы
$table_name = $this->table_prefix . $ctype['name'];
$this->db->createTable($table_name, $content_table_struct);
$this->db->createTable("{$table_name}_fields", $fields_table_struct, $config->db_engine);
$this->db->createCategoriesTable("{$table_name}_cats");
$this->db->createCategoriesBindsTable("{$table_name}_cats_bind");
$this->db->createTable("{$table_name}_props", $props_table_struct, $config->db_engine);
$this->db->createTable("{$table_name}_props_bind", $props_bind_table_struct, $config->db_engine);
$this->db->createTable("{$table_name}_props_values", $props_values_table_struct, $config->db_engine);
//
// добавляем стандартные поля
//
// заголовок
$this->addContentField($ctype['name'], array('name' => 'title', 'title' => LANG_TITLE, 'type' => 'caption', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_in_filter' => 1, 'is_fixed' => 1, 'is_fixed_type' => 1, 'is_system' => 0, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'none', 'min_length' => 3, 'max_length' => 100, 'is_required' => true)), true);
// дата публикации
$this->addContentField($ctype['name'], array('name' => 'date_pub', 'title' => LANG_DATE_PUB, 'type' => 'date', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_in_filter' => 1, 'is_fixed' => 1, 'is_fixed_type' => 1, 'is_system' => 1, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'left', 'show_time' => true)), true);
// автор
$this->addContentField($ctype['name'], array('name' => 'user', 'title' => LANG_AUTHOR, 'type' => 'user', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_in_filter' => 0, 'is_fixed' => 1, 'is_fixed_type' => 1, 'is_system' => 1, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'left')), true);
// фотография
$this->addContentField($ctype['name'], array('name' => 'photo', 'title' => LANG_PHOTO, 'type' => 'image', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_fixed' => 1, 'options' => array('size_teaser' => 'small', 'size_full' => 'normal', 'sizes' => array('micro', 'small', 'normal', 'big'))), true);
// описание
$this->addContentField($ctype['name'], array('name' => 'content', 'title' => LANG_DESCRIPTION, 'type' => 'text', 'ctype_id' => $id, 'is_in_list' => 1, 'is_in_item' => 1, 'is_fixed' => 1, 'options' => array('label_in_list' => 'none', 'label_in_item' => 'none')), true);
cmsCache::getInstance()->clean("content.types");
return $id;
}
示例8: __construct
function __construct($request)
{
parent::__construct($request);
$config = cmsConfig::getInstance();
$this->name = str_replace('backend', '', $this->name);
$this->root_path = $config->root_path . 'system/controllers/' . $this->name . '/backend/';
}
示例9: run
public function run()
{
$config = cmsConfig::getInstance();
$path = $config->upload_path . $this->installer_upload_path;
$path_relative = $config->upload_root . $this->installer_upload_path;
$installer_path = $path . '/' . 'install.php';
$sql_dump_path = $path . '/' . 'install.sql';
$is_imported = $this->importPackageDump($sql_dump_path);
$is_installed = $this->runPackageInstaller($installer_path);
// считаем, что пришла ошибка
if (is_string($is_installed)) {
cmsUser::addSessionMessage($is_installed, 'error');
$this->redirectToAction('install');
}
$redirect_action = '';
if ($is_imported && $is_installed === true) {
$redirect_action = $this->doPackage();
// если в файле install.php есть функция after_install_package, вызываем ее
// этот файл, если он есть, уже должен был загружен ранее
if (function_exists('after_install_package')) {
call_user_func('after_install_package');
}
}
$is_cleared = files_clear_directory($path);
return cmsTemplate::getInstance()->render('install_finish', array('is_cleared' => $is_cleared, 'redirect_action' => $redirect_action, 'path_relative' => $path_relative));
}
示例10: run
public function run($user)
{
$cfg = cmsConfig::getInstance();
$dest_dir = $cfg->upload_path . "u{$user['id']}";
files_remove_directory($dest_dir);
return $user;
}
示例11: parsePackageManifest
public function parsePackageManifest()
{
$config = cmsConfig::getInstance();
$path = $config->upload_path . $this->installer_upload_path;
$ini_file = $path . '/' . "manifest.{$config->language}.ini";
$ini_file_default = $path . '/' . "manifest.ru.ini";
if (!file_exists($ini_file)) {
$ini_file = $ini_file_default;
}
if (!file_exists($ini_file)) {
return false;
}
$manifest = parse_ini_file($ini_file, true);
if (file_exists($config->upload_path . $this->installer_upload_path . '/' . 'package')) {
$manifest['contents'] = $this->getPackageContentsList();
} else {
$manifest['contents'] = false;
}
if (isset($manifest['info']['image'])) {
$manifest['info']['image'] = $config->upload_host . '/' . $this->installer_upload_path . '/' . $manifest['info']['image'];
}
if (isset($manifest['install']) || isset($manifest['update'])) {
$action = isset($manifest['install']) ? 'install' : 'update';
if (isset($manifest[$action]['type']) && isset($manifest[$action]['name'])) {
$manifest['package'] = array('type' => $manifest[$action]['type'], 'type_hint' => constant('LANG_CP_PACKAGE_TYPE_' . strtoupper($manifest[$action]['type']) . '_' . strtoupper($action)), 'action' => $action, 'name' => $manifest[$action]['name'], 'controller' => isset($manifest[$action]['controller']) ? $manifest[$action]['controller'] : null);
// проверяем установленную версию
$manifest['package']['installed_version'] = call_user_func(array($this, $manifest[$action]['type'] . 'Installed'), $manifest['package']);
}
}
return $manifest;
}
示例12: store
public function store($value, $is_submitted, $old_value = null)
{
$config = cmsConfig::getInstance();
$files_model = cmsCore::getModel('files');
if ($value) {
$file = cmsModel::yamlToArray($old_value);
$path = $config->upload_path . $file['path'];
@unlink($path);
$files_model->deleteFile($file['id']);
$old_value = null;
}
$uploader = new cmsUploader();
if (!$uploader->isUploaded($this->name)) {
return $old_value;
}
$allowed_extensions = $this->getOption('extensions');
$max_size_mb = $this->getOption('max_size_mb');
if (!trim($allowed_extensions)) {
$allowed_extensions = false;
}
if (!$max_size_mb) {
$max_size_mb = 0;
}
$result = $uploader->upload($this->name, $allowed_extensions, $max_size_mb * 1048576);
if (!$result['success']) {
if (!empty($result['path'])) {
$uploader->remove($result['path']);
}
cmsUser::addSessionMessage($result['error'], 'error');
return null;
}
$file = $files_model->registerFile($result['url'], $result['name']);
return array('id' => $file['id'], 'url_key' => $file['url_key'], 'name' => $result['name'], 'size' => $result['size'], 'path' => $result['url']);
}
示例13: run
public function run($ctype)
{
$cfg = cmsConfig::getInstance();
if ($cfg->frontpage == "content:{$ctype['name']}" && !$ctype['options']['list_on']) {
$cfg->update('frontpage', 'none');
}
return true;
}
示例14: run
public function run()
{
$result = cmsConfig::getInstance()->update('is_site_on', 1);
if (!$result) {
cmsUser::addSessionMessage(LANG_CP_SETTINGS_NOT_WRITABLE, 'error');
}
$this->redirectBack();
}
示例15: __construct
private function __construct()
{
$this->site_cfg = cmsConfig::getInstance();
$this->title = $this->homeTitle();
$this->page_keys = $this->site_cfg->keywords;
$this->page_desc = $this->site_cfg->metadesc;
$this->setTplInfo();
}