blog->id; $blog_status = $core->blog->status; $blog_name = $core->blog->name; $blog_desc = $core->blog->desc; $blog_settings = $core->blog->settings; $blog_url = $core->blog->url; $action = $core->adminurl->get("admin.blog.pref"); $redir = $core->adminurl->get("admin.blog.pref"); } else { dcPage::checkSuper(); try { if (empty($_REQUEST['id'])) { throw new Exception(__('No given blog id.')); } $rs = $core->getBlog($_REQUEST['id']); if (!$rs) { throw new Exception(__('No such blog.')); } $blog_id = $rs->blog_id; $blog_status = $rs->blog_status; $blog_name = $rs->blog_name; $blog_desc = $rs->blog_desc; $blog_settings = new dcSettings($core, $blog_id); $blog_url = $rs->blog_url; } catch (Exception $e) { $core->error->add($e->getMessage()); } $action = $core->adminurl->get("admin.blog"); $redir = $core->adminurl->get("admin.blog", ['id' => "%s"], '&', true); } # Language codes $lang_combo = dcAdminCombos::getAdminLangsCombo(); # Status combo $status_combo = dcAdminCombos::getBlogStatusescombo(); # Date format combo $now = time(); $date_formats = $blog_settings->system->date_formats; $time_formats = $blog_settings->system->time_formats; $date_formats_combo = ['' => '']; foreach ($date_formats as $format) { $date_formats_combo[dt::str($format, $now)] = $format; } $time_formats_combo = ['' => '']; foreach ($time_formats as $format) { $time_formats_combo[dt::str($format, $now)] = $format; } # URL scan modes $url_scan_combo = [ 'PATH_INFO' => 'path_info', 'QUERY_STRING' => 'query_string' ]; # Post URL combo $post_url_combo = [ __('year/month/day/title') => '{y}/{m}/{d}/{t}', __('year/month/title') => '{y}/{m}/{t}', __('year/title') => '{y}/{t}', __('title') => '{t}', __('post id/title') => '{id}/{t}', __('post id') => '{id}' ]; if (!in_array($blog_settings->system->post_url_format, $post_url_combo)) { $post_url_combo[html::escapeHTML($blog_settings->system->post_url_format)] = html::escapeHTML($blog_settings->system->post_url_format); } # Note title tag combo $note_title_tag_combo = [ __('H4') => 0, __('H3') => 1, __('P') => 2 ]; # Image title combo $img_title_combo = [ __('(none)') => '', __('Title') => 'Title ;; separator(, )', __('Title, Date') => 'Title ;; Date(%b %Y) ;; separator(, )', __('Title, Country, Date') => 'Title ;; Country ;; Date(%b %Y) ;; separator(, )', __('Title, City, Country, Date') => 'Title ;; City ;; Country ;; Date(%b %Y) ;; separator(, )' ]; if (!in_array($blog_settings->system->media_img_title_pattern, $img_title_combo)) { $img_title_combo[html::escapeHTML($blog_settings->system->media_img_title_pattern)] = html::escapeHTML($blog_settings->system->media_img_title_pattern); } # Image default size combo $img_default_size_combo = []; try { $media = new dcMedia($core); $img_default_size_combo[__('original')] = 'o'; foreach ($media->thumb_sizes as $code => $size) { $img_default_size_combo[__($size[2])] = $code; } } catch (Exception $e) { $core->error->add($e->getMessage()); } # Image default alignment combo $img_default_alignment_combo = [ __('None') => 'none', __('Left') => 'left', __('Right') => 'right', __('Center') => 'center' ]; # Image default legend and title combo $img_default_legend_combo = [ __('Legend and title') => 'legend', __('Title') => 'title', __('None') => 'none' ]; # Robots policy options $robots_policy_options = [ 'INDEX,FOLLOW' => __("I would like search engines and archivers to index and archive my blog's content."), 'INDEX,FOLLOW,NOARCHIVE' => __("I would like search engines and archivers to index but not archive my blog's content."), 'NOINDEX,NOFOLLOW,NOARCHIVE' => __("I would like to prevent search engines and archivers from indexing or archiving my blog's content.") ]; # jQuery available versions $jquery_root = dirname(__FILE__) . '/../inc/js/jquery'; $jquery_versions_combo = [__('Default') . ' (' . DC_DEFAULT_JQUERY . ')' => DC_DEFAULT_JQUERY]; if (is_dir($jquery_root) && is_readable($jquery_root)) { if (($d = @dir($jquery_root)) !== false) { while (($entry = $d->read()) !== false) { if ($entry != '.' && $entry != '..' && substr($entry, 0, 1) != '.' && is_dir($jquery_root . '/' . $entry)) { if ($entry != DC_DEFAULT_JQUERY) { $jquery_versions_combo[$entry] = $entry; } } } } } # Update a blog if ($blog_id && !empty($_POST) && $core->auth->check('admin', $blog_id)) { $cur = $core->con->openCursor($core->prefix . 'blog'); $cur->blog_id = $_POST['blog_id']; $cur->blog_url = preg_replace('/\?+$/', '?', $_POST['blog_url']); $cur->blog_name = $_POST['blog_name']; $cur->blog_desc = $_POST['blog_desc']; if ($core->auth->isSuperAdmin() && in_array($_POST['blog_status'], $status_combo)) { $cur->blog_status = (int) $_POST['blog_status']; } $media_img_t_size = (integer) $_POST['media_img_t_size']; if ($media_img_t_size < 0) {$media_img_t_size = 100;} $media_img_s_size = (integer) $_POST['media_img_s_size']; if ($media_img_s_size < 0) {$media_img_s_size = 240;} $media_img_m_size = (integer) $_POST['media_img_m_size']; if ($media_img_m_size < 0) {$media_img_m_size = 448;} $media_video_width = (integer) $_POST['media_video_width']; if ($media_video_width < 0) {$media_video_width = 400;} $media_video_height = (integer) $_POST['media_video_height']; if ($media_video_height < 0) {$media_video_height = 300;} $nb_post_for_home = abs((integer) $_POST['nb_post_for_home']); if ($nb_post_for_home < 1) {$nb_post_for_home = 1;} $nb_post_per_page = abs((integer) $_POST['nb_post_per_page']); if ($nb_post_per_page < 1) {$nb_post_per_page = 1;} $nb_post_per_feed = abs((integer) $_POST['nb_post_per_feed']); if ($nb_post_per_feed < 1) {$nb_post_per_feed = 1;} $nb_comment_per_feed = abs((integer) $_POST['nb_comment_per_feed']); if ($nb_comment_per_feed < 1) {$nb_comment_per_feed = 1;} try { if ($cur->blog_id != null && $cur->blog_id != $blog_id) { $rs = $core->getBlog($cur->blog_id); if ($rs) { throw new Exception(__('This blog ID is already used.')); } } # --BEHAVIOR-- adminBeforeBlogUpdate $core->callBehavior('adminBeforeBlogUpdate', $cur, $blog_id); if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_POST['lang'])) { throw new Exception(__('Invalid language code')); } $core->updBlog($blog_id, $cur); # --BEHAVIOR-- adminAfterBlogUpdate $core->callBehavior('adminAfterBlogUpdate', $cur, $blog_id); if ($cur->blog_id != null && $cur->blog_id != $blog_id) { if ($blog_id == $core->blog->id) { $core->setBlog($cur->blog_id); $_SESSION['sess_blog_id'] = $cur->blog_id; $blog_settings = $core->blog->settings; } else { $blog_settings = new dcSettings($core, $cur->blog_id); } $blog_id = $cur->blog_id; } $blog_settings->addNameSpace('system'); $blog_settings->system->put('editor', $_POST['editor']); $blog_settings->system->put('copyright_notice', $_POST['copyright_notice']); $blog_settings->system->put('post_url_format', $_POST['post_url_format']); $blog_settings->system->put('lang', $_POST['lang']); $blog_settings->system->put('blog_timezone', $_POST['blog_timezone']); $blog_settings->system->put('date_format', $_POST['date_format']); $blog_settings->system->put('time_format', $_POST['time_format']); $blog_settings->system->put('comments_ttl', abs((integer) $_POST['comments_ttl'])); $blog_settings->system->put('trackbacks_ttl', abs((integer) $_POST['trackbacks_ttl'])); $blog_settings->system->put('allow_comments', !empty($_POST['allow_comments'])); $blog_settings->system->put('allow_trackbacks', !empty($_POST['allow_trackbacks'])); $blog_settings->system->put('comments_pub', empty($_POST['comments_pub'])); $blog_settings->system->put('trackbacks_pub', empty($_POST['trackbacks_pub'])); $blog_settings->system->put('comments_nofollow', !empty($_POST['comments_nofollow'])); $blog_settings->system->put('wiki_comments', !empty($_POST['wiki_comments'])); $blog_settings->system->put('comment_preview_optional', !empty($_POST['comment_preview_optional'])); $blog_settings->system->put('enable_xmlrpc', !empty($_POST['enable_xmlrpc'])); $blog_settings->system->put('note_title_tag', $_POST['note_title_tag']); $blog_settings->system->put('nb_post_for_home', $nb_post_for_home); $blog_settings->system->put('nb_post_per_page', $nb_post_per_page); $blog_settings->system->put('use_smilies', !empty($_POST['use_smilies'])); $blog_settings->system->put('no_search', !empty($_POST['no_search'])); $blog_settings->system->put('inc_subcats', !empty($_POST['inc_subcats'])); $blog_settings->system->put('media_img_t_size', $media_img_t_size); $blog_settings->system->put('media_img_s_size', $media_img_s_size); $blog_settings->system->put('media_img_m_size', $media_img_m_size); $blog_settings->system->put('media_video_width', $media_video_width); $blog_settings->system->put('media_video_height', $media_video_height); $blog_settings->system->put('media_flash_fallback', !empty($_POST['media_flash_fallback'])); $blog_settings->system->put('media_img_title_pattern', $_POST['media_img_title_pattern']); $blog_settings->system->put('media_img_use_dto_first', !empty($_POST['media_img_use_dto_first'])); $blog_settings->system->put('media_img_no_date_alone', !empty($_POST['media_img_no_date_alone'])); $blog_settings->system->put('media_img_default_size', $_POST['media_img_default_size']); $blog_settings->system->put('media_img_default_alignment', $_POST['media_img_default_alignment']); $blog_settings->system->put('media_img_default_link', !empty($_POST['media_img_default_link'])); $blog_settings->system->put('media_img_default_legend', $_POST['media_img_default_legend']); $blog_settings->system->put('nb_post_per_feed', $nb_post_per_feed); $blog_settings->system->put('nb_comment_per_feed', $nb_comment_per_feed); $blog_settings->system->put('short_feed_items', !empty($_POST['short_feed_items'])); if (isset($_POST['robots_policy'])) { $blog_settings->system->put('robots_policy', $_POST['robots_policy']); } $blog_settings->system->put('jquery_version', $_POST['jquery_version']); $blog_settings->system->put('prevents_clickjacking', !empty($_POST['prevents_clickjacking'])); # --BEHAVIOR-- adminBeforeBlogSettingsUpdate $core->callBehavior('adminBeforeBlogSettingsUpdate', $blog_settings); if ($core->auth->isSuperAdmin() && in_array($_POST['url_scan'], $url_scan_combo)) { $blog_settings->system->put('url_scan', $_POST['url_scan']); } dcPage::addSuccessNotice(__('Blog has been successfully updated.')); http::redirect(sprintf($redir, $blog_id)); } catch (Exception $e) { $core->error->add($e->getMessage()); } } // Display if ($standalone) { $breadcrumb = dcPage::breadcrumb( [ html::escapeHTML($blog_name) => '', __('Blog settings') => '' ] ); } else { $breadcrumb = dcPage::breadcrumb( [ __('System') => '', __('Blogs') => $core->adminurl->get("admin.blogs"), __('Blog settings') . ' : ' . html::escapeHTML($blog_name) => '' ]); } $desc_editor = $core->auth->getOption('editor'); $rte_flag = true; $rte_flags = @$core->auth->user_prefs->interface->rte_flags; if (is_array($rte_flags) && in_array('blog_descr', $rte_flags)) { $rte_flag = $rte_flags['blog_descr']; } dcPage::open(__('Blog settings'), '" . dcPage::jsConfirmClose('blog-form') . ($rte_flag ? $core->callBehavior('adminPostEditor', $desc_editor['xhtml'], 'blog_desc', ['#blog_desc'], 'xhtml') : '') . dcPage::jsLoad('js/_blog_pref.js') . # --BEHAVIOR-- adminBlogPreferencesHeaders $core->callBehavior('adminBlogPreferencesHeaders') . dcPage::jsPageTabs(), $breadcrumb ); if ($blog_id) { if (!empty($_GET['add'])) { dcPage::success(__('Blog has been successfully created.')); } if (!empty($_GET['upd'])) { dcPage::success(__('Blog has been successfully updated.')); } echo '
' . '

