本文整理汇总了PHP中TextHelper类的典型用法代码示例。如果您正苦于以下问题:PHP TextHelper类的具体用法?PHP TextHelper怎么用?PHP TextHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_position
private function update_position($request)
{
$fields_list = json_decode(TextHelper::html_entity_decode($request->get_value('tree')));
foreach ($fields_list as $position => $tree) {
PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER_EXTENDED_FIELDS_LIST . " SET \r\n\t\t\t\tposition = :position\r\n\t\t\t\tWHERE id = :id", array('position' => $position, 'id' => $tree->id));
}
}
示例2: load_lang
protected function load_lang(HTTPRequestCustom $request)
{
$locale = TextHelper::htmlspecialchars($request->get_string('lang', UpdateController::DEFAULT_LOCALE));
LangLoader::set_locale($locale);
UpdateUrlBuilder::set_locale($locale);
$this->lang = LangLoader::get('update', 'update');
}
示例3: getValue
function getValue($filtered = true)
{
$values = explode($this->separator, $this->_value);
$tags = array();
foreach ($values as &$value) {
$value = trim($value);
if ($value != '') {
if ($this->_filter && $filtered) {
$value = call_user_func($this->_filter, $value, $this->getName());
}
$tags[] = $value;
}
}
$ids = array();
foreach ($tags as $tag) {
$ds = new TableReader('blog_tag');
$id = $ds->select('blog_tag_id')->where('tag', $tag)->fetchScalar();
if (!$id) {
$writer = new TableWriter('blog_tag');
$id = $writer->insert(array('tag' => $tag, 'url_tag' => TextHelper::urlize($tag)));
}
$ids[] = $id;
}
return $ids;
}
示例4: register_archive
private static function register_archive($language_type, $title, $contents, $id_cat)
{
$number_subscribers = self::number_subscribers($id_cat);
$title = TextHelper::strprotect($title, TextHelper::HTML_NO_PROTECT, TextHelper::ADDSLASHES_FORCE);
$contents = TextHelper::strprotect($contents, HTML_NO_PROTECT, ADDSLASHES_FORCE);
self::$db_querier->inject("INSERT INTO " . NewsletterSetup::$newsletter_table_archive . " (id_cat, title, contents, timestamp, type, subscribers)\r\n\t\t\tVALUES (:id_cat, :title, :contents, :timestamp, :type, :field_type, :subscribers)", array('id_cat' => $id_cat, 'title' => $title, 'contents' => $contents, 'timestamp' => time(), 'type' => $language_type, 'subscribers' => 0));
}
示例5: build_table
private function build_table()
{
$table_model = new SQLHTMLTableModel(CalendarSetup::$calendar_events_table, 'table', array(new HTMLTableColumn(LangLoader::get_message('form.title', 'common'), 'title'), new HTMLTableColumn(LangLoader::get_message('category', 'categories-common'), 'id_category'), new HTMLTableColumn(LangLoader::get_message('author', 'common'), 'display_name'), new HTMLTableColumn(LangLoader::get_message('date', 'date-common'), 'start_date'), new HTMLTableColumn($this->lang['calendar.titles.repetition']), new HTMLTableColumn('')), new HTMLTableSortingRule('start_date', HTMLTableSortingRule::ASC));
$table_model->set_caption($this->lang['calendar.events_list']);
$table_model->add_permanent_filter('parent_id = 0');
$table_model->add_filter(new HTMLTableDateTimeGreaterThanOrEqualsToSQLFilter('start_date', 'filter1', $this->lang['calendar.labels.start_date'] . ' ' . TextHelper::lowercase_first(LangLoader::get_message('minimum', 'common'))));
$table_model->add_filter(new HTMLTableDateTimeLessThanOrEqualsToSQLFilter('start_date', 'filter2', $this->lang['calendar.labels.start_date'] . ' ' . TextHelper::lowercase_first(LangLoader::get_message('maximum', 'common'))));
$table = new HTMLTable($table_model);
$table->set_filters_fieldset_class_HTML();
$results = array();
$result = $table_model->get_sql_results('event
LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id');
foreach ($result as $row) {
$event = new CalendarEvent();
$event->set_properties($row);
$category = $event->get_content()->get_category();
$user = $event->get_content()->get_author_user();
$edit_link = new LinkHTMLElement(CalendarUrlBuilder::edit_event(!$event->get_parent_id() ? $event->get_id() : $event->get_parent_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit');
$delete_link = new LinkHTMLElement(CalendarUrlBuilder::delete_event($event->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => !$event->belongs_to_a_serie() ? 'delete-element' : ''), 'fa fa-delete');
$user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
$author = $user->get_id() !== User::VISITOR_LEVEL ? new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level())) : $user->get_display_name();
$br = new BrHTMLElement();
$results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $event->get_id(), $event->get_content()->get_rewrited_title()), $event->get_content()->get_title()), 'left'), new HTMLTableRowCell(new SpanHTMLElement($category->get_name(), array('style' => $category->get_id() != Category::ROOT_CATEGORY && $category->get_color() ? 'color:' . $category->get_color() : ''))), new HTMLTableRowCell($author), new HTMLTableRowCell(LangLoader::get_message('from_date', 'main') . ' ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . $br->display() . LangLoader::get_message('to_date', 'main') . ' ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell($event->belongs_to_a_serie() ? $this->get_repeat_type_label($event) . ' - ' . $event->get_content()->get_repeat_number() . ' ' . $this->lang['calendar.labels.repeat_times'] : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display())));
}
$table->set_rows($table_model->get_number_of_matching_rows(), $results);
$this->view->put('table', $table->display());
}
示例6: parse
public function parse()
{
$this->content = TextHelper::html_entity_decode($this->content);
foreach (static::$parsers as $parser) {
$this->content = $parser->unparse($this->content);
}
}
示例7: getAchievementsDefinitions
public static function getAchievementsDefinitions()
{
$dir = Config::$achievementsDefinitionsDirectory;
$imgFiles = scandir(Config::$imageDirectory . DIRECTORY_SEPARATOR . 'achievement');
$definitions = array_fill_keys(Media::getConstList(), []);
foreach (glob($dir . DIRECTORY_SEPARATOR . '*.json') as $file) {
$definition = TextHelper::loadJson($file);
$prevAch = null;
foreach ($definition->achievements as &$ach) {
foreach ($imgFiles as $f) {
if (preg_match('/' . $ach->id . '[^0-9a-zA-Z_-]/', $f)) {
$ach->path = $f;
}
}
$ach->next = null;
}
foreach ($definition->achievements as &$ach) {
if ($prevAch !== null) {
$prevAch->next = $ach;
}
$ach->prev = $prevAch;
$prevAch =& $ach;
}
unset($ach);
unset($prevAch);
$definitions[$definition->media][] = $definition;
}
foreach (Media::getConstList() as $key) {
uasort($definitions[$key], function ($a, $b) {
return $a->order - $b->order;
});
}
return $definitions;
}
示例8: find_by_criteria
/**
* @desc Builds a list of alerts matching the required criteria(s). You can specify many criterias. When you use several of them, it's a AND condition.
* It will only return the alert which match all the criterias.
* @param int $id_in_module Id in the module.
* @param string $type Alert type.
* @param string $identifier Alert identifier.
* @return AdministratorAlert[] The list of the matching alerts.
*/
public static function find_by_criteria($id_in_module = null, $type = null, $identifier = null)
{
$criterias = array();
if ($id_in_module != null) {
$criterias[] = "id_in_module = '" . intval($id_in_module) . "'";
}
if ($type != null) {
$criterias[] = "type = '" . TextHelper::strprotect($type) . "'";
}
if ($identifier != null) {
$criterias[] = "identifier = '" . TextHelper::strprotect($identifier) . "'";
}
//Restrictive criteria
if (!empty($criterias)) {
$array_result = array();
$result = self::$db_querier->select("SELECT id, entitled, fixing_url, current_status, creation_date, identifier, id_in_module, type, priority, description\n\t\t\tFROM " . DB_TABLE_EVENTS . "\n\t\t\tWHERE contribution_type = '" . ADMINISTRATOR_ALERT_TYPE . "' AND " . implode($criterias, " AND "));
while ($row = $result->fetch()) {
$alert = new AdministratorAlert();
$alert->build($row['id'], $row['entitled'], $row['description'], $row['fixing_url'], $row['current_status'], new Date($row['creation_date'], Timezone::SERVER_TIMEZONE), $row['id_in_module'], $row['identifier'], $row['type'], $row['priority']);
$array_result[] = $alert;
}
$result->dispose();
return $array_result;
} else {
return AdministratorAlertCache::load()->get_all_alerts_number();
}
}
示例9: parse
static function parse($path, $replacements = array(), &$substitutions = array())
{
$path = self::replaceUploadsDir($path);
$matches1 = array();
preg_match_all('/{(appd|uploads|public|random|date|root)(?:\\[([0-9a-zA-Z-_]+)\\])?}/', $path, $matches1, PREG_SET_ORDER);
$matches2 = array();
$expression = implode('|', array_keys($replacements));
preg_match_all('/{(' . $expression . ')(?:\\[([0-9a-zA-Z-_]+)\\])?}/', $path, $matches2, PREG_SET_ORDER);
$matches = array_merge($matches1, $matches2);
foreach ($matches as $match) {
if (isset($replacements[$match[1]])) {
$substitutions[$match[0]] = $replacements[$match[1]];
if (isset($match[2])) {
if (is_numeric($match[2])) {
$substitutions[$match[0]] = substr($substitutions[$match[0]], 0, $match[2]);
} elseif (is_callable($match[2])) {
$substitutions[$match[0]] = call_user_func($match[2], $substitutions[$match[0]]);
} elseif ($match[2] == 'url') {
$substitutions[$match[0]] = TextHelper::urlize($substitutions[$match[0]]);
}
}
} else {
$param = isset($match[2]) ? $match[2] : null;
$substitutions[$match[0]] = self::replace($match[1], $param);
}
}
return str_replace(array_keys($substitutions), array_values($substitutions), $path);
}
示例10: test_named_cycles
function test_named_cycles()
{
$this->assertEqual('odd', TextHelper::cycle(array('odd', 'even', 'name' => '1st')));
$this->assertEqual('red', TextHelper::cycle('red', 'black'));
$this->assertEqual('even', TextHelper::cycle(array('odd', 'even', 'name' => '1st')));
$this->assertEqual('black', TextHelper::cycle('red', 'black'));
}
示例11: __construct
public function __construct($error_message = '')
{
if (empty($error_message)) {
$error_message = LangLoader::get_message('form.doesnt_match_tel_regex', 'status-messages-common');
}
$this->set_validation_error_message($error_message);
parent::__construct(self::$regex, TextHelper::to_js_string(self::$js_regex), $error_message);
}
示例12: load_lang
protected function load_lang(HTTPRequestCustom $request)
{
$locale = TextHelper::htmlspecialchars($request->get_string('lang', self::DEFAULT_LOCALE));
$locale = in_array($locale, InstallationServices::get_available_langs()) ? $locale : self::DEFAULT_LOCALE;
LangLoader::set_locale($locale);
InstallUrlBuilder::set_locale($locale);
$this->lang = LangLoader::get('install', 'install');
}
示例13: Add_msg
function Add_msg($idtopic, $idcat, $contents, $title, $last_page, $last_page_rewrite, $new_topic = false)
{
global $LANG;
##### Insertion message #####
$last_timestamp = time();
$result = PersistenceContext::get_querier()->insert(PREFIX . 'forum_msg', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id(), 'contents' => FormatingHelper::strparse($contents), 'timestamp' => $last_timestamp, 'timestamp_edit' => 0, 'user_id_edit' => 0, 'user_ip' => AppContext::get_request()->get_ip_address()));
$last_msg_id = $result->get_last_inserted_id();
//Topic
PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET " . ($new_topic ? '' : 'nbr_msg = nbr_msg + 1, ') . "last_user_id = '" . AppContext::get_current_user()->get_id() . "', last_msg_id = '" . $last_msg_id . "', last_timestamp = '" . $last_timestamp . "' WHERE id = '" . $idtopic . "'");
//On met à jour le last_topic_id dans la catégorie dans le lequel le message a été posté
PersistenceContext::get_querier()->update(ForumSetup::$forum_cats_table, array('last_topic_id' => $idtopic), 'WHERE id = :id', array('id' => $idcat));
//Mise à jour du nombre de messages du membre.
PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER . " SET posted_msg = posted_msg + 1 WHERE user_id = '" . AppContext::get_current_user()->get_id() . "'");
//On marque le topic comme lu.
mark_topic_as_read($idtopic, $last_msg_id, $last_timestamp);
##### Gestion suivi du sujet mp/mail #####
if (!$new_topic) {
//Message précédent ce nouveau message.
$previous_msg_id = 0;
try {
$previous_msg_id = PersistenceContext::get_querier()->get_column_value(PREFIX . "forum_msg", 'MAX(id)', 'WHERE idtopic = :idtopic AND id < :id', array('idtopic' => $idtopic, 'id' => $last_msg_id));
} catch (RowNotFoundException $e) {
}
$title_subject = TextHelper::html_entity_decode($title);
$title_subject_pm = $title_subject;
if (AppContext::get_current_user()->get_id() > 0) {
$pseudo = '';
try {
$pseudo = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'display_name', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id()));
} catch (RowNotFoundException $e) {
}
$pseudo_pm = '<a href="' . UserUrlBuilder::profile(AppContext::get_current_user()->get_id())->rel() . '">' . $pseudo . '</a>';
} else {
$pseudo = $LANG['guest'];
$pseudo_pm = $LANG['guest'];
}
$next_msg_link = '/forum/topic' . url('.php?id=' . $idtopic . $last_page, '-' . $idtopic . $last_page_rewrite . '.php') . ($previous_msg_id ? '#m' . $previous_msg_id : '');
$preview_contents = substr($contents, 0, 300);
//Récupération des membres suivant le sujet.
$max_time = time() - SessionsConfig::load()->get_active_session_duration();
$result = PersistenceContext::get_querier()->select("SELECT m.user_id, m.display_name, m.email, tr.pm, tr.mail, v.last_view_id\n\t\t\tFROM " . PREFIX . "forum_track tr\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = tr.user_id\n\t\t\tLEFT JOIN " . PREFIX . "forum_view v ON v.idtopic = :idtopic AND v.user_id = tr.user_id\n\t\t\tWHERE tr.idtopic = :idtopic AND v.last_view_id IS NOT NULL AND m.user_id != :user_id", array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id()));
while ($row = $result->fetch()) {
//Envoi un Mail à ceux dont le last_view_id est le message précedent.
if ($row['last_view_id'] == $previous_msg_id && $row['mail'] == '1') {
AppContext::get_mail_service()->send_from_properties($row['email'], $LANG['forum_mail_title_new_post'], sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject, AppContext::get_current_user()->get_display_name(), $preview_contents, HOST . DIR . $next_msg_link, HOST . DIR . '/forum/action.php?ut=' . $idtopic . '&trt=1', 1));
}
//Envoi un MP à ceux dont le last_view_id est le message précedent.
if ($row['last_view_id'] == $previous_msg_id && $row['pm'] == '1') {
$content = sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject_pm, AppContext::get_current_user()->get_display_name(), $preview_contents, '<a href="' . $next_msg_link . '">' . $next_msg_link . '</a>', '<a href="/forum/action.php?ut=' . $idtopic . '&trt=2">/forum/action.php?ut=' . $idtopic . '&trt=2</a>');
PrivateMsg::start_conversation($row['user_id'], $LANG['forum_mail_title_new_post'], nl2br($content), '-1', PrivateMsg::SYSTEM_PM);
}
}
$result->dispose();
forum_generate_feeds();
//Regénération du flux rss.
}
return $last_msg_id;
}
示例14: get_message
private function get_message()
{
$msg = $this->error_message;
if ($this->input != null) {
$msg .= "\n" . 'line ' . $this->tpl_line . ' offset ' . $this->offset . ' near';
$msg .= ' "...' . TextHelper::htmlentities($this->input->to_string(-100, 200)) . '..."';
}
return $msg;
}
示例15: modelTranslator
public static function modelTranslator($json, $lang)
{
if (TextHelper::isJson($json)) {
$array = json_decode($json, true);
return $array[$lang];
} else {
return $json;
}
}