本文整理汇总了PHP中AppContext::get_content_formatting_service方法的典型用法代码示例。如果您正苦于以下问题:PHP AppContext::get_content_formatting_service方法的具体用法?PHP AppContext::get_content_formatting_service怎么用?PHP AppContext::get_content_formatting_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppContext
的用法示例。
在下文中一共展示了AppContext::get_content_formatting_service方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: second_parse
/**
* @desc Second parses a string with several default parameters. This methods exists to lighten the number of lines written.
* @param string $content Content to second parse
* @return string The second parsed string.
* @see ContentSecondParser
*/
public static function second_parse($content)
{
$parser = AppContext::get_content_formatting_service()->get_default_second_parser();
$parser->set_content($content);
$parser->parse();
return $parser->get_content();
}
示例2: build_form
private function build_form()
{
$picture_yes = '<i class="fa fa-success fa-2x" title="' . LangLoader::get_message('yes', 'common') . '"></i>';
$picture_no = '<i class="fa fa-error fa-2x" title="' . LangLoader::get_message('no', 'common') . '"></i>';
$picture_unknown = '<i class="fa fa-question fa-2x" title="' . LangLoader::get_message('unknown', 'main') . '"></i>';
$default_lang_config = LangsManager::get_lang(LangsManager::get_default_lang())->get_configuration();
$default_theme_config = ThemesManager::get_theme(ThemesManager::get_default_theme())->get_configuration();
$editors = AppContext::get_content_formatting_service()->get_available_editors();
$default_editor = $editors[ContentFormattingConfig::load()->get_default_editor()];
$server_configuration = new ServerConfiguration();
$general_config = GeneralConfig::load();
$server_environment_config = ServerEnvironmentConfig::load();
$sessions_config = SessionsConfig::load();
$maintenance_config = MaintenanceConfig::load();
$url_rewriting_available = false;
$url_rewriting_known = true;
try {
$url_rewriting_available = $server_configuration->has_url_rewriting();
} catch (UnsupportedOperationException $ex) {
$url_rewriting_known = false;
}
$summerization = "---------------------------------System report---------------------------------\n-----------------------------generated by PHPBoost-----------------------------\nSERVER CONFIGURATION-----------------------------------------------------------\nphp version\t\t\t: " . ServerConfiguration::get_phpversion() . "\ndbms version\t\t\t: " . PersistenceContext::get_dbms_utils()->get_dbms_version() . "\ngd library\t\t\t: " . (int) $server_configuration->has_gd_library() . "\nurl rewriting\t\t\t: " . ($url_rewriting_known ? (int) $url_rewriting_available : 'N/A') . "\napcu cache\t\t\t: " . (int) DataStoreFactory::is_apc_available() . "\nPHPBOOST CONFIGURATION---------------------------------------------------------\nphpboost version\t\t: " . Environment::get_phpboost_version() . "\nserver url\t\t\t: " . $general_config->get_site_url() . "\nsite path\t\t\t: " . $general_config->get_site_path() . "\ndefault theme\t\t\t: " . $default_theme_config->get_name() . " (" . LangLoader::get_message('version', 'admin') . " " . $default_theme_config->get_version() . ")\ndefault language\t\t: " . $default_lang_config->get_name() . "\ndefault editor\t\t\t: " . $default_editor . "\nhome page\t\t\t: " . Environment::get_home_page() . "\nurl rewriting\t\t\t: " . (int) $server_environment_config->is_url_rewriting_enabled() . "\napcu cache\t\t\t: " . (int) DataStoreFactory::is_apc_enabled() . "\noutput gzip\t\t\t: " . (int) $server_environment_config->is_output_gziping_enabled() . "\nsession cookie name\t\t: " . $sessions_config->get_cookie_name() . "\nsession duration\t\t: " . $sessions_config->get_session_duration() . "\nactive session duration\t\t: " . $sessions_config->get_active_session_duration() . "\nDIRECTORIES AUTHORIZATIONS-----------------------------------------------------\n";
$form = new HTMLForm('system-report', '', false);
$this->get_advises($form);
$fieldset = new FormFieldsetHTML('report', $this->admin_lang['server']);
$form->add_fieldset($fieldset);
$fieldset->add_field(new FormFieldFree('php_version', $this->admin_lang['php_version'], ServerConfiguration::get_phpversion()));
$fieldset->add_field(new FormFieldFree('dbms_version', $this->admin_lang['dbms_version'], PersistenceContext::get_dbms_utils()->get_dbms_version()));
$fieldset->add_field(new FormFieldFree('gd_library', $this->admin_lang['gd_library'], $server_configuration->has_gd_library() ? $picture_yes : $picture_no));
$fieldset->add_field(new FormFieldFree('url_rewriting', $this->admin_lang['url_rewriting'], $url_rewriting_known ? $url_rewriting_available ? $picture_yes : $picture_no : $picture_unknown));
$fieldset->add_field(new FormFieldFree('apcu_cache', LangLoader::get_message('apcu_cache', 'admin-cache-common'), DataStoreFactory::is_apc_available() ? $picture_yes : $picture_no));
$fieldset = new FormFieldsetHTML('report', $this->admin_lang['phpboost_config']);
$form->add_fieldset($fieldset);
$fieldset->add_field(new FormFieldFree('kernel_version', $this->admin_lang['kernel_version'], Environment::get_phpboost_version()));
$fieldset->add_field(new FormFieldFree('site_url', LangLoader::get_message('advanced-config.site_url', 'admin-config-common'), $general_config->get_site_url()));
$fieldset->add_field(new FormFieldFree('site_path', LangLoader::get_message('advanced-config.site_path', 'admin-config-common'), $general_config->get_site_path()));
$fieldset->add_field(new FormFieldFree('default_theme', LangLoader::get_message('general-config.default_theme', 'admin-config-common'), $default_theme_config->get_name() . " (" . LangLoader::get_message('version', 'admin') . " " . $default_theme_config->get_version() . ")"));
$fieldset->add_field(new FormFieldFree('default_language', LangLoader::get_message('general-config.default_language', 'admin-config-common'), $default_lang_config->get_name()));
$fieldset->add_field(new FormFieldFree('default_editor', LangLoader::get_message('content.config.default-formatting-language', 'admin-contents-common'), $default_editor));
$fieldset->add_field(new FormFieldFree('start_page', LangLoader::get_message('general-config.start_page', 'admin-config-common'), Environment::get_home_page()));
$fieldset->add_field(new FormFieldFree('phpboost_url_rewriting', $this->admin_lang['url_rewriting'], $server_environment_config->is_url_rewriting_enabled() ? $picture_yes : $picture_no));
$fieldset->add_field(new FormFieldFree('phpboost_apcu_cache', LangLoader::get_message('apcu_cache', 'admin-cache-common'), DataStoreFactory::is_apc_enabled() ? $picture_yes : $picture_no));
$fieldset->add_field(new FormFieldFree('output_gz', $this->admin_lang['output_gz'], $server_environment_config->is_output_gziping_enabled() ? $picture_yes : $picture_no));
$fieldset->add_field(new FormFieldFree('cookie_name', LangLoader::get_message('advanced-config.cookie-name', 'admin-config-common'), $sessions_config->get_cookie_name()));
$fieldset->add_field(new FormFieldFree('session_length', LangLoader::get_message('advanced-config.cookie-duration', 'admin-config-common'), $sessions_config->get_session_duration()));
$fieldset->add_field(new FormFieldFree('session_guest_length', LangLoader::get_message('advanced-config.active-session-duration', 'admin-config-common'), $sessions_config->get_active_session_duration()));
$fieldset = new FormFieldsetHTML('directories_auth', $this->admin_lang['directories_auth']);
$form->add_fieldset($fieldset);
$directories_summerization = '';
foreach (PHPBoostFoldersPermissions::get_permissions() as $key => $folder) {
$fieldset->add_field(new FormFieldFree(str_replace('/', '_', $key), $key, $folder->is_writable() ? $picture_yes : $picture_no));
$directories_summerization .= $key . str_repeat(' ', 5 - strlen($key) / 8) . ": " . (int) $folder->is_writable() . "\n";
}
$fieldset = new FormFieldsetHTML('summerization', $this->admin_lang['system_report_summerization']);
$form->add_fieldset($fieldset);
$fieldset->add_field(new FormFieldLabel($this->admin_lang['system_report_summerization_explain']));
$fieldset->add_field(new FormFieldMultiLineTextEditor('summerization', '', $summerization . $directories_summerization, array('rows' => 20, 'cols' => 15, 'class' => 'system-report')));
$this->form = $form;
}
示例3: generate_options
private function generate_options()
{
$options = array();
foreach (AppContext::get_content_formatting_service()->get_available_editors() as $id => $name) {
$options[] = new FormFieldSelectChoiceOption($name, $id);
}
return $options;
}
示例4: wiki_unparse
function wiki_unparse($var)
{
//Unparse de la balise link
$var = preg_replace('`<a href="/wiki/([a-z0-9+#-_]+)">(.*)</a>`sU', "[link=\$1]\$2[/link]", $var);
//On force le langage de formatage à BBCode
$content_manager = AppContext::get_content_formatting_service()->get_default_factory();
$unparser = $content_manager->get_unparser();
$unparser->set_content($var);
$unparser->parse();
return $unparser->get_content();
}
示例5: build_form
private function build_form(HTTPRequestCustom $request)
{
$config = GuestbookConfig::load();
$formatter = AppContext::get_content_formatting_service()->get_default_factory();
$formatter->set_forbidden_tags($config->get_forbidden_tags());
$form = new HTMLForm(__CLASS__);
$fieldset = new FormFieldsetHTML('message', $this->is_new_message ? $this->lang['guestbook.add'] : $this->lang['guestbook.edit']);
$form->add_fieldset($fieldset);
if (!AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
$fieldset->add_field(new FormFieldTextEditor('pseudo', LangLoader::get_message('form.name', 'common'), $this->get_message()->get_login(), array('required' => true, 'maxlength' => 25)));
}
$fieldset->add_field(new FormFieldRichTextEditor('contents', LangLoader::get_message('message', 'main'), $this->get_message()->get_contents(), array('formatter' => $formatter, 'rows' => 10, 'cols' => 47, 'required' => true), array(new FormFieldConstraintMaxLinks($config->get_maximum_links_message(), true), new FormFieldConstraintAntiFlood(GuestbookService::get_last_message_timestamp_from_user($this->get_message()->get_author_user()->get_id())))));
$fieldset->add_field(new FormFieldHidden('page', $request->get_getint('page', 1)));
$this->submit_button = new FormButtonDefaultSubmit();
$form->add_button($this->submit_button);
$form->add_button(new FormButtonReset());
$this->form = $form;
}
示例6: define
define('TITLE', $LANG['alert_topic']);
require_once '../kernel/header.php';
if (empty($alert) && empty($alert_post) || empty($topic['idcat'])) {
AppContext::get_response()->redirect('/forum/index' . url('.php'));
}
if (!AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
$error_controller = PHPBoostErrors::user_not_authorized();
DispatchManager::redirect($error_controller);
}
$tpl = new FileTemplate('forum/forum_alert.tpl');
//On fait un formulaire d'alerte
if (!empty($alert) && empty($alert_post)) {
//On vérifie qu'une alerte sur le même sujet n'ait pas été postée
$nbr_alert = PersistenceContext::get_querier()->count(PREFIX . 'forum_alerts', 'WHERE idtopic=:idtopic AND status = 0', array('idtopic' => $alert));
if (empty($nbr_alert)) {
$editor = AppContext::get_content_formatting_service()->get_default_editor();
$editor->set_identifier('contents');
$tpl->put_all(array('KERNEL_EDITOR' => $editor->display(), 'L_ALERT' => $LANG['alert_topic'], 'L_ALERT_EXPLAIN' => $LANG['alert_modo_explain'], 'L_ALERT_TITLE' => $LANG['alert_title'], 'L_ALERT_CONTENTS' => $LANG['alert_contents'], 'L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_REQUIRE_TEXT' => $LANG['require_text'], 'L_REQUIRE_TITLE' => $LANG['require_title']));
$tpl->assign_block_vars('alert_form', array('TITLE' => $topic_name, 'U_TOPIC' => 'topic' . url('.php?id=' . $alert, '-' . $alert . '-' . Url::encode_rewrite($topic_name) . '.php'), 'ID_ALERT' => $alert));
} else {
$tpl->put_all(array('L_ALERT' => $LANG['alert_topic'], 'L_BACK_TOPIC' => $LANG['alert_back'], 'URL_TOPIC' => 'topic' . url('.php?id=' . $alert, '-' . $alert . '-' . Url::encode_rewrite($topic_name) . '.php')));
$tpl->assign_block_vars('alert_confirm', array('MSG' => $LANG['alert_topic_already_done']));
}
}
//Si on enregistre une alerte
if (!empty($alert_post)) {
$tpl->put_all(array('L_ALERT' => $LANG['alert_topic'], 'L_BACK_TOPIC' => $LANG['alert_back'], 'URL_TOPIC' => 'topic' . url('.php?id=' . $alert_post, '-' . $alert_post . '-' . Url::encode_rewrite($topic_name) . '.php')));
//On vérifie qu'une alerte sur le même sujet n'ait pas été postée
$nbr_alert = PersistenceContext::get_querier()->count(PREFIX . 'forum_alerts', 'WHERE idtopic=:idtopic AND status = 0', array('idtopic' => $alert_post));
if (empty($nbr_alert)) {
$alert_title = retrieve(POST, 'title', '');
示例7: uninstall
public function uninstall()
{
return AppContext::get_content_formatting_service()->uninstall_editor('bbcode');
}
示例8: get_formatter
private function get_formatter()
{
$formatter = AppContext::get_content_formatting_service()->get_default_factory();
$formatter->set_forbidden_tags($this->comments_configuration->get_forbidden_tags());
return $formatter;
}
示例9: update_module
public static function update_module($module_id, $activated)
{
$error = '';
if (!$activated) {
MenuService::delete_mini_module($module_id);
MenuService::delete_module_feeds_menus($module_id);
$general_config = GeneralConfig::load();
$module_home_page_selected = $general_config->get_module_home_page();
if ($module_home_page_selected == $module_id) {
$general_config->set_module_home_page('');
$general_config->set_other_home_page('index.php');
}
$editors = AppContext::get_content_formatting_service()->get_available_editors();
if (in_array($module_id, $editors)) {
if (count($editors) > 1) {
$default_editor = ContentFormattingConfig::load()->get_default_editor();
if ($default_editor !== $module_id) {
PersistenceContext::get_querier()->update(DB_TABLE_MEMBER, array('editor' => $default_editor), 'WHERE editor=:old_editor', array('old_editor' => 'bbcode'));
} else {
$error = LangLoader::get_message('is_default_editor', 'editor-common');
}
} else {
$error = LangLoader::get_message('last_editor_installed', 'editor-common');
}
}
} else {
$module = self::get_module($module_id);
if ($module->get_configuration()->get_compatibility() != GeneralConfig::load()->get_phpboost_major_version()) {
$error = LangLoader::get_message('modules.not_compatible', 'admin-modules-common');
}
}
if (empty($error)) {
$module = self::get_module($module_id);
$module->set_activated($activated);
ModulesConfig::load()->update($module);
ModulesConfig::save();
MenuService::generate_cache();
Feed::clear_cache($module_id);
if (ServerEnvironmentConfig::load()->is_url_rewriting_enabled()) {
HtaccessFileCache::regenerate();
}
}
return $error;
}
示例10: define
*
###################################################*/
define('PATH_TO_ROOT', '../../..');
include_once PATH_TO_ROOT . '/kernel/begin.php';
AppContext::get_session()->no_session_location();
//Permet de ne pas mettre jour la page dans la session.
include_once PATH_TO_ROOT . '/kernel/header_no_display.php';
$page_path_to_root = retrieve(REQUEST, 'path_to_root', '');
$page_path = retrieve(REQUEST, 'page_path', '');
//Quel éditeur utiliser ? Si ce n'est pas précisé on prend celui par défaut de l'utilisateur
$editor = retrieve(REQUEST, 'editor', ContentFormattingConfig::load()->get_default_editor());
$contents = TextHelper::htmlentities(retrieve(POST, 'contents', ''), ENT_COMPAT, 'UTF-8');
$contents = TextHelper::htmlspecialchars_decode(stripslashes(TextHelper::html_entity_decode($contents)));
$ftags = retrieve(POST, 'ftags', TSTRING_UNCHANGE);
$forbidden_tags = explode(',', $ftags);
$formatting_factory = AppContext::get_content_formatting_service()->create_factory($editor);
//On prend le bon parseur avec la bonne configuration
$parser = $formatting_factory->get_parser();
$parser->set_content($contents);
$parser->set_path_to_root($page_path_to_root);
$parser->set_page_path($page_path);
if (!empty($forbidden_tags)) {
$parser->set_forbidden_tags($forbidden_tags);
}
$parser->parse();
//On parse la deuxième couche (code, math etc) pour afficher
$second_parser = $formatting_factory->get_second_parser();
$second_parser->set_content($parser->get_content());
$second_parser->set_path_to_root($page_path_to_root);
$second_parser->set_page_path($page_path);
$second_parser->parse();
示例11: generate_forbidden_tags_option
private function generate_forbidden_tags_option()
{
$options = array();
$available_tags = AppContext::get_content_formatting_service()->get_available_tags();
foreach ($available_tags as $identifier => $name) {
$options[] = new FormFieldSelectChoiceOption($name, $identifier);
}
return $options;
}
示例12: __construct
/**
* @desc Constructs a rich text edit field.
* In addition to the parameters of the FormMultiLineEdit ones, there is the formatter which
* is an instance of the ContentFormattingFactory which ensures the formatting. The default value
* corresponds to the user's default configuration and will be the one to use 99% of the time.
* @param string $id Field id
* @param string $label Field label
* @param string $value Default value
* @param string[] $field_options options
* @param FormFieldConstraint[] $constraints The constraints
*/
public function __construct($id, $label, $value, array $field_options = array(), array $constraints = array())
{
$this->formatter = AppContext::get_content_formatting_service()->get_default_factory();
parent::__construct($id, $label, '', $field_options, $constraints);
$this->set_value($value);
}