' . __('Blog parameters') . '

' . '
'; echo '

' . __('Blog details') . '

' . $core->formNonce(); echo '

' . form::field('blog_name', 30, 255, [ 'default' => html::escapeHTML($blog_name), 'extra_html' => 'required placeholder="' . __('Blog name') . '"' ] ) . '

'; echo '

' . form::textarea('blog_desc', 60, 5, html::escapeHTML($blog_desc)) . '

'; if ($core->auth->isSuperAdmin()) { echo '

' . form::combo('blog_status', $status_combo, $blog_status) . '

'; } else { /* Only super admins can change the blog ID and URL, but we need to pass their values to the POST request via hidden html input values so as to allow admins to update other settings. Otherwise dcCore::getBlogCursor() throws an exception. */ echo form::hidden('blog_id', html::escapeHTML($blog_id)) . form::hidden('blog_url', html::escapeHTML($blog_url)); } echo '
'; echo '

' . __('Blog configuration') . '

' . '

' . form::field('editor', 30, 255, html::escapeHTML($blog_settings->system->editor)) . '

' . '

' . form::combo('lang', $lang_combo, $blog_settings->system->lang, 'l10n') . '

' . '

' . form::combo('blog_timezone', dt::getZones(true, true), html::escapeHTML($blog_settings->system->blog_timezone)) . '

' . '

' . form::field('copyright_notice', 30, 255, html::escapeHTML($blog_settings->system->copyright_notice)) . '

' . '
'; echo '

' . __('Comments and trackbacks') . '

' . '
' . '
' . '

' . '

' . '

' . '

' . __('No limit: leave blank.') . '

' . '

' . '

' . '
' . '
' . '

' . '

' . '

' . '

' . __('No limit: leave blank.') . '

' . '

' . '
' . '
' . //Opera sucks '
' . '
' . //Opera sucks '
'; echo '

' . __('Blog presentation') . '

' . '
' . '
' . '

' . form::field('date_format', 30, 255, html::escapeHTML($blog_settings->system->date_format)) . form::combo('date_format_select', $date_formats_combo, ['extra_html' => 'title="' . __('Pattern of date') . '"']) . '

' . '

' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->date_format)) . '

' . '

' . form::field('time_format', 30, 255, html::escapeHTML($blog_settings->system->time_format)) . form::combo('time_format_select', $time_formats_combo, ['extra_html' => 'title="' . __('Pattern of time') . '"']) . '

' . '

' . __('Sample:') . ' ' . dt::str(html::escapeHTML($blog_settings->system->time_format)) . '

' . '

' . '

' . '
' . '
' . '

' . '

' . '

' . '

' . '

' . '

' . '
' . '
' . '
' . //Opera sucks '
'; echo '

' . __('Media and images') . '

' . '

' . __('Please note that if you change current settings bellow, they will now apply to all new images in the media manager.') . ' ' . __('Be carefull if you share it with other blogs in your installation.') . '
' . __('Set -1 to use the default size, set 0 to ignore this thumbnail size (images only).') . '

' . '
' . '
' . '
' . __('Generated image sizes (max dimension in pixels)') . '
' . '

' . form::number('media_img_t_size', [ 'min' => -1, 'max' => 999, 'default' => $blog_settings->system->media_img_t_size ]) . '

' . '

' . form::number('media_img_s_size', [ 'min' => -1, 'max' => 999, 'default' => $blog_settings->system->media_img_s_size ]) . '

' . '

' . form::number('media_img_m_size', [ 'min' => -1, 'max' => 999, 'default' => $blog_settings->system->media_img_m_size ]) . '

' . '
' . __('Default size of the inserted video (in pixels)') . '
' . '

' . form::number('media_video_width', [ 'min' => -1, 'max' => 999, 'default' => $blog_settings->system->media_video_width ]) . '

' . '

' . form::number('media_video_height', [ 'min' => -1, 'max' => 999, 'default' => $blog_settings->system->media_video_height ]) . '

' . '
' . __('Flash player') . '
' . '

' . '

' . __('For flv video, the Flash player will be anyway inserted.') . '

' . '
' . '
' . '
' . __('Default image insertion attributes') . '
' . '

' . form::combo('media_img_title_pattern', $img_title_combo, html::escapeHTML($blog_settings->system->media_img_title_pattern)) . '

' . '

' . '

' . '

' . __('It is retrieved from the picture\'s metadata.') . '

' . '

' . form::combo('media_img_default_size', $img_default_size_combo, (html::escapeHTML($blog_settings->system->media_img_default_size) != '' ? html::escapeHTML($blog_settings->system->media_img_default_size) : 'm')) . '

' . '

' . form::combo('media_img_default_alignment', $img_default_alignment_combo, html::escapeHTML($blog_settings->system->media_img_default_alignment)) . '

' . '

' . '

' . form::combo('media_img_default_legend', $img_default_legend_combo, html::escapeHTML($blog_settings->system->media_img_default_legend)) . '

' . '
' . '
' . '
' . //Opera sucks '
' . '
'; echo '

' . __('Advanced parameters') . '

'; if ($core->auth->isSuperAdmin()) { echo '

' . __('Blog details') . '

'; echo '

' . form::field('blog_id', 30, 32, html::escapeHTML($blog_id), '', '', false, 'required placeholder="' . __('Blog ID') . '"') . '

' . '

' . __('At least 2 characters using letters, numbers or symbols.') . '

' . '

' . __('Please note that changing your blog ID may require changes in your public index.php file.') . '

'; echo '

' . form::url('blog_url', [ 'size' => 50, 'max' => 255, 'default' => html::escapeHTML($blog_url), 'extra_html' => 'required placeholder="' . __('Blog URL') . '"' ]) . '

' . '

' . form::combo('url_scan', $url_scan_combo, $blog_settings->system->url_scan) . '

'; try { # Test URL of blog by testing it's ATOM feed $file = $blog_url . $core->url->getURLFor('feed', 'atom'); $path = ''; $status = '404'; $content = ''; $client = netHttp::initClient($file, $path); if ($client !== false) { $client->setTimeout(4); $client->setUserAgent($_SERVER['HTTP_USER_AGENT']); $client->get($path); $status = $client->getStatus(); $content = $client->getContent(); } if ($status != '200') { // Might be 404 (URL not found), 670 (blog not online), ... echo '

' . sprintf(__('The URL of blog or the URL scan method might not be well set (%s return a %s status).'), html::escapeHTML($file), $status) . '

'; } else { if (substr($content, 0, 6) != '' . sprintf(__('The URL of blog or the URL scan method might not be well set (%s does not return an ATOM feed).'), html::escapeHTML($file)) . '

'; } } } catch (Exception $e) { $core->error->add($e->getMessage()); } echo '
'; } echo '

' . __('Blog configuration') . '

' . '

' . form::combo('post_url_format', $post_url_combo, html::escapeHTML($blog_settings->system->post_url_format)) . '

' . '

' . __('Sample:') . ' ' . $core->blog->getPostURL('', date('Y-m-d H:i:00', $now), __('Dotclear'), 42) . '

' . '

' . '

' . form::combo('note_title_tag', $note_title_tag_combo, $blog_settings->system->note_title_tag) . '

' . '

' . '

' . '

' . __('XML/RPC interface allows you to edit your blog with an external client.') . '

'; if ($blog_settings->system->enable_xmlrpc) { echo '

' . __('XML/RPC interface is active. You should set the following parameters on your XML/RPC client:') . '

' . '
    ' . '
  • ' . __('Server URL:') . ' ' . sprintf(DC_XMLRPC_URL, $core->blog->url, $core->blog->id) . '
  • ' . '
  • ' . __('Blogging system:') . ' Movable Type
  • ' . '
  • ' . __('User name:') . ' ' . $core->auth->userID() . '
  • ' . '
  • ' . __('Password:') . ' <' . __('your password') . '>
  • ' . '
  • ' . __('Blog ID:') . ' 1
  • ' . '
'; } echo '
'; // Search engines policies echo '

' . __('Search engines robots policy') . '

'; $i = 0; foreach ($robots_policy_options as $k => $v) { echo '

'; $i++; } echo '
'; echo '

' . __('jQuery javascript library') . '

' . '

' . ' ' . form::combo('jquery_version', $jquery_versions_combo, $blog_settings->system->jquery_version) . '

' . '
' . //Opera sucks '
'; echo '

' . __('Blog security') . '

' . '

' . '
' . //Opera sucks '
'; echo '
'; // End advanced echo '

' . __('Plugins parameters') . '

'; # --BEHAVIOR-- adminBlogPreferencesForm $core->callBehavior('adminBlogPreferencesForm', $core, $blog_settings); echo '
'; // End 3rd party, aka plugins echo '

' . (!$standalone ? form::hidden('id', $blog_id) : '') . '

' . ''; if ($core->auth->isSuperAdmin() && $blog_id != $core->blog->id) { echo '
' . '

' . form::hidden(['blog_id'], $blog_id) . $core->formNonce() . '

' . '
'; } else { if ($blog_id == $core->blog->id) { echo '

' . __('The current blog cannot be deleted.') . '

'; } else { echo '

' . __('Only superadmin can delete a blog.') . '

'; } } echo '
'; # # Users on the blog (with permissions) $blog_users = $core->getBlogPermissions($blog_id, $core->auth->isSuperAdmin()); $perm_types = $core->auth->getPermissionsTypes(); echo '
' . '

' . __('Users on this blog') . '

'; if (empty($blog_users)) { echo '

' . __('No users') . '

'; } else { if ($core->auth->isSuperAdmin()) { $user_url_p = ' '%1$s'], '&', true) . '">%1$s'; } else { $user_url_p = '%1$s'; } # Sort users list on user_id key dcUtils::lexicalKeySort($blog_users); $post_type = $core->getPostTypes(); $current_blog_id = $core->blog->id; if ($blog_id != $core->blog->id) { $core->setBlog($blog_id); } echo '
'; foreach ($blog_users as $k => $v) { if (count($v['p']) > 0) { echo '
' . '

' . sprintf($user_url_p, html::escapeHTML($k)) . ' (' . html::escapeHTML(dcUtils::getUserCN( $k, $v['name'], $v['firstname'], $v['displayname'] )) . ')

'; if ($core->auth->isSuperAdmin()) { echo '

' . __('Email:') . ' ' . ($v['email'] != '' ? '' . $v['email'] . '' : __('(none)')) . '

'; } echo '
' . __('Publications on this blog:') . '
' . '
    '; foreach ($post_type as $type => $pt_info) { $params = [ 'post_type' => $type, 'user_id' => $k ]; echo '
  • ' . sprintf(__('%1$s: %2$s'), __($pt_info['label']), $core->blog->getPosts($params, true)->f(0)) . '
  • '; } echo '
'; echo '
' . __('Permissions:') . '
' . '
    '; if ($v['super']) { echo '
  • ' . __('Super administrator') . '
    ' . '' . __('All rights on all blogs.') . '
  • '; } else { foreach ($v['p'] as $p => $V) { if (isset($perm_types[$p])) { echo '
  • ' . __($perm_types[$p]); } else { echo '
  • ' . sprintf(__('[%s] (unreferenced permission)'), $p); } if ($p == 'admin') { echo '
    ' . __('All rights on this blog.') . ''; } echo '
  • '; } } echo '
'; if (!$v['super'] && $core->auth->isSuperAdmin()) { echo '
' . '

' . form::hidden(['redir'], $core->adminurl->get("admin.blog.pref", ['id' => $k], '&')) . form::hidden(['action'], 'perms') . form::hidden(['users[]'], $k) . form::hidden(['blogs[]'], $blog_id) . $core->formNonce() . '

' . '
'; } echo '
'; } } echo '
'; if ($current_blog_id != $core->blog->id) { $core->setBlog($current_blog_id); } } echo '
'; } dcPage::helpBlock('core_blog_pref'); dcPage::close();